Andreas Schwab wrote:
> 
> Bruce Korb <[EMAIL PROTECTED]> writes:
> 
> > Hi Andreas,
> >
> > Andreas Schwab wrote:
> >> >>   getent passwd bob
> >> >>   bob:x:1000:1000:Bob Proulx,,,:/home/bob:/bin/bash
> >> >
> >> > 1.  you cannot get it by user id,
> >>
> >> Yes, you can.
> >
> > OK.  I only read the man/info pages.
> 
> getent uses the same interfaces as getpwnam, getpwuid, etc.

So, why doesn't the page tell me how to determine the needed
entry given that my program is a script and really just wants
the full user name of the current user?  Specifically, how can
it be used to simplify the following:

  lname=`id | sed 's/ .*//;s/)//;s/.*(//'`
  fname=`getent passwd $lname | awk -F: '{ print $5 }'`

the main complexities are:
 1. lname may appear as 'uid=1234'
 2. getting lname is a hassle anyway
 3. Remembering that the user name is the fifth field is much harder
    to remember than ``getpwnam -h'' or ``getent passwd me'' and
    count colons
 4. two pipes + two subshells

Ick.

> The output of getent is much easier to parse than both of your examples.
> The first form is ambigous, and in the second form the tag names likely
> change due to i18n.

Neither one is the usual usage:

  $ getpwnam -N
  Bruce Korb

That's really easy to parse.


_______________________________________________
Bug-coreutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-coreutils

Reply via email to