[Info-vax] Command Line Versus Command Line

Arne Vajhøj arne at vajhoej.dk
Fri May 24 08:13:04 EDT 2024


On 5/24/2024 7:38 AM, chrisq wrote:
> Perhaps, but from a programmers point of view, the elegance of the shell
> command line method is that on entry to main(), both the arg count and
> args are separated and ready to verify and use. All the background
> legwork is done for you.
> 
> If you just hand the whole command line to a program, you have to
> parse and separate the args, for every program you write, very bug
> prone and added effort. Whole idea of good system design is to free
> the programmer from repetition, and mundane stuff that the system
> should deal with...

I don't think it is a big problem on the consuming side - the
problem is on the producing side.

A lot of the most popular programming languages provides
split arguments to the program also on operating systems where
command line is considered a single string.

And for other languages the operating system likely provide
functionality to do the split. On VMS it is the CLI$
routines. Michael linked to CommandLineToArgv for
Windows.

Of course developers can still fuck it up with
a DIY solution, but if people choose DIY over what
is already provided for them, then they chose.

It is the other direction that is more tricky. You have
N separated arguments and need to produce a command
line that will actually be split into the same N
arguments. Not a super common requirement. But tricky
to get 100% correct.

As illustrated by the Rust issue.

Arne





More information about the Info-vax mailing list