Project

General

Profile

« Previous | Next » 

Revision 9017

*{.sh,run}: added extra line before new sections to visually separate them. lib/sh/util.sh: added missing section headers.

View differences:

lib/sh/util.sh
24 24
# this is needed because aliases defined inside an if statement are not
25 25
# available inside that if statement
26 26

  
27

  
27 28
if self_not_included "${BASH_SOURCE[0]}"; then
28 29

  
30

  
31
#### options
32

  
29 33
shopt -s expand_aliases
30 34

  
35

  
36
#### aliases
37

  
31 38
unalias () { builtin unalias "$@" 2>&- || true; } # no error if undefined
32 39

  
40

  
33 41
#### exceptions
34 42

  
35 43
alias rethrow='return "$e"'
......
64 72
alias end_try='rethrow'
65 73
alias end_try_subshell='rethrow_subshell'
66 74

  
75

  
67 76
#### integers
68 77

  
69 78
let () { builtin let "$@" || true; }
......
71 80

  
72 81
bool2int () { save_e test -z "$1"; echo "$e"; } # empty->0; non-empty->1
73 82

  
83

  
74 84
#### arrays
75 85

  
76 86
join () { local IFS="$delim"; echo "$*"; } # usage: delim=... join elems...
......
81 91
	for (( i=$#; i >= 1; i-- )); do printf '%q ' "${!i}"; done
82 92
}
83 93

  
94

  
84 95
#### verbose output
85 96

  
86 97
# usage: (stdout2stderr; cmd...) || return
......
197 208
fi # load new aliases
198 209
if self_being_included; then
199 210

  
211

  
200 212
#### strings
201 213

  
202 214
sed_ere_flag="$(test "$(uname)" = Darwin && echo E || echo r)"
203 215

  
204 216
sed () { self -"$sed_ere_flag" "$@";}
205 217

  
218

  
206 219
#### vars
207 220

  
208 221
set_var () { eval "$1"'="$2"'; }
......
223 236
EOF
224 237
)"
225 238

  
239

  
226 240
#### commands
227 241

  
228 242
top_script="$0" # outermost script
......
251 265
	done
252 266
}
253 267

  
268

  
254 269
#### URLs
255 270

  
256 271
localize_url () { test _"$1" = _"$(hostname -f)" || echo "$1"; }
lib/sh/db.sh
22 22

  
23 23
log_sql () { test "$verbosity" -ge 2; }
24 24

  
25

  
25 26
### MySQL
26 27

  
27 28
# auto-adds connection/login opts when specified
......
63 64
	mysqldump "$@"|sed 's/^(-- Dump completed).*$/\1/'
64 65
}
65 66

  
67

  
66 68
### PostgreSQL
67 69

  
68 70
pg_copy_to ()

Also available in: Unified diff