-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
$ foo() { echo 'Checking $1'; : "${1:?}"; }
$ foo
Checking $1
-bash: 1: parameter null or not set
$ bc::cache foo
$ foo
$ echo $?
1
$ (set -x; client_type) |& tail -n 3
++ mktemp -d /tmp/bash-cache-0.8-274474/data/60/XXXXXXXXXX
+ cache=/tmp/bash-cache-0.8-274474/data/60/vZDnRVXVA1
+ bc::orig::client_typeThe failing ${1:?} expansion causes the shell to exit (in an interactive session it doesn't exit, but it does immediately terminate processing and return to the prompt, as if exiting). This prevents the function from being cached properly and, notably, suppresses the error message from being written to stderr.
Invoking the cached function in a subshell (i.e. ( "bc::orig::${func}" "${args[@]}" ) > "${cache}/out" 2> "${cache}/err" in bc::_write_cache) is sufficient to work-around this problem, but adding an extra subshell to every cache write would be an expensive solution.
Metadata
Metadata
Assignees
Labels
No labels