[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] tests: remove all unportable uses of echo
From: |
Jim Meyering |
Subject: |
Re: [PATCH] tests: remove all unportable uses of echo |
Date: |
Thu, 01 Apr 2010 19:26:22 +0200 |
Eric Blake wrote:
> On 04/01/2010 11:07 AM, Jim Meyering wrote:
>> Eric Blake wrote:
>>> On 04/01/2010 04:17 AM, Jim Meyering wrote:
>>>>
>>>> +sc_prohibit_echo_minus_en:
>>>> + @re='\<echo -[en]' \
>>>> + msg='do not use echo ''-e or echo ''-n; use printf instead' \
>>>> + $(_prohibit_regexp)
>>>
>>> This would be nice in gnulib, alongside the rule against test -a.
>>
>> Yes, it's on my list.
>
> While we're at it, can $re be broadened to catch other unportable usage
> patterns? Pretty much _any_ leading - is unportable, as is any embedded
> \, and since $ or ` for command substitution can hide \, they are worth
> checking as well. In other words, I'm thinking:
>
> @re='\<echo (-|.*[$`\])'
Relaxing it to catch any leading '-' would be good.
But the .*... part looks like it would evoke too many false
positive matches. e.g., echo fine; t=`some-command`; u=$v;
or echo 'something inoffensive' # oops `...` \012 $var
> with a corresponding change in $msg.
But if you come up with a regexp that provokes few FPs
in a reasonable sampling of projects (I'd check coreutils,
libvirt, grep if I were doing it) then you're welcome to add it.