亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 開發 > Linux Shell > 正文

csh,tcsh,bash,sh等shell的區別

2020-07-27 19:19:16
字體:
來源:轉載
供稿:網友

出自bash的faq,仔細看看。順便翻譯學習一下。

復制代碼 代碼如下:

Section C: Differences from other Unix shells
C:跟其他UNIX shells腳本的區別
C1) How does bash differ from sh, the Bourne shell?
C1) bash和 sh、Bourne shell的區別
This is a non-comprehensive list of features that differentiate bash
from the SVR4.2 shell.  The bash manual page explains these more
completely.
這時一個不全面的bash和SVR4.2 shell特性區別的列表,bash手冊解釋的更詳細
Things bash has that sh does not:
bash特有的功能:
        long invocation options
        長選項的調用
        [+-]O invocation option
        -l invocation option
        `!' reserved word to invert pipeline return value
         !嘆號保留字對管道返回的值取反
        `time' reserved word to time pipelines and shell builtins
         time保留字測試管道或內建命令耗時情況
        the `function' reserved word
        the `select' compound command and reserved word
        select復合命令和保留字
        arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done
        算術命令:for ((expr1 ; expr2; expr3 )); do list; done
        new $'...' and $"..." quoting
        新的引用方法$'...'  $"..."
        the $(...) form of command substitution
        $(...) 命令替代用法
        the $(<filename) form of command substitution, equivalent to
                $(cat filename)
        $(<filename)形式的命令的替換,相當于$(cat filename)
        the ${#param} parameter value length operator
        ${#param} 測試參數param的值的長度
        the ${!param} indirect parameter expansion operator
        ${!param} 間接參數擴展操作
        the ${!param*} prefix expansion operator
        ${!param*} 前綴擴展操作
        the ${param:offset[]} parameter substring operator
       ${param:ffset[]}參數通過偏移量截取子串操作
        the ${param/pat[/string]} parameter pattern substitution operator
        ${param/pat[/string]} 參數模式替換的操作
        expansions to perform substring removal (${p%[%]w}, ${p#[#]w})
         擴展子串刪除命令:(${p%[%]w}, ${p#[#]w})
        expansion of positional parameters beyond $9 with ${num}
        擴展了為止參數超過9的限制
        variables: BASH, BASH_VERSION, BASH_VERSINFO, UID, EUID, REPLY,
                   TIMEFORMAT, PPID, PWD, OLDPWD, SHLVL, RANDOM, SECONDS,
                   LINENO, HISTCMD, HOSTTYPE, OSTYPE, MACHTYPE, HOSTNAME,
                   ENV, PS3, PS4, DIRSTACK, PIPESTATUS, HISTSIZE, HISTFILE,
                   HISTFILESIZE, HISTCONTROL, HISTIGNORE, GLOBIGNORE, GROUPS,
                   PROMPT_COMMAND, FCEDIT, FIGNORE, IGNOREEOF, INPUTRC,
                   SHELLOPTS, OPTERR, HOSTFILE, TMOUT, FUNCNAME, histchars,
                   auto_resume
        上邊一堆的環境變量
        DEBUG trap
        ERR trap
        調試和錯誤陷阱
        variable arrays with new compound assignment syntax
         數組和復合賦值運算符的語法規則
        redirections: <>, &>, >|, <<<, [n]<&word-, [n]>&word-
         重定向規則: <>, &>, >|, <<<, [n]<&word-, [n]>&word-
        prompt string special char translation and variable expansion
        提示字符串特殊字符的轉化和變量展開
        auto-export of variables in initial environment
        自動繼承初始化的環境變量
        command search finds functions before builtins
        命令搜查函數限于內建命令
        bash return builtin will exit a file sourced with `.'
        bash返回內建命令 將退出一個.文件源
        builtins: cd -/-L/-P, exec -l/-c/-a, echo -e/-E, hash -d/-l/-p/-t.
                  export -n/-f/-p/name=value, pwd -L/-P,
                  read -e/-p/-a/-t/-n/-d/-s/-u,
                  readonly -a/-f/name=value, trap -l, set +o,
                  set -b/-m/-o option/-h/-p/-B/-C/-H/-P,
                  unset -f/-v, ulimit -m/-p/-u,
                  type -a/-p/-t/-f/-P, suspend -f, kill -n,
                  test -o optname/s1 == s2/s1 < s2/s1 > s2/-nt/-ot/-ef/-O/-G/-S
        上邊一堆內建命令
        bash reads ~/.bashrc for interactive shells, $ENV for non-interactive
        bash reads這樣寫交互腳本,環境變量非交互的。
        bash restricted shell mode is more extensive
        bash更廣泛的受限模式
        bash allows functions and variables with the same name
        允許函數名變量名一樣
        brace expansion
        括號擴展
        tilde expansion
        ~波浪號擴展
        arithmetic expansion with $((...)) and `let' builtin
        算術擴展:$((...)) 和let命令
        the `...' extended conditional command
        `...` 命令擴展
        process substitution
        進程替換
        aliases and alias/unalias builtins
        別名的內建命令
        local variables in functions and `local' builtin
        函數內本地變量
        readline and command-line editing with programmable completion
        讀取行和命令行可以編程完成
        command history and history/fc builtins
         查看歷史命令
        csh-like history expansion
        other new bash builtins: bind, command, compgen, complete, builtin,
                                 declare/typeset, dirs, enable, fc, help,
                                 history, logout, popd, pushd, disown, shopt,
                                 printf
         上邊一堆新的bash內建命令。
        exported functions
        filename generation when using output redirection (command >a*)
        重定向輸出文件名的生成
        POSIX.2-style globbing character classes
        POSIX.2-style globbing equivalence classes
        POSIX.2-style globbing collating symbols
        POSIX.2風格的通配符類、等價類、通配符號
        egrep-like extended pattern matching operators
        case-insensitive pattern matching and globbing
        不區分大小寫的模式匹配和通配符
        variable assignments preceding commands affect only that command,
                even for builtins and functions
        變量賦值前的命令只影響那個命令,包括內建命令和函數
        posix mode
        redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr,
                /dev/tcp/host/port, /dev/udp/host/port
        debugger support, including `caller' builtin and new variables
        調試支持,包括caller內建命令和新變量
        RETURN trap

 
Things sh has that bash does not:
下邊是sh有但是bash木有的
        uses variable SHACCT to do shell accounting
        includes `stop' builtin (bash can use alias stop='kill -s STOP')
        `newgrp' builtin
        turns on job control if called as `jsh'
        $TIMEOUT (like bash $TMOUT)
        `^' is a synonym for `|'
        new SVR4.2 sh builtins: mldmode, priv

Implementation differences:
執行情況的不同:
        redirection to/from compound commands causes sh to create a subshell
        bash does not allow unbalanced quotes; sh silently inserts them at EOF
        bash does not mess with signal 11
        sh sets (euid, egid) to (uid, gid) if -p not supplied and uid < 100
        bash splits only the results of expansions on IFS, using POSIX.2
                field splitting rules; sh splits all words on IFS
        sh does not allow MAILCHECK to be unset (?)
        sh does not allow traps on SIGALRM or SIGCHLD
        bash allows multiple option arguments when invoked (e.g. -x -v);
                sh allows only a single option argument (`sh -x -v' attempts
                to open a file named `-v', and, on SunOS 4.1.4, dumps core.
                On Solaris 2.4 and earlier versions, sh goes into an infinite
                loop.)
        sh exits a script if any builtin fails; bash exits only if one of
                the POSIX.2 `special' builtins fails

下邊都和上邊比較雷同了。。。大致瀏覽吧。
C2) How does bash differ from the Korn shell, version ksh88?

Things bash has or uses that ksh88 does not:
        long invocation options
        [-+]O invocation option
        -l invocation option
        `!' reserved word
        arithmetic for command: for ((expr1 ; expr2; expr3 )); do list; done
        arithmetic in largest machine-supported size (intmax_t)
        posix mode and posix conformance
        command hashing
        tilde expansion for assignment statements that look like $PATH
        process substitution with named pipes if /dev/fd is not available
        the ${!param} indirect parameter expansion operator
        the ${!param*} prefix expansion operator
        the ${param:offset[]} parameter substring operator
        the ${param/pat[/string]} parameter pattern substitution operator
        variables: BASH, BASH_VERSION, BASH_VERSINFO, UID, EUID, SHLVL,
                   TIMEFORMAT, HISTCMD, HOSTTYPE, OSTYPE, MACHTYPE,
                   HISTFILESIZE, HISTIGNORE, HISTCONTROL, PROMPT_COMMAND,
                   IGNOREEOF, FIGNORE, INPUTRC, HOSTFILE, DIRSTACK,
                   PIPESTATUS, HOSTNAME, OPTERR, SHELLOPTS, GLOBIGNORE,
                   GROUPS, FUNCNAME, histchars, auto_resume
        prompt expansion with backslash escapes and command substitution
        redirection: &> (stdout and stderr), <<<, [n]<&word-, [n]>&word-
        more extensive and extensible editing and programmable completion
        builtins: bind, builtin, command, declare, dirs, echo -e/-E, enable,
                  exec -l/-c/-a, fc -s, export -n/-f/-p, hash, help, history,
                  jobs -x/-r/-s, kill -s/-n/-l, local, logout, popd, pushd,
                  read -e/-p/-a/-t/-n/-d/-s, readonly -a/-n/-f/-p,
                  set -o braceexpand/-o histexpand/-o interactive-comments/
                  -o notify/-o physical/-o posix/-o hashall/-o onecmd/
                  -h/-B/-C/-b/-H/-P, set +o, suspend, trap -l, type,
                  typeset -a/-F/-p, ulimit -u, umask -S, alias -p, shopt,
                  disown, printf, complete, compgen
        `!' csh-style history expansion
        POSIX.2-style globbing character classes
        POSIX.2-style globbing equivalence classes
        POSIX.2-style globbing collating symbols
        egrep-like extended pattern matching operators
        case-insensitive pattern matching and globbing
        `**' arithmetic operator to do exponentiation
        redirection to /dev/fd/N, /dev/stdin, /dev/stdout, /dev/stderr
        arrays of unlimited size
        TMOUT is default timeout for `read' and `select'
        debugger support, including the `caller' builtin
        RETURN trap
        Timestamps in history entries
        {x..y} brace expansion

Things ksh88 has or uses that bash does not:
        tracked aliases (alias -t)
        variables: ERRNO, FPATH, EDITOR, VISUAL
        co-processes (|&, >&p, <&p)
        weirdly-scoped functions
        typeset +f to list all function names without definitions
        text of command history kept in a file, not memory
        builtins: alias -x, cd old new, newgrp, print,
                  read -p/-s/var?prompt, set -A/-o gmacs/
                  -o bgnice/-o markdirs/-o trackall/-o viraw/-s,
                  typeset -H/-L/-R/-Z/-A/-ft/-fu/-fx/-l/-u/-t, whence
        using environment to pass attributes of exported variables
        arithmetic evaluation done on arguments to some builtins
        reads .profile from $PWD when invoked as login shell

Implementation differences:
        ksh runs last command of a pipeline in parent shell context
        bash has brace expansion by default (ksh88 compile-time option)
        bash has fixed startup file for all interactive shells; ksh reads $ENV
        bash has exported functions
        bash command search finds functions before builtins
        bash waits for all commands in pipeline to exit before returning status
        emacs-mode editing has some slightly different key bindings

 
C3) Which new features in ksh-93 are not in bash, and which are?

New things in ksh-93 not in bash-3.0:
        associative arrays
        floating point arithmetic and variables
        math library functions
        ${!name[sub]} name of subscript for associative array
        `.' is allowed in variable names to create a hierarchical namespace
        more extensive compound assignment syntax
        discipline functions
        `sleep' and `getconf' builtins (bash has loadable versions)
        typeset -n and `nameref' variables
        KEYBD trap
        variables: .sh.edchar, .sh.edmode, .sh.edcol, .sh.edtext, .sh.version,
                   .sh.name, .sh.subscript, .sh.value, .sh.match, HISTEDIT
        backreferences in pattern matching (/N)
        `&' operator in pattern lists for matching
        print -f (bash uses printf)
        `fc' has been renamed to `hist'
        `.' can execute shell functions
        exit statuses between 0 and 255
        `+=' variable assignment operator
        FPATH and PATH mixing
        getopts -a
        -I invocation option
        printf %H, %P, %T, %Z modifiers, output base for %d
        lexical scoping for local variables in `ksh' functions
        no scoping for local variables in `POSIX' functions

New things in ksh-93 present in bash-3.0:
        [n]<&word- and [n]>&word- redirections (combination dup and close)
        for (( expr1; expr2; expr3 )) ; do list; done - arithmetic for command
        ?:, ++, --, `expr1 , expr2' arithmetic operators
        expansions: ${!param}, ${param:offset[]}, ${param/pat[/str]},
                    ${!param*}
        compound array assignment
        the `!' reserved word
        loadable builtins -- but ksh uses `builtin' while bash uses `enable'
        `command', `builtin', `disown' builtins
        new $'...' and $"..." quoting
        FIGNORE (but bash uses GLOBIGNORE), HISTCMD
        set -o notify/-C
        changes to kill builtin
        read -A (bash uses read -a)
        read -t/-d
        trap -p
        exec -c/-a
        `.' restores the positional parameters when it completes
        POSIX.2 `test'
        umask -S
        unalias -a
        command and arithmetic substitution performed on PS1, PS4, and ENV
        command name completion
        ENV processed only for interactive shells
        set -o pipefail

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
在线色欧美三级视频| 亚洲日韩第一页| 91精品视频大全| 国产在线999| 欧美黑人狂野猛交老妇| 另类天堂视频在线观看| 热门国产精品亚洲第一区在线| 欧美在线一级视频| 不用播放器成人网| 欧美精品aaa| 久久久国产一区| 欧美激情a在线| 懂色av一区二区三区| xxx一区二区| 97**国产露脸精品国产| 精品久久久一区| 久久成人av网站| 日韩av有码在线| 久久精品视频导航| 国产女同一区二区| 91在线视频一区| 国产精品成人在线| 亚洲国产欧美一区| 成人黄色片网站| 在线观看不卡av| 久久久噜噜噜久久中文字免| 国产精品久久久久av免费| 国产精品自产拍在线观看中文| 国产亚洲精品久久久久久牛牛| 亚洲美女在线观看| 亚洲毛茸茸少妇高潮呻吟| 欧美成人久久久| 91国内免费在线视频| 日韩小视频在线| 91久久精品久久国产性色也91| 国产精品福利观看| 久久久国产精品x99av| 亚洲精品久久久久中文字幕欢迎你| 精品人伦一区二区三区蜜桃网站| 狠狠久久五月精品中文字幕| 欧美国产高跟鞋裸体秀xxxhd| 国产精品女人久久久久久| 日韩国产在线看| 91av在线国产| 欧美二区在线播放| 亚洲黄色www网站| 精品国产一区av| 亚洲国产成人精品电影| 日韩免费av片在线观看| 国产精品精品一区二区三区午夜版| 久久亚洲国产成人| 亚洲精品久久久久中文字幕二区| 国产亚洲精品久久久| 亚洲天堂av在线播放| 影音先锋日韩有码| 亚洲精品美女网站| 精品一区电影国产| 日韩在线观看免费全| 91亚洲va在线va天堂va国| 国产精品三级在线| 国产精品精品一区二区三区午夜版| 国产精品美女视频网站| 久久影视电视剧凤归四时歌| 456国产精品| 国产精品视频男人的天堂| 日韩成人xxxx| 久久久久在线观看| 国产精品入口免费视频一| 国产精品久久9| 日韩av在线一区二区| 日韩欧美国产高清91| 精品国产一区久久久| 国产精品丝袜一区二区三区| 欧美日韩国产va另类| 日韩美女激情视频| 国产精品pans私拍| 国内精品一区二区三区| 成人在线小视频| 日韩精品亚洲元码| 国产精品av网站| 国产精品视频男人的天堂| 亚洲精品久久在线| 秋霞av国产精品一区| 欧美中文字幕视频| 亚洲一区二区三区乱码aⅴ蜜桃女| 国产第一区电影| 69久久夜色精品国产69乱青草| 中文字幕九色91在线| 欧美老妇交乱视频| 精品亚洲一区二区三区在线播放| 久久久精品影院| 日韩精品免费综合视频在线播放| 欧美性开放视频| 国产丝袜一区二区三区| 久久久精品久久久久| 国产成人一区二| 91成人在线观看国产| 日韩av不卡电影| 欧美日韩在线观看视频小说| 国产精品成人品| 超碰精品一区二区三区乱码| 亚洲国产天堂久久综合网| 欧美亚洲国产视频小说| 亚洲精品98久久久久久中文字幕| 国产精品亚洲综合天堂夜夜| 国产精品狼人色视频一区| 亚洲石原莉奈一区二区在线观看| 国产精品xxx视频| 久久成人人人人精品欧| 国产va免费精品高清在线观看| 亚洲国产成人精品女人久久久| 欧美一区二区三区图| 欧美二区在线播放| 亚洲va久久久噜噜噜| 欧美日韩视频免费播放| 久久精品国产成人精品| 欧美极品少妇与黑人| 国产在线播放91| 国产精品麻豆va在线播放| 国产精品流白浆视频| 亚洲精品欧美日韩| 久久精品精品电影网| 日韩美女视频在线观看| 国产精品久久久久久久久久新婚| 97国产精品视频人人做人人爱| 国产精品久久久久免费a∨大胸| 欧美亚洲国产日本| 亚洲国内高清视频| 久久久久久久久中文字幕| 91中文字幕在线观看| 久久久亚洲欧洲日产国码aⅴ| 国自产精品手机在线观看视频| 国产精品偷伦一区二区| 黑人巨大精品欧美一区二区一视频| 亚洲精品乱码久久久久久按摩观| 久久免费视频网站| 亚洲天堂网在线观看| 色综合久综合久久综合久鬼88| 国产在线98福利播放视频| 亚洲综合精品伊人久久| www.日韩免费| 久久久久亚洲精品成人网小说| 久久国产视频网站| 亚洲丝袜在线视频| 亚洲精品自拍偷拍| 国产69精品久久久久9999| 91青草视频久久| 欧美亚洲成人网| 亚洲人成在线观看网站高清| 18性欧美xxxⅹ性满足| 国产视频综合在线| 国产精品成人在线| 不卡中文字幕av| 国产成人亚洲综合91精品| 国产精品夜间视频香蕉| 91爱爱小视频k| 国内精品在线一区| 成人午夜两性视频| 在线观看欧美www| 91精品久久久久久久久| 精品国产福利视频| 久久精品美女视频网站| 国产精品一区二区三区免费视频| 91精品91久久久久久|