Forum: Cfengine Help Subject: backslashes within execresult Author: joke Link to topic: https://cfengine.com/forum/read.php?3,18896,18896#msg-18896
Hi, this time I'm not sure how backslashes are handled within the execresult function. I tried to process some command output with sed but cfengine's (3.1.0b2) escaping seems to be very odd. A function call like this seems to be automatically escaped: execresult("/bin/echo \*", "useshell"); The echoed result is "\*". Escaping the backslash with an other backslash execresult("/bin/echo \\*", "useshell"); returns the same echoed result "\*"; As far as I understand cfengine escaping should be done via $(const.endl), $(const.n), etc. constants and not via c-like escape sequences. Therefore execresult("/bin/echo \*", "useshell"); should be passed down as execve("/bin/sh", ["sh", "-c", "/bin/echo \\*"] with should result in a shell line like /bin/echo \* with ends in calling "/bin/echo" with "*" as first argument. But it should not be automatically escaped and be passed down as "\\" like cfengine does. _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine