Skip to main content

Bashup Version Build Coverage Health

Compatibility Implementations Format Downloads

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

See this document for planned features.

Changelog

2.0.2

  • Fixed PyPI release.

2.0.1

2.0.0

1.1.2

1.1.1

  • Tweaked the README.

1.1.0

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)

Source distribution for bashup 2.0.2
File Size Uploaded
bashup-2.0.2.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bashup 2.0.2
File Interpreter ABI Platform
bashup-2.0.2-py2.py3-none-any.whl Python 3, Python 2 none any Details

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

Release history Release notifications | RSS feed

This release

2.0.2 This release

2 release files

2.0.1

1 release file

2.0.0

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

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