Skip to content

Commit

Permalink
install.sh: Use install instead of cp, mkdir, etc.
Browse files Browse the repository at this point in the history
Suggested by @HRio during the review of sstephenson#105. Unrolled the loop since
there's so few commands now, and tweaked the `PREFIX` test and usage
message.
  • Loading branch information
Bland, Mike authored and sublimino committed Jun 18, 2018
1 parent e8a2774 commit a807025
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ set -e

BATS_ROOT="${0%/*}"
PREFIX="$1"
if [ -z "$1" ]; then
{ echo "usage: $0 <prefix>"
echo " e.g. $0 /usr/local"
} >&2

if [[ -z "$PREFIX" ]]; then
printf '%s\n' \
"usage: $0 <prefix>" \
" e.g. $0 /usr/local" >&2
exit 1
fi
mkdir -p "$PREFIX"/{bin,libexec/bats-core,share/man/man{1,7}}

for scripts_dir in 'bin' 'libexec/bats-core'; do
scripts=("$BATS_ROOT/$scripts_dir"/*)
cp "${scripts[@]}" "$PREFIX/$scripts_dir"
chmod a+x "${scripts[@]/#$BATS_ROOT[/]/$PREFIX/}"
done

cp "$BATS_ROOT/man/bats.1" "$PREFIX/share/man/man1"
cp "$BATS_ROOT/man/bats.7" "$PREFIX/share/man/man7"
install -d -m 755 "$PREFIX"/{bin,libexec/bats-core,share/man/man{1,7}}
install -m 755 "$BATS_ROOT/bin"/* "$PREFIX/bin"
install -m 755 "$BATS_ROOT/libexec/bats-core"/* "$PREFIX/libexec/bats-core"
install -m 644 "$BATS_ROOT/man/bats.1" "$PREFIX/share/man/man1"
install -m 644 "$BATS_ROOT/man/bats.7" "$PREFIX/share/man/man7"

echo "Installed Bats to $PREFIX/bin/bats"

0 comments on commit a807025

Please sign in to comment.