Added git ignore list.

parent 1738dc92
input.lex.*
input.yacc.*
shell
......@@ -39,7 +39,7 @@ Start: /* empty */
| Commands
;
Commands: Command
Commands: Command /*{ printf("cmd: %s\n", $1); }*/
/* | Command EOS*/
| Commands EOL { start_shell_entry(); } Command
| Commands '|' { start_shell_pipe(); } Command
......
......@@ -5,11 +5,14 @@
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <sys/stat.h>
#include "input.yacc.h"
#include "input.lex.h"
#include "input.l.h"
int is_interactive = 0;
void start_shell_pipe() {
printf("start pipe");
}
......@@ -19,13 +22,33 @@ void start_shell_entry() {
}
int main(void) {
yyset_debug(0);
// Detect if terminal is attached
struct stat stats;
fstat(0, &stats);
// Looks like a tty, so we're in interactive mode.
if (S_ISCHR(stats.st_mode)) {
is_interactive = 1;
start_shell_entry();
}
else if (S_ISFIFO(stats.st_mode))
// Looks like a pipe, so we're in non-interactive mode.
is_interactive = 1;
else {
is_interactive = 1;
start_shell_entry();
}
// Disable yacc debug mode
yyset_debug(1);
// Start the shell parser
if( yyparse() ) {
fprintf(stderr, "Error: Parsing failed\n");
return EXIT_FAILURE;
}
// EOF reached: clean up the mess
yylex_destroy();
if( yyin )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment