s.c 593 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <sys/wait.h>
  5. #include <unistd.h>
  6. #include "region.h"
  7. #include "reporting.h"
  8. #include "stringport.h"
  9. #include "tokenizer.h"
  10. #include "parser.h"
  11. #include "interpreter.h"
  12. #include "builtins.h"
  13. int main(int argc, char **argv)
  14. {
  15. int i;
  16. FILE *f;
  17. setenv("SHELL", "/bin/s", 1);
  18. if (argc == 1) {
  19. f = stdin;
  20. interactive_mode = isatty(fileno(stdin));
  21. }
  22. else {
  23. f = fopen(argv[1], "r");
  24. if (!f) {
  25. reporterr("Could not open file <%s>!", argv[1]);
  26. exit(-1);
  27. }
  28. interactive_mode = 0;
  29. }
  30. loop(f);
  31. return 0;
  32. }