From 532bfaee44c444fdc85dddaaddeceec2434ee1b7 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Mon, 8 Apr 2019 18:24:20 +0800 Subject: [PATCH] Some quotes stuff --- SongSync.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/SongSync.sh b/SongSync.sh index 76ab323..54868e2 100755 --- a/SongSync.sh +++ b/SongSync.sh @@ -39,15 +39,15 @@ if [ "$1" = "apply" ]; then # one downside of this approach is it will result in redownloading files already # on disk instead of moving them while read -r m; do - if [[ ${m:0:2} = "++" ]] || [[ ${m:0:2} = "--" ]] || [[ ${m:0:2} = "@@" ]]; then + if [[ "${m:0:2}" = "++" ]] || [[ "${m:0:2}" = "--" ]] || [[ "${m:0:2}" = "@@" ]]; then continue fi - hash=$(echo $m | cut -sd ' ' -f1) + hash=$(echo "$m" | cut -sd ' ' -f1) hash="${hash:1}" - path=$(echo $m | cut -sd / -f5,6) + path=$(echo "$m" | cut -sd / -f5,6) - if [[ ${m:0:1} = "+" ]]; then + if [[ "${m:0:1}" = "+" ]]; then if ! [ -z "${adds[${path}]}" ]; then echo "More than one SM file in ${path}, aborting" exit @@ -55,7 +55,7 @@ if [ "$1" = "apply" ]; then adds["${path}"]+="$hash" fi - if [[ ${m:0:1} = "-" ]]; then + if [[ "${m:0:1}" = "-" ]]; then # It can happan that a path is already in removes if there are multiple SM files in a directory # this should not really happen since there's the check above that refuses to add any files with that # problem. However when I do the initial sync on our machines they will have problematic files. @@ -63,7 +63,7 @@ if [ "$1" = "apply" ]; then # So just ignore it, the path is already in the removes list, so it will be nuked. # # I suppose it could happen that one of these borked paths were moved to a different location, but - # in that case there'd be multiple sms in the adds path. So... I guess it's OK. + # in that case thered be multiple sms in the adds path. So... I guess its OK. if [ -z "${removes[${path}]}" ]; then removes["${path}"]+="$hash" fi @@ -73,7 +73,7 @@ if [ "$1" = "apply" ]; then for removal_path in "${!removes[@]}"; do if [ -d "/tmp/${removes[$removal_path]}" ]; then echo "need to rm /tmp/${removes[$removal_path]}" - rm "/tmp/${removes[$removal_path]}" + rm -rf "/tmp/${removes[$removal_path]}" fi echo "Moving ${removal_path} to /tmp/${removes[$removal_path]}" @@ -81,7 +81,7 @@ if [ "$1" = "apply" ]; then done for add_path in "${!adds[@]}"; do - pack_dir=$(echo $add_path | cut -sd / -f1) + pack_dir=$(echo "$add_path" | cut -sd / -f1) if ! [ -z "${removes[${add_path}]}" ]; then crc32="$(echo -n "/Songs/${add_path}/" | gzip -c | tail -c8 | hexdump -n4 -e '"%u"')" echo "CACHE INVALIDATION NEEDED FOR ${add_path} : ${crc32}" @@ -104,5 +104,5 @@ if [ "$1" = "apply" ]; then eval "$scp_command" done - rm ${old_songs_file} + rm "${old_songs_file}" fi -- 2.11.0