Skip to content

pkg

Source: src/just_bashit/pkg.sh

Package manager detection and installed-version querying.


get-pkg-mgr

Print the name of the active package manager for the running OS. Returns non-zero and prints to stderr if the OS is unrecognised.

. just-bashit/src/just_bashit/pkg.sh

pm=$(get-pkg-mgr)          # e.g. "pacman" on Arch, "apt" on Debian
echo "Using ${pm}"

Usage

Usage: get-pkg-mgr

  Print the name of the active package manager for the running OS.

Options:
  -h  Show this message and exit.

Output:
  One of: apt, pacman, brew, dnf, zypper, apk, msys2.

OS mapping

OS / distro family Output
macOS brew
Debian, Ubuntu apt
Arch, CachyOS, Manjaro pacman
Fedora, RHEL, CentOS, Rocky, AlmaLinux dnf
openSUSE zypper
Alpine apk
MSYS2 / Cygwin / MinGW msys2

get-pkg-version

Print the installed version of a package using the specified package manager. Prints nothing (not an error) if the package is not installed.

. just-bashit/src/just_bashit/pkg.sh

get-pkg-version apt curl           # e.g. "8.5.0-2"
get-pkg-version pacman bash        # e.g. "5.2.37-1"
get-pkg-version pacman nosuchpkg   # prints nothing, exits 0

Usage

Usage: get-pkg-version PM PKG

  Print the installed version of PKG using package manager PM.
  Prints nothing (not an error) if the package is not installed.

Options:
  -h  Show this message and exit.

Arguments:
  PM   Package manager name: apt, pacman, brew, dnf, zypper, apk, msys2.
  PKG  Package name as known to the package manager.

Examples

# Check if curl is installed and get its version
ver=$(get-pkg-version "$(get-pkg-mgr)" curl)
if [[ -n "${ver}" ]]; then
    echo "curl ${ver} is installed"
else
    echo "curl is not installed"
fi

install-uv

Install uv and print the directory it is in. This is the one uv installer in just-bashit: get-jb.sh, setup-system's tools step and jbx's Python runner all call it.

  • Windows (Git Bash, MSYS2, Cygwin) with winget: winget install --id astral-sh.uv. winget picks the build for the machine, so ARM64 Windows gets aarch64-pc-windows-msvc even when the calling shell is an emulated x64 Git Bash. Every signal that shell can see says x64, and astral's install.sh reads only uname -m, so it used to install an x64 uv there that then ran emulated (#171). winget links uv into %LOCALAPPDATA%\Microsoft\WinGet\Links and adds that directory to the user PATH, which new shells see and the running one does not. The first install may show one UAC prompt, for the Visual C++ runtime that winget installs as a dependency.
  • Everywhere else, and on Windows when winget is missing or fails: astral's install.sh. It needs curl and awk, and install-uv stops and says why when either is missing.

Only the directory goes to stdout; the installers' own output goes to stderr. The caller decides whether to put the directory on its PATH:

. just-bashit/src/just_bashit/pkg.sh

dir="$(install-uv)" && PATH="${dir}:${PATH}"
install-uv -n    # print the command it would run, and run nothing

JB_NO_VERIFY=1 adds --insecure to the install.sh download. This is how jbx --no-verify reaches it.

On a Schannel curl (Git for Windows) the download also passes --ssl-revoke-best-effort, as every just-bashit curl call does: a revocation server that cannot be reached is not a failed install, and a revoked certificate is still refused.