Skip to main content

Main workflow

libdash is a fork of the Linux Kernel's dash shell that builds a linkable library with extra exposed interfaces. The primary use of libdash is to parse shell scripts, but it could be used for more.

The Python bindings are packaged as the libdash PyPi package.

The OCaml bindings---packaged as the libdash OPAM package---include two executables, shell_to_json and json_to_shell, which let you conveniently parse POSIX shell scripts into a JSON AST.

What are the dependencies?

The C code for dash should build on a wide variety of systems; it requires libtool and autotools (aclocal, autoheader, automake, autoconf). The library may not build on platforms with esoteric linkers; it's been tested on macOS and Linux.

The Python and OCaml bindings depend on being able to build the C code. See libdash.opam for details on the OCaml code's dependencies, which includes the build-time external dependencies. Python wheels have no need for these build-time dependencies, but building from a Python source distribution will only succeed when libtool and autotools are present.

The CI scripts (in .github/workflows/build.yml) give build details.

How to build libdash from source

Python

Run python3 setup.py install. On macOS, you must first install the build dependencies via brew install libtool autoconf automake.

You can test the Python bindings by running:

cd python; make test

OCaml

Install the OPAM file: opam pin add . or opam install .. This will build the OCaml library and install it in your OPAM repository. There are tests in another directory; they will only build when libdash is actually installed.

You can test the OCaml bindings by running:

cd ocaml; make test

Testing

The tests use test/round_trip.sh to ensure that every tester file in test/tests round-trips correctly through parsing and pretty printing.

