From owner-freebsd-stable Tue Nov 6 9:18:43 2001 Delivered-To: freebsd-stable@freebsd.org Received: from melchior.cuivre.fr.eu.org (melchior.enst.fr [137.194.161.6]) by hub.freebsd.org (Postfix) with ESMTP id A28DB37B405; Tue, 6 Nov 2001 09:18:38 -0800 (PST) Received: from melusine.cuivre.fr.eu.org (melusine.enst.fr [137.194.160.34]) by melchior.cuivre.fr.eu.org (Postfix) with ESMTP id 266A07EAF; Tue, 6 Nov 2001 18:18:36 +0100 (CET) Received: by melusine.cuivre.fr.eu.org (Postfix, from userid 1000) id A116624D0B; Tue, 6 Nov 2001 18:18:34 +0100 (CET) Date: Tue, 6 Nov 2001 18:18:34 +0100 From: Thomas Quinot To: Eugene Grosbein Cc: stable@freebsd.org, freebsd-gnats-submit@freebsd.org Subject: Re: bin/31627 sh(1) is broken - loss of data! Message-ID: <20011106181834.A23607@melusine.cuivre.fr.eu.org> Reply-To: thomas@cuivre.fr.eu.org References: <3BE8125B.E7DA340C@svzserv.kemerovo.su> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5i In-Reply-To: <3BE8125B.E7DA340C@svzserv.kemerovo.su>; from eugen@svzserv.kemerovo.su on Tue, Nov 06, 2001 at 11:39:55PM +0700 Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Le 2001-11-06, Eugene Grosbein écrivait : > #!/bin/sh > string=`printf "\21"` > echo $string | hd > Replace 21 with 201 and rerun. You see: > 00000000 0a |.| > 00000001 Can't reproduce here for the value \201, but for the other values you mention it looks like perfectly normal and expected behaviour from sh(1). It is not surprising at all that some characters "disappear" here: since $string appears unquoted, any character which is whitespace w.r.t. shell parsing rules won't be passed to echo. Try to quote your string: echo "$string" | hd In your other example, you use the 'read' builtin to get characters from jot, but read is /also/ defined to apply shell field splitting rules. A correct version of your test follows: #!/bin/sh -x for n in `jot 256 0` do c="`jot -c 1 $n`" echo "$c" | wc -c | grep -v 2 && echo "$n" done which correctly produces the following output: 1 0 1 10 because a shell variable cannot contain a null character (which is a string end marker), and backquote expansion is defined to remove trailing newlines. This is legal and expected behaviour, not a bug. Thomas. -- Thomas.Quinot@Cuivre.FR.EU.ORG To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message