bcx@eeg.UUCP ( Bryan Costales) (08/22/85)
The following is a solicitation for help to complete, and a proposal
and outline for, a Berkeley style shell to run under Apple's ProDos
operating system on the Apple II series computers. I am submitting it
to net.micro.apple because a {net,mod}.projects does not yet exist.
Please respond by uucp or U.S. mail to:
Bryan Costales
212 Prentiss
San Francisco, Ca 94110
uucp: ...!ptsfa!eeg!bcx
---------------------------------------------------------------------
Colaborators Sought
-------------------
1. Background
When I first received the ProDos operating system, I marveled at
how close it came to bringing the Apple into the world of Unix. It
didn't take long, however, for me to discover its drawbacks. The
following are observations, not flames.
-- The shell that is supplied by Apple (BASIC.SYSTEM)
is, like the former DOS 3.3, merely intended as
an extension of Applesoft BASIC and not a true shell.
-- The kernel (aka MLI) contains some wierd
restrictions. File names MUST be upper case and
may only contain a "." (shades of cp/m).
Directory files may be read but not written to,
except as raw blocks at the lowest MLI level.
-- None of the "mode" bits are allocated for
"permission to execute". None of the "reserved"
bits are available to programmers.
So I waited. Eventually a few shells arrived that attempted to make
ProDos a little more 'Programmer Friendly'. First came the Orca/m
assembler. Better, but not a true, general purpose shell. (eg.
Command line arguments resemble RSX). Then came the Anix 2.0
shell. Even better, but still short of the mark. (eg. redirection
supported, but buggy on hard disks). Finally, I'm stil waiting for
the Aztec C shell (Late August is their latest promise).
Despite these drawbacks, I still feel ProDos has the potential of
making the Apple environment more Unix-like.
2. What I Have Done
Shortly after ProDos was released (I was working with pre-release
documents), I began writing my own shell. Because there were no
assemblers running under ProDos, I used Lisa 2.6, under DOS 3.3, to
write it. The moving back and forth between the two systems killed
me, and I abandoned the project.
I then purchased Orca/m ProDos Version and started anew. I quickly
found that I couldn't addapt any of what I had done under Lisa 2.6
to Orca. I also discovered that Orca/m is about a 100 times slower
than Lisa at assembling. So stopped again.
My latest shot began when I purchased Lisa 3.1. This assembler is a
quantum leap above the old Lisa. Unfortunately the parsing rules
and some syntax was changed in the revision and I decided to
rethink the project and start over from scratch.
3. Why I Seek Help
I now have 2000 lines of code and am only 1/4 done. What with work
and other commitments, it will be a year or so before my shell is
completed. Since it was my intent to place the shell into public
domain, I thought "why not see if there is anyone who would like to
help?". Hence this note.
I appeal to you -- any 6502 assembly language hacks interested in
joining me on this project. I am willing to, once again, start from
scratch if need be. You suggest the assembler.
The Project
-----------
1. Introduction.
The name is tentatively "bsh" for "Berkeley-style Shell". Bsh is a
system program (SYS) to replace BASIC.SYSTEM as the defacto shell
under Apple ProDos. It is not an interactive shell, rather it is a
sophisticated executer of programs.
2. Programs.
There are several types of programs that bsh can executed
directly or indirectly:
BIN -- Executable binary or machine language programs.
These are run in core and may overlay but not
be co-resident.
CMD -- Relocatable, executable binary or machine
language programs limited to one block (512
bytes) in size. These are the individual
commands (eg, rm, cp, du, etc.). They load
into one of three shell buffers and must be
re-executable without reloading.
TXT -- Shell scripts. Must begin with a # character.
Environmental variables are manipulated using
appropriate CMD's (eg. set, if, endif, etc.).
BAS -- Applesoft Basic programs are run by first
loading the BASIC.SYSTEM shell, then running
it with the file name as its argument.
SYS -- A shell soft exit is done. Enviornmental
variables and history are saved. Then the
system program overlays the shell.
3. The Command Line.
Programs are run and CMD's executed by typing their name followed
by a space delimited list of arguments. For programs that are able
to use them, those arguments are placed into and array, and the
variables argc and argv passed. Certain characters have special
meaning in a command line, unless escaped by a backslash
character.
; -- Compounds commands, as: ls ; echo done
| -- Creates pipes, as: ls | wc -w
> -- Redirect stdout, as: ls > junk
>> -- Redirect & append stdout: cat letter >> mbox
< -- Redirect stdin, as: wc < mbox
<< -- Set EOF string, as: cat << @FUZZY@
>& -- Redirects stderr, as; prog >& log
>>& -- Redirects & append stderr: prog >>& log.sum
Command lines are also subject to wildcard expansion.
*c -- Match zero or more up to c
? -- Match a single character
[range] -- Match any in the Ascii range, as: [0-9]
[select] -- Match any of list, as: [A,a]
[both] -- Match any of list or range, as: [0-9,A,a]
Commands are placed in a history buffer for later re-execution.
The command line is subject to history substitution.
! -- Replace with current history number
!nn -- Re-execute command line number nn
!text -- Match text in history and re-execute
!$ -- Replace with last arg previous command
!! -- Re-execute previous command
Environmental variables can be placed into the command line. The
form is:
$name as: cp a.out $CMD/awk
and they are set using the "setenv" CMD as:
set CMD= /profile/shell/cmd
There are a limited number of environmental variables. They are:
HOME -- Home directory
CMD -- Command directory
SYS -- System programs directory
PATH -- Execution search path
i -- Numeric int
j -- Numeric int
x -- Numeric float
y -- Numeric float
PROMPT -- Prompt string
MAIL -- Mail spool directory
TMP -- Temporary Directory
1 thru 9 -- Shell script arguments (strings)
DEV -- Device driver directory
TERM -- Pathname of driver for terminal i/o
ROOT -- Volume under which all other volumes
will be files.
The shell also provides some built-in aliases:
/dev/... -> $DEV/...
. -> current prefix
.. -> previous prefix
~ -> $HOME
#nn -> $DEV/slot.nn
Command line arguments enclosed in full quotes are insulated from
all substitutions, expansions and transformations, except for
substitution of environmental variables and aliases.
Command line arguments enclosed in half quotes are insulated from
all change.
Command line arguments enclosed in reverse-half-quotes cause the
command so enclose to be executed and its output inserted at that
place in the command line.
4. Memory Use.
The shell resides at the top of memory from $a000 to $beff. Page
$be00 is the shell global variable variable page. All buffers are
internal to the shell except the following which build down from
$9fff: The three 1024 byte file buffers; The hash table derived
from $PATH; Shell script argv strings; Command line argv strings.
Zero page is only used while the shell is "active" (it is passive
when programs are running). Those locations are bank-switched in
and out of an internal buffer depending on the shell's status, thus
freeing zero page for use by all programs.
The shell makes no use of extended memory. It assumes a 64k Apple
II+ as its basic machine. On a IIe or //c, it can be configured to
soft exit to /ram for improved efficiency.
5. Hardware.
The shell is hardware independant, but is virtually unusable
without:
80 col hardware
upper/lower case keyboard (or enhancer)
hard disk (profile or sider)
6. Accounts and Users.
The shell can be configured differently for different users. This
is done by using the getslot program (like getty). I connects to a
slot of I/O and handles logins and passwords. The location of the
passwd file is known to getslot, not to the shell. The getslot
program loads the shell, configures it according to the passwd
file, then soft enters the shell. A soft entered shell will exit by
rerunning the program that started it.
This feature is intended to, for example, allow the user to log in
to his computer from work and transfer files. Give friends,
co-authors, and the like, accounts on his machine for exchanging
data. The password file will enable getslot to spawn, for example,
a uucico type program for network mail.
7. Patches to ProDos.
To achieve a friendlier environment, it will be necessary to make
some small patches to the ProDos kernel. These should be made by a
seperate "patchpro" program, so that various versions of the kernel
can be properly handled.
File names: A patch to allow file names to contain upper
and lower case letter, and all characters.
Mode Bits: A patch to allow the reserved bits to be
accessed and used by users.
----------------------------------------------------------------
Unix is a Trademark of AT&T
RSX is a Trademeark of Digital Equipment Corp.
Apple, Apple II, II+, //c , and ProDos are Trademarks of Apple Computer Corp.
Orca/m is a Trademark of The Byte Works, Inc.
----------------------------------------------------------------
--
----
Bryan Costales, EEG Systems Laboratory
1855 Folsom St, San Francisco, Ca 94103 (415) 621-8343
{ihnp4,dual,qantel}!ptsfa!eeg!bcx