aboutsummaryrefslogtreecommitdiff
path: root/bin/ls/ls.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ls/ls.c')
-rw-r--r--bin/ls/ls.c53
1 files changed, 30 insertions, 23 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 8a30dd326b4e..b5e3578f27bb 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1989, 1993, 1994\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#if 0
-#ifndef lint
-static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
-#endif /* not lint */
-#endif
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
@@ -136,6 +122,7 @@ static int f_numericonly; /* don't convert uid/gid to name */
int f_octal_escape; /* like f_octal but use C escapes if possible */
static int f_recursive; /* ls subdirectories also */
static int f_reversesort; /* reverse whatever sort is used */
+static int f_verssort; /* sort names using strverscmp(3) rather than strcoll(3) */
int f_samesort; /* sort time and name in same direction */
int f_sectime; /* print full time information */
static int f_singlecol; /* use single column output */
@@ -143,6 +130,7 @@ static int f_singlecol; /* use single column output */
static int f_sizesort;
int f_slash; /* similar to f_type, but only for dirs */
int f_sortacross; /* sort across rows, not down columns */
+ int f_sowner; /* disable showing owner's name */
int f_statustime; /* use time of last mode change */
static int f_stream; /* stream the output, separate with commas */
int f_thousands; /* show file sizes with thousands separators */
@@ -275,7 +263,7 @@ main(int argc, char *argv[])
colorflag = COLORFLAG_AUTO;
#endif
while ((ch = getopt_long(argc, argv,
- "+1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuwxy,", long_opts,
+ "+1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuvwxy,", long_opts,
NULL)) != -1) {
switch (ch) {
/*
@@ -325,14 +313,21 @@ main(int argc, char *argv[])
case 'A':
f_listdot = 1;
break;
- /* The -t and -S options override each other. */
+ /* The -S, -t and -v options override each other. */
case 'S':
f_sizesort = 1;
f_timesort = 0;
+ f_verssort = 0;
break;
case 't':
f_timesort = 1;
f_sizesort = 0;
+ f_verssort = 0;
+ break;
+ case 'v':
+ f_verssort = 1;
+ f_sizesort = 0;
+ f_timesort = 0;
break;
/* Other flags. Please keep alphabetic. */
case ',':
@@ -401,7 +396,11 @@ main(int argc, char *argv[])
f_listdir = 1;
f_recursive = 0;
break;
- case 'g': /* Compatibility with 4.3BSD. */
+ case 'g':
+ f_longform = 1;
+ f_singlecol = 0;
+ f_stream = 0;
+ f_sowner = 1;
break;
case 'h':
f_humanval = 1;
@@ -420,6 +419,9 @@ main(int argc, char *argv[])
break;
case 'n':
f_numericonly = 1;
+ f_longform = 1;
+ f_singlecol = 0;
+ f_stream = 0;
break;
case 'o':
f_flags = 1;
@@ -564,12 +566,15 @@ main(int argc, char *argv[])
blocksize /= 512;
}
}
+
/* Select a sort function. */
if (f_reversesort) {
- if (!f_timesort && !f_sizesort)
- sortfcn = revnamecmp;
- else if (f_sizesort)
+ if (f_sizesort)
sortfcn = revsizecmp;
+ else if (f_verssort)
+ sortfcn = revverscmp;
+ else if (!f_timesort)
+ sortfcn = revnamecmp;
else if (f_accesstime)
sortfcn = revacccmp;
else if (f_birthtime)
@@ -579,10 +584,12 @@ main(int argc, char *argv[])
else /* Use modification time. */
sortfcn = revmodcmp;
} else {
- if (!f_timesort && !f_sizesort)
- sortfcn = namecmp;
- else if (f_sizesort)
+ if (f_sizesort)
sortfcn = sizecmp;
+ else if (f_verssort)
+ sortfcn = verscmp;
+ else if (!f_timesort)
+ sortfcn = namecmp;
else if (f_accesstime)
sortfcn = acccmp;
else if (f_birthtime)