Project

General

Profile

« Previous | Next » 

Revision 9099

lib/sh/db.sh: mysql_cmd: get command name by adding $FUNCNAME in an alias instead of using ${FUNCNAME1} in the function, so that callers can also call mysql_cmd via a nested function, etc.

View differences:

lib/sh/db.sh
35 35
if self_being_included; then
36 36

  
37 37
# auto-adds connection/login opts when specified
38
mysql_cmd() # usage: mysql*() { ...; mysql_cmd "$@"; }
38
# usage: mysql*() { ...; mysql_cmd "$@"; } (with alias)
39
function mysql_cmd() # usage: mysql*() { ...; mysql_cmd cmd "$@"; }
39 40
{
40 41
	echo_func
42
	local cmd="$1"; shift
41 43
	local ssh_server="$(localize_url "$ssh_server")"
42 44
	local server="$(localize_url "$server")"
43 45
	if test "$ssh_server"; then
......
46 48
	set_database
47 49
	
48 50
	local var=ssh_dest; local_inv
49
	command ${ssh_dest:+ssh "$ssh_dest" }"${FUNCNAME[1]}" \
51
	command ${ssh_dest:+ssh "$ssh_dest" }"$cmd" \
50 52
${server:+ --host="$server" }${user:+--user="$user" } --password\
51 53
${password+="$password"} "$@"
52 54
}
55
alias mysql_cmd='mysql_cmd "$FUNCNAME"'
53 56

  
57
fi # load new aliases
58
if self_being_included; then
59

  
54 60
mysql()
55 61
{
56 62
	echo_func

Also available in: Unified diff