On Fri, Feb 09, 2007 at 10:17:21AM +0000, Roy Marples wrote:
> On Fri, 9 Feb 2007 10:51:29 +0100
> Harald van Dijk <[EMAIL PROTECTED]> wrote:
> > That works with your ; approach too, as well as with the
> > newline-separated approach:
> > 
> > replace="
> >     4d 1280 768 24
> >     5c 1400 1050 16
> > "
> > 
> > IFS=';
> > '
> > #set -f
> > set -- ${replace}
> > #set +f
> > unset IFS
> > 
> > for x ; do
> >   ....
> > done
> 
> Yes, but consider this
> 
> iwpriv_ESSID="
>       set AuthMode=WPAPSK;
>       set EncrypType=TKIP;
>       set WPAPSK=yourpasskey
> "
> 
> One issue is that any valid character is allowed in WPAPSK, including ;

Good point, but excluding newline, right? I can't try it, but rt2500's
own settings file format does not allow for newline in WPAPSK. So you
could simply only use newline as the separator whenever ; is allowed.

> $ foo="'one '\'' two' \
>        'three ; four' \
>       'five \ six' \
> "  
> $ eval set -- "${foo}" ; for x in "$@" ; do echo $x; done
> one ' two
> three ; four
> five \ six
> $
> 
> Demonstrates that we can achieve multi-line arrays like so, without the
> need to set shell opts or alter IFS

Yeah, you just use eval. :) It has its uses, but personally I would
avoid it where possible because it's so easy to get wrong. Just try it
with

iwpriv_ESSID="
        set\ AuthMode=WPAPSK
        set\ EncrypType=TKIP
        set\ WPAPSK=pass;key
"

Failing to properly escape the ; is a user error, but it becomes
difficult for baselayout to handle that error properly. Similarly, the
backslash-newline combinations are easily left out when you're already
editing a string. The format itself I have no problems with, though, so
if you have a way to nicely deal with accidental bad input, perhaps
using some simple scans, please go for it.

(Since the configuration files are only writable by root, I'll ignore
the possibility of intentional bad input here.)

Attachment: pgpVARxqQ8aGi.pgp
Description: PGP signature

Reply via email to