[systemd-devel] [PATCH] systemd-analyze: filter dot output with a regular expression
lennart at poettering.net
Mon Mar 25 15:48:46 PDT 2013
On Mon, 25.03.13 21:19, Lukasz Stelmach (stlman at poczta.fm) wrote:
> W dniu 25.03.2013 16:48, Lennart Poettering pisze:
> > On Sun, 24.03.13 13:32, Łukasz Stelmach (stlman at poczta.fm) wrote:
> >> Make "systemd-analyze dot" output only lines matching a regular
> >> expression passed on the command line. Without the regular expression
> >> print everything.
> > So far we mostly used globs everywhere in system. Does it really make
> > sense to use regexes here?
> > I mean, unit file names on purpose are "file-name like", and generally
> > even show up in the file system, so it sounds more natural to me to use
> > fnmatch here?
> Indeed fnmatch() is better for matching unit names, however, I match the
> whole line:
> "multi-user.target"->"basic.target" [color="green"];
Well, I really wouldn't match the whole line. If people want that they
can use grep, no?
Wouldn't it be nicer to match either unit name, and that's it?
> rather than the the unit names. To quickly match the line above I use
> "target.*target". A glob that does tha same is "*target*target*" not as
> nice, is it? (This is because globs are implicitly anchored at the
> beginning of strings while regexps are not)
Well, but if you apply the fnmatch to both the source and the dest, it
will work fine!
> I could use globs and match unit names but then the logic would have to
> be a bit more complicated. If there is one glob given on the command
> line then match either of the units. If two, then the first matches s
> and the other c. With regexp this you can match the colour too with no
> extra effort.
Honestly I really don't like matching the lines as a whole, since that
mixes up formatting and matching. We should match first, and format
then, and not the other way round. Otherwise you break people's code if
you change the output slightly...
Lennart Poettering - Red Hat, Inc.
More information about the systemd-devel