Re: Shouldn't "type" and "command" complain if there are no parameters?

2012-04-25 Thread Victor Engmark
On Thu, Apr 26, 2012 at 3:50 AM, Linda Walsh wrote: > Victor Engmark wrote: > >> Re-post from > parameters-to-bashs-command-**and-type-optional

Re: Is it possible or RFE to expand ranges of *arrays*

2012-04-25 Thread John Kearney
Am 26.04.2012 06:26, schrieb Linda Walsh: I know I can get a="abcdef" echo "${a[2:4]}" = cde how do I do: typeset -a a=(apple berry cherry date); then get: echo ${a[1:2]} = "berry" "cherry" ( non-grouped args) I tried to do it in a function and hurt myself. echo ${a[@]:1:2}

Is it possible or RFE to expand ranges of *arrays*

2012-04-25 Thread Linda Walsh
I know I can get a="abcdef" echo "${a[2:4]}" = cde how do I do: typeset -a a=(apple berry cherry date); then get: echo ${a[1:2]} = "berry" "cherry" ( non-grouped args) I tried to do it in a function and hurt myself.

Re: Shouldn't "type" and "command" complain if there are no parameters?

2012-04-25 Thread Linda Walsh
Victor Engmark wrote: Re-post from : [T]hese commands print nothing and return exit code 0 if no parameters are provided. But [...] `help command` and `help type` both state that at least on

Re: Passing variables by reference conflicts with local

