Re: [PATCH 1/2] Add infrastructure for translating Git with gettext
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jun 14, 2010, 22:51 UTC
- Message-ID
- <AANLkTimpb9_91SOCR_SkA38Iwi6LQzu3ejxgtmyHe6tA@mail.gmail.com>
- In-Reply-To
- <201006142356.46780.trast@student.ethz.ch>
On Mon, Jun 14, 2010 at 21:56, Thomas Rast <trast@student.ethz.ch> wrote:
Show 24 quoted lines
> Ævar Arnfjörð Bjarmason wrote: >> It turns out that this doesn't actually work, and I can't find a >> workaround. In Bash and Solaris's /bin/sh this executes until "dies >> here". The problem is that I can't use the subshell trick, since the >> gettext.sh inclusion has to be done in the current shell (I checked, >> tests will fail). >> >> #!/bin/sh >> (. does-not-exist.sh) >> echo "A subshell made it! ret = $?" >> . does-not-exist.sh >> # dies here >> echo "A real shell made it! ret = $?" >> >> Is there some clever shellscript trick that I'm missing, or will I >> have to resort to modifying the file at `make' time for this to work >> everywhere? > > Works for me in bash (4.0.35), but fails the way you say in dash (if > only I could figure out the option that tells me the version!). > > This works however: > > type does-not-exist.sh 2>/dev/null && . does-not-exist.sh
Thanks. That works, I've tested the following script:
#!/bin/sh
type meh.sh >/dev/null 2>&1 && . meh.sh && echo "Included meh.sh"
|| echo "Didn't include meh.sh"
echo "I've made it!"
type gettext.sh >/dev/null 2>&1 && . gettext.sh && echo "Included
gettext.sh" || echo "Didn't include gettext.sh"
echo "I've made it!"On the following:
FreeBSD: /bin/sh, bash
Solaris: /bin/sh, /usr/bin/ksh, bash,
Debian: dash, bashThey all make it to the last "I've made it!".
> I suspect it only works if the script is executable, as otherwise type > would not find it (but . would). But at least on my system, it is.
With gettext.sh the assumption that it's +x seems valid, the installation script for GNU gettext always gives it an executable bit.