envsetup: add function to detect shell
Add a function to detect shell, other functions can now use this to
handle shell specific behavior.
Change-Id: I4aabc0068e836c5433053b144d163fb0ed49f752
diff --git a/envsetup.sh b/envsetup.sh
index 084d5cf..b1c6056 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -1638,16 +1638,24 @@
"$(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
# Execute the contents of any vendorsetup.sh files we can find.