Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the program name in Racket?

Tags:

racket

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?

like image 478
mcandre Avatar asked Oct 15 '12 15:10

mcandre


2 Answers

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

like image 174
soegaard Avatar answered Nov 14 '22 03:11

soegaard


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.

like image 33
dyoo Avatar answered Nov 14 '22 03:11

dyoo