A complex shell Implementation in C programming.
This project is about writing the most stable and most complete UNIXshell possible.
- Introduction
- Functionalities
- Features
- Usage
- Built-in Commands
- Prompt and Exit Status
- How to Compile
- Dependencies
Welcome to 42sh, your implementation of a UNIX-like shell written in C. This shell project is designed to provide basic and advanced functionalities similar to the Bash shell. Feel free to explore the features and contribute to its development.
42sh utilizes various functions and libraries to offer a comprehensive set of functionalities:
- Functions of the
terminfo
(ncurses) library - Functions from the
man 2
section - Memory management with
malloc
andfree
- File and directory operations with
access
,open
,close
,read
,write
,opendir
,readdir
,closedir
- Path and directory manipulation with
getcwd
,chdir
- File status operations with
stat
,lstat
- Process management with
fork
,execve
,waitpid
- Signal handling with
signal
,kill
- Process termination with
exit
- Pipe operations with
pipe
- File descriptor duplication with
dup
,dup2
- Terminal-related functions with
isatty
,ioctl
,tcsetattr
,tcgetattr
42sh comes with the following features:
- Execute basic commands
- Execute complex commands with separators, pipes, and redirections
- Manage its own environment
- Built-in commands including
cd
,echo
,env
,printenv
,pwd
,setenv
,unsetenv
- Prompt based on the last exit status
- Support for non-interactive mode (running process in background/foreground)
Explore more functionalities as you dive into the shell!
# Example compilation command
make
# Example execution command
./42sh [OPTIONS]
42sh supports the following built-in commands:
cd
/chdir
: Change current directoryecho
: Display messagesenv
: Display or modify environment variablesprintenv
: Display environment variablespwd
: Print the current working directorysetenv
: Set environment variablesunsetenv
: Unset environment variables ...
The shell provides a dynamic prompt based on the last exit status, making it easier to understand the outcome of the previous command.
# Example compilation command
make all
Ensure you have the following dependencies installed:
- [cc/gcc, (readline)]