LINENO
is a ksh feature, also present in bash and zsh. There is no such feature in the Bourne shell, in the POSIX specification or in dash. If you need the line number, make sure that your script is executed under a shell that has the feature. Most systems have either bash or ksh available.
if [ -z "$LINENO" ]; then
if type ksh >/dev/null 2>/dev/null; then
exec ksh "$0" "$@"
elif type bash >/dev/null 2>/dev/null; then
exec ksh "$0" "$@"
else
echo 1>&2 "$0: Fatal error: unable to find a shell that supports LINENO."
exit 100
fi
fi
The short answers are, yes, it was done for compatibility (lots of programs referenced /bin/sh
and /bin/ed
), and in the early days /bin
and /usr/bin
contained totally disjoint sets of files. /bin
was on the root filesystem, a small disk that the computer's boot firmware had to be able to access, and held the more critical and often-used files. /usr/bin
was on /usr
, typically an entirely separate, larger disk. /usr
, at first, also contained users' home directories. As /usr
grew, we would periodically replace its drive with something larger. The system could run with no /usr
mounted, even if wasn't all that useful.
/usr
's disk (or disk partition) was mounted after the Unix kernel had been booted and the system was partway through the user-mode boot process (/etc/rc
), so programs like sh
and mount
and fsck
had to be in the root filesystem, generally in /bin
and /etc
. Sun had even rearranged /
and /usr
so that a shared copy of /usr
could be mounted read-only across a network. /usr/tmp
became a symlink to /var/tmp
. /var
was either on the root filesystem or, preferably, on another partition.
I believe it was Sun that decided, at one point, that it wasn't worth heroically trying to have a system be able to come up if its /usr
was trashed. Most users either had /
and /usr
on the same physical disk - so if it died, both filesystems were toast - or had /usr
mounted read-only from a server. So some critical programs used for system boot and maintenance were compiled statically and put in /sbin
, but most of the programs in /bin
were moved to /usr/bin
and /bin
became a symlink to /usr/bin
.
System V prior to R4 didn't even have symlinks. Sun and AT&T worked to combine SunOS and SVR3, and that became SVR4 (and Solaris 2). It had /bin
as a symlink to /usr/bin
.
So when that web site says "On SysV Unix /bin
traditionally has been a symlink to /usr/bin
", they really should have said "On System V Release 4 and followons, ...".
Best Answer
I'd guess lack of features - no command history, no fancy redirection, no command line editing. BSD introduced
csh
the C shell for those reasons. Another factor is that the Genuine Bourne Shell was only recently available in open source form. Unless you licensed it, you couldn't distribute it. That put it out of reach for free-of-cost distros, and made it ideologically unpalatable for other distros, and *BSDs.But the code is available now. You can take a look, compile it, give it a spin.