diff options
author | Jason McIntyre <jmc@cvs.openbsd.org> | 2008-09-04 15:44:42 +0000 |
---|---|---|
committer | Jason McIntyre <jmc@cvs.openbsd.org> | 2008-09-04 15:44:42 +0000 |
commit | ecfe00efc6d765c4ac7c281c9e2d226c4f5518e5 (patch) | |
tree | 6cdb7aa97ec6587719f0a83d96a241df412e5574 | |
parent | a27702fcc2bb21fc0dee53d8632b99f13e857baa (diff) |
- make -ln and -nl combinations behave identically. currently -l overrides -n.
behaviour now similar to netbsd/freebsd/solaris.
- make -gn and -ng combinations behave identically: long listing, numeric
group ID, no user ID. currently -g overrides -n. behaviour now similar to
netbsd/solaris.
- allow -m and -x to override -1Cgln (and each other) if specified last.
currently -m and -x can be overriden even if they are specified last.
behaviour now similar to netbsd/freebsd. fixes PR 5785 from
Jacek Masiulaniec.
- update man page to reflect reality.
ls.c diff based on Jacek Masiulaniec's diff from PR 5785, and extended by
sobrado. this work is really a joint effort from sobrado and myself.
i don't know about igor, but this particular diff has nearly killed me...
ok millert otto
-rw-r--r-- | bin/ls/ls.1 | 100 | ||||
-rw-r--r-- | bin/ls/ls.c | 23 |
2 files changed, 73 insertions, 50 deletions
diff --git a/bin/ls/ls.1 b/bin/ls/ls.1 index 896e03e8954..914f3a5d014 100644 --- a/bin/ls/ls.1 +++ b/bin/ls/ls.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ls.1,v 1.52 2007/05/31 19:19:15 jmc Exp $ +.\" $OpenBSD: ls.1,v 1.53 2008/09/04 15:44:41 jmc Exp $ .\" $NetBSD: ls.1,v 1.14 1995/12/05 02:44:01 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 @@ -33,7 +33,7 @@ .\" .\" @(#)ls.1 8.7 (Berkeley) 7/29/94 .\" -.Dd $Mdocdate: May 31 2007 $ +.Dd $Mdocdate: September 4 2008 $ .Dt LS 1 .Os .Sh NAME @@ -62,6 +62,15 @@ If more than one operand is given, non-directory operands are displayed first; directory and non-directory operands are sorted separately and in lexicographical order. +By default, +.Nm +lists one entry per line to standard +output; the exceptions are to terminals or when the +.Fl C , +.Fl m , +or +.Fl x +options are specified. .Pp The options are as follows: .Bl -tag -width Ds @@ -113,9 +122,19 @@ after each that is a FIFO. .It Fl f Output is not sorted. .It Fl g -The same as +List in long format as in .Fl l , except that the owner is not printed. +The output of +.Fl gn +and +.Fl ng +is identical: +a long listing with numerical group ID, +and no numerical user ID. +.Fl g +is always overridden by +.Fl l . .It Fl h When used with a long format option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, @@ -149,6 +168,19 @@ Stream output format; list files across the page, separated by commas. List in long format as in .Fl l , but retain user and group IDs in a numeric format. +The output of +.Fl gn +and +.Fl ng +is identical: +a long listing with numerical group ID, +and no numerical user ID. +The output of +.Fl ln +and +.Fl \&nl +is identical: +a long listing with numerical group and user ID. .It Fl o Include the file flags in a long format .Pf ( Fl g , l , @@ -204,52 +236,42 @@ or Multi-column output sorted across the page rather than down the page. .El .Pp -The +It is not an error to specify more than one of +the following mutually exclusive options: .Fl 1 , .Fl C , .Fl g , .Fl l , +.Fl m , +.Fl n , and -.Fl n -options all override each other; the last one specified determines -the format used with the exception that if both -.Fl l +.Fl x ; +.Fl c , +.Fl S , +.Fl t , and -.Fl g -are specified, +.Fl u ; +.Fl k +and +.Fl h . +Where more than one option is specified from the same +mutually exclusive group, +the last option given overrides the others, +except that .Fl l -will always override -.Fl g . -.Pp -The -.Fl c +always overrides +.Fl g ; +.Fl k +always overides +.Fl h ; and -.Fl u -options override each other; the last one specified determines -the file time used. -The .Fl f -option overrides any occurrence of either. -.Pp -By default, -.Nm -lists one entry per line to standard -output; the exceptions are to terminals or when the -.Fl C , -.Fl m , -or -.Fl x -options are specified. -.Pp -File information is displayed with one or more -.Ao blank Ac Ns s -separating the information associated with the -.Fl i , -.Fl s , -.Fl l , +always overrides +.Fl c , +.Fl S , +.Fl t , and -.Fl n -options. +.Fl u . .Ss The Long Format If the .Fl g , diff --git a/bin/ls/ls.c b/bin/ls/ls.c index e9156ae39ce..651233a8320 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ls.c,v 1.29 2007/05/07 18:39:28 millert Exp $ */ +/* $OpenBSD: ls.c,v 1.30 2008/09/04 15:44:41 jmc Exp $ */ /* $NetBSD: ls.c,v 1.18 1996/07/09 09:16:29 mycroft Exp $ */ /* @@ -43,7 +43,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.29 2007/05/07 18:39:28 millert Exp $"; +static char rcsid[] = "$OpenBSD: ls.c,v 1.30 2008/09/04 15:44:41 jmc Exp $"; #endif #endif /* not lint */ @@ -135,43 +135,44 @@ ls_main(int argc, char *argv[]) while ((ch = getopt(argc, argv, "1ACFLRSTacdfghiklmnopqrstux")) != -1) { switch (ch) { /* - * The -1, -C and -l, -m and -x options all override each + * The -1, -C and -l, -m, -n and -x options all override each * other so shell aliasing works right. */ case '1': f_singlecol = 1; - f_column = f_columnacross = f_longform = f_stream = 0; + f_column = f_columnacross = f_longform = 0; + f_numericonly = f_stream = 0; break; case 'C': f_column = 1; - f_longform = f_columnacross = f_singlecol = f_stream = 0; + f_columnacross = f_longform = f_numericonly = 0; + f_singlecol = f_stream = 0; break; case 'g': f_longform = 1; if (f_grouponly != -1) f_grouponly = 1; - f_numericonly = 0; f_column = f_columnacross = f_singlecol = f_stream = 0; break; case 'l': f_longform = 1; f_grouponly = -1; /* -l always overrides -g */ - f_numericonly = 0; f_column = f_columnacross = f_singlecol = f_stream = 0; break; case 'm': f_stream = 1; - f_column = f_columnacross = f_singlecol = 0; - f_singlecol = 0; + f_column = f_columnacross = f_longform = 0; + f_numericonly = f_singlecol = 0; break; case 'x': f_columnacross = 1; - f_column = f_longform = f_singlecol = f_stream = 0; + f_column = f_longform = f_numericonly = 0; + f_singlecol = f_stream = 0; break; case 'n': f_longform = 1; f_numericonly = 1; - f_column = f_singlecol = 0; + f_column = f_columnacross = f_singlecol = f_stream = 0; break; /* The -c and -u options override each other. */ case 'c': |