On Sun, 19 Mar 2006 03:02:51 +0000, 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
>> echo $x
>> done
>>
>> If the first element in XXX might start with "-", then it takes a little
>> more work to ensure it isn't misinterpreted as an option to "set": eval
>> "set x $XXX"
>> shift
>>
>>
>> paul
>
> Great! That works. Unfortunately, the example I gave you was simplified
> from my actual application (too big and confusing to post here). There is
> another complication ... my variable has new-line characters embedded in
> it so the "eval" above gets many invalid command errors. I need to replace
> the new-lines with spaces. I will try the tr command.
Got it working with bash's substitution: xxx=${xxx//$'\n'/ }
_______________________________________________
Bug-bash mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-bash