diff --git a/scsh/scsh.scm b/scsh/scsh.scm index d163943..7651ef6 100644 --- a/scsh/scsh.scm +++ b/scsh/scsh.scm @@ -292,10 +292,10 @@ (define-record-resumer type/cache (lambda (cache) - (set-cache:cwd cache ""))) ; set the cache to an impossible filename. + (set-cache:cwd cache (process-cwd)))) ; set the cache to an impossible filename. (define *unix-cwd* - (make-cache "")) ; Initialise the cache to an impossible filename. + (make-cache (process-cwd))) ; Initialise the cache to an impossible filename. (define (unix-cwd) (cache:cwd *unix-cwd*)) @@ -325,12 +325,19 @@ result)))) ;;; The thread-specific CWD: A fluid -(define $cwd (make-fluid (process-cwd))) +(define-record state + cwd) -(define (cwd) (fluid $cwd)) -(define (set-cwd! dir) (set-fluid! $cwd dir)) +(define-record-resumer type/state + (lambda (state) + (set-state:cwd state (make-fluid (process-cwd))))) + +(define $cwd (make-state (make-fluid (process-cwd)))) + +(define (cwd) (fluid (state:cwd $cwd))) +(define (set-cwd! dir) (set-fluid! (state:cwd $cwd) dir)) (define (let-cwd dir thunk) - (let-fluid $cwd dir thunk)) + (let-fluid (state:cwd $cwd) dir thunk)) (define (with-cwd* dir thunk) (let ((changed-dir #f))