popd.scm 857 B

12345678910111213141516171819202122
  1. (commands popd)
  2. ;; TODO: write to output port
  3. (define popd
  4. (lambda* (#:key
  5. ;; command interface
  6. (previous-result '())
  7. (shell-state default-shell-state)
  8. (silent #f))
  9. "Change the current working directory, poping the current working
  10. directory off the directory stack."
  11. (let* ([dir-stack (get-shell-state shell-state 'directory-stack)]
  12. [updated-dir-stack (cdr dir-stack)])
  13. (let ([previous-working-directory (car updated-dir-stack)])
  14. (receive (new-pwd shell-state) (cd previous-working-directory #:silent #t)
  15. (values new-pwd
  16. (update-shell-state* shell-state
  17. '(current-working-directory directory-stack)
  18. (list new-pwd updated-dir-stack))))))))
  19. (alias pop-directory popd)