Bournegol???

greyface-1 pts0 comments

Marc Lehmann's "Bournegol Page"

Last change: 2014-12-30

Bournegol???

While browsing, I found this except from the book Unix Power Tools:

... To fix it, first get the source, and then change it in the obvious three places in xec.c. You will have to learn Bournegol [the ALGOL-like dialect of C that Steve Bourne used to<br>write the original Bourne shell-JP ]. Another alternative is to replace /bin/sh with one of the free sh look-alikes... (CT in comp.unix.questions on Usenet, 20 February 1990)

I immediately asked myself: what could Bournegol look like? Well,<br>it's not that easy to find the original Bourne<br>Shell sourcecode, so,<br>after some googling, I thought I might put an example of Bournegol on<br>my homepage, so other people have the chance to find about "Bournegol"<br>without the tedious search.

(many years later I found this<br>paper, A Partial Tour Through<br>the UNIX Shell, which makes for very nice reading).

Ok, without any further ado, here is an excerpt of the file<br>xec.c, referenced above, supposedly from the 7th Edition UNIX, that gives you an<br>impression of bournegol:

LOCAL INT parent;

SYSTAB commands;

/* ======== command execution ========*/

execute(argt, execflg, pf1, pf2)<br>TREPTR argt;<br>INT *pf1, *pf2;<br>/* `stakbot' is preserved by this routine */<br>REG TREPTR t;<br>STKPTR sav=savstak();

sigchk();

IF (t=argt) ANDF execbrk==0<br>THEN REG INT treeflgs;<br>INT oldexit, type;<br>REG STRING *com;

treeflgs = t->tretyp; type = treeflgs&COMMSK;<br>oldexit=exitval; exitval=0;

SWITCH type IN

case TCOM:<br>BEGIN<br>STRING a1;<br>INT argn, internal;<br>ARGPTR schain=gchain;<br>IOPTR io=t->treio;<br>gchain=0;<br>argn = getarg(t);<br>com=scan(argn);<br>a1=com[1]; gchain=schain;

IF (internal=syslook(com[0],commands)) ORF argn==0<br>THEN setlist(t->comset, 0);<br>FI

IF argn ANDF (flags&noexec)==0<br>THEN /* print command if execpr */<br>IF flags&execpr<br>THEN argn=0; prs(execpmsg);<br>WHILE com[argn]!=ENDARGS<br>DO prs(com[argn++]); blank() OD<br>newline();<br>FI

SWITCH internal IN

case SYSDOT:<br>IF a1<br>THEN REG INT f;

IF (f=pathopen(getpath(a1), a1))<br>[...]

case SYSTRAP:<br>IF a1<br>THEN BOOL clear;<br>IF (clear=digit(*a1))==0<br>THEN ++com;<br>FI<br>WHILE *++com<br>DO INT i;<br>IF (i=stoi(*com))>=MAXTRAP ORF i<br>[...]

case TFORK:<br>IF execflg ANDF (treeflgs&(FAMP|FPOU))==0<br>THEN parent=0;<br>ELSE WHILE (parent=fork()) == -1<br>DO sigchk(); alarm(10); pause() OD<br>FI

IF parent<br>THEN /* This is the parent branch of fork; */<br>/* it may or may not wait for the child. */<br>IF treeflgs&FPRS ANDF flags&ttyflg<br>THEN prn(parent); newline();<br>FI<br>IF treeflgs&FPCL THEN closepipe(pf1) FI<br>IF (treeflgs&(FAMP|FPOU))==0<br>THEN await(parent);<br>ELIF (treeflgs&FAMP)==0<br>THEN post(parent);<br>ELSE assnum(&pcsadr, parent);<br>FI

chktrap();<br>break;

[...]

(Note the single use of curly braces after case SYSTIMES. This<br>and the lowercase case let me believe this segment might have been<br>added at a later stage). The necesssary macro definitions to understand (if<br>you dare to try) the above excerpt can be found in the file mac.h:

/*<br>* UNIX shell<br>* S. R. Bourne<br>* Bell Telephone Laboratories<br>*/

#define LOCAL static<br>#define PROC extern<br>#define TYPE typedef<br>#define STRUCT TYPE struct<br>#define UNION TYPE union<br>#define REG register

#define IF if(<br>#define THEN ){<br>#define ELSE } else {<br>#define ELIF } else if (<br>#define FI ;}

#define BEGIN {<br>#define END }<br>#define SWITCH switch(<br>#define IN ){<br>#define ENDSW }<br>#define FOR for(<br>#define WHILE while(<br>#define DO ){<br>#define OD ;}<br>#define REP do_lbr<br>#define PER }while(<br>#define DONE );<br>#define LOOP for(;;){<br>#define POOL }

#define SKIP ;<br>#define DIV /<br>#define REM %<br>#define NEQ ^<br>#define ANDF &&<br>#define ORF ||

#define TRUE (-1)<br>#define FALSE 0<br>#define LOBYTE 0377<br>#define STRIP 0177<br>#define QUOTE 0200

#define EOF 0<br>#define NL '\n'<br>#define SP ' '<br>#define LQ '`'<br>#define RQ '\''<br>#define MINUS '-'<br>#define COLON ':'

#define MAX(a,b) ((a)>(b)?(a):(b))

Hope you found this interesting ;)

Any questions/hints/critics? Contact the author of this page!

define parent bournegol treeflgs argn while

Related Articles