I have some questions on the subject, of commas compared to space, in delimiting parameters.
They are questions that C programmers familiar with the cmd prompt, may be able to throw some light on..
I know that when doing
c:\>program a b c
there are 4 parameters [0]=program
[1]=a
[2]=b
[3]=c
According to hh ntcmds.chm
concepts..
Shell overview
; and , are used to separate parameters
; or , command1 parameter1;parameter2 Use to separate command parameters.
I see dir a,b
gives the same result as dir a b
but
c:\>program a,b,c
gives parameters [0]=program [1]=a,b,c
So do some? or all? windows commands use ; and , ? and is that interpretation within the code of each command, or done by the shell like with space?
And if it is in the code of each command.. how would I know which do it?
I notice that documentation of explorer.exe mentions the comma,e.g. you can do
explorer /e,.
but DIR /? does not mention it, but can use it. And a typical c program doesn't take , as a delimiter at all.. So is it the case that the shell doesn't use comma to delimit, it uses space. And windows commands that do, do so 'cos they are (all?) written to delimit the parameters the shell has given them further when commas are used?
In the Command Prompt, the caret character ( ^ ) will let you escape spaces—in theory. Just add it before each space in the file name. (You'll find this character in the number row on your keyboard.
The Windows command-line interpreter uses a caret character ( ^ ) to escape reserved characters that have special meanings (in particular: & , | , ( , ) , < , > , ^ ).
Double quotes enable escaping through the use of the backslash (\). For example, if the special character semicolon is a value that is double-quoted, it should be represented as backslash semicolon (\;) so that the Integration Engine knows that the actual value (;) should be used.
You can put the arguments in quotes: myprogram.exe "(this is some text, with special characters.)"
There are two differences here between Unix and Windows:
DIR
are built into the shell; their command line syntax doesn't have to follow the same rules as for regular programsWindows C programs built using Visual Studio use the command line parser in the Microsoft C runtime, which is similar to a typical Unix shell parser and obeys spaces and quotation marks.
I've never seen a C program that uses ,
or ;
as a command line separator. I was aware of the special case for explorer /e,.
, but I'd never seen the dir a,b
example until just now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With