aboutsummaryrefslogtreecommitdiffstats
path: root/envsetup.sh
diff options
context:
space:
mode:
authorKhalid Zubair <kzubair@cyngn.com>2016-02-09 00:27:55 (GMT)
committerRashed Abdel-Tawab <rashed@linux.com>2018-08-11 00:20:45 (GMT)
commit36c3ef723afbe59a03e9e7524d1be016555f00ea (patch)
tree2d56b4ab1fd1c00b46b1062a1cb42f42f29cc41b /envsetup.sh
parent70a184a518736421f411d4f0cb8cf7f60d90e0b9 (diff)
downloadandroid_build-36c3ef723afbe59a03e9e7524d1be016555f00ea.zip
android_build-36c3ef723afbe59a03e9e7524d1be016555f00ea.tar.gz
android_build-36c3ef723afbe59a03e9e7524d1be016555f00ea.tar.bz2
envsetup: add function to detect shellrefs/changes/26/222726/5
Add a function to detect shell, other functions can now use this to handle shell specific behavior. Change-Id: I4aabc0068e836c5433053b144d163fb0ed49f752
Diffstat (limited to 'envsetup.sh')
-rw-r--r--envsetup.sh12
1 files changed, 10 insertions, 2 deletions
diff --git a/envsetup.sh b/envsetup.sh
index 4f13c4b..6eb5e4c 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1638,16 +1638,24 @@ function atest()
"$(gettop)"/tools/tradefederation/core/atest/atest.py "$@"
}
-if [ "x$SHELL" != "x/bin/bash" ]; then
+function __detect_shell() {
case `ps -o command -p $$` in
*bash*)
+ echo bash
;;
*zsh*)
+ echo zsh
;;
*)
- echo "WARNING: Only bash and zsh are supported, use of other shell may lead to erroneous results"
+ echo unknown
+ return 1
;;
esac
+ return
+}
+
+if ! __detect_shell > /dev/null; then
+ echo "WARNING: Only bash and zsh are supported, use of other shell may lead to erroneous results"
fi
# determine whether arrays are zero-based (bash) or one-based (zsh)