diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2023-01-24 17:34:37 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2023-01-27 15:16:04 -0700 |
commit | 8fa508f6f7fa1fd695e943cdf809d5f5209dabf3 (patch) | |
tree | 9e0b7798bd36cdd7d1e6e57cd577f6f19460fc65 /bin/hstow | |
parent | 2e0cb5415ea526e9357c9176c2a327d0a3500ea8 (diff) | |
download | dotfiles-8fa508f6f7fa1fd695e943cdf809d5f5209dabf3.tar.gz |
hstow: just remove empty directories that are in our way
Diffstat (limited to 'bin/hstow')
-rwxr-xr-x | bin/hstow | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -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" |