summaryrefslogtreecommitdiff
path: root/examples/c
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2020-04-18 09:27:14 +0200
committerAkim Demaille <akim.demaille@gmail.com>2020-04-18 10:37:13 +0200
commit8b5fb7c4c3fb0f16e0ea2ae7160c7dcd143538b4 (patch)
tree96df38e159662b770f55a1ec3c9b93a63c066246 /examples/c
parentd6ae95fb50317fc3ffee018bfc4a6358da04332a (diff)
downloadbison-8b5fb7c4c3fb0f16e0ea2ae7160c7dcd143538b4.tar.gz
examples: beware of readline on macOS
macOS' version of readline does not repeat stdin on stdout in non-interactive mode, contrary to the current version of GNU readline. * examples/test: Add support for strip_prompt. * examples/c/bistromathic/bistromathic.test (strip_prompt): Set it when needed. Early exit when needed.
Diffstat (limited to 'examples/c')
-rwxr-xr-xexamples/c/bistromathic/bistromathic.test17
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/c/bistromathic/bistromathic.test b/examples/c/bistromathic/bistromathic.test
index 4f64b1a1..5d9966f3 100755
--- a/examples/c/bistromathic/bistromathic.test
+++ b/examples/c/bistromathic/bistromathic.test
@@ -15,6 +15,12 @@
# 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'; then
+ strip_prompt=true
+fi
+
cat >input <<EOF
1+2*3
EOF
@@ -85,6 +91,17 @@ run 0 '> 1 / 0
## Completion. ##
## ------------ ##
+# From now on, the differences between versions of GNU Readline are
+# too painful to try to cope with.
+if $strip_prompt; then
+ echo "SKIP: this is not the GNU Readline we expect"
+ if $exit; then
+ exit 0
+ else
+ exit 1
+ fi
+fi
+
# Check completion after an operator.
sed -e 's/\\t/ /g' >input <<EOF
(1+\t\t