Advertisement
GoToBread

Shell interpreter in C

Nov 4th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.58 KB | None | 0 0
  1. //Command interpreter
  2.  
  3. #include <stdio.h>
  4.  
  5. char prompt[2] = "\nSHELL>";
  6. char* partOfString = "";
  7. char* command = "";
  8.  
  9. char space = ' ';
  10. char* echo = "echo";
  11.  
  12. void parseCommand()
  13. {
  14.     if(command[0] == '#') return; //this is a comment in the shell
  15.     //use strcmp and fscanf for I/O
  16.     //if (strcmp(command, "echo") printf("%s", partOfString);
  17. }
  18.  
  19. void promptUser()
  20. {
  21.     while(command != "" || command != "exit")
  22.     {
  23.         printf("%s", prompt);
  24.         scanf("%s", &command);
  25.         parseCommand();
  26.         if (command == "exit") break;
  27.     }
  28. }
  29.  
  30. int main()
  31. {
  32.     promptUser();
  33.     getchar();
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement