src/eprefix-activate: better way to detect if the script is sourced
Signed-off-by: Maciej Barć <xgqt@protonmail.com>
This commit is contained in:
parent
462dab713e
commit
da429430ad
@ -72,12 +72,17 @@ eprefix_world() {
|
|||||||
# >>> Checks
|
# >>> Checks
|
||||||
|
|
||||||
# Exit if script is not sourced
|
# Exit if script is not sourced
|
||||||
if [[ "${0}" != *sh ]]
|
case ${-} in
|
||||||
then
|
*i* )
|
||||||
echo "Don't run this script"
|
:
|
||||||
echo "Source it instead"
|
;;
|
||||||
exit 1
|
* )
|
||||||
fi
|
echo "${eprefix_bad} Error: not a login shell"
|
||||||
|
echo "${eprefix_bad} Run: source ${0}"
|
||||||
|
echo ">>> Exiting the shell"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Exit if eprefix does not exist
|
# Exit if eprefix does not exist
|
||||||
if [ ! -d "${EPREFIX}" ]
|
if [ ! -d "${EPREFIX}" ]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user