rsh (rishav's shell) is a basic shell developed as part of the CSE-1 course (Monsoon 2019) at IIIT Hyderabad.
Notable features include piping, redirection and proper job control with foreground and background job support. Also present is history recall and tab completion for filenames.
A variety of builtins have also been implemented (see src/builtin.c).
rsh uses the meson build system. To install, either apt install meson or brew install meson.
We also need the readline library. Either brew install readline or apt install libreadline-dev.
Then:
meson build
ninja -C build
The executable can be found at build/rsh.
- semi-colon delimited list of jobs:
cd /; pwd; ls - i/o redirection:
sort < in.txt > out.txt - piping:
cat in.txt | sort | wc -l > out.txt - start jobs in the background:
sleep 500 & - job suspension with CTRL-Z, along with job control using
fgandbg - view job list:
jobs - history recall and file-name completion
cronjob -c command -p cycle -t duration: runcommandeverycycleseconds fordurationseconds asynchronouslysetenvandunsetenvpinfo: show process infokjob: send signal to some arbitrary PIDoverkill: kill all background jobs
builtin.c: matches the input against the list of builtins; currentlycd,pwd,echo,ls,pinfo,nightswatch,dirty,interrupts,history,quit,jobs,setenv,unsetenv,fg,bg,kjob,overkill,cronjob.cronjob.c: implements the cronjob builtinenv.c: implements thesetenvandunsetenvbuiltinshistory.c: responsible for loading the history list from disk, maintaining it in memory, and persisting to file on exitls.c: implements thelsbuiltin. The-land-aoptions are implementednightswatch.c: implements thenightswatchbuiltin; supports thedirtyandinterruptssub-commandspinfo.c: implements thepinfobuiltin to fetch process information. Not supported on macOS due to lack of a procfsexternal.c: runs external commands (non-builtins); responsible for putting newly created processes into their own groups and handling terminal controlinterpret.c: checks if the input matches a builtin, otherwise delegates to the external handlermain.c: runs the main REPL loop. The main shell state data structure is also defined inmain.h. Also responsible for initializing the shell; handlingSIGCHLD, and saving the existing term attributes for restoring laterparse.c: tokenizes and parses the input line. Supports semicolon delimited commands, optionally ampersand terminated to indicate a background jobprompt.c: generates the promptutil.c: has utility functions for operating on the job table, etc.kill.c: implements thekjobandoverkillbuiltins
- Input of the form
foo>out.txtorfoo> out.txtis not parsed correctly.
See LICENSE.txt