Mailing List ArchiveSupport open source code!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Bash syntax question
- To: tlug@example.com
- Subject: Re: [tlug] Bash syntax question
- From: Frank Bennett <bennett@example.com>
- Date: Wed, 30 Jan 2002 17:30:09 +0900
- Content-disposition: inline
- Content-type: text/plain; charset=euc-jp
- In-reply-to: <20020130080552.GA30629@example.com>
- References: <20020130060350.GA737@example.com> <20020130080552.GA30629@example.com>
- User-agent: Mutt/1.3.25i
Here's a better solution that takes advantage of Bash 2.0 indirect assignment. All of the clutter is now concealed inside the function. (Just in case I'm at risk of being flamed for this series of messages, this is for shoehorning workable gettext support into a shell script. Finished functionality available on request. :-) #!/bin/bash function ask_questions () { local IFS IFS=$'\t' LOCAL_ARRAY=(${!1}) shift PUBLIC_ARRAY=("${QUESTIONS[@]}") echo === Assignment via parameter === for i in "${LOCAL_ARRAY[@]}"; do echo "${i}" $1 done echo === Assignment from global variable === for i in "${PUBLIC_ARRAY[@]}"; do echo "${i}" $1 done } QUESTIONS=("1. WHY?" "2. REALLY, WHY?" "3. WELL?") ask_questions "QUESTIONS[*]" Huh?
- References:
- [tlug] Bash syntax question
- From: Frank Bennett
- Re: [tlug] Bash syntax question
- From: Frank Bennett
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Bash syntax question
- Next by Date: [tlug] Re: pcg-c1mrx / pcg-c1mv
- Previous by thread: Re: [tlug] Bash syntax question
- Next by thread: [tlug] pcg-c1mrx / pcg-c1mv
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links