亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: 100 CoolShell ch01 問(wèn)題 [打印本頁(yè)]

作者: yanjerry9133    時(shí)間: 2012-03-20 16:53
標(biāo)題: 100 CoolShell ch01 問(wèn)題
  1. #!/bin/sh
  2. # inpath - Verifies that a specified program is either valid as is,
  3. #   or that it can be found in the PATH directory list.

  4. in_path()
  5. {
  6.   # Given a command and the PATH, try to find the command. Returns
  7.   # 0 if found and executable, 1 if not. Note that this temporarily modifies
  8.   # the IFS (input field separator) but restores it upon completion.

  9.   cmd=$1        path=$2         retval=1
  10.   oldIFS=$IFS   IFS=":"

  11.   for directory in $path
  12.   do
  13.     if [ -x $directory/$cmd ] ; then
  14.       retval=0      # if we're here, we found $cmd in $directory
  15.     fi
  16.   done
  17.   IFS=$oldIFS
  18.   return $retval
  19. }

  20. checkForCmdInPath()
  21. {
  22.   var=$1

  23.   # The variable slicing notation in the following conditional
  24.   # needs some explanation: ${var#expr} returns everything after
  25.   # the match for 'expr' in the variable value (if any), and
  26.   # ${var%expr} returns everything that doesn't match (in this
  27.   # case, just the very first character. You can also do this in
  28.   # Bash with ${var:0:1}, and you could use cut too: cut -c1.

  29.   if [ "$var" != "" ] ; then
  30.     if [ "${var%${var#?}}" = "/" ] ; then
  31.       if [ ! -x $var ] ; then
  32.         return 1
  33.       fi
  34.     elif ! in_path $var $PATH ; then
  35.       return 2
  36.     fi
  37.   fi
  38. }

復(fù)制代碼
其中后那個(gè)elif ! in_path $var $PATH 看不懂啊,請(qǐng)教各位。。。
作者: Shell_HAT    時(shí)間: 2012-03-20 18:40
調(diào)用函數(shù)in_path,$var和$PATH傳到函數(shù)里面之后就是$1和$2
還有哪里不懂?




歡迎光臨 Chinaunix (http://www.72891.cn/) Powered by Discuz! X3.2