Re: Question about variables and for loop

2006-03-18 Thread Bob
On Sun, 19 Mar 2006 03:02:51 +, Bob wrote: > On Sat, 18 Mar 2006 20:44:17 -0500, Paul Jarc wrote: > >> Bob <[EMAIL PROTECTED]> wrote: >>> XXX='a "b c" d' >>> for x in $XXX ; do >>> echo $x >>> done >> >> XXX='a "b c" d' >> eval "set $XXX" >> for x in "$@" ; do >>

Re: Question about variables and for loop

2006-03-18 Thread Bob
On Sat, 18 Mar 2006 20:44:17 -0500, Paul Jarc wrote: > Bob <[EMAIL PROTECTED]> wrote: >> XXX='a "b c" d' >> for x in $XXX ; do >> echo $x >> done > > XXX='a "b c" d' > eval "set $XXX" > for x in "$@" ; do > echo $x > done > > If the first element in XXX might st

Re: Question about variables and for loop

2006-03-18 Thread Paul Jarc
Bob <[EMAIL PROTECTED]> wrote: > XXX='a "b c" d' > for x in $XXX ; do > echo $x > done XXX='a "b c" d' eval "set $XXX" for x in "$@" ; do echo $x done If the first element in XXX might start with "-", then it takes a little more work to ensure it isn't misi

Question about variables and for loop

2006-03-18 Thread Bob
Hi, I hope it's OK to ask questions here (the Gnu Bash FAQ seems to say it's OK). Values in the variable $@ can be extracted in a for loop in a way to preserve individual strings that may have white space. For example: #!/bin/bash for x in "$@" ; do echo $x