Changeset View
Changeset View
Standalone View
Standalone View
bin/ls/ls.c
Show First 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | static int f_nofollow; /* don't follow symbolic link arguments */ | ||||
int f_nonprint; /* show unprintables as ? */ | int f_nonprint; /* show unprintables as ? */ | ||||
static int f_nosort; /* don't sort output */ | static int f_nosort; /* don't sort output */ | ||||
int f_notabs; /* don't use tab-separated multi-col output */ | int f_notabs; /* don't use tab-separated multi-col output */ | ||||
static int f_numericonly; /* don't convert uid/gid to name */ | static int f_numericonly; /* don't convert uid/gid to name */ | ||||
int f_octal; /* show unprintables as \xxx */ | int f_octal; /* show unprintables as \xxx */ | ||||
int f_octal_escape; /* like f_octal but use C escapes if possible */ | int f_octal_escape; /* like f_octal but use C escapes if possible */ | ||||
static int f_recursive; /* ls subdirectories also */ | static int f_recursive; /* ls subdirectories also */ | ||||
static int f_reversesort; /* reverse whatever sort is used */ | 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_samesort; /* sort time and name in same direction */ | ||||
int f_sectime; /* print full time information */ | int f_sectime; /* print full time information */ | ||||
static int f_singlecol; /* use single column output */ | static int f_singlecol; /* use single column output */ | ||||
int f_size; /* list size in short listing */ | int f_size; /* list size in short listing */ | ||||
static int f_sizesort; | static int f_sizesort; | ||||
int f_slash; /* similar to f_type, but only for dirs */ | int f_slash; /* similar to f_type, but only for dirs */ | ||||
int f_sortacross; /* sort across rows, not down columns */ | int f_sortacross; /* sort across rows, not down columns */ | ||||
int f_statustime; /* use time of last mode change */ | int f_statustime; /* use time of last mode change */ | ||||
▲ Show 20 Lines • Show All 123 Lines • ▼ Show 20 Lines | #endif | ||||
* For historical compatibility, we'll use our autodetection if CLICOLOR | * For historical compatibility, we'll use our autodetection if CLICOLOR | ||||
* is set. | * is set. | ||||
*/ | */ | ||||
#ifdef COLORLS | #ifdef COLORLS | ||||
if (getenv("CLICOLOR")) | if (getenv("CLICOLOR")) | ||||
colorflag = COLORFLAG_AUTO; | colorflag = COLORFLAG_AUTO; | ||||
#endif | #endif | ||||
while ((ch = getopt_long(argc, argv, | while ((ch = getopt_long(argc, argv, | ||||
"+1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuwxy,", long_opts, | "+1ABCD:FGHILPRSTUWXZabcdfghiklmnopqrstuvwxy,", long_opts, | ||||
NULL)) != -1) { | NULL)) != -1) { | ||||
switch (ch) { | switch (ch) { | ||||
/* | /* | ||||
* The -1, -C, -x and -l options all override each other so | * The -1, -C, -x and -l options all override each other so | ||||
* shell aliasing works right. | * shell aliasing works right. | ||||
*/ | */ | ||||
case '1': | case '1': | ||||
f_singlecol = 1; | f_singlecol = 1; | ||||
▲ Show 20 Lines • Show All 147 Lines • ▼ Show 20 Lines | case 'q': | ||||
f_octal_escape = 0; | f_octal_escape = 0; | ||||
break; | break; | ||||
case 'r': | case 'r': | ||||
f_reversesort = 1; | f_reversesort = 1; | ||||
break; | break; | ||||
case 's': | case 's': | ||||
f_size = 1; | f_size = 1; | ||||
break; | break; | ||||
case 'v': | |||||
f_verssort = 1; | |||||
break; | |||||
case 'w': | case 'w': | ||||
f_nonprint = 0; | f_nonprint = 0; | ||||
f_octal = 0; | f_octal = 0; | ||||
f_octal_escape = 0; | f_octal_escape = 0; | ||||
break; | break; | ||||
case 'y': | case 'y': | ||||
f_samesort = 1; | f_samesort = 1; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Lines | if (f_kblocks) | ||||
blocksize = 2; | blocksize = 2; | ||||
else { | else { | ||||
(void)getbsize(¬used, &blocksize); | (void)getbsize(¬used, &blocksize); | ||||
blocksize /= 512; | blocksize /= 512; | ||||
} | } | ||||
} | } | ||||
/* Select a sort function. */ | /* Select a sort function. */ | ||||
if (f_reversesort) { | if (f_reversesort) { | ||||
if (!f_timesort && !f_sizesort) | if (f_sizesort) | ||||
sortfcn = revnamecmp; | |||||
else if (f_sizesort) | |||||
sortfcn = revsizecmp; | sortfcn = revsizecmp; | ||||
else if (f_verssort) | |||||
sortfcn = revverscmp; | |||||
else if (!f_timesort) | |||||
sortfcn = revnamecmp; | |||||
else if (f_accesstime) | else if (f_accesstime) | ||||
sortfcn = revacccmp; | sortfcn = revacccmp; | ||||
else if (f_birthtime) | else if (f_birthtime) | ||||
sortfcn = revbirthcmp; | sortfcn = revbirthcmp; | ||||
else if (f_statustime) | else if (f_statustime) | ||||
sortfcn = revstatcmp; | sortfcn = revstatcmp; | ||||
else /* Use modification time. */ | else /* Use modification time. */ | ||||
sortfcn = revmodcmp; | sortfcn = revmodcmp; | ||||
} else { | } else { | ||||
if (!f_timesort && !f_sizesort) | if (f_sizesort) | ||||
sortfcn = namecmp; | |||||
else if (f_sizesort) | |||||
sortfcn = sizecmp; | sortfcn = sizecmp; | ||||
else if (f_verssort) | |||||
sortfcn = verscmp; | |||||
else if (!f_timesort) | |||||
sortfcn = namecmp; | |||||
else if (f_accesstime) | else if (f_accesstime) | ||||
sortfcn = acccmp; | sortfcn = acccmp; | ||||
else if (f_birthtime) | else if (f_birthtime) | ||||
sortfcn = birthcmp; | sortfcn = birthcmp; | ||||
else if (f_statustime) | else if (f_statustime) | ||||
sortfcn = statcmp; | sortfcn = statcmp; | ||||
else /* Use modification time. */ | else /* Use modification time. */ | ||||
sortfcn = modcmp; | sortfcn = modcmp; | ||||
▲ Show 20 Lines • Show All 423 Lines • Show Last 20 Lines |