mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2026-04-26 20:17:58 +00:00
initial version
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mpw-shell.h"
|
||||
|
||||
|
||||
|
||||
|
||||
std::unordered_map<std::string, EnvironmentEntry> Environment;
|
||||
|
||||
|
||||
|
||||
|
||||
// should set {MPW}, {MPWVersion}, then execute {MPW}StartUp
|
||||
void init(void) {
|
||||
Environment.emplace("status", std::string("0"));
|
||||
Environment.emplace("exit", std::string("1")); // terminate script on error.
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
init();
|
||||
|
||||
command_ptr head;
|
||||
|
||||
|
||||
try {
|
||||
head = read_fd(0);
|
||||
} catch (std::exception &ex) {
|
||||
fprintf(stderr, "%s\n", ex.what());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
int status = execute(head);
|
||||
exit(status);
|
||||
} catch(std::exception &ex) {
|
||||
fprintf(stderr, "%s\n", ex.what());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user