Browse Source

scripts: improve variable escaping

Jan-Tarek Butt 7 years ago
parent
commit
0f3e660842
4 changed files with 14 additions and 14 deletions
  1. 3 3
      scripts/patch.sh
  2. 1 1
      scripts/sha512sum.sh
  3. 4 4
      scripts/update-patches.sh
  4. 6 6
      scripts/update.sh

+ 3 - 3
scripts/patch.sh

@@ -15,14 +15,14 @@ trap 'rm -rf "$PATCHDIR"' EXIT
 for module in $GLUON_MODULES; do
 	echo "--- Patching module '$module' ---"
 
-	git clone -s -b base --single-branch "$GLUONDIR"/$module "$PATCHDIR" 2>/dev/null
+	git clone -s -b base --single-branch "$GLUONDIR/$module" "$PATCHDIR" 2>/dev/null
 
 	cd "$PATCHDIR"
-	for patch in "$GLUONDIR"/patches/$module/*.patch; do
+	for patch in "$GLUONDIR/patches/$module"/*.patch; do
 		git -c user.name='Gluon Patch Manager' -c user.email='gluon@void.example.com' -c commit.gpgsign=false am --whitespace=nowarn --committer-date-is-author-date "$patch"
 	done
 
-	cd "$GLUONDIR"/$module
+	cd "$GLUONDIR/$module"
 	git fetch "$PATCHDIR" 2>/dev/null
 	git checkout -B patched FETCH_HEAD
 	git submodule update --init --recursive

+ 1 - 1
scripts/sha512sum.sh

@@ -1,7 +1,7 @@
 #!/bin/sh
 
 check_command() {
-	which $1 >/dev/null 2>&1
+	which "$1" >/dev/null 2>&1
 }
 
 if check_command sha512sum; then

+ 4 - 4
scripts/update-patches.sh

@@ -8,14 +8,14 @@ shopt -s nullglob
 for module in $GLUON_MODULES; do
 	echo "--- Updating patches for module '$module' ---"
 
-	rm -f "$GLUONDIR"/patches/$module/*.patch
-	mkdir -p "$GLUONDIR"/patches/$module
+	rm -f "$GLUONDIR"/patches/"$module"/*.patch
+	mkdir -p "$GLUONDIR"/patches/"$module"
 
-	cd "$GLUONDIR"/$module
+	cd "$GLUONDIR"/"$module"
 
 	n=0
 	for commit in $(git rev-list --reverse --no-merges base..patched); do
 		let n=n+1
-		git show --pretty=format:'From: %an <%ae>%nDate: %aD%nSubject: %B' --no-renames $commit > "$GLUONDIR"/patches/$module/"$(printf '%04u' $n)-$(git show -s --pretty=format:%f $commit).patch"
+		git show --pretty=format:'From: %an <%ae>%nDate: %aD%nSubject: %B' --no-renames "$commit" > "$GLUONDIR/patches/$module/$(printf '%04u' $n)-$(git show -s --pretty=format:%f "$commit").patch"
 	done
 done

+ 6 - 6
scripts/update.sh

@@ -6,17 +6,17 @@ set -e
 
 for module in $GLUON_MODULES; do
 	echo "--- Updating module '$module' ---"
-	var=$(echo $module | tr '[:lower:]/' '[:upper:]_')
+	var=$(echo "$module" | tr '[:lower:]/' '[:upper:]_')
 	eval repo=\${${var}_REPO}
 	eval branch=\${${var}_BRANCH}
 	eval commit=\${${var}_COMMIT}
 
-	mkdir -p "$GLUONDIR"/$module
-	cd "$GLUONDIR"/$module
+	mkdir -p "$GLUONDIR/$module"
+	cd "$GLUONDIR/$module"
 	git init
 
-	if ! git branch -f base $commit 2>/dev/null; then
-		git fetch $repo $branch
-		git branch -f base $commit 2>/dev/null
+	if ! git branch -f base "$commit" 2>/dev/null; then
+		git fetch "$repo" "$branch"
+		git branch -f base "$commit" 2>/dev/null
 	fi
 done