Subject: Re: gtar 1.13.25 configure fails on FreeBSD/NetBSD due to sh bug
To: Paul Eggert <eggert@twinsun.com>
From: Simon Burge <simonb@wasabisystems.com>
List: netbsd-bugs
Date: 11/05/2001 22:54:02
[ CC list trimmed slightly ]

Paul Eggert wrote:

> > From: Christian Weisgerber <naddy@freebsd.org>
> > Date: Mon, 5 Nov 2001 01:33:48 +0100
> > 
> >     test $jm_cv_func_decl_free != yes
> > 
> >     cat >>confdefs.h <<EOF
> >     #define HAVE_DECL_FREE $?
> >     EOF
> > 
> > FreeBSD's /bin/sh resets $? when it starts evaluating the redirections,
> > so the symbol is always defined to 0 regardless of the previous
> > test result.  That probably qualifies as a shell bug,
> 
> It sure does.  I'll CC: this message to freebsd-bugs and netbsd-bugs
> to let them know about the bug.
> 
> Thanks for the bug report.  I'll install a workaround in the next
> test version of GNU tar.

Surely the answer isn't as simple as:

Index: eval.c
===================================================================
RCS file: /cvsroot/basesrc/bin/sh/eval.c,v
retrieving revision 1.57
diff -d -p -u -r1.57 eval.c
--- eval.c	2001/02/04 19:52:06	1.57
+++ eval.c	2001/11/05 11:48:24
@@ -436,7 +436,6 @@ expredir(n)
 	for (redir = n ; redir ; redir = redir->nfile.next) {
 		struct arglist fn;
 		fn.lastp = &fn.list;
-		oexitstatus = exitstatus;
 		switch (redir->type) {
 		case NFROMTO:
 		case NFROM:

The insides of sh(1) scare me, but the above seems to work ok.  We
don't have any regression tests for sh, but I've tried building a
couple of packages that use both GNU configure and libtool which
seem like reasonable torture tests for sh, and these built ok.

Simon.
--
Simon Burge                            <simonb@wasabisystems.com>
NetBSD CDs, Support and Service:    http://www.wasabisystems.com/