aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-03 17:57:54 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-03 17:57:54 -0200
commit69d97712ecfcd06aa4edb7374b262131210d0bbc (patch)
tree5f5bbee7a7bafa051792f2824875551bbb1fdd2e
parent5d89dad9b83be6e5e5013efdcdd7aee0d10b580c (diff)
downloadlua-69d97712ecfcd06aa4edb7374b262131210d0bbc.tar.gz
lua-69d97712ecfcd06aa4edb7374b262131210d0bbc.tar.bz2
lua-69d97712ecfcd06aa4edb7374b262131210d0bbc.zip
arguments "var=value" doesn't need quotes for value
-rw-r--r--lua.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/lua.c b/lua.c
index 2ebfc951..d2749ca4 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.5 1997/11/21 19:00:46 roberto Exp roberto $ 2** $Id: lua.c,v 1.6 1997/12/01 20:31:25 roberto Exp roberto $
3** Lua stand-alone interpreter 3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -26,6 +26,21 @@
26#endif 26#endif
27 27
28 28
29static void assign (char *arg)
30{
31 if (strlen(arg) >= 500)
32 fprintf(stderr, "lua: shell argument too long");
33 else {
34 char buffer[500];
35 char *eq = strchr(arg, '=');
36 lua_pushstring(eq+1);
37 strncpy(buffer, arg, eq-arg);
38 buffer[eq-arg] = 0;
39 lua_setglobal(buffer);
40 }
41}
42
43
29static void manual_input (void) 44static void manual_input (void)
30{ 45{
31 if (isatty(0)) { 46 if (isatty(0)) {
@@ -65,12 +80,15 @@ int main (int argc, char *argv[])
65 else if (strcmp(argv[i], "-v") == 0) 80 else if (strcmp(argv[i], "-v") == 0)
66 printf("%s %s\n(written by %s)\n\n", 81 printf("%s %s\n(written by %s)\n\n",
67 LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS); 82 LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS);
68 else if ((strcmp(argv[i], "-e") == 0 && i++) || strchr(argv[i], '=')) { 83 else if (strcmp(argv[i], "-e") == 0) {
84 i++;
69 if (lua_dostring(argv[i]) != 0) { 85 if (lua_dostring(argv[i]) != 0) {
70 fprintf(stderr, "lua: error running argument `%s'\n", argv[i]); 86 fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
71 return 1; 87 return 1;
72 } 88 }
73 } 89 }
90 else if (strchr(argv[i], '='))
91 assign(argv[i]);
74 else { 92 else {
75 int result = lua_dofile(argv[i]); 93 int result = lua_dofile(argv[i]);
76 if (result) { 94 if (result) {