add ZSH support to "exports"
Stefan Schuermans

Stefan Schuermans commited on 2020-08-10 17:59:07
Showing 1 changed files, with 7 additions and 3 deletions.


based on patch by Florian Walbroel
... ...
@@ -1,7 +1,11 @@
1
-if [[ -z ${BASH_SOURCE[0]:-} ]]
1
+if [[ -v BASH_VERSION ]]
2 2
 then
3
-  echo "BASH_SOURCE is not set, unsupported shell" >&2
3
+  export UPT_HOME="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
4
+elif [[ -v ZSH_VERSION ]]
5
+then
6
+  export UPT_HOME="$(readlink -f "$(dirname "${(%):-%x}")")"
7
+else
8
+  echo "Unsupported shell, only bash and zsh are supported." >&2
4 9
   return 2
5 10
 fi
6
-export UPT_HOME="$(readlink -f "$(dirname "${BASH_SOURCE[0]}")")"
7 11
 export PATH="$UPT_HOME/bin${PATH:+:${PATH}}"
8 12