aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-22 16:05:23 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>1997-12-22 16:05:23 -0200
commit43461d267f6f9925bac60064d682790c9bcb9ad5 (patch)
tree97b3b6a381dfe0d00329bd7cd834ba395b3a529e
parentfae0b5282562cb1814f1bcaf9a6eb25cb0d37111 (diff)
downloadlua-43461d267f6f9925bac60064d682790c9bcb9ad5.tar.gz
lua-43461d267f6f9925bac60064d682790c9bcb9ad5.tar.bz2
lua-43461d267f6f9925bac60064d682790c9bcb9ad5.zip
help message
-rw-r--r--lua.c69
1 files changed, 42 insertions, 27 deletions
diff --git a/lua.c b/lua.c
index 275abe75..bb4730af 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.9 1997/12/11 17:00:21 roberto Exp roberto $ 2** $Id: lua.c,v 1.10 1997/12/19 18:34:23 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*/
@@ -25,16 +25,20 @@
25#define isatty(x) (x==0) /* assume stdin is a tty */ 25#define isatty(x) (x==0) /* assume stdin is a tty */
26#endif 26#endif
27 27
28/* command line options: 28
29** -v print version information (banner). 29static void print_message (void)
30** -d debug on 30{
31** -e dostring on next arg 31 fprintf(stderr,
32** a=b sets global 'a' with string 'b' 32"Lua: command line options:\n"
33** -q interactive mode without prompt 33" -v print version information\n"
34** -i interactive mode with prompt 34" -d turn debug on\n"
35** - executes stdin as a file 35" -e stat dostring `stat'\n"
36** name dofile "name" 36" -q interactive mode without prompt\n"
37*/ 37" -i interactive mode with prompt\n"
38" - executes stdin as a file\n"
39" a=b sets global `a' with string `b'\n"
40" name dofile `name'\n\n");
41}
38 42
39 43
40static void assign (char *arg) 44static void assign (char *arg)
@@ -104,22 +108,33 @@ int main (int argc, char *argv[])
104 lua_dofile(NULL); /* executes stdin as a file */ 108 lua_dofile(NULL); /* executes stdin as a file */
105 } 109 }
106 else for (i=1; i<argc; i++) { 110 else for (i=1; i<argc; i++) {
107 if (strcmp(argv[i], "-") == 0) 111 if (argv[i][0] == '-') { /* option? */
108 lua_dofile(NULL); /* executes stdin as a file */ 112 switch (argv[i][1]) {
109 else if (strcmp(argv[i], "-i") == 0) 113 case 0:
110 manual_input(1); 114 lua_dofile(NULL); /* executes stdin as a file */
111 else if (strcmp(argv[i], "-q") == 0) 115 break;
112 manual_input(0); 116 case 'i':
113 else if (strcmp(argv[i], "-d") == 0) 117 manual_input(1);
114 lua_debug = 1; 118 break;
115 else if (strcmp(argv[i], "-v") == 0) 119 case 'q':
116 printf("%s %s\n(written by %s)\n\n", 120 manual_input(0);
117 LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS); 121 break;
118 else if (strcmp(argv[i], "-e") == 0) { 122 case 'd':
119 i++; 123 lua_debug = 1;
120 if (lua_dostring(argv[i]) != 0) { 124 break;
121 fprintf(stderr, "lua: error running argument `%s'\n", argv[i]); 125 case 'v':
122 return 1; 126 printf("%s %s\n(written by %s)\n\n",
127 LUA_VERSION, LUA_COPYRIGHT, LUA_AUTHORS);
128 break;
129 case 'e':
130 i++;
131 if (lua_dostring(argv[i]) != 0) {
132 fprintf(stderr, "lua: error running argument `%s'\n", argv[i]);
133 return 1;
134 }
135 break;
136 default:
137 print_message();
123 } 138 }
124 } 139 }
125 else if (strchr(argv[i], '=')) 140 else if (strchr(argv[i], '='))