I want to be able to run a script like run.sh test -a
but my arguments are empty.
#!/bin/bash
function install() {
echo "Installing $1"
}
while getopts "ab" ARG; do
case "$ARG" in
a) install
echo "Setting up A" ;;
b) install
echo "Setting up B" ;;
*) echo "argument missing" ;;
esac
done
My expected output would be if I run run.sh test -a
:
Installing test
Setting up A
However there is no output returned. If I run run.sh -a
, I get:
Installing
Setting up A