Revision 9255
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
394 | 394 |
require_fd_not_exists() # usage: require_fd_not_exists fd || return 0 |
395 | 395 |
{ ! fd_exists "$1" || type=info die "fd $1 already exists, skipping"; } |
396 | 396 |
|
397 |
set_fd() # usage: dest=fd expr='[<>]&fd' [noclobber=1] set_fd
|
|
397 |
set_fd() # usage: dest=fd expr='[<>]src' [noclobber=1] set_fd
|
|
398 | 398 |
{ |
399 |
echo_func; kw_params dest dir src
|
|
399 |
echo_func; kw_params dest expr
|
|
400 | 400 |
: "${dest:?}" "${expr:?}" |
401 | 401 |
test ! "$noclobber" || require_fd_not_exists "$dest" || return 0 |
402 |
echo_eval exec "$dest$expr"
|
|
402 |
echo_eval exec "$expr" |
|
403 | 403 |
} |
404 | 404 |
|
405 |
shadow_fd() { noclobber=1 set_fd; } # usage: dest=fd expr='[<>]&fd' shadow_fd
|
|
405 |
shadow_fd() { noclobber=1 set_fd; } # usage: dest=fd expr='[<>]src' shadow_fd
|
|
406 | 406 |
|
407 | 407 |
# convention: use fd 10/11/12 for command-specific alternate stdin/stdout/stderr |
408 | 408 |
|
Also available in: Unified diff
lib/sh/util.sh: set_fd()/shadow_fd(): updated usage and kw_params