预计阅读本页时间:-
The Bourne Shell
bash is almost completely backward-compatible with the Bourne shell. The only significant feature of the latter that bash doesn't support is ^ (caret) as a synonym for the pipe (|) character. This is an archaic feature that the Bourne shell includes for its own backward compatibility with earlier shells. No modern UNIX version has any shell code that uses ^ as a pipe.
To describe the differences between the Bourne shell and bash, we'll go through each chapter of this book and enumerate the features discussed in the chapter that the Bourne shell does not support. Although some versions of the Bourne shell exist that include a few bash features,[1] we refer to the standard Bourne shell that has been around for many years.
广告:个人专属 VPN,独立 IP,无限流量,多机房切换,还可以屏蔽广告和恶意软件,每月最低仅 5 美元
The cd - form of the cd command; tilde (~) expansion; the jobs command; the help built-in.
All. (That is, the Bourne shell doesn't support any of the readline, history, and editing features discussed in this chapter.)
Aliases; prompt string customization; set options. The Bourne shell supports only the following: -e, -k, -n, -t, -u, -v, -x, and -. It doesn't support option names (-o). The shopt built-in. Environment files aren't supported. The following built-in variables aren't supported:
All variables beginning with BASH_
All variables beginning with COMP
CDPATH
DIRSTACK
FCEDIT
FUNCNAME
GROUPS
HISTCMD
HISTCONTROL
HISTFILE
HISTIGNORE
HISTSIZE
HISTFILESIZE
HOSTFILE
HOSTNAME
HOSTTYPE
IGNOREEOF
INPUTRC
LANG
LC_ALL
LC_COLLATE
LC_MESSAGES
LINENO
MACHTYPE
MAILCHECK
OLDPWD
OPTARG
OPTERR
OPTIND
OSTYPE
PIPESTATUS
PS3
PS4
POSIXLY_CORRECT
PROMPT_COMMAND
PWD
RANDOM
REPLY
SECONDS
SHELLOPTS
SHLVL
TIMEFORMAT
TMOUT
auto_resume
histchars
Functions; the type command; the local command; the ${#parameter} operator; pattern-matching variable operators (%, %%, #, ##). Extended pattern matching. Command-substitution syntax is different: use the older ` command ` instead of $( command). The built-in pushd and popd commands.
The ! keyword; the select construct isn't supported. The Bourne shell return doesn't exit a script when it is sourced with . (dot).
Use the external command getopt instead of getopts, but note that it doesn't really do the same thing. Integer arithmetic isn't supported: use the external command expr instead of the $(( arithmetic-exp )) syntax. The arithmetic conditional (( arithmetic-exp )) isn't supported; use the old condition test syntax and the relational operators -lt, -eq, etc. Array variables are not supported. declare and let aren't supported.
The command, builtin, and enable built-ins. The -e and -E options to echo are not supported. The I/O redirectors >| and <> are not supported. None of the options to read is supported. printf is usually available as an external command.
Job control—specifically, the jobs, fg, and bg commands. Job number notation with %, i.e., the kill and wait commands only accept process IDs. The - option to trap (reset trap to the default for that signal). trap only accepts signal numbers, not logical names. The disown built-in.
The DEBUG, ERR, and RETURN fake signals are not supported. The EXIT fake signal is supported as signal 0.
The ulimit command and privileged mode aren't supported. The -S option to umask is not supported. The Bourne shell's restrictive counterpart, rsh, only inhibits assignment to PATH.
[1] For example, the Bourne shell distributed with System V supports functions and a few other shell features common to bash and the Korn shell.