From: Johannes Sixt <j.sixt@viscovery.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Jonathan Nieder <jrnieder@gmail.com>
Subject: Re: [PATCH 1/6] i18n win32: add git-am eval_gettext variable prefix
Date: Thu, 26 May 2011 08:34:43 +0200 [thread overview]
Message-ID: <4DDDF483.70805@viscovery.net> (raw)
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;
/*
next prev parent reply other threads:[~2011-05-26 6:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-25 23:19 [PATCH 0/6] i18n: Windows shellscript support Ævar Arnfjörð Bjarmason
2011-05-25 23:19 ` [PATCH 1/6] i18n win32: add git-am eval_gettext variable prefix Ævar Arnfjörð Bjarmason
2011-05-26 6:34 ` Johannes Sixt [this message]
2011-05-26 14:13 ` Junio C Hamano
2011-05-26 14:59 ` Johannes Sixt
2011-05-26 15:16 ` Ævar Arnfjörð Bjarmason
2011-05-25 23:19 ` [PATCH 2/6] i18n win32: add git-bisect " Ævar Arnfjörð Bjarmason
2011-05-25 23:19 ` [PATCH 3/6] i18n win32: add git-pull " Ævar Arnfjörð Bjarmason
2011-05-25 23:19 ` [PATCH 4/6] i18n win32: add git-stash " Ævar Arnfjörð Bjarmason
2011-05-25 23:19 ` [PATCH 5/6] i18n win32: add git-submodule " Ævar Arnfjörð Bjarmason
2011-05-25 23:19 ` [PATCH 6/6] i18n win32: add test " Ævar Arnfjörð Bjarmason
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=4DDDF483.70805@viscovery.net \
--to=j.sixt@viscovery.net \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.