Skip to main content

Butch - The free Batch interpreter

Named after the famous Pulp Fiction boxer Butch Coolidge from Tennessee.

How to run

Installation

pip install butch

Post-Installation

Make sure to run the test suite after the installation to verify everything works as it should. The test suite is included in the package itself, so it should be located in the first site-packages folder found via site.getsitepackages().

python -m unittest discover \
    $(python -c "import site;print(site.getsitepackages()[0])")/butch

Development

Get the latest version:

pip install https://github.com/KeyWeeUsr/butch/zipball/master

Running

Butch is available as a standalone executable as well as a Python module, therefore it can be invoked by any of these commands if installed properly:

butch
python -m butch

which will launch the REPL (console) directly.

Use butch /C "echo Hello, Batch" for interpreting a Batch command from a string or use butch /C hello.bat to run Batch from a file.

Use /K switch instead of /C to jump into the console after a command or a file finishes.

Use butch /h to display help for other switches.

Features

Commands

  • [ ] ASSOC

  • [ ] CALL

  • [X] CD

    pending:

    • [ ] /D change current drive + path

  • [X] CHDIR

  • [X] CLS

  • [ ] COLOR

  • [ ] COPY

  • [X] DATE

    pending:

    • [ ] set the system date when called without arguments

  • [X] DEL

    pending:

    • [ ] /F force deleting of read-only files

    • [ ] /S delete specified files from all subdirectories

    • [ ] /A selects files to delete based on attributes

  • [X] DIR

    pending:

    • [ ] Volume drive lookup

    • [ ] Volume label on drive

    • [ ] /A

    • [ ] /B

    • [ ] /C

    • [ ] /D

    • [ ] /L

    • [ ] /N

    • [ ] /O

    • [ ] /P

    • [ ] /Q

    • [ ] /S

    • [ ] /T

    • [ ] /W

    • [ ] /X

    • [ ] DIRCMD env variable preset

  • [X] ECHO

  • [ ] ENDLOCAL

  • [X] ERASE

  • [X] EXIT

  • [ ] FOR

  • [ ] FTYPE

  • [ ] GOTO

  • [ ] IF

  • [X] MD

  • [X] MKDIR

  • [ ] MKLINK

  • [ ] MOVE

  • [X] PATH

  • [X] PAUSE

  • [X] POPD

  • [X] PROMPT

  • [X] PUSHD

  • [X] RD

  • [X] REM

  • [ ] REN

  • [X] RMDIR

  • [/] SET

    pending:

    • [X] single value adding (set x=123)

    • [X] single value clearing (set x=)

    • [X] listing all stored variables (set)

    • [X] /P prompt for user input (set /P x=prompt)

    • [ ] case-insensitive access, but case-sensitive output

    • …

  • [ ] SETLOCAL

  • [ ] SHIFT

  • [ ] START

  • [X] TIME

    pending:

    • [ ] set the system time when called without arguments

  • [X] TITLE

  • [X] TYPE

  • [ ] VER

  • [ ] VERIFY

  • [ ] VOL

  • [X] ::

  • [ ] External commands

  • [ ] CLI prioritization of external commands

Syntax

  • [X] Echo off (@)

  • [X] Quotes (")

  • [X] Quotes (") in words

  • [ ] Conditions (IF, ELSE)

  • [ ] Caret escaping (^)

  • [ ] Code blocks ((, ))

  • [ ] Code blocks (multi-line block with (, ))

  • [X] Redirection to commands (| - pipes)

    pending:

    • [ ] RMDIR command doesn’t pull ctx.output and related parts

    • [ ] generic command I/O handling as a decorator/class?

  • [X] Output redirection (>, >>)

  • [X] Input redirection (<), e.g.: set /p key="prompt" < file

    https://ss64.com/nt/syntax-redirection.html

  • [ ] Special (reserved) names

  • [ ] Redirection to special (nul)

  • [ ] Joining streams (STDIN, STDOUT, STDERR, UNDEFINED (3-9)) (2>&1)

  • [ ] Command concatenation (&)

  • [ ] Command concatenation (&&)

  • [ ] Command concatenation (||)

  • [ ] Recognize Windows path separator in path input (\)

Console

  • [ ] /? as a proper help page trigger

  • [ ] /T for foreground/background colors

  • [ ] /A for printing only ANSI (which is most likely just 1252)

  • [ ] /U for printing Unicode (Unicode UCS-2 LE)

  • [ ] /D registry with autorun commands (.bashrc, kind of) + ignore

  • [ ] /E:ON|OFF, /X, /Y enable/disable command extensions

  • [ ] /S quote stripping from commands

  • [ ] /V:ON|OFF delayed expansion

TODO

  • [ ] Ensure for dynamic type checking

  • [ ] Mypy for static type checking

  • [/] Documentation

  • [X] PyPI package

  • [ ] Library interface for programmatic emulation

Metadata

Release files for butch 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for butch 1.0.0
File Interpreter ABI Platform
butch-1.0.0-py3-none-any.whl Python 3 none any Details

Release files / butch-1.0.0-py3-none-any.whl

Download URL butch-1.0.0-py3-none-any.whl
Size 94.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7070325e7da8ecc5cb5ddd2b27bb912b2b2a93330018d180ebc147dff33902fc
BLAKE2b-256 checksum
How to use checksums
d53a6074ff21aa34a52beba1fcc491ffef9bff4f12216e5a1b34fc76dc5f9c51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.10

Security for butch 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page