Capture failed pipeline
pmatos opened this issue · 2 comments
I am starting to have more and more scripts using rash but they are quite flaky in general.
One thing I still haven't figured out the best way to achieve is grab a pipeline failure with the failing exit code. For example:
#lang rash
(define (my-false)
{true
echo "1"
false
echo "42"})
I get:
> (my-false)
1
; run-pipeline: unix pipeline-segment (#<path:/usr/bin/false>) terminated with code 1
;
; Context:
; /home/pmatos/.racket/7.3/pkgs/shell-pipeline/private/mixed-pipeline.rkt:161:6 for-loop
; /home/pmatos/.racket/7.3/pkgs/shell-pipeline/private/mixed-pipeline.rkt:257:0 unpack21
; /home/pmatos/Projects/igalia/jsc-utils/webkit.rkt:23:0 my-false
; /home/pmatos/installs/racket-7.3/collects/racket/repl.rkt:11:26
I see the error
call that terminates this in the rash source (https://github.com/willghatch/racket-rash/blob/master/shell-pipeline/private/mixed-pipeline.rkt) however this error call is less than ideal if I want to grab the error and the exit code. I could in principle catch the exception thrown by error
(exn:fail
) and parse the string, however this is less than ideal. Is there a good way to actually do this at the moment?
The flakiness comes exactly from this problem of not being able to properly catch failures. A new exception is exactly what I was thinking about. I will take a look at it later today and if I can put together something I will send a PR even if in draft mode. Glad you agree this can be improved. Thanks for rash - it's awesome - needs a marketing team!