Project

General

Profile

« Previous | Next » 

Revision 9270

lib/sh/util.sh: put usage message at end of line when possible, so that the function name always comes before it

View differences:

util.sh
197 197

  
198 198
log() { if can_log; then echo "$log_indent$PS4$1" >&"$log_fd"; fi; }
199 199

  
200
# usage: symbol=... log_custom msg
201
log_custom()
200
log_custom() # usage: symbol=... log_custom msg
202 201
{ log_indent="${log_indent//[^ ]/$symbol}" PS4="${PS4//[^ ]/$symbol}" log "$@";}
203 202

  
204 203
log_err() { symbol='#' verbosity=1 log_fd="$err_fd" log_custom "$@"; }
205 204

  
206 205
log_info() { symbol=: log_custom "$@"; }
207 206

  
208
# usage: cmd || { save_e; log_e; ...; rethrow; }
209
log_e() { log_err "command exited with error $e"; }
207
log_e() # usage: cmd || { save_e; log_e; ...; rethrow; }
208
{ log_err "command exited with error $e"; }
210 209

  
211
# usage: cmd || [type=...] die msg
212
die() { save_e; kw_params type; "log_${type:-err}" "$1"; rethrow; }
210
die() # usage: cmd || [type=...] die msg
211
{ save_e; kw_params type; "log_${type:-err}" "$1"; rethrow; }
213 212

  
214 213

  
215 214
#### functions
......
381 380

  
382 381
### external command input/output
383 382

  
384
# usage: cmd1 | { pipe_delay; cmd2; }
385
pipe_delay () { sleep 0.1; } # s; display after leading output of cmd1
383
pipe_delay () # usage: cmd1 | { pipe_delay; cmd2; }
384
{ sleep 0.1; } # s; display after leading output of cmd1
386 385

  
387 386
fi # load new aliases
388 387
if self_being_included; then

Also available in: Unified diff