[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sh portability questions

From: Akim Demaille
Subject: sh portability questions
Date: Tue, 27 Sep 2005 13:53:02 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux)

Now that there are no doubts about the portability of shell functions
(in the sense that there's always a shell on the machine that supports
function ---and maybe the documentation should reflect this), I'm
curious about the support of "return" and "local".  Is there anything
known about them?  ISTR there were spies about return in the Autoconf
test suite, but there seems to be nothing about it today
(hum... wrong, there is now something in m4sh.m4 that looks for
"return" support, see below).


# -----------------
# This is a spy to detect "in the wild" shells that do not support shell
# functions correctly.  It is based on the Autotest testcases.
[as_func_return () {
  (exit [$]1)
as_func_success () {
  as_func_return 0
as_func_failure () {
  as_func_return 1
as_func_ret_success () {
  return 0
as_func_ret_failure () {
  return 1

AS_IF([as_func_success], [],
  echo as_func_success failed.])
  echo as_func_failure succeeded.])
AS_IF([as_func_ret_success], [],
  echo as_func_ret_success failed.])
  echo as_func_ret_failure succeeded.])
AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
  echo positional parameters were not saved.])
test $exitcode = 0])

reply via email to

[Prev in Thread] Current Thread [Next in Thread]