Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Dennis Williamson
On Tue, Feb 15, 2011 at 9:54 PM, Dennis Williamson
 wrote:
> On Tue, Feb 15, 2011 at 9:16 PM, Clark J. Wang  wrote:
>> On Wed, Feb 16, 2011 at 9:59 AM, Chet Ramey  wrote:
>>
>>> On 2/15/11 6:18 AM, Clark J. Wang wrote:
>>> > For following script:
>>> >
>>> > var='[hello'
>>> > echo "${var//[/}"
>>> >
>>> > With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash
>>> 4.2
>>> > with compat41 on still outputs [hello . Bug? Or Bug fixed?
>>>
>>> It's a bug, and I will release a patch.  In the meantime, see if the
>>> attached patch does the right thing on your platform.
>>>
>>> The patch fixed this simple example but it does not work for more
>> complicated scenario:
>>
>> bash# cat foo.sh
>> var='[hello'
>> echo "${var//[/}"
>>
>> red='\[\e[0;31m\]'
>> echo "${red//\\[\\e/}"
>> bash# /usr/local/bash-4.1.9/bin/bash foo.sh
>> hello
>> [0;31m\]
>> bash# /usr/local/bash-4.2.0/bin/bash foo.sh
>> [hello
>> \[\e[0;31m\]
>> bash# /usr/local/bash-4.2.0-fix/bin/bash foo.sh
>> hello
>> \[\e[0;31m\]
>> bash#
>>
>> Chet
>>> --
>>> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>>>                 ``Ars longa, vita brevis'' - Hippocrates
>>> Chet Ramey, ITS, CWRU    c...@case.edu
>>> http://cnswww.cns.cwru.edu/~chet/
>>>
>>
>>
>>
>> --
>> Clark
>>
>
> Also, 4.0.33 and 3.2.0 pass, 2.05b and 4.2.0 fail.
>

I should have been clear that that applies to the more complex example.



Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Dennis Williamson
On Tue, Feb 15, 2011 at 9:16 PM, Clark J. Wang  wrote:
> On Wed, Feb 16, 2011 at 9:59 AM, Chet Ramey  wrote:
>
>> On 2/15/11 6:18 AM, Clark J. Wang wrote:
>> > For following script:
>> >
>> > var='[hello'
>> > echo "${var//[/}"
>> >
>> > With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash
>> 4.2
>> > with compat41 on still outputs [hello . Bug? Or Bug fixed?
>>
>> It's a bug, and I will release a patch.  In the meantime, see if the
>> attached patch does the right thing on your platform.
>>
>> The patch fixed this simple example but it does not work for more
> complicated scenario:
>
> bash# cat foo.sh
> var='[hello'
> echo "${var//[/}"
>
> red='\[\e[0;31m\]'
> echo "${red//\\[\\e/}"
> bash# /usr/local/bash-4.1.9/bin/bash foo.sh
> hello
> [0;31m\]
> bash# /usr/local/bash-4.2.0/bin/bash foo.sh
> [hello
> \[\e[0;31m\]
> bash# /usr/local/bash-4.2.0-fix/bin/bash foo.sh
> hello
> \[\e[0;31m\]
> bash#
>
> Chet
>> --
>> ``The lyf so short, the craft so long to lerne.'' - Chaucer
>>                 ``Ars longa, vita brevis'' - Hippocrates
>> Chet Ramey, ITS, CWRU    c...@case.edu
>> http://cnswww.cns.cwru.edu/~chet/
>>
>
>
>
> --
> Clark
>

Also, 4.0.33 and 3.2.0 pass, 2.05b and 4.2.0 fail.



Bash 4.2 printf %()T seems to ignore TZ

2011-02-15 Thread Dennis Williamson
When I ran make test I noticed a discrepancy in a couple of the times
output during the printf tests. I pulled out the relevant section and
this is what I get:

LC_ALL=C
LANG=C
SECS=1275250155
export TZ=EST5EDT
printf "%()T\n" $SECS
printf "%(%e-%b-%Y %T %Z)T\n" $SECS  # added %Z

result:

15:09:15
30-May-2010 15:09:15 CDT

printf.right says it should be "16:09:15" in both cases. Note that the
%Z I added outputs CDT.

The next part of the test that compares date +%s passes.

Also:

$ LC_ALL=C LANG=C TZ=EST5EDT date -d @$SECS
Sun May 30 16:09:15 EDT 2010
$ TZ=EST5EDT date -d @$SECS
Sun May 30 16:09:15 EDT 2010
$ date -d @$SECS
Sun May 30 15:09:15 CDT 2010

Running in Ubuntu 9.10

Machine: i686
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i686'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i686-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale'
-DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H   -I.  -I. -I./include
-I./lib   -g -O2
uname output: Linux emperor 2.6.31-21-generic #59-Ubuntu SMP Wed Mar
24 07:28:56 UTC 2010 i686 GNU/Linux
Machine Type: i686-pc-linux-gnu

Bash Version: 4.2
Patch Level: 0
Release Status: release



Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Clark J. Wang
On Wed, Feb 16, 2011 at 9:59 AM, Chet Ramey  wrote:

> On 2/15/11 6:18 AM, Clark J. Wang wrote:
> > For following script:
> >
> > var='[hello'
> > echo "${var//[/}"
> >
> > With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash
> 4.2
> > with compat41 on still outputs [hello . Bug? Or Bug fixed?
>
> It's a bug, and I will release a patch.  In the meantime, see if the
> attached patch does the right thing on your platform.
>
> The patch fixed this simple example but it does not work for more
complicated scenario:

bash# cat foo.sh
var='[hello'
echo "${var//[/}"

red='\[\e[0;31m\]'
echo "${red//\\[\\e/}"
bash# /usr/local/bash-4.1.9/bin/bash foo.sh
hello
[0;31m\]
bash# /usr/local/bash-4.2.0/bin/bash foo.sh
[hello
\[\e[0;31m\]
bash# /usr/local/bash-4.2.0-fix/bin/bash foo.sh
hello
\[\e[0;31m\]
bash#

Chet
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRUc...@case.edu
> http://cnswww.cns.cwru.edu/~chet/
>



-- 
Clark


Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Chris F.A. Johnson

On Tue, 15 Feb 2011, Chet Ramey wrote:


On 2/15/11 6:18 AM, Clark J. Wang wrote:

For following script:

var='[hello'
echo "${var//[/}"

With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash 4.2
with compat41 on still outputs [hello . Bug? Or Bug fixed?


It's a bug, and I will release a patch.  In the meantime, see if the
attached patch does the right thing on your platform.


   On Mandriva, I get '[hello'; after applying the patch I get 'hello'.

--
   Chris F.A. Johnson, 
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)



Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Clark J. Wang
On Wed, Feb 16, 2011 at 9:20 AM, Chet Ramey  wrote:

> On 2/15/11 6:18 AM, Clark J. Wang wrote:
> > For following script:
> >
> > var='[hello'
> > echo "${var//[/}"
> >
> > With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash
> 4.2
> > with compat41 on still outputs [hello . Bug? Or Bug fixed?
>
> This is strange.  It echoes "hello" on Mac OS X, but "[hello" on
> Red Hat.  I'll have to take a look at where the difference might be.
>
> I tested bash 4.2 on Debian 6.0. And bash 4.1 behaves the same on Linux and
Mac OS X (10.4 PPC).

> Chet
>
> --
> ``The lyf so short, the craft so long to lerne.'' - Chaucer
> ``Ars longa, vita brevis'' - Hippocrates
> Chet Ramey, ITS, CWRUc...@case.edu
> http://cnswww.cns.cwru.edu/~chet/
>



-- 
Clark


Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Chet Ramey
On 2/15/11 6:18 AM, Clark J. Wang wrote:
> For following script:
> 
> var='[hello'
> echo "${var//[/}"
> 
> With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash 4.2
> with compat41 on still outputs [hello . Bug? Or Bug fixed?

It's a bug, and I will release a patch.  In the meantime, see if the
attached patch does the right thing on your platform.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.2/lib/glob/gmisc.c	2011-02-05 16:11:17.0 -0500
--- lib/glob/gmisc.c	2011-02-15 20:50:43.0 -0500
***
*** 126,129 
--- 126,130 
  		{
  	  matlen += wpat - wbrack - 1;	/* incremented below */
+ 	  wpat--;			/* back up to NUL */
  	  break;
  	}
***
*** 262,265 
--- 263,267 
  		{
  	  matlen += pat - brack - 1;	/* incremented below */
+ 	  pat--;			/* back up to NUL */
  	  break;
  	}


Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Allan McRae

On 16/02/11 11:20, Chet Ramey wrote:

On 2/15/11 6:18 AM, Clark J. Wang wrote:

For following script:

var='[hello'
echo "${var//[/}"

With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash 4.2
with compat41 on still outputs [hello . Bug? Or Bug fixed?


This is strange.  It echoes "hello" on Mac OS X, but "[hello" on
Red Hat.  I'll have to take a look at where the difference might be.



Just to rule out it being Linux specifc, I get the expected "hello" on 
Arch Linux.


Allan



Re: [bash4.2] ${v//[/} bug?

2011-02-15 Thread Chet Ramey
On 2/15/11 6:18 AM, Clark J. Wang wrote:
> For following script:
> 
> var='[hello'
> echo "${var//[/}"
> 
> With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash 4.2
> with compat41 on still outputs [hello . Bug? Or Bug fixed?

This is strange.  It echoes "hello" on Mac OS X, but "[hello" on
Red Hat.  I'll have to take a look at where the difference might be.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: compat31

2011-02-15 Thread Dennis Williamson
On Tue, Feb 15, 2011 at 8:45 AM, Roman Rakus  wrote:
> On 02/14/2011 04:03 PM, Dennis Williamson wrote:
>>
>> I'm having a discussion with someone who claims that for them on Bash
>> 4.0.33, with compat31*off*, they are getting 3.1 behavior with quoted
>> patterns in a =~ match.
>
> Is it on Fedora? If so, it was a bug and is fixed since Fedora's
> bash-4.1.2-1 package.
>
> RR
>

Yes, it turns out that he's using Fedora with the buggy package.

Thanks to Roman and Marc for the information that solved it.

Greg, I had already been through that.



Re: compat31

2011-02-15 Thread Roman Rakus

On 02/14/2011 04:03 PM, Dennis Williamson wrote:

I'm having a discussion with someone who claims that for them on Bash
4.0.33, with compat31*off*, they are getting 3.1 behavior with quoted
patterns in a =~ match.
Is it on Fedora? If so, it was a bug and is fixed since Fedora's 
bash-4.1.2-1 package.


RR


Re: compat31

2011-02-15 Thread Marc Herbert
Le 14/02/2011 15:03, Dennis Williamson a écrit :
> I'm having a discussion with someone who claims that for them on Bash
> 4.0.33, with compat31 *off*, they are getting 3.1 behavior with quoted
> patterns in a =~ match.
> 
> They're saying that this:
> 
> [[ a =~ "." ]] && echo match || echo no
> 
> results in "match".
> 
> I cannot reproduce this without doing
> 
> shopt -s compat31
> 
> or removing the quotes. Are there any other circumstances that could
> produce this behavior?

I think this qualifies:

http://thread.gmane.org/gmane.comp.shells.bash.bugs/15080/focus=15107





Re: compat31

2011-02-15 Thread Greg Wooledge
On Mon, Feb 14, 2011 at 07:26:16PM -0600, Dennis Williamson wrote:
> The user is performing this from a shell prompt. I had him try
> 
> [[ $BASH_VERSION =~ "4\.0" ]] && echo yes || echo no
> 
> which should output "yes" only if he's using Bash 4.0 *and* compat31
> is on.

Gah.  Too much trickery and silliness.  Just have him put these lines
in the script

echo "$BASH_VERSION"
shopt
set -o

Gather up ALL of the information at once instead of playing games and
trying to discern one piece at a time through a dirty window.



[bash4.2] ${v//[/} bug?

2011-02-15 Thread Clark J. Wang
For following script:

var='[hello'
echo "${var//[/}"

With bash 4.1 it outputs hello but with 4.2 it outputs [hello . And bash 4.2
with compat41 on still outputs [hello . Bug? Or Bug fixed?

-- 
Clark