[libvirt] [PATCH] schematestutils.sh: improve shell portability: avoid "echo -e"
Eric Blake
eblake at redhat.com
Wed Apr 14 14:31:34 UTC 2010
On 04/14/2010 05:28 AM, Jim Meyering wrote:
> echo -e is not portable.
> This is the sole remaining use in all of libvirt.
ACK.
How'd you find it? I know we've talked about adding a maint.mk check to
help automate some of this (was it over on the bug-grep list?), but I
still haven't thought of a good regexp that doesn't suffer from too many
false positives (in particular, distinguishing between \ as arguments to
echo vs. \ as line continuation can be hard) while still catching the
worst offenders. Right now, about the best regex I can think of is:
'echo .?[$-]'
which will filter out:
echo -n oops
echo -e oops
echo "$oops"
where the first two are blatantly wrong, and the third might be a false
positive if you can audit $oops for safety. It would also have a FP on:
echo a-b
although that is less likely, and it totally misses echo 'a\\b', but you
can only do so much.
--
Eric Blake eblake at redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100414/ebd5d00b/attachment-0001.sig>
More information about the libvir-list
mailing list