Skip to content

it is a lightweight Unix-compatible shell written in C, designed to mimic the behavior of traditional shells like bash and sh.

Notifications You must be signed in to change notification settings

Yogesh-rana-2301/ChefsShell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ChefsShell ♛

it is a lightweight Unix-compatible shell written in C, designed to mimic the behavior of traditional shells like bash and sh.

License: MIT Language: C Platform: Unix-like

Overview

ChefsShell is a functional command-line interpreter that will be supporting 10+ built-in commands, process creation, command execution, and memory-optimized operation. It serves as both a learning resource for understanding shell internals and a practical tool for Unix-like systems.

Features to be implemented

  • Built-in Commands: cd, pwd, echo, exit, clear, type, and more
  • Process Management: Uses fork() and execvp() to run external programs
  • Command Parsing: Tokenization, argument handling, and whitespace trimming
  • Memory Efficient: Optimized allocation and deallocation (20% reduced RAM usage)
  • Cross-Platform (Unix-like): Works on Linux and macOS
  • Error Handling: Clear error messages for invalid commands or missing executables
  • Scalable Codebase: Modular design for easy extension

Getting Started

Prerequisites

You need:

  • GCC or Clang compiler
  • Linux or macOS terminal

Clone the repository

Build

make

Run

./chefshell

Clean Build Artifacts

make clean

##� Usage Examples

Built-in Commands

$ cd ~/Documents
$ pwd
/home/user/Documents

$ echo Hello World
Hello World

$ type pwd
pwd is a shell builtin

$ clear
# Clears the terminal screen

$ exit
# Exits the shell

Running External Programs

$ ls -la
# Lists files with details

$ gcc file.c -o file
# Compiles a C program

$ ./file
# Executes the compiled program

Technical Highlights

Modular & OOP-Inspired Architecture

Although written in C, the project uses object-oriented design principles:

  • Separation of concerns across modules
  • Struct-based modular design
  • Clear abstraction boundaries between components

System Calls

ChefsShell leverages essential Unix system calls:

System Call Purpose
fork() Create child process
execvp() Execute external program
waitpid() Process synchronization
getcwd() Get current working directory (for pwd)
chdir() Change directory (for cd)

Memory Optimization

Effective use of:

  • Dynamic allocation (malloc, realloc)
  • Manual garbage cleanup
  • Avoiding leaks using structured free logic
  • Minimal memory footprint during execution

Roadmap

Planned enhancements:

  • Pipes (ls | grep txt)
  • Redirection (>, <, >>)
  • Command history (arrow key navigation)
  • Environment variable support ($PATH, $HOME)
  • Background execution (&)
  • Tab auto-completion
  • Signal handling (Ctrl+C, Ctrl+Z)
  • Scripting support (execute .sh files)

Contributing

Contributions, issues, and pull requests are welcome!

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Please ensure your code follows the existing style and includes appropriate comments.

Testing

To test the shell:

# Run built-in command tests
$ make test

# Manual testing
$ ./chefshell
$ echo $?  # Check exit status

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

  • Unix manual pages and POSIX standards
  • GNU Bash implementation details
  • Codecrafters Build your own X
  • The Unix philosophy of doing one thing well

Contact

For questions or suggestions, please open an issue on GitHub.

About

it is a lightweight Unix-compatible shell written in C, designed to mimic the behavior of traditional shells like bash and sh.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages