SH(I)                           12/14/76                                SH(I)

NAME
	sh - system shell
	set - shell variables
	wait - modified	wait command
	cd or chdir - modified chdir
	newbin - reread the private bin directory

SYNOPSIS
	sh [same as previous shell]
	set a =	word
	set a +	num
	set a -	num
	wait [pid]
	cd (or chdir) newdir
	cd (or chdir)
	newbin
	xeq filename
        logout

DESCRIPTION
	This shell has all of the features of the previous shell with
	the following additions.

	There are 52 shell-time variables defined, named a to z and
	A to Z.	 You reference them with $a and	so on.	You can	refer
	to them just like you refer to $1 and the other arguments to
	the shell.  A shell variable is set by:

		set a =	whatever

	which sets the given variable.  The whatever can of course be
	concocted from existing	shell variables.  Unset	variables have
	null values.  Here is an example:

		% set a = aardvark
		% set b = etc; set c = motd
		% echo $a
		aardvark
		% cat /$b/$c      ;: becomes cat /etc/motd
		---Message of the day here---
		%

	You can	do a little arithmetic with shell variables:

		set a +	num
		set a -	num

	add or subtract	the num	from the existing contents of the var-
	iable.	If either the num or the previous contents of the var-
	iable do not have the form of a number, it is an error.

	The capital letter variables may be reserved for special purpo-
	ses in the future.  In any event, it is a good idea to write
	your command files using lower case variables for general stuff
	to avoid problems.  There are currently three special variables.

	Variable $N contains the current number or arguments to this
	shell.	It is updated whenever you do a	shift command.	Varia-
	ble $P contains	the PID	of the last process started with an &.
	To take advantage of this, the wait command has been changed to
	optionally take an argument which is the PID to wait for.
	Variable $M has the prompt message (usually "% "), which you
	are free to change.

	There is a small change to chdir.  The "cd" command is a synonym
	for chdir for lazy typists.  If no argument is given, cd or chdir
	changes back to your login directory.

	A new feature, private bin directories, has been added.  A user
	can have a private bin directory which is subdirectory "bin" of
	his login directory.  Whenever a command is typed, this directory
	is searched after the current directory and before /bin and
	/usr/bin.  To save time, the names in the private bin directory are
	hashed into an in-core bit table and a command is only tried in
	the private bin directory if it matches a hash table entry.  If the
	private bin directory is changed, "newbin" updates the hash table.
	The implementation of this is clever enough that you will always
	be able to get commands out of your private bin directory no
	matter what directory you change to.

	The "xeq" command reads the given file into the current shell
	so that you can put set and chdir commands in a file and have
	them be effective.  If there is a file ".startup" when you log
	in, it initially does a "xeq .startup".

        The new "-e" switch echoes out commands as they are executed,
	and types substituted arguments in braces.  This is handy for
	debugging shell command files and for background shell files.

        The "logout" command logs you out, for people who don't like
	to type ctrl/d.

AUTHOR
	John Levine, among others

SEE ALSO
	sh(I) (old version).
FILES
	/bin/sh - shell for executing command files
	/etc/xglob - modified glob
	/etc/passwd - for pathname of login directory
BUGS
	More complicated string operators would be useful.
	Not a bug, really, but __if should be able to do numerical
	comparisons.
