scheme / scsh

A Unix shell embedded in scheme
Other
386 stars 36 forks source link

Interpreter doesn't find file to execute after loading a file that uses with-cwd #48

Open hllizi opened 11 months ago

hllizi commented 11 months ago

Using with-cwd somehow messes up the way the interpreter looks for the file to be executed if the interpreter is started via a shebang sequence and with-cwd is employed in a file that is loaded with "-l" or "-lm". (I am using Scheme 48, btw)

Minimal (non)working example:

lib.scm:

(with-cwd "/tmp"
          (for-each display
                    (directory-files)))

main.scm:

#! /nix/store/3x6dm1pp2m2pb104agz0r8fzcms13wam-scsh-0.7pre/bin/scsh \
-l lib.scm -s
!#

(display "I got here!")

The result when both files are put in the same directory and main.scm ist executed is:

error: No such file or directory [open-input-file]
       "./main.scm"
       #{&i/o-error}

A hackish solution to the problem is to put (chdir ".") at the end of lib.scm. Then "I got here!" will get to be printed.

The same problem exists when Scheme 48 modules are used and with-cmd is used in the definitions.