From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 7 02:22:25 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DF5DA1065676 for ; Mon, 7 Apr 2008 02:22:25 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 615228FC24 for ; Mon, 7 Apr 2008 02:22:24 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (adsl58-200.kln.forthnet.gr [77.49.185.200]) (authenticated bits=128) by igloo.linux.gr (8.14.2/8.14.2/Debian-3) with ESMTP id m372M37Y028785 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 7 Apr 2008 05:22:10 +0300 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m372M1AH001577; Mon, 7 Apr 2008 05:22:01 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m372Lu81001563; Mon, 7 Apr 2008 05:21:56 +0300 (EEST) (envelope-from keramida@ceid.upatras.gr) From: Giorgos Keramidas To: Julian Elischer References: <47F8C1B3.4030902@unitix.org> <47F913AE.3040604@elischer.org> Date: Mon, 07 Apr 2008 05:21:55 +0300 In-Reply-To: <47F913AE.3040604@elischer.org> (Julian Elischer's message of "Sun, 06 Apr 2008 11:17:18 -0700") Message-ID: <87ve2ujtfg.fsf@kobe.laptop> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-MailScanner-ID: m372M37Y028785 X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.23, required 5, ALL_TRUSTED -1.80, AWL -0.22, BAYES_00 -2.60, PLING_QUERY 1.39) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: freebsd-hackers@freebsd.org, dino Subject: Re: bug in /bin/sh?!? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Apr 2008 02:22:26 -0000 On Sun, 06 Apr 2008 11:17:18 -0700, Julian Elischer wrote: > dino wrote: >> Hello, >> >> on my FreeBSD 7.0-STABLE the line: >> >>> sh -c 'set -- ${HOME+A B C}; echo "1:$1"; echo "2:$2:"; echo "3:$3:"' >> >> prints >> >> 1:A B C: >> 2:: >> 3:: >> >> I would rather expect: >> >> 1:A: >> 2:B: >> 3:C: >> >> Is it correct that field splitting isn't performed on default/alternate >> expanded values? > > "A B C" is a single value tha thappens to contain spaces. > so, yes there is no splitting at that point. I think there *is* splitting. To inhibit splitting, you would have to use quotes, i.e. one of: set -- "${HOME+A B C}"; echo "1:$1"; echo "2:$2"; echo "3:$3" set -- ${HOME+"A B C"}; echo "1:$1"; echo "2:$2"; echo "3:$3" Splitting does occur in bash, mksh, pdksh and zsh in FreeBSD. The Solaris 10 version of /bin/sh shell does not accept the original at all (I used Solaris 10 Update 3, aka "Solaris 10 11/06 s10x_u3wos_10 X86", for the test): $ sh -c 'set -- ${HOME+A B C}; echo "1:$1"; echo "2:$2:"; echo "3:$3:"' sh: bad substitution $ but it does accept any of the quoted options. The /usr/bin/ksh shell on Solaris accepts the original, but it splits the result at whitespace.