2011-12-30 01:48:33 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
resolve_link() {
|
|
|
|
$(type -p greadlink readlink | head -1) "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
abs_dirname() {
|
|
|
|
local path="$1"
|
2017-06-23 23:49:00 +02:00
|
|
|
local save_cwd="$PWD"
|
|
|
|
local dir name
|
2011-12-30 01:48:33 +01:00
|
|
|
|
2017-06-23 23:49:00 +02:00
|
|
|
while [[ -n "$path" ]]; do
|
|
|
|
dir="${path%/*}"
|
|
|
|
if [[ "$dir" != "$path" ]]; then
|
|
|
|
cd "$dir"
|
|
|
|
name="${path##*/}"
|
|
|
|
else
|
|
|
|
name="$path"
|
|
|
|
fi
|
2011-12-30 01:48:33 +01:00
|
|
|
path="$(resolve_link "$name" || true)"
|
|
|
|
done
|
2017-06-23 23:49:00 +02:00
|
|
|
echo "$PWD"
|
|
|
|
cd "$save_cwd"
|
2011-12-30 01:48:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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")"
|
2013-11-11 05:56:29 +01:00
|
|
|
mkdir -p "$PREFIX"/{bin,libexec,share/man/man{1,7}}
|
2011-12-30 01:48:33 +01:00
|
|
|
cp -R "$BATS_ROOT"/bin/* "$PREFIX"/bin
|
|
|
|
cp -R "$BATS_ROOT"/libexec/* "$PREFIX"/libexec
|
2013-11-09 09:09:26 +01:00
|
|
|
cp "$BATS_ROOT"/man/bats.1 "$PREFIX"/share/man/man1
|
|
|
|
cp "$BATS_ROOT"/man/bats.7 "$PREFIX"/share/man/man7
|
2011-12-30 01:48:33 +01:00
|
|
|
|
|
|
|
echo "Installed Bats to $PREFIX/bin/bats"
|