mirror of https://github.com/rusefi/lua.git
arguments "var=value" doesn't need quotes for value
This commit is contained in:
parent
5d89dad9b8
commit
69d97712ec
22
lua.c
22
lua.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lua.c,v 1.5 1997/11/21 19:00:46 roberto Exp roberto $
|
** $Id: lua.c,v 1.6 1997/12/01 20:31:25 roberto Exp roberto $
|
||||||
** Lua stand-alone interpreter
|
** Lua stand-alone interpreter
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -26,6 +26,21 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void assign (char *arg)
|
||||||
|
{
|
||||||
|
if (strlen(arg) >= 500)
|
||||||
|
fprintf(stderr, "lua: shell argument too long");
|
||||||
|
else {
|
||||||
|
char buffer[500];
|
||||||
|
char *eq = strchr(arg, '=');
|
||||||
|
lua_pushstring(eq+1);
|
||||||
|
strncpy(buffer, arg, eq-arg);
|
||||||
|
buffer[eq-arg] = 0;
|
||||||
|
lua_setglobal(buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void manual_input (void)
|
static void manual_input (void)
|
||||||
{
|
{
|
||||||
if (isatty(0)) {
|
if (isatty(0)) {
|
||||||
|
@ -65,12 +80,15 @@ int main (int argc, char *argv[])
|
||||||
else if (strcmp(argv[i], "-v") == 0)
|
else if (strcmp(argv[i], "-v") == 0)
|
||||||
printf("%s %s\n(written by %s)\n\n",
|
printf("%s %s\n(written by %s)\n\n",
|
||||||
LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS);
|
LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS);
|
||||||
else if ((strcmp(argv[i], "-e") == 0 && i++) || strchr(argv[i], '=')) {
|
else if (strcmp(argv[i], "-e") == 0) {
|
||||||
|
i++;
|
||||||
if (lua_dostring(argv[i]) != 0) {
|
if (lua_dostring(argv[i]) != 0) {
|
||||||
fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
|
fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (strchr(argv[i], '='))
|
||||||
|
assign(argv[i]);
|
||||||
else {
|
else {
|
||||||
int result = lua_dofile(argv[i]);
|
int result = lua_dofile(argv[i]);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
Loading…
Reference in New Issue