aboutsummaryrefslogtreecommitdiff
path: root/module/hnh/util/env.scm
diff options
context:
space:
mode:
Diffstat (limited to 'module/hnh/util/env.scm')
-rw-r--r--module/hnh/util/env.scm10
1 files changed, 9 insertions, 1 deletions
diff --git a/module/hnh/util/env.scm b/module/hnh/util/env.scm
index a6877186..ca0e5ea8 100644
--- a/module/hnh/util/env.scm
+++ b/module/hnh/util/env.scm
@@ -1,5 +1,5 @@
(define-module (hnh util env)
- :export (let-env))
+ :export (let-env with-working-directory))
(define-syntax let-env
(syntax-rules ()
@@ -22,4 +22,12 @@
env-pairs))))]))
+(define-syntax-rule (with-working-directory directory thunk)
+ (let ((old-cwd #f))
+ (dynamic-wind
+ (lambda ()
+ (set! old-cwd (getcwd))
+ (chdir directory))
+ thunk
+ (lambda () (chdir old-cwd)))))