From ed22882b07ac3e2bfbb00dc307ea808b6e6a60c4 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 22 Jul 2017 17:06:14 -0400 Subject: [PATCH] More shell quoting fixes Signed-off-by: Anders Kaseorg --- .../build-acis/common/container-build-helpers.sh | 6 +++--- building/build-acis/debian-build/build.sh | 2 +- building/build-acis/debian-micro/build.sh | 2 +- building/build-acis/debian-mini/build.sh | 2 +- building/build-acis/debian/build.sh | 2 +- building/build-acis/flannel/build.sh | 2 +- building/build-debs/build-all.sh | 2 +- building/build-debs/clean.sh | 2 +- .../build-debs/common/package-build-helpers.sh | 6 +++--- .../homeworld-admitserver/inner-build.sh | 2 +- .../homeworld-authserver/inner-build.sh | 2 +- .../build-debs/homeworld-etcd/inner-build.sh | 2 +- .../homeworld-hyperkube/inner-build.sh | 2 +- building/build-debs/homeworld-rkt/inner-build.sh | 2 +- building/build-helpers/helper-acbuild/build.sh | 2 +- building/build-helpers/helper-go/build.sh | 6 +++--- building/build-iso/generate.sh | 4 ++-- building/upload-acis/rebuild.sh | 16 ++++++++-------- building/upload-debs/rebuild.sh | 2 +- deployment/clustered/generate.sh | 4 ++-- 20 files changed, 35 insertions(+), 35 deletions(-) diff --git a/building/build-acis/common/container-build-helpers.sh b/building/build-acis/common/container-build-helpers.sh index cc5e295e2..b897d4d66 100644 --- a/building/build-acis/common/container-build-helpers.sh +++ b/building/build-acis/common/container-build-helpers.sh @@ -11,7 +11,7 @@ ACBUILDDIR="${ROOT}/acbuild-tmp" GO_VER=1.8.3 GO_TGZ="${HELPERS}/go-bin-${GO_VER}.tgz" -ACI_BRIEF="$(basename ${ROOT})" +ACI_BRIEF="$(basename "${ROOT}")" ACI_NAME="homeworld.mit.edu/${ACI_BRIEF}" function common_setup() { @@ -208,9 +208,9 @@ function run_builder() { for line in "$@" do echo "$line" - done) >${BUILDDIR}/inner-build.sh + done) > "${BUILDDIR}/inner-build.sh" - chmod +x ${BUILDDIR}/inner-build.sh + chmod +x "${BUILDDIR}/inner-build.sh" # stage1 should not be kvm RKT_OPTS=(--stage1-path=/usr/lib/rkt/stage1-images/stage1-coreos.aci) diff --git a/building/build-acis/debian-build/build.sh b/building/build-acis/debian-build/build.sh index 1dddedc41..bc647d567 100755 --- a/building/build-acis/debian-build/build.sh +++ b/building/build-acis/debian-build/build.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -u -cd "$(dirname $0)" +cd "$(dirname "$0")" source ../common/debian.sh RELEASE="stretch" diff --git a/building/build-acis/debian-micro/build.sh b/building/build-acis/debian-micro/build.sh index cd6166a99..7694ee22c 100755 --- a/building/build-acis/debian-micro/build.sh +++ b/building/build-acis/debian-micro/build.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -u -cd "$(dirname $0)" +cd "$(dirname "$0")" source ../common/debian.sh RELEASE="stretch" diff --git a/building/build-acis/debian-mini/build.sh b/building/build-acis/debian-mini/build.sh index 6397e2aad..d764f1c30 100755 --- a/building/build-acis/debian-mini/build.sh +++ b/building/build-acis/debian-mini/build.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -u -cd "$(dirname $0)" +cd "$(dirname "$0")" source ../common/debian.sh RELEASE="stretch" diff --git a/building/build-acis/debian/build.sh b/building/build-acis/debian/build.sh index 9fb8db9bd..19ae628f1 100755 --- a/building/build-acis/debian/build.sh +++ b/building/build-acis/debian/build.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -u -cd "$(dirname $0)" +cd "$(dirname "$0")" source ../common/debian.sh RELEASE="stretch" diff --git a/building/build-acis/flannel/build.sh b/building/build-acis/flannel/build.sh index 04dc31739..cccc84731 100755 --- a/building/build-acis/flannel/build.sh +++ b/building/build-acis/flannel/build.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -u -cd "$(dirname $0)" +cd "$(dirname "$0")" source ../common/container-build-helpers.sh FLANNEL_VER="0.8.0" diff --git a/building/build-debs/build-all.sh b/building/build-debs/build-all.sh index 79595f1bd..c07b44f10 100755 --- a/building/build-debs/build-all.sh +++ b/building/build-debs/build-all.sh @@ -6,7 +6,7 @@ set -e -u for x in homeworld-*/ do - (cd $x && ./build-package.sh) + (cd "$x" && ./build-package.sh) done ./clean.sh diff --git a/building/build-debs/clean.sh b/building/build-debs/clean.sh index 7d12a7f42..2a31e7664 100755 --- a/building/build-debs/clean.sh +++ b/building/build-debs/clean.sh @@ -3,6 +3,6 @@ rm -f homeworld-*_amd64.build rm -f homeworld-*_amd64.buildinfo rm -f homeworld-*_amd64.changes rm -f homeworld-*.orig.tar.xz -rm -f *.dsc +rm -f -- *.dsc rm -f homeworld-*-dbgsym_*.deb rm -f homeworld-*.tar.gz diff --git a/building/build-debs/common/package-build-helpers.sh b/building/build-debs/common/package-build-helpers.sh index 058619416..cfd218fcd 100644 --- a/building/build-debs/common/package-build-helpers.sh +++ b/building/build-debs/common/package-build-helpers.sh @@ -1,14 +1,14 @@ -PKGBASE="$(basename $(dirname $(realpath $0)))" +PKGBASE="$(basename "$(dirname "$(realpath "$0")")")" -if [ "$(echo ${PKGBASE} | cut -d '-' -f 1)" != "homeworld" ] +if [ "$(echo "${PKGBASE}" | cut -d '-' -f 1)" != "homeworld" ] then echo "Invalid internal name ${PKGBASE} from $0" 1>&2 exit 1 fi DVERSION="$(head -n 1 debian/changelog | cut -d '(' -f 2 | cut -d ')' -f 1)" -VERSION="$(echo $DVERSION | cut -d '-' -f 1)" +VERSION="$(echo "$DVERSION" | cut -d '-' -f 1)" BIN=../binaries STAGE=.. UPSTREAM=../../upstream diff --git a/building/build-debs/homeworld-admitserver/inner-build.sh b/building/build-debs/homeworld-admitserver/inner-build.sh index 1ef6bd3c0..b489083cc 100755 --- a/building/build-debs/homeworld-admitserver/inner-build.sh +++ b/building/build-debs/homeworld-admitserver/inner-build.sh @@ -3,7 +3,7 @@ set -e -u rm -rf go tar -xf go-bin-1.8.3.tgz go/ -export GOROOT=$(pwd)/go/ +export GOROOT="$(pwd)/go/" export PATH="$PATH:$GOROOT/bin" if [ "$(go version 2>/dev/null)" != "go version go1.8.3 linux/amd64" ] diff --git a/building/build-debs/homeworld-authserver/inner-build.sh b/building/build-debs/homeworld-authserver/inner-build.sh index 6954c3bf6..922083afc 100755 --- a/building/build-debs/homeworld-authserver/inner-build.sh +++ b/building/build-debs/homeworld-authserver/inner-build.sh @@ -3,7 +3,7 @@ set -e -u rm -rf go tar -xf go-bin-1.8.3.tgz go/ -export GOROOT=$(pwd)/go/ +export GOROOT="$(pwd)/go/" export PATH="$PATH:$GOROOT/bin" if [ "$(go version 2>/dev/null)" != "go version go1.8.3 linux/amd64" ] diff --git a/building/build-debs/homeworld-etcd/inner-build.sh b/building/build-debs/homeworld-etcd/inner-build.sh index b20694ced..10f7695bb 100755 --- a/building/build-debs/homeworld-etcd/inner-build.sh +++ b/building/build-debs/homeworld-etcd/inner-build.sh @@ -4,7 +4,7 @@ set -e -u rm -rf go acbuild tar -xf go-bin-1.8.3.tgz go/ tar -xf acbuild-bin-0.4.0.tgz acbuild/ -export GOROOT=$(pwd)/go/ +export GOROOT="$(pwd)/go/" export PATH="$PATH:$GOROOT/bin:$(pwd)/acbuild" if [ "$(go version 2>/dev/null)" != "go version go1.8.3 linux/amd64" ] diff --git a/building/build-debs/homeworld-hyperkube/inner-build.sh b/building/build-debs/homeworld-hyperkube/inner-build.sh index b5af02070..5e455f516 100755 --- a/building/build-debs/homeworld-hyperkube/inner-build.sh +++ b/building/build-debs/homeworld-hyperkube/inner-build.sh @@ -3,7 +3,7 @@ set -e -u rm -rf go tar -xf go-bin-1.8.3.tgz go/ -export GOROOT=$(pwd)/go/ +export GOROOT="$(pwd)/go/" export PATH="$PATH:$GOROOT/bin" if [ "$(go version 2>/dev/null)" != "go version go1.8.3 linux/amd64" ] diff --git a/building/build-debs/homeworld-rkt/inner-build.sh b/building/build-debs/homeworld-rkt/inner-build.sh index 5a0abfc93..ea3af2646 100755 --- a/building/build-debs/homeworld-rkt/inner-build.sh +++ b/building/build-debs/homeworld-rkt/inner-build.sh @@ -3,7 +3,7 @@ set -e -u rm -rf go tar -xf go-bin-1.8.3.tgz go/ -export GOROOT=$(pwd)/go/ +export GOROOT="$(pwd)/go/" export PATH="$PATH:$GOROOT/bin" if [ "$(go version 2>/dev/null)" != "go version go1.8.3 linux/amd64" ] diff --git a/building/build-helpers/helper-acbuild/build.sh b/building/build-helpers/helper-acbuild/build.sh index ca76bb483..089521c99 100755 --- a/building/build-helpers/helper-acbuild/build.sh +++ b/building/build-helpers/helper-acbuild/build.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -cd "$(dirname $0)" +cd "$(dirname "$0")" if [ -e "../acbuild-bin-0.4.0.tgz" ] then diff --git a/building/build-helpers/helper-go/build.sh b/building/build-helpers/helper-go/build.sh index 06147310d..71752e35e 100755 --- a/building/build-helpers/helper-go/build.sh +++ b/building/build-helpers/helper-go/build.sh @@ -14,11 +14,11 @@ mv go go1.4 tar -xf go1.8.3.src.tar.xz go mv go go1.8.3 BOOTSTRAP="${ROOT}/go1.4" -cd ${ROOT}/go1.4/src/ +cd "${ROOT}/go1.4/src/" ./make.bash -cd ${ROOT}/go1.8.3/src +cd "${ROOT}/go1.8.3/src" GOROOT_FINAL="/usr/lib/homeworld-goroot" GOARCH="amd64" GOOS="linux" CGO_ENABLED="1" GOROOT_BOOTSTRAP="${BOOTSTRAP}" ./make.bash -cd ${ROOT} +cd "${ROOT}" rm -rf go1.4 mv go1.8.3 go tar -czf ../go-bin-1.8.3.tgz go/ diff --git a/building/build-iso/generate.sh b/building/build-iso/generate.sh index 0ec4a8f7b..c7142dddd 100755 --- a/building/build-iso/generate.sh +++ b/building/build-iso/generate.sh @@ -24,7 +24,7 @@ chmod +w --recursive cd gunzip cd/initrd.gz PASS=$(pwgen 20 1) echo "Password: $PASS" -sed "s|{{HASH}}|$(echo ${PASS} | mkpasswd -s -m sha-512)|" preseed.cfg.in >preseed.cfg +sed "s|{{HASH}}|$(echo "${PASS}" | mkpasswd -s -m sha-512)|" preseed.cfg.in >preseed.cfg SETUPVER="$(head -n 1 ../build-debs/homeworld-apt-setup/debian/changelog | cut -d '(' -f 2 | cut -d ')' -f 1)" ADMITVER="$(head -n 1 ../build-debs/homeworld-admitclient/debian/changelog | cut -d '(' -f 2 | cut -d ')' -f 1)" cp "../build-debs/binaries/homeworld-apt-setup_${SETUPVER}_amd64.deb" "." @@ -39,5 +39,5 @@ admission.conf preseed.cfg EOF gzip cd/initrd -(cd cd && md5sum $(find -follow -type f) >md5sum.txt) +(cd cd && find . -follow -type f -print0 | xargs -0 md5sum > md5sum.txt) genisoimage -quiet -o preseeded.iso -r -J -no-emul-boot -boot-load-size 4 -boot-info-table -b isolinux.bin -c isolinux.cat ./cd diff --git a/building/upload-acis/rebuild.sh b/building/upload-acis/rebuild.sh index 4c7dcf0ba..fa1c1a9c8 100755 --- a/building/upload-acis/rebuild.sh +++ b/building/upload-acis/rebuild.sh @@ -2,7 +2,7 @@ set -e -u -cd "$(dirname $0)" +cd "$(dirname "$0")" mkdir -p staging cp ../build-acis/containers/*.aci -t staging @@ -15,12 +15,12 @@ do done function find_latest() { - LATEST="$(ls staging/$1*-linux-amd64.aci | grep -vF latest | sort | tail -n 1)" + LATEST="$(ls "staging/$1"*-linux-amd64.aci | grep -vF latest | sort | tail -n 1)" echo "Latest for $1: $LATEST" - ln -sf "$(basename $LATEST)" "staging/${1}latest-linux-amd64.aci" - ln -sf "$(basename $LATEST.asc)" "staging/${1}latest-linux-amd64.aci.asc" - ln -sf "$(basename $LATEST)" "staging/${2}-linux-amd64.aci" - ln -sf "$(basename $LATEST.asc)" "staging/${2}-linux-amd64.aci.asc" + ln -sf "$(basename "$LATEST")" "staging/${1}latest-linux-amd64.aci" + ln -sf "$(basename "$LATEST.asc")" "staging/${1}latest-linux-amd64.aci.asc" + ln -sf "$(basename "$LATEST")" "staging/${2}-linux-amd64.aci" + ln -sf "$(basename "$LATEST.asc")" "staging/${2}-linux-amd64.aci.asc" } for x in debian-build debian debian-mini debian-micro @@ -35,9 +35,9 @@ sleep 0.1 DEST=/mit/hyades/acis/homeworld.mit.edu/ for x in staging/*.aci staging/*.aci.asc do - FILENAME="$(basename $x)" + FILENAME="$(basename "$x")" echo "checking $x" - if [ ! -e "${DEST}/${FILENAME}" ] || [ "$(wc -c <${x})" != "$(wc -c <${DEST}/${FILENAME})" ] + if [ ! -e "${DEST}/${FILENAME}" ] || [ "$(wc -c < "${x}")" != "$(wc -c < "${DEST}/${FILENAME}")" ] then echo "copying $x" cp -dfT "$x" "${DEST}/${FILENAME}" diff --git a/building/upload-debs/rebuild.sh b/building/upload-debs/rebuild.sh index fd984390e..c18f46c18 100755 --- a/building/upload-debs/rebuild.sh +++ b/building/upload-debs/rebuild.sh @@ -2,7 +2,7 @@ set -e -u -cd "$(dirname $0)" +cd "$(dirname "$0")" reprepro -Vb . includedeb homeworld ../build-debs/binaries/homeworld-*.deb rsync -av --progress ./dists ./pool /mit/hyades/debian/ diff --git a/deployment/clustered/generate.sh b/deployment/clustered/generate.sh index c86cf334e..8b935539e 100755 --- a/deployment/clustered/generate.sh +++ b/deployment/clustered/generate.sh @@ -9,8 +9,8 @@ fi rm -f flannel.yml -ADDRESS="$(grep 'CLUSTER_CIDR=' ${1} | sed 's/^\(.*\)=\(.*\)$/\2/g')" -if [ "$(echo $ADDRESS | tr "./" "\n\n" | wc -l)" != 5 ] +ADDRESS="$(grep 'CLUSTER_CIDR=' "${1}" | sed 's/^\(.*\)=\(.*\)$/\2/g')" +if [ "$(echo "$ADDRESS" | tr "./" "\n\n" | wc -l)" != 5 ] then echo "Invalid address." exit 1