I need help to write getopt
function to handle multiple argument for one option like below example, appreciate your kind support.
Example:
./getopt.sh -s abcd -s efgh -s ijkl -s bdnc -e test
This is i got so far
#!/bin/bash
OPTS=`getopt -o s:e:h -n '$0' -- "$@"`
eval set -- "$OPTS"
while true; do
case "$1" in
-s ) SOURCE=$1 ;shift ;;
-h ) echo "$0 -s source -e enviroment"; shift ;;
-e ) ENV=$1; shift; shift ;;
* ) break ;;
esac
done
if [ $ENV='TEST' ];then
echo "execute on test with $SOURCE"
elif [ $ENV='DEV' ];then
echo "execute on dev with $SOURCE"
else
exit
fi
but here I want to execute -s multiple time.