Commit Graph

12 Commits

Author SHA1 Message Date
evilham c030deea3d [__line] Add support for '--state replace'
It is currently counter-intuitive that something like:

    # File '/thing' contents
    #SomeSetting WrongValue

    # Manifest
    __line '/thing' \
           --line 'SomeSeting GoodValue' \
           --regex '^(#[[:space:]]*)?SomeSetting[[:space:]]'

Produces:

    # Resulting '/thing' contents
    #SomeSetting WrongValue

This makes sense given the implementation, but it masks a very common use-case.

Changing the default behaviour for such a base type is not really an option, so
instead we add a `replace` as a valid value for `--state`, which would result
in:

    # Resulting '/thing' contents with: --state replace
    SomeSetting GoodValue

For compatibility, if the regex is missing, `--state replace` behaves just as
`--state present`.
2020-10-09 06:51:44 +02:00
Dennis Camera 5a9a1ba57f [__line] Produce error when file does not exist 2020-01-15 22:00:56 +01:00
Dennis Camera 51b1b11cc2 [__line/state] Logic fixes in explorer
This commit fixes the incorrectly reported state "wrongposition" if position is
"after" and anchor is present in the file but the line missing.
2020-01-15 17:57:45 +01:00
Dennis Camera 4cdb8aaa03 [__line/state] Make sure the index match is at the beginning
Without the == 1 all lines which contain --line as a substring match.  e.g. if
--line is "line" and the file contains the line "wrong line" this was considered
a match.
2020-01-15 17:50:43 +01:00
Dennis Camera 93ec4b46aa [__line] Ensure the line is only added once 2020-01-15 17:27:25 +01:00
Jonas Weber 4eaace7dd5 Handle missing file in __line explorer gracefully
closes #675
2018-06-20 11:14:25 +02:00
Steven Armstrong 4516ee0baa position can not be empty
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
2018-06-01 15:27:40 +02:00
Steven Armstrong fb26894cbd when searching treat line as string, and regex as regexp
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
2018-05-18 16:57:34 +02:00
Steven Armstrong a3968f8313 rewrite __line type for --before and --after support
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
2018-05-18 01:25:35 +02:00
uqam-fob fc8dded8e9 __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).
2017-12-29 17:09:06 +01:00
Nico Schottelius 95513ab538 __line: handle fixed strings correctly, posix gave us -F -x for this case
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
2013-10-29 12:23:07 +01:00
Nico Schottelius 63573a9797 make package_data work
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
2012-10-29 22:50:27 +01:00