I would like to programmatically detect the program name within Racket code. This can be done in Chicken Scheme with:
#!/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))
How could I emulate this in Racket?
Is this what you want?
(find-system-path 'run-file)
See also racket/cmdline
for how to parse the commandline.
http://docs.racket-lang.org/reference/Command-Line_Parsing.html
Note: for this particular pattern of execution, to have a library module that can also be run as a main, use a submodule named main. See Main and Test Submodules, which shows how to do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With