__line: Support regex beginning with an hyphen (fixes #607) (#608)

If `regex` begins with an hyphen, `grep` treats it as an option
and treats `file` as the regular expression. This leads to `grep`
trying to read from the standard input and making it wait infinitely.

This patch adds the missing argument breaker `--` and allows
`regex` to begin with an hyphen (provided it is called correctly).
This commit is contained in:
uqam-fob 2017-12-29 11:09:06 -05:00 committed by Darko Poljak
parent 3397bcbf9b
commit fc8dded8e9

View file

@ -35,7 +35,7 @@ else
fi
# Allow missing file - thus 2>/dev/null
if grep -q $greparg "$regex" "$file" 2>/dev/null; then
if grep -q $greparg -- "$regex" "$file" 2>/dev/null; then
echo present
else
echo absent