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
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.
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