### 15.2 Working Directory ¶

When MIT/GNU Scheme is started, the current working directory (or simply, working directory) is initialized in an operating-system dependent manner; usually, it is the directory in which Scheme was invoked. The working directory can be determined from within Scheme by calling the `pwd` procedure, and changed by calling the `cd` procedure. Each REP loop has its own working directory, and inferior REP loops initialize their working directory from the value in effect in their superior at the time they are created.

procedure: working-directory-pathname ¶
procedure: pwd ¶

  Returns the current working directory as a pathname that has no name, type, or version components, just host, device, and directory components. `pwd` is an alias for `working-directory-pathname`; the long name is intended for programs and the short name for interactive use.

procedure: set-working-directory-pathname! filename ¶
procedure: cd filename ¶

  Makes filename the current working directory and returns the new current working directory as a pathname. Filename is coerced to a pathname using `pathname-as-directory`. `cd` is an alias for `set-working-directory-pathname!`; the long name is intended for programs and the short name for interactive use.

  When this procedure is executed in the top-level REP loop, it changes the working directory of the running Scheme executable.

      (set-working-directory-pathname! "/usr/morris/blisp")
           ⇒  #[pathname "/usr/morris/blisp/"]
      (set-working-directory-pathname! "~")
           ⇒  #[pathname "/usr/morris/"]

  This procedure signals an error if filename does not refer to an existing directory.

  If filename describes a relative rather than absolute pathname, this procedure interprets it as relative to the current working directory, before changing the working directory.

      (working-directory-pathname)
           ⇒  #[pathname "/usr/morris/"]
      (set-working-directory-pathname! "foo")
           ⇒  #[pathname "/usr/morris/foo/"]

procedure: with-working-directory-pathname filename thunk ¶

  This procedure dynamically binds the current working directory to filename and returns the value of thunk (a procedure of no arguments). Filename is coerced to a pathname using `pathname-as-directory`.