One hacky way is just to write your comments as arguments to a no-op command. Particularly useful might be the
: null utility:
: Some interesting notes on the following are ...
+ : Some interesting notes on the following are...
The colon command does nothing, accepts whatever arguments you give it, and always succeeds. You get an extra
: at the start of your trace output, but that probably isn't a huge problem for your purpose.
If you don't like the
: an even nastier trick is to use a fake command:
seq 1 1
Some comment &>/dev/null
+ seq 1 1
+ Some comment
That is, the
Some comment line is printed out as trace output when the shell tries to run it, but the resulting error message is sent to
/dev/null. This is nasty for a lot of obvious reasons, but it also counts as an error for the purposes of
Note that in either case, your comment is parsed by the shell in the ordinary way, so in particular if you have any special characters they need to be quoted, and because it's trace output the quoting will be displayed.