mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-22 04:51:12 +02:00
I couldn't tell why I got this error `.env: line 129: syntax error near unexpected token `('` after adding a bunch of plugins.
I didn't knew what most of the plugins do, nor what the `dotenv` plugin is doing behind the scene!
After figuring out the problem, I though it would be much better displaying an error message only in case there are some parsing errors. Now I would get this:
```
Found some errors while parsing your .env file:
.env: line 129: syntax error near unexpected token `('
```
14 lines
256 B
Bash
14 lines
256 B
Bash
#!/bin/zsh
|
|
|
|
source_env() {
|
|
if [[ -f .env ]]; then
|
|
if errs=$(bash -n .env 2>&1);
|
|
then source .env;
|
|
else
|
|
printf '%s\n' "Found some errors while parsing your .env file: " "$errs";
|
|
fi
|
|
fi
|
|
}
|
|
|
|
autoload -U add-zsh-hook
|
|
add-zsh-hook chpwd source_env
|