Re: Using unset to destroy array elements doesn't work with 'nullglob' set

2009-06-06 Thread Francis Moreau
On 5 juin, 20:29, Chet Ramey  wrote:
> Francis Moreau wrote:
> > Hello,
>
> > My version of bash is "GNU bash, version 3.2.33(1)-release (x86_64-
> > redhat-linux-gnu)" running on a fedora 9.
>
> > Here's is a small script to show the bug:
>
> > #!/bin/bash
>
> > #shopt -s nullglob
>
> > foo[0]=0
> > unset foo[0]
> > echo ${f...@]}
>
> > When shopt line is commented then the element at index 0 is destroyed
> > and the echo doesn't output anything. However is a uncomment the shopt
> > line the element at index 0 is not destroyed anymore and the echo
> > output "0".
>
> This is why the man page says:
>
> The  unset  builtin  is  used to destroy arrays.  unset name[subscript]
> destroys the array element at index subscript.  Care must be  taken  to
> avoid unwanted side effects caused by filename generation.
>
> In this case, you should quote the argument if you don't want globbing
> to potentially alter it.
>

Yes sorry for the noise, I've been struggling to debug a bash script
for too long and my brain was not working anymore.


RFE: zero prefixed expansion, e.g. {01..02} -> 01 02

2009-06-06 Thread Till Maas
Aloas,

I often need the results of expansion like {01..10} to be prefixed with zeros, 
currently I always need to have two expansions, e.g.

cat foo0{1..9}.bar foo{10..23}.bar

It would be nice if I could use e.g. 

cat foo{01..23}.bar 

instead to get the same results.

Regards
Till


signature.asc
Description: This is a digitally signed message part.


Re: RFE: zero prefixed expansion, e.g. {01..02} -> 01 02

2009-06-06 Thread pk
On Friday 5 June 2009 20:28, Till Maas wrote:

> Aloas,
> 
> I often need the results of expansion like {01..10} to be prefixed with
> zeros, currently I always need to have two expansions, e.g.
> 
> cat foo0{1..9}.bar foo{10..23}.bar
> 
> It would be nice if I could use e.g.
> 
> cat foo{01..23}.bar
> 
> instead to get the same results.

Bash 4 does what you want.