some echo the input, some do not.
rm -f $expected $expectederr $actual $actualerr
touch $expected $expectederr $actual $actualerr
-cat > $expected <<EOF
+#
+# Sigh. Different readline versions change echoing behavior, so we need
+# to deal.
+#
+
+set +e
+whatnowtest="$(echo cd | TERM=dumb whatnow -prompt '')"
+set -e
+
+case "${whatnowtest}" in
+ cd) cat > "$expected" <<EOF
+attach $testname_quoted
+alist
+$testname
+detach $testname_quoted
+alist
+EOF
+ break;;
+ "") cat > "$expected" <<EOF
$testname
EOF
+ break;;
+ *) echo "Unknown response to whatnow readline test"
+ echo "Response is: ${whatnowtest}"
+ exit 1
+ break;;
+esac
# whatnow's exit status is always 1 so that is not a failure
set +e
echo "attach $testname_quoted" | \
- whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
-echo "alist" | whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
+ TERM=dumb whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
+echo "alist" | TERM=dumb whatnow -attach foo -noedit -prompt '' \
+ 2>> $actualerr >> $actual
echo "detach $testname_quoted" | \
- whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
-echo "alist" | whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
+ TERM=dumb whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
+echo "alist" | TERM=dumb whatnow -attach foo -noedit -prompt '' \
+ 2>> $actualerr >> $actual
set -e
check "$expectederr" "$actualerr"
expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual
-cat > $expected <<EOF
+#
+# Handle different output depending on readline version
+#
+
+set +e
+whatnowtest="$(echo cd | TERM=dumb whatnow -prompt '')"
+set -e
+
+case "${whatnowtest}" in
+ cd) cat > "$expected" <<EOF
+cd ${MH_TEST_DIR}/foo\'s\ bar
+pwd
+$SPDIR
+EOF
+ break;;
+ "") cat > "$expected" <<EOF
$SPDIR
EOF
+ break;;
+ *) echo "Unknown response to whatnow readline test"
+ echo "Response is: ${whatnowtest}"
+ exit 1
+ break;;
+esac
cat > $expectederr <<EOF
EOF
# ||true to ignore whatnow's exit status
# watch the quoting -- shell and printf and then the shell run inside whatnow
printf "cd $MH_TEST_DIR/foo\\\\'s\\\\ bar\npwd\n" | \
- whatnow -noedit -prompt '' 2> "$actualerr" > "$actual" || true
+ TERM=dumb whatnow -noedit -prompt '' 2> "$actualerr" > "$actual" || true
check "$expectederr" "$actualerr"
check "$expected" "$actual"
expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual
-cat > $expected <<EOF
+#
+# Handle different output depending on readline version
+#
+
+set +e
+whatnowtest="$(echo cd | TERM=dumb whatnow -prompt '')"
+set -e
+
+case "${whatnowtest}" in
+ cd) cat > "$expected" <<EOF
+baz
+boz
+ls
+EOF
+ break;;
+ "") cat > "$expected" <<EOF
baz
boz
EOF
+ break;;
+ *) echo "Unknown response to whatnow readline test"
+ echo "Response is: ${whatnowtest}"
+ exit 1
+ break;;
+esac
cat > $expectederr <<EOF
EOF
# NB use of sort as the order of output of ls is not guaranteed
-echo 'ls' | whatnow -noedit -prompt '' 2> "$actualerr" | sort > "$actual"
+echo 'ls' | TERM=dumb whatnow -noedit -prompt '' 2> "$actualerr" | \
+ sort > "$actual"
check "$expectederr" "$actualerr"
check "$expected" "$actual"