Given a shell script (with conditions, concatenations and interpolations) that builds and executes certain commands (in my case calls to ImageMagick's convert
cli), is there a way to list the commands that were executed in that script? Since the script calls convert
multiple times substituting args, I'd like to get a list like the following.
convert ...
convert ...
convert ...
.开发者_运维技巧..
I'm using zsh in OS X, but can switch to bash, etc.
Stick a
set -x
at the top of your script. Works in bash, should work in zsh.
In zsh
(maybe only with oh-my-zsh
enabled) I find there's a lot of noise produced with set -x
or setopt xtrace
.
But you can also:
typeset -ft <function_name>
to trace only one function.
To turn it off:
typeset +ft <function_name>
Adapted from the A User's Guide to the Z-Shell.
精彩评论