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

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



Eric Blake wrote:
> 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.

Thanks.  Pushed.

> How'd you find it?  I know we've talked about adding a maint.mk check to

I simply used

    git grep 'echo -e'

Maybe that's good enough for now.

> 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.


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