Does the smoking scheme have the equivalent of Perl $ 0?

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 
()
+5
source share
3 answers

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.

+6
source

(argv)must do the job. Example:

#!/usr/local/bin/csi -script

(display (argv)) (newline) (exit)

Prints (/usr/local/bin/csi -script ./test.scm)

+1

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))
+1

All Articles