moonbridge
changeset 2:6016547c6410
Changed invocation of moonbridge command: single script with additional command line arguments for script
author | jbe |
---|---|
date | Thu Jan 08 20:07:17 2015 +0100 (2015-01-08) |
parents | a556c89270fe |
children | 3b3f0ecc4ac4 |
files | moonbridge.c |
line diff
1.1 --- a/moonbridge.c Sun Jan 04 19:37:19 2015 +0100 1.2 +++ b/moonbridge.c Thu Jan 08 20:07:17 2015 +0100 1.3 @@ -2530,7 +2530,7 @@ 1.4 fprintf(out, " [-l|--logfile <logfile>] \\\n"); 1.5 fprintf(out, " [-p|--pidfile <pidfile>] \\\n"); 1.6 fprintf(out, " [-s|--stats] \\\n"); 1.7 - fprintf(out, " <Lua file> [<Lua file> ...]\n"); 1.8 + fprintf(out, " -- <Lua script> [<cmdline options for Lua script>]\n"); 1.9 exit(err); 1.10 } 1.11 1.12 @@ -2609,7 +2609,7 @@ 1.13 moonbr_usage_error(); 1.14 } 1.15 } 1.16 - if (argc - optind <= 0) moonbr_usage_error(); 1.17 + if (argc - optind < 1) moonbr_usage_error(); 1.18 if (pid_filename) { 1.19 pid_t otherpid; 1.20 while ((moonbr_pidfh = pidfile_open(pid_filename, 0644, &otherpid)) == NULL) { 1.21 @@ -2687,19 +2687,15 @@ 1.22 lua_pushcfunction(L, moonbr_listen); 1.23 lua_setglobal(L, "listen"); 1.24 lua_pushcfunction(L, moonbr_addtraceback); // on stack position 1 1.25 - { 1.26 - int i; 1.27 - for (i=optind; i<argc; i++) { 1.28 - moonbr_log(LOG_INFO, "Loading \"%s\"", argv[i]); 1.29 - if (luaL_loadfile(L, argv[i])) { 1.30 - moonbr_log(LOG_ERR, "Error while loading \"%s\": %s", argv[i], lua_tostring(L, -1)); 1.31 - moonbr_terminate_error(); 1.32 - } 1.33 - if (lua_pcall(L, 0, 0, 1)) { 1.34 - moonbr_log(LOG_ERR, "Error while executing \"%s\": %s", argv[i], lua_tostring(L, -1)); 1.35 - moonbr_terminate_error(); 1.36 - } 1.37 - } 1.38 + moonbr_log(LOG_INFO, "Loading \"%s\"", argv[optind]); 1.39 + if (luaL_loadfile(L, argv[optind])) { 1.40 + moonbr_log(LOG_ERR, "Error while loading \"%s\": %s", argv[optind], lua_tostring(L, -1)); 1.41 + moonbr_terminate_error(); 1.42 + } 1.43 + { int i; for (i=optind+1; i<argc; i++) lua_pushstring(L, argv[i]); } 1.44 + if (lua_pcall(L, argc-(optind+1), 0, 1)) { 1.45 + moonbr_log(LOG_ERR, "Error while executing \"%s\": %s", argv[optind], lua_tostring(L, -1)); 1.46 + moonbr_terminate_error(); 1.47 } 1.48 lua_getglobal(L, "listen"); 1.49 lua_pushcfunction(L, moonbr_listen);