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

Re: [PATCH 1/6] i18n win32: add git-am eval_gettext variable prefix

From
Johannes Sixt <j.sixt@viscovery.net>
Date
May 26, 2011, 06:34 UTC
Message-ID
<4DDDF483.70805@viscovery.net>
In-Reply-To
<1306365594-22061-2-git-send-email-avarab@gmail.com>
Am 5/26/2011 1:19, schrieb Ævar Arnfjörð Bjarmason:
> -		eval_gettext 'Patch failed at $msgnum $FIRSTLINE'; echo
> +		GIT_I18N_VARIABLE_msgnum=$msgnum
> +		GIT_I18N_VARIABLE_FIRSTLINE=$FIRSTLINE
> +		eval_gettext 'Patch failed at $GIT_I18N_VARIABLE_msgnum $GIT_I18N_VARIABLE_FIRSTLINE'; echo
That's not pretty.

I wonder whether it is possible to automate the variable prefix. Looking at the definition of eval_gettext()

eval_gettext () {
	printf "%s" "$1" | (
		export PATH $(git sh-i18n--envsubst --variables "$1");
		git sh-i18n--envsubst "$1"
	)
}

I gather that the actual substitution of variable values is done by sh-i18n--envsubst, and not by the shell (right?). Let's look at an example:

	git sh-i18n--envsubst --variables '$foo and $bar'
produces
	foo
	bar
What if it produced
	GIT_I18N_VARIABLE_foo=$foo
	GIT_I18N_VARIABLE_bar=$bar
	export GIT_I18N_VARIABLE_foo GIT_I18N_VARIABLE_bar
then the definition of eval_gettext() would look like
eval_gettext () {
	printf "%s" "$1" | (
		export PATH
		eval "$(git sh-i18n--envsubst --variables "$1")"
		git sh-i18n--envsubst "$1"
	)
}

and the second call of sh-i18n--envsubst should replace $foo and $bar that it sees on stdin by the values of GIT_I18N_VARIABLE_foo and GIT_I18N_VARIABLE_bar from the environment.

What do you think?

BTW, if you re-roll the series, would you mind shortening the prefix to, say, _I18N__ because on Windows the variables names count towards the environment budget, which is restricted to 32k characters.

BTW2, the following patch is needed to avoid a crash of an invocation of 'git sh-i18n--envsubst' without arguments.

-- Hannes
(Warning: hand-edited patch text)
diff --git a/sh-i18n--envsubst.c b/sh-i18n--envsubst.c
index 7125093..8104973 100644
--- a/sh-i18n--envsubst.c
+++ b/sh-i18n--envsubst.c
@@ -76,2 +76,3 @@ main (int argc, char *argv[])
 	  error ("we won't substitute all variables on stdin for you");
+	  break;
 	  /*
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 3 of 11 in “i18n: Windows shellscript support”
  1. 0/6 i18n: Windows shellscript supportÆvar Arnfjörð Bjarmason, May 25, 2011
  2. 1/6 i18n win32: add git-am eval_gettext variable prefixÆvar Arnfjörð Bjarmason, May 25, 2011
  3. Johannes SixtMay 26, 2011
  4. Junio C HamanoMay 26, 2011
  5. Johannes SixtMay 26, 2011
  6. Ævar Arnfjörð BjarmasonMay 26, 2011
  7. 2/6 i18n win32: add git-bisect eval_gettext variable prefixÆvar Arnfjörð Bjarmason, May 25, 2011
  8. 3/6 i18n win32: add git-pull eval_gettext variable prefixÆvar Arnfjörð Bjarmason, May 25, 2011
  9. 4/6 i18n win32: add git-stash eval_gettext variable prefixÆvar Arnfjörð Bjarmason, May 25, 2011
  10. 5/6 i18n win32: add git-submodule eval_gettext variable prefixÆvar Arnfjörð Bjarmason, May 25, 2011
  11. 6/6 i18n win32: add test eval_gettext variable prefixÆvar Arnfjörð Bjarmason, May 25, 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.