1

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?

gebby
  • 155
  • 1
  • 5

1 Answers1

1

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.

GoZoner
  • 67,920
  • 20
  • 95
  • 145
  • Guess what, the code runs as intended in `Ubuntu`. Maybe the `Petite` windows installation is broken. Does it work for you in `Windows`? – gebby Oct 18 '13 at 10:28
  • I've no Windows machine to try. Please up-vote and perhaps mark as 'answered'. – GoZoner Oct 18 '13 at 13:09
  • I think I'm going to give it some more time for someone with Windows to chip in. I think there's something wrong with the way that function is implemented in Windows because even Racket does not return all the values. I tried it with your code(mine raised an error like you said) and it returned `{C:\mine\.ss\test.ss}`. Is anybody else getting the same in Windows? – gebby Oct 18 '13 at 18:58
  • 1
    Yeah, it is. I guess no one uses scheme in Windows. Might as well accept your answer. – gebby Oct 25 '13 at 21:28