Collecting Output

collect-output is a pipeline meta-command which returns the command’s output as a string with any trailing newlines removed. This is the equivalent to the shell’s Command Substitution, $(...).

collect-output.idio
;; for simple commands
sysname := collect-output uname -s

printf "sysname is %s\n" sysname

;; or pipelines
count := collect-output uname -s | wc -c

printf "sysname is %s characters\n" count
$ idio collect-output
sysname is Linux
sysname is 6 characters

Asynchronous Commands

The job being run for collect-output is termed an asynchronous command. Whether an asynchronous command succeeds or fails does not affect whether Idio chooses to exit because of command failure as the asynchronous command is not on the critical path of Idio itself.

Idio will, by default, issue a report if an asynchronous command fails.

Last built at 2024-06-17T06:11:37Z+0000 from 77077af (dev) for Idio 0.3