I am learning bash my self 🙂 and I am stuck on my problem please help!
I have seen many bash scripts which have flags which can be executed without running the whole script like if using proot-distro then we type proot-distro login distroname or proot-distro --help etc.
How can I achieve this?
You basically need to to iterate through the arguments using a while [[ $# -gt 0 ]]; do case $1 in ... esac; shift; done loop. You enable flags, collect optargs, or target files as you go. There are plenty of tutorials and examples on how to do it out there. You can also look at mine as examples. Just avoid relying on getopt[s]. The capability to specify short options together isn’t worth the complexity.