我有一些关键的bash脚本,由我无法控制的代码调用,我无法看到他们的控制台输出.我想要完整地了解这些脚本的作用,以便以后分析.为此,我想让每个脚本都自我跟踪.这是我目前正在做的事情:
#!/bin/bash # if last arg is not '_worker_',relaunch with stdout and stderr # redirected to my log file... if [[ "$BASH_ARGV" != "_worker_" ]]; then $0 "$@" _worker_ >>/some_log_file 2>&1 # add tee if console output wanted exit $? fi # rest of script follows...
有更好,更清洁的方法吗?