[prog] Shell question...
John Clarke
johnc+linuxchix at kirriwa.net
Mon Dec 13 11:47:48 EST 2004
On Sat, Dec 11, 2004 at 03:18:44 +0100, Riccarda Cassini wrote:
> >
> > You have way too much time on your hands :-)
>
> Heh, I'd rather call it applied ISO 9000 / QA testing ;-)
Your boss might believe you, but you and I both know I'm right :-)
> > echo "$1='$VALUE'"
>
> Then, what about bl'a ? ;-)
>
> This may seem like just being silly. Well, it is. However, there's a
> kernel of truth in it... Is there an (easy) way to make this approach
> robust against any kind of special characters, like " ' $ \ etc.?
Good question. I think it's possible, but it's not easy to handle all
metacharacters anywhere in the string. Not in shell anway, because
there isn't a great range of substitution available -- bash has
${var//pattern/replacement} but I couldn't get it to do all characters.
You also have to protect against several levels of shell interpolation
(the outer script, read_vars.sh, and the eval) which, as you've already
discovered, soon needs way too many backslashes. I played with it for a
minute or two and found a couple of different ways to handle quotes, but
I couldn't make it do $. Eventually you decide it's easier to do it in
perl or C :-)
> Probably not all that relevant in my case, but you know, in general,
> when it doesn't cost much, it's always better to do things the right
> way *before* you have a raging client on the phone...
That's true, but if you was done right the first time you wouldn't be
trying to fix it now, would you?
Cheers,
John
--
The indication need not be a dialog box; it could be an icon (for example,
a picture of a rotting fish) or some other indicator.
-- RFC 2616 (HTTP/1.1), section 13.1.4
More information about the Programming
mailing list