1
0
mirror of https://github.com/sstephenson/bats.git synced 2024-09-29 20:48:27 +02:00
bats/install.sh
Dmitry Rozhkov adc7ecfe17 Avoid undocumented usage of the head utility.
Some implementations of head (e.g. the one in Busybox)
can't handle options like "-1". Replace them with "-n1".

Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>
2016-05-02 14:47:48 +00:00

38 lines
733 B
Bash
Executable File

#!/usr/bin/env bash
set -e
resolve_link() {
$(type -p greadlink readlink | head -n1) "$1"
}
abs_dirname() {
local cwd="$(pwd)"
local path="$1"
while [ -n "$path" ]; do
cd "${path%/*}"
local name="${path##*/}"
path="$(resolve_link "$name" || true)"
done
pwd
cd "$cwd"
}
PREFIX="$1"
if [ -z "$1" ]; then
{ echo "usage: $0 <prefix>"
echo " e.g. $0 /usr/local"
} >&2
exit 1
fi
BATS_ROOT="$(abs_dirname "$0")"
mkdir -p "$PREFIX"/{bin,libexec,share/man/man{1,7}}
cp -R "$BATS_ROOT"/bin/* "$PREFIX"/bin
cp -R "$BATS_ROOT"/libexec/* "$PREFIX"/libexec
cp "$BATS_ROOT"/man/bats.1 "$PREFIX"/share/man/man1
cp "$BATS_ROOT"/man/bats.7 "$PREFIX"/share/man/man7
echo "Installed Bats to $PREFIX/bin/bats"