This is a linux shell implemented in c
supports ';', piping and redirection (<, > , >>).
signals CTRL+Z and CTRL+C are handled.
The built in commands are :-- ls (-al)
, echo
, pwd
, cd
, pinfo
, history
, nightswatch
(both interrupt
and newborn
), setenv var [value]
, unsetenv var
, jobs
kjob <job number> <signal number>
, fg <job number>
, bg <job number>
, overkill
, quit
.
it prints out a prompt in the form of <username@system_name:curr_dir>
it prints :')
before the prompt if the previous command executed normally, otherwise prints :'(
can create background process using an &
at the end of the command
displays <command name> with pid <pid> exited with code <exit code>
when a background process ends
to run
$ make
$ ./tushell
to exit
$ quit
or
$ ^D
inside the program. This kills all bbackground processes created by the program and then terminates. ^C might not do the same and can sometimes give errors
shell.c
: this is where the shell runs from.bg.c
: where background processes are created, and where jobs, kjob, fg, bg are implemented.fg.c
: where the foreground process runs fromchange_dir.c
: where cd is implementedecho.c
: where echo is implemented.exit.c
: where the quit and overkill is implementedget_prompt.c
: where pwd and printing the prompt is implementedhistory.c
: this creates a file calledhistory_tush.txt
WHEREVER THE TERMINAL IS RUN FROM. So if you run it from two different locations, it gives different histories for them.ls.c
: where ls is outputted from. flags -l,-a,-la,-al are implemented. It outputs everything in a column (even if -l is not specified).nightswatch.c
: where nightswatch is implemented. it exits the loop with "q\n". by default it executes every 5 seconds.pinfo.c
: this is where pinfo is implemented
-pwd
, cd
, echo
are in-built. teh command cd -
is valid and goes to the previous working directory.
ls [-la]
is in-built. Even if[-l]
is not specified, it outputs the file names in a column.pinfo [pid(optional)]
is in-built.history [number (optional)]
is in-built. by default it gives the last 10. if it has to give n previous commands, but it has stored less commands, then it outputs all the commands it can output. Number has to be a two-digit (or one-digit) number.