Hi Iain,
I am not keen on the $(empty) variable idea. I think this should work
without a workaround. I have found the problem and patched svn. Would
you let me know if this works for you now?
Mark
Iain Patterson wrote:
> * This won't work:
>
> editfiles:
> {
> /path/to/file
> ReplaceAll "bad text" With ""
> }
>
> cfagent will say "ReplaceAll without With" because the replacement
> text is empty. The solution is to do this:
>
> control:
> empty = ( "" )
>
> editfiles:
> {
> /path/to/file
> ReplaceAll "bad text" With "$(empty)"
> }
>
> It might be helpful to have $(empty) as a special variable for this
> case. Patch attached if you agree that this could be beneficial.
>
> * The following doesn't work:
>
> control:
> ActionSequence = ( editfiles )
>
> editfiles:
> {
> /path/to/file
> EditMode "Binary"
> ReplaceAll "string" With "string"
> }
>
> cfagent says "Search and replace patterns are identical in binary edit
> /path/to/file" in a loop forever.
>
> This works correctly if EditMode is not "Binary". In this case
> cfagent will note that "Replacement matches search string and will thus
> replace every time - edit was not done" and skip the replacement.
>
> * The following works if the file is an ASCII file but not if it is a
> binary file:
>
> control:
> ActionSequence = ( editfiles )
>
> editfiles:
> {
> /path/to/file
> EditMode "Binary"
>
> ReplaceAll "string" With "strung"
> }
>
> For example:
>
> # echo string > /path/to/file
> # cfagent
> # cat /path/to/file
> strung
>
> # cat << EOF > testcase.c
> #include <stdio.h>
> int main() { printf("string\n"); }
> EOF
> # gcc -o /path/to/file testcase.c
> # cfagent
> # /path/to/file | sed -n l
> string$
>
> This appears to be because cfagent is getting confused with the
> requirement that the replacement string be at most the same length as
> the search string. The following works:
>
> control:
> ActionSequence = ( editfiles )
>
> editfiles:
> {
> /path/to/file
> EditMode "Binary"
> ReplaceAll "string" with "strun"
> }
>
> With the same testcase.c as above:
>
> # gcc -o /path/to/file testcase.c
> # cfagent
> # /path/to/file | sed -n l
> strun $
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Bug-cfengine mailing list
> [email protected]
> https://cfengine.org/mailman/listinfo/bug-cfengine
--
Mark Burgess
Web: http://www.iu.hio.no/~mark
Tlf: +47 22453272
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine