On Wed, Jun 10, 2015 at 05:17:37PM -0500, Peng Yu wrote:
> The foo example that you showed below print the highlight commands all
> at once.
INCORRECT!
You fail to understand.
I chose that example ON PURPOSE. It is a clear example of why set -v
is rubbish.
If I had chosen an example like this:
#!/bin/bash -v
command one
command two
command three
Then it would have APPEARED to do what you want, and you would
have gained a FALSE SENSE OF ACCOMPLISHMENT by using a tool that
only works in the simplest, most stupid, most degenerate, most
not-in-need-of-a-fancy-debugging-tool cases.
> I want the commands and their output be interleaved as what
> happens with `set -v`.
You are confused about what set -v does.
set -v prints lines AS THEY ARE READ by the shell's PARSER.
It does NOT print COMMANDS that are EXECUTED. That is what set -x does.
set -v is totally different.
set -v is almost completely USELESS in real life.
That's why nobody uses it.
That's why it's dramatically under-documented.
That's why nobody CARES about it.
And stop using that fucking backtick markup to indicate "this is a
shell command". It's confusing as all hell, because backticks are
also valid syntax within a bash command.