Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ll-xn!husc6!linus!encore!paradis From: paradis@encore.UUCP (Jim Paradis) Newsgroups: comp.os.minix Subject: More on sh/shar Message-ID: <1643@encore.UUCP> Date: Thu, 28-May-87 10:42:46 EDT Article-I.D.: encore.1643 Posted: Thu May 28 10:42:46 1987 Date-Received: Sat, 30-May-87 07:41:58 EDT Organization: Encore Computer Corp., Marlboro, MA Lines: 39 Remember my last message complaining about /bin/sh being unable to unpack "real" shell archives? Well, last night I got SO sick&tired of the situation that I took a deep breath and dove head-first into the code for /bin/sh. Getting it to compile was a feat unto itself... (seems the MINIX compiler handles globals and externs differently from the PC/IX compiler...). Side note: Why is it that command interpreter code is almost ALWAYS devoid of useful comments? I've had to swim around in System V sh, BSD4.2 csh and MINIX sh, and in all three cases the only useful comments in the code were those added after the fact by the local developers... Anyway, after dredging through the code, I found that my worst fears were indeed true: on "<<" input redirections, sh does indeed try to read the ENTIRE redirected input into memory. What's REALLY stupid is that when it actually goes to feed the redirected input into a command, it creates a temporary file and writes the data out to the file. Why not just dump the data into the temporary file in the first place and skip the memory-hogging? What's REALLY REALLY stupid is that after it creates the temp file, it doesn't bother to release the memory that was used to store the data!! Anyhow, I modified the shell so as to read the data in and dump it directly into a temporary file -- the only in-memory buffering is that of the line currently being read (limit of 512 chars). The damn thing actually worked the first time, too! Anyway, as soon as I'm done cleaning up the code a bit (making sure it releases all the memory it allocates, making sure it properly deletes the temporary file, etc). I'll post the changes for all to share. I'll also post the changes that were required for me to recompile the thing under MINIX... +----------------+ Jim Paradis linus--+ +--+-------------+ | Encore Computer Corp. necntc--| | | E N C O R E | | 257 Cedar Hill St. ihnp4--+-encore!paradis | +-------------+--+ Marlboro MA 01752 decvax--| +----------------+ (617) 460-0500 talcott--+ You don't honestly think ENCORE is responsible for this??!!