[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Gettextize: using functions?
From: |
Tim Mooney |
Subject: |
Re: Gettextize: using functions? |
Date: |
1 May 2002 20:21:22 GMT |
In article <address@hidden>,
Andreas Schwab <address@hidden> wrote:
> address@hidden (Tim Mooney) writes:
>
> |>
> |> In any case, if autoconf (or the GNU coding standards) is going to relax
> its
> |> stance on shell functions, I would suggest that the documentation be very
> |> explicit about using the older function style
> |>
> |> foo() {
> |> }
> |>
> |> vs. the newer style supported by Korn/Bash/POSIX shells,
> |>
> |> function foo {
> |> }
>
> It's the other way round: POSIX uses the 'foo ()' syntax, and 'function
> foo' has unspecified effect.
I'm not sure I understand.
More-or-less traditional Bourne shells *don't* grok
#! /bin/sh
function foo {
echo "hi"
}
foo
Examples of shells that choke on this: /bin/sh on Tru64 or Solaris.
However, if you take the file and use the POSIX interpreter on either of
those platforms (/usr/bin/posix/sh on Tru64, /usr/xpg4/bin/sh on Solaris),
it works fine.
If you instead do
#! /bin/sh
foo() {
echo "hi"
}
foo
then that will work with both older Bourne shells (like /bin/sh on Solaris
or Tru64) and newer shells like the POSIX shell, Korn shell, bash, etc.
In other words, the only shells I can find that *do* grok `function foo'
are the ones that claim to be closer to POSIX than traditional Bourne.
Using the foo() { ... } style functions is what I'm advocating should be
strongly recommended in the documentation, if functions are no longer
anathema.
Tim
--
Tim Mooney address@hidden
Information Technology Services (701) 231-1076 (Voice)
Room 242-J6, IACC Building (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164
- Re: Gettextize: using functions?,
Tim Mooney <=