2013-10-17 104 views
1

这个问题肯定是之前问过的,here。除了在Command-line access and exit valuesr6rs-lib中提到的command-line功能外,所提供的一些解决方案确实可行(在Windows中)。使用`命令行`功能在Scheme中获取命令行参数

我设法用*argv*实现我在Gauche想(非R6RS兼容的实现):

(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) 

我想要做同样的Petite Chez Scheme这是r6rs使用command-line功能兼容。我试图使用该章节中的代码,但我得到的只是一个带有脚本名称和第一个参数的列表。 e.g

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

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

有一些其他的库导入我的思念,将使其工作

回答

1

下面的“脚本”中“的Ikarus计划”工作对我来说:

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

[email protected]$ ./ik.scm a b c 
(./ik.scm a b c) 
[email protected]$ ikarus --r6rs-script ./ik.scm a b c 
(./ik.scm a b c) 

和娇小

[email protected]$ petite --script ~/ik.scm a b c 
(/Users/ebg/ik.scm a b c) 

注意,正式(import (rnrs programs (6)))将不会导入display这样写你的代码失败。

+0

猜猜看,代码在Ubuntu中按照预期运行。也许'娇小'的窗户安装被打破。它在'Windows'中适合你吗? – gebby

+0

我没有Windows机器可以尝试。请投票表决,也许标记为“已回答”。 – GoZoner

+0

我想我会给它更多的时间让有人用Windows芯片进去。我认为在Windows中实现该功能的方式有些问题,因为即使是Racket也不会返回所有的值。我用你的代码试了一下(我的错误像你说的那样),它返回'{C:\ mine \ .ss \ test.ss}'。其他人在Windows中获得相同的结果吗? – gebby