Project

General

Profile

« Previous | Next » 

Revision 8973

lib/util.sh: use `|| return` instead of `|| exit` because `|| exit` doesn't seem to work inside functions (it does not have the errexit effect). also, `|| return` has the advantage of not exiting the program if the caller used || after the command (i.e. as an error handler) to temporarily disable errexit.

View differences:

lib/util.sh
59 59

  
60 60
#### verbose output
61 61

  
62
# usage: (stdout2stderr; cmd...) || exit
63
# `|| exit` needed on Mac because of bug where -e doesn't apply to ()
62
# usage: (stdout2stderr; cmd...) || return
63
# `|| return` needed on Mac because of bug where -e doesn't apply to ()
64 64
stdout2stderr () { exec >&2; }
65 65

  
66 66
: "${verbosity:=$verbose}" "${verbosity:=0}"
......
76 76
alias dec_log_level='declare verbosity="$verbosity" PS4="${PS4#$log_indent}"
77 77
let verbosity++'
78 78

  
79
# usage: (log_stderr; cmd...) || exit
80
# `|| exit` needed on Mac because of bug where -e doesn't apply to ()
79
# usage: (log_stderr; cmd...) || return
80
# `|| return` needed on Mac because of bug where -e doesn't apply to ()
81 81
log_stderr () { if ! can_log; then exec 2>/dev/null; fi; }
82 82

  
83 83
log_stderr_cmd () # usage: [stdout2stderr=1] log_stderr_cmd cmd...

Also available in: Unified diff