From b1642210516b6aeb2762d6811506f4fb6d66c24c Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 6 Oct 2015 12:26:17 +0200 Subject: [PATCH] setenv: check in a more robust way that the script is being sourced Sometimes a leading '-' shows up in $0 for login shells, for example this happens when opening a shell with "sudo -i"; in these cases $0 will look like "-bash" instead of "bash", and the comparison with $(basename $SHELL) fails even if the script is being sourced. Fix this by stripping the leading '-'. --- setenv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setenv b/setenv index e5c51a5..b9a1569 100644 --- a/setenv +++ b/setenv @@ -1,6 +1,6 @@ #!/bin/sh -[ "$0" = "$(basename $SHELL)" ] || { echo "This script is meant to be sourced, not executed" 1>&2; exit 1; } +[ "${0#-}" = "$(basename $SHELL)" ] || { echo "This script is meant to be sourced, not executed" 1>&2; exit 1; } export ANDROID_HOME=$HOME/Android/android-sdk-linux export PATH=$PATH:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools -- 2.1.4