I have a script that I want to run in three ways:
- Without a flag --
./script.sh
- With a flag but no parameter --
./script.sh -u
- With a flag that takes a parameter --
./script.sh -u username
Is there a way to do this?
After reading some guides (examples here and here) it doesn't seem like this is a possibility, especially if I want to use getopts
.
Can I do this with getopts
or will I need to parse my options another way? My goal is to continue using getopts
if I can.