-
-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: grep pattern fixed to remove line comments #311
base: master
Are you sure you want to change the base?
Conversation
Running `pelias` yields the error `grep: warning: stray \ before #`. This can be fixed by not escaping `#` in the grep pattern.
The second part of the grep pattern does now remove lines starting with 0 or more whitespace characters followed by #.
Thanks for the bugfix. I don't see this warning on my terminal, could you please post the following: uname -a
Darwin Peters-MacBook-Pro-2.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_X86_64 x86_64 i386 Darwin
grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD I wonder if we can use this pattern which seems much easier to read: grep -Ev '^$|^#' .env or maybe this to maintain backwards compatibility: grep -v '^\s*[$#]' .env Also wondering why the pipe still needs to be escaped |
I don't have a link to the doc handy right now, but the echo '
#
bar' | grep -v '^$\|^\s*#' The pattern I'm using Arch Linux, the exact versions are:
|
As we have the comment Apart from that, |
One last thing: We are currently removing blank lines as well as lines having
Inside So, all cases are covered. But I think it would be good to document this a bit better. |
One subshell `(...) &&` was replaced with `if [...]; then`.
👋 I did some awesome work for the Pelias project and would love for everyone to have a look at it and provide feedback.
Here's the reason for this change 🚀
pelias
yields the errorgrep: warning: stray \ before #
.Here's what actually got changed 👏
#
in the grep pattern.$
after a pattern for white-spaces\s*
before the line-comment character#
. This was changed to^\s*#
which remove lines starting with 0 or more whitespace characters followed by#
.Here's how others can test the changes 👀
Run the
pelias
command and check if loading .env variables does still work as expected/is now fixed. Especially if line comments (with and without whitespace before#
) get removed.