Enclosed program name and directory in double quotes so that they can contain whitespace.
[mmh] / test / whatnow / test-cd
1 #!/bin/sh
2 ######################################################
3 #
4 # Test that whatnow's "cd" copes with directory names
5 # which have spaces and quotes in them (see bug #23319)
6 #
7 ######################################################
8
9 if test -z "${MH_OBJ_DIR}"; then
10     srcdir=`dirname "$0"`/../..
11     MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
12 fi
13
14 . "$MH_OBJ_DIR/test/common.sh"
15
16 setup_test
17
18 set -e
19 SPDIR="$MH_TEST_DIR/foo's bar"
20 rm -rf "$SPDIR"
21 mkdir "$SPDIR"
22 cd "$SPDIR"
23 touch baz boz
24 cd
25
26 expectederr=$MH_TEST_DIR/$$.expectederr
27 actualerr=$MH_TEST_DIR/$$.actualerr
28 expected=$MH_TEST_DIR/$$.expected
29 actual=$MH_TEST_DIR/$$.actual
30
31 cat > $expected <<EOF
32 $SPDIR
33 EOF
34
35 cat > $expectederr <<EOF
36 EOF
37
38 # ||true to ignore whatnow's exit status
39 # watch the quoting -- shell and printf and then the shell run inside whatnow
40 printf "cd $MH_TEST_DIR/foo\\\\'s\\\\ bar\npwd\n" | whatnow -noedit -prompt '' 2> "$actualerr" > "$actual" || true
41
42 diff -u $expectederr $actualerr || exit 1
43 diff -u $expected $actual