From 8fa508f6f7fa1fd695e943cdf809d5f5209dabf3 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 24 Jan 2023 17:34:37 -0700 Subject: hstow: just remove empty directories that are in our way --- bin/hstow | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'bin/hstow') diff --git a/bin/hstow b/bin/hstow index 9e2e42c2..8da39a47 100755 --- a/bin/hstow +++ b/bin/hstow @@ -162,19 +162,19 @@ stow1 () { | while read -r link file file_dir adopt target link_target; do if [ "$target" = "$link_target" ]; then continue - elif [ -z "$link_target" -a ! -h "$file" -a -f "$link" ]; then - if $adopt; then - mv -f "$link" "$file" - ln -s "$target" "$link" - else - echo "$file" # into $conflicts - fi - elif [ -n "$link_target" ]; then + elif [ -n "$link_target" ]; then # implies $link is a symlink # With at least GNU ln(1), passing -f, but not also -T, does # not replace an existing link in some cases. # -T is not POSIX, so we remove any existing link first. rm "$link" ln -s "$target" "$link" + elif $adopt && [ ! -h "$file" -a -f "$link" ]; then + mv -f "$link" "$file" + ln -s "$target" "$link" + elif [ -d "$link" ] && rmdir "$link" 2>/dev/null; then + ln -s "$target" "$link" + elif [ -e "$link" ]; then + echo "$file" # into $conflicts else mkdir -p "$HOME/$file_dir" ln -s "$target" "$link" -- cgit v1.2.3