Re: [PATCH/RFC] completion: filter sources of git scripts from available commands

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

 



SZEDER Gábor <szeder@xxxxxxxxxx> writes:

> Possible solutions to avoid this issue are:
>
> - Strip the current working directory from $PATH temporarily while we run
>   'git help -a' to get all the available commands.  Care must be taken,
>   because '.' can appear at the very beginning, end, or in the middle of
>   $PATH, not to mention that on unixes it's unlikely but possible to have
>   a directory containing e.g. ':.:' in the $PATH.
>
> - Filter out scripts from the output of 'git help -a'.  This can be done
>   by either
>   * listing all possible script extensions, but this list will most likely
>     never be complete, or
>   * filtering out all commands containing a filename extension, i.e.
>     anything with a '.' in it.
>   This will bite users whose custom git commands have filename extensions,
>   i.e. who put 'git-mycmd.sh' in '~/bin'.
>
> Since this is an RFC, it goes with the last option, because that's the
> shortest and simplest.

Would it be another option to re-evaluate the list upon chdir (we
can trap an attempt to "cd", can't we?) _and_ if $PATH might contain
".".  It is OK if the latter criterion is not precise as long as it
does not say "$PATH does not have '.' in it" when it does.

>
> Signed-off-by: SZEDER Gábor <szeder@xxxxxxxxxx>
> ---
>  contrib/completion/git-completion.bash | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index c21190d..9173c41 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -637,6 +637,7 @@ __git_list_all_commands ()
>  	do
>  		case $i in
>  		*--*)             : helper pattern;;
> +		*.*)              : script sources;;
>  		*) echo $i;;
>  		esac
>  	done
--
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]