Using staticExec the return value of the executed program can't be checked. Even the manual's example of git rev-parse HEAD can fail if you're not inside a git repo, which you can't catch nicely. I think staticExec should either return an empty string if the return value isn't 0, or have a way to get back the return value as well as stdout.
git rev-parse HEAD
Throw an exception if the return code is non-zero?
It's not quite as simple as that (besides, exceptions should be used for unexpected, exceptional cases). Different platforms have different ideas on what a error return code is.
There are three ways I've seen:
Personally, I think 2 would be the best, since platform-specific error codes might not matter; it could just have a succeeded boolean attribute.
2 is by far the hardest to implement and 1 affects backwards compatibility. What should be done is that the proc grows an "onErrorRaise= true" flag and then an OSError exception is raised. If set to false the empty string is returned instead.
Wouldn't it make sense to force users to check the return code of the process? Therefore breaking backwards compatibility should be acceptable in this case.
@dom96 Returning a tuple is quite hard to do in the VM though.
@Araq Why is it hard?
Now at least it produces "" instead of crashing, I think.
That sounds like it will lead to some ambiguities.
added system.gorgeEx that includes the exitCode; refs #4874; fixes #1994