xref: /freebsd/bin/sh/tests/builtins/cd1.0 (revision cddbc3b40812213ff00041f79174cac0be360a2a)
1# $FreeBSD$
2set -e
3
4P=${TMPDIR:-/tmp}
5cd $P
6T=$(mktemp -d sh-test.XXXXXX)
7
8chmod 0 $T
9if [ `id -u` -ne 0 ]; then
10	# Root can always cd, regardless of directory permissions.
11	cd -L $T 2>/dev/null && exit 1
12	[ "$PWD" = "$P" ]
13	[ "$(pwd)" = "$P" ]
14	cd -P $T 2>/dev/null && exit 1
15	[ "$PWD" = "$P" ]
16	[ "$(pwd)" = "$P" ]
17fi
18
19chmod 755 $T
20cd $T
21mkdir -p 1/2/3
22ln -s 1/2 link1
23ln -s 2/3 1/link2
24(cd -L 1/../1 && [ "$(pwd -L)" = "$P/$T/1" ])
25(cd -L link1 && [ "$(pwd -L)" = "$P/$T/link1" ])
26(cd -L link1 && [ "$(pwd -P)" = "$P/$T/1/2" ])
27(cd -P link1 && [ "$(pwd -L)" = "$P/$T/1/2" ])
28(cd -P link1 && [ "$(pwd -P)" = "$P/$T/1/2" ])
29
30rm -rf ${P}/${T}
31