builtins: cd: Support `cd -'.

* gash/builtins.scm (cd-command): Support `cd -'.
This commit is contained in:
Jan Nieuwenhuizen 2018-07-14 15:14:05 +02:00
parent 56a36baee5
commit 97a95ee002
1 changed files with 4 additions and 2 deletions

View File

@ -48,9 +48,11 @@
(define (cd-command . args)
(match args
(() (chdir (getenv "HOME")))
(() (cd-command (getenv "HOME")))
((dir)
(chdir dir))
(assignment "OLDPWD" (getcwd))
(if (string=? dir "-") (chdir (variable "OLDPWD"))
(chdir dir)))
((args ...)
(format (current-error-port) "cd: too many arguments: ~a\n" (string-join args)))))