@@ -211,12 +211,12 @@ basic command interpreter, not a full scripting language like [[rc]].
211211\l if/goto (and glob) were external programs
212212
213213%claude:
214- The small size of Ken Thompson's shell reflects the \unix philosophy
215- of keeping the shell minimal: [[if]] and [[goto]] were separate
216- programs (not builtins), and wildcard expansion was handled by
217- an external [[glob]] program. This made the shell itself trivial
218- at the cost of some awkwardness---for example, you could not
219- write a loop without creating a script file for [[goto]] to jump into.
214+ % The small size of Ken Thompson's shell reflects the \unix philosophy
215+ % of keeping the shell minimal: [[if]] and [[goto]] were separate
216+ % programs (not builtins), and wildcard expansion was handled by
217+ % an external [[glob]] program. This made the shell itself trivial
218+ % at the cost of some awkwardness---for example, you could not
219+ % write a loop without creating a script file for [[goto]] to jump into.
220220
221221%history:
222222\item The Bourne shell~\cite{sh}, also called [[sh]], superseded
@@ -261,14 +261,14 @@ as in [[rc]], but instead a complex recursive descent parser.
261261\l design of sh by bourne: https://www.youtube.com/watch?v=2kEJoWfobpA
262262
263263%claude:
264- Part of the difficulty comes from the source code itself: Bourne
265- wrote extensive C macros to make the code look like Algol
266- ([[IF]], [[THEN]], [[BEGIN]], [[END]], etc.), which allegedly
267- inspired the International Obfuscated C Code Contest.
268- More fundamentally, the Bourne shell has no formal grammar---Tom Duff
269- once remarked that ``nobody knows the grammar of [[sh]]''---so
270- the parser is full of special cases and context-dependent
271- disambiguation that make it hard to reason about.
264+ % Part of the difficulty comes from the source code itself: Bourne
265+ % wrote extensive C macros to make the code look like Algol
266+ % ([[IF]], [[THEN]], [[BEGIN]], [[END]], etc.), which allegedly
267+ % inspired the International Obfuscated C Code Contest.
268+ % More fundamentally, the Bourne shell has no formal grammar---Tom Duff
269+ % once remarked that ``nobody knows the grammar of [[sh]]''---so
270+ % the parser is full of special cases and context-dependent
271+ % disambiguation that make it hard to reason about.
272272
273273%\item C shell lots of interactive features.
274274%\item Korn shell lots of interactive features.
@@ -1263,7 +1263,10 @@ variable stringification, see Section~\ref{sec:quoting}).
12631263%claude:
12641264The [[boot.rc]] script also assigns [[objtype=arm]].
12651265This is not just a local shell variable: in \plan, all shell
1266- variables are automatically exported to the environment.
1266+ variables are automatically exported to the environment---there
1267+ is no need for an [[export]] command like in [[bash]]%
1268+ \footnote{If you need environment isolation, [[rfork e]] creates
1269+ a private copy of [[/env/]]; see Section~\ref{sec:rfork}.}.
12671270When [[mk]] (the build tool) is later run from this shell,
12681271it inherits [[$objtype]] and uses it to select the correct
12691272compiler and assembler (e.g., [[5c]], [[5a]], [[5l]] for ARM).
@@ -1303,6 +1306,10 @@ would be unaffected.
13031306The [[exec]] builtin replaces the current shell process
13041307with the specified command. Here it replaces the boot
13051308shell with an interactive instance of [[rc]] (the [[-i]] flag).
1309+ Without [[exec]], the boot shell would fork a child [[rc]],
1310+ wait for it to finish, and then continue---but there is
1311+ nothing left to do, so the extra process would just waste
1312+ a process slot until the interactive shell exits.
13061313See Chapter~\ref{chap:builtins} for the full list of builtins.
13071314
13081315\subsection{Other features}
0 commit comments