Subject: bin/10379: sh expands $? incorrectly within backticks
To: None <gnats-bugs@gnats.netbsd.org>
From: Andreas Gustafsson <gson@nominum.com>
List: netbsd-bugs
Date: 06/16/2000 14:04:18
>Number:         10379
>Category:       bin
>Synopsis:       sh expands $? incorrectly within backticks
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jun 16 14:05:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Andreas Gustafsson
>Release:        Jun 13, 2000
>Organization:
Nominum Inc.
>Environment:
System: NetBSD trebuchet.rc.vix.com 1.4ZD NetBSD 1.4ZD (TREBUCHET) #0: Tue Jun 13 19:34:23 PDT 2000 gson@trebuchet.rc.vix.com:/usr/src/sys/arch/i386/compile/TREBUCHET i386


>Description:

When used within backticks, the shell variable $? expands to 0
even if the previous shell command exited witih a nonzero status.

>How-To-Repeat:

Type

   sh -c 'false; echo `echo "$?"`'

On NetBSD-current, this prints 0, which is incorrect.  On NetBSD 1.4
and the half dozen other Unix-like systems I have tried, it correctly
prints an nonzero value.

>Fix:

Not known.
>Release-Note:
>Audit-Trail:
>Unformatted: