Revision 9129
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
301 | 301 |
|
302 | 302 |
#### streams |
303 | 303 |
|
304 |
fd_exists () { (: <&"$1") 2>/dev/null; }
|
|
304 |
fd_exists() { (: <&"$1") 2>/dev/null; } |
|
305 | 305 |
|
306 | 306 |
require_fd_not_exists() # usage: require_fd_not_exists fd || return 0 |
307 | 307 |
{ ! fd_exists "$1" || type=info die "fd $1 already exists, skipping"; } |
308 | 308 |
|
309 |
set_fd () # usage: dest=fd dir='[<>]' src=fd [noclobber=1] set_fd
|
|
309 |
set_fd() # usage: dest=fd dir='[<>]' src=fd [noclobber=1] set_fd |
|
310 | 310 |
{ |
311 | 311 |
inc_log_level; echo_func |
312 | 312 |
: "${dest:?}" "${dir:?}" "${src:?}" |
... | ... | |
314 | 314 |
echo_eval exec "$dest$dir&$src" |
315 | 315 |
} |
316 | 316 |
|
317 |
shadow_fd () # usage: prefix=# src=fd dir='[<>]' shadow_fd
|
|
317 |
shadow_fd() # usage: prefix=# src=fd dir='[<>]' shadow_fd |
|
318 | 318 |
{ |
319 | 319 |
echo_minor_func |
320 | 320 |
: "${prefix:?}" "${src:?}" "${dir:?}" |
... | ... | |
323 | 323 |
|
324 | 324 |
# convention: use fd 10/11/12 for command-specific alternate stdin/stdout/stderr |
325 | 325 |
|
326 |
set_global_fds ()
|
|
326 |
set_global_fds() |
|
327 | 327 |
# allows commands to access global stdin/stdout/stderr using fd 20/21/22 |
328 | 328 |
# this works even when /dev/tty isn't available |
329 | 329 |
{ |
Also available in: Unified diff
*{.sh,run}: removed extra space between function name and ()