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"


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章