bug in /bin/sh?!?
Dan Grillo
dan at grillo.net
Sun Apr 6 21:14:01 UTC 2008
Julian Elischer writes:
| 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.
This is one place where bash and ash disagree:
~ redhat-linux-box[2]> /bin/bash
bash-3.00$ sh -c 'set -- ${HOME+A B C}; echo "1:$1"; echo "2:$2:"; echo "3:$3:"'
1:A
2:B:
3:C:
bash-3.00$ bash --version
GNU bash, version 3.00.15(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2004 Free Software Foundation, Inc.
--Dan
--
Dan Grillo dan at grillo.net 650-299-1470
More information about the freebsd-hackers
mailing list