Skip to content

Commit

Permalink
Clarify default install directory (#1912)
Browse files Browse the repository at this point in the history
The install script seems to suggest `/usr/local/bin` as the default install directory. However, pressing `RETURN` will actually set the install dir to an empty string. The error message is not helpful as it then reads `The directory  does not exist.` (note the additional space).

This fix makes the script behave as expected: pressing `RETURN` accepts the default suggestion.

Signed-off-by: André Knörig <aknoerig@users.noreply.github.com>
  • Loading branch information
aknoerig authored Sep 9, 2024
1 parent c990866 commit 26093c0
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@
# SOFTWARE.
set -e

set_install_dir() {
# Set install directory
DEFAULT_INSTALL_DIR="/usr/local/bin"
if [ -z "${INSTALL_DIR}" ]; then
read -p "Install location? [$DEFAULT_INSTALL_DIR]: " INSTALL_DIR
INSTALL_DIR=${INSTALL_DIR:-$DEFAULT_INSTALL_DIR}
fi
if [ ! -d "$INSTALL_DIR" ]; then
echo "The directory $INSTALL_DIR does not exist. Please create it and re-run this script."
# Ask user to manually create directory rather than making it for them,
# so they don't just type in "y" again and accidentally install at ./y
exit 1
fi
# Expand abbreviations in INSTALL_DIR
INSTALL_DIR=$(cd "$INSTALL_DIR"; pwd)
}

command_exists() {
command -v "$@" >/dev/null 2>&1
Expand Down Expand Up @@ -150,18 +166,7 @@ main() {
esac
fi

# Set install directory
if [ -z "${INSTALL_DIR}" ]; then
read -p "Install location? [/usr/local/bin]: " INSTALL_DIR
fi
if [ ! -d "$INSTALL_DIR" ]; then
echo "The directory $INSTALL_DIR does not exist. Please create it and re-run this script."
# Ask user to manually create directory rather than making it for them,
# so they don't just type in "y" again and accidentally install at ./y
exit 1
fi
# Expand abbreviations in INSTALL_DIR
INSTALL_DIR=$(cd "$INSTALL_DIR"; pwd)
set_install_dir

# Check if `cog` command already exists
if command_exists cog; then
Expand Down

0 comments on commit 26093c0

Please sign in to comment.