用户工具

站点工具


bit010:7_随笔笔记:8_历史的:未整理:shell:判断source运行

if [ "$0" == "${BASH_SOURCE[0]}" ] ; then
	echo -e "\033[1;31m[ERROR] Using the shell \"source\" command to this script.\033[0m \033[0;33mexample: source ${BASH_SOURCE[0]}\033[0m";
else
  echo "NOT NULL"
fi


test "$BASH_SOURCE" = "" && echo "This script only can be run from bash" && return
SCRIPT_SOURCE=$BASH_SOURCE
test "$SCRIPT_SOURCE" = "$0" && echo "Script is being run, should be sourced" && exit 1

bit010/7_随笔笔记/8_历史的/未整理/shell/判断source运行.txt · 最后更改: 2025/05/26 15:30 由 127.0.0.1