ISHell is Linux command-line shell implemented in C. It provides users most of the common features of a Unix-like shell but with a simpler interface and implementation. The shell supports command execution, process management, I/O redirection, piping, signal handling, autocompletion, and built-in commands.
The shell supports a variety of built-in commands implemented in C, including:
echo
: Display text.cd
: Change directory.pwd
: Print working directory.exit
: Exit the shell.ls
: List files and directories.pinfo
: Retrieve process information.history
: Show command history.discover
: Search files/directories.jobs
: List background processes.sig
: Send signals to jobs.fg
: Bring jobs to the foreground.bg
: Resume stopped jobs in the background.
- Command System: Supports both foreground and background processes, allowing users to chain commands using
;
and&
operators.
- Comprehensive Tracking: Background processes initiated with the
&
operator are monitored, enabling users to control them through built-in commands likejobs
,fg
,bg
, andsig
. - Enhanced Multitasking: Provides a flexible environment for handling multiple processes simultaneously.
- I/O Redirection: Users can redirect output to files or take input from files seamlessly using
<
,>
, and>>
. - Piping Support: Allows the output of one command to be used as the input for another command, supporting complex command sequences.
- Responsive to Signals: The shell handles common signals such as Ctrl+C (terminate), Ctrl+Z (background), and Ctrl+D (logout) for a smooth user experience.
- Intuitive Suggestions: Autocompletion enhances user experience by providing file or directory name suggestions based on current input when the tab key is pressed.
The C-Shell is designed to meet several specifications:
- Input/Output Redirection: Supports redirection of both input and output with appropriate error handling.
- Command Pipelines: Allows chaining commands using pipes (
|
) for seamless data flow between commands. - Signal Handling: Responds appropriately to user signals for managing process states.
- Autocompletion: Implements tab completion for commands and file names.
- Build the Project: Compile the shell using:
make
- Run the Shell: Execute the shell with:
./shell
Kindly refer description.md for some notes on the implementation of the shell.
- All commands are limited to a maximum size of 1000 characters.
- The shell currently differentiates between
(filename)
, '(filename)', and "(filename)", and only expects the first format. - The maximum number of
;
or&
separators in a single command is 10,000. - Quotes are not processed in any command except for the
discover
command, where they are used to distinguish a filename from the target directory. - The completion of background processes is managed through probing.
- The flags
-df
and-fd
can be used as shorthand for-d -f
. - Control sequences such as Ctrl+C and Ctrl+Z are not handled by the shell.
- The
discover
command accepts a maximum of three arguments. - The
ls
command lists all files, directories, and executables in alphabetical order, displaying each argument in the order provided when multiple arguments are given. - Command history varies based on the directory from which the shell is spawned; to maintain continuous history, the shell should be started from the same directory.
- Invalid commands entered as background processes are executed as separate processes, even if their output consists solely of error messages.
- When multiple processes are executed using
;
or&
, the time taken by the last foreground process is displayed.