1 |
On Fri, Feb 09, 2007 at 10:17:21AM +0000, Roy Marples wrote: |
2 |
> On Fri, 9 Feb 2007 10:51:29 +0100 |
3 |
> Harald van Dijk <truedfx@g.o> wrote: |
4 |
> > That works with your ; approach too, as well as with the |
5 |
> > newline-separated approach: |
6 |
> > |
7 |
> > replace=" |
8 |
> > 4d 1280 768 24 |
9 |
> > 5c 1400 1050 16 |
10 |
> > " |
11 |
> > |
12 |
> > IFS='; |
13 |
> > ' |
14 |
> > #set -f |
15 |
> > set -- ${replace} |
16 |
> > #set +f |
17 |
> > unset IFS |
18 |
> > |
19 |
> > for x ; do |
20 |
> > .... |
21 |
> > done |
22 |
> |
23 |
> Yes, but consider this |
24 |
> |
25 |
> iwpriv_ESSID=" |
26 |
> set AuthMode=WPAPSK; |
27 |
> set EncrypType=TKIP; |
28 |
> set WPAPSK=yourpasskey |
29 |
> " |
30 |
> |
31 |
> One issue is that any valid character is allowed in WPAPSK, including ; |
32 |
|
33 |
Good point, but excluding newline, right? I can't try it, but rt2500's |
34 |
own settings file format does not allow for newline in WPAPSK. So you |
35 |
could simply only use newline as the separator whenever ; is allowed. |
36 |
|
37 |
> $ foo="'one '\'' two' \ |
38 |
> 'three ; four' \ |
39 |
> 'five \ six' \ |
40 |
> " |
41 |
> $ eval set -- "${foo}" ; for x in "$@" ; do echo $x; done |
42 |
> one ' two |
43 |
> three ; four |
44 |
> five \ six |
45 |
> $ |
46 |
> |
47 |
> Demonstrates that we can achieve multi-line arrays like so, without the |
48 |
> need to set shell opts or alter IFS |
49 |
|
50 |
Yeah, you just use eval. :) It has its uses, but personally I would |
51 |
avoid it where possible because it's so easy to get wrong. Just try it |
52 |
with |
53 |
|
54 |
iwpriv_ESSID=" |
55 |
set\ AuthMode=WPAPSK |
56 |
set\ EncrypType=TKIP |
57 |
set\ WPAPSK=pass;key |
58 |
" |
59 |
|
60 |
Failing to properly escape the ; is a user error, but it becomes |
61 |
difficult for baselayout to handle that error properly. Similarly, the |
62 |
backslash-newline combinations are easily left out when you're already |
63 |
editing a string. The format itself I have no problems with, though, so |
64 |
if you have a way to nicely deal with accidental bad input, perhaps |
65 |
using some simple scans, please go for it. |
66 |
|
67 |
(Since the configuration files are only writable by root, I'll ignore |
68 |
the possibility of intentional bad input here.) |