__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).
remotes/origin/AnotherKamila-patch-1
uqam-fob 7 years ago committed by Darko Poljak
parent 3397bcbf9b
commit fc8dded8e9
  1. 2
      cdist/conf/type/__line/explorer/state

@ -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

Loading…
Cancel
Save