Re: [PATCH] bash completion: use read -r everywhere
- From
Thomas Rast <trast@student.ethz.ch>
- Date
- Dec 21, 2011, 19:09 UTC
- Message-ID
- <87wr9pkahw.fsf@thomas.inf.ethz.ch>
- In-Reply-To
- <7vipl9hht4.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> Thomas Rast <trast@student.ethz.ch> writes:
>
>> POSIX specifies
>>
>> The read utility shall read a single line from standard input.
>> By default, unless the -r option is specified, backslash ('\')
>> shall act as an escape character...
>>
>> Our omission of -r 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[...]
Show 11 quoted lines
> Thanks.
>
> As this script is specific to bash, it is secondary importance what POSIX
> says. The "-r" option is important only because "bash" happens to follow
> POSIX in this case. I'd like to see the early part of the message reworded
> perhaps like this:
>
> At various points in the script, we use "read" utility without
> giving it the "-r" option that prevents a backslash ('\')
> character to act as an escape character. This breaks e.g. reading
> refnames from ...Perhaps we can then just fold it into the first paragraph after the POSIX quote, like
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?
> Does this regress for zsh users in some ways, by the way?
I'm not one of them, but a quick googling for "zsh builtin read" turns up that it has a dozen options, and -r means
-r
Raw mode: a \ at the end of a line does not signify line continuation. I can't discern whether it treats \ special at all with or without -r.
--
Thomas Rast
trast@{inf,student}.ethz.ch