Skip to main content

The free Batch interpreter

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

butch-1.0.0-py3-none-any.whl (94.4 kB view details)

Uploaded Python 3

File details

Details for the file butch-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: butch-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 94.4 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for butch-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7070325e7da8ecc5cb5ddd2b27bb912b2b2a93330018d180ebc147dff33902fc
MD5 43d4c1ea8e0109a435ecf634dc8c155f
BLAKE2b-256 d53a6074ff21aa34a52beba1fcc491ffef9bff4f12216e5a1b34fc76dc5f9c51

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page