From af33b469e3cebe77808b305ed49df5ee5b9be512 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sun, 30 Mar 2014 21:09:15 +0300 Subject: [PATCH] Added README file to the project - changed the exec name in Makefile to cshell --- Makefile | 2 +- README.txt | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 README.txt diff --git a/Makefile b/Makefile index 726fb0e..a29ac96 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ SOURCES=main.c OBJECTS=$(SOURCES:.c=.o) # executable name -EXECUTABLE=myTerminal +EXECUTABLE=cshell $(EXECUTABLE): $(OBJECTS) @echo "Building target" $@ "..." diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..08b8404 --- /dev/null +++ b/README.txt @@ -0,0 +1,89 @@ +Sagi Dayan 2014 + +----------------------------- +OS course Ex1 - Home - cshell +----------------------------- + +this project is a basic Terminal emulator written in C for OS course in JCE. + +This Terminal will be able to run almost all programs in the PATH /bin/ +and will create a new process of that . + +the Prompt format: + @$ + +the exit code is the Return code from the last child process. +if 0 -> child ended successfully. + +for more details see Q&A + +sagi dayan (c) 2014. + +------------ +Build & Run & Exit +------------ +To build cshell run in terminal: make +and run with the command: cshell +to quit run from cshell: exit + +to clean the directory run: make clean + +------------------------- +Design Decisions & Issues +------------------------- +the main idea is to be able to run & create processes via commands. +you can enter almost any basic command (and some more) that the binarys are in +PATH /bin/ . + +Main issues: + * you cannot navigate to different directories. + * you cannot pipe command and arguments. + * every word will be treated as an argumant! + therefore you cannot write something like: + $ ls -a > "my text.txt" + cshell will see the arguments as: + # ls + # -a + # > + # "my + # text.text" + + and that will throw you an error. + + + +------- +Q&A +------- +Q: can i redirect output to a file? +A: yes you can. use the "redirect" char '>' and then the file name. + like so: + $ man ls > myFile.txt + Note: the content of the file Will be deleted, in othe words, it acts + exactly like '>' in the UNIX Shell. not '>>'. + Note2: the file name must be in one word. as you can see in Issues, + cshell dose not support an argument that is seperated with space or tab. + +Q: what is that wired number before the prompt? +A: that wierd number is atually the return code of the last process that you ran. + the Unix defult return code of a succssesful end of process will be 0. otherwise, + in case fo an error or an exception, the code can be any number (code) that the + developer of that specific software maked down to exit at. + +Q: why 255? +A: as i noticed, the defaul code of "exit(1)" is actually 256, but + in the exersize wanted to return 255 in case of an "unknown command" or default + exit(1). + +Q: why cant i exit cshell with ctrl-c (^C)? +A: because that was also another task in this Ex. + only running childes will be killed, while the main process (cshell) + will stay running and kicking. + +Q: So how to exit? +A: run 'exit'. + +Q: Can i redirect stderr output to file? +A: No. the task was to implament only regular output. + +