Dave Tweed wrote: >> Are you sure about this? When was the last time you wrote a CLI >> program on Windows where you had to handle the raw command line and >> didn't have access to an array of parsed command line arguments? >> What language did you use? > > I never have. YOU'RE the one who said that applications built to work > with Windows shells need to handle quoted arguments. > > I assume that the command-line handling is hidden in run-time > libraries > that come with the software development environments for Windows. To clarify, Windows makes the whole command line available to the application as one string. You can do with it as you please. The shell does do some substitutions if you use special characters, but quotes are not significant. If you step back and think about it instead of just what you're used to, this isn't such a bad idea. I would rather the operating system not think it knows how my program wants to interpret the command line. Passing the whole thing as a raw string is the most policy-free thing to do. It's trivial enough to have some application-space layer parse it into tokens if that's how you want to view the command line. Any competent application that is intended to run accross platforms wouldn't make direct OS calls anyway. You use some kind of abstraction layer that presents the model your app wants to see. That layer is rewritten per OS to convert from the native interface to your portable interface. My software does this too. The routine STRING_CMLINE_TOKEN gets the next command line token. The Windows implementation parses the next token from the raw command line string, which includes stripping off enclosing quotes ("") or apostrophies (''). That's why I had totally forgotten about this distinction for 15 years until it was brought up here a few days ago. The "" and '' is my convention, and I appreciate Windows not trying to enforce something else. Unix has a rather different concept of the command line, and this same concept if also encoded in C by the definition of the call arguments to MAIN. Both these view the command line as a array of text string arguments. While that's generally how command lines are used, it is more restrictive, and I think a bad choice to enforce at the operating system and language level, even if eventually you want to view the command line that way at higher levels. I'd be curious to know how the conversion is done on Windows in the C runtime library to parse the command line into separate arguments that are then passed to MAIN. Is a outer set of quotes ("") stripped off? What about apostrophies ('')? What, if anything, does the C standard say about this? If this is left to the implementation, then you really can't blame Windows just because they chose a different but still complient approach. If the standard really does allow both interpretations, then it's clearly the app that is wrong if it assumes only possible implementation. Just to verify, I wrote a dumb program SHOW all the command line arguments as presented by STRING_CMLINE_TOKEN. It worked as expected. Here is the result when the command was entered using the Windows CMD shell: C:\olin\string>test_args abc "def" 'ghi' "'jkl'" '"mno"' 'pq''r' "st'u" Arg 1: abc Arg 2: def Arg 3: ghi Arg 4: 'jkl' Arg 5: "mno" Arg 6: pq'r Arg 7: st'u ******************************************************************** Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products (978) 742-9014. Gold level PIC consultants since 2000. -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist