diff options
author | Krish De Souza <kd913@ic.ac.uk> | 2018-11-07 02:32:57 +0300 |
---|---|---|
committer | Andrew Eikum <aeikum@codeweavers.com> | 2018-11-16 21:54:56 +0300 |
commit | 416bea727e43c9dd1bb744d9c62f2903e8ea091c (patch) | |
tree | 3ac31bc0412a43f84c1b8ae9a11daa0641392c3a /configure.sh | |
parent | e47e856563bff202c56fb67a3a0d424346485dc6 (diff) |
Shellcheck fixes for configure.sh and steamrt-bootstrap.sh
In steamrt-bootstrap,sh
+ Used quotes to prevent word splitting SC2046
+ Used $() notation rather than legacy backtick SC2006
+ which is non-standard. 'command -v' is builtin SC2230
In configure.sh
+ Assigned to local variable separately to avoid masking return values SC2155
+ Used to quote to prevent glob matching SC2053
+ Used -z command rather than ! -n SC2236
+ Fixed SC2129 which would have a minor performance gain of avoiding constantly opening and closing the makefile.
Diffstat (limited to 'configure.sh')
-rwxr-xr-x | configure.sh | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/configure.sh b/configure.sh index 0eec916a..026f1d2e 100755 --- a/configure.sh +++ b/configure.sh @@ -19,7 +19,10 @@ if [[ $(tput colors 2>/dev/null || echo 0) -gt 0 ]]; then COLOR_CLEAR=$'\e[0m' fi -sh_quote() { local quoted="$(printf '%q ' "$@")"; [[ $# -eq 0 ]] || echo "${quoted:0:-1}"; } +sh_quote() { + local quoted + quoted="$(printf '%q ' "$@")"; [[ $# -eq 0 ]] || echo "${quoted:0:-1}"; +} err() { echo >&2 "${COLOR_ERR}!!${COLOR_CLEAR} $*"; } stat() { echo >&2 "${COLOR_STAT}::${COLOR_CLEAR} $*"; } info() { echo >&2 "${COLOR_INFO}::${COLOR_CLEAR} $*"; } @@ -72,7 +75,8 @@ function configure() { check_steamrt_image "$steamrt64_type" "$steamrt64_name" check_steamrt_image "$steamrt32_type" "$steamrt32_name" - local srcdir="$(dirname "$0")" + local srcdir + srcdir="$(dirname "$0")" # Build name local build_name="$arg_build_name" @@ -87,26 +91,28 @@ function configure() { # Don't die after this point or we'll have rather unhelpfully deleted the Makefile [[ ! -e "$MAKEFILE" ]] || rm "$MAKEFILE" - # Config - echo >> "$MAKEFILE" "# Generated by: $THIS_COMMAND" - echo >> "$MAKEFILE" "" - echo >> "$MAKEFILE" "SRCDIR := $(escape_for_make "$srcdir")" - echo >> "$MAKEFILE" "BUILD_NAME := $(escape_for_make "$build_name")" + { + # Config + echo "# Generated by: $THIS_COMMAND" + echo "" + echo "SRCDIR := $(escape_for_make "$srcdir")" + echo "BUILD_NAME := $(escape_for_make "$build_name")" - # ffmpeg? - if [[ -n $arg_ffmpeg ]]; then - echo >> "$MAKEFILE" "WITH_FFMPEG := 1" - fi + # ffmpeg? + if [[ -n $arg_ffmpeg ]]; then + echo "WITH_FFMPEG := 1" + fi - # SteamRT - echo >> "$MAKEFILE" "STEAMRT64_MODE := $(escape_for_make "$steamrt64_type")" - echo >> "$MAKEFILE" "STEAMRT64_IMAGE := $(escape_for_make "$steamrt64_name")" - echo >> "$MAKEFILE" "STEAMRT32_MODE := $(escape_for_make "$steamrt32_type")" - echo >> "$MAKEFILE" "STEAMRT32_IMAGE := $(escape_for_make "$steamrt32_name")" + # SteamRT + echo "STEAMRT64_MODE := $(escape_for_make "$steamrt64_type")" + echo "STEAMRT64_IMAGE := $(escape_for_make "$steamrt64_name")" + echo "STEAMRT32_MODE := $(escape_for_make "$steamrt32_type")" + echo "STEAMRT32_IMAGE := $(escape_for_make "$steamrt32_name")" - # Include base - echo >> "$MAKEFILE" "" - echo >> "$MAKEFILE" "include \$(SRCDIR)/build/makefile_base.mak" + # Include base + echo "" + echo "include \$(SRCDIR)/build/makefile_base.mak" + } >> "$MAKEFILE" stat "Created $MAKEFILE, now run make to build." stat " See README.md for make targets and instructions" @@ -142,7 +148,7 @@ function parse_args() { fi # Looks like an argument does it have a --foo=bar value? - if [[ ${arg%=*} != $arg ]]; then + if [[ ${arg%=*} != "$arg" ]]; then val="${arg#*=}" arg="${arg%=*}" val_passed=1 @@ -173,11 +179,11 @@ function parse_args() { fi # Check if this arg used the value and shouldn't have or vice-versa - if [[ -n $val_used && ! -n $val_passed ]]; then + if [[ -n $val_used && -z $val_passed ]]; then # "--arg val" form, used $2 as the value. # Don't allow this if it looked like "--arg --val" - if [[ ${val#--} != $val ]]; then + if [[ ${val#--} != "$val" ]]; then err "Ambiguous format for argument with value \"$arg $val\"" err " (use $arg=$val or $arg='' $val)" return 1 |