"Dmitry V. Levin" <[EMAIL PROTECTED]> 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. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."