Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Bernd Eggink
On 12.02.2013 18:50, Dashing wrote: On Tue, 12 Feb 2013 18:02:05 +0100 "Chet Ramey" I've fixed the problem, and the fix will be in the next release. Thank you, Chet! On Tue, 12 Feb 2013 10:13:46 +0100 "Bernd Eggink" superfluous blank in the ${rest: -1} expression Bernd, this blank makes a

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Dashing
On Tue, 12 Feb 2013 18:02:05 +0100 "Chet Ramey" >I've fixed the problem, and the fix will be in the next release. Thank you, Chet! On Tue, 12 Feb 2013 10:13:46 +0100 "Bernd Eggink" >superfluous blank in the ${rest: -1} expression Bernd, this blank makes a big difference: ${rest: -1} last chara

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Bernd Eggink
On 11.02.2013 18:50, Dashing wrote: Bash version: 4.2.042 I have a script that behaves erratically: = #! /bin/bash last=${1##* } rest=${1% *} while [[ "${rest: -1}" == '\' ]]; do last="${rest##* } $last" oldrest=$rest rest=${rest% *} if [[ "$oldrest" == "$

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Chet Ramey
> Bash version: 4.2.042 > > I have a script that behaves erratically: Thanks for the report. The reason it is erratic and not always reproducible in the same spot is that it is the result of an array bounds error, and so depends on the contents of memory beyond the end of a string. I've fixed

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Chet Ramey
On 2/12/13 11:37 AM, Andreas Schwab wrote: > Greg Wooledge writes: > >> Then you are still doing something wrong. > > No matter how badly the script is written, bash should execute it > properly, which it doesn't. Try running it under valgrind in a > multibyte locale and you will see the error

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Andreas Schwab
Greg Wooledge writes: > Then you are still doing something wrong. No matter how badly the script is written, bash should execute it properly, which it doesn't. Try running it under valgrind in a multibyte locale and you will see the error immediately: ==18677== Conditional jump or move depends

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Dashing
On Tue, 12 Feb 2013 14:45:26 +0100 "Greg Wooledge" wrote: >There are no literal backslashes in an argument that is >produced by tab completion. The backslashes are a form >of quoting, and they are removed by the calling shell >during the quote removal phase. When bind -x sets READLINE_LINE back

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Greg Wooledge
On Tue, Feb 12, 2013 at 02:37:03PM +0100, Dashing wrote: > For my purposes this is irrelevant, because the nature of the > script from which my example code derived is tab completion. > READLINE_LINE will contain mplayer foo1\ foo2\ etc. Then you are still doing something wrong. imadev:~$ args

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Dashing
On Tue, 12 Feb 2013 14:16:24 +0100 "Greg Wooledge" wrote: >On Mon, Feb 11, 2013 at 06:50:49PM +0100, Dashing wrote: >> $ ./pe 'mplayer foo1\ foo2\ foo3\ 4\ 5\ foo6\ 7' >> :--Mistake--: >> :--Mistake--: > >Whatever you're doing, it's wrong. > >./pe mplayer foo1\ foo2\ foo3\ 4\ 5\ foo6\ 7 > >#!/bin

Re: [Parameter Expansion] bug in ${variable% *}

2013-02-12 Thread Greg Wooledge
On Mon, Feb 11, 2013 at 06:50:49PM +0100, Dashing wrote: > $ ./pe 'mplayer foo1\ foo2\ foo3\ 4\ 5\ foo6\ 7' > :--Mistake--: > :--Mistake--: Whatever you're doing, it's wrong. ./pe mplayer foo1\ foo2\ foo3\ 4\ 5\ foo6\ 7 #!/bin/bash prog=$1 shift exec "$prog" extra args go here "$@" THAT is how

[Parameter Expansion] bug in ${variable% *}

2013-02-11 Thread Dashing
Bash version: 4.2.042 I have a script that behaves erratically: = #! /bin/bash last=${1##* } rest=${1% *} while [[ "${rest: -1}" == '\' ]]; do last="${rest##* } $last" oldrest=$rest rest=${rest% *} if [[ "$oldrest" == "$rest" ]]; then echo :