autoconf-patches
[Top][All Lists]
Advanced

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

[PATCH] Condense the shell function test


From: Paolo Bonzini
Subject: [PATCH] Condense the shell function test
Date: Thu, 30 Oct 2008 10:29:10 +0100
User-agent: Thunderbird 2.0.0.17 (Macintosh/20080914)

This patch shortens m4sh scripts by 30 lines approximately.  There is
already enough cruft at the beginning of those scripts!

Ok?  Does it make sense, more precisely?

Paolo
commit 4298bf09e470242b2ef50a514e1d729d494766c9
Author: Paolo Bonzini <address@hidden>
Date:   Thu Oct 30 10:23:40 2008 +0100

    trim down the length of the shell function test
    
    * lib/m4sugar/m4sh.m4 (_AS_SHELL_FN_WORK): Condense.

diff --git a/lib/m4sugar/m4sh.m4 b/lib/m4sugar/m4sh.m4
index 1416587..e097e1e 100644
--- a/lib/m4sugar/m4sh.m4
+++ b/lib/m4sugar/m4sh.m4
@@ -387,43 +387,19 @@ m4_define([_AS_RUN],
 # This is a spy to detect "in the wild" shells that do not support shell
 # functions correctly.  It is based on the m4sh.at Autotest testcases.
 m4_define([_AS_SHELL_FN_WORK],
-[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_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; }
 
 exitcode=0
-AS_IF([as_func_success], [],
-  [exitcode=1
-  echo as_func_success failed.])
-AS_IF([as_func_failure],
-  [exitcode=1
-  echo as_func_failure succeeded.])
-AS_IF([as_func_ret_success], [],
-  [exitcode=1
-  echo as_func_ret_success failed.])
-AS_IF([as_func_ret_failure],
-  [exitcode=1
-  echo as_func_ret_failure succeeded.])
+as_func_success || { exitcode=1; echo as_func_success failed.; }
+as_func_failure && { exitcode=1; echo as_func_failure succeeded.; }
+as_func_ret_success || { exitcode=1; echo as_func_ret_success failed.; }
+as_func_ret_failure && { exitcode=1; echo as_func_ret_failure succeeded.; }
 AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
-  [exitcode=1
-  echo positional parameters were not saved.])
+      [exitcode=1; echo positional parameters were not saved.])
 test x$exitcode = x0[]])# _AS_SHELL_FN_WORK
 
 

reply via email to

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