Additionally, you can run tests that compare the OCaml and Python implementations (after you've installed them both):

cd test; make

How to use the parser

For Python, see python/rt.py, an example tool that does a round-trip: shell syntax to AST back to shell syntax.

For OCaml, see ocaml/shell_to_json.ml, a tool that parses shell syntax and produces JSON (using the atdgen bindings).

The ideal low-level interface to use is parsecmd_safe in parser.c; you'll need to ensure that dash's initialization routines have been called and that the stack marks are managed correctly. Parsing the POSIX shell is a complicated affair: beyond the usual locale issues, aliases affect the lexer, so one must use setalias and unalias to manage any aliases that ought to exist.

How work with the parsed nodes

The general AST is described in nodes.h. There are some tricky invariants around the precise formatting of control codes; the OCaml code shows some examples of working with the args fields in ocaml/ast.ml, which converts the C AST to an OCaml AST.

The OCaml tools shell_to_json and json_to_shell will produce JSON ASTs, allowing you to work with these ASTs in any language.

Pretty printing

The pretty printer does its best to produce valid shell scripts, but it's possible to manually construct AST nodes that don't directly correspond to valid scripts.

For example, the Python AST [[['Q', [['C', 34]]]]] represents a quoted field containing a double quote character. Translated literally, this would yield the string """, which is not a valid shell script. The pretty printer will instead automatically escape the inner quote, rendering "\"".

While the printer tries to get things right either way, you should use escapes to signal to the printer when to escape: you should use the Python AST [[['Q', [['E', 34]]]]] to mark the inner double quote as escaped.

Known issues

We currently do not escape the character ! (exclamation point). In an interactive shell, ! is likely treated as a history substitution (and so should be escaped), but in a non-interactive shell, ! is treated normally. We currently cater to non-interactive shells; eventually this behavior will be controllable.

Download files

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

Source Distribution

libdash-0.5.0.tar.gz (181.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

libdash-0.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl (271.1 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

libdash-0.5.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (280.9 kB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libdash-0.5.0-cp314-cp314t-macosx_11_0_arm64.whl (159.9 kB view details)

Uploaded CPython 3.14tmacOS 11.0+ ARM64

libdash-0.5.0-cp314-cp314-musllinux_1_2_x86_64.whl (271.1 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

libdash-0.5.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (280.9 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libdash-0.5.0-cp314-cp314-macosx_11_0_arm64.whl (159.9 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

libdash-0.5.0-cp313-cp313-musllinux_1_2_x86_64.whl (271.1 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

libdash-0.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (280.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libdash-0.5.0-cp313-cp313-macosx_11_0_arm64.whl (159.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

libdash-0.5.0-cp312-cp312-musllinux_1_2_x86_64.whl (271.1 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

libdash-0.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (280.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libdash-0.5.0-cp312-cp312-macosx_11_0_arm64.whl (159.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

libdash-0.5.0-cp311-cp311-musllinux_1_2_x86_64.whl (271.1 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

libdash-0.5.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (280.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libdash-0.5.0-cp311-cp311-macosx_11_0_arm64.whl (159.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

libdash-0.5.0-cp310-cp310-musllinux_1_2_x86_64.whl (271.1 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

libdash-0.5.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (280.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libdash-0.5.0-cp310-cp310-macosx_11_0_arm64.whl (159.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

libdash-0.5.0-cp39-cp39-musllinux_1_2_x86_64.whl (271.1 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

libdash-0.5.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (280.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libdash-0.5.0-cp39-cp39-macosx_11_0_arm64.whl (159.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

libdash-0.5.0-cp38-cp38-musllinux_1_2_x86_64.whl (270.9 kB view details)

Uploaded CPython 3.8musllinux: musl 1.2+ x86-64

libdash-0.5.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (280.7 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

libdash-0.5.0-cp38-cp38-macosx_11_0_arm64.whl (160.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

File details

Details for the file libdash-0.5.0.tar.gz.

File metadata

  • Download URL: libdash-0.5.0.tar.gz
  • Upload date:
  • Size: 181.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for libdash-0.5.0.tar.gz
Algorithm Hash digest
SHA256 31940be1397fe5e9d53414e58beefa80dd66288293ef3c71aa68f3ff262fe964
MD5 2121140efb16389c3441cc140a2ed5f5
BLAKE2b-256 b327075ea3b44c64616e268367713988f52e7c83cb262aac4ed9e323a39d4065

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3230357029f9c0021ee37def4fe45998eb896dbdef641dfa8f16bd86973450dd
MD5 78c88689b32a80c17a5098053e4fce9c
BLAKE2b-256 02a744eb24ed4517b3170a04825dc513060998352b3126783071a8783c4297e1

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp314-cp314t-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 990033ab20b553e97a3a4fd1a40bbc607b5ea7a6a10c9c9c9acc9f63522a0d2c
MD5 825bcee317213f855ecf290ffb893cb1
BLAKE2b-256 d270d56eafa92b4a4eb4963452abfa6afd856c59e9b6b92dc7f5dc49a9750238

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp314-cp314t-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp314-cp314t-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d8b7974303bc2e0046c2d6fd93589959ee45a7b6d27cd3526a3cbbb0892fdbe9
MD5 d3b280383923728c28d0331f6782db2c
BLAKE2b-256 20a5233dc5d7f1bcc9396e2ec023d0a2147a740665a7c0ce159df94b9332a514

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 027453215226ae7ac559b505c0bb660ef9ef1a34ef76bf790a88478f3b7e9a8a
MD5 09dfdaf88c385e2518b5c3c128224109
BLAKE2b-256 f5c89ca5760eb75ff3a0a1bf38eebd32526f721f413df526b60041890cd12569

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 713e5a72169b6f09750dd1aa20483f68e014be5930ba0eaa72591789b23041c2
MD5 91c8e615331ca42dc3f6fe495888a553
BLAKE2b-256 09513d3e8de70f4cd6704be015e23ff9e9ebcb32fe447d692c03bbe77dabfcec

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a46aa0305e3ec8e67e9f02d5f68b52022c26fa83f6f031f32e38122ac2f9da92
MD5 14a8e30185bfe79e4270bb62ea3d6f39
BLAKE2b-256 85624db919cebe1877ac44be6eee7b99e7e54ac3f6829e9354aea5c2d573cfef

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e7e5d36c652df3ef4520aaad858575e87782b3aa3537eb05b055376ae3489fc3
MD5 28192f0c7b4e01a970262cc7a2576bdf
BLAKE2b-256 5b303f49c5d130dff26e9e2522964b90ca97866c9ea12e541e8fe9dfa80ea27a

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 65bcad03622f10ecff17c6aacfcae4210826c201497131b7267e8670821037fa
MD5 e8556c3dca7b84ad7aab2c4717af4444
BLAKE2b-256 bcb7ff9b0f0c493b5cda94b9094b2f6fa0a06c0e6db716724779b3ea3c710774

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c42ef4c8ea6effd78edece95428ec68dde13a79832d36dde091e7e3a9c913424
MD5 4c528af833608a3f912bd29c4c8681e7
BLAKE2b-256 6a3b6114455eb27470a6735fcec44bf7bac271b388009af46b2c14379994084c

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3911ef9254c8dc401c394df237388e2d4128407496c023bcb8e794abe4014fe5
MD5 747d27fb86755642de7af44e6e91be98
BLAKE2b-256 e572e467de309e8813411969d7ace25292139744f4515986a2a69f94d159dc79

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e48fc6cd63e6a929fa2ca36a0fc39f810cdb8ceb5aa702707c4dfff652533c68
MD5 4d274855240155f13dc343ff01128ab9
BLAKE2b-256 c6a63c318168c7da487cc05cf663557a01ec602fdc7ad15030ca409718e97be3

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad12a82a95eb0e22e9c838f30ebb3fdcbbe7cf2b353d5b8d9abe9883434942e3
MD5 0305bcf34dec7864fe97cceacbd7ab62
BLAKE2b-256 3e5aa1bf5c751e346203a0017bd81dbf28ac5cb94115262a4b0b1817a6c292ed

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c4e1d86767f571d9e08e395c35c8d9b4a0020b00865f6c07bde768231513c1dd
MD5 e98fe57752c1a08875675c125cb0d1f4
BLAKE2b-256 f55ce8516a0dceb3790aa8c7ccd5841669bb5eadd8436360287ddf0f8e59a767

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c5b31314993f891582e0ddb3417fa50756d8899fdc43bcf0dce297321aaca9d5
MD5 aef60247a0d14400706c66d0582a5a63
BLAKE2b-256 a7657de6fe3a3661484d5e101d6c8bea513e6a2fc66722079ea30c70ffd2404b

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab85a895bd7a4752cf437554897b62cee8bcd78e4374e5aa2d5ec0ba68cfa17d
MD5 183ffb4c4d24e288440b409a6f1c8a83
BLAKE2b-256 c690f240a53de880e62976500a862ab4f6cbe5c2c63c9db27f9a4daa3fe40d01

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 bd697268ee6c03262a427b916d8228861a9507aba95585f39e03fff989eab79f
MD5 fae4f147ef38b16fd01747c337587ca0
BLAKE2b-256 701e3a286ae20f6951a42ad1a94632e6ec6ae3d5a8dc18342250deeb85240084

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2838196676d582d4383a02daa8ced74b7239fd15413c5ceb8040ece708fad761
MD5 7b4df8c68b2a09186e9798ab52c0712f
BLAKE2b-256 dcffdd4b94fc546bdf52f1f1d2fd9f97f78f69b787e67b1495d358752a3cd410

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d814932511868575505043cf63c66051a9968dbeb65000b5c3e02fc76369a3b4
MD5 ea4fe90e62afd68a49488e8533fe4209
BLAKE2b-256 357461b7fba863a2100f34ed472f52d731e0c36aee1939cb411b684d664d4348

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a04f08fcd1477872fda3fa8535bbd6897b232ad14dbb335c3bec275c9d3ae826
MD5 e52460bcc0630eb75ecbad3c58a48c88
BLAKE2b-256 f6777350077b7094746657cb8bb123a60e0a17f4d9724e8b6f97f21c6140e652

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 de55e741d39ab99e46595ac66fd1f88b214e735f4f21e0a08a8eef341672c191
MD5 b6504354c42ee2c1fd058cfa63ce891b
BLAKE2b-256 a3b3a744f8056a523e5b843d6faa97e70662887b052011a6cd582bd282f93df3

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7bd57348a6817583da518896bb8120f32204ed41b9006ceb9e0fa55b6d8fb1f9
MD5 c138bd200a5b90322dd1480ec93b3915
BLAKE2b-256 9e6ceeeee1cd411a924702855ee6953fedea23aef500569533813c7d8573752c

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp38-cp38-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d544c19e5a027e9e7c2bd68013821f73e1b2dc54071bb3004f0966cb1e0c3eca
MD5 7b54daadc1c0f95d26a1db6d7ab35f4f
BLAKE2b-256 98869343145f56104ad5b3d4a63b933f48a5ca48c83cab157d931b055656d7b4

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp38-cp38-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 05749302f563f098c2613efa0564721503e9dc401efe2bacf8262bfd79feb48b
MD5 788c3089b4612a37cf0555eb35e068eb
BLAKE2b-256 c4392ba97510c401ab67c6f0b07b0f4c695f21a3a56eb32ec29ddab6ac5c8815

See more details on using hashes here.

File details

Details for the file libdash-0.5.0-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for libdash-0.5.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20ab378908c62da14df6e60cb6e098bd3392def8ae789e22aeef32a83a8b25e4
MD5 1b2c203bd319c0e7ed8d4dba8f7aead2
BLAKE2b-256 793291a71f33bae61ba0e94c09b50f5433b2b8f99ab9ad458cbc5bbb0e12aee0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page