A small cross-platform POSIX-style shell written in Python.
Project description
py-posix-shell
py-posix-shell is a small POSIX-style shell implemented in pure Python. It is
intended to run on Windows, Linux, and macOS with the same Python package and the
same console entry point.
The project focuses on a practical, compact subset of POSIX shell behavior:
- command lists with
;,&&,||, and background& - pipelines with
| - quoting with single quotes, double quotes, and backslash escapes
- parameter expansion such as
$HOME,$?,${name:-word}, and${name:=word} - command substitution with
$(...)and backticks - field splitting, pathname expansion, and tilde expansion
- redirection with
<,>,>>,2>,2>>,>&, and<& - shell variables, exported environment variables, and positional parameters
- common builtins including
cd,pwd,exit,export,unset,set,shift,echo,printf,read,type,command,env,test, and[
It deliberately does not try to be a full replacement for dash, bash, or
zsh. Complex POSIX features such as functions, aliases, job control, traps,
arithmetic expansion, case/esac, for/while/until loops, and here-documents are
not implemented yet.
Installation
From this repository:
pip install .
For editable development:
pip install -e ".[dev]"
Usage
Start an interactive shell:
pysh
Run one command:
pysh -c "name=world; echo \"hello $name\""
Run a script:
pysh ./script.sh arg1 arg2
The package also installs the longer py-posix-shell command.
Development
Run the tests with:
pytest
The implementation uses only the Python standard library at runtime.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_posix_shell-0.1.0.tar.gz.
File metadata
- Download URL: py_posix_shell-0.1.0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93648200042e23820666be6253021726d5543749463619fc3450b255ac1db86a
|
|
| MD5 |
25b40fecf28703ac6d0dda350082ee82
|
|
| BLAKE2b-256 |
c17898c49f9207eb6529e356531e661f162cef506e9ae7ec3bc6cc2d7ff21445
|
File details
Details for the file py_posix_shell-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_posix_shell-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.11.15 Windows/10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2bb8ef7391fee5c51c6851f480c6ed55bc7e6a3a8444312de63fa614b4c3084e
|
|
| MD5 |
794926d890c9ebf4211b50dcbc27e1df
|
|
| BLAKE2b-256 |
5194a8e1faeedb89452da3e91cc2bfcf601760e52908e6f5ed890b75d9673914
|