Merge pull request #435 from omasanori/srfi-22-scheme-r7rs

[RFC] Treat `scheme-r7rs` command name as in SRFI 22.
This commit is contained in:
Alex Shinn 2017-11-18 14:36:07 +09:00 committed by GitHub
commit e0dcb88b8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

11
main.c
View file

@ -307,6 +307,17 @@ sexp run_main (int argc, char **argv) {
args = SEXP_NULL;
env = NULL;
/* SRFI 22: invoke `main` procedure by default if the interpreter is invoked */
/* as `scheme-r7rs`. */
if (strncmp(basename(argv[0]), "scheme-r7rs", strlen("scheme-r7rs")) == 0) {
main_symbol = "main";
/* skip option parsing since we can't pass `--` before the name of script */
/* to avoid misinterpret the name as options when the interpreter is */
/* executed via `#!/usr/env/bin scheme-r7rs` shebang. */
i = 1;
goto done_options;
}
/* parse options */
for (i=1; i < argc && argv[i][0] == '-'; i++) {
switch ((c=argv[i][1])) {