Re: [PATCHv5 16/16] Introduce portable_unset and use it to ensure proper && chaining

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

 



Jonathan Nieder <jrnieder@xxxxxxxxx> writes:

> Elijah Newren wrote:
>
>> --- a/t/test-lib.sh
>> +++ b/t/test-lib.sh
>> @@ -268,6 +268,10 @@ remove_cr () {
>>  	tr '\015' Q | sed -e 's/Q$//'
>>  }
>>  
>> +portable_unset () {
>> +	unset $* || true
>> +}
>
> I think this should read
>
> 	portable_unset () {
> 		unset "$@"
> 		return 0
> 	}
>
> (or || true).  That is, if I try
>
> 	portable_unset "foo bar"
>
> then on platforms where an envvar named "foo bar" is allowed,
> this should unset it, no?

Yes, or closer to Elijah's original:

	unset "$@" || true

I do not think calling this "portable_" makes much sense, though.  Maybe
depending on the exit status of "unset" may be unportable, but the wrapper
does not make unset portable.  It just picks one behaviour we happen to
like among the possible two (one being "unset always succeeds" vs the
other being "unset errors out if you feed an unset variable").

I have no objection against calling it "sane_unset", though.  It makes it
crystal clear that the semantics wrapper implements is what we picked
because we like (i.e. deem the sanest among alternatives).
--
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]