Bug 30392

Summary: sh: incorrect value of $? in here-documents
Product: Base System Reporter: Christian Weisgerber <naddy>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   

Description Christian Weisgerber 2001-09-06 15:50:00 UTC
In here-documents, sh expands $? to the return value of the current
command rather than that of the previous command.

This behavior differs from that of all other Bourne family shells
I have tested (bash 2.05, ksh93 2001-07-04, pdksh 5.2.14, zsh 4.0.2,
Solaris 7 /usr/bin/sh and /usr/bin/ksh).

I noticed this because it breaks the evaluation of several
(non-critical) tests in the configure script of gtar 1.13.22.

How-To-Repeat: 
------->
false
cat >>foo <<EOF
$?
EOF
cat foo
<-------

Returns 0 for FreeBSD sh, 1 for all other shells.
Comment 1 Maxim Konovalov freebsd_committer freebsd_triage 2004-07-18 07:38:47 UTC
State Changed
From-To: open->closed

Duplicate of bin/41410.