My shell script takes in a set of input variables some are optional. The input should follow the following signature.
myscript.sh var1 var2 [-x var3] [-y var4]`.
The -x and -y are optional inputs and these options can occur at any location (between var1 & var 2 or at the start) but var3 will always preceed var4. Also var1 will preceed var 2.
The script I have does a lot of if else checks to cover all the probabilities. Something like this
if [ $1 == "-x" ]; then
## Then check if $3 == "-y"
## Assign values to VAR1 , VAR2, VAR3, VAR4
## else check for other possibilities
fi
I was wondering if there was a better way of doing this and assigning the values to variables?