How can I reliably get the script name in a chicken schema?
It seems that -ss is eating the name of the script, so it does not appear unless I use a dot slash to run my scripts.
scriptedmain.scm:
#!/usr/bin/env csi -q (display (command-line-arguments)) (display "\n") (exit)
Trace:
$ ./scriptedmain.scm (-q ./scriptedmain.scm) wonko:Desktop andrew$ csi -ss scriptedmain.scm ()
This is a late answer, so it may not be useful for the original poster. But for any others who might run into this question, the simple answer is to use a parameter:
(program-name)
This should return the correct name for all situations. The docs are here.
(argv)must do the job. Example:
(argv)
#!/usr/local/bin/csi -script (display (argv)) (newline) (exit)
Prints (/usr/local/bin/csi -script ./test.scm)
(/usr/local/bin/csi -script ./test.scm)
scriptedmain.scm () :
:
csi -ss scriptedmain.scm
shebangs:
./scriptedmain.scm
csc -o scriptedmain scriptedmain.scm ./scriptedmain
GitHub.
#!/bin/sh #| exec csi -ss $0 ${1+"$@"} exit |# (define (main) (display (format "Program: ~a\n" (program-name))) (exit)) (if (not (equal? (program-name) "csi")) (main))