Project

General

Profile

« Previous | Next » 

Revision 9093

lib/sh/util.sh: import_vars alias and applicable aliases that use it: documented that when used inside another alias 2+ levels deep, it must be run inside a function. this is due to a strange bug in bash where $() expressions in 2-level aliases produce a syntax error when the alias is expanded outside a function.

View differences:

lib/sh/util.sh
264 264
get_prefix_vars() { : "${prefix:?}"; eval echo '${!'$prefix'*}'; }
265 265

  
266 266
# usage: local prefix=..._; import_vars
267
# when used inside another alias 2+ levels deep, *must* be run inside a function
267 268
alias import_vars="$(cat <<'EOF'
268 269
: "${prefix:?}"
269 270
declare src_var dest_var
lib/sh/db.sh
6 6
# using prefixed connection vars
7 7
alias use_local='declare prefix=local_; import_vars'
8 8
alias use_remote='declare prefix=remote_; import_vars'
9
alias use_local_remote='use_local; use_remote'
9
alias use_local_remote='use_local; use_remote' # *must* be run inside a function
10 10

  
11 11
quote='"'
12 12

  

Also available in: Unified diff