mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
Remove argv[0] from the arguments of main_symbol.
While the (command-line) in (scheme process-context) contains the command name (argv[0]), SRFI 22 specifies that the interpreter passes the command-line arguments except argv[0] to the script. Fix #413. Signed-off-by: Masanori Ogino <masanori.ogino@gmail.com>
This commit is contained in:
parent
b52711cac8
commit
361e8e6590
4 changed files with 17 additions and 18 deletions
|
@ -522,4 +522,4 @@
|
||||||
(verbose? boolean (#\v "verbose"))))
|
(verbose? boolean (#\v "verbose"))))
|
||||||
,run-app))
|
,run-app))
|
||||||
|
|
||||||
(define (main args) (run-application app-spec args))
|
(define (main args) (run-application app-spec))
|
||||||
|
|
|
@ -280,7 +280,6 @@
|
||||||
res))))
|
res))))
|
||||||
|
|
||||||
(define (main args)
|
(define (main args)
|
||||||
(let ((args (cdr args)))
|
|
||||||
(cond
|
(cond
|
||||||
((equal? "t" (car args))
|
((equal? "t" (car args))
|
||||||
(for-each (lambda (f) (write-string f) (newline)) (tar-files (cadr args))))
|
(for-each (lambda (f) (write-string f) (newline)) (tar-files (cadr args))))
|
||||||
|
@ -294,4 +293,4 @@
|
||||||
(write-string
|
(write-string
|
||||||
(utf8->string (tar-extract-file (cadr args) (car (cddr args))))))
|
(utf8->string (tar-extract-file (cadr args) (car (cddr args))))))
|
||||||
(else
|
(else
|
||||||
(error "unknown tar command" (car args))))))
|
(error "unknown tar command" (car args)))))
|
||||||
|
|
2
main.c
2
main.c
|
@ -597,7 +597,7 @@ sexp run_main (int argc, char **argv) {
|
||||||
sym = sexp_intern(ctx, main_symbol, -1);
|
sym = sexp_intern(ctx, main_symbol, -1);
|
||||||
tmp = sexp_env_ref(ctx, env, sym, SEXP_FALSE);
|
tmp = sexp_env_ref(ctx, env, sym, SEXP_FALSE);
|
||||||
if (sexp_procedurep(tmp)) {
|
if (sexp_procedurep(tmp)) {
|
||||||
args = sexp_list1(ctx, args);
|
args = sexp_list1(ctx, sexp_cdr(args));
|
||||||
check_exception(ctx, sexp_apply(ctx, tmp, args));
|
check_exception(ctx, sexp_apply(ctx, tmp, args));
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "couldn't find main binding: %s in %s\n", main_symbol, main_module ? main_module : argv[i]);
|
fprintf(stderr, "couldn't find main binding: %s in %s\n", main_symbol, main_module ? main_module : argv[i]);
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
(begin
|
(begin
|
||||||
(define (main args)
|
(define (main args)
|
||||||
(write-string "Hello, ")
|
(write-string "Hello, ")
|
||||||
(write-string (if (pair? (cdr args)) (cadr args) "world!"))
|
(write-string (if (pair? args) (car args) "world!"))
|
||||||
(newline))
|
(newline))
|
||||||
(define (bye args)
|
(define (bye args)
|
||||||
(write-string "Goodbye, ")
|
(write-string "Goodbye, ")
|
||||||
(write-string (if (pair? (cdr args)) (cadr args) "world!"))
|
(write-string (if (pair? args) (car args) "world!"))
|
||||||
(newline))))
|
(newline))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue