install.sh: pick first on-PATH target dir, allow TARGET= override
This commit is contained in:
parent
74e7f5529c
commit
48a219a7cc
1 changed files with 17 additions and 1 deletions
18
install.sh
18
install.sh
|
|
@ -6,8 +6,24 @@
|
|||
set -eu
|
||||
|
||||
repo_dir=$(cd "$(dirname "$0")" && pwd)
|
||||
target=${HOME}/bin
|
||||
|
||||
# Pick the first install target that's already on $PATH so the symlinks are
|
||||
# immediately usable. Override with TARGET=<dir> ./install.sh.
|
||||
pick_target() {
|
||||
if [ -n "${TARGET:-}" ]; then
|
||||
printf %s "$TARGET"
|
||||
return
|
||||
fi
|
||||
for candidate in "$HOME/bin" "$HOME/.local/bin"; do
|
||||
case ":$PATH:" in
|
||||
*":$candidate:"*) printf %s "$candidate"; return ;;
|
||||
esac
|
||||
done
|
||||
# Nothing on PATH — fall back to ~/bin and warn later.
|
||||
printf %s "$HOME/bin"
|
||||
}
|
||||
|
||||
target=$(pick_target)
|
||||
mkdir -p "$target"
|
||||
|
||||
for src in "$repo_dir"/bin/*; do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue