set -x just show a final result of the command. Any way to view each step more clear, like pics below.
It sounds like you'd like to have a shell syntax scanner and parser that outputs the found tokens and the actions it takes along the way to executing the actual command.
I'm not aware of any shell that does this as it would slow down processing immensely as well as producing an huge amount of output for each even slightly complex command.
bash, if you compile the shell yourself with the
DEBUG macro defined and if you enable all the commented out calls to the
itrace() function in the shell's source code1, then you can get a bit of what you're wanting to see:
bash-4.4$ if [[ "$BASHPID" = 10 ]] && [[ "$USER" = myself ]]; then echo hello me; fi TRACE: pid 22914: parse_matched_pair: open = " close = " flags = 0 TRACE: pid 22914: parse_matched_pair: returning $BASHPID" TRACE: pid 22914: parse_matched_pair: open = " close = " flags = 0 TRACE: pid 22914: parse_matched_pair: returning $USER" TRACE: pid 22914: param_expand: `$BASHPID' pflags = 0
Here, you can see the parser outputting a few debugging statements about finding opening and closing double quotes and shell variables. Later, another processing step informs us that a parameter expansion of
$BASHPID is performed, but far from all steps are listed.
This type of debugging output from
bash is more useful for people actually involved with writing and modifying the shell's source code though, and are definitely not intended to serve as a way of understanding the shells parsing and interpretation of its input.
To become more familiar with how the syntax and grammar of the shell works, I'd suggest starting at the POSIX definition of the shell's grammar (which is quite complex, and more or less meaningless to anyone who can't read EBNF).
1Except for one in
lib/glob/glob.c that has a syntax error in it.
set -x is for bash shell scripts, it won't work for binary files.
If you like to trace a binary execution, you should consider a debugger (e.g.