ARG_MAX
| Shells
| whatshell
| portability
| permissions
| UUOC
| ancient
| -
| ../Various
| HOME
$@
"
| echo/printf
| set -e
| test
| tty defs
| tty chars
| $()
vs )
| IFS
| using siginfo
| nanosleep
| line charset
| locale
2006年02月14日 .. 2021年02月13日 (see recent changes)
After I had repeatedly wondered how all those "ash" variants might be related, and had found hardly any information, I had a closer look at the variants I know.
Source is available for all variants, except for BSD/OS.
Thanks to TUHS for archiving the traditional BSDs and 386BSD,
to Kirk McKusick for his CSRG archive,
and to Peter Seebach for allowing me to learn all BSD/OS variants.
This page documents relationships.
And for the variants without changelogs (the traditional BSDs, 386BSD, BSD/OS and Minix)
this page aims at being a complete log concerning source code changes.
But for the other, later variants this was certainly not the goal and just a few,
arbitrarily chosen changes or bugfixes are listed.
Why no commented diffs? I won't manage to do that work. And if you're interested
on this level, then you are looking at the source already and these comments are a good start.
Content:
· 1.) Original release '89
· 2.) Traditional BSDs:
4.3BSD-Net/2 '91,
4.4BSD-Alpha '92,
4.4BSD '93,
4.4BSD-Lite '94,
4.4BSD-Lite2 '95
· 3.) 386BSD '92-'93
· 4.) BSD/OS (BSDi) '91-'03
· 5.) NetBSD '93-
· 6.) FreeBSD '96-
· 7.) early port from NetBSD to Linux '93 (and early Slackware, Debian)
· 8.) dash '97- (and later Slackware)
· 9.) Slackware variant of dash '06-
· 10.) Android variant (derived from NetBSD) '05-
· 11.) Cygwin variants of ash '98-
· 12.) BusyBox '01-
· 13.) Minix '01-
Illustration of the family tree (click for an increased size).
It was written by Kenneth Almquist as replacement to the
traditional "System V Release 4" Bourne shell
due to the license war between AT&T and Berkeley.
Berkeley distributed it first with "BSD 4.3-Net/2".
The source was
posted to comp.sources.unix, "A reimplementation of the System V shell", on 30-05-1989.
Shortly after, Kenneth published a
job control patch
to fix the problem that more than 4 jobs were not handled properly.
First, a few summaries for orientation, what it's about with these almquist shells.
Differences between the ash family and the SVR4 shell:
$(...)
" command substitution
export VAR=value
"
echo
accepts option -e to interpret escape sequences (undocumented)
bltin
" and "setvar
"
"catf"
, "expr"
, "line"
, "nlecho"
%func
" is recognized
as a directory containing function definitions.
Read more about this.
"local -"
makes $-
local in functions (thanks to Jilles Tjoelker)
--
" as end of options for built-ins
Common to ash variants and the SVR4 shell only, in contrast to other bourne compatible shells:
notexistent_cmd 2>/dev/null
" doesn't redirect the error "not found"
(exception: dash since 0.4.17 and FreeBSD 9.0)
echo x> file*
" doesn't expand file*
Details which are only found in early ash variants:
SHELLVERS="ash 0.2"
#
and %
form of parameter expansion
${10}
set --
" doesn't unset the parameter list
IFS vs. "$*"
`...`
), side effect: this form cannot be nested [changed in 4.4BSD]
@
"
sh -c cmd arg0 arg1
", 1ドル
is set to arg0
[fixed relatively late: all traditional BSDs, and early Free-/NetBSDs and early Minix
behave as well]
VAR=set eval 'echo $VAR'
" gives no output,
that is, you can't call eval
with local variables
for i do
" not accepted
(but "for i; do
" or "for i<newline>do
")
-v
not implemented
trap
" doesn't accept symbolic signal names
expr
" built-in, merged with "test"
!!pattern
"
-z
(don't collapse filename pattern if it doesn't match)
case x in (x)
"
[1]
[Fixed soon. As exceptions, NetBSD and Minix fixed this quite late]
$( )
"
(but not on "` `
")
${var=`cmd`}
"
#!
(if the kernel fails), if not compiled with BSD support
case x in (x)
" because the
parser is robust about case constructs in $(...)
command substitution.
Details which are found in early and in some later ash variants:
foo=`exit 1`
[fixed in NetBSD 1.4, dash-0.3.5 and thus busybox, FreeBSD 9.0]
A detail which is found in ash, in the SVR4 shell, and in most bourne compatible shells, but usually not documented
{ ...; }
" as body in a for
loop (instead of "do ...; done
")
#
or $
)
echo
doesn't interpret escape sequences by default on BSDs,
but requires -e
SHELLVERS="ash 0.2"
removed
$((...))
"
"let"
and "exp"
ENV
instead of SHINIT
at start
${10}
, but doesn't implement it
shift
" built-in knows "can't shift that many"
!!pattern
" removed
$( )
"
lc
" built-in removed
%func/%builtin
functionality was removed from the manual but not from the code
#
and %
forms of
parameter expansion are documented as unimplemented
Apparently, the 386BSD patchkit 2.4 (local copy) went into this release or vice versa:
`...`
) "re-introduced",
thus back-ticks become nestable
and:
${var=`cmd`}
" is accepted
false; echo `echo $?`
" or "false || foo=bar; echo $?
" or "foo=; false; $foo; echo $?
")
The 386BSD distribution was derived from 4.3BSD-Net/2 and aimed at maintaining a runnable system,
that is, completing Net2 with the pieces which had to be removed after the license war.
Some changes:
10ドル
,
01/'97, NetBSD 1.3
<>
" redirection, 02/'99
case x in (x)
" [1] see footnote above, 06/'06, NetBSD 4
Some changes:
<>
" redirection, 10/'00,03/'01, FreeBSD 4.6
case x in (x)
" [1] see footnote above, 08-09/'02, FreeBSD 4.8/5.1
%builtin
in PATH
was removed (%func
remains), 9.0
notexistent_cmd 2>/dev/null
" now also redirects the error "not found", 9.0
foo=`exit 1`
, 9.0
CVS-Web on freebsd.org.
As this variant is closeley related to 4.3BSD-Net/2 with the 386BSD patches, it still shows the following effects:
#
and %
type
built-in
trap
doesn't accept symbolic signal names
sh -c cmd arg0 arg1
", 1ドル
is set to arg0
-v
without functionality
case x in (x)
" [1] see footnote above
${var=`cmd`}
"
This variant is usually known as ash-0.2 and several distributions came with it:
ash-linux-0.2 tarball on metalab.unc.edu.
Two high priorities of this project are restricting to POSIX conformance and slim implementation.
The Ubuntu distribution switched to dash
(wiki.ubuntu.com)
as system shell (/bin/sh
) with release 6.10
(october '06).
The Debian distribution switched to dash with the release
6.0/"Squeeze"
(release goals,
Debian shells).
(It was a release goal for Lenny already,
but the move was postponed, then).
The dash manual documents the command line history and editing capabilities (gained with 4.4BSD-Alpha).
These features are disabled at compile time, though.
You can enable them by recompiling: have the "BSD editline and history library" available
(package libedit-dev on Debian) and remove -DSMALL
from src/Makefile
.
Some changes:
case x in (x)
" [1] see footnote above, 08/'99, 0.3.5-4
<>
redirection, '99/'00, 0.3.x
pmatch()
with fnmatch(3)
as of 0.3.7-1,
but switched this several times later (due to problems with buggy glibc versions).
[^...]
and extended character classes
like [:print:]
are recognized
for
loop
(that is, as "do ... done
"), 04/'01, 0.3.8-1
fnmatch
" used again (and thus [^...]
) 11/'01 with 0.3.80-30
jobid
" built-in removed, 02/'02 with 0.3.8-36
notexistent_cmd 2>/dev/null
" redirects the error "not found" since 12/'02, 0.4.7.
setvar
" built-in removed 04/'03 with 0.4.14.
fnmatch
" not used anymore (and thus no [^...]
) 04/'04 with 0.4.26
fnmatch()
,
06/'04, 0.4.26.
exp
" aka "let
" built-in removed 02/'05 with 0.5.3
Herbert Xu's dash, Debian package. For the changelogs, see ./Changelog (0.5.5.1 snapshot) and the older ./debian/changelog (snapshot) in the distribution.
Slackware 2.1 ('10/'94) had switched to the abovementioned early ash-linux-0.2 port.
Slackware 8.1 (09/'06) then switched to a variant similar to dash 0.3.7-14.
It is based on a NetBSD ash tarball named ash-0.4.0 and a collection of 21 debian patches,
(with the debian specific stuff taken out).
With later releases, these patches were not modified anymore
(until Slackware 13.1, at the time of this writing).
The debian changelog which is contained stops at 0.3.7-14, a fix from 0.3.7-11 is in
(preserve previous exit status upon entering a function), and a fix from 0.3.7-15 is not in
(unknown escape codes are printed literally by echo).
Some other smaller distributions, emphasizing on a slim shell, also use the Slackware shell variant.
Via slackware.org mirrors to slackware-current/source/ap/ash/
The initial release
(android-1.0) in the public part of the Android core source repository dates from
Oct 21 2007.
It's a checkout from the NetBSD repository, some time after 13th of june 2005
which is the latest rcs time stamp in the code.
NetBSD was going to be released as 3.0 soon, in December 2005.
The NetBSD ash source was checked out only once, early in the alpha phase of the Android project,
http://cygwin.com/ (aka http://sources.redhat.com/cygwin/),
Home is www.busybox.net, source online (with log)
Additionally:
Minix specific:
Hence, the following is implemented in an older way:
Minix 2 on minix3.org
Additionally:
and was just minimally modified so that it compiled on Android.
android.googlesource.com, the public part in the Android Open-Source Project (AOSP).
mksh is also available and has become the default shell for many apps, e.g. the terminal emulator.
Core source: /platform/system/core
11.) Cygwin variants of ash ('98-current)
and synchs with Debian ash-0.3.4-2 on 1998年08月31日.
and "don't run commands in backquotes in parent shell context".
read -r
is not default anymore, -e
not implemented anymore
foo.exe
when foo
is found but is not an executable
/bin/sh
Repository of
older Cygwin releases,
ChangeLog.RedHat from ash-20040127-3
12.) BusyBox ('01-current)
The BusyBox distribution is aiming for small implementations.
Apart from that, emphasis is both on standards compliance and on user convenience,
where bash plays a role.
Although further features were added, there's no reference documentation
at the time of this writing (05/'11).
VMWare ESX (6.7.0) has it as system shell.
(This release also added msh, the minix shell, and lush, "a work in progress").
The code was accumulated into one file and notably modified.
to activate math, to deactivate jobcontrol and aliases,
to activate these built-ins:
type
(early releases), getopts
,
command
, chdir
, some flags for read
(later releases);
and to integrate these commands as built-ins:
true+false
(early releases),
echo
, test
(later releases)
ASH_BASH_COMPAT
", active per default)
for several bash compatibility features:
option pipefail
, substring and replacement parameter expansion
${x:y:z}
and ${x/y/z}
,
[[
, source
, $'...'
, &>
fnmatch(3)
instead of the embedded pmatch()
,
which has further issues due to bugs in some glibc versions.
This also introduces [^...]
as synonym for [!...]
.
13.) Minix ('01-'06/'06-current)
This ash was derived from 4.3BSD-Net/2, apparently with the
386bsd patchkit 2.4 applied.
getopts
" fixed ($OPTIND
correct after an
"option requires an argument")
if ; [...]
"
false
" built-in added (true was always a synonym for the colon command)
readline()
#!
#
if 0, *
otherwise
$PSE
is used as prompt if exit status of last command was not 0
exec()
failed
/usr/bin:/bin:/usr/sbin:/sbin:
"