From 3b77a58ea32ad55a17a2b7a35c1405ec389d2323 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Fri, 26 Jul 2024 10:56:10 +0200 Subject: [PATCH] Quote variables when doing substring manipulation --- lib/commands/track.sh | 2 +- lib/fs.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/commands/track.sh b/lib/commands/track.sh index 82638e37..208ff735 100644 --- a/lib/commands/track.sh +++ b/lib/commands/track.sh @@ -34,7 +34,7 @@ track() { for homepath in $files_to_track; do IFS=$oldIFS - local relpath=${homepath#$HOME/} + local relpath=${homepath#"$HOME/"} pending 'track' "$relpath" local relpath_in_repo="home/$relpath" local repopath="$repo/$relpath_in_repo" diff --git a/lib/fs.sh b/lib/fs.sh index 8e729d78..cc0df183 100644 --- a/lib/fs.sh +++ b/lib/fs.sh @@ -191,12 +191,12 @@ create_rel_path() { if [[ $target = "${prefix%/}" ]]; then target_path='' else - target_path=${target##$prefix} + target_path=${target##"$prefix"} fi # The path from the common directory to the source_dir is # $source_dir without the prefix local source_dir_path - source_dir_path=${source_dir##$prefix} + source_dir_path=${source_dir##"$prefix"} # Determine the path from the source_dir to the common directory (consists only of ../) local common_dir_path=''