A shell is an interface that enables users to
interact with the operating system. A shell isn’t considered an
application because of its inescapable nature, but it’s the same as any
other process running on a system. The difference between a shell and an
application is that a shell’s purpose is to enable users to run other
applications. In some operating systems (such as UNIX, Linux, and VMS),
the shell is a command-line interface (CLI); in other operating systems
(such as Windows and Mac OS X), the shell is a graphical user interface
(GUI).
Both CLI and GUI shells have
benefits and drawbacks. For example, most CLI shells allow powerful
command chaining (using commands that feed their output into other
commands for further processing; this is commonly referred to as the
pipeline). GUI shells, however, require commands to be completely
self-contained. Furthermore, most GUI shells are easy to navigate,
whereas CLI shells require a preexisting knowledge of the system to
avoid attempting several commands to discern the location and direction
to head in when completing an automation task. Therefore, choosing which
shell to use depends on your comfort level and what’s best suited to
perform the task at hand.
Note
Even though GUI shells
exist, the term “shell” is used almost exclusively to describe a
command-line environment, not a task that is performed with a GUI
application, such as Windows Explorer. Likewise, shell scripting refers
to collecting commands normally entered on the command line or into an
executable file.
A Short History of Shells
The first shell in wide use
was the Bourne shell, the standard user interface for the UNIX operating
system; UNIX systems still require it for booting. This robust shell
provided pipelines and conditional and recursive command execution. It
was developed by C programmers for C programmers.
Oddly, however, despite being
written by and for C programmers, the Bourne shell didn’t have a C-like
coding style. This lack of similarity to the C language drove the
invention of the C shell, which introduced more C-like programming
structures. While the C shell inventors were building a better
mousetrap, they decided to add command-line editing and command aliasing
(defining command shortcuts), which eased the bane of every UNIX user’s
existence: typing. The less a UNIX user has to type to get results, the
better.
Although most UNIX users
liked the C shell, learning a completely new shell was a challenge for
some. So, the Korn shell was invented, which added a number of the C
shell features to the Bourne shell. Because the Korn shell is a
commercially licensed product, the open source software movement needed a
shell for Linux and FreeBSD. The collaborative result was the Bourne
Again shell, or Bash, invented by the Free Software Foundation.
Throughout
the evolution of UNIX and the birth of Linux and FreeBSD, other
operating systems were introduced along with their own shells. Digital
Equipment Corporation (DEC) introduced Virtual Memory System (VMS) to
compete with UNIX on its VAX systems. VMS had a shell called Digital
Command Language (DCL) with a verbose syntax, unlike that of its UNIX
counterparts. Also, unlike its UNIX counterparts, it wasn’t case
sensitive, nor did it provide pipelines.
Somewhere along the way, the PC
was born. IBM took the PC to the business market, and Apple rebranded
roughly the same hardware technology and focused on consumers. Microsoft
made DOS run on the IBM PC, acting as both kernel and shell and
including some features of other shells. (The pipeline syntax was
inspired by UNIX shells.)
Following DOS was Windows,
which went from application to operating system quickly. Windows
introduced a GUI shell, which has become the basis for Microsoft shells
ever since. Unfortunately, GUI shells are notoriously difficult to
script, so Windows provided a DOSShell-like environment. It was improved
with a new executable, cmd.exe instead of command.com, and a more
robust set of command-line editing features. Regrettably, this change
also meant that shell scripts in Windows had to be written in the
DOSShell syntax for collecting and executing command groupings.
Over time,
Microsoft realized its folly and decided systems administrators should
have better ways to manage Windows systems. Windows Script Host (WSH)
was introduced in Windows 98, providing a native scripting solution with
access to the underpinnings of Windows. It was a library that allowed
scripting languages to use Windows in a powerful and efficient manner.
WSH is not its own language, however, so a WSH-compliant scripting
language was required to take advantage of it, such as JScript,
VBScript, Perl, Python, Kixstart, or Object REXX. Some of these
languages are quite powerful in performing complex processing, so WSH
seemed like a blessing to Windows systems administrators.
However, the rejoicing
was short-lived because there was no guarantee that the WSH-compliant
scripting language you chose would be readily available or a viable
option for everyone. The lack of a standard language and environment for
writing scripts made it difficult for users and administrators to
incorporate automation by using WSH. The only way to be sure the
scripting language or WSH version would be compatible on the system
being managed was to use a native scripting language, which meant using
DOSShell and enduring the problems that accompanied it. In addition, WSH
opened a large attack vector for malicious code to run on Windows
systems. This vulnerability gave rise to a stream of viruses, worms, and
other malicious programs that have wreaked havoc on computer systems,
thanks to WSH’s focus on automation without user intervention.
The end result was that
systems administrators viewed WSH as both a blessing and a curse.
Although WSH presented a good object model and access to a number of
automation interfaces, it wasn’t a shell. It required using Wscript.exe
and Cscript.exe, scripts had to be written in a compatible scripting
language, and its attack vulnerabilities posed a security challenge.
Clearly, a different approach was needed for systems management; over
time, Microsoft reached the same conclusion.