lundi 8 mars 2021

Shell script - not using if loop

I have an if loop that tells it if it gets a certain argument to do an install, however if it doesn't receive that argument, it should quit... am I doing something wrong? No matter the argument, it does the install.

echo "You ran the command: $1"
if [ $0=zero ]
then
  echo "Zero Install"
else
  echo "Sorry, wrong argument."
  exit
fi
if [ $1=install ]
then
  if [ $2=brew ]
  then
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  else
    echo "Sorry, invalid package."
    exit
  fi
else
  echo "Sorry, invalid command."
  exit
fi

Aucun commentaire:

Enregistrer un commentaire