Re: [PATCH 3/3] Revert "bash prompt: avoid command substitution when finalizing gitstring"

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

 



On Wed, Aug 21, 2013 at 5:22 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:
> Brandon Casey <drafnel@xxxxxxxxx> writes:
>
>> On Wed, Aug 21, 2013 at 2:47 PM, Junio C Hamano <gitster@xxxxxxxxx> wrote:

>>>         # on load...
>>>         printf -v __git_printf_supports_v -- "%s" yes >/dev/null 2>&1
>>>
>>>         ...
>>>
>>>         if test "${__git_printf_supports_v}" = yes
>>>         then
>>>                 printf -v gitstring -- "$printf_format" "$gitstring"
>>>         else
>>>                 gitstring=$(printf -- "$printf_format" "$gitstring")
>>>         fi
>>
>> Yes, that appears to work.
>
> A real patch needs to be a bit more careful, though.  The variable
> needs to be cleared before all of the above,

Agreed.

> and the testing would
> want to consider that the variable may not be set (i.e. use
> "${var-}" when checking).

Why is "${var-}" necessary?  Wouldn't that be equivalent to "${var}"
or "$var"?  We obviously wouldn't want to do 'if test $var = yes', but
I would have thought it was sufficient to wrap the variable
dereference in quotes as your original did.

-Brandon
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]