summaryrefslogtreecommitdiffstats
path: root/uninstall
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2022-07-01 16:30:56 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2022-07-01 16:32:32 +0900
commit51fdaad002a5ad827bd5ebfac43386592005d02c (patch)
tree6efb57d73a256fbf17af122cbf6c85489f60baf9 /uninstall
parent885cd8ff04e73d61279f0ac58011f74613e809dd (diff)
[uninstall] Remove readlink to support relative symlinks of dotfiles
Close #2853
Diffstat (limited to 'uninstall')
-rwxr-xr-xuninstall14
1 files changed, 5 insertions, 9 deletions
diff --git a/uninstall b/uninstall
index 094d6891..4e587211 100755
--- a/uninstall
+++ b/uninstall
@@ -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"