chibi-scheme
chibi-scheme copied to clipboard
script-file absolute path is resolved too late
Given a file bug.scm
with the contents:
(import (scheme base)
(scheme write)
(srfi 193)
(chibi filesystem))
(change-directory "/") ; <-- This line causes the bug.
(write (script-file))
(newline)
Running chibi-scheme bug.scm
outputs "/bug.scm"
.
That's because raw-script-file
is not resolved from a relative to an absolute pathname until (script-file)
is called.
What would be a good place to resolve it? The relative pathname is set in main.c
.
The easiest way to fix this is to record the PWD in (srfi 193) on loading, however in pathological cases (dynamic loading of SRFI 193 after changing directory) that fails. So we probably need to resolve in main.c.