2
0
mirror of https://github.com/junegunn/fzf synced 2024-11-16 12:12:48 +00:00

[uninstall] Remove readlink to support relative symlinks of dotfiles

Close #2853
This commit is contained in:
Junegunn Choi 2022-07-01 16:30:56 +09:00
parent 885cd8ff04
commit 51fdaad002
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627

View File

@ -51,13 +51,8 @@ remove() {
}
remove_line() {
src=$(readlink "$1")
if [ $? -eq 0 ]; then
echo "Remove from $1 ($src):"
else
src=$1
echo "Remove from $1:"
fi
src=$1
echo "Remove from $1:"
shift
line_no=1
@ -75,8 +70,9 @@ remove_line() {
echo " - Line #$line_no: $content"
[ "$content" = "$1" ] || ask " - Remove?"
if [ $? -eq 0 ]; then
awk -v n=$line_no 'NR == n {next} {print}' "$src" > "$src.bak" &&
mv "$src.bak" "$src" || break
temp=$(mktemp)
awk -v n=$line_no 'NR == n {next} {print}' "$src" > "$temp" &&
cat "$temp" > "$src" && rm -f "$temp" || break
echo " - Removed"
else
echo " - Skipped"