The debug operation logs one or more values at the debug level and then
returns the last value unchanged. When called with no arguments, it defaults to
logging the current value of _. When provided values, it logs each argument’s
string representation, joins them with spaces, and emits a single line to
standard error. After logging, the last value is rebound to the specified
destination or _ if none is provided.
The syntax of the debug operation is:
[ $destination ] debug [ value1 [ value2 … ] ]
If no $destination or values are given, debug is equivalent to:
_ debug _
logging the current _ value. If values are provided, you must supply a
destination when specifying any values; otherwise, omit both to log _.
For example, to log the current value without rebinding a name:
debug
If _ holds 42, this writes:
42
to stderr and leaves _ as 42.
To log two values and bind the last one explicitly:
$result debug $interimList $statusFlag
If interimList is ["a","b"] and statusFlag is true, this writes:
[“a”,”b”] true
to stderr and then binds true to result.
Any misuse–such as providing values without a destination–results in a parse or runtime error.