Skip to content

Commit

Permalink
Improved error msgs and checks in MotteKit installer
Browse files Browse the repository at this point in the history
  • Loading branch information
dmotte committed Dec 19, 2024
1 parent e11e79a commit 1b1b122
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scripts/mottekit/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,28 @@ readonly mottekit_dir=~/.mottekit
[ -e "$mottekit_dir" ] &&
{ echo "The $mottekit_dir directory already exists" >&2; exit 1; }

for i in ~/.local/bin ~/bin; do
path_dirs=(~/.local/bin ~/bin)

for i in "${path_dirs[@]}"; do
[ "$PATH" = "$i" ] || [[ "$PATH" = *:"$i":* ]] ||
[[ "$PATH" = "$i":* ]] || [[ "$PATH" = *:"$i" ]] &&
{ entrypoint=$i/mottekit; break; }
done

[ -z "$entrypoint" ] && {
echo 'Cannot find a location in PATH suitable for installing the' \
'MotteKit entrypoint' >&2
'MotteKit entrypoint. You must have one of the following' \
'directories in your PATH:' >&2
echo "${path_dirs[@]@Q}" >&2
exit 1
}

[ -e "$entrypoint" ] &&
{ echo "The entrypoint $entrypoint already exists" >&2; exit 1; }

command -v git >/dev/null ||
{ echo 'The git command is required but cannot be found' >&2; exit 1; }

echo "Creating the MotteKit directory $mottekit_dir"
mkdir "$mottekit_dir"

Expand Down

0 comments on commit 1b1b122

Please sign in to comment.