Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request for an API that do not exit when executable to run is not found #90

Open
Frizlab opened this issue Jul 17, 2020 · 2 comments
Open

Comments

@Frizlab
Copy link

Frizlab commented Jul 17, 2020

Specifically I’m launching a process in a server (yes, I know, I shouldn’t!), and it’s a pity having a server being killed like that, even in the case of a misconfiguration.

I’ve seen the launchThrowably() method on the Process extension; I was thinking of something along these lines but for runAsync (e.g. runAsyncThrowably?)

@kareman
Copy link
Owner

kareman commented Jul 18, 2020

Yes this is something that should be better supported in SwiftShell. It might be better to have all the run*-commands throw errors if they can't be executed.

For now you can verify the command is available first:

guard SwiftShell.run("which","wrongcommand").succeeded else {
	// handle error
}
let c  = runAsync("wrongcommand")

Or you can let bash handle it:

let c  = runAsync(bash: "wrongcommand")
try c.finish()

Then the error will be thrown when you call finish().

@Frizlab
Copy link
Author

Frizlab commented Sep 23, 2020

Another workaround, I think, would be to call runAsync("/usr/bin/env", "wrongcommand"). The wrongcommand can even be a full path, it seems to work.
There are few OSes where /usr/bin/env does not exist AFAICT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants