source:
vendor/bash/3.1/examples/functions/coproc.bash
| Last change on this file was 3228, checked in by , 19 years ago | |
|---|---|
| File size: 1.7 KB | |
| Rev | Line | |
|---|---|---|
| [3228] | 1 | # coprocess.bash |
| 2 | # | |
| 3 | # vi:set sts=2 sw=2 ai: | |
| 4 | # | |
| 5 | ||
| 6 | coprocess_pid= | |
| 7 | ||
| 8 | # | |
| 9 | # coprocess - Start, control, and end coprocesses. | |
| 10 | # | |
| 11 | function coprocess () | |
| 12 | { | |
| 13 | while (( $# > 0 )) ; do | |
| 14 | case "$1" in | |
| 15 | # | |
| 16 | # coprocess close | |
| 17 | # | |
| 18 | c|cl|clo|clos|close) | |
| 19 | shift | |
| 20 | exec 61>&- 62<&- | |
| 21 | coprocess_pid= | |
| 22 | if [ "$1" = "-SIGPIPE" ] ; then | |
| 23 | # Only print message in an interactive shell | |
| 24 | case "$-" in | |
| 25 | *i*) | |
| 26 | echo 'SIGPIPE' >&2 | |
| 27 | ;; | |
| 28 | esac | |
| 29 | return 1 | |
| 30 | fi | |
| 31 | return 0 | |
