Remove is_sourced functionality, it's not needed anymore
This commit is contained in:
parent
4c548c1037
commit
9cc652e34d
31
ghcup
31
ghcup
@ -1003,34 +1003,6 @@ posix_realpath() {
|
|||||||
unset mysource mydir posix_realpath_error
|
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
|
# @FUNCTION: get_meta_version_file
|
||||||
# @DESCRIPTION:
|
# @DESCRIPTION:
|
||||||
@ -1689,8 +1661,6 @@ fi
|
|||||||
#--[ Command line parsing and entry point ]--#
|
#--[ Command line parsing and entry point ]--#
|
||||||
##############################################
|
##############################################
|
||||||
|
|
||||||
if ! is_sourced ; then
|
|
||||||
|
|
||||||
[ $# -lt 1 ] && usage
|
[ $# -lt 1 ] && usage
|
||||||
|
|
||||||
while [ $# -gt 0 ] ; do
|
while [ $# -gt 0 ] ; do
|
||||||
@ -1920,6 +1890,5 @@ if ! is_sourced ; then
|
|||||||
break;;
|
break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
fi # is_sourced
|
|
||||||
|
|
||||||
# vim: tabstop=4 shiftwidth=4 expandtab
|
# vim: tabstop=4 shiftwidth=4 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user