Browse Source

Simple shell reading loop performed

Ivan Arkhipov 5 years ago
parent
commit
160c04969f
2 changed files with 21 additions and 2 deletions
  1. 3 2
      esh_init.c
  2. 18 0
      esh_main_loop.c

+ 3 - 2
esh_init.c

@@ -113,8 +113,9 @@ void EShProcessConfigFile() {
 	}
 
 	char* line = NULL;
-	ssize_t len;
-	int line_length;
+	ssize_t len = 0;
+	int line_length = 0;
+	
     while ((line_length = getline(&line, &len, file)) != -1) {
     	if (line[line_length - 1] == '\n') {
     		line[line_length - 1] = '\0';

+ 18 - 0
esh_main_loop.c

@@ -1,11 +1,29 @@
 #include "esh_main_loop.h"
+#include "esh_misc.h"
 
 void EShRunLoop() {
+	for (;;) {
+		EShShowMsg();
+		char* command = NULL;
+		int command_length = 0;
+		ssize_t buf_size = 0;
 
+	    while ((command_length = getline(&command, &buf_size, stdin)) == 0) {
+	    	// repeating
+	    }
+
+	    if (command_length == -1)
+	    	break;
+	}
 }
 
 void EShShowMsg() {
+	EShUpdateInviteMessage();
+	EShUpdateInviteMessage();
+	EShUpdateInviteMessage();
+	EShUpdateInviteMessage();
 
+	printf("%s", esh_info_global->invite_message);
 }
 
 void EShParseCommandIntoJobs(char* command) {