diff options
author | Botond Hende <nettingman@gmail.com> | 2024-10-27 00:35:58 +0200 |
---|---|---|
committer | Botond Hende <nettingman@gmail.com> | 2024-10-27 00:35:58 +0200 |
commit | a947053a6f572e848cd6b36eeb1e64ed8e54746b (patch) | |
tree | 884458ba59e57c607da8a705ad2c9939da9edcc6 | |
parent | 6e26c01f8628ad3a18bc3d73633de94ae3e41ef7 (diff) |
fixed escaping file paths in linkify
-rwxr-xr-x | linkify | 22 |
1 files changed, 11 insertions, 11 deletions
@@ -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 |