tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Proposal to add /usr/bin/shquote
Date: Sat, 6 Sep 2008 18:34:40 +0200
From: Alan Barrett <apb%cequrux.com@localhost>
Message-ID: <20080906163440.GR1374%apb-laptoy.apb.alt.za@localhost>
| Yes, sure, I can do that. My point is that I don't want to write
| unreadable code over and over again (and risk getting it wrong) when a
| simple utility could do the job.
I agree, I think the cmd should be added. It is so easy to get this
right, most of the time, so only unusual cases trip it up, that having it
done properly, and then available for easy use is the right thing to do.
I believe that even more now you pointed out that the libc function exists
(I hadn't seen that one before) - commands that provide wrappers around
useful libc functions are almost always a good idea.
My only reservation might be that while shell quoting is a very common need,
we also need quoting for other programs - the one I see most is for sed
patterns - pkgsrc could really do with that one, when you consider the
number of times that it does stuff like
sed 's/PREFIX/${PREFIX}/'
and then imaging the user who, instead of /usr/pkg decides to stick their
packages in /usr/packages&extras or something (add spaces if you like but
they're irrelevant in this context).
That is, I'd kind of like to be able to quote in the appropriate way for
the most common commands that need it, rather than just sh, but as just
a wrapper around shquote(3), I doubt that's quite so easy.
kre
ps: there are a couple of bugs in the code samples in the shquote(3)
man page - one is just a *roff usage error, using \0 instead of \e0
(the former is a space, the latter generates \0). The other (that
I noticed, there might of course be more) is a logic error (actually
repeated in each of the two examples) - I'll leave that as an exercise
for the reader...
Home |
Main Index |
Thread Index |
Old Index