2012-04-25 Thread Linda Walsh
Clark Wang wrote: On Wed, May 5, 2010 at 01:57, Freddy Vulto wrote: It appears that `unset' is capable of traversing down the call-stack and unsetting variables repeatedly: a=0 b=0 c=0 d=0 e=0 _unset() { unset -v b c c d d d e; } t1() { local a=1 b=1 c=1 d=1 t2 }

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Linda Walsh
Ted Okuzumi wrote: I am writing this e-mai to report to report a bug in bash Description: Cannot redirect into an array from multiline variable Does not work: echo "$mydata" | while read line; do myarray+=( "$line" ); done Have you tried this? Ishtar:> a='this is a tes

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Ted Okuzumi
Thank you for that detailed information. I really appreciate the 2 workarounds you provided. I can confirm by adding in this line to my script: shopt -s lastpipe fixes the problem, confirming that it was indeed a subshell issue. Best regards, Ted On Wed, Apr 25, 2012 at 10:50 AM, DJ Mills wr

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Greg Wooledge
On Wed, Apr 25, 2012 at 04:05:15PM -0400, Chet Ramey wrote: > OK. Now make the call move_to_high_fd(0, 1, -1) and see if that fixes it. cyclops:/var/tmp/bash/bash-4.2$ ./bash ~/foo cyclops:/var/tmp/bash/bash-4.2$ ./bash -c 'shopt -s lastpipe; echo hi | read f

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Chet Ramey
On 4/25/12 3:09 PM, Greg Wooledge wrote: > On Wed, Apr 25, 2012 at 02:54:07PM -0400, Chet Ramey wrote: >> On 4/25/12 2:04 PM, Greg Wooledge wrote: >> >>> Maybe it only works on boxes with a very large "open files" resource >>> limit. Perhaps the hard-coded 255 should be replaced with something >>>

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Greg Wooledge
On Wed, Apr 25, 2012 at 02:54:07PM -0400, Chet Ramey wrote: > On 4/25/12 2:04 PM, Greg Wooledge wrote: > > > Maybe it only works on boxes with a very large "open files" resource > > limit. Perhaps the hard-coded 255 should be replaced with something > > involving getrlimit() or similar? > > I se

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Chet Ramey
On 4/25/12 2:04 PM, Greg Wooledge wrote: > Maybe it only works on boxes with a very large "open files" resource > limit. Perhaps the hard-coded 255 should be replaced with something > involving getrlimit() or similar? I see two potential fixes here. First, try changing the 255 to -1 and see wha

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Greg Wooledge
On Wed, Apr 25, 2012 at 01:31:11PM -0400, Chet Ramey wrote: > OK. Maybe someone with OpenBSD can debug the appropriate code in > execute_cmd.c:execute_pipeline. Maybe the call to move_to_high_fd > fails. Breakpoint 1 at 0x41d5fc: file execute_cmd.c, line 2107. Breakpoint 2 at 0x414aa3: file gene

Re: Severe Bash Bug with Arrays

2012-04-25 Thread DJ Mills
On Wed, Apr 25, 2012 at 1:36 PM, Ted Okuzumi wrote: > Please note that if I use a different command in the while loop it works. > > So instead of > echo "$mydata" | while read -r line; do myarray+=( "$line" ); done > > if I say: > echo "$mydata" | while read -r line; do echo "$line" ; done > > The

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Greg Wooledge
On Wed, Apr 25, 2012 at 10:36:53AM -0700, Ted Okuzumi wrote: > Please note that if I use a different command in the while loop it works. > > So instead of > echo "$mydata" | while read -r line; do myarray+=( "$line" ); done > > if I say: > echo "$mydata" | while read -r line; do echo "$line" ; do

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Ted Okuzumi
Please note that if I use a different command in the while loop it works. So instead of echo "$mydata" | while read -r line; do myarray+=( "$line" ); done if I say: echo "$mydata" | while read -r line; do echo "$line" ; done Then it works. To pipe output into a while statement works, normally,

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Chet Ramey
On 4/25/12 1:10 PM, Greg Wooledge wrote: > On Wed, Apr 25, 2012 at 12:55:06PM -0400, Greg Wooledge wrote: >> It also fails on OpenBSD 5.0 using bash 4.2.10 from ports. > > And it also fails on OpenBSD 5.0 using bash 4.2.24 straight from the > original sources. OK. Maybe someone with OpenBSD can

Re: Directory completion problems

2012-04-25 Thread Chet Ramey
On 4/23/12 3:57 AM, Artur Rataj wrote: > To be exact, symlink is in the directory ~/a, and it points to ~/test and > there is also a directory ~/.java. So, after cd ~/a/symlink, there are two > ../.java files -- one in the physical parent, and one in the logical > parent. The former is a directory,

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Greg Wooledge
On Wed, Apr 25, 2012 at 12:55:06PM -0400, Greg Wooledge wrote: > It also fails on OpenBSD 5.0 using bash 4.2.10 from ports. And it also fails on OpenBSD 5.0 using bash 4.2.24 straight from the original sources. cyclops:/var/tmp/bash/bash-4.2$ ./bash -c 'echo $BASH_VERSION' 4.2.24(1)-release cyclo

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Greg Wooledge
On Wed, Apr 25, 2012 at 06:26:18PM +0200, Roman Rakus wrote: > On 04/25/2012 06:15 PM, Chet Ramey wrote: > >OK. I get the same working behavior on Mac OS X, Solaris 8/10, RHEL 5, > >BSD/OS (old), and Fedora 15. I'm not sure what to tell you. > On Fedora 16 it works as expected. > $ rpm -q bash >

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Roman Rakus
On 04/25/2012 06:15 PM, Chet Ramey wrote: On 4/25/12 11:27 AM, Greg Wooledge wrote: On Wed, Apr 25, 2012 at 11:07:57AM -0400, Chet Ramey wrote: z4.local(1)$ ../bash-4.2-patched/bash -c 'echo $BASH_VERSION' 4.2.24(9)-release z4.local(1)$ ../bash-4.2-patched/bash ./x3 foo z4.local(1)$ ./x3 foo I

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Chet Ramey
On 4/25/12 11:27 AM, Greg Wooledge wrote: > On Wed, Apr 25, 2012 at 11:07:57AM -0400, Chet Ramey wrote: >> z4.local(1)$ ../bash-4.2-patched/bash -c 'echo $BASH_VERSION' >> 4.2.24(9)-release >> z4.local(1)$ ../bash-4.2-patched/bash ./x3 >> foo >> z4.local(1)$ ./x3 >> foo > > I grabbed patches 21-24

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Greg Wooledge
On Wed, Apr 25, 2012 at 11:07:57AM -0400, Chet Ramey wrote: > z4.local(1)$ ../bash-4.2-patched/bash -c 'echo $BASH_VERSION' > 4.2.24(9)-release > z4.local(1)$ ../bash-4.2-patched/bash ./x3 > foo > z4.local(1)$ ./x3 > foo I grabbed patches 21-24 and applied them. No change. imadev:/var/tmp/bash/b

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Chet Ramey
On 4/25/12 10:55 AM, Greg Wooledge wrote: > On Wed, Apr 25, 2012 at 08:40:11AM -0400, Chet Ramey wrote: >> Since you're using bash-4.2, you can experiment with the `lastpipe' shopt >> option. If that's enabled, bash runs the last element of a pipeline in >> the parent shell context without creatin

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Greg Wooledge
On Wed, Apr 25, 2012 at 08:40:11AM -0400, Chet Ramey wrote: > Since you're using bash-4.2, you can experiment with the `lastpipe' shopt > option. If that's enabled, bash runs the last element of a pipeline in > the parent shell context without creating a subshell. I actually started writing a res

Re: Severe Bash Bug with Arrays

2012-04-25 Thread Chet Ramey
On 4/25/12 1:23 AM, Clark Wang wrote: >> Bash Version: 4.2 >> Patch Level: 0 >> Release Status: release >> >> Description: >>Cannot redirect into an array from multiline variable >> >> Does not work: >> echo "$mydata" | while read line; do myarray+=( "$line" ); done >> > > Here the whole