From 53e5df3efac39728630a26fcbde054c16f8ca094 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D0=BE=D0=B3=D0=B4=D0=B0=D0=BD?= Date: Fri, 14 Jul 2023 23:09:33 +0300 Subject: [PATCH] =?UTF-8?q?=D1=82=D0=B5=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BE?= =?UTF-8?q?=D0=B1=D1=80=D0=B0=D0=B1=D0=B0=D1=82=D1=8B=D0=B2=D0=B0=D0=B5?= =?UTF-8?q?=D1=82=20=D1=80=D0=B5=D0=BB=D0=B0=D1=82=D0=B8=D0=B2=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/link-modeline.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/source/link-modeline.sh b/source/link-modeline.sh index cdd3e59..6e1a4b7 100644 --- a/source/link-modeline.sh +++ b/source/link-modeline.sh @@ -1,20 +1,21 @@ -# create symbolic links -# by vim-like modelines -# of all files in the directory +# pootential arguments: +# directory=$1 +# options=$2 -# arguments -directory=$1 +# options for linking with "ln" +options="-sfvnr" -# link modeline regular expression +# regular expression of link-modeline regex="^.{2,3}link: \K\S+" -files=(`grep -rPHl "${regex}"`) -destinations=(`grep -rPho "${regex}"`) +files=($(grep -rPHl "${regex}")) +destinations=($(grep -rPho "${regex}")) -for ((e = 0; e <= (${#files[@]} - 1); e++)); +# linking +for e in ${!files[@]}; do - target=${files[$e]} - link_name=${destinations[$e]} - ln -sfvnr $target $link_name + target=(${files[$e]}) + link_name=(${destinations[$e]}) + ln $options $target $link_name done