mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-22 04:51:12 +02:00
Add a message informing users about parsing errors
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 `('
```
This commit is contained in:
parent
accdcb2f1c
commit
91b09eb848
1 changed files with 5 additions and 1 deletions
|
|
@ -2,7 +2,11 @@
|
|||
|
||||
source_env() {
|
||||
if [[ -f .env ]]; then
|
||||
source .env
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue