Bug 187728 - [patch] bc(1) should print error message to stderr
Summary: [patch] bc(1) should print error message to stderr
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
Depends on:
Reported: 2014-03-19 09:50 UTC by ksmakoto
Modified: 2017-12-31 22:27 UTC (History)
0 users

See Also:

file.diff (993 bytes, patch)
2014-03-19 09:50 UTC, ksmakoto
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ksmakoto 2014-03-19 09:50:00 UTC
bc(1) should prints error message to stderr. For example,

UNIX (Heirloom) bc prints to stderr
$ echo ':' | /usr/local/heirloom/usr/5bin/bc > /dev/null
syntax error on line 1, teletype
$ echo ':' | /usr/local/heirloom/usr/5bin/bc 2> /dev/null

GNU bc prints to stderr
$ echo ':' | /usr/local/bin/bc > /dev/null
(standard_in) 1: illegal character: :
$ echo ':' | /usr/local/bin/bc 2> /dev/null

FreeBSD (OpenBSD) bc prints to stdout
$ echo ':' | /usr/bin/bc > /dev/null
$ echo ':' | /usr/bin/bc 2> /dev/null
bc: stdin:1: illegal character: : unexpected

Fix: see attached patch

Patch attached with submission follows:
How-To-Repeat: see Full Description
Comment 1 Jilles Tjoelker freebsd_committer 2014-03-23 18:20:25 UTC
In PR bin/187728, you wrote:
> bc(1) should prints error message to stderr.

POSIX seems to require this in interactive mode; in non-interactive
mode, invalid input causes undefined behaviour.

Note that the patch changes more than just the destination of the error
message. The code in the repository prints the error message if and when
dc reaches the point of the error, rather than immediately when the
error is detected in the patched version.

Since the patched version is simpler, it seems that the original code
may be deliberately written that way.

Jilles Tjoelker
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:35 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