So I am writing a small script in zsh which can take multiple arguments. However, the users happen to pass arguments out-of-order. For example, this would be valid call to the script:
./logproc.sh --include /var/log --exclude-file-ext gz,bz --show-only
Now, I am able to use positional arguments like $1, $2 etc. to expect --include
first, then --exclude-file-ext
and so on. But users are calling the script like this:
./logproc.sh --show-only --exclude-file-ext gz,bz --include /var/log
or
./logproc.sh --exclude-file-ext gz,bz --show-only --include /var/log
With time, the requirement to add more features is increasing and the permutation and combination of figuring out which arguments were passed to the script are going to explode.
Is there a built-in tool in zsh or a command (an external tool which can be called in the script) which can be used to figure out the arguments that were sent to the script?
PS: I am looking for ZSH-specific solution.