On 07-Jul-17 8:38 PM, Manfred wrote:
> On 7/7/2017 5:46 PM, Alf P. Steinbach wrote:
>> It replaces every `'\0'` with a space, to synthesize a possible
>> original command line like the one in Windows. The idea is to provide
>> conceptually the same on all platforms. Hence the need for quoting for
>> the general case, if I understand this correctly (I'm not 100% sure).
>
> I, for one, find the *nix cmdline arg handling definitely better
> designed than Windows's (which in fact does nothing useful with it), so
> why the attempt to build a Windows-like command line, and not the other
> way around?
I provide both. See the interface presented in original posting. I like
the Winnie the Pooh response to “honey or syrup?”, namely “both, thank
you”. :)
> If you wish, your library could set up a decent argc/argv set from the
> Windows command line,
It does.
> e.g. including wildchar expansion and the like.
Yes, I've considered that, thanks!, but, first of all, I must do one
thing at a time. And secondly, as opposed to providing command line
arguments in UTF-8, which is both an implementation fix and a core
language + standard library design level fix, I think wildchar expansion
would be a distinct /extension/ of the C++ standard library. In
contrast, the intent of /stdlib/ is just to fix the implementation, to
provide a more practically usable implementation. Wrt. that goal of
limitation providing command line arguments is border-line already, and
necessarily treated as an extension, but I think it may be crucial to
enable and foster adoption of the library. For only if /stdlib/ makes
client code at least as convenient or more convenient than with the
/NoWide/ library (adopted in Boost last month), will it fly, I think.
But doing that by default, as MinGW g++ unfortunately does for the
arguments of `main`, breaks expectation in Windows: it does not conform
to the convention established by the main compiler for the platform.
For example, the Windows / Visual C++ approach allows you to write a
`fastmove` program that accepts `fastmove *.bah someplace\*.foo`. That
will just not work with with MinGW g++'s default. And I don't know any
way to tell MinGW g++ to not do that. :(
The current design of fetching the data from the OS on all systems, is
in part motivated by the need to fix MinGW g++'s effectively broken
implementation: since I fail to fix it, I provide an alternative.
And partly this design is motivated by MinGW g++ not conforming to the
Visual C++ convention wrt. to the `__argv` and `__argc` variables (it's
a Windows thing). Changing these works with Visual C++, but doesn't
affect the arguments that MinGW g++ passes to `main`. Thus it's
apparently not possible with a transparent fix of MinGW g++'s behavior,
and the /NoWide/ solution of passing on argc and argv, is abhorrent to
me (I also suspect that it's simply wrong when pitted against MinGW g++
and wildcard arguments, but I haven't tested that yet).
> A lot could be done in that direction (ref the sh/bash manpage) although
> I cannot say if it can be worth the effort at all on Windows, given the
> limited use of cmdline args on this platform.
Command line args are used most every time you “open” a file in Windows,
e.g. by double-clicking it.
> On the other hand, a program targeted for *nix most probably wants to
> use the native argc/argv, since they are quite effectively preprocessed
> by the shell, and it wants to make use of its features.
Yes.
Except where one makes use of some 3rd party top level code, where one
doesn't have access to the `main` arguments.
> I am not sure what you mean about need for quoting, anyway on *nix
> quoting is processed by the shell, and it is removed after interpreting
> that a quoted string has to be parsed in its well defined way (e.g. as a
> single argument if it includes spaces - the QUOTING subsection of the
> bash manpage is two pages of dense specification) before passing the
> result to the program.
Well I meant the `command_line()` function to produce a possible command
line that, when used to create a new process, would reproduce exactly
the command line args here.
Client code that needs the individual arguments can just access them via
`Command_line_args`.
Cheers!, & thanks for your feedback,
- Alf