mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2025-03-15 04:32:00 +00:00
-c support
This commit is contained in:
parent
bfd1e353e5
commit
69476fd0e0
@ -154,9 +154,15 @@ int main(int argc, char **argv) {
|
||||
Environment e;
|
||||
init(e);
|
||||
|
||||
const char *cflag = nullptr;
|
||||
|
||||
int c;
|
||||
while ((c = getopt(argc, argv, "D:v:h")) != -1) {
|
||||
while ((c = getopt(argc, argv, "c:D:v:h")) != -1) {
|
||||
switch (c) {
|
||||
case 'c':
|
||||
// -c command
|
||||
cflag = optarg;
|
||||
break;
|
||||
case 'D':
|
||||
// -Dname or -Dname=value
|
||||
define(e, optarg);
|
||||
@ -205,17 +211,25 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
};
|
||||
|
||||
fprintf(stdout, "MPW Shell 0.0\n");
|
||||
if (!cflag) fprintf(stdout, "MPW Shell 0.0\n");
|
||||
e.startup(true);
|
||||
read_file(p1, "/Users/kelvin/mpw/Startup");
|
||||
//p2.finish();
|
||||
e.startup(false);
|
||||
|
||||
if (cflag) {
|
||||
std::string s(cflag);
|
||||
s.push_back('\n');
|
||||
p1.process(s.data(), s.data() + s.length(), true);
|
||||
p2.finish();
|
||||
exit(e.status());
|
||||
}
|
||||
|
||||
if (isatty(STDIN_FILENO))
|
||||
interactive(p1);
|
||||
else
|
||||
read_fd(p1, STDIN_FILENO);
|
||||
p2.finish();
|
||||
|
||||
return 0;
|
||||
exit(e.status());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user