Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script that downloads Babashka if not available and runs the file as a Babashka script afterwards
#!/usr/bin/env bash
#_(
bb_dir="$HOME/.bb"
if [ ! -x "$bb_dir/bb" ]; then
echo "Babashka not found. Installing it at $bb_dir directory..."
download_dir="$(mktemp -d)"
trap "rm -rf $download_dir" EXIT
curl "https://raw.githubusercontent.com/babashka/babashka/master/install" -Ssqlo "$download_dir/install"
mkdir -p "$bb_dir"
bash "$download_dir/install" --dir "$bb_dir" --static
fi
exec "$bb_dir/bb" -f "$0" -- "$@"
)
(println "Hello World!")
@verma

This comment has been minimized.

Copy link

@verma verma commented May 28, 2021

Very nice, thanks for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment