Forum: Cfengine Help Subject: splitstring and nullbytes Author: joke Link to topic: https://cfengine.com/forum/read.php?3,18907,18907#msg-18907
Sorry to bother again. But this time it's about splitstring and nullbytes. If I want to get a slist variable with a list of filenames I can use execresult to call an external command to get a string variable in return and call the splitstring later on get the actual slist. Since filenames can contain anything except null-bytes the only save way is using null-bytes as a delimiter (-print0). vars: "files_string" string => execresult("/usr/bin/find /some/path -name "some_pattern" -print0", "noshell"); If I want to split the string I would do be doing this way: vars: "files_list" slist => splitstring("$(files_string)", "\0", "100"); But cfengine doesn't handle "\0" or "\x0" correctly although these are valid pcre inputs for a null-byte. If I use "$(const.n)" or "$(const.endl)" the string seems to be chopped after the first occurrence of a null-byte. The string "first\0second\0third" will be splitted to "first". That's completely wrong. It should stay unchanged because there aren't any newlines. Any ideas how to do the splitting? _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine