Run the following commands
make
- ./nyash
- Concatenate multiple commands in a single line by separating them with a semicolon
;
- Run processes in background by appending an ampersand
&
at the end of the command - NYASH displays the pid of such processes before executing them in the background
- Child handling: NYASH displays the exit status of such processes when they are terminated, suspended or continued.
< [FILE]
can be used to redirect input from the specified[FILE]
for a command> [FILE]
and>> [FILE]
can be used to redirect the output to the specified[FILE]
for a command.>
Overwrites the output file and>>
appends to the output file- Both input and output redirections can be used on a single command
- Example:
cat < input.txt > output.txt
- Example:
<command> | <command>
can be used to pipe the output of the command on the left side of the pipe to the command on the right side of the pipe- Two or more commands can be chained together by piping
- Piping can be used alongside input and output redirections
- Example:
cat < in.txt | wc -l > lines.txt
- Example:
- Note that in case of a conflict between taking input/output from the pipe or through a redirection, the redirection is given higher preference
- Example:
cat in.txt | sort > out.txt | wc -l
- This shall output 0 since the
sort
command redirects the output toout.txt
and not the pipe
- Example:
<ctrl>C
orSIGINT
does not kill NYASH<ctrl>Z
orSIGTSTP
does not kill NYASH<ctrl>D
or anEOF
safely logs out of the shell (functionally equivalent to theexit
command)
- NYASH comes with a sleek prompt displaying the username and the hostname of the machine, and the current working directory
Usage: cd [DIR]
- Here,
[DIR]
can take on any of the following values~
Changes directory to the home directory i.e. the directory from which the shell was executed-
Changes directory to the previous working directory- Any relative path from the home directory is valid
- Any absolute path (i.e. from the root directory) is valid
- Passing no arguments changes directory to the home directory
- Note that these are valid as long as the user has the appropriate permissions for the directory passed
Usage: pwd
Usage: echo [STRING]
- Note that quotes and escape characters are not handled. The passed string is tokenized based on whitespace before echoing.
Usage: ls [OPTIONS]... [FILE]...
- Here,
[OPTIONS]
can take any of the following values- Specifying no options prints only the names of the non-hidden files/folders from the FILEs passed
-a
(all) Behaves similar to no options but additionally prints hidden files-l
(long format) Prints additional info such as permissions, date modified, size for each non-hidden file- Note that multiple options can be used at the same time
- The
[FILE]
argument can be- A relative or absolute path to a file or a folder
- Note that the user is required to have appropriate permissions to read the details/contents of the file/folder
Usage: pinfo [pid]
- Displays the pid, process status, memory consumption and executable path for the specified process
- Passing a valid
pid
displays the info related to the specifiedpid
- If no arguments are passed, instead displays the info related to the current NYASH process
Usage: repeat [N >= 0] [command]
Usage: history [0 <= N <= 20]
- If no argument is passed, displays the 10 most recently used commands
- This data is stored in
/home/user/.nyash_history
to allow for persistent usage, deleting which may lead to loss of all history data
jobs - Displays the processes spawned by the shell which are either running or suspended along with a unique job number
Usage: jobs [OPTIONS]...
- Here
[OPTIONS]
can take any of the following values- Specifying no options prints all spawned processes which are either running or stopped
-r
prints only the currently running spawned processes-s
prints only the currently stopped spawned processes
- NYASH assigns a positive integer which is greater than all the current job numbers in use as the job number to a spawned process. Hence, multiple processes may have the same job number overall (due to the counter resetting by emptying the job list), but they will not share the same job number simultaneously. This feature was implemented in this way to avoid large job numbers through usage of the shell for a longer period.
Usage: sig [job_number] [signal_number]
- The
job_number
can be any of the job numbers listed using the commandjobs
- The
signal_number
can be any of the signals listed under the manpage signal(7)
Usage: fg [job_number]
- The
job_number
can be any of the job numbers listed using the commandjobs
Usage: bg [job_number]
- The
job_number
can be any of the job numbers listed using the commandjobs
replay - Executes a given command and repeats execution every specified interval of time for a total of a specified time period
Usage: replay [OPTIONS]...
- Here, the
[OPTIONS]
must include exactly one instance of the following-i
(or alternatively,--interval
and-interval
) Followed by a positive integer[N > 0]
which indicates the frequency of the replay command-p
(or alternatively,--period
and-period
) Followed by a positive integer[N > 0]
which indicates the total time period for which the replay command can be executed-c
(or alternatively,--command
and-command
) Followed by the command to be replayed<command>
- An additional feature of the
replay
command is that, it can be suspended via sending a signal<ctrl>Z
like any other system command and it is displayed as a job via thejobs
command
Usage: baywatch [OPTION] <command>
- Here, the
[OPTION]
must include exactly one instance of-n
followed by a positive integer[N > 0]
which specifies the interval for printing the command output
- Here, the
<command>
must be exactly one among the followinginterrupt
which prints the number of times the CPU(s) has been interrupted by the keyboard-controllernewborn
which prints the PID of the most recently created process on the systemdirty
which prints the size of the part of the memory which is dirty
- A keypress of
q
stops execution of the command
- The
main
function is contained inmain.c
- A few global variables used across multiple files are declared as
extern
variables in the fileglobals.h
- The
commands
folder contains the .c and .h files related to the commands implemented in NYASH named appropriately as the command which they are used in implementing - The
processor
folder contains the .c and .h files related to the child signal handling, prompt feature and execution of system commands in foreground and background - The
utils
folder contains the .c and .h files implementing various data-structres and functionality that are used throughout various other files- Including a vector of strings, linked list of strings, linked list of
job
struct and a tokenizer
- Including a vector of strings, linked list of strings, linked list of
| Hope you have an above average experience! :D