hakunin hakunin - 2 months ago 7
Bash Question

Tracing shell commands executed within shell scripts (e.g. zsh)

Given a shell script (with conditions, concatenations and interpolations) that builds and executes certain commands (in my case calls to ImageMagick's

cli), is there a way to list the commands that were executed in that script? Since the script calls
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.