Re: RFE -or- Howto?

2010-08-02 Thread Chris F.A. Johnson

On Mon, 2 Aug 2010, Linda Walsh wrote:


But then we've devolved to really ugly.

I like the look of
(a b c) = (1 2 3).

At least the "<<<" allows it to be on one line though not so attractively,
but using the multiline redirection just gets too unslightly for words.


A minor loss of "prettiness" is negligible compared to
portability.


It makes it clear that you are no longer doing what I want, a multi-variable
assignment.


It *is* a multi-variable assignment.


But that's my sense of what looks readable in codeYMMV.


On 8/2/2010 3:51 PM, Chris F.A. Johnson wrote:

On Mon, 2 Aug 2010, Dennis Williamson wrote:


It's called a "here string".


And the same thing can also be accomplished with the more portable
here document:

read a b c d <<.
1 2 3 4
.




--
   Chris F.A. Johnson, 
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)



Re: RFE -or- Howto?

2010-08-02 Thread Dennis Williamson
It's called a "here string".

On Mon, Jul 26, 2010 at 8:02 PM, Linda Walsh  wrote:
> Huh. Triple redirect...  Thanks!
>
>
> On 7/26/2010 5:53 PM, Chet Ramey wrote:
>> On 7/26/10 6:25 PM, Linda Walsh wrote:
>>>  I don't know if there's an easy way, but if not would you consider an
>>> RFE --
>>>
>>> Is there a syntax for a mult-var assignment, ala:
>>> (a b c d)=(1 2 3 4)
>>
>> Yes.
>>
>> read a b c d <<<"1 2 3 4"
>>
>> Chet
>
>



Re: RFE -or- Howto?

2010-07-27 Thread Linda Walsh
Huh. Triple redirect...  Thanks!


On 7/26/2010 5:53 PM, Chet Ramey wrote:
> On 7/26/10 6:25 PM, Linda Walsh wrote:
>>  I don't know if there's an easy way, but if not would you consider an
>> RFE --
>>
>> Is there a syntax for a mult-var assignment, ala:
>> (a b c d)=(1 2 3 4)
> 
> Yes.
> 
> read a b c d <<<"1 2 3 4"
> 
> Chet



Re: RFE -or- Howto?

2010-07-26 Thread Chet Ramey
On 7/26/10 6:25 PM, Linda Walsh wrote:
>  I don't know if there's an easy way, but if not would you consider an
> RFE --
> 
> Is there a syntax for a mult-var assignment, ala:
> (a b c d)=(1 2 3 4)

Yes.

read a b c d <<<"1 2 3 4"

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



RFE -or- Howto?

2010-07-26 Thread Linda Walsh

 I don't know if there's an easy way, but if not would you consider an RFE --

Is there a syntax for a mult-var assignment, ala:
(a b c d)=(1 2 3 4)

results would be: a=1, b=2, c=3, d=4

I know I can get the rval into an array, but can't figure out how to move
the array vals to discrete variables.

In *this* particular situation, I'm trying to something like
for (p v1 v2) in "(a  1  2)" "(b  2.0 2.1)"  "(c  0.2.2  0.2.2-1)"; do
...

If it's not there, I wonder if it would be a syntactic advantage to use
a lead-in char, like "@" to indicate that a parenthesized list following
it would be a list of vars ?

I'm constantly running into little scriptlets that need multiple vals 
assigned/interation,
and it would be so handy to have a simple syntax, than to do the more perverse
thing:

U="$(uname -sno)"
PUB_CONST SYSTEM_KERNEL="${U%% *}"
U="${U##$SYSTEM_KERNEL }"
PUBLIC HOSTNAME="${U%% *}"
U="${U##$HOSTNAME }"
PUB_CONST OSTYPE="${U//\//-}"
unset U