当前位置:  操作系统/服务器>linux

csh,tcsh,bash,sh等shell的区别

    来源: 互联网  发布时间:2014-10-16

    本文导语:  出自bash的faq,仔细看看。顺便翻译学习一下。 代码如下:Section C: Differences from other Unix shellsC:跟其他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 tha...

出自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 $(|, 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),

    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。




特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

©2012-2021,,E-mail:www_#163.com(请将#改为@)

浙ICP备11055608号-3