Kron Shell: Functions

Kron Shell: Functions

1. Reference to foo function

foo ( )
{
}


2. Var scoping
ksh Var 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"


你可能感兴趣的:(shell,var,scoping,funciton;,ksh;Korn)