On Dec  6 11:56, Jon Turney wrote:
> On 05/12/2025 19:41, Corinna Vinschen wrote:
> > +     fprintf (stderr, "Usage: %s [-] [group]\n",
> 
> Maybe '[-|-l]'?

The usage message is the same as used by the shadow-utils newgrp
on Linux.  It supports -l, but doesn't print it for some reason.

If you think we should do it better, I can change our usage output
and send a v2 patch, no worries.

> > +              program_invocation_short_name);
> > +     return 1;
> > +   }
> >         new_child_env = true;
> >         --argc;
> >         ++argv;
> > @@ -165,8 +165,16 @@ main (int argc, const char **argv)
> >       }
> >     else
> >       {
> > -      gr = getgrnam (argv[1]);
> > -      if (!gr)
> > +      char *eptr;
> > +
> > +      if ((gr = getgrnam (argv[1])) != NULL)
> > +   /*valid*/;
> > +      else if (isdigit ((int) argv[1][0])
> > +          && (gid = strtoul (argv[1], &eptr, 10)) != ULONG_MAX
> > +          && *eptr == '\0'
> > +          && (gr = getgrgid (gid)) != NULL)
> 
> I spent a bit of time worrying how this handled edge cases like '' or '0',
> but I think it's all good!

Thanks for checking!


Corinna

Reply via email to