From 2d4d6cdc1bb3dfc19fe46709857f44a14baa5ee1 Mon Sep 17 00:00:00 2001 From: Brenton Horne Date: Tue, 20 Nov 2018 04:33:28 +1000 Subject: [PATCH] Fixing several ShellCheck warnings --- launch-dedicated.sh | 8 ++++---- launch-game.sh | 4 ++-- packaging/linux/buildpackage.sh | 16 ++++++++-------- packaging/osx/buildpackage.sh | 18 +++++++++--------- packaging/package-all.sh | 2 +- packaging/source/buildpackage.sh | 8 ++++---- packaging/update-wiki.sh | 8 ++++---- packaging/windows/buildpackage.sh | 10 +++++----- thirdparty/fetch-geoip-db.sh | 2 +- thirdparty/fetch-thirdparty-deps-osx.sh | 2 +- thirdparty/fetch-thirdparty-deps-windows.sh | 2 +- thirdparty/fetch-thirdparty-deps.sh | 6 +++--- 12 files changed, 43 insertions(+), 43 deletions(-) diff --git a/launch-dedicated.sh b/launch-dedicated.sh index 4e5cf7408d..940ec33004 100755 --- a/launch-dedicated.sh +++ b/launch-dedicated.sh @@ -14,8 +14,8 @@ EnableSingleplayer="${EnableSingleplayer:-"False"}" Password="${Password:-""}" while true; do - mono --debug OpenRA.Server.exe Game.Mod=$Mod \ - Server.Name="$Name" Server.ListenPort=$ListenPort \ - Server.AdvertiseOnline=$AdvertiseOnline \ - Server.EnableSingleplayer=$EnableSingleplayer Server.Password=$Password + mono --debug OpenRA.Server.exe Game.Mod="$Mod" \ + Server.Name="$Name" Server.ListenPort="$ListenPort" \ + Server.AdvertiseOnline="$AdvertiseOnline" \ + Server.EnableSingleplayer="$EnableSingleplayer" Server.Password="$Password" done diff --git a/launch-game.sh b/launch-game.sh index 3081396d60..253045f7b5 100755 --- a/launch-game.sh +++ b/launch-game.sh @@ -5,7 +5,7 @@ MODLAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))") MODARG='' if [ z"${*#*Game.Mod}" = z"$*" ] then - if which zenity > /dev/null + if command -v zenity > /dev/null then TITLE=$(zenity --forms --add-combo="" --combo-values="Red Alert|Tiberian Dawn|Dune 2000|Tiberian Sun" --text "Select mod" --title="" || echo "cancel") if [ "$TITLE" = "cancel" ]; then exit 0 @@ -31,7 +31,7 @@ if [ $? != 0 ] && [ $? != 1 ]; then elif command -v kdialog > /dev/null; then kdialog --title "{MODNAME}" --error "${ERROR_MESSAGE}" else - printf "${ERROR_MESSAGE}\n" + printf "%s\n" "${ERROR_MESSAGE}" fi exit 1 fi diff --git a/packaging/linux/buildpackage.sh b/packaging/linux/buildpackage.sh index 860a2d510d..6c7fd4ba72 100755 --- a/packaging/linux/buildpackage.sh +++ b/packaging/linux/buildpackage.sh @@ -10,12 +10,12 @@ command -v curl >/dev/null 2>&1 || command -v wget > /dev/null 2>&1 || { echo >& DEPENDENCIES_TAG="20180723" if [ $# -eq "0" ]; then - echo "Usage: `basename $0` version [outputdir]" + echo "Usage: $(basename "$0") version [outputdir]" exit 1 fi # Set the working dir to the location of this script -cd $(dirname $0) +cd "$(dirname "$0")" || exit 1 TAG="$1" OUTPUTDIR="$2" @@ -35,7 +35,7 @@ elif [[ ${TAG} == pkgtest* ]]; then SUFFIX="-pkgtest" fi -pushd "${TEMPLATE_ROOT}" > /dev/null +pushd "${TEMPLATE_ROOT}" > /dev/null || exit 1 if [ ! -d "${OUTPUTDIR}" ]; then echo "Output directory '${OUTPUTDIR}' does not exist."; @@ -44,14 +44,14 @@ fi echo "Building core files" -pushd ${SRCDIR} > /dev/null +pushd "${SRCDIR}" > /dev/null || exit 1 make linux-dependencies make core SDK="-sdk:4.5" make version VERSION="${TAG}" make install-engine prefix="usr" DESTDIR="${BUILTDIR}/" make install-common-mod-files prefix="usr" DESTDIR="${BUILTDIR}/" -popd > /dev/null +popd > /dev/null || exit 1 # Add native libraries echo "Downloading dependencies" @@ -79,14 +79,14 @@ build_appimage() { MOD_ID=${1} DISPLAY_NAME=${2} APPDIR="$(pwd)/${MOD_ID}.appdir" - APPIMAGE="OpenRA-$(echo ${DISPLAY_NAME} | sed 's/ /-/g')${SUFFIX}-x86_64.AppImage" + APPIMAGE="OpenRA-$(echo "${DISPLAY_NAME}" | sed 's/ /-/g')${SUFFIX}-x86_64.AppImage" cp -r "${BUILTDIR}" "${APPDIR}" # Add mod files - pushd "${SRCDIR}" > /dev/null + pushd "${SRCDIR}" > /dev/null || exit 1 cp -r "mods/${MOD_ID}" mods/modcontent "${APPDIR}/usr/lib/openra/mods" - popd > /dev/null + popd > /dev/null || exit 1 # Add launcher and icons sed "s/{MODID}/${MOD_ID}/g" AppRun.in | sed "s/{MODNAME}/${DISPLAY_NAME}/g" > AppRun.temp diff --git a/packaging/osx/buildpackage.sh b/packaging/osx/buildpackage.sh index 38b2a42fed..90dc9afb0f 100755 --- a/packaging/osx/buildpackage.sh +++ b/packaging/osx/buildpackage.sh @@ -12,12 +12,12 @@ fi LAUNCHER_TAG="osx-launcher-20171118" if [ $# -ne "2" ]; then - echo "Usage: `basename $0` tag outputdir" + echo "Usage: $(basename "$0") tag outputdir" exit 1 fi # Set the working dir to the location of this script -cd $(dirname $0) +cd "$(dirname "$0")" || exit 1 TAG="$1" OUTPUTDIR="$2" @@ -44,10 +44,10 @@ populate_template() { # Deletes from the first argument's mod dirs all the later arguments delete_mods() { - pushd "${BUILTDIR}/${1}/Contents/Resources/mods" > /dev/null + pushd "${BUILTDIR}/${1}/Contents/Resources/mods" > /dev/null || exit 1 shift - rm -rf $@ - pushd > /dev/null + rm -rf "$@" + pushd > /dev/null || exit 1 } echo "Building launchers" @@ -70,12 +70,12 @@ modify_plist "{DEV_VERSION}" "${TAG}" "${BUILTDIR}/OpenRA.app/Contents/Info.plis modify_plist "{FAQ_URL}" "http://wiki.openra.net/FAQ" "${BUILTDIR}/OpenRA.app/Contents/Info.plist" echo "Building core files" -pushd ${SRCDIR} > /dev/null +pushd "${SRCDIR}" > /dev/null || exit 1 make osx-dependencies make core SDK="-sdk:4.5" make version VERSION="${TAG}" make install-core gameinstalldir="/Contents/Resources/" DESTDIR="${BUILTDIR}/OpenRA.app" -popd > /dev/null +popd > /dev/null || exit 1 curl -s -L -O https://raw.githubusercontent.com/wiki/OpenRA/OpenRA/Changelog.md markdown Changelog.md > "${BUILTDIR}/OpenRA.app/Contents/Resources/CHANGELOG.html" @@ -106,10 +106,10 @@ else curl -s -L -O https://github.com/OpenRA/libdmg-hfsplus/archive/master.zip || exit 3 unzip -qq master.zip rm master.zip - pushd libdmg-hfsplus-master > /dev/null + pushd libdmg-hfsplus-master > /dev/null || exit 1 cmake . > /dev/null make > /dev/null - popd > /dev/null + popd > /dev/null || exit 1 if [[ ! -f libdmg-hfsplus-master/dmg/dmg ]] ; then echo "libdmg-hfsplus compilation failed" diff --git a/packaging/package-all.sh b/packaging/package-all.sh index d9d10b3dee..641e59e1f7 100755 --- a/packaging/package-all.sh +++ b/packaging/package-all.sh @@ -10,7 +10,7 @@ export GIT_TAG="$1" export BUILD_OUTPUT_DIR="$2" # Set the working dir to the location of this script using bash parameter expansion -cd "${0%/*}" +cd "${0%/*}" || exit 1 #build packages using a subshell so directory changes do not persist beyond the function function build_package() ( diff --git a/packaging/source/buildpackage.sh b/packaging/source/buildpackage.sh index 01a996edbc..62a05412f2 100755 --- a/packaging/source/buildpackage.sh +++ b/packaging/source/buildpackage.sh @@ -2,18 +2,18 @@ # OpenRA packaging script for versioned source tarball if [ $# -ne "2" ]; then - echo "Usage: `basename $0` tag outputdir" + echo "Usage: $(basename "$0") tag outputdir" exit 1 fi # Set the working dir to the location of this script -cd $(dirname $0) +cd "$(dirname "$0")" || exit 1 TAG="$1" OUTPUTDIR="$2" SRCDIR="$(pwd)/../.." -pushd ${SRCDIR} > /dev/null +pushd "${SRCDIR}" > /dev/null || exit 1 make version VERSION="${TAG}" git ls-tree HEAD --name-only -r -z | xargs -0 tar cvjf "${OUTPUTDIR}/OpenRA-${TAG}-source.tar.bz2" -popd > /dev/null +popd > /dev/null || exit 1 diff --git a/packaging/update-wiki.sh b/packaging/update-wiki.sh index 0d0f3b81ff..6d5d9eecfc 100755 --- a/packaging/update-wiki.sh +++ b/packaging/update-wiki.sh @@ -24,15 +24,15 @@ mkdir -p "$(dirname "$SSH_KEY")" openssl aes-256-cbc -k "$KEY" -in ssh.enc -d -out "$SSH_KEY" chmod 0600 "$SSH_KEY" -rm -rf $HOME/openra-wiki -git clone git@github.com:OpenRA/OpenRA.wiki.git $HOME/openra-wiki +rm -rf "$HOME/openra-wiki" +git clone git@github.com:OpenRA/OpenRA.wiki.git "$HOME/openra-wiki" mono --debug ../OpenRA.Utility.exe all --docs > "${HOME}/openra-wiki/Traits${TAG}.md" mono --debug ../OpenRA.Utility.exe all --weapon-docs > "${HOME}/openra-wiki/Weapons${TAG}.md" mono --debug ../OpenRA.Utility.exe all --lua-docs > "${HOME}/openra-wiki/Lua API${TAG}.md" mono --debug ../OpenRA.Utility.exe all --settings-docs > "${HOME}/openra-wiki/Settings${TAG}.md" -pushd $HOME/openra-wiki +pushd "$HOME/openra-wiki" || exit 1 git config --local user.email "orabot@users.noreply.github.com" git config --local user.name "orabot" git add "Traits${TAG}.md" @@ -40,6 +40,6 @@ git add "Lua API${TAG}.md" git add "Settings${TAG}.md" git commit -m "Update trait and scripting documentation for branch $1" && git push origin master -popd +popd || exit shred -u "$SSH_KEY" diff --git a/packaging/windows/buildpackage.sh b/packaging/windows/buildpackage.sh index 4fe132ed29..fa195210e1 100755 --- a/packaging/windows/buildpackage.sh +++ b/packaging/windows/buildpackage.sh @@ -5,12 +5,12 @@ command -v markdown >/dev/null 2>&1 || { echo >&2 "Windows packaging requires ma command -v makensis >/dev/null 2>&1 || { echo >&2 "Windows packaging requires makensis."; exit 1; } if [ $# -ne "2" ]; then - echo "Usage: `basename $0` tag outputdir" + echo "Usage: $(basename "$0") tag outputdir" exit 1 fi # Set the working dir to the location of this script -cd $(dirname $0) +cd "$(dirname "$0")" || exit 1 TAG="$1" OUTPUTDIR="$2" @@ -32,17 +32,17 @@ function makelauncher() sed "s|DISPLAY_NAME|$2|" WindowsLauncher.cs.in | sed "s|MOD_ID|$3|" | sed "s|FAQ_URL|${FAQ_URL}|" > WindowsLauncher.cs mcs -sdk:4.5 WindowsLauncher.cs -warn:4 -codepage:utf8 -warnaserror -out:"$1" -t:winexe ${LAUNCHER_LIBS} -win32icon:"$4" rm WindowsLauncher.cs - mono "${SRCDIR}/fixheader.exe" $1 > /dev/null + mono "${SRCDIR}/fixheader.exe" "$1" > /dev/null } echo "Building core files" -pushd ${SRCDIR} > /dev/null +pushd "${SRCDIR}" > /dev/null || exit 1 make windows-dependencies make core SDK="-sdk:4.5" make version VERSION="${TAG}" make install-core gameinstalldir="" DESTDIR="${BUILTDIR}" -popd > /dev/null +popd > /dev/null || exit 1 echo "Compiling Windows launchers" makelauncher "${BUILTDIR}/RedAlert.exe" "Red Alert" "ra" RedAlert.ico diff --git a/thirdparty/fetch-geoip-db.sh b/thirdparty/fetch-geoip-db.sh index d1325a1175..9166daa712 100755 --- a/thirdparty/fetch-geoip-db.sh +++ b/thirdparty/fetch-geoip-db.sh @@ -5,7 +5,7 @@ set -e download_dir="${0%/*}/download" mkdir -p "${download_dir}" -cd "${download_dir}" +cd "${download_dir}" || exit 1 filename="GeoLite2-Country.mmdb.gz" diff --git a/thirdparty/fetch-thirdparty-deps-osx.sh b/thirdparty/fetch-thirdparty-deps-osx.sh index f61ff09e9b..9c5f9e7eac 100755 --- a/thirdparty/fetch-thirdparty-deps-osx.sh +++ b/thirdparty/fetch-thirdparty-deps-osx.sh @@ -4,7 +4,7 @@ LAUNCHER_TAG="osx-launcher-20171118" download_dir="${0%/*}/download/osx" mkdir -p "$download_dir" -cd "$download_dir" +cd "$download_dir" || exit 1 if [ ! -f libSDL2.dylib ]; then echo "Fetching OS X SDL2 library from GitHub." diff --git a/thirdparty/fetch-thirdparty-deps-windows.sh b/thirdparty/fetch-thirdparty-deps-windows.sh index 09623c068d..28f0ff3691 100755 --- a/thirdparty/fetch-thirdparty-deps-windows.sh +++ b/thirdparty/fetch-thirdparty-deps-windows.sh @@ -6,7 +6,7 @@ set -e download_dir="${0%/*}/download/windows" mkdir -p "${download_dir}" -cd "${download_dir}" +cd "${download_dir}" || exit 1 if [ ! -f SDL2.dll ]; then echo "Fetching SDL2 from libsdl.org" diff --git a/thirdparty/fetch-thirdparty-deps.sh b/thirdparty/fetch-thirdparty-deps.sh index 8d49b4a87f..55f7e8c9c2 100755 --- a/thirdparty/fetch-thirdparty-deps.sh +++ b/thirdparty/fetch-thirdparty-deps.sh @@ -11,7 +11,7 @@ set -e download_dir="${0%/*}/download" mkdir -p "${download_dir}" -cd "${download_dir}" +cd "${download_dir}" || exit 1 if [ ! -f StyleCopPlus.dll ]; then echo "Fetching StyleCopPlus from NuGet" @@ -79,7 +79,7 @@ if [ ! -f FuzzyLogicLibrary.dll ]; then rm -rf FuzzyLogicLibrary fi -if [ ! -f SDL2-CS.dll -o ! -f SDL2-CS.dll.config ]; then +if [ ! -f SDL2-CS.dll ] || [ ! -f SDL2-CS.dll.config ]; then echo "Fetching SDL2-CS from GitHub." if command -v curl >/dev/null 2>&1; then curl -s -L -O https://github.com/OpenRA/SDL2-CS/releases/download/20161223/SDL2-CS.dll @@ -90,7 +90,7 @@ if [ ! -f SDL2-CS.dll -o ! -f SDL2-CS.dll.config ]; then fi fi -if [ ! -f OpenAL-CS.dll -o ! -f OpenAL-CS.dll.config ]; then +if [ ! -f OpenAL-CS.dll ] || [ ! -f OpenAL-CS.dll.config ]; then echo "Fetching OpenAL-CS from GitHub." if command -v curl >/dev/null 2>&1; then curl -s -L -O https://github.com/OpenRA/OpenAL-CS/releases/download/20151227/OpenAL-CS.dll