minor formatting of check-dependency script

This commit is contained in:
Josh Ashton
2024-02-12 09:15:07 -07:00
parent 8b50750059
commit 04a4ce2653
+10 -2
View File
@@ -1,4 +1,12 @@
#!/bin/zsh
if [[ $# -ne 2 ]]; then
echo "Usage: $0 <command> <package>"
echo "Checks if a command is installed and if not, installs the package."
echo "Supported package managers: apt, pacman, dnf, yum, brew, port"
exit 1
fi
COMMAND=$1
PACKAGE=$2
@@ -12,7 +20,7 @@ error() {
if ! command -v $COMMAND &> /dev/null
then
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "$COMMAND not found. Installing $COMMAND..."
echo "$COMMAND not found. Installing $PACKAGE..."
DISTRO=$(cat /etc/os-release | grep -oP '(?<=^ID=).+' | tr -d '"')
@@ -57,5 +65,5 @@ then
error
fi
else
echo "$COMMAND is already installed."
echo "Package $PACKAGE which provides the command $COMMAND, is already installed."
fi