Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!pacbell.com!att!ucbvax!ENG.SUN.COM!wmb From: wmb@ENG.SUN.COM Newsgroups: comp.lang.forth Subject: Re: fsh Message-ID: <9104121340.AA17242@ucbvax.Berkeley.EDU> Date: 11 Apr 91 15:34:59 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: wmb%ENG.SUN.COM@SCFVM.GSFC.NASA.GOV Organization: The Internet Lines: 59 > Are there any Unix shells that are forth based? Is there some really > obvious reason why this would be [impractical|silly|stupid]? Would anyone > be interested? I would think it would be interesting to do, and might > be faster than the typical "script" approach to developing unix tools.... This idea comes up from time to time. As far as I know, nobody has taken a serious stab at implementing it. I have made some steps in that direction, as I will describe later, but first let me list some reasons why it may not be the best thing to do: 1) The Unix shells are basically programming languages whose primitive data types are strings and patterns. Forth doesn't exactly excel in its string-handling capabilities. Another thing that "standard" Forth doesn't have is dynamic memory allocation, which is pretty necessary for a lot of the things that shells do (e.g. argument wildcard expansion). 2) The existing Unix shells are pretty adequate for the jobs that most people want to do with them. Sometimes the "quoting" in scripts gets a bit hairy, but by and large people can get the job done. 3) The value of many shell scripts is strongly related to the number of people who can or will use it. "fsh" scripts would have a pretty limited audience, since the job of propagating a new language to a wide audience is very very difficult (Proof: literally thousands of programming languages have been invented and implemented, but only a handful have more that 100 users, and the number of languages that are truly widespread is small indeed). 4) It would take many many hours of work to bring the functionality of an "fsh" up to the level of ksh or the latest version of csh. What would be the payoff? Here's what I have done already (and I doubt that I will do much more along these lines): a) You can execute Unix shell commands from within Forth. The most popular commands can be execute directly, simply by typing their names. Other commands must be preceded by "sh ". I once had a mode whereby any unrecognized word was sent to a subshell for execution, but I decided that I didn't like that behavior and turned it off. b) My Forth system has a line editor with interactive history and command completion. This can be used for shell commands too. Before ksh came out, I used to use Forth as a front end to csh just so I could have the editing functions, but now that we have ksh, I just use it directly. c) On non-Unix machines, I do use Forth as a shell. The Atari ST and the Macintosh do not come with a standard shell program, so I use Forth as a shell when I don't want to use their graphical user interface. The standard OS-9 shell is pretty wimpy (the line editing functions are weak), so I use Forth as an editing front end for it. Mitch Bradley, wmb@Eng.Sun.COM