run-application docs are outdated
The system:operating-system:run-application documentation is very outdated and doesn't mention any of the new arguments.
The new features were partially inspired by sb-ext:run-program; its documentation could also serve as inspiration for documenting run-application.
I noticed today that of the two commands below, which I believe should be equivalent, only the first one works. The second one invokes git but provokes its "usage:" message.
let command = format-to-string("git clone --recurse-submodules --branch=%s -- %s %s",
branch, url, as(<str>, dest-dir));
let command = as(<str-vec>,
list("git", "clone", "--recurse-submodules",
concat("--branch=", branch), "--", url, as(<str>, dest-dir)));
Not sure if it's a bug in the implementation, in my code, or if it's something that just needs to be documented.
Is this under Linux? And, what other args are you passing to run-application ? As you say, they ought to be equivalent.
$ uname -a Linux dodo2 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux
Also on macos, with this simplified code:
define constant <str-vec> = limited(<vector>, of: <string>);
define function run-application-problem () => ()
run-application("git config -l");
run-application(as(<str-vec>, #("git", "config", "-l")));
end function;
I can look into it.
I think it's working as intended. The command line eventually gets passed to execve as a C array of strings.
let command = format-to-string("git clone --recurse-submodules --branch=%s -- %s %s",
branch, url, as(<str>, dest-dir));
becomes (because under-shell? is true by default)
{"sh", "-c", "git clone --recurse-submodules --branch=... -- ... ...", NULL}
and
let command = as(<str-vec>,
list("git", "clone", "--recurse-submodules",
concat("--branch=", branch), "--", url, as(<str>, dest-dir)));
becomes
{"sh", "-c", "git", "clone", "--recurse-submodules", "--branch=...", "--", "...", "...", NULL}
So the former works because the shell runs that whole command, the latter doesn't because the -c option for sh just takes the next argument (git) . The rest of the args disappear off somewhere.
So the specialization of run-application which takes a string is the same as sending a one-element sequence with that string in it; it doesn't split the string into separate args.
That makes sense, and will be clarified when/if I update the documentation. Thanks!
FYI I wasn't happy with my assertion that "The rest of the args disappear off somewhere" and asked a question on SO, which was answered very clearly. https://stackoverflow.com/questions/52649315/what-happens-to-extra-arguments-in-sh-invocation
I think I addressed this in #1473.