[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#727708: [PATCH] systemctl: allow globbing in commands which take multiple unit names



On Thu, Dec 26, 2013 at 09:41:42PM +0100, Lennart Poettering wrote:
> On Thu, 26.12.13 10:09, Russ Allbery (rra@debian.org) wrote:
> > What I've switched to instead is using tiny enums for this purpose.  So:
> > 
> >     enum mangle_type {
> >         MANGLE_NOGLOB = 0,
> >         MANGLE_GLOB   = 1
> >     };
> > 
> > and then at the call site:
> > 
> >     n = unit_name_mangle(e, MANGLE_NOGLOB);
> > 
> > which makes the meaning of that argument immediately obvious.
> 
> As long as this is just one boolean arg on functions, or the functions
> are internally used I think booleans are fine to use.
> 
> I don't think flag fields are necessarily the best choice for APIs in
> general. For APIs that are built around a context object seperate
> boolean setter calls are the better choice (i.e. foobar_set_waldo() to
> set som boolean called "waldo" on a context object "foobar). 
I went ahead and added MANGLE_GLOB/NOGLOB as Russ suggested. I think
that it make the code in systemctl (which is pretty convoluted) easier
to read. It is a separate commit, so it's easy to revert if you think
the change isn't worth it.

Zbyszek


Reply to: