-R needs interpreter name, not SRFI 22

This commit is contained in:
Alex Shinn 2019-01-01 23:18:49 +08:00
parent 2962f68ced
commit 336a69a416
3 changed files with 17 additions and 16 deletions

View file

@ -280,17 +280,18 @@
res)))) res))))
(define (main args) (define (main args)
(cond (let ((args (cdr args)))
((equal? "t" (car args)) (cond
(for-each (lambda (f) (write-string f) (newline)) (tar-files (cadr args)))) ((equal? "t" (car args))
((equal? "x" (car args)) (for-each (lambda (f) (write-string f) (newline)) (tar-files (cadr args))))
(if (tar-safe? (cadr args)) ((equal? "x" (car args))
(tar-extract (cadr args)) (if (tar-safe? (cadr args))
(error "tar file not a single relative directory" (cadr args)))) (tar-extract (cadr args))
((equal? "c" (car args)) (error "tar file not a single relative directory" (cadr args))))
(tar-create (cadr args) (cddr args))) ((equal? "c" (car args))
((equal? "f" (car args)) (tar-create (cadr args) (cddr args)))
(write-string ((equal? "f" (car args))
(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
View file

@ -545,7 +545,7 @@ sexp run_main (int argc, char **argv) {
for (j=argc-1; j>=i; j--) for (j=argc-1; j>=i; j--)
args = sexp_cons(ctx, tmp=sexp_c_string(ctx,argv[j],-1), args); args = sexp_cons(ctx, tmp=sexp_c_string(ctx,argv[j],-1), args);
/* if no script name, use interpreter name */ /* if no script name, use interpreter name */
if (i >= argc || main_symbol != NULL) if (i >= argc || main_module != NULL)
args = sexp_cons(ctx, tmp=sexp_c_string(ctx,argv[0],-1), args); args = sexp_cons(ctx, tmp=sexp_c_string(ctx,argv[0],-1), args);
load_init(i < argc || main_symbol != NULL); load_init(i < argc || main_symbol != NULL);
sexp_set_parameter(ctx, sexp_meta_env(ctx), sym=sexp_intern(ctx, sexp_argv_symbol, -1), args); sexp_set_parameter(ctx, sexp_meta_env(ctx), sym=sexp_intern(ctx, sexp_argv_symbol, -1), args);

View file

@ -3,9 +3,9 @@
(begin (begin
(define (main args) (define (main args)
(write-string "Hello, ") (write-string "Hello, ")
(write-string (if (pair? args) (car args) "world!")) (write-string (if (pair? (cdr args)) (cadr args) "world!"))
(newline)) (newline))
(define (bye args) (define (bye args)
(write-string "Goodbye, ") (write-string "Goodbye, ")
(write-string (if (pair? args) (car args) "world!")) (write-string (if (pair? (cdr args)) (cadr args) "world!"))
(newline)))) (newline))))