Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Install Bats Using GNU Stow

Todd A. Jacobs edited this page Aug 23, 2014 · 1 revision

Purpose

Sometimes you want to install a package like Bats, but you either don't want to install it in a system directory like /usr/local because you don't have root privileges, or you want to be able to manage multiple versions cleanly. GNU Stow can handle both use cases well, and installing or upgrading Bats with Stow is trivial.

Installing as Root

stow=/usr/local/stow
version=$(libexec/bats -v | tr A-Z a-z | tr ' ' -)

# Unstow older versions of Bats.
shopt -s nullglob
old_bats=(`find "$stow" -type d -name bats-\*`)
for package in "${old_bats[@]}"; do
    sudo stow --dir="$stow" --delete $(basename "$package")
done

sudo ./install.sh "${stow}/${version}"
sudo stow --dir="$stow" --restow "$version"

Installing as User

mkdir ~/stow
stow=~/stow
version=$(libexec/bats -v | tr A-Z a-z | tr ' ' -)

# Unstow older versions of Bats.
shopt -s nullglob
old_bats=(`find "$stow" -type d -name bats-\*`)
for package in "${old_bats[@]}"; do
    stow --dir="$stow" --delete $(basename "$package")
done

./install.sh "${stow}/${version}"
stow --dir="$stow" --restow "$version"