fix add.sh + add EEXIST-error
This commit is contained in:
parent
888b576ea3
commit
d9fba2b35d
1 changed files with 6 additions and 5 deletions
11
add.sh
11
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue