diff --git a/commands/dorothy b/commands/dorothy index 9fc9300c6..999828add 100755 --- a/commands/dorothy +++ b/commands/dorothy @@ -328,6 +328,11 @@ function dorothy_() ( uname -r | grep --quiet --ignore-case --fixed-strings --regexp='manjaro' } + # see [commands/is-alpine] for details + function __is_alpine { + test -f /etc/os-release && grep --quiet --ignore-case --regexp='ID=alpine' /etc/os-release 2>/dev/null; + } + # see [commands/fs-realpath] for details function __fs_realpath { # options @@ -638,7 +643,15 @@ function dorothy_() ( function relocate_then_symlink_if_necessary { local symlink="$1" destination="$2" relocate_if_necessary "$symlink" "$destination" - ln -sfF "$destination" "$symlink" + if __is_alpine; then + # alpine doesn't support -F, however the removals of relocate_if_necessary should make it unnecessary + ln -sf "$destination" "$symlink" + else + # -F: replace symlink if directory if needed + # -f: unlink symlink path if needed + # -s: symbolic link + ln -sfF "$destination" "$symlink" + fi # cleanup accidents symlink="$symlink/$(basename "$destination")" if test -L "$symlink"; then diff --git a/commands/symlink-helper b/commands/symlink-helper index c78e150ad..0643b0890 100755 --- a/commands/symlink-helper +++ b/commands/symlink-helper @@ -152,13 +152,22 @@ function symlink_helper() ( # not a symlink, confirm with the user what to do fs-rm --confirm -- "$option_symlink" fi + elif test -L "$option_symlink"; then + # is a broken symlink, drop it and recreate + rm "$option_symlink" fi # create the symlink # -F: replace symlink if directory if needed # -f: unlink symlink path if needed - # -s: symbolik link - ln -sfF "$option_existing" "$option_symlink" + # -s: symbolic link + if is-alpine; then + # alpine doesn't support -F, however the above removals should make it unnecessary + # https://github.com/bevry/dorothy/actions/runs/11323459946/job/31486170602#step:4:11 + ln -sf "$option_existing" "$option_symlink" + else + ln -sfF "$option_existing" "$option_symlink" + fi # log result to stderr echo-style --success="👍 Symlink created at " --code="$option_symlink" --bold=" targetting " --code="$option_existing"