7d538a2373c21dac7f11dddff75f895ded8c09cf
[mmh] / test / whatnow / test-attach-detach
1 #!/bin/sh
2 ######################################################
3 #
4 # Test that whatnow's "ls" copes with directory names
5 # which have spaces in them (see bug #23319)
6 #
7 ######################################################
8
9 set -e
10
11 if test -z "${MH_OBJ_DIR}"; then
12     srcdir=`dirname "$0"`/../..
13     MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
14 fi
15
16 . "$MH_OBJ_DIR/test/common.sh"
17
18 setup_test
19
20 cd "$MH_TEST_DIR"
21 testname="baz's boz"
22 testname_quoted="baz\'s\ boz"
23 touch "$testname"
24 # whatnow's attach stuff needs a draft to work on
25 cp "$MH_TEST_DIR/Mail/inbox/1" "$MH_TEST_DIR/Mail/draft"
26
27 expectederr=$MH_TEST_DIR/$$.expectederr
28 actualerr=$MH_TEST_DIR/$$.actualerr
29 expected=$MH_TEST_DIR/$$.expected
30 actual=$MH_TEST_DIR/$$.actual
31
32 rm -f $expected $expectederr $actual $actualerr
33 touch $expected $expectederr $actual $actualerr
34
35 #
36 # Sigh.  Different readline versions change echoing behavior, so we need
37 # to deal.
38 #
39
40 set +e
41 whatnowtest=`echo cd | TERM=dumb whatnow -prompt ''`
42 set -e
43
44 case "${whatnowtest}" in
45     cd) cat > "$expected" <<EOF
46 attach $testname_quoted
47 alist
48 $testname
49 detach $testname_quoted
50 alist
51 EOF
52     ;;
53     "") cat > "$expected" <<EOF
54 $testname
55 EOF
56     ;;
57     *) echo "Unknown response to whatnow readline test"
58     echo "Response is: ${whatnowtest}"
59     exit 1
60     ;;
61 esac
62
63 # whatnow's exit status is always 1 so that is not a failure
64 set +e
65 echo "attach $testname_quoted" | \
66   TERM=dumb whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
67 echo "alist" | TERM=dumb whatnow -attach foo -noedit -prompt '' \
68                                 2>> $actualerr >> $actual
69 echo "detach $testname_quoted" | \
70   TERM=dumb whatnow -attach foo -noedit -prompt '' 2>> $actualerr >> $actual
71 echo "alist" | TERM=dumb whatnow -attach foo -noedit -prompt '' \
72                                 2>> $actualerr >> $actual
73 set -e
74
75 check "$expectederr" "$actualerr"
76 check "$expected" "$actual"
77
78 test ${failed:-0} -eq 0  &&  rm "$testname"
79
80 exit $failed