Commits

Steven! Ragnarök committed f7e940e

Change the shell's name to pash.

Comments (0)

Files changed (7)

 LIB_DEPS=-lreadline
 CFLAGS=-Wall -g -I$(INC_DIR)
 
-default: bin/sh142
+default: bin/pash
 
 testutils: $(patsubst $(UTIL_DIR)/$(SRC_DIR)/%.c,$(UTIL_DIR)/%,$(wildcard $(UTIL_DIR)/$(SRC_DIR)/*.c))
 
 
 dylibs: $(DYN_DIR)/test_function.so $(DYN_DIR)/path_lookup.so
 
-$(BIN_DIR)/sh142: $(SRC_DIR)/main.c dependencies
+$(BIN_DIR)/pash: $(SRC_DIR)/main.c dependencies
 	$(CC) obj/* $(LIB_DEPS) $(SRC_DIR)/main.c $(CFLAGS) -o $@
 
 $(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(INC_DIR)/%.h
 unit: dylibs
 	ruby -r"rake" -r"rake/testtask" -e"Rake::TestTask.new; Rake::Task[:test].invoke"
 
-cuke: bin/sh142
+cuke: bin/pash
 	cucumber features/ -t ~@skipme
 
 modules.png: modules.dot
 
 clean:
 	# Cleaning _NEVER_ fails.
-	rm *.o sh142 obj/* bin/* examples/* test_utils/* &>/dev/null && exit 0 || exit 0
+	rm *.o pash obj/* bin/* examples/* test_utils/* &>/dev/null && exit 0 || exit 0
 
 .PHONY: clean cuke test testutils unit default
 

include/interpreter.h

-#ifndef SH142TYPES
-#include "sh142types.h"
+#ifndef PASHTYPES
+#include "pashtypes.h"
 #endif
 #include "path_lookup.h"
 #include "fifo.h"
-#ifndef SH142TYPES
-#include "./sh142types.h"
+#ifndef PASHTYPES
+#include "./pashtypes.h"
 #endif
 
 /* The parser takes an input array of tokens and builds an

include/pashtypes.h

+/* Protect from multiple inclusion */
+#define PASHTYPES
+/* The maximum size of a single token. */
+#define MAX_TOKEN_LENGTH 64
+#define MAX_STRING_LENGTH 256
+#define MAX_SAVED_EXITSTATUSES 10
+
+/* Different types of tokens!!!! */
+typedef enum {
+	VARASSIGN, VALUE, VARIABLE, COMMAND, ARGLIST, REDIRECTLIST, STDIN_REDIRECT,
+	STDOUT_REDIRECT, STDERR_REDIRECT, DATA_VARIABLE, BACKGROUND_KEY,
+	NEGATED_COMMAND
+} node_type;
+
+/* Since we have mutually recursive structures, we need to use forward
+ * declaration and thus, cannot omit the struct name.
+ */
+typedef struct sllist strlist;
+typedef struct nodelist ast_nodelist;
+typedef struct node ast_node;
+
+
+struct node {
+	node_type type;
+	char token[MAX_TOKEN_LENGTH];
+	ast_nodelist *children;
+};
+
+struct nodelist {
+	ast_node *node;
+	ast_nodelist *next;
+};
+
+struct sllist {
+	char str[MAX_TOKEN_LENGTH];
+	strlist *next;
+};
+

include/sh142types.h

-/* Protect from multiple inclusion */
-#define SH142TYPES
-/* The maximum size of a single token. */
-#define MAX_TOKEN_LENGTH 64
-#define MAX_STRING_LENGTH 256
-#define MAX_SAVED_EXITSTATUSES 10
-
-/* Different types of tokens!!!! */
-typedef enum {
-	VARASSIGN, VALUE, VARIABLE, COMMAND, ARGLIST, REDIRECTLIST, STDIN_REDIRECT,
-	STDOUT_REDIRECT, STDERR_REDIRECT, DATA_VARIABLE, BACKGROUND_KEY,
-	NEGATED_COMMAND
-} node_type;
-
-/* Since we have mutually recursive structures, we need to use forward
- * declaration and thus, cannot omit the struct name.
- */
-typedef struct sllist strlist;
-typedef struct nodelist ast_nodelist;
-typedef struct node ast_node;
-
-
-struct node {
-	node_type type;
-	char token[MAX_TOKEN_LENGTH];
-	ast_nodelist *children;
-};
-
-struct nodelist {
-	ast_node *node;
-	ast_nodelist *next;
-};
-
-struct sllist {
-	char str[MAX_TOKEN_LENGTH];
-	strlist *next;
-};
-

src/interpreter.c

 
 		execerr = execvp(command->token, argv);
 		if (execerr == -1) {
-			fprintf(stderr, "sh142: %s: command not found.\n", argv[0]);
+			fprintf(stderr, "pash: %s: command not found.\n", argv[0]);
 			exit(127);
 		}
 	} else {
 #include "../include/interpreter.h"
 
 /* The prompt string printed by Readline */
-#define PROMPT_STRING "sh142$ "
+#define PROMPT_STRING "pash$ "
 
 void load_config_files(void);
 void prepare_fifo(void);
 	int fd[2];
 	char lsbuffer[MAX_STRING_LENGTH], sourcebuffer[MAX_STRING_LENGTH];
 	FILE *ls_output, *source_file;
-	const char *fileext = ".sh142\n";
+	const char *fileext = ".pash\n";
 
 	pipe(fd);
 	ls_pid = fork();