Base-64 encoded shell commands
  • Shell 55.8%
  • Go 44.2%
Find a file
j 932895c4b0
All checks were successful
Build-Test-Publish / build (push) Successful in 36s
Refactor Go toolchain bootstrap into shared ensure-go.sh
2026-07-05 19:22:21 +12:00
.gitea/workflows Refactor Go toolchain bootstrap into shared ensure-go.sh 2026-07-05 19:22:21 +12:00
.vscode First commit 2025-08-09 16:44:26 +12:00
.gitignore Update .gitignore 2025-09-02 20:42:54 +12:00
build.sh Refactor Go toolchain bootstrap into shared ensure-go.sh 2026-07-05 19:22:21 +12:00
clean.sh First commit 2025-08-09 16:44:26 +12:00
ensure-go.sh Refactor Go toolchain bootstrap into shared ensure-go.sh 2026-07-05 19:22:21 +12:00
go.mod Migrate build from C++/CMake to pure Go cross-compilation 2026-06-13 21:10:53 +12:00
main.go Harden bb64: strict decode, multi-line -e, dockerless self-update 2026-07-05 17:23:29 +12:00
publish.sh Refactor Go toolchain bootstrap into shared ensure-go.sh 2026-07-05 19:22:21 +12:00
README.md Harden bb64: strict decode, multi-line -e, dockerless self-update 2026-07-05 17:23:29 +12:00
test.sh Harden bb64: strict decode, multi-line -e, dockerless self-update 2026-07-05 17:23:29 +12:00

bb64

Installation

If you don't already have getpkg installed:

curl https://getbin.xyz/getpkg-install | bash

Then install bb64 via getpkg for the current user:

getpkg install bb64

Use

Bash Base64, written in Go (a port of the original C++ implementation).

Uses a custom Base64 character set for bash compatibility, not compatible with other utilities.

Usage:
    bb64 BASE64COMMAND          Decodes and runs the command
    bb64 -[i|d] BASE64COMMAND   Displays the decoded command
    bb64 -e COMMAND             Encodes the command and prints the result
    bb64 -e                     Encodes the command provided on stdin and prints the result
    bb64 -u                     Updates bb64 to the latest version (downloads from getbin.xyz)
    bb64 -v                     Prints the version number
    bb64 version                Prints the version number

Implementation Notes

bb64 runs the command by replacing the current process, so it ensures that tty, environment variables etc are all identical for the run command. It works with interactive commands, like nano or ssh.

bb64 supports bash scripts, as the command is run as: bash -c 'COMMAND' Where COMMAND is passed to bash as a single argument.

Encoding (-e) preserves line breaks, so multi-line scripts — including # comments and heredocs — survive the round trip. Runs of spaces/tabs collapse to a single space, other control characters are stripped, and leading/trailing whitespace is trimmed.

Decoding for execution validates the entire payload: corrupted or truncated base64 is refused (exit 255) rather than silently running a partial command. Whitespace inside the encoded string is tolerated. The display modes (-i/-d) still show whatever prefix decodes, with a warning if the payload is invalid.

If the command is run, the return value is the return value of the command. If it isn't run, bb64 returns -1 (exit code 255).

bb64 -u downloads the published binary for the current platform straight from getbin.xyz (bb64:latest-<arch>) and atomically swaps it in place — no docker required.