summaryrefslogtreecommitdiff
path: root/find/testsuite/test_escape_c.sh
diff options
context:
space:
mode:
authorJames Youngman <jay@gnu.org>2011-06-18 11:34:01 +0100
committerJames Youngman <jay@gnu.org>2011-06-19 11:49:33 +0100
commit1005e5bf604622778e56032e8ef262d9c1f2dcab (patch)
treebaa3517ec13eca6fae08a07c6ae6e00eff758c63 /find/testsuite/test_escape_c.sh
parent9e764b139df6842c40c779c123edf6c138e5cbe3 (diff)
downloadfindutils-1005e5bf604622778e56032e8ef262d9c1f2dcab.tar.gz
Add a test for "find -printf \c".
* find/testsuite/Makefile.am (test_shell_progs): Add test_escape_c.sh. * find/testsuite/test_escape_c.sh: New test for "find -printf \c".
Diffstat (limited to 'find/testsuite/test_escape_c.sh')
-rwxr-xr-xfind/testsuite/test_escape_c.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/find/testsuite/test_escape_c.sh b/find/testsuite/test_escape_c.sh
new file mode 100755
index 00000000..50351eac
--- /dev/null
+++ b/find/testsuite/test_escape_c.sh
@@ -0,0 +1,37 @@
+#! /bin/sh
+testname="$(basename $0)"
+
+parent="$(cd .. && pwd)"
+if [[ -f "${parent}/ftsfind" ]]; then
+ ftsfind="${parent}/ftsfind"
+ oldfind="${parent}/find"
+elif [[ -f "${parent}/oldfind" ]]; then
+ ftsfind="${parent}/find"
+ oldfind="${parent}/oldfind"
+else
+ echo "Cannot find the executables to test." >&2
+ exit 1
+fi
+
+goldenfile="${srcdir}/test_escapechars.golden"
+expected='hello^.^world'
+
+for executable in "$oldfind" "$ftsfind"
+do
+ if result="$($executable . -maxdepth 0 \
+ -printf 'hello^\cthere' \
+ -exec printf %s {} \; \
+ -printf '^world\n' )"; then
+ if [[ "${result}" != "${expected}" ]]; then
+ exec >&2
+ echo "$executable produced incorrect output:"
+ echo "${result}"
+ echo "Expected output was:"
+ echo "${expected}"
+ exit 1
+ fi
+ else
+ echo "$executable returned $?" >&2
+ exit 1
+ fi
+done