I am writing a simple bash script. My script installs ppa. The problem is I can't add two arguments. I want to write something simple like this:
./ppa.sh -i ppa:chris-lea/node.js nodejs
I tried this, but doesn't read the second argument 'nodejs'...
#! /bin/sh
# Install/add PPA or Program
while getopts ":i:e:" option;
do
case $option in
i)
echo received -i with $OPTARG
ang='sudo apt-add-repository'
;;
e)
echo received -e with $OPTARG
ang='other line'
;;
:)
echo "option -$OPTARG needs an argument"
exit
;;
*)
echo "invalid option -$OPTARG"
exit
;;
esac
# done
if [ "`echo $OPTARG | cut -d ':' -f1`" == "ppa" ]; then
echo 'is a ppa'
$ang $OPTARG ; sleep 2s && sudo apt-get update; clear
sudo apt-get -y install $OPTARG2
fi
done