From 26aef3155212308fd2415502d7fb3e3c51f698f1 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 3 May 2020 10:21:24 +0200 Subject: [PATCH] examples: beware of portability issues with readline On OpenBSD 6.5, the prompt is repeated, but not the actual command line... Don't try to cope with that. Reported by Bruno Haible. https://lists.gnu.org/r/bug-bison/2020-05/msg00015.html * examples/c/bistromathic/bistromathic.test: Skip when readline behave this way. --- examples/c/bistromathic/bistromathic.test | 26 +++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/examples/c/bistromathic/bistromathic.test b/examples/c/bistromathic/bistromathic.test index 1e5bd0e1..7d3a7002 100755 --- a/examples/c/bistromathic/bistromathic.test +++ b/examples/c/bistromathic/bistromathic.test @@ -15,12 +15,30 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# macOS' version of readline does not repeat stdin on stdout in -# non-interactive mode. -if ! echo '1-1' | prog | grep '1-1' >/dev/null; then - strip_prompt=true + +# Beware of portability issues of readline when not feeding it from a +# terminal. +# +# With recent versions of GNU Readline, input "1+2*3\n" gives +# "> 1+2*3\n7\n> \n" +# +# macOS' version does not display the prompt and does not repeat stdin +# on stdout, so input "1+2*3\n" gives "7\n" as output. Let's try to +# cope with this. +# +# On OpenBSD 6.5 the prompt is displayed, but the input is not +# repeated (!). So input "1+2*3\n" gives "> 7\n> \n" as output. + +if ! echo '1-1' | prog | grep '>' >/dev/null; then + # macOS. + strip_prompt=true +elif ! echo '1-1' | prog | grep '1-1' >/dev/null; then + # OpenBSD 6.5. I don't want to spend time on this. + echo "SKIP: this is not the GNU Readline we expect" + exit 0 fi + cat >input <