xref: /freebsd/bin/sh/tests/expansion/pathname2.0 (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1# $FreeBSD$
2
3unset LC_ALL
4LC_COLLATE=C
5export LC_COLLATE
6
7failures=0
8
9check() {
10	testcase=$1
11	expect=$2
12	eval "set -- $testcase"
13	actual="$*"
14	if [ "$actual" != "$expect" ]; then
15		failures=$((failures+1))
16		printf '%s\n' "For $testcase, expected $expect actual $actual"
17	fi
18}
19
20set -e
21T=$(mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX)
22trap 'rm -rf $T' 0
23cd -P $T
24
25mkdir testdir testdir2 'testdir/*' 'testdir/?' testdir/a testdir/b testdir2/b
26mkdir testdir2/.c
27touch testf 'testdir/*/1' 'testdir/?/1' testdir/a/1 testdir/b/1 testdir2/b/.a
28
29check '*\/' 'testdir/ testdir2/'
30check '"testdir/"*"/1"' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1'
31check '"testdir/"*"/"*' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1'
32check '"testdir/"*\/*' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1'
33check '"testdir"*"/"*"/"*' 'testdir/*/1 testdir/?/1 testdir/a/1 testdir/b/1'
34
35exit $((failures != 0))
36