diff options
Diffstat (limited to 'shell/ash_test/ash-psubst')
-rw-r--r-- | shell/ash_test/ash-psubst/bash_procsub.right | 9 | ||||
-rwxr-xr-x | shell/ash_test/ash-psubst/bash_procsub.tests | 33 |
2 files changed, 42 insertions, 0 deletions
diff --git a/shell/ash_test/ash-psubst/bash_procsub.right b/shell/ash_test/ash-psubst/bash_procsub.right new file mode 100644 index 0000000..aa16a96 --- /dev/null +++ b/shell/ash_test/ash-psubst/bash_procsub.right @@ -0,0 +1,9 @@ +hello 1 +hello 2 +hello 3 +<(echo "hello 0") +hello 4 +HI THERE +hello error +hello error +hello stderr diff --git a/shell/ash_test/ash-psubst/bash_procsub.tests b/shell/ash_test/ash-psubst/bash_procsub.tests new file mode 100755 index 0000000..63b8367 --- /dev/null +++ b/shell/ash_test/ash-psubst/bash_procsub.tests @@ -0,0 +1,33 @@ +# simplest case +cat <(echo "hello 1") + +# can have more than one +cat <(echo "hello 2") <(echo "hello 3") + +# doesn't work in quotes +echo "<(echo \"hello 0\")" + +# process substitution can be nested inside command substitution +echo $(cat <(echo "hello 4")) + +# example from http://wiki.bash-hackers.org/syntax/expansion/proc_subst +# process substitutions can be passed to a function as parameters or +# variables +f() { + cat "$1" >"$x" +} +x=>(tr '[:lower:]' '[:upper:]') f <(echo 'hi there') + +# process substitution can be combined with redirection on exec +rm -f err +# save stderr +exec 4>&2 +# copy stderr to a file +exec 2> >(tee err) +echo "hello error" >&2 +sync +# restore stderr +exec 2>&4 +cat err +rm -f err +echo "hello stderr" >&2 |