tutes-dump/site-tutorials/shells.html

218 lines
5.8 KiB
HTML
Raw Normal View History

2020-07-11 06:11:19 -04:00
<html>
<head>
<title>Ultimate Differences Amongst UNIX&reg; Shells</title>
</head>
<body>
<h1>Ultimate Differences Amongst UNIX&reg; Shells</h1>
<p>
This tutorial is a work in progress (WIP).
</p>
<h2>Contents</h2>
<ul>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#ThompsonShell">Thompson Shell</a></li>
<li><a href="#BourneShell">Bourne Shell</a></li>
<li><a href="#CShell">C Shell</a></li>
<li><a href="#OtherShells">Other Shells</a></li>
<li><a href="#Conclusion">Conclusion</a></li>
</ul>
<h2><a id="Introduction" name="Introduction">Introduction</a></h2>
<p>
The UNIX shells described in this tutorial include:
osh (a port of the Thompson shell),
sh (and sh-like shells),
csh (and csh-like shells),
and others.
</p>
<p>
What are the critical differences and/or similarities among
the various UNIX shells?
The differences are generally command-line syntax issues.
</p>
<p>
In the following sections, each example command line is noted by "Ecl [123]:".
You can get an idea of how the shells differ by comparing the "Ecl [123]:"
from each section against its corresponding "Ecl [123]:" in the other sections.
</p>
<p>
The similarities among the UNIX shells described in this tutorial
are more important than the differences.
This is because when you learn how to use one shell,
you in effect also learn how to use the others.
In essence,
each of the shells plays the same role from
the user's perspective.
That role is to act as an interface to the functionality
which is available in the UNIX operating system.
</p>
<h2><a id="ThompsonShell" name="ThompsonShell">Thompson Shell</a></h2>
<p>
In UNIX history,
the Thompson shell preceded both the Bourne shell and the C shell,
and its command language is a subset of both of these shells.
Control flow in the Thompson shell is implemented via
<a href="http://v6shell.org/man/if.1.html">if</a>(1)
and
<a href="http://v6shell.org/man/goto.1.html">goto</a>(1),
which are external shell utilities.
However, flow control in the Bourne and C shells is built into each shell.
</p>
<p>
An enhanced port of the Thompson shell is available on SDF
as <code>`/usr/pkg/bin/osh'</code>.
You can read its manual by doing a <code>`man osh'</code>
at the command prompt.
You can also read its manual
<a href="http://v6shell.org/man/osh.1.html">online</a>
if you prefer to do so.
</p>
<pre><font face="monospace">
Ecl 1:
% setenv PATH /usr/pkg/bin:/usr/bin:/bin ; printenv PATH
/usr/pkg/bin:/usr/bin:/bin
Ecl 2:
% which osh if goto ^ ( tr '\n' ' ' ; echo ) ^ sed 's/.*/ls -l &amp;/' ^ osh
-r-xr-xr-x 1 root wheel 7880 Jul 18 21:37 /usr/pkg/bin/goto
-r-xr-xr-x 1 root wheel 14160 Jul 18 21:37 /usr/pkg/bin/if
-r-xr-xr-x 1 root wheel 38216 Jul 18 21:37 /usr/pkg/bin/osh
Ecl 3:
% if -r /netbsd echo /netbsd: Is readable ; \
if -w /netbsd echo /netbsd: Is writable
/netbsd: Is readable
</font></pre>
<p>
...
<br>
Notice that the <code>`setenv'</code> command
above is not available in the original Thompson shell.
This is just one of the <b>osh</b> enhancements.
Do we want to say anything about the PWB shell?
</p>
<h2><a id="BourneShell" name="BourneShell">Bourne Shell</a></h2>
<p>
This includes the original Bourne shell, its derivatives, and workalikes.
A true Bourne shell or a Bourne-like shell typically serves as
the standard command interpreter on most UNIX systems.
</p>
<p>
A Bourne-shell workalike is available on SDF as <code>`/bin/sh'</code>.
You can read its manual by doing a <code>`man sh'</code>
at the command prompt.
You can also read its manual
<a href="http://netbsd.gw.com/cgi-bin/man-cgi?sh+1.alpha+NetBSD-2.1">online</a>
if you prefer to do so.
</p>
<pre><font face="monospace">
Ecl 1:
$ PATH=/usr/pkg/bin:/usr/bin:/bin ; export PATH ; printenv PATH
/usr/pkg/bin:/usr/bin:/bin
Ecl 2:
$ ls -l `which sh ksh bash`
-r-xr-xr-x 1 root wheel 298431 Oct 24 2005 /bin/ksh
-r-xr-xr-x 1 root wheel 199717 Oct 24 2005 /bin/sh
-rwxr-xr-x 1 root wheel 963696 Jun 4 08:57 /usr/pkg/bin/bash
Ecl 3:
$ if test -r /netbsd ; then echo /netbsd: Is readable ; fi ; \
> if test -w /netbsd ; then echo /netbsd: Is writable ; fi
/netbsd: Is readable
</font></pre>
<h2><a id="CShell" name="CShell">C Shell</a></h2>
<p>
This includes the original C shell, its derivatives, and workalikes.
</p>
<p>
The C shell is available on SDF as <code>`/bin/csh'</code>.
You can read its manual by doing a <code>`man csh'</code>
at the command prompt.
You can also read its manual
<a href="http://netbsd.gw.com/cgi-bin/man-cgi?csh+1.alpha+NetBSD-2.1">online</a>
if you prefer to do so.
</p>
<pre><font face="monospace">
Ecl 1:
% setenv PATH /usr/pkg/bin:/usr/bin:/bin ; printenv PATH
/usr/pkg/bin:/usr/bin:/bin
Ecl 2:
% ls -l `which csh tcsh zsh`
-r-xr-xr-x 1 root wheel 214333 Oct 24 2005 /bin/csh
-r-xr-xr-x 1 root wheel 459408 Jun 29 2005 /usr/pkg/bin/tcsh
-r-xr-xr-x 2 root wheel 6352 May 11 2007 /usr/pkg/bin/zsh
Ecl 3:
% if (-r /netbsd) echo /netbsd: Is readable ; \
if (-w /netbsd) echo /netbsd: Is writable
/netbsd: Is readable
</font></pre>
<h2><a id="OtherShells" name="OtherShells">Other Shells</a></h2>
<p>
Is this section needed?
</p>
<p>
This section will include information about the Z shell,
rc (AT&T Plan 9 shell),
and any other UNIX shell which does not neatly fall into one category..?
</p>
<h2><a id="Conclusion" name="Conclusion">Conclusion</a></h2>
<p>
Expand on the differences/similarities in light of the preceding content.
One important thing to notice is that though there are differences...
The similarities are more important IMO.
After all,
it is the similarities that allow the user to switch from one shell
to another with little difficulty.
</p>
<hr>
UNIX&reg; is a registered trademark of <a
href="http://www.opengroup.org/tm-guidelines.htm"
>The Open Group</a>.
<br><br>
$Id: shells.html,v 1.1 2008/12/19 16:35:57 jwodder Exp $
</body>
</html>