From d9fba2b35d8e6aa44ab081386eec3eba85f80068 Mon Sep 17 00:00:00 2001 From: kento2 Date: Wed, 11 Mar 2026 01:21:38 +0100 Subject: [PATCH] fix add.sh + add EEXIST-error --- add.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/add.sh b/add.sh index f172ba9..a13e3c8 100755 --- a/add.sh +++ b/add.sh @@ -6,20 +6,21 @@ test -d files/ || { } for arg in $@; do - arg="$(realpath "$arg")" - file="${arg#"$HOME"}" + arg="$(realpath -s "$arg")" + file="${arg#"$HOME"/}" test "$arg" != "$file" || { - >&2 echo "$f is not in $HOME" + >&2 echo "$file is not in $HOME" continue } - test -e "files/$file" && { - >&2 echo "$f is already added" + test ! -e "files/$file" || { + >&2 echo "$file is already added" continue } mkdir -vp "files/$(dirname "$file")" mv -iv "$arg" "files/$file" ln -vfs "$(realpath "files/$file")" "$arg" + echo "added" done