Version7: This is version 7. I now pause() under JOB instead of busy-waiting using wait3(). Instead SIGCHLD is caught by checkjobs(), which wait3()s to get the child's new status, and sets a global which will cause waitfor() to break out of its pause() loop. SIGTSTP is caught by stopjob() still. Version8: This version sets TOSTOP to stop output in the background. It also can sucessfully bring processes to and from background + stopped. For some reason, pipes fail dismally. Fixed, I wasn't closing all the fds :-( Also ^Z sometimes calls the shell's parent & not shell?? Is exec() getting the bckgnd flag for all processes in a pipeline? Version9: This version sets TOSTOP to stop output in the background. It also can sucessfully bring processes to and from background + stopped. ^Z doesn't tromp the shell now (that I can tell). Still can't get SIGTTIN to work :-( Version10: I've added the cbreak stuff (unused as yet), and also made parse use a line buffer. This is so I can import clam's CLE and add that. Version11: Added the CLE, with some bits hacked out so that I don't use history or file name completion. It seems to work :-) Version12: Added some comments, added ifdefs for it to compile under Minix, which it does, although bcc won't pass structs - therefore should pass a struct ptr in invoke/redirect. Also added some job code, but not tested as yet - I'm running under Minix ;-) Version13: Changed BOOLEAN to bool, altered the rdrct usage to allow bcc to compile it. Also moved ^G to \007, serves me right for cutting & pasting :-). Wish there was an easy way to save diffs - dump? Version14: Installed the job code to keep a job list, and it works. I should add %job numbers, which should be easy. Seems the terminal chars are not being unset properly, as vi won't go into cbreak mode. Why? Version15: Added % handling into fg & bg, plus cwd support. Bugs & kludges: vi still doesn't go after fg, shell waiting not on fg'd process headpid is a _kludge_, I must fix Apart from that, it's all rather well. Version16: The problem with vi was that TERMCAP was too long for the var routines. Just don't define it. I now use currentjob everywhere, and Head* no longer exist. It all works quite well now, yummo!!! I haven't moved it back to Minix since version thirteen, probably some missed #defines etc. Version17: I've written my own clex.c to find files, binaries, usernames, and have added it to the shell. `Nameopt' works, but I'm not sure how to indicate the first word on the line. `Complete' is probably buggy, I haven't installed it yet. Changed yankprev to return the 1st position, and so bug a) is fixed. I am using a `dummy' path at the moment, and should use the `real' one. Fixed complete to work, which it appears to do. Also I am now using the real path, and that works as well. I even made sure I was free()ing all the malloc'd stuff!! Ta da! Version18: v17 compiles no worries under Minix (bcc), but I get a malloc assert error + core dump when expanding ~ - I wonder why? Even does under ACK :-( Only when I print them out. Weird, I nedd to malloc a few extra bytes, also expand sometimes expands to the biggest :-(, not just ~. Fixed, a bug in expand. Now I should make it continue expanding ~blah/ as a directory. Added match() and matchdir(), plus a hacked-up meta_2(), and it works. I really want to convert meta/parse to use a linked list of words instead of a single line, then we can malloc as we find words, and save copying too. Version19: Well, parse now parses the carray, and meta now puts things in there, and qsorts after a *?[], so it's all rather nice. I think gettoken needs a bit of a rewrite as I just hacked it a lot, and it dies when using ""s. I don't know if I'll have to insert into the carray when expanding all the meta's, or just append as I'm doing now. Oh well, we'll soon see. Altered clex to see ~ as a directory when there is a / in it, simple. I should write a meta_1 to expand ~ as well I guess. Version20: Meta now uses a singly linked list so it can insert words, and meta_1 now expands tilde. Parse now runs with the linked list, wow it works! Tilde() also expands ~/ now, so ~ *?[] all fully work! Version21: Hist.c is added but not yet connected to anything, but the code is simple so there should be no problem. Savehist & history connected, ^Js at end of each history?! Fixed. Also connected ^P and ^N, which work happily! Tried to add !, but forgot I must convert from line to linked list, sigh. Did this, had to always malloc in meta_1, which I will fix. Also !word & !num work, but !! and !-num don't :-( Fixed, calculating old histnum wrong. Currently saving histories with ! in them, should save after expanding !. Version22: Added a routine to expand the word linked list after meta_1, so that savehist now gets a line without !! etc. I must remember to not strcpy, as expline() mallocs already. Done. Added a simple echo to builtin.c, in case I ever lose ls(1). Now about to tidy up comlined, remove the fileno()s. Seems to work. Also got rid of zin,zout. Bug, > appears not to work, but >> does. Fixed. Went back to a line parser in parse, now that expline() exists. Bug, when history skips a number (duplicate), the number is lost too. Version23: Starting on adding variable expansion to the shell. Wow, meta_2 now calls dollar, which expands $var, $$, $#, $0... correctly :-) Doing $* will involve inserting into the carray. Also made set look like Clam's list, and added a shift builtin :-) Added $*, but because I'm not ignoring things like * ' & " yet, I had to make it $@ to go. I'll fix it later. To do: fix var.c to use a linked list & have arbitrary-sized values. Fixed EVinit to accept arbitrary-sized env names, and fixed prints to use a 1024-byte buffer, although this should be malloc'd or realloc'd. This fixed the vi bug somehow. Version24: I'm trying to get meta to understand single and double quotes. I've rearranged meta a bit. We now have: meta_1 forms words, or quoted charaters, and parses ! savehist here meta_2 parses $ and ~ meta_3 parses * ? and [] Meta_2 should strip away double quotes, and parse $ and ~ in double quotes. Stripping single quotes I've left for the command parser. I'd still prefer a parser that works on the carray and not a string, sigh. Also, to do eventually, make _everything_ modular i.e defines in header.h for CLE or not, history or not, as well as script, job control etc. Make these dependent on the machine defined, and thus only define one thing on a compile line. Done, and seems to work quite well. New bug: !! doesn't give last line, but line before that. Fixed, although saw a `random' infinite loop expanding !!, don't know why. Also, % fred='*.c' doesn't work. Hmm, perhaps treating quote pairs as words is wrong, e.g echo hello'$'$cat"q*" really has only two words, not five as it is at the moment. Version25: Meta_1 now breaks the line into wordlets, where a wordlet may end in a space, or be enclosed in "" or '', and later ``. To ensure spaces are preserved, the carray mode is now a bitfield, with the bit C_SPACE indicating if there's a space. So echo fred cat'jim'dog is the list: echo C_SPACE fred C_SPACE cat 'jim' dog I had to change most of meta to use C_SPACE, and expline to expand when it saw C_SPACE, but now I can get meta_2 & meta_3 to properly parse the carray. It seems to work quite well, surprisingly. Also sat down and drew the routine connectivity on a file-by-file basis, found a few routines I don't use yet. Changed main() so that lines starting with # are ignored totally, much better. Clam appears to expand `` before *, so I must do that too. ToDo: When replacing a word by its meta expansion, make sure the last part of the expansion has the old C_SPACE bit, and all the other words in the expansion have C_SPACE on. Other ideas: (I should start a separate list) Make list of things in sh, csh, tcsh & ksh worth adding Shell debugger - extra builtins like step & debug Add aliases & the prompt variable Ifdefing - CLE, ALIAS, SCRIPT, HIST Add a dumb CLE for file reading Proper binding: bind string string Tidy up code, esp. comlined & job Remove static limits on vars & add dimensionality Add other sh $ things Change header so only specify machine type on compile line $precmd, maybe? Just cut out and added Callum's prprompt() to main.c, and it works! I just can't do prompt='string', because '' fails for some reason. Version26: I've just added proper key binding, i.e bind string string, and it's recursive to boot, and there's a 512-char limit on expansion, and it appears to work at least for normal strings. I can't seem to bind ^[[D to ^[b ??? A bug in getcomcmd(), now fixed, and binding truly works!! I took v25 home and compiled it under 16-bit & 32-bit Minix, a few slight changes as the ACK compiler is picky. Code size is 26K under ACK, 40K under bcc. Time to tidy up the code before adding more stuff. Made builtin much more elegant, still works. Job control is playing up, must investigate. Clex is pretty compact, but needs more comments. Comlined really needs attacking. I've done some reformatting in getuline(), but I should try & unduplicate code. Took feature_off out of getuline(), no problems. Reduced insert(), overwrite() and show() down to one function, Show(). Also made goend() a part of Show, missed the go() at the end & initially didn't work. I wonder if it would be possible to use only one curs[]? Yep, seems to work :-) Moved code to pyramid, problems with direct, not dirent & also strtok etc. Fixed in header.h, also changed Makefile & header.h so only have to specify machine in Makefile. Merged delprevword & backword, also delnext & forword, now to try & add the yank stuff into that. Done that too. Wonder if I can remove yankbuf as f'n arguments. Yep, sure can, had to do it in clex too. Also am now using a variable $wordterm, or a default string, to find the end of words e.g ^w, ^[b etc. Time to save all these changes. Version27: Tidied up header.h a bit. We might need USES_DIRECT for direct/dirent stuff. Have added this. Also `ported' back to pyramid, both ucb and att, and finally fixed up the termcap stuff, and now works with no defines under both universes. Added some comments to clex. I won't touch exec or parse yet as they both need a lot of work done on them. Finally removed the last bit of global, now in builtin.c. Tidied term and signal up, replaced prints with the Clam 1.4.3 version with VARARGS & STDARG & modified header.h to reflect this. Tidied main up a bit too. Took the current version home & tidied up hist & job, and made the varlist a linked list. Time to lint it, this ought to be fun! I ignored all the pass 2 & 3 stuff, impossible to fix. A problem with bool as an enum, because I use it so often with ints. I may convert all to ints. Hmm, job control is still playing up, I don't know why. Version28: I radically changed meta_1 over the weekend to produce a carray list of wordlets, with parsing of special symbols like ; | || && >> n> etc. These are stored in the carray with name==NULL & mode holding a bit pattern indicating the symbol stored. Of course I'm exit()ing way before I get to the parser at the moment. meta_2 copes with the symbols now! Even meta_3 appears to work with this, now all I have to do now is rewrite the parser, sigh :-S. Done, at least a provisional one. Gettoken just returns a token or a word, but should strcat non-C_SPACE'd word together where necessary. I think I fixed the job problem, don't set current job in every addjob(). Expline has to be fixed to fill in the symbols known. Done, but even better would be to save the history as a LL, and would speed expanding ! in meta_1. Yes, but still have to expand line when doing ^P then. I'll leave it for now. Put history expansion back into meta_1 with no problems. Time to do file input. I created routines fileopen(), getfileline() and source() in file.c. getfileline() does a stdio-like buffering, using the yankbuf as a 512-byte buffer. Currently source() just prints out the lines it reads; I should extract the { getline(); do_meta(); command(); } loop and make it a separate routine, use a f'n ptr for getline(), and so avoid code duplication. Ok, made the call to getuline() in main() as a f'n ptr. Moved the loop code to doline(), which now returns false when no input left, tidied things up, and now have a rudimentary source!! Looks like a new version time. I still have to work out what to do with =. Probably I'll treat it simply as just an end of word char, and force asg() to be called when lastchar(argv[0])=='=', how does that sound??? Version29: I'm compiling Callum's alias.c, modified to use the new getfileline(). I'm just getting a .o file at the moment, I haven't done the builtins yet. I should modify redirect() to take a structure of 10 `things' which tell it how/what to open for each fd 0-10, and to dup2 each fd to fd+10, returning the same sort of structure for the dup2'd fds. Thus I could have a for loop to do all the work. Another ToDo: save the tty state at startup, and before we get a userline restore to that state, so processes leaving us in nl state won't affect us. Would like to still allow stty speed changes etc. Ok, alias compiles, added the alias() & unalias() builtins, -e is cut at the moment, everything appears to work but alias -l. Fixed, I forgot an argument. Of course I now need a getaliasline() for (*getline)() to point to, and then I could have aliases working. I bet it won't be as simple. Wrote a getaliasline(), munged up a runalias() which ignores argv & envp. It sort of works, but for some reason the shell goes away after the alias is run. Also does it with source(), grrr. Fixed, sort of, main() now loops indefinitely instead of checking doline()s return value. Must fix doline() by moving setcbreak, prprompt etc to comlined. Done. More ToDo stuff, I should make a separate wishlist file: tilde [-l] show user-defined/all ~ directories tilde short dir make dir accessible as ~short untilde short remove short from list Have a MODE key in CLE, and an UNMODE key too. Mark some binds as `mode only' via bind -m This will allow vi thru bindings Also need a BEEP key, to bind useless keys to BEEP Version30: Had to change main to close only fds 4-19, to allow getfileline() to work. Should keep a list of pipe fds to close, rather than closing all. Source now copes with my .clamrc, except commented lines, and dollar() hates PATH= "~# $HOME/.bin", for some reason. Also, I can't use my aliases until a) I make Argv point to the args, and b) I fix dollar to use $*. Oh, also, dir= fails with can't assign error, sigh. Also, .. doesn't work in CLE. Ok, setup() now sources .klamrc :-) Ok, commented lines fixed! Fixed the dir= problem. Also need to return flag from getxline() to indicate if to save in history. Dollar now uses $*, hooray. Hmm, runalias() now sets Argc=argc; Argv=argv; but Argv seems to not point correctly. Probably as doline is using linebuf twice??? Yup, that was the problem, doline() now mallocs() linebuf. Should really remove as many static structs as possible. Oops, dollar() wasn't checking Argc when expanding the args, now fixed. This means all my aliases should work!!! I think the shell's now nearly useable :-) Some more ideas for the melting pot: In command() or invoke(), dup2(i,10+i) for i=0 to 2, and dup2() back after the invocation. This means all err mesgs will have to go to 11 or 12. Also, keep a list of open'd fds in invoke() so we don't close down any getfileline() fds. Filename completion is playing up, with .. & absolute paths, grr. I added dupup() and dupdown() as per above, but it's not working yet. Callum & I are working on merging effort on Clam, hooray! Ho ho, fixed the bug just mentioned, we can now n> as well as | and < :-) :-) Time to save as v30b. Have nearly added a mode-bit for vi bindings, but I thing my dupup() stuff has buggered up source, so I can't automatically test it. Hah, was dupup()ing more than once, now a flag to stop this, and source works. So does my rudimentary vibinds, but how to bind to a >127 char from a source. I may modify Bind() to accept \octalnum as a char. Done, and now vi bindings works! It's extremely cute, in my opinion! I think I'll save this as v30, freeze, and work an updated manual for Callum to read :-) And expand the vi bindings. Version31: I just mangled the Clam manual to reflect v30's status, lots commented out, mainly builtins, clam's flags (-x etc.) and the ~# directory. I am compiling the code under Minix on minnie to see if I've introduced any nasties, too. getline conflicts with getline in getpwent, so I should rename it. Some incompat ptrs still in prints.c lines 100, 105, 118 (va_arg) - must fix. Currently, v30 compiles on the 3/50 (-gx, stripped) as: text data bss dec hex 40960 8192 11296 60448 ec20 Have taken v30 home to Minix. Bug in find(), must NULL name & var once malloc'ing a var struct, Minix's malloc doesn't memset(0). Fixed. Also weird bug sourc'ing & binding together; tracked down to not freeing linebuf in doline(). Now vi bindings work. Strange bug with ^A on first line, fixed, bad prprompt() placement in getuline(). Nameclash under ACK Minix with getline, now getaline. Shell size is (ACK): text data bss stack memory 31744 4652 13490 47394 97280 I've fixed some of the small bugs in Buglist, a few others will have to wait until I get back to dbx. Others still need major work to fix. Back at work, file.c now has a stack of buffers :-) Hmm. .. & / now seem to work again, sigh. But job control has died, grr. Weird, I can bg then fg, but not run /bin/ls & and then fg, the latter gives a setpgrp error. Why? SH*T, it works on the Pyramid, but not the Sun, (&@^^!@&^*&$@! At least SIGTTIN works on the Pyr. Just got an Ultrix account, slight change to header.h to get it to compile & run straight off. And the fg error is missing, and it has SIGTTIN. Mega-mail from Callum, still no good idea about fg. Fixed the .. and / COMPLETE bugs, a wonder they every worked. Also fixed % ^D to show all commands, takes a long time. Rang Callum, problems when TERMCAP=/file. Also, QUOTE must read() not getcomcmd(), and an MSB char for mprint. Fixed. Version32: Callum suggested we buffer all the writes etc in CLE and flush just before getcomcmd. Sounds like a good idea. Done, wasn't too hard. Things to do: mputc should handle the ^ & MSB stuff, instead of it being everywhere. Repeated calls to forward etc. should be fixed. CLE now groks both sets of ctrl chars, and groks MSB when printing, hooray. Added the (un)tilde builtins, but haven't connected them up with meta or clex yet. tilde() now expands these new shorthands. So does clex :-) Clex now expands ~# too, but not meta as yet. Tilde -l also added. Added support to save stty state, only occurs if var KEEPSTTY is defined. It works, I can stty nl now, great. Added TAB expansion of $ and $var/, yummo. Callum noted that doing j as 1st command (when alias j jobs) causes alias child to dump core. Moved setcooked() into CLE for speed, and main does bzero now. Hmm, altered runalias so as not to fork if alias at end of pipeline, but this may be buggy. Modified job.c so joblist shows changed jobs from doline(), and addjob always sets the currentptr. Also, doline() now much faster sourcing .klamrc. Started to add in new job control, with NEWJOBCTRL defines. Doesn't work. I give up. Ideas: change addcarray to be addcarray(char *str, carray *prev, mode, bool malc), malc= to malloc, prev used by meta and is NULL for clex. Also, fix invoke to update the last exit status & add this to dollar. Ok, addcarray changed, and meta/clex both use ncand as the counter. Saving this version before huge hack on meta to use addcarray. Meta now uses addcarray, no worries. Just noticed, alias args have gone missing, because they are not forked & thus have to share the carray. Need to pass a bool to doline() to inform it that we are running an alias. Done. Also fixed some bugs in meta, now uses wordlist not carray. Thus, each pass thru doline uses its own section of carray, hooray. Hacked doline as above, but doesn't work yet. Aliases without forking nearly going, but closing pipes is the big problem at the moment. It works after putting back in a close() loop in doline, but this is a MUST DO: Only close those fds that the process doesn't use and command() hasn't used yet. Hell, I can even do cmd | alias > file, wow. Callum noticed % ls ^D or % ls > ^D doesn't give files in current dir. Fixed. Lint time again, I've done pass 1. And some of pass 2. clex now skips quote chars at beginning of yanked word. Version33: Idea: meta_1 should scan for $ signs too, EOS out the dollar sign and mark the word as C_DOLLAR. Thus dollar() would only ever get 1 var at a time. Also, break up "words .." and `words ..` (but not '') into separate words so they can be expanded more easily. This has been done, and it wasn't pleasant. But Callum convinced me to undo this, which I eventually have, sigh. Tidied up dollar(), much easier to read & faster. Gettoken now copes with non C_SPACE words, I can take that out of the Buglist. Started adding support for exitstatus ($?), it's in dollar & there's a global var. Seems to work, ls always returns 0, cat will return 1. Now must make all builtins return a value. Done. Added support for ;. Also added && and ||, yippee!!! Knocked up the start of ``, by opening a pipe, forking & redirecting child output to our input. Haven't done the conversion of chars to carray yet. Haha, done eventually by using getfileline to get the line, meta_1 to parse the line & insert into carray. Done. Had to mod meta_1 so as to malloc as needed. Phew! Backquotes done! Can meta_3 use addcarray()? No, because qsort stuffs up the linked list of course. Fixed doline() to loop until getline dies, thus we don't free/malloc continuously. Working on expline. Sent callum v33b to keep him quiet. Expline now seems to work properly. It nearly works under Minix too, no hangs yet. Backquotes work under Minix. Added exec & exit builtins. Version34: Just noticed, clam does: % fred= '*.c' ; echo $fred *.c where sh does: $ fred= '*.c' ; echo $fred fred.c malloc.c Seems like $ is expanded before * - must change meta order. No, shell does this properly, I didn't realise :-) Dollar() now expands var[num] properly! Excitement++. Oh, but asg() only uses argv[1]. Fixed. Now pushd and popd work, great! Even better, [num] can be any int value, not just a single digit :-) BUG: The whole line is expanded, instead of pipeline by pipeline. This affects pushd -> dir=$cwd $dir ; echo $dir ; cd $1 because the echo wants the new value of dir. This is tricky because we need to savehist() a whole line, but only expand it pipeline by pipeline. Possible solution? Have in doline(): meta_1() savehist() while (get a pipeline from the carray) { meta_2,3,4() command() } Seems reasonable to me. Profiling. the close()s in doline() chew up the startup time, I've removed them, but we have to be careful to close all opened fds, esp. pipes. Strcmp() seems to be called a lot, prob in meta, we need to fix it. Oh, and make prints ONLY write() when it hits a \n or gets a full buffer (sprints excepted). shell takes 1.25 sec to start up (3/50) vs. 4.2 for clam 1.4. To Do: Once more go thru and clean up code, especially hist, alias and job, oh and meta esp. Bug, TAB doesn't complete aliases & builtins. Callum is here :-). Took settou() out of job.c, we now have to stty tostop manually if we want it. BUG, now backgnd aliases can't be stopped, but backgnd normal commands can. Working on the pipeline bug, need to move the && and || code out to doline for it to work. Done, it appears to work. Many moons later ... just about to indent, but ran it thru gcc -Wall, and found a few more problems. Indent introduced some bad bugs which I am still finding, ^H wasn't working because of this. Lawrie Brown is having trouble on his A/UX Mac with his .klamrc, but it works on the Sun, the SPARC and the Pyramid. Altering job control so it can be used under SysV. Ruly truly! What I mean is, we can show the list of processes, but we can't bg or fg them of course. Hmm, it works :-) at least on the Pyramid. Added kill builtin. 8-) Oh frabjous day! Have got POSIX job control (nearly) working! The same as Berkeley, but in fg() must move first the terminal then the shell to the stopped jobs process group. Now just a small race condition in waitfor(), which MUST be fixed! Code now passes gcc -Wall. Found the `race condition', signal.c wasn't setting SIGCHLD->checkjobs() as the #ifdef was only checking JOB, and not POSIXJOB too. Phew! Version35: Back at work, now not using pause(), as there was a race condition between the testing of the current ptr's status, and the pause() :-S. It all seems to work, except for using aliases in pipes under SysV, which I must check. Fixed, a bug in SyS V's waitfor(). In fact, I've merged the waitfors together. Wonderful. Big bug in alias loop detection, which has an exit(1) for now. Speaking of aliases, the & is not being propogated down. Perhaps this is a good enough reason to fork when doing aliases. If the user wants the alias to run as a background job, we should fork. Done. Hmm, fg of pipelines doens't yet work. Currently, shell has these sizes: text data bss 40960 8192 12704 Sun 3/50, gcc -O 49152 8192 12744 Sun3/50, cc, not optimised 73728 8192 29192 Sun SLC, cc, not optimised 75776 10240 51232 Pyr 9810, cc, not optimised 84380 10892 33196 A/UX, cc, not optimised 139264 20480 30400 Ultrix, cc -O Worked on the ^P ^N bug at home under bcc, nearly fixed it. Fixed! I MUST rewrite the CLE stuff from scratch, it's too warty. Removed struct rusage from job.c as NULL works just as well, and allows it to compile on the Apple. Callum found a minor bug, can't ^C a fg'd job, fixed. Also added RUNFG and RUNBG to job.c to distinguish them. 2/92 Down in Deakin! I'm working on getting the term.c to correctly set/reset stty parameters during cbreak/cooked. I think I have fixed it :-) Need to rewrite the UCB stuff to use the POSIX ioctl stuff. Sigh! I think I need to define a new environment; as well as ATT UCB MINIX COHERENT we need POSIX :-S I have fixed redirect() to push only those fds dup'd, and to have a stack structure for the dups. After a bit of work it seems to be working, including error checking. Created a Malloc(size,mesg) that exit(1)s with the mesg if NULL. Should try and rationalise the malloc usage. Added a umask builtin instead of using a silly variable. Works. Fixed recursive aliases, I think. At least alias mush mush -S -C now works. Yes, even alias ls 'cd / ; ls -l' works too :-) Time to move to version 36. Version36: Trying to fix meta.c :-) Especially to fix quotes and dollar parsing in meta_1(), but dollar stuff is amazingly hard. Need a meta_cat() function which concatenates non C_SPACE'd things after meta_2 and meta_3. I should also add stuff into dollar() to check for []* because these are not caught by meta_1 - too hard there. Hmm, dollar working, but weird things now happening with arguments to aliases and normal processes?! Fixed, I think. Well, I've just removed meta_3 and _4, and now there is only the loop in meta_2, but I now call new routines star() and backquot() which look very similar to _3 and _4 :-), plus I added a joinup routine to concatenated non C_SPACE'd words. Seems to work. Changed all internal Clam vars except cwd and prompt to start with 1 uppercase letter, rest lowercase. Whee, I changed SUN to SUNOS3, and created SUNOS4, and now use the latter which defines POSIX (and not UCB), and use tc[g,s]etattr() in term.c too!!! Term.c now has 3 sets of cooked/cbreak routines, for ATT, POSIX and UCB/other. It looks much neater! I compiled it under Pyr OSx and PC Minix 1.5, and found a few errors; under PC MINIX, size is now 36160 text, 5918 data and 12590 bss. Today I rewrote meta_1, and fixed expline, and they now WORK!!!! Bugs now in the new meta_2, which I must fix. Added support for A/UX, which is nearly POSIX, hee hee! But, I must check up on wait3() and the wait structure for POSIX job control, seems A/UX when pedantic, doesn't cope with union wait. Backquotes currently don't work as yet, they depend too heavily on the old meta_4, but I'll fix them soon. Added 'unbind all' - couldn't help myself. POSIX uses waitpid() which is like wait3, I modified it & compiles under SunOS, now to try A/UX. A few minor things, but it does run, doesn't source the .klamrc properly yet. Version37: This version is to POSIXify the shell, and catch system call bugs & lint errors. The next version will be to remove semantic & programming bugs. Hooray, the A/UX box now has dbx, I might be able to debug it there :-) Took the code home again to my Minix box, and used all the compilers I had there to find/remove bugs. The betatest Ansi compiler is the most stringent, and it forced me to create prototypes for all the library routines that I use, as well as coerce uchars to chars in comlined. However, the code compiles without complaint with all 3 compilers, all 3 executables run(!) and the output sizes follow (under 8088 PC Minix 1.5): Compiler Text Data Bss ------------------------------------- Ansi cc -O 36224 6252 12588 ACK cc -O 36624 6250 12594 bcc -O 47520 4968 12660 Well, added the Minix proto patches, and it still compiles & runs with cc under SUNOS3, SUNOS4, BSDPYR, ATTPYR, AUX, and compiles under Ultrix (I can't run it as I can't rlogin or telnet to csdec1). Now using gcc and SUNOS4, the prototypes are picking up lots of parameter mismatches! Fixed them all, except qsort() [oh and the impossible prints() ones]. It still runs. Found the big `source .klamrc' error under AUX - its strpbrk() doesn't return NULL when you give it an empty string, sigh! I should work on the next big bug, we don't seem to be waitfor()ing all of our alias children e.g alias q '/bin/ls c* ; /bin/ls -l a*', sometimes the a* output comes first. Yes, prints()s show we are only waiting for the 1st command in a multicommand alias - I must fix it. I think I have! Giving the code to gcc - Wall now to catch the little things. Walls under SUNOS4 ok. Walls under SUNOS3 ok. Linted under BSDPYR, and nothing more than the usual useless lint errors. Linted under SUNOS3 & SUNOS4 too. Currently, sizes are (using -O): text data bss SUNOS4 40960 8192 11608 (Sun 3/50) SUNOS4 49152 8192 11896 (SPARC, Sun 4c) AUX 76432 10964 32044 (68030 Mac) BSDPYR 83968 12288 49980 (Pyr 9810) Version38: Sent the src to Callum who found lots of meta bugs. We've decided to discard double quote, and backquotes look like single quotes. Done. I've also added a C_CURLY for future use. This makes backquotes work again - that was simple! Also fixed a bug with dollar(), and added back in the var[] code that I'd stupidly removed a while ago. Defined my own wait macros for BSD and SysV use, which allows me to remove several nasty ifdef'd code fragments in job.c I hope they work ok. They seem to. Went thru all the src and made static over 40 functions! Removed useless prototypes in the .c files. Also added $ignoreeof and support for .login/.logout, and now my default Minix shell is Clam 2.0 :-) I found that my recent waitfor rewrite stuffed bg() and fg() which has now been fixed. Just about to work heavily on bg'd aliases, and job control for V7 using ptrace. I have pushed all files to 38.5 and delta'd there so I can restore the source before the mangling. Well, bg'd aliases are now working - at least they are under SUNOS4. Fails under BSDPYR and SUNOS3. Got it going under SUNOS3. ** Hooray ** it also works under BSDPYR as well!!! Great. Now onto V7 Job Control :-) $$$$>>> Version 7 Job Control works!!! Amazing! I mean, even fg and bg! I had to overload ^\ to mean ^Z, so you can't core dump immediately, but it all works. Terrific!!!! Read the source code for more details. I have now got V7JOB, UCBJOB and POSIXJOB defines. job.c code is so heavily #ifdef'd it's not funny. Time to test everywhere. Job control works under SUNOS3, GENBSD (Ultrix), SUNOS4, BSDPYR Fixed a bug in meta viz. $$ which now works. Well, that's probably enough for Version 38, lots of mangling took place!!! Version39: I took the code home and got job control running on Minix :-) Amazingness! There were a few glitches which I think I fixed, and I'm still not too sure about how to properly fix the hanging while Minix Clam is sourcing a file, but I'll work on it. Wrote up some notes on V7JOB on the weekend and sent them off to Callum. Now recompiling the code here to make sure it still works. Still works under SUNOS4. Works under BSDPYR and SYSVPYR too. Time to send it to Callum for regression testing. Damn, found a nasty bug while streamlining rmjob. Took hours before I realised that rmjob was destroying the list I was trying to traverse in joblist. Fixed for good. Fg doesn't work under AUX, I'll have to investigate. Bug in dollar(), var[] fails if there isn't a space after the `]'. Callum wants to rewrite the meta stuff. I think it's ok now. Sigh. Fixed an overenthusiastic use of joinup(), now home$HOME works. Also added backslashes in quotes :-S Much later (i.e months), got 386BSD up & running; ported the shell to the system, which did involve a few changes. Found a bug involving $*, fixed. Callum pointed out a bug in the job control code. For some reason, I can't ^Z a % sleep 100, nor can I ^C a % sleep 100 & ; fg. Can't seem to work out why either. 27/7/93 Back again after nearly a year. Got sick of the ifdefs in header.h and job.h, so plit header.h into several machine files, and split job.c into three job-dependent files. The only problem is of consistency now. Still compiles under J386BSD, SUNOS4, BSDPYR, SYSVPYR, AUX and GENBSD (Ultrix). Things I want to do: + Remove the existing alias code and just expand aliases in meta.c + Rewrite comlined.c (of course) + Write val.c, where a val is a variable with value, and then rewrite alias.c, tilde, history, vars to use this. Time to freeze to version 40 before I mangle val.c Version40: Ok, cut out the alias executing code from exec.c/main.c. Have written but not tested the val.c code. Now to rewrite the alias.c code. Done, also rewritten the var.c code and it appears to work. Altered tilde as well :-) That only leaves hist and bind! Done hist.c, wc *.c now 10K smaller. Perhaps I could work in the linked list used in job.c as well? Moved fg(), bg() back into job.c and left small xxstuff() f'ns in xxjob.c. Hmm, just checked, job control appears to work again under all three types. Made var.c a bit more rational. We now have set/unset, export/unexport and setenv. No = any more. Hmm, source seems to work again ?! Must find and fix the fg bug, when no job# is given. ?! seems to work under sunos4. Decided to just make the shell an interactive one (no scripts), and have dubbed it Wish: Warren's Interactive Shell. Now main invokes ~/.wishrc and ~/.wishlogin. Time for some regression testing. I'll leave the job control linked list stuff as is for the moment, and maybe work on comlined as a separate program until it is finished. Got Minix running again at home, Wish compiled with only a few changes. v7 job control works (or so it seems). There is a bug in job control current_job which I must look at. Fixed some small clex/val bugs. Tidied up the defines and added version numbers for each OS. Wrote a small program to find what vars/functions should be made static; made several things static. Added a make proto to make proto.h, much nicer. Used gcc -Wall to remove some unused vars as well. Pulled the output buffering stuff from comlined.c into clebuf.c. Maybe comlined isn't too bad after all. If I could document and/or remove copyback(), I'd feel a lot better. Damn, put aliases back in so I can use it as a real shell and find more bugs that way. Fixed a bug in alias execution. Version 41 (October 1996): This version isn't really documented very well. I think I moved the code from SCCS to RCS after porting it back to FreeBSD 1 and Minix 1.7, so the code shouldn't be radically different from the last version 40. From now on, I will put `closed on [date]' on the version number in this file. Added lots of ifdefs to turn off functionality; this might help for when we do regression testing. Now I need a proper `ifdef' remover program :-)