From owner-freebsd-current Fri Jul 28 0: 3:57 2000 Delivered-To: freebsd-current@freebsd.org Received: from knight.cons.org (knight.cons.org [194.233.237.86]) by hub.freebsd.org (Postfix) with ESMTP id 5CDED37B551; Fri, 28 Jul 2000 00:03:52 -0700 (PDT) (envelope-from cracauer@knight.cons.org) Received: (from cracauer@localhost) by knight.cons.org (8.9.3/8.9.3) id JAA10612; Fri, 28 Jul 2000 09:03:50 +0200 (CEST) Date: Fri, 28 Jul 2000 09:03:49 +0200 From: Martin Cracauer To: Jun Kuriyama Cc: cracauer@FreeBSD.ORG, Current Subject: Re: /bin/sh dumps core with here-document of 8bit text Message-ID: <20000728090349.A9976@cons.org> References: <7mr98fq7b4.wl@waterblue.imgsrc.co.jp> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <7mr98fq7b4.wl@waterblue.imgsrc.co.jp>; from kuriyama@FreeBSD.ORG on Fri, Jul 28, 2000 at 12:09:51PM +0900 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In <7mr98fq7b4.wl@waterblue.imgsrc.co.jp>, Jun Kuriyama wrote: > #!/bin/sh > cat < [8bit text which contains 0x82 character] > EOF I'm very short of time these days, but here are thoughts and a backtrace: 0x82 == \202 == CTLVAR in the parser. For real variable expansion, the parser inserts \202 into the input string. Furthermore, it is an error that the forking shell doesn't detect that its forked counterpart dumped core. I see two solutions: 1) It seems that you can work around the coredump by looking at the next char after \202. For real expansions of variables in here-documents that is \201. Once can probably determine all possible legal combinations and ignore others. However, that would just prevent this coredump and would not support processing the CTL* chars as literal chars in here-documents, at the very least they will be eaten. 2) move the CTL* stuff from expand.h to values outside the char domain. Do do this, all input strings must be converted from char* to int* in the first steps of the parser, all buffers must hold int*, which means that they cannot be displayed to the terminal or presented as input to external programs without converting them back. Of course, I will do the latter :-) However, I'm in the middle of preparation for a job interview, so that is not possible right now. Anyone trying to fix this, especially going the first path, keep in mind that you must not break variable expansion in here-documents: foo=42 cat < http://www.cons.org/cracauer/ BSD User Group Hamburg, Germany http://www.bsdhh.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message