On 01/03/11 07:04, Eric Blake wrote:
> Bruce's patch mixes refactoring with bug fixing, making it a bit harder
> to read, and introduced a bug in its own right:

>> -# Avoid meddling by environment variable of the same name.
>> -v=
>> +get_ver()
>> +{
>> +    local PS4='>gv> '
> 
> Portable scripts CANNOT use local (since POSIX does not require it), and
> setting PS4 is not commonly done in portable scripting.

Hi Eric,

That's what I call a "dinkleberry".
Sorry.  Very helpful for debugging tho.....

> I'll probably end up writing yet a third approach, which collects git
> rev-list output into a temporary variable in order to correctly detect
> failures, without refactoring into a helper function.

Dump all stderr to a temp file, print it if needed then remove it?
Presuming that:
   exec 8>&2 2>$TMPDIR/.git-ver-gen-$$
.........
   cat $TMPDIR/.git-ver-gen-$$ >&8
   rm -f $TMPDIR/.git-ver-gen-$$
is portable.

Reply via email to