On Thu, Nov 08, 2007 at 10:58:38AM -0500, Peter Memishian wrote:
> 
>  > This:
>  > 
>  > % eval $(dladm show-wifi -p)
>  > 
>  > would be great (though only if dladm quotes things like ESSIDs
>  > correctly!).
> 
> What are you expecting it to do -- create a set of environment variables?

Variables, yes, environment variables, no.

This:

% eval `dladm show-wifi -p|sed s,/,_,`

works and does what you'd expect in the Bourne, Korn and bash shells (it
sets shell variables like "LINK", but does not export them unless they
were already exported).

>  > % dladm show-wifi -p -o essid,bssid | read essid bssid
>  > 
>  > not so much, because the shell read built-in simply splits the line into
>  > two using $IFS, and ESSID could contain whitespace (which is typically
>  > in $IFS).
> 
> That's why the various field values are double-quoted.

The shell read built-ins typically don't deal with quotes though.  Try
this:

% echo '"foo bar" baz'|read a b c ; echo $a:$b:$c 
"foo:bar":baz
% 

I must admit that I found dladm show-wifi -p output odd at first, but it
does make parsing from shell scripts easier and safer than the more
traditional parseable output (-o filed1,field2,..fieldN).  OTOH, it may
be harder to parse from other kinds of programs.

Nico
-- 
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to