Revision 9058
Added by Aaron Marcuse-Kubitza over 11 years ago
lib/sh/util.sh | ||
---|---|---|
277 | 277 |
top_dir="$(dirname "$top_script")" |
278 | 278 |
|
279 | 279 |
# auto-removes a command's output file on error (like make's .DELETE_ON_ERROR) |
280 |
function to_file () # usage: stdout=... to_file cmd... |
|
280 |
function to_file () # usage: stdout=... [if_not_exists=1] to_file cmd...
|
|
281 | 281 |
{ |
282 | 282 |
echo_func |
283 | 283 |
: "${stdout?}"; echo_vars stdout |
284 |
test ! "$if_not_exists" || test ! -e "$stdout" || return 0 |
|
284 | 285 |
"$@" >"$stdout" || { save_e; log_e; rm "$stdout"; rethrow; } |
285 | 286 |
} |
286 | 287 |
alias to_file='to_file ' # last space alias-expands next word |
Also available in: Unified diff
lib/sh/util.sh: to_file (): support only running if the file does not exist by setting $if_not_exists