opendylan icon indicating copy to clipboard operation
opendylan copied to clipboard

run-application docs are outdated

Open cgay opened this issue 7 years ago • 8 comments

The system:operating-system:run-application documentation is very outdated and doesn't mention any of the new arguments.

cgay avatar Aug 25 '18 05:08 cgay

The new features were partially inspired by sb-ext:run-program; its documentation could also serve as inspiration for documenting run-application.

housel avatar Aug 25 '18 20:08 housel

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.

cgay avatar Oct 01 '18 05:10 cgay

Is this under Linux? And, what other args are you passing to run-application ? As you say, they ought to be equivalent.

pedro-w avatar Oct 01 '18 07:10 pedro-w

$ uname -a Linux dodo2 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux

cgay avatar Oct 01 '18 14:10 cgay

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.

pedro-w avatar Oct 01 '18 19:10 pedro-w

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.

pedro-w avatar Oct 02 '18 06:10 pedro-w

That makes sense, and will be clarified when/if I update the documentation. Thanks!

cgay avatar Oct 02 '18 20:10 cgay

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

pedro-w avatar Oct 04 '18 15:10 pedro-w

I think I addressed this in #1473.

cgay avatar Jun 20 '23 04:06 cgay