Remove is_sourced functionality, it's not needed anymore

This commit is contained in:
Julian Ospald 2019-01-04 12:32:51 +08:00
parent 4c548c1037
commit 9cc652e34d
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28

31
ghcup
View File

@ -1003,34 +1003,6 @@ posix_realpath() {
unset mysource mydir posix_realpath_error
}
# @FUNCTION: is_sourced
# @DESCRIPTION:
# Tries to figure out if we are being sourced. Based on
# https://stackoverflow.com/a/28776166
# @RETURNS: 0 if we are being sourced, 1 otherwise
is_sourced() {
if [ -n "$ZSH_EVAL_CONTEXT" ]; then
case $ZSH_EVAL_CONTEXT in
*:file)
return 0 ;;
esac
elif [ -n "$KSH_VERSION" ]; then
# shellcheck disable=SC2154
[ "$(cd "$(dirname -- "$0")" && pwd -P)/$(basename -- "$0")" != "$(cd "$(dirname -- "${.sh.file}")" && pwd -P)/$(basename -- "${.sh.file}")" ] && return 0
elif [ -n "$BASH_VERSION" ]; then
# shellcheck disable=SC2128
[ "$0" != "$BASH_SOURCE" ] && return 0
else # All other shells: examine $0 for known shell binary filenames
# Detects `sh` and `dash`; add additional shell filenames as needed.
case ${0##*/} in
sh|dash)
return 0 ;;
esac
fi
# assume we are not sourced, if our above checks didn't find it
return 1
}
# @FUNCTION: get_meta_version_file
# @DESCRIPTION:
@ -1689,8 +1661,6 @@ fi
#--[ Command line parsing and entry point ]--#
##############################################
if ! is_sourced ; then
[ $# -lt 1 ] && usage
while [ $# -gt 0 ] ; do
@ -1920,6 +1890,5 @@ if ! is_sourced ; then
break;;
esac
done
fi # is_sourced
# vim: tabstop=4 shiftwidth=4 expandtab