www.delorie.com/djgpp/v2faq/faq130.html | search |
| Previous | Next | Up | Top |
Q: How do I pass a command-line argument which contains double quotes?
Q: How do I pass an argument which begins with the @ character?
main
function (see
description of filename expansion), and the quote characters serve to protect the arguments from expansion. You should escape-protect the quote characters with a
backslash in order for them to be treated as literal characters. For example, if you have a file called myfile.c'v, type it as myfile.c\'v when you call your program. If
you have single quotes in your program arguments and you don't want those arguments to be expanded, then surround them by double quotes, like this: "*.c'v". The program will
get the string *.c'v with the double quotes stripped away. Note that backslashes are only special if they are in front of a quote, whitespace, or backslash (they also serve as DOS directory separators, remember?). This is also different from what you get under a Unix shell.
The @ character serves to signal a response file (see the description of response file method), so it's also special. To pass an argument whose first character is @, surround that argument with single or double quotes, otherwise it will be taken as a name of a response file which holds the actual command line.
Note that you can quote parts of the wildcard to protect only those parts from expansion; the unquoted parts will still be expanded. This allows to use wildcards with embedded whitespace and expand file names with special characters which need to be quoted, like in c:/Prog*' 'F* (which should expand into c:/Program Files) and *.c"'"v (which should expand into all files with the *.c'v extension).
webmaster donations bookstore | delorie software privacy |
Copyright ⌐ 1998 by Eli Zaretskii | Updated Sep 1998 |
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)