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
|
for arg in $@; do
|
||||||
arg="$(realpath "$arg")"
|
arg="$(realpath -s "$arg")"
|
||||||
file="${arg#"$HOME"}"
|
file="${arg#"$HOME"/}"
|
||||||
|
|
||||||
test "$arg" != "$file" || {
|
test "$arg" != "$file" || {
|
||||||
>&2 echo "$f is not in $HOME"
|
>&2 echo "$file is not in $HOME"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
test -e "files/$file" && {
|
test ! -e "files/$file" || {
|
||||||
>&2 echo "$f is already added"
|
>&2 echo "$file is already added"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir -vp "files/$(dirname "$file")"
|
mkdir -vp "files/$(dirname "$file")"
|
||||||
mv -iv "$arg" "files/$file"
|
mv -iv "$arg" "files/$file"
|
||||||
ln -vfs "$(realpath "files/$file")" "$arg"
|
ln -vfs "$(realpath "files/$file")" "$arg"
|
||||||
|
echo "added"
|
||||||
done
|
done
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue