Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ukma!psuvm.bitnet!whv From: wtoomey@GARA.UNE.OZ (Warren Toomey) Newsgroups: comp.os.minix Subject: Clam, a Tcsh-like shell (part 0 of 7) Message-ID: <75238WHV@PSUVM> Date: 9 Mar 89 01:51:29 GMT Sender: Minix operating system Reply-To: INFO-MINIX@UDEL.EDU Organization: University of New England, Armidale, Australia Lines: 191 COMMENTS: Warning -- original Sender: tag was info-minix-request@UDEL.EDU COMMENTS: To: info-minix@udel.edu Here is a Tcsh-like shell written by a friend of mine, Callum Gibson. It has been mostly beta-tested by Robert Regn & myself (thanks Robert!), and so I thought I'd post it. Callum & I are v.busy at the moment (read hectic), so I can't promise that bugs will be fixed. If you have any patches, let me know. Warren Toomey (wtoomey@gara.une.oz) P.S Source is 12bit compressed & uuencoded to save me money, and to get past the 25K limit on outgoing postings. P.P.S Known bugs/omissions at present are: Clam doesn't catch CTRL-\ There are no subshells '( )' and NO flow control !! If a command cannot executed because of lack of space, a message isn't always displayed. (Probably the shell is being used if exec fails - should be only in the ENOEXEC case ) If I want to complete a path standing on a directory with only one entry (e.g. /usr/local/ ) no completion is made until the first char. of this entry is typed. No redirection of builtin commands is possible With 24000 stack clam runs about 200 commands, then the stack is exhausted and clam can't run any extern command. There are problems with the `` subs. Try: /usr/ast 24 echo `tty` |od -c ----------------------- README follows, please read! ---------------------- Clam is a `Tcsh'-ish shell, with a syntax more like Bourne shell. It offers command line editing, history susbstitution, aliases etc. It was written by Callum Gibson for a Comp.Sci Honours project, and was ported to Minix by Warren Toomey. Copyright Notice ---------------- The Clam source is copyright (c) 1988 C.Gibson. Permission is granted to copy and give away the sources as is, but no changes must be made to the source. Binary copies must also be accompanied by this source. You are not allowed to use Clam on a non-Minix system. Basically, Callum & I don't want to look after several variants of Clam, so if you have a bug patch, or some new whizz-bang feature you have written, PLEASE post the patch to us (with #ifdef MINIX around it), and we'll post an official patch if we like it. Note that Clam has several builtin functions that have not been written yet. Callum will get around to it, so if you finish a function off, post it to us ONLY! One last note- When Clam is finally finished to Callum's satisfaction (and that means all the UCB, ATT, SUN and MINIX sections) he will post it to comp.sources.unix. This posting is for MINIX Clam ONLY!!! This means that firstly we don't guarantee that it will work on any system other than Minix. Secondly, as the Copyright says, you can't use Clam on a non-Minix system, or we'll get angry. Installing Clam under Minix --------------------------- Clam runs under vanilla 1.3c PC-MINIX with no modification (sorry, haven't got an ST to try it on, but there should be no problems). You will need the directory functions posted by Terrance Holm (see his posting <575@uvicctr.UUCP> on the 13th Dec, 1988). Some of the programs such as `vi' and `man' may be in different directories than mine, so read through `header.h'. Also, I have both the termcap & directory libraries separate from `libc.a', so read & modify the makefile if necessary. Clam should only need about 20-30K of stack, so don't forget to chmem it when the compile is finished. Play with the chmem value, and let me know what you find is optimum. Finally, Clam needs some termcap entries that were not in the 1.3c termcap entry. They are `up=\E[A' and `nd=\E[C'. Notes on Clam ------------- Clam is NOT a Tcsh clone, really. It just feels like it. So it does some things differently than Tcsh, Csh, or Sh. For example- Variables: Clam uses internal variables only to do things. On startup it makes internal copies of environment variables. When it execs another process, it just passes on those environment variables. So if your environment HOME is `fred' and you say `HOME=jim' in Clam, `fred' will be the one passed on. You can alter the environment variables by using export, so `export HOME' after `HOME=jim' will ensure `jim' gets passed on. The Path: One reason why Clam uses internal variable copies is to allow it to place a `builtin directory' somwhere on your path. This directory is specified by `~#'. On startup, Clam prepends the builtin directory to the start of its copy of PATH. Try `list' when you are in Clam. It should show a line like `PATH= ~# /bin /usr/bin', meaning the builtin directory is searched first before /bin and /usr/bin. You can alter the path, of course, but don't leave out ~#, unless you don't want builtins. Note that if you export PATH, the ~# will be stripped from the environment copy. Aliases: Aliases have a more Bourne shell syntax than Tcsh. For example, `alias ls "ls -l $*" ' aliases ls, with $* having the normal shell meaning. Of course, $1 $2 etc are available as well. Assignment: Variables are assigned as per Bourne shell, but the `=' sign need not be right next to the variable. This means that `chmem =25000 clam' is interpreted as a variable assignment. To get around this, do ` chmem "=25000" clam ', the double quotes preventing expansion of the `='. See the included .login and .clamrc for examples of the above. Changes to get Clam running under Minix --------------------------------------- Since Clam is a UCB shell at heart, I have made many changes to get it up under Minix. These are all in #ifdef's and #ifndef's, so that eventually Clam will compile under any system with the appropriate defines. The changes come under the following headings: * Job Control- Control of foreground & background process under UCB Unix depends on signals not available under Minix, so there is no job control with Minix Clam. * Scripts- At the moment, most of the Clam script functions (such as `while','for',`repeat' etc. have not been written. I have removed the code that references them to reduce Clam's memory requirement. * Clam uses hashing of the executables on the path to find and execute programs faster. Unfortunately, it used too much stack under Minix and kept crashing, so I took it out. There was no noticeable difference in preformance! * Several of the array sizes in `header.h' were reduced to cut the memory needed. Also executables like `/usr/local/bin/vi' are declared for my own system. You might like to change these. * Minix headers don't seem to declare function types, so extra declarations occur in the source. Also some of the structs used by Minix are different to normal Unix (e.g the FILE struct), so some of the variable declarations were altered. * The code that uses symbolic links has been cut out. * Finally, the most serious gripe! Minix seems to be a hodgepodge of UCB (e.g termcap & ioctl), ATT (e.g dir functions) and Version 7 Unix (e.g old open function). This means that I've had to nest #ifdef's in many places, and write code to use the old open function. Roll on POSIX Minix. Bugs & Patches -------------- If you find a bug, or make a patch to fix it, post it to me: wtoomey@gara.une.oz (Sorry, I don't know how to get it to Australia, I don't often post from overseas!) Please DON'T post it to the net, or we'll all get confused. I will post official patches to Clam as they are needed. That's about it. If you're used to Csh or Tcsh, you should find Clam easy to use. If not, read the manual `clam.1'. Clam starts by executing the commands in `.clamrc', and then `.login' if it is the login shell, so I've included the two files that I use. Share & Enjoy! Warren Toomey & Callum Gibson