Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Thompson shell
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Design == The shell's design was intentionally minimalistic; even the ''if'' and ''goto'' statements, essential for control of program flow, were implemented as separate commands.<ref name=Mashey1976-10-13/> The shell has no facilities for comments besides a builtin command {{code|:}}. Programmers simply write text after this command, which ignores all parameters and simply succeeds. Other builtins include {{code|chdir}}, {{code|exit}}, {{code|login}}, {{code|newgrp}}, {{code|shift}}, and {{code|wait}}.<ref name=etsh.man/> The ''if'' command combines the uses of modern-day Bourne shell ''test'' and ''if''. The command first looks for an expression (which can be similar to modern-day ''test'' or involve an external command) then treats the rest of the command-line as the command to execute if the condition turns out true. There is no ''else'' branch.<ref>{{cite web |title=if(1) (html) - IF(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_if.1.html |website=etsh.nl}}</ref> ''goto'' is implemented in an interesting way, as it is separate from the shell. When asked to jump to "LABEL", it seeks the current command file for a line that says {{code|: LABEL}} (recall that {{code|:}} is simply ignored), then exits. When the shell tries to read a next line, the repositioned file descriptor will direct it to the labelled location.<ref>{{cite web |title=goto(1) (html) - GOTO(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_goto.1.html |website=etsh.nl}}</ref> There is no redirection of additional file descriptors other than standard input and output (0 and 1) in Thompson shell. Redirection of stderr (file descriptor 2) also requires an external program wrapper, {{code|fd2}}.<ref>{{cite web |title=fd2(1) (html) - FD2(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_fd2.1.html |website=etsh.nl}}</ref> The shell supports globbing,<ref name=etsh.man>{{cite web |title=tsh(1) (html) - TSH(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_tsh.1.html |website=etsh.nl}}</ref> but actually implements it by deferring it to a {{code|glob}} command that replaces the arguments and calls the requested command.<ref>{{cite web |title=glob(1) (html) - GLOB(1) - Manuals - Etsh Project (V6Shell) |url=https://etsh.nl/man/_glob.1.html |website=etsh.nl}}</ref> Thompson shell has positional parameters, but no named variables nor access to environmental variables. It understands the creation of background commands with {{code|&}}, similar to Bourne shell. It offers quoting and backslash escapes, though the single quotes work differently from Bourne shell.<ref name=etsh.man/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)