py-posix-shell
py-posix-shell is a cross-platform POSIX-style shell implemented in pure
Python. The long-term goal is to become a practical dash-like shell that can
run on Windows, Linux, and macOS from the same Python package.
It is still young, but it now supports the pieces needed by many ordinary shell scripts:
- command lists with
;,&&,||, background&, and! - pipelines with
| if/elif/else/fifor,while, anduntilloops withbreakandcontinuecase/esac- POSIX-style functions with
return - grouping with
{ ...; }and subshells with( ... ) - quoting with single quotes, double quotes, and backslash escapes
- parameter expansion such as
$HOME,$?,${name:-word},${name:=word},${#name},${name#pattern},${name##pattern},${name%pattern}, and${name%%pattern} - arithmetic expansion with
$(( expression )) - command substitution with
$(...)and backticks - field splitting, pathname expansion, tilde expansion, and
set -f - here-documents with
<<and<<- - redirection with
<,>,>>,<>,2>,2>>,>&, and<& - interactive filename completion with
Tab - shell variables, exported environment variables, and positional parameters
- common builtins including
.,:,alias,unalias,cd,pwd,eval,exec,exit,export,readonly,unset,set,shift,getopts,echo,printf,read,type,command,env,test,[,trap,umask,times,hash, andhistory - internal POSIX/GNU-style utility fallbacks for hosts such as Windows where
commands may be missing. The shell prefers a native command when it exists and
otherwise falls back to Python implementations of common tools including
ls,cat,cp,mv,rm,install,unlink,mkdir,rmdir,pwd,sort,uniq,wc,cut,head,tail,chmod,chown,chgrp,echo,date,sleep,printf,basename,dirname,whoami,yes,clear,help,find,xargs,locate,updatedb,diff,cmp,diff3,sdiff,grep,egrep,fgrep,sed,awk,gawk,base64,tr,vi, andtar
The implementation intentionally remains dependency-free at runtime. It aims for
useful POSIX behavior first, then progressively tighter compatibility with
dash.
Known gaps include job control, full signal semantics, complete interactive line
editing, and exact set -e edge cases.
Installation
From PyPI:
pip install py-posix-shell
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
Build the package with:
poetry build
Metadata
Release files for py-posix-shell 0.4.26
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py_posix_shell-0.4.26.tar.gz | 716.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py_posix_shell-0.4.26-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 793.0 kB
Release files / py_posix_shell-0.4.26.tar.gz
| Download URL | py_posix_shell-0.4.26.tar.gz |
|---|---|
| Size | 716.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adba5de63db6ea8e2b42e53829e8c2ce6efab7bd7e1aa9e9dc782dea788af723
|
|
BLAKE2b-256 checksum How to use checksums |
6e27a827150d360222f962d2cc4c3dd5802268fa100f740bceb2f833a8868898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|
Release files / py_posix_shell-0.4.26-py3-none-any.whl
| Download URL | py_posix_shell-0.4.26-py3-none-any.whl |
|---|---|
| Size | 76.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87a297012d48a868a8d11eae28da3eb44e3a11d04733c1b7fd772155905022c0
|
|
BLAKE2b-256 checksum How to use checksums |
b06dcd339050ed1c1107ae00d831457eafaf5240217e89921894198b7d7c733d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.11.15 Windows/10
|