From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Re: [9fans] rc of Unix Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Kenji Arisawa To: 9fans@cse.psu.edu Content-Transfer-Encoding: 7bit In-Reply-To: Message-Id: <40F3FBFD-AF3F-11D7-85AC-000393A941BC@ar.aichi-u.ac.jp> Date: Sun, 6 Jul 2003 08:20:23 +0900 Topicbox-Message-UUID: ea0e02d6-eacb-11e9-9e20-41e7f4b1d025 Hello, I introduced builtin function "read" into Unix rc. bash$ diff builtins.c builtins.c.orig 30,34d29 < #define RC_READ 1 < #if RC_READ < static void b_read(char **); < #endif < 46,48d40 < #if RC_READ < { b_read, "read" }, < #endif 111,136d102 < < #if RC_READ < /* read that simulate Plan 9 read -- introduced by Kenar */ < static void b_read(char **av) { < char buf[1024]; < int i = 0; < if (*++av != NULL) { < set(FALSE); < return; < } < for(;;){ < if(i == sizeof(buf)){ < write(1, buf, i); < i = 0; < } < if(read(0, &buf[i++], 1) <= 0){ < i--; < break; < } < if(buf[i-1] == '\n') < break; < } < write(1, buf, i); < set(TRUE); < } < #endif where "builtins.c.orig" is of rc-1.7 I hope that does not introduce a bug ( not tested enough). Kenji Arisawa