Re: [PATCH] bash: offer only paths after '--'

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

 



SZEDER Gábor <szeder@xxxxxxxxxx> writes:

> On Tue, Jul 08, 2008 at 11:18:37PM +0000, Shawn O. Pearce wrote:
>> Junio C Hamano <gitster@xxxxxxxxx> wrote:
>> > SZEDER Gábor <szeder@xxxxxxxxxx> writes:
>> > > +		c=$((++c))
>> > 
>> > This assignment is somewhat curious, although it should work as expected
>> > either way ;-)
> ...
> Maybe an old C++ "heritage"?  In C++ it matters for class types (e.g.
> iterators), because the postfix operator might be slower than the
> prefix.

Heh, I was not talking about prefix vs postfix but about the assignment
into the variable that is incremented as a side effect of evaluating the
left hand side.  If you know the variable is incremented already there is
no point in assigning the resulting value to it ;-)

	c=$(( $c + 1 ))

would have avoided such an uneasy feeling, and would have been more
portable.  Even though $((x)) and $(($x)) are supposed to evaluate the
same, some shells do not like dollar-less variable names in arithmetic
expansion, and prefix/postfix increment/decrement are not required to be
supported by POSIX.

But this script being bash completion, we can use as much bashism as we
want here; perhaps I would have written:

	: $((c++))
        
--
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]

  Powered by Linux