]> git.saurik.com Git - apple/shell_cmds.git/blob - sh/tests/builtins/cd1.0
d797157d1912bd403a85923dfd7bca5af30b4b35
[apple/shell_cmds.git] / sh / tests / builtins / cd1.0
1 # $FreeBSD: head/bin/sh/tests/builtins/cd1.0 228975 2011-12-30 00:04:11Z uqs $
2 set -e
3
4 P=${TMPDIR:-/tmp}
5 cd $P
6 T=$(mktemp -d sh-test.XXXXXX)
7
8 chmod 0 $T
9 if [ `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" ]
17 fi
18
19 chmod 755 $T
20 cd $T
21 mkdir -p 1/2/3
22 ln -s 1/2 link1
23 ln -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
30 rm -rf ${P}/${T}