fix(install): Enhance checks and code

- Opengrep complains about non quoted strings
- Bad indentation fixed
This commit is contained in:
2025-07-06 10:52:35 +02:00
parent a409a1347e
commit b47b956798

View File

@@ -18,28 +18,28 @@ COMON_INSTALL_PATHS="$HOME/.local/bin $HOME/.bin $HOME/bin"
INSTALL_PATH="" INSTALL_PATH=""
for p in $COMON_INSTALL_PATHS; do for p in $COMON_INSTALL_PATHS; do
if [ -d $p ]; then if [ -d $p ]; then
INSTALL_PATH=$p INSTALL_PATH=$p
break break
fi fi
done done
# check if the user has write access to the INSTALL_PATH # check if the user has write access to the INSTALL_PATH
if [ -z "$INSTALL_PATH" ]; then if [ -z "$INSTALL_PATH" ]; then
INSTALL_PATH="/usr/local/bin" INSTALL_PATH="/usr/local/bin"
if [ ! -w $INSTALL_PATH ]; then if [ ! -w $INSTALL_PATH ]; then
echo "You don't have write access to $INSTALL_PATH" echo "You don't have write access to $INSTALL_PATH"
echo "Please, run with sudo or install locally" echo "Please, run with sudo or install locally"
exit 1 exit 1
fi fi
fi fi
# ensure that $INSTALL_PATH is in the PATH # ensure that $INSTALL_PATH is in the PATH
if ! echo $PATH | grep -q $INSTALL_PATH; then if ! echo "$PATH" | grep -q "$INSTALL_PATH"; then
echo "Sorry, $INSTALL_PATH is not in the PATH" echo "Sorry, ${INSTALL_PATH} is not in the PATH"
echo "Please, add it to your PATH in your shell configuration file" echo "Please, add it to your PATH in your shell configuration file"
echo "then restart your shell and run this script again" echo "then restart your shell and run this script again"
exit 1 exit 1
fi fi
# Where to download the binary # Where to download the binary
@@ -47,7 +47,7 @@ BASE="https://github.com/metal3d/katenary/releases/latest/download/"
# for compatibility with older ARM versions # for compatibility with older ARM versions
if [ $ARCH = "x86_64" ]; then if [ $ARCH = "x86_64" ]; then
ARCH="amd64" ARCH="amd64"
fi fi
BIN_URL="$BASE/katenary-$OS-$ARCH" BIN_URL="$BASE/katenary-$OS-$ARCH"
@@ -58,8 +58,8 @@ echo "Downloading $BIN_URL"
T=$(mktemp -u) T=$(mktemp -u)
curl -SL -# $BIN_URL -o $T || (echo "Failed to download katenary" && rm -f $T && exit 1) curl -SL -# $BIN_URL -o $T || (echo "Failed to download katenary" && rm -f $T && exit 1)
mv $T $INSTALL_PATH/katenary mv "$T" "${INSTALL_PATH}/katenary"
chmod +x $INSTALL_PATH/katenary chmod +x "${INSTALL_PATH}/katenary"
echo echo
echo "Installed to $INSTALL_PATH/katenary" echo "Installed to $INSTALL_PATH/katenary"
echo "Installation complete! Run 'katenary help' to get started." echo "Installation complete! Run 'katenary help' to get started."