#!/bin/sh
#
# BrowserCode installer serve-only build. Hosted at https://bcode.sh/bytecode,
# alongside (not replacing) https://bcode.sh/install, which stays the path for
# the full CLI.
#
# curl -fsSL https://bcode.sh/bytecode | sh -s -- --no-modify-path --version 0.1.19
#
# Installs `bcode-linux-[-musl]-serve`, which provides ONLY `bcode serve`;
# run, tui, web, github and the rest are absent and exit 1. It exists for headless
# containers.
#
# POSIX sh, not bash: Alpine is a supported target here and ships no bash.
set -eu
REPO=browser-use/browsercode
DIM='\033[0;2m'
RED='\033[0;31m'
OFF='\033[0m'
say() { printf "${DIM}%s${OFF}\n" "$1" >&2; }
die() {
printf "${RED}%s${OFF}\n" "$1" >&2
shift
for line in "$@"; do [ -n "$line" ] && printf "${DIM}%s${OFF}\n" "$line" >&2; done
exit 1
}
# Reject empty and flag-shaped values: `--version "$UNSET"` would otherwise
# silently install latest, which is exactly what pinning exists to prevent.
need() {
case $2 in
"" | -*) die "$1 needs a value (got: ${2:-})" ;;
esac
}
usage() {
cat >&2 /dev/null)" \
"If $install_dir is mounted noexec, pass --install-dir."
fi
mv "$staged" "$install_dir/bcode"
staged=
say "Installed $install_dir/bcode ($installed) provides 'bcode serve' only"
case ":$PATH:" in
*":$install_dir:"*) ;;
*) say "Not on PATH. Add it with: export PATH=\"$install_dir:\$PATH\"" ;;
esac