diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-04-01 22:59:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-04-01 22:59:39 +0000 |
commit | 7380c71f539df517aa508e6319ffa25b431036d5 (patch) | |
tree | 5806605b2b4d89fda89754258d35b2fc859f1a68 /bin/ls/ls.c | |
parent | 1e9becb7053969ec46b51de9adb7c903b518fd47 (diff) |
option 'n' was unused, so let's come up with a feature to use it!!! YEAH!!
add -n (numeric uid/gid), fix some man page errors; tv@pobox.com
Diffstat (limited to 'bin/ls/ls.c')
-rw-r--r-- | bin/ls/ls.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c index 7dc75185714..893f65817f3 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ls.c,v 1.6 1997/01/03 22:36:08 millert Exp $ */ +/* $OpenBSD: ls.c,v 1.7 1997/04/01 22:59:38 deraadt Exp $ */ /* $NetBSD: ls.c,v 1.18 1996/07/09 09:16:29 mycroft Exp $ */ /* @@ -47,7 +47,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94"; #else -static char rcsid[] = "$OpenBSD: ls.c,v 1.6 1997/01/03 22:36:08 millert Exp $"; +static char rcsid[] = "$OpenBSD: ls.c,v 1.7 1997/04/01 22:59:38 deraadt Exp $"; #endif #endif /* not lint */ @@ -96,6 +96,7 @@ int f_longform; /* long listing format */ int f_newline; /* if precede with newline */ int f_nonprint; /* show unprintables as ? */ int f_nosort; /* don't sort output */ +int f_numericonly; /* don't expand uid to symbolic name */ int f_recursive; /* ls subdirectories also */ int f_reversesort; /* reverse whatever sort is used */ int f_sectime; /* print the real time for all files */ @@ -133,7 +134,7 @@ main(argc, argv) f_listdot = 1; fts_options = FTS_PHYSICAL; - while ((ch = getopt(argc, argv, "1ACFLRSTWacdfgikloqrstu")) != -1) { + while ((ch = getopt(argc, argv, "1ACFLRSTWacdfgiklnoqrstu")) != -1) { switch (ch) { /* * The -1, -C and -l options all override each other so shell @@ -149,6 +150,12 @@ main(argc, argv) break; case 'l': f_longform = 1; + f_numericonly = 0; + f_column = f_singlecol = 0; + break; + case 'n': + f_longform = 1; + f_numericonly = 1; f_column = f_singlecol = 0; break; /* The -c and -u options override each other. */ @@ -392,6 +399,7 @@ display(p, list) int bcfile, flen, glen, ulen, maxflags, maxgroup, maxuser; int entries, needstats; char *user, *group, buf[20]; /* 32 bits == 10 digits */ + char nuser[12], ngroup[12]; char *flags = NULL; /* @@ -452,10 +460,17 @@ display(p, list) btotal += sp->st_blocks; if (f_longform) { - user = user_from_uid(sp->st_uid, 0); + if (f_numericonly) { + snprintf(nuser, 12, "%u", sp->st_uid); + snprintf(ngroup, 12, "%u", sp->st_gid); + user = nuser; + group = ngroup; + } else { + user = user_from_uid(sp->st_uid, 0); + group = group_from_gid(sp->st_gid, 0); + } if ((ulen = strlen(user)) > maxuser) maxuser = ulen; - group = group_from_gid(sp->st_gid, 0); if ((glen = strlen(group)) > maxgroup) maxgroup = glen; if (f_flags) { |