From a947053a6f572e848cd6b36eeb1e64ed8e54746b Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Sun, 27 Oct 2024 00:35:58 +0200 Subject: fixed escaping file paths in linkify --- linkify | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/linkify b/linkify index 83f1bc1..625c3e5 100755 --- a/linkify +++ b/linkify @@ -6,7 +6,7 @@ if [[ "$#" -lt 1 ]]; then fi home=$HOME -script_dir=`dirname $(realpath $0)` +script_dir=`dirname $(realpath "$0")` script_home="$script_dir/home" fof=0 @@ -15,25 +15,25 @@ files=0 for file in "$@" do - if [[ -h $file ]]; then + if [[ -h "$file" ]]; then ((links++)) - elif [[ -d $file ]]; then + elif [[ -d "$file" ]]; then echo "$file is directory, skipping" - elif [[ -f $file ]]; then - real_path_file=$(realpath $file) - check_home=$(echo $real_path_file | cut -d'/' -f-3) + elif [[ -f "$file" ]]; then + real_path_file="$(realpath "$file")" + check_home="$(echo "$real_path_file" | cut -d'/' -f-3)" - if [[ $home = $check_home ]]; then - relative_path=$(echo $real_path_file | cut -d'/' -f4-) + if [[ "$home" = "$check_home" ]]; then + relative_path="$(echo "$real_path_file" | cut -d'/' -f4-)" desired_path="$script_home/$relative_path" - mkdir -p $(dirname $desired_path) - mv $file $desired_path + mkdir -p "$(dirname "$desired_path")" + mv "$file" "$desired_path" if [[ "$file" == *".fof" ]]; then cp "$desired_path" "${file::-4}" ((fof++)) else - ln -s $desired_path $file + ln -s "$desired_path" "$file" ((files++)) fi else -- cgit v1.2.3-70-g09d2