fix and test cd builtin.

This commit is contained in:
Jan Nieuwenhuizen 2018-11-24 11:32:33 +01:00
parent 58d1627b08
commit f81b526bd0
6 changed files with 16 additions and 2 deletions

View File

@ -95,6 +95,9 @@ tests="
70-slash-string
70-slash-string-slash
100-cd
100-cd-foo
100-sed
100-sed-once
100-sed-global

View File

@ -65,8 +65,14 @@
((dir)
(let ((old (variable "OLDPWD")))
(assignment "OLDPWD" (getcwd))
(if (string=? dir "-") (chdir old)
(chdir dir))))
(catch #t
(lambda _
(if (string=? dir "-") (chdir old)
(chdir dir))
0)
(lambda (key command fmt args exit)
(apply format (current-error-port) "cd: ~a: ~a\n" (cons dir args))
1))))
((args ...)
(format (current-error-port) "cd: too many arguments: ~a\n" (string-join args)))))

1
test/100-cd-foo.exit Normal file
View File

@ -0,0 +1 @@
1

1
test/100-cd-foo.sh Normal file
View File

@ -0,0 +1 @@
cd /foo

2
test/100-cd.sh Normal file
View File

@ -0,0 +1,2 @@
cd /bin
pwd

1
test/100-cd.stdout Normal file
View File

@ -0,0 +1 @@
/bin