bug-coreutils
[Top][All Lists]
Advanced

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

Re: proposed new program: getpwnam [Re: --format flag


From: Bruce Korb
Subject: Re: proposed new program: getpwnam [Re: --format flag
Date: Thu, 18 Dec 2003 08:41:32 -0800

Jim Meyering wrote:

> I hesitate to add new tools that can be approximated with
> one-liners using e.g Perl
> 
>   $ perl -MUser::pwent -e '$pw=getpwnam "root" or die; print $pw->shell,"\n"'
>   /bin/bash

I think I know why I didn't think of that.  :-)

>   [ Coreutils should come with a collection of useful one-liners,
>     shell functions/aliases, and little scripts.  But someone would
>     have to collect and document them.  Volunteers? ]
> 
> But `getpwnam --shell root' is certainly easier to type.  And
> as a real program, it'd be able to produce better (including
> internationalized) diagnostics and do better error checking --
> e.g. via closeout.c's close_stdout.
> 
> So, in this case it's probably worth it.  I do like the idea of a
> getpwnam command, but am not sure that should be the name of the command.
> Obviously it's a good name from the consistency-with-library-name
> standpoint, but its mangled name is sort of reminiscent of `creat'.
> Suggested alternatives welcome.

I think consistency is more important than the literary aesthetics
of full words.  The time for that would have been when getpwnam(3)
was invented.  I really prefer limiting the things needed to remember.
When writing "C", it's ``getpwnam()'', when writing a shell script,
it's ... the same!  :-D

> Would you be interested in converting your program to use the same
> sort of framework that's used in the other 90 programs in coreutils?
> And documenting it?

One cute thing about my weirdo style is that the doc stuff (tho a bit
anemic in this case) is done.  The attached man page and texinfo stuff
is directly derived from the "opts.def" file.

However, in direct answer to your question, I'd consider either adapting
this thing to your framework, or adapting the other way.  That might
take a while, though. ;)

Cheers - Bruce

P.S. another example might be, "realpath(1)".  Perhaps there's a perl
     way to do it, but this doesn't work:

     perl -e '$p = realpath("."); print "$p\n";'

     I'm not a perl guru.  Anyway, a few years ago in my SCO days, I
     did convince the Unix Labs command line guy to add a realpath(1).
     Maybe it's in the current UnixWare/OpenUnix/whatever-its-called?

$ ./realpath -?
USAGE:  ./realpath [ -h | -v | <path> ... ]
If no '<path>'s are supplied, pathnames are read from stdin
$ ./realpath -v
realpath version 1.0
.TH GETPWNAM 1 2003-12-16 "" "Programmer's Manual"
.\"  DO NOT EDIT THIS FILE   (getpwnam.1)
.\"  
.\"  It has been AutoGen-ed  Tuesday December 16, 2003 at 09:09:26 PM PST
.\"  From the definitions    opts.def
.\"  and the template file   agman1.tpl
.\"
.SH NAME
getpwnam \- Get password entries
.SH SYNOPSIS
.B getpwnam
.\" Mixture of short (flag) options and long options
.RB [ -\fIflag\fP " [\fIvalue\fP]]... [" --\fIopt-name\fP " [[=| 
]\fIvalue\fP]]..."
.br
.in +8
[ user-name-or-id ]
.PP
This command uses getpwnam(3) or getpwuid(3) to obtain the requested
information from the passwd database.  If a user name or user id is
not provided, the information for the current user is obtained.
The results are printed in the order selected.  If you select no options,
nothing is printed on success, but the user name/user id will have been
validated.
.SH "DESCRIPTION"
This manual page documents, briefly, the \fBgetpwnam\fP command.
Its description is not documented.
.SH OPTIONS
.TP
.BR -n ", " --name
Print the user name.
.sp
The user login name will be printed.
.TP
.BR -p ", " --passwd
Print the (encrypted) password.
.sp
The encrypted password will be printed.
.TP
.BR -u ", " --uid
Print the user id.
.sp
The numeric user id will be printed.
.TP
.BR -g ", " --gname
Print the group name.
.sp
The name of the user's primary group will be printed.
.TP
.BR -G ", " --gid
Print the group id.
.sp
The numeric primary group id will be printed.
.TP
.BR -N ", " --gecos
Print the real user name (comment string).
.sp
The real user name will be printed, usually.
It is designated as the account "comment string".
.TP
.BR -d ", " --dir
Print the home directory.
.sp
The user's home directory will be printed.
.TP
.BR -s ", " --shell
Print the login shell.
.sp
The name of the program that is run when the user logs in will be printed.
.TP
.BR -A ", " --all
Print everything.
This option must not appear in combination with any of the following options:
name, passwd, uid, gname, gid, gecos, dir, shell.
.sp
Print all of the available fields, including the name of
the primary group.
.TP
.BR -V ", " --verbose
Verbose output.
.sp
Print each item of information on a separate line, with
a short description of each.
.TP
.BR \-? , " \--help"
Display usage information and exit.
.TP
.BR \-! , " \--more-help"
Extended usage information passed thru pager.
.TP
.BR \-v " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]"
Output version of program and exit.  The default mode is `v', a simple
version.  The `c' mode will print copyright information and `n' will
print the full copyright notice.
.SH AUTHOR
Bruce Korb
.br
Please send bug reports to:  address@hidden

.PP
Released under the GNU General Public License.
.PP
This manual page was \fIAutoGen\fP-erated from the \fBgetpwnam\fP
option definitions.

Attachment: getpwnam.texi
Description: TeXInfo document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]