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 <patrick@stwcx.xyz>
Change-Id: I2843d96a7fdaa46f9ee6edb9031ca9c16ca3bd98
diff --git a/setup b/setup
index d018c98..a1702f9 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