echo "one foo=bar" gives an unexpected result. Why ?
On Wed, 18 Mar 2020 16:37:25 +0100, R.Wieser wrote:
JJ,
So, I entered, on a commandline, the following: "one foo=bar".
My apologies, as I see that I somehow left the word "echo" out in the body
of the message, and placed the double-quotes wrong in the subjectline. :-(
The full commandline I used is (without the doublequotes ofcourse) "echo one
foo=bar"
This exact command line:
echo "one foo=bar"
:-) /allmost/ the same one.
Regards,
Rudy Wieser
Two reasons:
1. The "=" character is treated as delimiters.
2. CMD processes redirection syntax first.
Thus the command line:
echo one foo=bar
CMD recognizes the " foo" syntax as redirection. It stops before the "="
delimiter. Then strips it out from the command line. After the redirection
has been processed, the command line becomes:
echo one =bar
Then that "one =bar" is outputed.
This is similar case when there's a file named "foo=bar" and below command
line is executed.
dir foo=bar
That ends up making DIR listing two files: "foo" and "bar". It's output
would be like this.
Volume in drive E is SOMETHING
Volume Serial Number is 1111-1111
Directory of E:\TEST
Directory of E:\TEST
File Not Found
Notice that it shows two "Directory of..." lines, instead of one.
|