From mboxrd@z Thu Jan 1 00:00:00 1970 From: dds@aueb.gr (Diomidis Spinellis) Date: Thu, 14 Jul 2016 17:38:38 +0300 Subject: [TUHS] Shell control through external commands In-Reply-To: <20160714141112.M89671@kw.igs.net> References: <4fcf31ef-50af-10b5-0c34-ad647ed10a4e@aueb.gr> <20160714141112.M89671@kw.igs.net> Message-ID: On 14/07/2016 17:11, schoedel at kw.igs.net wrote: > On Thu, 14 Jul 2016 16:18:43 +0300, Diomidis Spinellis wrote >> I remember hearing that originally the Unix shell had control structures >> (e.g. if, while, case) implemented through external commands. However, >> I can't see this reflected in the source code. The 7th Edition >> Bourne shell has these commands built-in (usr/src/cmd/sh/cmd.c), while >> the 6th Edition (usr/source/s2/sh.c) seems to lack them completely. > > http://www.tuhs.org/cgi-bin/utree.pl?file=V6/usr/source/s1/if.c > http://www.tuhs.org/cgi-bin/utree.pl?file=V6/usr/source/s1/goto.c Thank you! So: - if(1) gets as arguments an expression to evaluate and the command to execute if the expression is true, and - goto(1) changes the seek offset of the shared standard input file descriptor to match the label's position in the file. This is a much simpler implementation that what I thought would be the case, but, true to the spirit of Unix, remarkably effective.