This project is a simple Unix shell written in C. It provides an interactive command-line environment that supports executing commands, handling pipelines, managing background jobs, and performing basic input/output redirection.
- Executes Unix commands using
execvp
. - Supports command-line arguments.
- Splits user input into tokens while respecting quotes and escape sequences.
- Supports variable expansion (e.g.,
$HOME
). - Expands wildcard patterns (
*
and?
) usingglob
.
- Supports chaining commands using the pipe (
|
) operator. - Redirects output of one command to the input of another.
- Input redirection (
<
): Read from a file instead of standard input. - Output redirection (
>
): Write output to a file (overwrite mode). - Append redirection (
>>
): Write output to a file (append mode). - Stderr redirection (
2>&1
): Redirects stderr to stdout.
- Commands ending with
&
run in the background. - Supports listing background jobs with
jobs
.
exit
- Exits the shell.cd
- Changes the working directory.clear
- Clears the screen.jobs
- Displays running background jobs.export
- Sets environment variables.
- Handles
SIGINT
(Ctrl+C) to prevent shell termination. - Gracefully handles child process termination.
- Clone this repository:
git clone https://github.com/jordyorel/orus_shell.git cd orus_shell
- Compile the shell:
gcc -o orus main.c -lreadline
- Run the shell:
./orus
Once inside the shell, you can:
- Run commands like
ls
,grep
,cat
, etc. - Use pipes:
ls | grep .c
- Redirect output:
ls > output.txt
- Run background processes:
sleep 10 &
- List jobs:
jobs
- Change directories:
cd /path/to/directory
- Exit:
exit
- No support for command substitution (
$(command)
). - No job control commands (
fg
,bg
,Ctrl+Z
). - No scripting capabilities (loops, conditionals, functions).
- Limited error handling for syntax errors.
- Implement
fg
andbg
commands for job control. - Improve error messages and debugging support.
- Add support for command substitution.
- Implement signal handling for stopping/resuming jobs (
Ctrl+Z
).
Feel free to fork the project and submit pull requests! For major changes, please open an issue first to discuss what you’d like to change.
This project is licensed under the MIT License.