From 4d74e0f49515e23668a9dd955f30939cd03f94b2 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Wed, 11 Mar 2015 09:45:59 +1100 Subject: [PATCH] Fail if run in POSIX compatability mode This is mostly to detect if someone is running the script with "sh ./stack.sh" where sh is the bash-symlink that puts it in POSIX mode (this can be invoked in other ways, but much less common). In this case POSIXLY_CORRECT is set; so if we see that, bail out early before we start hitting syntax errors. Closes-Bug: #1430535 Change-Id: I7bbc4b0f656df9f6d9da2243c8caeb42d30ace95 --- stack.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/stack.sh b/stack.sh index bf9fc0118e..36a9ed46d2 100755 --- a/stack.sh +++ b/stack.sh @@ -21,6 +21,13 @@ # Learn more and get the most recent version at http://devstack.org +# check if someone has invoked with "sh" +if [[ "${POSIXLY_CORRECT}" == "y" ]]; then + echo "You appear to be running bash in POSIX compatability mode." + echo "devstack uses bash features. \"./stack.sh\" should do the right thing" + exit 1 +fi + # Make sure custom grep options don't get in the way unset GREP_OPTIONS