Chinaunix

标题: 请教一个脚本 [打印本页]

作者: catabcxyz    时间: 2008-01-21 22:03
标题: 请教一个脚本
run_rc_script()
{
        _file=$1
        _arg=$2
        if [ -z "$_file" -o -z "$_arg" ]; then
                err 3 'USAGE: run_rc_script file arg'
        fi

        unset        name command command_args command_interpreter \
                extra_commands pidfile procname \
                rcvar required_dirs required_files required_vars
        eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd

        case "$_file" in
        *.sh)                                # run in current shell
                set $_arg ; . $_file
                ;;
        *[~#]|*.OLD|*.orig|*,v)                # scratch file; skip
                warn "Ignoring scratch file $_file"
                ;;
        *)                                # run in subshell
                if [ -x $_file ]; then
                        if [ -n "$rc_fast_and_loose" ]; then
                                set $_arg ; . $_file
                        else
                                ( trap "echo Script $_file interrupted; kill -QUIT $$" 3
                                  trap "echo Script $_file interrupted; exit 1" 2
                                  set $_arg ; . $_file )
                        fi
                fi
                ;;
        esac
}
请问其中case "$_file" in 的各分支*.sh)   *[~#]|*.OLD|*.orig|*,v)   *) 表示什么含义, _file代表一个文件名
作者: 寂寞烈火    时间: 2008-01-21 22:16
man bash
word in [ [(] pattern [ | pattern ] ... ) list ;; ] ... esac
              A case command first expands word, and tries to match it against
              each pattern in turn, using the same matching rules as for path-
              name expansion (see Pathname Expansion below).  When a match  is
              found,  the  corresponding  list  is  executed.  After the first
              match, no subsequent matches are attempted.  The exit status  is
              zero if no pattern matches.  Otherwise, it is the exit status of
              the last command executed in list.





欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2