liyao20060101 发表于 2018-8-23 08:04:03

Kron Shell: Functions-LinuxLeon

Kron Shell: Functions  1. Reference to foo function
foo ( )  {
  }
  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]
查看完整版本: Kron Shell: Functions-LinuxLeon