From owner-freebsd-bugs Tue Nov 6 9:20: 9 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id F18D537B418 for ; Tue, 6 Nov 2001 09:20:01 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.4/8.11.4) id fA6HK1O58624; Tue, 6 Nov 2001 09:20:01 -0800 (PST) (envelope-from gnats) Date: Tue, 6 Nov 2001 09:20:01 -0800 (PST) Message-Id: <200111061720.fA6HK1O58624@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Thomas Quinot Subject: Re: bin/31627 sh(1) is broken - loss of data! Reply-To: Thomas Quinot Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR bin/31627; it has been noted by GNATS. 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! Date: Tue, 6 Nov 2001 18:18:34 +0100 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-bugs" in the body of the message