On Wed, 24 Aug 2016 18:54:36 -0500 "Sean Johnson" <
se...@ttys0.net> wrote:
SJ> The regular expression has to filter some other piece of data, ostensibly the
SJ> character set a->z, of which you only want b->p. The a->z character set would
SJ> need to first exist, perhaps as a string variable, and then your regular
SJ> expression would consume that string to break out into character elements of
SJ> b-> p. To my eyes, that doesn’t provide any benefit over using something like the
SJ> string_split function.
expandrange() does almost exactly what Christian wants, but with
numbers, so there's some precedent in CFEngine for easier specification
of a long slist. expandrange() could be hacked to do letters in addition
to numbers... but I don't have a valid use case, and as far as I know it
hasn't ever been requested. (This request, I think, is better solved by
my example below.)
On Thu, 25 Aug 2016 06:04:26 -0700 (PDT) Christian Linden <
lindo...@gmail.com> wrote:
CL> I want to mount a /dev/sd$(alphabet) as soon as it's available.
Fortunately, findfiles() supports shell range expressions and wildcards:
#+begin_src cfengine3
bundle agent main
{
vars:
"found_alphabet" slist => findfiles("/dev/sd[b-p]");
"found_letters" slist => findfiles("/dev/sd?");
reports:
"$(found_alphabet) is found on the system by CFEngine.";
"letter $(found_letters) is found on the system by CFEngine.";
}
#+end_src
My machine has only two disks, sadly:
#+begin_src text
%cf-agent -KI ./
test_findfiles_range.cf
R: /dev/sdb is found on the system by CFEngine.
R: letter /dev/sda is found on the system by CFEngine.
R: letter /dev/sdb is found on the system by CFEngine.
#+end_src
I hope that helps...
Ted