- Feb
- 240
- 3
This query is actually an offshoot of different thread (http://jpsoft.com/forums/threads/how-do-i-give-this-command.3797/), because I think that the essential issue there was not addressed or discussed fully.
The TCC help file notes:
"WARNING: Escape characters are considered to be normal characters on the right side of a pipe."
I would like to clarify two things about this warning:
1] This behavior is only consistent when there is no command that follows the pipe. However, if we add an additional pipe afterward, then the escape characters to the right of the pipe *are* treated as escape characters, as demonstrated here:
[C:\]echo "foo" | echoargs ^q^q^q
Arg 0 is <^q^q^q>
[C:\]echo "foo" | echoargs ^q^q^q | findstr ">"
Arg 0 is <">
In the first example, the ^q chars are treated as literals to the right of the pipe. In the second example, although they are to the right of the pipe, they are to the left of an additional pipe, and they are treated as escape characters.
Similarly, if we execute:
echo "foo" | echoargs > a.txt ^q^q^q
Then a.txt contains: Arg 0 is <">
Here too, although they are to the right of the pipe, they are treated as escape characters because there is a redirection afterwards (although the redirection is physically noted to their left, it is logically executed afterward).
WAD? At the least, the docs should be clarified. But overall the behavior seems inconsistent.
2] Additionally, I would note that in cmd.exe, at least in today's versions, the escape character is *not* ignored at the right of a pipe; thus, when it comes to such constructions, behavior will be different under cmd.exe and under TCC. What is the rationale behind this discrepancy?
The TCC help file notes:
"WARNING: Escape characters are considered to be normal characters on the right side of a pipe."
I would like to clarify two things about this warning:
1] This behavior is only consistent when there is no command that follows the pipe. However, if we add an additional pipe afterward, then the escape characters to the right of the pipe *are* treated as escape characters, as demonstrated here:
[C:\]echo "foo" | echoargs ^q^q^q
Arg 0 is <^q^q^q>
[C:\]echo "foo" | echoargs ^q^q^q | findstr ">"
Arg 0 is <">
In the first example, the ^q chars are treated as literals to the right of the pipe. In the second example, although they are to the right of the pipe, they are to the left of an additional pipe, and they are treated as escape characters.
Similarly, if we execute:
echo "foo" | echoargs > a.txt ^q^q^q
Then a.txt contains: Arg 0 is <">
Here too, although they are to the right of the pipe, they are treated as escape characters because there is a redirection afterwards (although the redirection is physically noted to their left, it is logically executed afterward).
WAD? At the least, the docs should be clarified. But overall the behavior seems inconsistent.
2] Additionally, I would note that in cmd.exe, at least in today's versions, the escape character is *not* ignored at the right of a pipe; thus, when it comes to such constructions, behavior will be different under cmd.exe and under TCC. What is the rationale behind this discrepancy?