Added README file to the project - changed the exec name in Makefile to cshell

This commit is contained in:
Sagi Dayan 2014-03-30 21:09:15 +03:00
parent 1bca3de24d
commit af33b469e3
2 changed files with 90 additions and 1 deletions

View File

@ -20,7 +20,7 @@ SOURCES=main.c
OBJECTS=$(SOURCES:.c=.o)
# executable name
EXECUTABLE=myTerminal
EXECUTABLE=cshell
$(EXECUTABLE): $(OBJECTS)
@echo "Building target" $@ "..."

89
README.txt Normal file
View File

@ -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/<bin name>
and will create a new process of that <bin name>.
the Prompt format:
<exit code> <userName>@<hostName>$
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.