Re: [PATCH] bash completion: use read -r everywhere
From: Thomas Rast <hidden>
Date: 2016-06-15 22:52:41
Junio C Hamano [off-list ref] writes:
Thomas Rast [off-list ref] writes:quoted
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
[...]
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