A custom shell implementation in C
-
Clone the repository
git clone https://github.com/OSN-Monsoon-2024/mini-project-1-JBalwaySUS.git -
Compile the executable
make all -
Run the excutable
./a.out
Size of input buffer is 4096 characters i.e. for multiple commands or for single a single long command, the max no. of characters in one line of input can only be 4096 characters.
Using the '-l' flags reports the file size in terms of 1KB blocks like ls in bash. It receives the no. of 512-Byte Blocks from the sys/stat.h structure field st_block and divides it by 2 to display the same no. of blocks as ls -l in bash
-
A log file is created at the directory where the shell is invoked from and the log is persistant for shells invoked from the same directory
For eg:
If shell is invoked from
/home/username/, amysh.logis created at/home/username/and the log commands persist for any shell invoked from this directory even if they are run after chnaging directories.But if shell is invoked from
/home/username/seashell, a new log file is created at this directory and the commands in thismysh.logwill be unique from the one in/home/username -
The log file also stores commands which resulted in an error.
The Virtual memory field displays the memory used by the process in Bytes.
Using the -e flag on a file tries to execute the file or directory as specified but if it fails to do so, it tries to print out the contents of the file. Upon failure of both only does it print "Missing permissions for this task!" to stderr
- Definition of an alias must begin with the keyword
aliasfollowed by the alias name = command to be aliased. For eg:alias reveala = reveal -a - The log file stores the alias without any modifications.
- The maximum number of aliases that can be stored is
4096.
- Definition of a function must begin with the keyword
funcfollowed by the function name and the command to be executed is enclosed within{}on separate lines. For eg:func revealall() { reveal -a } - The log file stores the function name without any modifications.
- The maximum number of functions that can be stored is
4096.
-
I/O Redirections assumes that files dont have to be written and appeneded to in the same command. For eg:
cat < file1 << file2is not supported. -
I/O Redirection assumes the next argument after the redirection operator (i.e.
<,>or>>) is the file to be read from or written to.
And this file must be at the end of the command.
-
The piping is done sequentially i.e. the first command is executed and then the output is piped to the next command.
Unlike bash, the commands are not executed in parallel. -
Background processes cannot be piped into other commands. For eg:
cat file.txt & | wcis NOT supported.
But the last command in a pipe can be a background process. For eg:cat file.txt | wc &is supported.
Rediraction is done before piping i.e. the output of the redirection is piped to the next command.
Therefore if output is redirected to a file, the next command in the pipe will not have any output to work with.
-
The maximum number of background processes that can be launched is
4096over the span of a single terminal session. -
The activites stores the process id and the command that was run.
It does not store any arguments that were passed to the command.
ping assumes all commands are of the form:
ping <pid> <signal>
i.e. multiple signals cannot be sent in a single command.
-
Similar to
ping,fgandbgassume all commands are of the form:fg <pid>orbg <pid>i.e. typingfgorbgwithout a pid will not work like in bash. -
A background process does not have access to the terminal and bringing such a process to the foreground, will cause the process to run in foreground with no access to
STDINorSTDOUTSimilarly, a foreground process cannot be run in the background using
bgdoing so hijacks the terminal.
If not time is specified using -n, the default time is 1 second.
iMan only searches for the first argument in the command and displays the online manual for that command.
All other arguments are ignored.