Dear All,
I have a hard struggle with understanding how it works. From the bash manual
1) From shell operation 2. point it breaks tokens first:
echo + `echo \\z`
2) Command Substitution inside text into a separate shell:
echo \\z
3) Again the 2. point from the shell operation tokenizing (with quoting):
echo + \\z (\+\ = \ ; plus the z remains)
4)This results:
feed echo with \z => \z
5) Back to the substitution, but point 8 said that in the old style quoting the backslash remains if it follows letter z
6) so after substitution it looks:
echo \z
7) After command substitution yet another tokenizing (with quoting):
echo + z
8) results: feed echo with z, which is good
z
However the
1) From shell operation 2. point it breaks tokens first:
echo + `echo \\\z`
2) Command Substitution inside text into a separate shell:
echo \\\z
3) Again the 2. point from the shell operation tokenizing (with quoting):
echo + \\\z (left two \+\ = \ ; plus the \z remains just z)
4)This results:
echo feed with \z => \z
from this point is this the same as above, however its result all in all is:
\z
Could somebody correct me what is wrong with my knowledge?
thank you very much
I have a hard struggle with understanding how it works. From the bash manual
3.1.1 Shell Operation
The following is a brief description of the shell’s operation when it reads and executes a command. Basically, the shell does the following:
- Reads its input from a file (see Shell Scripts), from a string supplied as an argument to the -c invocation option (see Invoking Bash), or from the user’s terminal.
- Breaks the input into words and operators, obeying the quoting rules described in Quoting. These tokens are separated by metacharacters. Alias expansion is performed by this step (see Aliases).
- Parses the tokens into simple and compound commands (see Shell Commands).
- Performs the various shell expansions (see Shell Expansions), breaking the expanded tokens into lists of filenames (see Filename Expansion) and commands and arguments.
- Performs any necessary redirections (see Redirections) and removes the redirection operators and their operands from the argument list.
- Executes the command (see Executing Commands).
- Optionally waits for the command to complete and collects its exit status (see Exit Status)
and from Command Substitution:
[*]When the old-style backquote form of substitution is used, backslash retains its literal meaning except when followed by ‘$’, ‘`’, or ‘\’.
echo `echo \\z`
1) From shell operation 2. point it breaks tokens first:
echo + `echo \\z`
2) Command Substitution inside text into a separate shell:
echo \\z
3) Again the 2. point from the shell operation tokenizing (with quoting):
echo + \\z (\+\ = \ ; plus the z remains)
4)This results:
feed echo with \z => \z
5) Back to the substitution, but point 8 said that in the old style quoting the backslash remains if it follows letter z
6) so after substitution it looks:
echo \z
7) After command substitution yet another tokenizing (with quoting):
echo + z
8) results: feed echo with z, which is good
z
However the
echo `echo \\\z`
1) From shell operation 2. point it breaks tokens first:
echo + `echo \\\z`
2) Command Substitution inside text into a separate shell:
echo \\\z
3) Again the 2. point from the shell operation tokenizing (with quoting):
echo + \\\z (left two \+\ = \ ; plus the \z remains just z)
4)This results:
echo feed with \z => \z
from this point is this the same as above, however its result all in all is:
\z
Could somebody correct me what is wrong with my knowledge?
thank you very much