Is there supposed to be something along the lines of
```sh
[ -n "${mod_dir}" ] && [ -d "${mod_dir}" ] || exit 1
```
right here?