теперь обрабатывает релативы

This commit is contained in:
bogdan zažigin 2023-07-14 23:09:33 +03:00
parent bd9302eb2f
commit 53e5df3efa

View file

@ -1,20 +1,21 @@
# create symbolic links # pootential arguments:
# by vim-like modelines # directory=$1
# of all files in the directory # options=$2
# arguments # options for linking with "ln"
directory=$1 options="-sfvnr"
# link modeline regular expression # regular expression of link-modeline
regex="^.{2,3}link: \K\S+" regex="^.{2,3}link: \K\S+"
files=(`grep -rPHl "${regex}"`) files=($(grep -rPHl "${regex}"))
destinations=(`grep -rPho "${regex}"`) destinations=($(grep -rPho "${regex}"))
for ((e = 0; e <= (${#files[@]} - 1); e++)); # linking
for e in ${!files[@]};
do do
target=${files[$e]} target=(${files[$e]})
link_name=${destinations[$e]} link_name=(${destinations[$e]})
ln -sfvnr $target $link_name ln $options $target $link_name
done done