From 512028d952ee109e8c09591979c46945bae83f31 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Fri, 17 Jan 2020 10:35:31 -0600 Subject: setup: support zsh zsh populates $0 even when sourcing a script. This caused sourcing this script to think that it was being executed and it `exit 1`d the running shell. Since no sane distribution would ever set /bin/sh to zsh, the presence of $ZSH_NAME implies that the script is being sourced. Tested with both bash and zsh in both modes of operation. Signed-off-by: Patrick Williams Change-Id: I2843d96a7fdaa46f9ee6edb9031ca9c16ca3bd98 --- setup | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'setup') diff --git a/setup b/setup index d018c9814..a1702f991 100755 --- a/setup +++ b/setup @@ -15,8 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # - -if [ "$(basename -- "$0")" = "setup" ]; then +if [ -z "$ZSH_NAME" ] && [ "$(basename -- "$0")" = "setup" ]; then echo The script must be sourced, not executed exit 1 fi -- cgit v1.2.3