Bug 262493 - bc has bad "prompt" for input, breaking 25+ years of FreeBSD behavior
Summary: bc has bad "prompt" for input, breaking 25+ years of FreeBSD behavior
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.0-RELEASE
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-03-11 22:56 UTC by David E. O'Brien
Modified: 2022-11-30 10:43 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David E. O'Brien freebsd_committer freebsd_triage 2022-03-11 22:56:30 UTC
Up until FreeBSD 13.0, bc had no "prompt" for interactively entered math text.
This made it very easy to copy-n-paste using quick mouse clicks when one wanted to reuse a math statement.

Now with 13.0, one cannot do that any longer due to very annoying leading ">>>" text.

Pre-13.0:
$ bc
1+2+3+4+5+6+7
28
1+2+3+4+5+6+7 + 8
36

13.0:
$ bc
>>> 1+2+3+4+5+6+7
28
>>> >>> 1+2+3+4+5+6+7 + 8

Parse error: bad token
    <stdin>:2


I am aware of the fact that 13.0 changed from a 2010 BSDL bc (FreeBSD 9.0-12.2)
and that replaced GNU bc used since 1993 (FreeBSD 1.x-11.4).

However, since the Google SoC and GNU bc has behaved this way since
FreeBSD 1.0, their replacement should behave as close to expected
FreeBSD behavior as possible.
Comment 1 Herbert J. Skuhra 2022-03-12 09:42:50 UTC
This is no longer the case on main, stable/13 and releng/13.1.

https://cgit.freebsd.org/src/commit?id=44d4804d1945435745518cd09eb8ae6ab22ecef4

% $ uname -r
13.1-STABLE
$ bc --version
bc 5.2.2
%  bc
1+2
3

Your options on releng/13.0 are:

- run bc with -P (alias?)
- rebuild world with WITHOUT_GH_BC=yes
- build bc from usr.bin/bc
- Modify usr.bin/gh-bc/Makefile and rebuild gh-bc
--- a/usr.bin/gh-bc/Makefile
+++ b/usr.bin/gh-bc/Makefile
@@ -34,7 +34,7 @@ NLSSRCDIR=    ${BCDIR}/locales
 CFLAGS+=       -DMAINEXEC=${PROGNAME}
 CFLAGS+=       -DNLSPATH=/usr/share/nls/%L/%N.cat
 CFLAGS+=       -DBC_ENABLED
-CFLAGS+=       -DBC_ENABLE_PROMPT
+CFLAGS+=       -DBC_ENABLE_PROMPT=0
Comment 2 Marcin Cieślak 2022-11-30 10:43:09 UTC
+1 from here, I was very surprised by this after 13.0 upgrade and happy to see it go away.