bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read -a severely broken


From: Chet Ramey
Subject: Re: read -a severely broken
Date: Tue, 26 Feb 2002 10:03:02 -0500

> Configuration Information [Automatically generated, do not change]:
> Machine: i586
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i586' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i586-pc-linux-gnu' 
> -DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H  -D_FILE_OFFSET_BITS=64  -I.  -I. 
> -I./include -I./lib -I/include -Os -fomit-frame-pointer -ffast-math 
> -march=pentium
> uname output: Linux ibe.miee.ru 2.4.17-rmap12e #3 Wed Feb 13 21:46:03 MSK 
> 2002 i686 unknown
> Machine Type: i586-pc-linux-gnu
> 
> Bash Version: 2.05
> Patch Level: 0
> Release Status: release
> 
> Description:
>       read -a SOMETHING < file doesnt work: it fills only the first array 
> entry

This is not a bug.

> Repeat-By:
>       echo -e "a\nb\nc\n" > a
>       FOO=""
>       read -a FOO < a
>       echo ${FOO[0]}
>       echo ${FOO[1]}
>       echo ${FOO[2]}

`read' reads only a single line from the standard input; I don't know why
you expect it to behave differently now.

>       cat a | read -a FOO
>       echo ${FOO[0]}
>         echo ${FOO[1]}
>         echo ${FOO[2]}

This doesn't do what you expect, since the pipe forces the `read' to be
performed in a subshell.  Look at the Bash FAQ, question E4.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
( ``Discere est Dolere'' -- chet)

Chet Ramey, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]