Skip to content

RustamSheoran/Shell-C-plusplus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shell++

A modern C++20 command-line shell implementation featuring AST-based parsing, interactive editing, and comprehensive job control.

Features

  • AST-Based Command Parsing: Full abstract syntax tree with operator precedence
  • 28 Built-in Commands: Including job control, directory navigation, and variable management
  • Interactive Shell: Line editing, command history, and tab completion
  • Job Control: Background/foreground process management with signals
  • I/O Redirection: File descriptors and pipelines
  • Memory Management: Custom polymorphic allocators for performance

Quick Start

mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make shell
./shell

Built-in Commands

Category Commands
Navigation cd, pwd, pushd, popd, dirs
Job Control fg, bg, jobs, disown, wait, kill
Variables export, unset, declare, local, readonly, shift
History history, fc
Utilities echo, type, hash, help, true, false, exit
I/O test, [, read, printf

Architecture

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│   Input     │───▶│   Parser    │───▶│  Executor   │
│ (Terminal)  │    │   (AST)     │    │ (Builtins)  │
└─────────────┘    └─────────────┘    └─────────────┘

Building

Requirements

  • C++20 compatible compiler (GCC 11+ or Clang 14+)
  • CMake 3.16+
  • Google Test (for tests)

Build Commands

# Debug build with tests
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON
make -j$(nproc)

# Run tests
ctest --output-on-failure

# Release build
cmake .. -DCMAKE_BUILD_TYPE=Release
make shell

Usage

Interactive Mode

$ ./shell
$ echo "Hello, World!"
Hello, World!
$ ls -la
$ cd /tmp
$ pwd
/tmp

Background Jobs

$ sleep 10 &
[1] 12345
$ jobs
[1]+ Running sleep 10 &
$ fg %1

Command History

$ history
1  echo "Hello"
2  ls -la
$ !1
echo "Hello"
Hello

Testing

cd build
ctest --output-on-failure

Test coverage:

  • 82 tests passing
  • AST nodes, parser, executor, builtins
  • Integration tests
  • Performance benchmarks
  • Edge case handling

Performance

  • Command execution: ~1.2ms
  • Complex pipelines: ~4ms
  • Throughput: 782 commands/second
  • Memory: Stable under load

License

MIT License - see LICENSE file.

Contributing

Contributions welcome! Please ensure:

  • Code follows C++20 standards
  • All tests pass
  • Commit messages are descriptive

Project Status

Shell++ is a fully functional command shell with:

  • Complete AST-based parsing and execution
  • 28 built-in commands
  • Interactive features (history, completion, editing)
  • Comprehensive test suite (82 tests)
  • Production-ready code quality

About

Modern C++20 command-line shell with AST-based parsing, interactive editing, job control, pipelines, and 28 built-in commands.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors