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

Re: [PATCH] t1507: change quoting in test_did_you_mean to a more general one

From
Johannes Sixt <j.sixt@viscovery.net>
Date
May 9, 2011, 06:39 UTC
Message-ID
<4DC78C3C.6060004@viscovery.net>
In-Reply-To
<7voc3cqyfp.fsf@alter.siamese.dyndns.org>
Am 5/9/2011 6:40, schrieb Junio C Hamano:
Show 9 quoted lines
> Johannes Sixt <j.sixt@viscovery.net> writes:
> 
>> - The behavior of quoting at the right of :- when the ${...:-...} exansion
>> appears in double-quotes was debated recently at length at the Austin
>> group (which revises the POSIX standard). You better move the expansions
>> to assignments of temporary variables,...
> 
> What alternative semantics do Austin folks have in mind, by the way?  Just
> declare this undefined?

Most of the debate centered around how to quote a closing brace: the problem is that usually the backslash within double-quotes is only special when followed by $, `, or \, therefore, it should not be possible to quote a closing brace using \}. It turned out that different shells handled this particular case differently. IIRC, there were also discrepancies whether whitespace generated on the RHS of :- (or other operators) was retained or discarded. The conclusion for us as application developers is not to depend on too many subtle details in such a variable expansions because the specification is too vague, shells implement it differently, and some even get it outright wrong (as the case discovered by Kascper).

> -	printf "fatal: Path '$2$3' $4, but not ${5:-'$3'}.\n" >expected &&
> -	printf "Did you mean '$1:$2$3'${2:+ aka '$1:./$3'}?\n" >>expected &&
> +	sq="'"
This cuts the && chain.
> +	cat >expected <<-EOF &&
> +	fatal: Path '$2$3' $4, but not ${5:-$sq$3$sq}.
> +	Did you mean '$1:$2$3'${2:+ aka $sq$1:./$3$sq}?
> +	EOF

Looks good otherwise; I tested this with various shells, and there were no surprises.

-- Hannes
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 12 in “t1507: change quoting in test_did_you_mean to a more general one”
  1. t1507: change quoting in test_did_you_mean to a more general oneKacper Kornet, May 5, 2011
  2. Junio C HamanoMay 5, 2011
  3. Michael J GruberMay 6, 2011
  4. Kacper KornetMay 6, 2011
  5. Michael J GruberMay 6, 2011
  6. Johannes SixtMay 6, 2011
  7. Michael J GruberMay 6, 2011
  8. Junio C HamanoMay 6, 2011
  9. Junio C HamanoMay 9, 2011
  10. Johannes SixtMay 9, 2011
  11. Junio C HamanoMay 9, 2011
  12. Kacper KornetMay 6, 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.