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