Imported from ../bash-2.01.tar.gz.
[platform/upstream/bash.git] / tests / dirstack.tests
1 dirs -c
2 # errors -- empty stack
3 pushd
4 popd
5
6 # errors -- bad numeric arguments -- should not cause the script to exit
7 pushd -m
8 popd -m
9 dirs -m
10
11 MYDIR=$PWD
12 unalias cd 2>/dev/null
13
14 unalias -a
15
16 command cd -P /
17
18 case "$OLDPWD" in
19 $MYDIR) echo ok ;;
20 *)      echo oops -- bad \$OLDPWD ;;
21 esac
22
23 pushd /usr
24 echo $PWD $OLDPWD
25 dirs
26 echo ${DIRSTACK[@]}
27
28 # this should not change the directory stack at all
29 pushd -n +0
30 dirs
31
32 popd
33 pushd /usr
34
35 pushd /etc
36 dirs
37 dirs -l
38 dirs -v
39
40 # two consecutive `pushd's should swap the top two stack elements, then
41 # swap them back, leaving the stack intact
42 pushd
43 pushd
44
45 pushd /tmp
46 echo ${DIRSTACK[0]} ; dirs +0
47 echo ${DIRSTACK[2]} ; dirs +2
48
49 # these should be errors, but not affect the directory stack
50 dirs +9; dirs -9
51 pushd +9 ; pushd -9
52 popd +9 ; popd -9
53
54 popd -n +2
55 dirs
56 echo ${DIRSTACK[@]}
57
58 pushd -n /usr
59 echo $PWD
60 dirs
61 echo ${DIRSTACK[@]}
62
63 builtin pwd
64
65 DIRSTACK[1]=/bin
66 dirs
67
68 builtin pwd
69 popd +2
70 builtin pwd -L
71 pushd -1
72 dirs
73 echo ${DIRSTACK[0]}
74
75 dirs -c
76 dirs
77
78 # this is for the benefit of pure coverage
79 cd $MYDIR