git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Sixt <j.sixt@viscovery.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Kacper Kornet <draenog@pld-linux.org>,
	Michael J Gruber <git@drmicha.warpmail.net>,
	git@vger.kernel.org
Subject: Re: [PATCH] t1507: change quoting in test_did_you_mean to a more general one
Date: Mon, 09 May 2011 08:39:56 +0200	[thread overview]
Message-ID: <4DC78C3C.6060004@viscovery.net> (raw)
In-Reply-To: <7voc3cqyfp.fsf@alter.siamese.dyndns.org>

Am 5/9/2011 6:40, schrieb Junio C Hamano:
> 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

  reply	other threads:[~2011-05-09  6:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-05 19:10 [PATCH] t1507: change quoting in test_did_you_mean to a more general one Kacper Kornet
2011-05-05 20:02 ` Junio C Hamano
2011-05-06  7:43   ` Michael J Gruber
2011-05-06  8:51     ` Kacper Kornet
2011-05-06  9:14       ` Michael J Gruber
2011-05-06 10:22     ` Johannes Sixt
2011-05-06 11:10       ` Michael J Gruber
2011-05-06 14:23       ` Junio C Hamano
2011-05-09  4:40       ` Junio C Hamano
2011-05-09  6:39         ` Johannes Sixt [this message]
2011-05-09 16:20           ` Junio C Hamano
2011-05-06  8:39   ` Kacper Kornet

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=4DC78C3C.6060004@viscovery.net \
    --to=j.sixt@viscovery.net \
    --cc=draenog@pld-linux.org \
    --cc=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).