-run command option fix
This commit is contained in:
parent
79377476cb
commit
8d90513a6b
21
ml.cpp
21
ml.cpp
|
|
@ -2220,8 +2220,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
// help
|
// help
|
||||||
if (cmdOptionExists(argv, argv + argc, "-h")) {
|
if (cmdOptionExists(argv, argv + argc, "-h")) {
|
||||||
std::cout
|
std::cout << "Usage:\n\t-h print this help\n\t-b skip stdlib loading\n\t-c code - runs code passed on command line\n\t-f source_file - executes code in file\n\t-i runs repl\n\t-run used for shebang\n\t-p prints profile info at the end\n\t-d better stacktrace when exception\n\t-v prints version string\n\n";
|
||||||
<< "Usage:\n\t-h print this help\n\t-b skip stdlib loading\n\t-c code - runs code passed on command line\n\t-f source_file - executes code in file\n\t-i runs repl\n\t-run used for shebang\n\t-p prints profile info at the end\n\t-d better stacktrace when exception\n\t-v prints version string\n\n";
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// version
|
// version
|
||||||
|
|
@ -2236,15 +2235,17 @@ int main(int argc, char *argv[]) {
|
||||||
run(codes[i], env);
|
run(codes[i], env);
|
||||||
// run files
|
// run files
|
||||||
} else if (cmdOptionExists(argv, argv + argc, "-f")) {
|
} else if (cmdOptionExists(argv, argv + argc, "-f")) {
|
||||||
std::vector<std::string> files = getCmdOption(argv, argc, "-f");
|
for (auto & file : getCmdOption(argv, argc, "-f"))
|
||||||
for (size_t i = 0; i < files.size(); i++)
|
run(read_file_contents(file), env);
|
||||||
run(read_file_contents(files[i]), env);
|
|
||||||
// sheebang
|
// sheebang
|
||||||
} else if (argc == 3 && cmdOptionExists(argv, argv + argc, "-run")) {
|
} else if (cmdOptionExists(argv, argv + argc, "-run")) {
|
||||||
std::string file_content = read_file_contents(argv[2]);
|
for (auto & file : getCmdOption(argv, argc, "-run")) { // TODO check only one file is specified ??
|
||||||
if (file_content.find("#!") == 0) // shebang ?
|
std::string file_content = read_file_contents(file);
|
||||||
file_content.erase(0, file_content.find("\n") + 1); // TODO mac osx newline??
|
if (file_content.find("#!") == 0) // shebang ?
|
||||||
run(file_content, env);
|
file_content.erase(0, file_content.find("\n") + 1); // TODO mac osx newline??
|
||||||
|
|
||||||
|
run(file_content, env);
|
||||||
|
}
|
||||||
// repl
|
// repl
|
||||||
} else {
|
} else {
|
||||||
repl(env);
|
repl(env);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue