ESH

Executive Shell
git clone http://git.omkov.net/ESH
Log | Tree | Refs | README | Download

AuthorJamozed <[email protected]>
Date2021-09-12 05:50:16
Commit7e36ae142479671fd82e18aceaf0bb9738761644
Parenta690d360e9b0fb87c2b8af544b59df28d8ee5148

Fix words being ignored by the lexer in some cases

Diffstat

M CHANGELOG | 4 ++++
M CMakeLists.txt | 2 +-
M src/lex.c | 28 ++++++++++++++--------------
M src/main.c | 2 +-

4 files changed, 20 insertions, 16 deletions

diff --git a/CHANGELOG b/CHANGELOG
index 29c67e5..8412762 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+0.5.1, 
+* Implement pipe handling
+* Implement redirect handling
+
 0.5.0, 2021-09-11
 * Rename OSH to ESH
 * Implement --help and --version
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1683268..0a3762f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,5 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
-PROJECT(ESH VERSION 0.5.0 LANGUAGES C)
+PROJECT(ESH VERSION 0.5.1 LANGUAGES C)
 
 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
 ADD_COMPILE_DEFINITIONS(PROJECT_VERSION="${PROJECT_VERSION}")
diff --git a/src/lex.c b/src/lex.c
index 60315e3..73c79bf 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -64,23 +64,23 @@ skip:;
 
 	if (l->sp == l->sl) { n.k = LK_EOF; goto ret; }
 	if (C == '\n' || C == ';') { l->sp += 1; n.k = LK_END; goto ret; }
+	
 	if (C == '#') { for (l->sp += 1; C != '\n'; l->sp += 1) {} goto skip; }
 
-	for (n.k = LK_WORD, ss = &C; l->sp != l->sl && C != '\n' && C != ';';) {
-		if (isspace(C)) { l->sp += 1; break; }
-		
-		/*
-			FIXME currently words are ignored if they are immediately followed
-			by another character such as '|', '<', or '>'
-		*/
+	ss = &C; if (l->sp != l->sl && C != '\n' && C != ';') {
 		switch (C) {
-		case '\'': { /* TODO */ } break;
-		case '\"': { /* TODO */ } break;
-		case '|':  { n.k = LK_PIPE; } goto esc_1;
-		case '<':  { n.k = LK_RDIN; } goto esc_1;
-		case '>':  { n.k = LK_ROUT; } goto esc_1;
-		esc_1: { ss = &C; sl += 1; l->sp += 1; } goto end;
-		default: { sl += 1; l->sp += 1; } break;
+		case '|': { n.k = LK_PIPE; } goto esc_1;
+		case '<': { n.k = LK_RDIN; } goto esc_1;
+		case '>': { n.k = LK_ROUT; } goto esc_1;
+		esc_1: { /*ss = &C;*/ sl += 1; l->sp += 1; } goto end;
+		
+		/* Parse anything else as a word */
+		default: { n.k = LK_WORD; /*sl += 1; l->sp += 1;*/ } break;
+		}
+		
+		for (; l->sp != l->sl && C != '\n' && C != ';' && C != ' ';) {
+			if (C == '|' || C == '<' || C == '>') { break; }
+			else { sl += 1; l->sp += 1; }
 		}
 	}
 
diff --git a/src/main.c b/src/main.c
index 3b92251..2487ab0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -79,7 +79,7 @@ int main(int ac, char *av[]) { (void)(ac); A0 = av[0];
 	signal(SIGINT, &reset); signal(SIGTSTP, SIG_IGN); signal(SIGQUIT, SIG_IGN);
 	if (errno) { warn("%s", serr()); }
 
-	eshrc();
+	if (!Lflag) { eshrc(); }
 
 	do {
 		if (sigsetjmp(jmp, 1)) { fputc('\n', stdout); } jmpflag = true;