Revision 9622
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
627 | 627 |
|
628 | 628 |
#### commands |
629 | 629 |
|
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' |
|
630 |
already_exists_msg() # usage: cond || what=... already_exists_msg || return 0 |
|
631 |
{ type=info die "$what already exists, skipping"; } |
|
634 | 632 |
|
635 | 633 |
require_not_exists() # usage: require_not_exists file || return 0 |
636 |
{ test ! -e "$1" || what="file \"$1\"" "already_exists_msg"; }
|
|
634 |
{ test ! -e "$1" || what="file \"$1\"" already_exists_msg; }
|
|
637 | 635 |
|
638 | 636 |
function to_file() # usage: stdout=... [if_not_exists=1] to_file cmd... |
639 | 637 |
# 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: undid r9621 because the `|| return 0` should actually always be explicitly specified by the caller, to make it clear that the function will be aborted