Revision 9621
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
627 | 627 |
|
628 | 628 |
#### commands |
629 | 629 |
|
630 |
already_exists_msg() # usage: cond || what=... already_exists_msg || return 0 |
|
631 |
{ type=info die "$what already exists, skipping"; } |
|
630 |
# err handler usage: cond || what=... already_exists_msg |
|
631 |
# ..._not_exists() func usage: cond || what=... "already_exists_msg" |
|
632 |
function already_exists_msg() { type=info die "$what already exists, skipping";} |
|
633 |
alias already_exists_msg='"already_exists_msg" || return 0' |
|
632 | 634 |
|
633 | 635 |
require_not_exists() # usage: require_not_exists file || return 0 |
634 |
{ test ! -e "$1" || what="file \"$1\"" already_exists_msg; }
|
|
636 |
{ test ! -e "$1" || what="file \"$1\"" "already_exists_msg"; }
|
|
635 | 637 |
|
636 | 638 |
function to_file() # usage: stdout=... [if_not_exists=1] to_file cmd... |
637 | 639 |
# auto-removes a command's output file on error (like make's .DELETE_ON_ERROR) |
Also available in: Unified diff
lib/sh/util.sh: already_exists_msg(): added alias for use as an error handler. note that ..._not_exists() functions should continue to use the "already_exists_msg" function instead to preserve the exit status.