In order to run a bash script I need some arguments and flags, since the requirements are pretty tricky I've chosen to use a getopt function like this
while getopts ":s:g:r" o; do case "${o}" in s) # Variables that require value VALUE1=${OPTARG} ;; g) # Variables that require value MGROUP=${OPTARG} ;; r) # Variables that, if present, set just a flag ASROOT=1 ;; *) echo "Usage: ./myscript.sh -s value1 -g value2 -r" ;; esac done I would like to have all parameters optional so I can write some conditions later in my code, and first two (s and g) with an arguments, the third (r) is only a optional flag. In the future I may need to add additional parametrers, always optional. Any advice?