*: fix shellcheck warnings

Fixes scripts and removes shellcheck warning suppressions.

* regexp warnings
* use ./*glob* so names don't become options
* use $(..) instead of legacy `..`
* read with -r to avoid mangling backslashes
* double quote to prevent globbing and word splitting
This commit is contained in:
Anthony Romano
2017-09-06 10:38:08 -07:00
parent 3c1845604b
commit 9abe9da9db
10 changed files with 149 additions and 147 deletions

View File

@ -16,15 +16,15 @@ function setup_env {
local proj=${1}
local ver=${2}
if [ ! -d ${proj} ]; then
git clone https://github.com/coreos/${proj}
if [ ! -d "${proj}" ]; then
git clone https://github.com/coreos/"${proj}"
fi
pushd ${proj} >/dev/null
pushd "${proj}" >/dev/null
git checkout master
git fetch --all
git reset --hard origin/master
git checkout $ver
git checkout "${ver}"
popd >/dev/null
}
@ -34,28 +34,28 @@ function package {
local srcdir="${2}/bin"
local ccdir="${srcdir}/${GOOS}_${GOARCH}"
if [ -d ${ccdir} ]; then
srcdir=${ccdir}
if [ -d "${ccdir}" ]; then
srcdir="${ccdir}"
fi
local ext=""
if [ ${GOOS} == "windows" ]; then
if [ "${GOOS}" == "windows" ]; then
ext=".exe"
fi
for bin in etcd etcdctl; do
cp ${srcdir}/${bin} ${target}/${bin}${ext}
cp "${srcdir}/${bin}" "${target}/${bin}${ext}"
done
cp etcd/README.md ${target}/README.md
cp etcd/etcdctl/README.md ${target}/README-etcdctl.md
cp etcd/etcdctl/READMEv2.md ${target}/READMEv2-etcdctl.md
cp etcd/README.md "${target}"/README.md
cp etcd/etcdctl/README.md "${target}"/README-etcdctl.md
cp etcd/etcdctl/READMEv2.md "${target}"/READMEv2-etcdctl.md
cp -R etcd/Documentation ${target}/Documentation
cp -R etcd/Documentation "${target}"/Documentation
}
function main {
mkdir release
cd release
setup_env ${PROJ} ${VER}
setup_env "${PROJ}" "${VER}"
for os in darwin windows linux; do
export GOOS=${os}
@ -74,14 +74,14 @@ function main {
popd >/dev/null
TARGET="etcd-${VER}-${GOOS}-${GOARCH}"
mkdir ${TARGET}
package ${TARGET} ${PROJ}
mkdir "${TARGET}"
package "${TARGET}" "${PROJ}"
if [ ${GOOS} == "linux" ]; then
tar cfz ${TARGET}.tar.gz ${TARGET}
tar cfz "${TARGET}.tar.gz" "${TARGET}"
echo "Wrote release/${TARGET}.tar.gz"
else
zip -qr ${TARGET}.zip ${TARGET}
zip -qr "${TARGET}.zip" "${TARGET}"
echo "Wrote release/${TARGET}.zip"
fi
done