www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - minor question of the difference between " and '

reply WhatMeWorry <kheaser gmail.com> writes:
string pwdxCommand = escapeShellCommand("pwdx", to!string(pid));
writeln("pwdxCommand = ", pwdxCommand);

Output:
     Current process ID: 7962
     pwdxCommand = 'pwdx' '7962'


I'm confused as to why the writeln statement didn't output "pwdx 
7962"?
Afterall, isn't that the definition of a string?  So what's up 
with the two groupings of single quotes?

BTW, those aren't backticks?  (think that is what the key is 
called)

Thanks in advance.
Aug 10 2016
next sibling parent =?UTF-8?Q?Ali_=c3=87ehreli?= <acehreli yahoo.com> writes:
On 08/10/2016 04:32 PM, WhatMeWorry wrote:
 string pwdxCommand = escapeShellCommand("pwdx", to!string(pid));
 writeln("pwdxCommand = ", pwdxCommand);

 Output:
     Current process ID: 7962
     pwdxCommand = 'pwdx' '7962'


 I'm confused as to why the writeln statement didn't output "pwdx 7962"?
 Afterall, isn't that the definition of a string?  So what's up with the
 two groupings of single quotes?

 BTW, those aren't backticks?  (think that is what the key is called)
No, they are not backticks. This is: ` :)
 Thanks in advance.
I haven't used it myself but judging from it's documented purpose, those quotes are used to allow spaces so that the shell considers it a single command line argument as a whole: grep 'foo bar' * git commit -m 'My message' etc. Ali
Aug 10 2016
prev sibling parent pineapple <meapineapple gmail.com> writes:
On Wednesday, 10 August 2016 at 23:32:54 UTC, WhatMeWorry wrote:
 Afterall, isn't that the definition of a string?  So what's up 
 with the two groupings of single quotes?
http://www.howtogeek.com/howto/29980/whats-the-difference-between-single-and-double-quotes-in-the-bash-shell/
Aug 11 2016