Email list hosting service & mailing list manager

Get and set current directory Lassi Kortela (21 Jul 2019 12:26 UTC)
Get and set current directory Lassi Kortela (21 Jul 2019 12:40 UTC)
Re: Get and set current directory Lassi Kortela (21 Jul 2019 13:44 UTC)
Re: Get and set current directory Lassi Kortela (21 Jul 2019 13:59 UTC)
Re: Get and set current directory Marc Feeley (21 Jul 2019 14:25 UTC)
Re: Get and set current directory Lassi Kortela (21 Jul 2019 14:56 UTC)
Re: Get and set current directory Shiro Kawai (21 Jul 2019 20:59 UTC)
Re: Get and set current directory John Cowan (21 Jul 2019 22:35 UTC)

Re: Get and set current directory Lassi Kortela 21 Jul 2019 13:59 UTC

> has the advantage of allowing dynamic binding for procedures such as open-input-file that need to resolve relative file names

One trick is to have a procedure:

     (with-current-directory "/some/dir"
       (lambda () ...))

So with-current-directory saves the OS's idea of the current directory,
does a chdir() to the desired directory before the thunk and then a
chdir() back to the old one afterwards. There's an unwind-protect so the
chdir() is restored to the old one even on error. Many people use this
pattern in various languages. It simple to implement and nice to use.

Caveat: Eager to hear how the dynamic duo of threads and signals will
ruin this proposal too :) I haven't had to deal with those.