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.
This commit is contained in:
Akim Demaille
2020-05-03 10:21:24 +02:00
parent 392f3caef6
commit 26aef31552

View File

@@ -15,12 +15,30 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# 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 <<EOF
1+2*3
EOF