summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/zash/cd-isolated.exp11
-rw-r--r--tests/zash/cd-isolated.sh16
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/zash/cd-isolated.exp b/tests/zash/cd-isolated.exp
new file mode 100644
index 0000000..13467d5
--- /dev/null
+++ b/tests/zash/cd-isolated.exp
@@ -0,0 +1,11 @@
+after=0 same=yes
+/
+/
+bad=nonzero same=yes
+redir=0 same=yes
+vars=pwd oldpwd
+list=0 same=yes
+yes
+int=2 same=yes
+ro=2 same=yes
+[status 0]
diff --git a/tests/zash/cd-isolated.sh b/tests/zash/cd-isolated.sh
new file mode 100644
index 0000000..f740aa0
--- /dev/null
+++ b/tests/zash/cd-isolated.sh
@@ -0,0 +1,16 @@
+# A lone ( cd dir ) must put the shell back where it was.
+start=$(pwd -P)
+(cd /); echo "after=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)"
+(cd /; pwd)
+(cd / && pwd)
+(cd /nonexistent) 2>/dev/null; echo "bad=$([ $? -ne 0 ] && echo nonzero) same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)"
+(cd /) 2>/dev/null; echo "redir=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)"
+old=$OLDPWD
+(cd /); echo "vars=$([ "$PWD" = "$start" ] && echo pwd) $([ "$OLDPWD" = "$old" ] && echo oldpwd)"
+(cd /; :); echo "list=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)"
+(cd /) || echo no
+(cd /) && echo yes
+
+( typeset -i PWD; (cd /) 2>/dev/null; echo "int=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)" )
+readonly PWD
+(cd /) 2>/dev/null; echo "ro=$? same=$([ "$(pwd -P)" = "$start" ] && echo yes || echo no)"