Differences between csh, tcsh, bash, sh, and other shell

Source: Internet
Author: User
Tags builtin character classes
There are some differences between csh, tcsh, bash, sh, and other shell, such as csh, tcsh, bash, and sh.
Section C: Differences from other Unix shellsC: Differences with other UNIX shells scripts C1) How does bash differ from sh, the Bourne shell? C1) bash, sh, and Bourne shell differences This is a non-comprehensive list of features that differentiate bashfrom the SVR4.2 shell. the bash manual page explains these morecompletely. in this case, a list of the differences between bash and SVR4.2 shell features is incomplete. The bash manual explains Things bash has that sh does not: bash-specific features: long invocation options long option call [+-] O invocation option-l invocation option '! 'Reserved word to invert pipeline return value! The exclamation point reserved word reversed the value returned by the pipeline 'time' reserved word to time pipelines and shell builtins time reserved word test pipeline or built-in command time consumption the 'function' reserved word the 'select' compound command and reserved word select compound command and reserved word arithmetic for command: for (expr1; expr2; expr3); do list; done arithmetic command: for (expr1; expr2; expr3); do list; done new $ '... and $ "... "quoting New reference method $ '... '$ "... "the $ (...) form of command substitution $ (...) command substitution usage the $ (
 
  
, & >,>|,<<,[ N] <& word-, [n]> & word-redirect rule: <>,>,>, >|, <, [n] <& word -, [n]> & word-prompt string special char translation and variable expansion prompt conversion and variable expansion of special character strings auto-export of variables in initial environment automatically inherits the initialized environment variable command search the finds functions before builtins command search function is limited to the built-in command bash return builtin will exit a file sourced '. 'bash returns the built-in command to exit one. file source builtins: cd-/-L/-P, exec-l/-c/-a, ech O-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 writes interactive scripts, and environment variables are non-interactive. Bash restricted shell mode is more extensive bash wider restricted mode bash allows functions and variables with the same name allows function name variables to be the same as brace expansion brackets extended tilde expansion ~ Wave number extension arithmetic expansion with $ ((...)) and 'let' builtin arithmetic extension: $ ((...)) and let command '... 'Extended conditional command '... 'command extension process substitution process replace aliases and alias/unalias builtins alias built-in command local variables in functions and 'local' builtin function local variable readline and command-line editing with programmable completion read command history and history/fc builtins can be programmed to view the historical command csh-like history expa. Nsion other new bash builtins: bind, command, compgen, complete, builtin, declare/typeset, dirs, enable, fc, help, history, logout, popd, pushd, disown, shopt, A bunch of new bash built-in commands on printf. Exported functions filename generation when using output redirection (command> *) generate POSIX.2-style globbing character classes POSIX.2-style globbing character classes POSIX.2-style globbing collating symbols POSIX.2 style wildcard class, equivalence class, wildcard number egrep-like extended pattern matching operators case-insensitive pattern matching and globbing case-insensitive pattern matching and wildcard variable assignments preceding commands affect Only that command, the command before even for builtins and functions variable value assignment only affects that command, including built-in commands and 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 debugging support, including caller built-in commands and the new variable RETURN trap Things sh has that bash does not: below are some of sh but some of bash's uses variable SHACCT to do shell accounting should des 'stop' bu Iltin (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: different execution conditions: 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 signa L 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 fa The lower part of ils is the same as that above... For more information, see. 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, delimiter, FIGNORE, delimiter, HOSTFILE, DIRSTACK, PIPESTATUS, HOSTNAME, OPTERR, SHE Lopts, 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 neural-style globbing character classes POSIX.2-style globbing classification classes POSIX.2-style globbing collating processing egrep-like extended pattern matching operators case-regular 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 t Imeout 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 expan Sion 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. ma Tch, 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 100' + = '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' funings 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 '! 'Reserved word loadable builtins -- but ksh uses 'builtin 'while bash uses 'enable' command', 'builtin ', 'disawn' builtins new $ '... and $ "... "quoting FIGNORE (but bash uses GLOBIGNORE), HISTCMD set-o using Y/-C changes to kill builtin read-A (bash uses read-) read-t/-d trap-p exec-c/-'. 'restores the positional parameters when it completes POSIX.2 'test' umask-S unalias-a command and arithmetic substitution completed MED on PS1, PS4, and ENV command name completion ENV processed only for interactive shells set-o pipefail
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.