3
0

bash_procsub.tests 723 B

123456789101112131415161718192021222324252627282930313233
  1. # simplest case
  2. cat <(echo "hello 1")
  3. # can have more than one
  4. cat <(echo "hello 2") <(echo "hello 3")
  5. # doesn't work in quotes
  6. echo "<(echo \"hello 0\")"
  7. # process substitution can be nested inside command substitution
  8. echo $(cat <(echo "hello 4"))
  9. # example from http://wiki.bash-hackers.org/syntax/expansion/proc_subst
  10. # process substitutions can be passed to a function as parameters or
  11. # variables
  12. f() {
  13. cat "$1" >"$x"
  14. }
  15. x=>(tr '[:lower:]' '[:upper:]') f <(echo 'hi there')
  16. # process substitution can be combined with redirection on exec
  17. rm -f err
  18. # save stderr
  19. exec 4>&2
  20. # copy stderr to a file
  21. exec 2> >(tee err)
  22. echo "hello error" >&2
  23. sync
  24. # restore stderr
  25. exec 2>&4
  26. cat err
  27. rm -f err
  28. echo "hello stderr" >&2