From owner-freebsd-questions Wed Jan 5 10:26: 2 2000 Delivered-To: freebsd-questions@freebsd.org Received: from horst.bfd.com (horst.bfd.com [12.9.219.10]) by hub.freebsd.org (Postfix) with ESMTP id 6440D15446 for ; Wed, 5 Jan 2000 10:25:54 -0800 (PST) (envelope-from ejs@bfd.com) Received: from HARLIE.bfd.com (bastion.bfd.com [12.9.219.14]) by horst.bfd.com (8.9.3/8.9.3) with ESMTP id KAA01634; Wed, 5 Jan 2000 10:25:07 -0800 (PST) (envelope-from ejs@bfd.com) Date: Wed, 5 Jan 2000 10:25:07 -0800 (PST) From: "Eric J. Schwertfeger" To: Oliver Fromme Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Poss bug in /bin/sh? In-Reply-To: <200001051738.SAA36801@dorifer.heim3.tu-clausthal.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, 5 Jan 2000, Oliver Fromme wrote: > Eric J. Schwertfeger wrote in list.freebsd-questions: > > cat >> confdefs.h < > #define PTY_BSD_SCHEME_FIRST_CHARS "`ls /dev/pty* | cut -c 9-9 | uniq | tr -d '\n'`" > > EOF > > [...] > > running the same under bash produces the desired output. What's wrong > > here? Yes, this is part of the configure script, if it looks strange, > > though with my limited shell knowledge, I'd still expect it to work. > > >From the sh(1) manpage: > > If the delimiter as specified on the initial line is quoted, > then the here-doc-text is treated literally, otherwise the > text is subjected to parameter expansion, command > substitution, and arithmetic expansion (as described in the > section on `Expansions''). I understand this, and should have been more specific. I'd expect shell expansion in this case, and it obviously is expanding, given the output below. What I don't expect is output of #define PTY_BSD_SCHEME_FIRST_CHARS "" #define PTY_BSD_SCHEME_SECOND_CHARS "" So my question wasn't expanding vs not expanding, it was why isn't it expanding the way I'd expect it to, and why the error from sort. The output of the lines, when done on a seperate line is as expected. In fact, I can't reproduce this behavior anywhere except within here-doc-text. The following does work correctly, and I don't understand why there should be a difference, as it's doing the same substitution, but storing into an intermediate variable. first=`ls /dev/pty* | cut -c 9-9 | uniq | tr -d '\n'` cat >> confdefs.h < So /bin/sh works perfectly correct. Bash probably doesn't. Right. I didn't go into this assuming bash was correct and sh wasn't, only that bash was giving me the expected behavior and sh wasn't. The error could as easily (more easily, actually) be that the expected behavior is incorrect. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message