From f429651e2e172f8f546c332c26bcc788f738ef09 Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Sun, 5 Jun 2016 18:56:30 +0700 Subject: [PATCH 1/2] Remove unused Bash-only code The Bash shell has several features, like the [[ operator and the pipefail option, that aren't available in other shells like Dash (which follows the POSIX standard more strictly). But since we don't actually *need* any of Bash's more advanced features, there's no reason not to remove them to make the script runnable with Dash. --- build.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index a8f8d81..9922543 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash set -eu -set -o pipefail cd `dirname $0` @@ -11,13 +10,13 @@ FAKE_EXE=packages/build/FAKE/tools/FAKE.exe FSIARGS="" OS=${OS:-"unknown"} -if [[ "$OS" != "Windows_NT" ]] +if [ "$OS" != "Windows_NT" ] then FSIARGS="--fsiargs -d:MONO" fi -function run() { - if [[ "$OS" != "Windows_NT" ]] +run() { + if [ "$OS" != "Windows_NT" ] then mono "$@" else @@ -25,7 +24,7 @@ function run() { fi } -function yesno() { +yesno() { # NOTE: Defaults to NO read -p "$1 [y/N] " ynresult case "$ynresult" in @@ -39,7 +38,7 @@ run $PAKET_BOOTSTRAPPER_EXE bootstrapper_exitcode=$? set -e -if [[ "$OS" != "Windows_NT" ]] && +if [ "$OS" != "Windows_NT" ] && [ $bootstrapper_exitcode -ne 0 ] && [ $(certmgr -list -c Trust | grep X.509 | wc -l) -le 1 ] && [ $(certmgr -list -c -m Trust | grep X.509 | wc -l) -le 1 ] From b32ea35397a4c80c550793f83fc92dea5e5b354f Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Sun, 5 Jun 2016 19:38:30 +0700 Subject: [PATCH 2/2] Handle FSIARGS correctly in zsh In zsh, a variable with a space in it will be treated as if it was quoted, which is not how bash behaves. There's a zsh-specific option you can set to consider it as two words instead, but that's not friendly to strictly-POSIX-compliant shells like dash. Instead, for maximum compatibility and simplicity, simply split it into two variables. --- build.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 9922543..59c644e 100755 --- a/build.sh +++ b/build.sh @@ -9,10 +9,14 @@ PAKET_EXE=.paket/paket.exe FAKE_EXE=packages/build/FAKE/tools/FAKE.exe FSIARGS="" +FSIARGS2="" OS=${OS:-"unknown"} if [ "$OS" != "Windows_NT" ] then - FSIARGS="--fsiargs -d:MONO" + # Can't use FSIARGS="--fsiargs -d:MONO" in zsh, so split it up + # (Can't use arrays since dash can't handle them) + FSIARGS="--fsiargs" + FSIARGS2="-d:MONO" fi run() { @@ -69,5 +73,5 @@ run $PAKET_EXE restore [ ! -e build.fsx ] && run $PAKET_EXE update [ ! -e build.fsx ] && run $FAKE_EXE init.fsx -run $FAKE_EXE "$@" $FSIARGS build.fsx +run $FAKE_EXE "$@" $FSIARGS $FSIARGS2 build.fsx