]>
diplodocus.org Git - nmh/blob - test/whatnow/test-cd
2 ######################################################
4 # Test that whatnow's "cd" copes with directory names
5 # which have spaces and quotes in them (see bug #23319)
7 ######################################################
11 if test -z "${MH_OBJ_DIR}"; then
12 srcdir
=`dirname "$0"`/..
/..
13 MH_OBJ_DIR
=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
16 .
"$MH_OBJ_DIR/test/common.sh"
20 # Set TERM to get consistent output.
21 TERM
=dumb
; export TERM
23 SPDIR
="$MH_TEST_DIR/foo's bar"
26 (cd "$SPDIR" && touch baz boz
)
28 expectederr
=$MH_TEST_DIR/$$.expectederr
29 actualerr
=$MH_TEST_DIR/$$.actualerr
30 expected
=$MH_TEST_DIR/$$.expected
31 actual
=$MH_TEST_DIR/$$.actual
34 # Handle different output depending on readline version
38 whatnowtest
=`echo cd | whatnow -prompt ''`
40 case ${whatnowtest} in
41 cd) cat > "$expected" <<EOF
42 cd ${MH_TEST_DIR}/foo\'s\ bar
46 # If path to $SPDIR is too long, readline will wrap and disturb
47 # the actual output. It obeys COLUMNS, so set that to a value
48 # that should be longer that $SPDIR plus a bit more.
49 COLUMNS
=`getconf PATH_MAX . 2>/dev/null` || COLUMNS
=8192
52 "") cat > "$expected" <<EOF
56 *) echo "Unknown response to whatnow readline test"
57 echo "Response is: ${whatnowtest}"
62 cat > $expectederr <<EOF
65 # ||true to ignore whatnow's exit status
66 # watch the quoting -- shell and printf and then the shell run inside whatnow
67 printf 'cd %s/foo\\'"'"'s\\ bar\npwd\n' "$MH_TEST_DIR" | \
68 run_prog whatnow
-noedit -prompt '' 2> "$actualerr" > "$actual" || true
70 check
"$expectederr" "$actualerr"
71 check
"$expected" "$actual"
73 test ${failed:-0} -eq 0 && rm -r "$SPDIR"