Skip to content

armgit / strix

Public Imported from GitHub
0

Open-source AI penetration testing tool to find and fix your app’s vulnerabilities.

fix: improve install script PATH handling for more shells

0xallam7417e6f8d0be
diff --git a/scripts/install.sh b/scripts/install.sh
index 55ab10ff..07ec154a 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -209,11 +209,16 @@ check_docker() {
add_to_path() {
local config_file=$1
local command=$2
+
if grep -Fxq "$command" "$config_file" 2>/dev/null; then
- return 0
+ print_message info "${MUTED}PATH already configured in ${NC}$config_file"
elif [[ -w $config_file ]]; then
echo -e "\n# strix" >> "$config_file"
echo "$command" >> "$config_file"
+ print_message info "${MUTED}Successfully added ${NC}strix ${MUTED}to \$PATH in ${NC}$config_file"
+ else
+ print_message warning "Manually add the directory to $config_file (or similar):"
+ print_message info " $command"
fi
}
@@ -226,13 +231,19 @@ setup_path() {
config_files="$HOME/.config/fish/config.fish"
;;
zsh)
- config_files="$HOME/.zshrc $HOME/.zshenv"
+ config_files="${ZDOTDIR:-$HOME}/.zshrc ${ZDOTDIR:-$HOME}/.zshenv $XDG_CONFIG_HOME/zsh/.zshrc $XDG_CONFIG_HOME/zsh/.zshenv"
;;
bash)
- config_files="$HOME/.bashrc $HOME/.bash_profile $HOME/.profile"
+ config_files="$HOME/.bashrc $HOME/.bash_profile $HOME/.profile $XDG_CONFIG_HOME/bash/.bashrc $XDG_CONFIG_HOME/bash/.bash_profile"
+ ;;
+ ash)
+ config_files="$HOME/.ashrc $HOME/.profile /etc/profile"
+ ;;
+ sh)
+ config_files="$HOME/.ashrc $HOME/.profile /etc/profile"
;;
*)
- config_files="$HOME/.bashrc $HOME/.profile"
+ config_files="$HOME/.bashrc $HOME/.bash_profile $XDG_CONFIG_HOME/bash/.bashrc $XDG_CONFIG_HOME/bash/.bash_profile"
;;
esac
@@ -245,23 +256,36 @@ setup_path() {
done
if [[ -z $config_file ]]; then
- config_file="$HOME/.bashrc"
- touch "$config_file"
- fi
-
- if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
+ print_message warning "No config file found for $current_shell. You may need to manually add to PATH:"
+ print_message info " export PATH=$INSTALL_DIR:\$PATH"
+ elif [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
case $current_shell in
fish)
add_to_path "$config_file" "fish_add_path $INSTALL_DIR"
;;
+ zsh)
+ add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
+ ;;
+ bash)
+ add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
+ ;;
+ ash)
+ add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
+ ;;
+ sh)
+ add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
+ ;;
*)
- add_to_path "$config_file" "export PATH=\"$INSTALL_DIR:\$PATH\""
+ export PATH=$INSTALL_DIR:$PATH
+ print_message warning "Manually add the directory to $config_file (or similar):"
+ print_message info " export PATH=$INSTALL_DIR:\$PATH"
;;
esac
fi
if [ -n "${GITHUB_ACTIONS-}" ] && [ "${GITHUB_ACTIONS}" == "true" ]; then
echo "$INSTALL_DIR" >> "$GITHUB_PATH"
+ print_message info "Added $INSTALL_DIR to \$GITHUB_PATH"
fi
}