Shell脚本执行时打印执行的命令
#!/bin/bash
# filename: a.sh
# 设置PS4环境变量
export PS4='+ $(basename "$0"):${FUNCNAME}:$LINENO: '
if [ "$debug" == "true" -o "$debug" == "yes" ];then set -x; fi
# 执行命令
function foo(){
echo 'in foo'
}
function bar(){
echo 'in bar'
}
function main(){
foo
bar
}
main
debug=true bash a.sh
+ a.sh::22: main
+ a.sh:main:18: foo
+ a.sh:foo:9: echo 'in foo'
in foo
+ a.sh:main:19: bar
+ a.sh:bar:13: echo 'in bar'
in bar

浙公网安备 33010602011771号