Custom shell in low level C for Linux & Mac.
S. No | Topic |
---|---|
1 | Usage |
2 | Features |
3 | Built-In Commands |
4 | File Structure |
5 | Naming of the Shell |
6 | To-Do |
7 | Author(s) |
-
git clone https://github.com/Ahish9009/ash/
-
cd ash
-
on
Linux
:make linux
onMacOS
:make mac
ormake
-
./ash
-
make clean
- Set of self-written custom built-in commands
- Self written and customized
- Run within the shell's process itself
- The list of built-in commands can be found here
- Supports semi-colon separated commands
- Eg.
ls ; cd ..; echo
- Eg.
- Supports multiple piping
- Eg.
ls | cat | tail -3
- Eg.
- Supports input & output redirection
- Eg.
cat < inp > out
- Eg.
- Allows job control/process management
- Jobs can be run in the foreground or background
- Background jobs can be brought to the foreground and vice versa
- Process exit status is displayed on termination of a background job
- Stores command history
- Handles/traps signals
CTRL-Z
sends the job(s) in the foreground to the backgroundCTRL-C
terminates the current foreground job
- Previous commands can be recalled using the
up arrow key
- The nth command can be recalled by pressing the
up arrow key
n times and hittingenter
- The nth command can be recalled by pressing the
The following self-written commands are built into the shell:
ls -[al] [path/to/dir]
- Lists files in the specified directory
- Lists files of the current directory if no path is specified
-l
: list in long format with more details-a
: display hidden files (those starting with '.')
cd [path/to/dir]
- Changes working directory to the path specified
- Accepts both absolute and relative paths
cd -
: switches to the previous working directorycd
: switches to the root directory
pwd
- returns the name of the current working directory
echo -[n] [string ...]
- write arguments to the standard output
-n
: does not print the trailing newline character
jobs
- display status of jobs in the current session
kjob <signal number> [pid ...]
- send the specified signal to the specified processes
- Multiple pids can be passed
history [n]
- displays the history of commands
- passing a number n as argument displays the last n entries
fg [job id]
- runs the job specified by <job id> in the foreground
- <job id> can be found using
jobs
bg [job id]
- run the job specified by <job id> in the background
- <job id> can be found using
jobs
overkill
- kill all background processes
ps [pid]
- shows information on the process specified by the pid
- shows shell process information if no argument is passed
set_env [name] [value]
- sets the environment variable name to have the specified value
unset_env [name]
- unsets the environment variable name
cronjob -c [command] -t [time] -p [period]
- executes command every time seconds for period duration
.
├── HEADERS
│ ├── bg.h
│ ├── cd.h
│ ├── cronjob.h
│ ├── echo.h
│ ├── env.h
│ ├── exec.h
│ ├── fg.h
│ ├── help.h
│ ├── history.h
│ ├── jobs.h
│ ├── kjob.h
│ ├── ls.h
│ ├── overkill.h
│ ├── parse.h
│ ├── pcwd.h
│ ├── ps.h
│ ├── processes.h
│ ├── prompt.h
│ ├── redirect.h
│ ├── signals.h
│ ├── sort.h
│ └── utils.h
│
└── SOURCE FILES
├── bg.c
├── cd.c
├── cronjob.c
├── echo.c
├── env.c
├── exec.c
├── fg.c
├── help.c
├── history.c
├── jobs.c
├── kjob.c
├── ls.c
├── overkill.c
├── parse.c
├── pcwd.c
├── ps.c
├── processes.c
├── prompt.c
├── redirect.c
├── shell.c
├── signals.c
├── sort.c
└── utils.c
The s in ash is to emphasize the absence of an 's' before the first 'h' in Ahish 😛
The shell is named using the "<initial>SH" convention
- Wildcard substitution
- Memory leaks 😛
- Test linux more