Bashup

A (toy) language that compiles to bash. You can think of bashup as just a little syntactic sugar sprinkled on top of bash; any valid bash script is also a valid bashup script.
Just a spoonful of sugar makes the bashisms go down…
#!/bin/bash
@fn hi greeting='Hello', target {
echo "${greeting}, ${target}!"
}
hi --target='World'
Installation:
$ pip install bashup
Compile and run the above example:
$ bashup -i above_example.bashup -o above_example.sh
$ bash above_example.sh
Hello, World!
Or just run it directly:
$ bashup -r above_example.bashup
Hello, World!
Compiled code (above_example.sh):
#!/bin/bash
#
# usage: hi [--greeting=<GREETING>] --target=<TARGET> [ARGS]
#
hi() {
local greeting='Hello'
local target
local target__set=0
local args=()
while (( $# )); do
if [[ "${1}" == --greeting=* ]]; then
greeting=${1#--greeting=}
elif [[ "${1}" == --target=* ]]; then
target=${1#--target=}
target__set=1
else
args+=("${1}")
fi
shift
done
if ! (( target__set )); then
echo "[ERROR] The --target parameter must be given."
return 1
fi
__hi "${greeting}" "${target}" "${args[@]}"
}
__hi() {
local greeting=${1}
local target=${2}
shift 2
echo "${greeting}, ${target}!"
}
hi --target='World'
Supported Bash Versions
The generated bash code works with bash 3.1 and above (tested against 3.1 to 4.3).
Nifty Features
Bashup tries its best to match the indentation of its compiled code against your hand-written bash. For example:
@fn hi greeting='Hello', target {
echo "${greeting}, ${target}!"
}
…compiles to:
#
# usage: hi [--greeting=<GREETING>] --target=<TARGET> [ARGS]
#
hi() {
local greeting='Hello'
local target
local target__set=0
local args=()
while (( $# )); do
if [[ "${1}" == --greeting=* ]; then
greeting=${1#--greeting=}
...
Planned Improvements
Changelog
2.0.2
Fixed PyPI release.
2.0.1
Fixed - Issue #9: “Misc updates”
2.0.0
1.1.2
Badges now use shields.io.
Fixed - Issue #5: “Make compatible with latest “themattrix/tox” Docker baseimage.”
1.1.1
Tweaked the README.
1.1.0
Fixed - Issue #2: “Run generated bash code against multiple versions of bash.”
Feature - Issue #3: “Allow running of bashup scripts directly.”
Fixed - Issue #4: “Last positional parameter to @fn may not be passed to generated function.”
1.0.0
Initial release, supports @fn syntax.
Metadata
Release files for bashup 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bashup-2.0.2.tar.gz | 6.6 kB | Without provenance | Details for bashup-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bashup-2.0.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for bashup-2.0.2-py2.py3-none-any.whl |
Total release size: 14.4 kB
Release files / bashup-2.0.2.tar.gz
| Download URL | bashup-2.0.2.tar.gz |
|---|---|
| Size | 6.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b433fda415e76f8ac0c86fbb5389f5b67cccccbaaf301a39b6ed191c2dfd6c7e
|
|
BLAKE2b-256 checksum How to use checksums |
311d8aee7145db8d5bc19016c407dd7e2d6fc3f9dc162f7c5d821b8b9c07d25f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / bashup-2.0.2-py2.py3-none-any.whl
| Download URL | bashup-2.0.2-py2.py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
3ffa2b723f78e5eda159bea8a67ebb99215600df299b8a03b86cffa9aff5506a
|
|
BLAKE2b-256 checksum How to use checksums |
4ba587d43661f2c273ca5e7e92190dc90fc403db91fe2fd65bdf26adf3ef4923
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for bashup 2.0.2
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.