Re: [PATCH v2] contrib/subtree: fix split with squashed subtrees

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

 



On 9/9/25 21:02, Junio C Hamano wrote:
Besides, "if test -n ${subtree_dir-}" without colon would be the
more proper way for those who care about "set -u", wouldn't it?  It
is not that you want to substitute with an empty string that comes
between that "-" and "}" when subtree_dir is unset or set to empty.
You are preparing for the case where the variable is truly not set,
and the variable being set to an empty string is not something you
are worried about.
Yes, "test -n ${subtree_dir-}" is definitely the more correct expression.

At the very real risk of embarrassing myself in public today... in the particular case of a "test -n," is there actually an appreciable difference? Either way, the output of the substitution is empty if the input is empty or undefined. Here, "test -n ${subtree_dir:-}" is merely less efficient. Right?

The difference between "${x:-}" vs "${x-}" really starts to matter if you want to permit the empty string (or not). It also matters if you call a command that has side effects.

(And in the context of this patch, neither are necessary.)





[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