Re: [PATCH v2 1/3] completion: bash: add __git_have_func helper

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

 



Felipe Contreras <felipe.contreras@xxxxxxxxx> writes:

>> Anyway, this seems to work for me:
>> 
>> 	__git_have_func () {
>> 		case "$1" in
>> 		-*) return 1 ;;
>> 		esac
>> 		declare -F "$1" >/dev/null 2>&1
>> 	}
>
> I wondered some of those things too, but opted for the minimal approach.
>
> Your change seems good to me, however I prefer this to the case
> statement:
>
>   [[ "$1" == -* ]] && return 1
>
> But doesn't seem to be too welcomed in git's bash style.

Actually, there is no formal "bash style" guide for our codebase.
In bash completion script, you are free to use any bashisms as you
find convenient, as long as it is consistent with the surrounding
code.

As SZEDER and you later agree in the downthread, Zsh compatibility
would be a lot more important than sticking to general POSIX shell
subset (and following our shell style guide for the rest of the
system that tries hard to be independent from bashism) when
improving this script.

> Looks like this would be prefered:
>
>   if [[ "$1" == -* ]]; then
>     return 1
>   fi

This is another example that we do not apply the shell style guide
in Documentation/CodingGuidelines to this script (if we did, we
wouldn't see the semicolon there).

Thanks.



[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