Re: [PATCH v2 4/4] completion: be nicer with zsh
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Jan 30, 2012, 19:28 UTC
- Message-ID
- <20120130192834.GA28920@burratino>
- In-Reply-To
- <CAMP44s0dU5zQLnen_DSONOum7P1UsPTASSkF1sJE2m7kAwx21A@mail.gmail.com>
Felipe Contreras wrote:
Show 10 quoted lines
> What would you rather use? > > [ "$__git_merge_strategies" ] && > __git_merge_strategies=$(__git_list_merge_strategies) > > That's 90 characters long. Although much better without the 2>/dev/null. > > if [ "$__git_merge_strategies" ]; then > __git_merge_strategies=$(__git_list_merge_strategies) > fi
Neither, since they both have the test inverted. But I prefer to explicitly use the "-n" operator.
[[ -n $__git_merge_strategies ]] || __git_merge_strategies=$(__git_list_merge_strategies)
seems as fine as any other spelling to me. It means "either this value has already been computed and cached, or we need to compute it".