> 1. You get the directory of the file via "${passfile%/*}" - isn't "dirname"
> the appropriate solution?
> 2. Why do you use double brackets where single brackets i.e. the test command
> would suffice?
It's preferable to use internal bash features instead of relying on external
commands, when possible. This makes the code more portable and reduces the
number of processes that run on the system.
'[[' syntax is newer and has more features. See
https://mywiki.wooledge.org/BashFAQ/031
As long as you're using bash, use the newer '[[' syntax, but if you are limited
to POSIX shell (sh) then use '['.
By the way, it looks like there are some spacing/indentation issues in the
patch.