Subject: bin/10379: sh expands $? incorrectly within backticks
To: None <>
From: Andreas Gustafsson <>
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
>Originator:     Andreas Gustafsson
>Release:        Jun 13, 2000
Nominum Inc.
System: NetBSD 1.4ZD NetBSD 1.4ZD (TREBUCHET) #0: Tue Jun 13 19:34:23 PDT 2000 i386


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



   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.


Not known.