How bash getopts knows what arguments the call has
2
votes
1
answer
364
views
If
getopts
is a bash function, by my understanding, you need to pass $@
- the whole arguments to getopts
to let the function know what kind of arguments you have in order to proceed, right?
It seems to me that you don't need it, so how the getopts
get to know what arguments I have in the current scope? Does it have a way to trace the previous call like the other high-level languages do?
while getopts abcde opt; do
˄˄˄˄˄ <-- you only need to pass the argument labels here,
how getopts knows what arguments I have
case $opt in
...
esac
done
Asked by Till
(193 rep)
Nov 21, 2023, 08:08 AM
Last activity: Nov 25, 2023, 04:04 PM
Last activity: Nov 25, 2023, 04:04 PM