- This is a Shell written in C for Linux operating system.
- lol this is part of an assignment at college
- I wouldn't recommend anyone installing it. 😂
- Go use bash instead of this.
- My
Ctrl+Z,Ctrl+Care Not working properly. - Go to the folder you wish, And Run:
$ git clone https://github.com/Abhinavreddy-B/C-Shell.git
- Compile as:
$ make (or) $ make main
- Run As:
$ ./main
- How To Exit?
- I am not a VIM user, I provide a way to exit my Shell.
- just press
Ctrl+D
2021101034
├── commands
│ ├── commands.h
│ ├── bg.c
│ ├── cd.c
│ ├── discover.c
│ ├── echo.c
│ ├── fg.c
│ ├── history.c
│ ├── jobs.c
│ ├── ls.c
│ ├── pinfo.c
│ ├── pwd.c
│ └── sig.c
├── Helpers
│ ├── Helpers.h
│ ├── add_to_list.c
│ ├── check_invalid.c
│ ├── getinfo.c
│ ├── History.c /* TO HANDLE HISTORY */
│ ├── interrupt_handlers.c
│ ├── ioredirect.c
│ ├── pipe.c
│ ├── process_creation.c
│ ├── splitter.c /* split the command among cd,ls,echo,..... */
│ └── tokenize.c
├── io_module
│ ├── input.c /* Taking input ( raw mode ) and autocompletion */
│ ├── input.h
│ ├── print_error.c
│ ├── print_error.h
│ ├── prompt.c
│ └── prompt.h
├── Linked_list
│ └── ADT for Linked List
├── main.c
├── makefile
├── headers.h
├── README.md
└── README.pdf
commands:contains implementations of built-in commands
Helpers:contains some helper functions
Linked_list:contains ADT for linked list (used in storing background process data)
io_module:function for taking input, printing errors and prompt
$ make
(or)
$ make main
$ ./main
assuming precendence order is
';'>'&'>'|'> (spaces and tabs) > (io redirection) . So tokenising accordingly.
- Spec1:
- Assuming that
<,>,>>would always be followed by a file name ( i.e commands like "cat < >" or "cat <" will give ambiguous results)
- Assuming that
- Spec2:
- the commands when using pipe run one command after the other
takes 10 seconds to execute.
~> sleep 5 | sleep 5
- the commands when using pipe run one command after the other
- Spec4:
bgis having problems with "vi" / "vim" due to some unknown vi bugs.
- Spec6:
- Everything is implemented as mentioned in the PDF
assumed all lengths such as
Maximum input size,Maximum directory path length,.... to be 1001
assuming precendence order is
';'>'&'>(spaces and tabs) . So tokenising accordingly.
Please use a terminal window of sufficient width so that text wrat does not cause any problem
- cd:
- Not handling
~when~is not at the start of the path (similar to bash). - maximum length of paths is
1001chars
- Not handling
- echo:
- printed as is irrespective of Quotes and newlines (
",\n,'). - handled space and '
\t' characters similar to bash ( replace multiple space / tabs with single space ).
- printed as is irrespective of Quotes and newlines (
- pwd:
- Did not check for the number of arguments passed ( since bash also does the same ).
absolute path
- ls:
- implemented same as that of Bash.
- assumed that there cant be paths like
/, where there are some special files / folders which are not handlable. - if there are multiple files / folders as arguments , we printed in the same order as given to us ( Bash prints for files first and directories next ).
- if the user name , or group name exceeds 15 characters , only the first 15 chars of their name are printed.
- pinfo:
- cannot read the executable path for certain processes like
systemd( pid - 1 ) , where user does not have appropriate permissions.
- cannot read the executable path for certain processes like
- History:
- even if the input has only a combination of spaces and tabs , they are being added to history.
- even if input is an invalid command it is being added to history.
- refraing from adding to history only when the new input is exact same as old one (including space / tabs ).
- saving history in a hidden file
.shell_history.tmp. any arbitrary changes made to this file while programme execution would not reflect and leads to unexpected errors.
- Background commands:
- running
vi/vimas a background process is creating problems due to some issues with inputs (stdin) on some machines. All other external commands work perfectly.
- running
- Foreground processes:
- The time taken printed is the sum of individual parts of command
sleep 3 ; sleep 4 would print the time taken as 7s