From a09a285186e82f22be54b36cd016c75de120cd7c Mon Sep 17 00:00:00 2001 From: dadada Date: Sat, 21 May 2022 12:14:49 +0200 Subject: [PATCH] improve quoting --- update | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/update b/update index a7ffc2a..69fdbed 100755 --- a/update +++ b/update @@ -2,9 +2,9 @@ update() { url="$1" - pad="$(basename $url).txt" + pad="$(basename "$url").txt" dst="$pad" - gitdir="$(dirname $dst)" + gitdir="$(dirname "$dst")" curl --silent -k -o "${dst}" "${url}/export/txt" status="$?" @@ -13,7 +13,7 @@ update() { return fi - newlength="$(wc -l < ${dst})" + newlength="$(wc -l < "${dst}")" if [ "$newlength" -lt 3 ] then echo "Skipping update of ${url}, because pad has likely been removed" @@ -22,11 +22,12 @@ update() { git -C "${gitdir}" add "${dst}" changes=$(git -C "${gitdir}" diff --cached | wc -l) - if [ "$changes" -gt 0 ]; then - git -C "${gitdir}" commit -m "Updated: ${dst} from ${url}" - else + if [ "$changes" -lt 1 ]; then echo "Nothing changed for ${url}" + return fi + + git -C "${gitdir}" commit -m "Updated: ${dst} from ${url}" } if ! git rev-parse --is-inside-work-tree