old-www/LDP/LG/issue49/fischer.html

192 lines
7.1 KiB
HTML

<!--startcut ==============================================-->
<!-- *** BEGIN HTML header *** -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD>
<title>A Brief History of the 'rm' and 'rmdir' commands LG #49</title>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
ALINK="#FF0000">
<!-- *** END HTML header *** -->
<!-- *** BEGIN navbar *** -->
<A HREF="index.html"><IMG ALT="[ Table of Contents ]"
SRC="../gx/indexnew.gif" WIDTH=163 HEIGHT=60 ALIGN=bottom ></A>
<A HREF="../index.html"><IMG ALT="[ Front Page ]"
SRC="../gx/homenew.gif" WIDTH=163 HEIGHT=60 ALIGN=bottom></A>
<A HREF="bennet.html"><IMG ALT="[ Prev ]" SRC="../gx/back2.gif" WIDTH=41 HEIGHT=60 ALIGN=bottom></A>
<A HREF="../faq/index.html"><IMG ALT="[ Linux Gazette FAQ ]"
SRC="./../gx/dennis/faq.gif"WIDTH=163 HEIGHT=60 ALIGN=bottom></A>
<A HREF="lamb.html"><IMG ALT="[ Next ]" SRC="../gx/fwd.gif" WIDTH=41 HEIGHT=60 ALIGN=bottom ></A>
<!-- *** END navbar *** -->
<!--endcut ============================================================-->
<H4>
"Linux Gazette...<I>making Linux just a little more fun!</I>"
</H4>
<P> <HR> <P>
<!--===================================================================-->
<center>
<H1><font color="maroon">A Brief History of the 'rm' and 'rmdir' commands</font></H1>
<H4>By <a href="mailto:enf@pobox.com">Eric Fischer</a></H4>
</center>
<P> <HR> <P>
<!-- END header -->
<p>
Unlike many of the most basic Unix and Linux utilities,
the <tt>rm</tt> command's name is not actually older than Unix itself.
In Unix's predecessors, the Compatible Time Sharing System (CTSS) and Multics,
the command used to remove files was called <tt>delete</tt>,
which in Multics could optionally be abbreviated to <tt>dl</tt>.
In Unix, the name became <tt>rm</tt>, probably to reflect the
philosophical change from deleting files
to removing the directory entries that linked to them.
<p>
Also part of Unix by the time of its First Edition manual
(November 3, 1971) was the <tt>rmdir</tt> command to remove directories.
Today the <tt>rmdir</tt> command
just makes an <tt>rmdir()</tt> system call for each of its arguments
and reports any errors.
But in 1971 there was no
<tt>rmdir()</tt> system call, so the <tt>rmdir</tt> program
had to do all the work itself.
It would make sure the directory being removed
was empty and that its permissions were correct and
then remove the ``<tt>.</tt>'' and ``<tt>..</tt>'' special links
before unlinking the directory itself.
This situation persisted until 1983, when the introduction
of the new Fast File System in 4.2BSD made the creation and removal
of directories the responsibility of the kernel.
<p>
The 1971 version of <tt>rm</tt> did not have any of the options
that current versions have.
It was also willing to remove read-only files, though the
manual noted that it ``probably should ask.''
It was changed so that it did ask (as CTSS's <tt>delete</tt> had been
in 1965) in a new version whose
manual page was dated January 20, 1973, and which included these options:
<p>
<table>
<tr>
<td><tt>rm -f&nbsp;&nbsp;</tt></td>
<td>don't ask before removing read-only files</td>
</tr>
<tr>
<td><tt>rm -r&nbsp;&nbsp;</tt></td>
<td>recursively remove subdirectories</td>
</tr>
</table>
<p>
The way the
<tt>rm -r</tt>
option was implemented at that time,
when <tt>rm</tt> encountered a directory among the files it was
removing, it would <tt>cd</tt> (then called <tt>chdir</tt>)
to that directory and
start another instance of <tt>rm&nbsp;-r&nbsp;*</tt> to remove its contents.
A version which did the recursion within a single <tt>rm</tt> process
appeared in the Seventh Edition of Unix in 1979,
which also introduced a new option:
<p>
<table>
<tr>
<td><tt>rm -i&nbsp;&nbsp;</tt></td>
<td>ask whether each file or directory should be removed</td>
</tr>
</table>
<p>
This made it possible to type <tt>rm&nbsp;-i&nbsp;*</tt> to
interactively remove selected files from a directory, including ones whose
names had somehow been mangled to the point that they had become untypable.
This feature had actually been needed much earlier, but prior
to the Seventh Edition it had been done by a separate, now long abandoned
program called <tt>dsw</tt>.
<p>
The name of <tt>dsw</tt> was more mysterious than any other command,
even in this operating system known for its obscure names.
The Sixth Edition manual taunted the curious with
the note that ``the name
<i>dsw</i> is a carryover from the ancient past. Its etymology is
amusing.'' The First Edition had added ``...&nbsp;but the name is
nonetheless ill-advised,'' but this disappeared from later manuals.
<p>
The speculation about what the name of <tt>dsw</tt> might really mean
(delete s--t work? <i>do svidaniya</i>?) was put to an end
when Dennis Ritchie revealed in a 1981 Usenet posting
that the name had originally meant ``delete from switches.''
This was a reference to the toggle switches on the front panel of
the PDP-7 computer that the earliest version of Unix ran on.
(Some later hardware also had console switches, and the
Third through Sixth Editions had a <tt>getcsw()</tt> system
call that programs could use to find out what they were set to.)
<p>
To use the original <tt>dsw</tt>, you would set the front panel
switches to a number and run <tt>dsw</tt>, which would then
read that number of entries from the current directory, print on the terminal
the name of the last one it had read, and crash itself, leaving a core dump.
You could then, if you wanted, remove the file it had named
by reexecuting the <tt>core</tt> file.
When this awful user interface was replaced by a more reasonable one,
the name remained until the entire program was replaced by <tt>rm&nbsp;-i</tt>.
<p>
At that point, the evolution of the <tt>rm</tt> command came, for
the most part, to an end.
A slightly altered version, dated April 1, 1981 and distributed with
4.2BSD, introduced an option terminator ``<tt>-</tt>'' to make
it easier to remove files whose names started with a dash.
For consistency with other commands,
the POSIX standard changed this to ``<tt>--</tt>''
and made the capitalized option ``<tt>-R</tt>''
also remove directories recursively.
<!-- *** BEGIN copyright *** -->
<P> <hr> <P>
<H5 ALIGN=center>
Copyright &copy; 2000, Eric Fischer<BR>
Published in Issue 49 of <i>Linux Gazette</i>, January 2000</H5>
<!-- *** END copyright *** -->
<!--startcut ==========================================================-->
<P> <HR> <P>
<!-- *** BEGIN navbar *** -->
<A HREF="index.html"><IMG ALT="[ Table of Contents ]"
SRC="../gx/indexnew.gif" WIDTH=163 HEIGHT=60 ALIGN=bottom ></A>
<A HREF="../index.html"><IMG ALT="[ Front Page ]"
SRC="../gx/homenew.gif" WIDTH=163 HEIGHT=60 ALIGN=bottom></A>
<A HREF="bennet.html"><IMG ALT="[ Prev ]" SRC="../gx/back2.gif" WIDTH=41 HEIGHT=60 ALIGN=bottom></A>
<A HREF="../faq/index.html"><IMG ALT="[ Linux Gazette FAQ ]"
SRC="./../gx/dennis/faq.gif"WIDTH=163 HEIGHT=60 ALIGN=bottom></A>
<A HREF="lamb.html"><IMG ALT="[ Next ]" SRC="../gx/fwd.gif" WIDTH=41 HEIGHT=60 ALIGN=bottom ></A>
<!-- *** END navbar *** -->
</BODY></HTML>
<!--endcut ============================================================-->