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

Re: Bug report: $program_name in error message

From
Junio C Hamano <gitster@pobox.com>
Date
Dec 19, 2016, 20:50 UTC
Message-ID
<xmqqfuljod70.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<xmqqk2avodi1.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 18 quoted lines
> Comparing these changes that involve "\$variable" ...
>
>  	dashless=$(basename -- "$0" | sed -e 's/-/ /')
>  	usage() {
> -		die "usage: $dashless $USAGE"
> +		die "$(eval_gettext "usage: \$dashless \$USAGE")"
> ... and these that appear in the same patch ...
>
> @@ -190,13 +193,16 @@ cd_to_toplevel () {
>  require_work_tree_exists () {
>  	if test "z$(git rev-parse --is-bare-repository)" != zfalse
>  	then
> -		die "fatal: $0 cannot be used without a working tree."
> +		program_name=$0
> +		die "$(gettext "fatal: \$program_name cannot be used without a working tree.")"
> ...
>  
> tells me that the latter needs to be eval_gettext?
Just for fun:
    $ git grep -n '[^_]gettext .*\\\$'
shows three hits.  Two of them are from that one.
The other is at git-rebase--interactive.sh:440
Perhaps like this to fix.
-- >8 --
Subject: rebase -i: fix mistaken i18n

f2d17068fd ("i18n: rebase-interactive: mark comments of squash for translation", 2016-06-17) attempted to apply sh-i18n and failed to use $(eval_gettext "string with \$variable interpolation").

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 git-rebase--interactive.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 41fd374c72..96865b2375 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -437,7 +437,8 @@ update_squash_messages () {
 			}' <"$squash_msg".bak
 		} >"$squash_msg"
 	else
-		commit_message HEAD > "$fixup_msg" || die "$(gettext "Cannot write \$fixup_msg")"
+		commit_message HEAD >"$fixup_msg" ||
+		die "$(eval_gettext "Cannot write \$fixup_msg")"
 		count=2
 		{
 			printf '%s\n' "$comment_char $(gettext "This is a combination of 2 commits.")"
Previous: Junio C HamanoNext: Stefan Beller
Message 6 of 9 in “Bug report: $program_name in error message”
  1. Josh Bleecher SnyderDec 18, 2016
  2. Stefan BellerDec 18, 2016
  3. Josh Bleecher SnyderDec 18, 2016
  4. Stefan BellerDec 19, 2016
  5. Junio C HamanoDec 19, 2016
  6. Junio C HamanoDec 19, 2016
  7. Stefan BellerDec 19, 2016
  8. Vasco AlmeidaDec 20, 2016
  9. Junio C HamanoDec 20, 2016

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.