From 38a82878136a8e10179f9545c15ffcf2bea1c50a Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 3 May 2020 17:59:13 +0200 Subject: [PATCH] bistromathic: beware of portability issues of readline on AIX Readline may emit escape sequences before the prompt. Reported by Bruno Haible. https://lists.gnu.org/r/platform-testers/2020-05/msg00001.html. * examples/c/bistromathic/bistromathic.test: Trust readline _only_ if we get what we expect on some reference computation. --- examples/c/bistromathic/bistromathic.test | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/examples/c/bistromathic/bistromathic.test b/examples/c/bistromathic/bistromathic.test index dfefa804..d33b4e8f 100755 --- a/examples/c/bistromathic/bistromathic.test +++ b/examples/c/bistromathic/bistromathic.test @@ -28,12 +28,24 @@ # # 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. +# +# On AIX, you get some escaping sequence before the prompt: +# "[?1034h> 1+2*3". It appears to pass the terminfo capability +# "smm", to put the terminal in "meta mode": as if the user had hit +# META. -if ! echo '1-1' | prog | grep '>' >/dev/null; then - # macOS. +echo >perfect '> 0 +0 +> ' + +echo >ok '0' +echo '0' | prog >effective + +if diff perfect effective >/dev/null 2>&1; then + # Alles ist gut. +elif diff ok effective >/dev/null 2>&1; then 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. +else echo "SKIP: this is not the GNU Readline we expect" exit 77 fi