🐚 PyShell — A Feature-Rich POSIX-Compatible Shell in Python
A feature-rich, POSIX-compatible shell implemented in Python with advanced scripting capabilities.
Cross-platform and extensible, PyShell brings the power of Unix-style scripting to Python environments.
✨ Features
- POSIX Compatibility: Standard shell syntax (
if,while,for,case) - Advanced Arrays: Indexed and associative arrays
- Pipeline Support: Full pipe, redirection, and background job control
- Function Definitions: Shell functions with local variables
- Parameter Expansion:
${var:-default},${var#pattern}, etc. - Command Substitution:
$(command)and backtick syntax - Arithmetic Expansion:
$((expression))with full math operations - Brace Expansion:
{1..10},{a,b,c} - Glob Patterns:
*,?,[...]with extended matching - Built-in Commands: 50+ built-ins (
cd,echo,export,test,local, etc.) - Job Control: Background jobs with
fg/bg - History & Completion: Command history with readline integration
- Aliases: Command aliasing support
- Cross-Platform: Works on Linux, macOS, and Windows
🚀 Installation
<<<<<<< HEAD
From Source
git clone https://github.com/yogvidwankhede/PyShell.git
cd pyshell
pip install -e .
Using pip (once published)
=======
pip install pyshell-terminal
From Source
git clone https://github.com/yogvidwankhede/PyShell.git
cd PyShell
pip install -e .
📖 Usage
Interactive Mode
python main.py
Execute Command
python main.py -c "echo Hello World"
Run Script
python main.py script.sh
💡 Examples
Variables and Arrays
# Simple variables
name="PyShell"
echo $name
# Arrays
arr=(one two three)
echo ${arr[0]}
echo ${arr[@]}
# Associative arrays
declare -A config
config[host]="localhost"
config[port]=8080
echo ${config[host]}
Control Flow
# If statements
if [ -f "file.txt" ]; then
echo "File exists"
else
echo "File not found"
fi
# Loops
for i in {1..5}; do
echo "Count: $i"
done
# While loops
count=0
while [ $count -lt 5 ]; do
echo $count
count=$((count + 1))
done
Functions
greet() {
local name=$1
echo "Hello, $name!"
}
greet "World"
Pipelines and Redirection
# Pipes
cat file.txt | grep "pattern" | wc -l
# Redirection
echo "data" > output.txt
cat input.txt >> output.txt
command 2> errors.log
🏗️ Architecture
pyshell/
├── main.py # Entry point and REPL
├── pyshell/
│ ├── tokenizer.py # Lexical analysis
│ ├── parser.py # Syntax analysis
│ ├── executor.py # Command execution
│ ├── expansions.py # Variable/command expansion
│ ├── builtins.py # Built-in commands
│ ├── state.py # Global shell state
│ ├── ast_nodes.py # AST node definitions
│ ├── exceptions.py # Custom exceptions
│ └── utils.py # Utilities
└── tests/ # Test suite
🧪 Testing
python tests/run_all_tests.py
🤝 Contributing
Contributions are welcome! 🙌
- Fork the repository
- Create a feature branch
git checkout -b feature/AmazingFeature
- Commit your changes
git commit -m "Add some AmazingFeature"
- Push to your branch
git push origin feature/AmazingFeature
- Open a Pull Request
📝 Roadmap
- Tab completion improvements
- More POSIX test operators
- Process substitution
- Co-processes
- Additional shell options
- Performance optimizations
🙏 Acknowledgments
- Inspired by Bash, Zsh, and other Unix shells
- Built using Python’s
readlineandsubprocessmodules
Release files for pyshell-terminal 1.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyshell_terminal-1.1.2.tar.gz | 52.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyshell_terminal-1.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 94.9 kB
Release files / pyshell_terminal-1.1.2.tar.gz
| Download URL | pyshell_terminal-1.1.2.tar.gz |
|---|---|
| Size | 52.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b11d8f8f1c10348e1d28947641a6f71d7eb8a7bcdee9ca40aa2e71530fc659cd
|
|
BLAKE2b-256 checksum How to use checksums |
9c9328b8581cfe3a5b550a26c6c9f48b870c435e4f9176dab9600c3d6a5e1bce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / pyshell_terminal-1.1.2-py3-none-any.whl
| Download URL | pyshell_terminal-1.1.2-py3-none-any.whl |
|---|---|
| Size | 42.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba3902c675690648028ea86245c375b734bc937161c22c4fe516436aa69c5f10
|
|
BLAKE2b-256 checksum How to use checksums |
323b52487d9bad26bceb93ef1d1bb0c3f327b33d73e06812c8e41ff40a6ae82b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|