]> diplodocus.org Git - nmh/blob - test/format/test-unquote
sortm.c: Flip get_fields()'s logic to simplify.
[nmh] / test / format / test-unquote
1 #!/bin/sh
2 #
3 # Test that the unquote function works properly.
4 #
5
6 if test -z "${MH_OBJ_DIR}"; then
7 srcdir=`dirname "$0"`/../..
8 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
9 fi
10
11 . "$MH_OBJ_DIR/test/common.sh"
12
13 setup_test
14
15 #
16 # Test various unquoting scenarios
17 #
18
19 run_test 'eval fmttest -raw -format "%(unquote{text})" "Mr. Foo Bar"' \
20 'Mr. Foo Bar'
21
22 run_test 'eval fmttest -raw -format "%(unquote{text})" "Mr. \"Foo\" Bar"' \
23 'Mr. Foo Bar'
24
25 #
26 # Note here: the string we wanted passed on the command line is:
27 #
28 # "Mr. \"Foo\" Bar"
29 #
30 # The extra \ are necessary to get it past the shell
31 #
32
33 run_test 'eval fmttest -raw -format "%(unquote{text})" "Mr. \\\"Foo\\\" Bar"' \
34 'Mr. "Foo" Bar'
35
36 exit ${failed:-0}