Closed u-u-h closed 5 years ago
The best practice with Swift/T is to use an app function to call a shell script, then handle any errors in the shell script. Or put the exit code in a file where you can read() it later from Swift/T, but always exit 0 as far as Swift/T is concerned.
The other thing you could try is the system() and system1() functions: http://swift-lang.github.io/swift-t/guide.html#stdlib_system
Did you get this working as intended?
It is on my todo list for late this year. Current plan is to implement something and post a pull request here.
Ok, feel free to re-open this.
When using an
app
function where the command indicates errors using a nonzero exit code the wrapping logic captures an error message, and I get a stack trace, but not the actual error code. When wrapping a simple utility function (say:curl(1)
) the calling code may want to programmatically handle the exit code and not declare it complete program failure (e.g., an array or URLs get fetched in parallel; some may fail, we're only interested in the successful ones and the failure code).I know I could write a full TCL wrapper with
try ...
block, but it seems to be a common pattern for app functions. Adding an @exitcode argument (like @stdout) seems like a clean way to express things in a backward-compatible fashion. Implementation requires touching a few more places in the turbine code base than I'd like to, so I don't have a patch yet.