chibi-scheme icon indicating copy to clipboard operation
chibi-scheme copied to clipboard

script-file absolute path is resolved too late

Open lassik opened this issue 1 year ago • 1 comments

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.

lassik avatar Jun 07 '23 21:06 lassik

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.

ashinn avatar Jun 08 '23 01:06 ashinn