bash scope problem

This is a discussion on bash scope problem within the Linux Administration forums, part of the Linux Forums category; Hello, Can someone please tell me what I'm doing wrong or have set wrong? From a bash command line, ...


Go Back   Usenet Forums > Linux Forums > Linux Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-30-2004
news-david.IHATESPAM@wizNOSPAMdoNOTSPAMm.net
 
Posts: n/a
Default bash scope problem

Hello,

Can someone please tell me what I'm doing wrong or have set wrong?

From a bash command line, if I type

read -a array

then type
1 2 3

I get an array that contains
array[0]=1
array[1]=2
array[2]=3

All is good.

But, if I type

echo "1 2 3" | read -a array

I don't have any array defined.

It looks like this must be spawning some sort of shell or exec and the array
is being defined locally in that context and then is not returned to my
current shell.

This problem exists even if I try using
declare -a array
and/or
typeset -a array

Call me an idiot for not knowing what must be a trivial problem but please
let me know what I'm doing wrong! How can I do this and bring the array
into the current shell?

Thanks,
Dave
Reply With Quote
  #2 (permalink)  
Old 04-30-2004
news-david.IHATESPAM@wizNOSPAMdoNOTSPAMm.net
 
Posts: n/a
Default Re: bash scope problem

Forgot to mention:

bash --version
GNU bash, version 2.05b.0(1)-release (i386-redhat-linux-gnu)
Copyright (C) 2002 Free Software Foundation, Inc.

Thanks,
Dave
Reply With Quote
  #3 (permalink)  
Old 04-30-2004
news-david.IHATESPAM@wizNOSPAMdoNOTSPAMm.net
 
Posts: n/a
Default Re: bash scope problem

Nevermind, I RTFM'ed the BASH FAQ, found the answer at E4.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 02:34 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0