git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Ville Skyttä" <ville.skytta@iki.fi>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] completion: avoid aliased command lookup error in nounset mode
Date: Fri, 16 Apr 2021 13:40:46 -0700	[thread overview]
Message-ID: <xmqq7dl2klo1.fsf@gitster.g> (raw)
In-Reply-To: <20210416191939.1120651-1-ville.skytta@iki.fi> ("Ville =?utf-8?Q?Skytt=C3=A4=22's?= message of "Fri, 16 Apr 2021 22:19:39 +0300")

Ville Skyttä <ville.skytta@iki.fi> writes:

> Aliased command lookup accesses the `list` variable before it has been
> set, causing an error in "nounset" mode. Initialize to an empty string
> to avoid that.
>
>     $ git nonexistent-command <Tab>bash: list: unbound variable
>
> Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
> ---
>  contrib/completion/git-completion.bash | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, will queue.

> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index dfa735ea62..49e76e9d08 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1129,7 +1129,7 @@ __git_pretty_aliases ()
>  # __git_aliased_command requires 1 argument
>  __git_aliased_command ()
>  {
> -	local cur=$1 last list word cmdline
> +	local cur=$1 last list= word cmdline
>  
>  	while [[ -n "$cur" ]]; do
>  		if [[ "$list" == *" $cur "* ]]; then

      reply	other threads:[~2021-04-16 20:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-16 19:19 [PATCH] completion: avoid aliased command lookup error in nounset mode Ville Skyttä
2021-04-16 20:40 ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq7dl2klo1.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=ville.skytta@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).