Question

This question has definitely been asked before, here. Some of the solutions presented did work(in Windows) except for the command-line function mentioned in Command-line access and exit values in r6rs-lib.

I managed to achieve what I wanted in Gauche(non r6rs compliant implementation) using *argv*:

(display *argv*)
> gosh test.ss first 1 2 3 4 5 6 7 8 9 10 11 12 13
         >> (first 1 2 3 4 5 6 7 8 9 10 11 12 13)

I want to do the same with Petite Chez Scheme which is r6rs compliant using the command-line function. I've tried to use the code in that chapter but all I get is a list with the script's name and only the first argument. e.g

#!r6rs
(import (rnrs programs (6)))
(display (command-line))

> petite --script test.ss first second
    >> (test.ss first)

Is there some other library import I'm missing that would make it work?

Was it helpful?

Solution

The following 'script' works for me in 'Ikarus Scheme':

#!/usr/bin/env scheme-script
(import (rnrs))
(display (command-line))
(newline)

ebg@ebg$ ./ik.scm a b c
(./ik.scm a b c)
ebg@ebg$ ikarus --r6rs-script ./ik.scm a b c
(./ik.scm a b c)

and for Petite

ebg@ebg$ petite --script ~/ik.scm a b c
(/Users/ebg/ik.scm a b c)

Note that officially (import (rnrs programs (6))) won't import display so as written your code should fail.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top