Re: [libvirt] [PATCH] schematestutils.sh: improve shell portability: avoid "echo -e"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]