git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] bash completion: use read -r everywhere

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 21, 2011, 19:23 UTC
Message-ID
<7v1urxhgpw.fsf@alter.siamese.dyndns.org>
In-Reply-To
<87wr9pkahw.fsf@thomas.inf.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
> Perhaps we can then just fold it into the first paragraph after the
> POSIX quote, like
Well, that is what I tried say so we are on the same page ;-).
Show 7 quoted lines
>   We use the 'read' command without -r, so that it treats '\' as an
>   escape character, in several places.  This breaks the loop reading
>   refnames from git-for-each-ref in __git_refs() if there are refnames
>   such as "foo'bar", in which case for-each-ref helpfully quotes them as
>   in
>
> Or some such.  Do you want me to resend?
Nah, The above as-is is perfectly fine.

By the way, this is not a problem with the patch, but the for-each-ref loop is a poor example. Its --shell option is meant to produce a scriptlet that can be evaled without the buggy processing loop you are fixing, i.e.

	script=$(git for-each-ref --shell --format='
		ref=%(refname:short)
                ref=${ref#*/}
                if [[ "$ref" == "$cur"* ]]
                then
                	...
	' refs/remotes/) &&
        eval "$script"
is how it was designed to be used avoiding shell loops.
>> Does this regress for zsh users in some ways, by the way?
>
> I'm not one of them, but...

Thanks, that was all I wanted to know before deciding if I should apply this directly to 'master' or cook in 'next' to give real zsh users a chance to object or tweak it.

Previous: Thomas Rast
Message 4 of 4 in “bash completion: use read -r everywhere”
  1. bash completion: use read -r everywhereThomas Rast, Dec 21, 2011
  2. Junio C HamanoDec 21, 2011
  3. Thomas RastDec 21, 2011
  4. Junio C HamanoDec 21, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.