4 ms·
True in principle: On Windows, the fundamental data structure for command line args is an array, while on linux it's an array of strings. I think you could arg
by xg15 5y ago
True in principle: On Windows, the fundamental data structure for command line args is an array, while on linux it's an array of strings.
I think you could argue that an array is a better-suited data structure than a single string though, as most programs take more than a single argument on the command line.
Also note than on unixy systems, the command line is only "serialized as an array" when you run a command from the shell. (And then the shell does the serialisation, not the OS).
If a program is launched by another process, the command line is always an array, never a string.
- zokier 5y ago> Also note than on unixy systems, the command line is only "serialized as an array" when you run a command from the shell. (And then the shell does the serialisation, not the OS). > If a program is launched by another process, the command line is always an array, never a string. Maybe an example illustrates what I meant by serializing the command-line expression. Many programs take key-value arguments in the form `--key value`, so conceptually that is not an array but a serialization of key-value mapping into an array. You could imagine that an higher level wrapper to call that program could be represented as `exec_foo({"key": "value"})`, and that argument map is then serialized into the string array `--key value`. Of course that sort of serialization of higher-level concepts (like key-value mappings or subcommands or whatev) is very much target program specific. Which leads to the main argument that in any non-trivial cases you need to serialize the higher-level "api" (which might be key-value mapping, or something more complex) to the "wire format" which can be either array of strings or single string; conceptually that is fairly minor difference.