Bug 155778 - awk(1) doesn't set error exit status on errors
Summary: awk(1) doesn't set error exit status on errors
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 8.2-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Warner Losh
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-22 11:00 UTC by Dmitry Marakasov
Modified: 2023-09-17 14:09 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Marakasov freebsd_committer freebsd_triage 2011-03-22 11:00:01 UTC
awk doesn't set error exit status on errors:

% awk '{if ($1 == '1') print 2}' <&- && echo OK || echo FAILED
awk: i/o error occurred on /dev/stdin
 source line number 1
awk: i/o error occurred while closing /dev/stdin
 source line number 1
OK

GNU awk, however, behaves correctly:

% gawk '{if ($1 == '1') print 2}' <&- && echo OK || echo FAILED 
gawk: cmd. line:1: fatal: error reading input file `-': Bad file descriptor
FAILED

How-To-Repeat: See description.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 07:59:53 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Warner Losh freebsd_committer freebsd_triage 2021-07-20 01:46:46 UTC
This now causes a hang in ota.
Comment 3 Warner Losh freebsd_committer freebsd_triage 2023-09-17 14:09:42 UTC
The awk that's in 14.0 fixes this. I'm not sure which earlier releases this affects.