schemecommand-line-argumentsgetmodulefilenamechicken-scheme

Does Chicken Scheme have an equivalent to Perl's $0?


How can I reliably get the script name in Chicken Scheme?

It seems that -ss eats up the script name, so it's not visible unless I use 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 
()

Solution

  • This is a late response, so may not be of use to the original poster. But to any others who may come across this question, the simple answer is to use the parameter:

    (program-name)
    

    This should return the correct name for all situations. Docs here.