shebang support added
This commit is contained in:
6
ml.cpp
6
ml.cpp
@@ -1886,6 +1886,12 @@ int main(int argc, char *argv[]) {
|
||||
std::vector<std::string> files = getCmdOption(argv, argc, "-f");
|
||||
for (size_t i = 0; i < files.size(); i++)
|
||||
run(read_file_contents(files[i]), env);
|
||||
// just one parameter - filename
|
||||
} else if (argc == 2) {
|
||||
std::string file_content = read_file_contents(argv[1]);
|
||||
if (file_content.find("#!") == 0) // shebang ?
|
||||
file_content.erase(0, file_content.find("\n") + 1); // TODO mac osx newline??
|
||||
run(file_content, env);
|
||||
// repl
|
||||
} else {
|
||||
repl(env);
|
||||
|
||||
Reference in New Issue
Block a user