Command Errors

By default, Idio will exit with the same exit status as any external command that fails (including signals). This aggressive nature is deliberate.

Some filthy casuals might consider that to be inconvenient so you can suppress various aspects of this behaviour.

For each of these examples you can try running with the value set to #f, the default, or #t by removing the comment character ;.

suppress-pipefail!

This is much like the inverse of the shell’s set -o pipefail setting. It defaults to #f, ie. Idio will fail if any of the processes in a pipeline fail.

suppress-pipefail.idio
;suppress-pipefail! = #t

false | true

(jobs)
$ idio suppress-pipefail
$ echo $?
1

# edit suppress-pipefail.idio

$ idio suppress-pipefail

job      0: a?=#f: ((false) (true))
           PID fl  status       cmd
  proc: 157346  C  (exit 1)     (false)
  proc: 157347  C  (exit 0)     (true)
  flags: C - completed; !C - not completed; S - stopped
 Started at Mon Nov 14 15:30:21 2022, ran for 0s
 R 0.011; U 0.005; S 0.014

suppress-exit-on-error!

This is much like the inverse of the shell’s set -e (and set -E if available) setting, defaulting to #f, ie. Idio will fail if the last process in a pipeline fails.

suppress-exit-on-error.idio
;suppress-exit-on-error! = #t

true | false

(jobs)
$ idio suppress-exit-on-error
$ echo $?
1

# edit suppress-exit-on-error.idio

$ idio suppress-exit-on-error


job      0: a?=#f: ((true) (false))
           PID fl  status       cmd
  proc: 157515  C  (exit 0)     (true)
  proc: 157516  C  (exit 1)     (false)
  flags: C - completed; !C - not completed; S - stopped
 Started at Mon Nov 14 15:36:03 2022, ran for 0s
 R 0.012; U 0.003; S 0.017

suppress-async-command-report!

There is no equivalent to this in the shell. Idio does not exit if an asynchronous command fails but it will report any failure by default.

suppress-async-command-report.idio
;suppress-async-command-report! = #t

iph := pipe-from false

printf "iph is %s\n" iph

close-handle iph

(jobs)
$ idio suppress-async-command-report
default-racse-handler: this async job result has been ignored:[158530]:
job 158531: a?=#t: ((false))
           PID fl  status       cmd
  proc: 158531  C  (exit 1)     (false)
  flags: C - completed; !C - not completed; S - stopped
 Started at Mon Nov 14 15:54:41 2022, ran for 0s
 R 0.009; U 0.003; S 0.006


iph is #<H opr!   4:"/dev/fd/4":1:0>

# edit suppress-async-command-report.idio

$ idio suppress-async-command-report
iph is #<H opr!   4:"/dev/fd/4":1:0>

Note

  1. “racse” stands for Report Asynchronous Command Status Error

  2. Asynchronous commands are given a Process Group ID even in scripts

Last built at 2024-11-21T07:11:43Z+0000 from 77077af (dev) for Idio 0.3