Kron Shell: Functions-LinuxLeon
Kron Shell: Functions 1. Reference to foo functionfoo ( ) {
}
2. Var scoping
kshVar scoping as inherited
#!/bin/ksh a()
{
typeset tmp=$1
tmp="changed"
}
b()
{
typeset tmp="wangjing"
echo $tmp
a "${tmp}"
echo $tmp
}
set -x
b
output
+ b + tmp=wangjing
+ typeset tmp
+ echo wangjing
wangjing
+ a wangjing
+ tmp=wangjing
+ typeset tmp
+ tmp=changed
+ echo changed
changed
3. Specific Parameters parsing
$# $0 $1 $* $@
● Unquoted $* is the same as $@
● "$*" is equivalent to "$1 $2 ... $n"
● "$@" is equivalent to "$1" "$2" ... "$n"
页:
[1]