Re: Q: bash parameter expansion

2008-04-21 Thread Andreas Schwab
"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."




Re: Q: bash parameter expansion

2008-04-21 Thread Dmitry V. Levin
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.


-- 
ldv


pgp1h7fFxh1fa.pgp
Description: PGP signature


Re: Q: bash parameter expansion

2008-04-21 Thread Chet Ramey

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/




bash PO file typos/query

2008-04-21 Thread Clytie Siddall

Hello :)

I have just translated the file bash-3.2 for the Translation Project.  
In doing so, I've encountered the following typos, which I thought you  
might like to weed out in a future release.



1. duplicate word

#: builtins/caller.def:133
msgid "Without EXPR, returns returns \"$line $filename\".  With EXPR,"

- returns returns
+ returns


2. split strings

Split strings are not good i18n practice. This is because different  
languages have different sytax, so we can't produce accurate  
translations that fit the overall sentence. Please combine split  
strings into complete strings, and use line-breaks or other layout  
measures to deal with display limitations.


(a)

#: builtins/caller.def:133
msgid "Without EXPR, returns returns \"$line $filename\".  With EXPR,"
msgstr ""

#: builtins/caller.def:134
msgid "returns \"$line $subroutine $filename\"; this extra information"
msgstr ""

#: builtins/caller.def:135
msgid "can be used used to provide a stack trace."
msgstr ""

(b)

#: builtins/caller.def:137
msgid "The value of EXPR indicates how many call frames to go back  
before the"

msgstr ""

#: builtins/caller.def:138
msgid "current one; the top frame is frame 0."

(c)

#: builtins/pushd.def:663
msgid "Display the list of currently remembered directories.   
Directories"

msgstr ""

#: builtins/pushd.def:664
msgid "find their way onto the list with the `pushd' command; you can  
get"

msgstr ""

#: builtins/pushd.def:665
msgid "back up through the list with the `popd' command."
msgstr ""

(d)

#: builtins/pushd.def:667
msgid "The -l flag specifies that `dirs' should not print shorthand  
versions"

msgstr ""

#: builtins/pushd.def:668
msgid "of directories which are relative to your home directory.  This  
means"

msgstr ""

#: builtins/pushd.def:669
msgid "that `~/bin' might be displayed as `/homes/bfox/bin'.  The -v  
flag"

msgstr "'"

#: builtins/pushd.def:670
msgid "causes `dirs' to print the directory stack with one entry per  
line,"

msgstr ""

#: builtins/pushd.def:671
msgid "prepending the directory name with its position in the stack.   
The -p"

msgstr ""

#: builtins/pushd.def:672
msgid "flag does the same thing, but the stack position is not  
prepended."

msgstr ""

(e)

#: builtins/pushd.def:675
msgid "+N   displays the Nth entry counting from the left of the list  
shown by"

msgstr ""

#: builtins/pushd.def:676
#: builtins/pushd.def:679
msgid " dirs when invoked without options, starting with zero."
msgstr ""

(f)

#: builtins/pushd.def:678
msgid ""
"-N   displays the Nth entry counting from the right of the list shown  
by"

msgstr ""

(presumably combines with another string)

(g)

#: builtins/pushd.def:684
msgid "Adds a directory to the top of the directory stack, or rotates"
msgstr ""

#: builtins/pushd.def:685
msgid "the stack, making the new top of the stack the current working"
msgstr ""

#: builtins/pushd.def:686
msgid "directory.  With no arguments, exchanges the top two  
directories."

msgstr ""

(h)

#: builtins/pushd.def:688
msgid "+N   Rotates the stack so that the Nth directory (counting"
msgstr ""

#: builtins/pushd.def:689
msgid " from the left of the list shown by `dirs', starting with"
msgstr ""

#: builtins/pushd.def:690
#: builtins/pushd.def:694
msgid " zero) is at the top."
msgstr ""

(i)

#: builtins/pushd.def:692
msgid "-N   Rotates the stack so that the Nth directory (counting"
msgstr ""

#: builtins/pushd.def:693
msgid " from the right of the list shown by `dirs', starting with"
msgstr ""

(again, presumably combines with another string)

(j)

#: builtins/pushd.def:696
msgid "-n   suppress the normal change of directory when adding  
directories"

msgstr ""

#: builtins/pushd.def:697
msgid " to the stack, so only the stack is manipulated."
msgstr ""

(k)

#: builtins/pushd.def:699
msgid "dir  adds DIR to the directory stack at the top, making it the"
msgstr ""

#: builtins/pushd.def:700
msgid " new current working directory."
msgstr ""

(l)

#: builtins/pushd.def:707
msgid "Removes entries from the directory stack.  With no arguments,"
msgstr ""

#: builtins/pushd.def:708
msgid "removes the top directory from the stack, and cd's to the new"
msgstr ""

#: builtins/pushd.def:709
msgid "top directory."
msgstr ""

(m)

#: builtins/pushd.def:711
msgid "+N   removes the Nth entry counting from the left of the list"
msgstr ""

#: builtins/pushd.def:712
msgid " shown by `dirs', starting with zero.  For example: `popd  
+0'"

msgstr "

#: builtins/pushd.def:713
msgid " removes the first directory, `popd +1' the second."
msgstr ""

(n)

#: builtins/pushd.def:715
msgid "-N   removes the Nth entry counting from the right of the list"
msgstr ""

#: builtins/pushd.def:716
msgid " shown by `dirs', starting with zero.  For example: `popd  
-0'"

msgstr ""

#: builtins/pushd.def:717
msgid " removes the last directory, `popd -1' the next to last."
msgstr ""

(o)

#: builtins/pushd.def:719
msgid "-n   suppress the normal chang