Dmitry V. Levin wrote:
On Mon, Apr 21, 2008 at 10:06:10AM +0200, Andreas Schwab wrote:
Dmitry V. Levin writes:
I wonder whether such difference in parameter expansion is valid:
$ env -i sh -c 'fun() { echo "[${*#foo }]"; }; fun foo bar'
[foo bar]
$ env -i sh -c 'fun() { echo "[${*#foo}]"; }; fun foo bar'
[ bar]
Works as documented:
`${PARAMETER#WORD}'
`${PARAMETER##WORD}'
The WORD is expanded to produce a pattern just as in filename
expansion (*note Filename Expansion::). If the pattern matches
the beginning of the expanded value of PARAMETER, then the result
of the expansion is the expanded value of PARAMETER with the
shortest matching pattern (the `#' case) or the longest matching
pattern (the `##' case) deleted. If PARAMETER is `@' or `*', the
^^^^^^^^^^^^^^^^^^^^^^^^^^
pattern removal operation is applied to each positional parameter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
in turn, and the expansion is the resultant list.
Ouch, one more documented incompatibility between bash and dash.
Posix leaves it unspecified. Bash and ksh do it one way; ash/dash and
zsh another.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Live Strong. No day but today.
Chet Ramey, ITS, CWRU [EMAIL PROTECTED] http://cnswww.cns.cwru.edu/~chet/