Cylc clean accepts {1,2,3} but not [4-6] wildcards

hey,

why does this work…

cylc clean foo/run{1,2,3}

… but this doesn’t?..

cylc clean foo/run[4-6]
WARNING - No workflows matching u-cy886/[4-6]

thanks,

jonny

That’s down to your bash shell.

You have not quoted the patterns to protect them shell interpretation before cylc clean sees the command line. See cylc clean --help: quote glob patterns, and {...} is not given as a valid pattern (different programs, such as bash vs the Python glob library vs the Python regex library support different kinds of patterns).

This works by sheer luck - bash expands that to foo/run1 foo/run2 foo/run3 without checking first that those files exist (in your current directory not the Cylc run directory!). So the cylc clean command gets a list of files that happen to be valid, rather than looking for all files that match the pattern.

To see this:

$ echo junk{1,2,3}
junk1 junk2 junk3  # expanded, but these files don't exist

By contrast bash does not expand foo/run[4-6] unless matching files exist (in your current directory).

$ echo junk[1-3]
junk[1-3]  # not expanded

$ touch junk1 junk2 junk3 junk4
$ echo junk[1-3]
junk1 junk2 junk3  # now it is!

So in this case cylc clean sees the original pattern even though it’s not protected by quotes.

My local tests just now show that works though (i.e. [1-3] ranges are valid for cylc clean) … I’ll just check on the HPC…

[UPDATE] yes cylc clean foo/run[4-6] works there too, perhaps you made a typo in that command line?

However, you should use quotes just in case you ever have a foo/run3 in your current working directory (in which case bash will expand it before cylc clean gets it):

$ cylc clean "foo/run[4-6]"
1 Like

brilliant, thanks for the detailed answer!