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
diff --git a/stack.sh b/stack.sh
index bf9fc01..36a9ed4 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