Linux Shell的類別

來源:互聯網
上載者:User
The Bourne Shell

When Unix was first born, it had a very basic shell written by Ken Thompson, one of the creators
of Unix. The Bourne shell was written by Steve Bourne in 1979 as a scriptable Unix shell. All other
shells have a prefix to qualify which shell they are — ksh, csh, zsh, and so on — but the Bourne shell
does not call itself bsh because it simply is “the shell,” so its canonical path is /bin/sh. Other shells
came along later with more features, while staying generally compatible with the Bourne shell —
some more compatible than others.
One of the most significant new concepts that the Bourne shell provided was the pipeline, the structure
that allows one process to pass its output to the input of another process. This was a dramatic
change in the capability of a shell command. Bourne also introduced variables and flow control,
turning the shell from being a very basic command interpreter into a flexible scripting language.

The KornShell

The Kornshell (ksh) was written by David Korn in 1983. It is a very popular shell for scripting as well
as interactive use, particularly on proprietary Unices. Like bash and dash, it is backward-compatible
with the Bourne shell but adds new features and syntax. Ksh introduced cursor-key navigation of the
shell history, as well as providing arrays and floating-point math. For a long time, ksh was proprietary
Unix software of AT&T, so pdksh (now mksh, http://mirbsd.de/mksh) is a Free Software equivalent
to ksh93. After ksh93 was released under IBM’s Common Public License in 2005, most GNU/
Linux distributions included ksh93 instead of pdksh or mksh, as did OpenSolaris. As a result, whenever
you find ksh on a recent system, it is likely to be the genuine ksh93 and not a clone.

The common ground between ksh and Bourne functionality was used to define the POSIX standard
for /bin/sh, so ksh is a significant shell scripting language. In traditional Unix systems, it is quite
acceptable for the root user’s shell to be set to /bin/ksh. It is the default shell on IBM’s AIX Unix.
/etc/init.d scripts will still be run under the Bourne shell, but the interactive root shell can be ksh
(often with the -o vi option to provide vi-like history recall).
Microsoft’s Services For Unix (SFU — now discontinued) provided an almost-compatible ksh shell for
the Windows environment, although it was based on mksh, which at the time was not quite compatible
with the original ksh. At http://lists.blu.org/pipermail/discuss/1998-August/002393.html,
you can read the story of how David Korn queried a Microsoft product manager about his choice of
Kornshell implementation during a presentation about SFU. Korn criticized the choice of implementation
because it was incompatible with genuine ksh, and asked whether Microsoft had considered any of
the more compatible ksh variants. Only after the poor Microsoft representative had tried to claim that
their implementation of the Kornshell was fully compatible with the Kornshell was it eventually pointed
out to him that the person asking the awkward questions about Kornshell compatibility was David
Korn himself.

The C Shell

The C shell (csh) was written in the 1970s by Bill Joy, one of the founders of Sun Microsystems and
also a very prolific BSD Unix hacker. One of the main attractions of csh was that its syntax looked
a lot more like the C language, which many systems programmers are very familiar with. It was also

a better interactive shell than the Bourne shell, providing the history command for the first time.
It also added job control and the concept of using the tilde (~) to represent the current user’s home
directory. All of these features (but not the C-style syntax) have been taken on by all of the other
shells listed here.
In 1996, Tom Christiansen wrote a widely distributed article entitled “Csh Programming
Considered Harmful” (http://www.faqs.org/faqs/unix-faq/shell/csh-whynot/), which
pointed out some of the ways in which csh syntax can be counterintuitive or limiting to the systems
programmer. The issues that Christiansen raises are particularly focused around the areas of redirection
and process control.

The Tenex C Shell

 

Tcsh is the Tenex Csh, and offers many improvements to the standard csh, while remaining totally
compatible with csh. Its improvements over csh include better history control; pushd and popd for
stacking directory positions; terminal locking; and which, where, and also read-only variables. It
also provides spelling correction; an interactive tcsh will prompt the user with suggested options if it
suspects that a typing error has been made.
In addition to automatic completion of commands and filenames, tcsh also adds automatic completion
of variable names. It can be configured to do this in either case-sensitive or case-insensitive mode.

The Z Shell

 

The Z shell (zsh) was written by Paul Falstad in 1990. It was intended to be a ksh-like shell but also
included some csh-like features because csh was a very popular interactive shell in the 1970s and
1980s. It is particularly good as an interactive shell. It does not claim full POSIX or Bourne compatibility,
which allows it greater flexibility to add new features, although it does aim to be ksh compatible.
It can change its behavior with the emulate command, or if called as /bin/sh or /bin/ksh, to
act more like those shells.
Zsh is a lot like bash for interactive use, with similar, although in some ways more featureful, history
recall and command completion. The compctl command can be used to customize just how the
completion works. Globbing syntax is slightly different from ksh and Bourne shell, and arrays are
indexed from 1, not 0.

The Bourne Again Shell

 

Bash is the standard interactive shell on most GNU/Linux and Mac OSX systems, and is becoming
popular with traditional Unix users, too. It is also the default shell for the Cygwin environment,
which provides GNU tools under Microsoft Windows. It is compatible with the Bourne shell, but
adds a number of extra features, most of which are covered in this book. The name of the bash shell
(the “Bourne Again shell”) is a play on the name of the author of the Bourne shell.

Bash was initially written by Brian Fox in 1988 for the Free Software Foundation (FSF) and is currently
maintained by Chet Ramey. It takes some ideas from various shells including csh and ksh.
Most noticeably, bash uses [[ … ]], $( … ), and (( … )) syntaxes from ksh.
Bash, if called as sh, acts more like the Bourne shell in the confi guration fi les it reads. This is documented
in more detail later in this chapter.

the deBian alMQuiSt Shell

 

Dash started life in 1989 as the Almquist Shell (ash), written by Kenneth Almquist. It was ported for
the Debian project in 1999 by Herbert Xu as the Debian Almquist Shell (dash). Like bash, it aims for
POSIX compliance, but unlike bash, it tries nothing more; it aims only to be a POSIX-compliant shell.
This makes it smaller, lighter, and faster than bash. It therefore replaces bash as the default /bin/sh in
many GNU/Linux distributions, which generally retain bash for interactive use, using dash for system
scripts, particularly startup scripts.
The longstanding availability of bash as /bin/sh on GNU/Linux caused some problems when
migrating to dash, as a lot of system scripts called /bin/sh as their interpreter but expected
to be able to use features of bash. The site https://bugs.launchpad.net/ubuntu/+source/
dash/+bug/61463 provides a list of many of the problems experienced when Ubuntu 6.10 moved
from bash to dash as the default /bin/sh in 2006.

 

Shell Scripting Expert RECIP ES for Linux, Bash, and More

Seve Parker ISBN: 978-0-470-02448-5

Linux Shell Scrpting with Bash

Linux Shell Scripting Cookbook 4397758.8717885311

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.