Changeset View
Standalone View
bin/ls/ls.c
Show First 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | static int f_numericonly; /* don't convert uid/gid to name */ | ||||
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 */ | ||||
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_sgroup; /* show the name of owning group */ | |||||
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_sowner; /* show owner's name */ | |||||
int f_statustime; /* use time of last mode change */ | int f_statustime; /* use time of last mode change */ | ||||
static int f_stream; /* stream the output, separate with commas */ | static int f_stream; /* stream the output, separate with commas */ | ||||
int f_thousands; /* show file sizes with thousands separators */ | int f_thousands; /* show file sizes with thousands separators */ | ||||
char *f_timeformat; /* user-specified time format */ | char *f_timeformat; /* user-specified time format */ | ||||
static int f_timesort; /* sort by time vice name */ | static int f_timesort; /* sort by time vice name */ | ||||
int f_type; /* add type character for non-regular files */ | int f_type; /* add type character for non-regular files */ | ||||
static int f_whiteout; /* show whiteout entries */ | static int f_whiteout; /* show whiteout entries */ | ||||
#ifdef COLORLS | #ifdef COLORLS | ||||
▲ Show 20 Lines • Show All 116 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:FGHILOPRSTUWXZabcdfghiklmnopqrstuwxy,", 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 81 Lines • ▼ Show 20 Lines | #endif | ||||
case 'I': | case 'I': | ||||
f_noautodot = 1; | f_noautodot = 1; | ||||
break; | break; | ||||
case 'L': | case 'L': | ||||
fts_options &= ~FTS_PHYSICAL; | fts_options &= ~FTS_PHYSICAL; | ||||
fts_options |= FTS_LOGICAL; | fts_options |= FTS_LOGICAL; | ||||
f_nofollow = 0; | f_nofollow = 0; | ||||
break; | break; | ||||
case 'O': | |||||
f_flags = 1; | |||||
break; | |||||
minsoochoo0122_proton.me: ls(1) says it cannot find an option for this although I compiled and installed it. Any ideas? | |||||
Done Inline ActionsMissing in the allowed options you're passing getopt_long. pauamma_gundo.com: Missing in the allowed options you're passing getopt_long. | |||||
Done Inline ActionsI fixed this by editing usage minsoochoo0122_proton.me: I fixed this by editing usage | |||||
Done Inline ActionsI modified getopt_long on the 280th line. minsoochoo0122_proton.me: I modified getopt_long on the 280th line. | |||||
Done Inline ActionsYou need to update the string passed to getopt_long() above. See the getopt_long.3 man page for more details. markj: You need to update the string passed to getopt_long() above. See the getopt_long.3 man page for… | |||||
case 'P': | case 'P': | ||||
fts_options &= ~FTS_COMFOLLOW; | fts_options &= ~FTS_COMFOLLOW; | ||||
fts_options &= ~FTS_LOGICAL; | fts_options &= ~FTS_LOGICAL; | ||||
fts_options |= FTS_PHYSICAL; | fts_options |= FTS_PHYSICAL; | ||||
f_nofollow = 1; | f_nofollow = 1; | ||||
break; | break; | ||||
case 'R': | case 'R': | ||||
f_recursive = 1; | f_recursive = 1; | ||||
Show All 12 Lines | case 'b': | ||||
f_octal = 0; | f_octal = 0; | ||||
f_octal_escape = 1; | f_octal_escape = 1; | ||||
break; | break; | ||||
/* The -d option turns off the -R option. */ | /* The -d option turns off the -R option. */ | ||||
case 'd': | case 'd': | ||||
f_listdir = 1; | f_listdir = 1; | ||||
f_recursive = 0; | f_recursive = 0; | ||||
break; | break; | ||||
case 'g': /* Compatibility with 4.3BSD. */ | case 'g': | ||||
f_longform = 1; | |||||
f_singlecol = 0; | |||||
f_stream = 0; | |||||
f_sowner = 1; | |||||
break; | break; | ||||
Done Inline ActionsRemove the line that's commented-out. rpokala: Remove the line that's commented-out. | |||||
Done Inline Actions? jrtc27: ? | |||||
case 'h': | case 'h': | ||||
f_humanval = 1; | f_humanval = 1; | ||||
break; | break; | ||||
case 'i': | case 'i': | ||||
f_inode = 1; | f_inode = 1; | ||||
break; | break; | ||||
case 'k': | case 'k': | ||||
f_humanval = 0; | f_humanval = 0; | ||||
f_kblocks = 1; | f_kblocks = 1; | ||||
break; | break; | ||||
case 'm': | case 'm': | ||||
f_stream = 1; | f_stream = 1; | ||||
f_singlecol = 0; | f_singlecol = 0; | ||||
f_longform = 0; | f_longform = 0; | ||||
break; | break; | ||||
case 'n': | case 'n': | ||||
f_numericonly = 1; | f_numericonly = 1; | ||||
f_longform = 1; | |||||
f_singlecol = 0; | |||||
f_stream = 0; | |||||
break; | break; | ||||
case 'o': | case 'o': | ||||
f_flags = 1; | f_longform = 1; | ||||
Done Inline ActionsWhy's f_flags gone? Was it wrong before? This needs addressing in the commit message if so. jrtc27: Why's f_flags gone? Was it wrong before? This needs addressing in the commit message if so. | |||||
Done Inline ActionsI added explanation in the summary. minsoochoo0122_proton.me: I added explanation in the summary. | |||||
f_singlecol = 0; | |||||
f_stream = 0; | |||||
f_sgroup = 1; | |||||
(void)printf("The original function of the -o option is deprecated. Use -O to show file flags.\n"); | |||||
Done Inline ActionsWell it doesn't behave the same as -O, so suggesting that seems wrong. Printing warnings that can't be disabled is also often not well received, and it should definitely not go to stdout. This line is also way too long for the column limit. jrtc27: Well it doesn't behave the same as -O, so suggesting that seems wrong. Printing warnings that… | |||||
Done Inline ActionsThen how about adding a warning message in man page, not through stdout? minsoochoo0122_proton.me: Then how about adding a warning message in man page, not through stdout? | |||||
Done Inline ActionsIs the manual page visible enough? (But if the deprecation message stays in source,, yes please to stderr.) pauamma_gundo.com: Is the manual page visible enough? (But if the deprecation message stays in source,, yes please… | |||||
Done Inline ActionsRecently some systems started warning about fgrep being deprecated (this is GNU's doing) and to me that's infuriating. So I vote for moving this information to the manual page only. pstef: Recently some systems started warning about `fgrep` being deprecated (this is GNU's doing) and… | |||||
Done Inline ActionsThank you for your suggestion. I like this idea. I removed warning message in stderr and moved it to the man page. minsoochoo0122_proton.me: Thank you for your suggestion. I like this idea. I removed warning message in stderr and moved… | |||||
break; | break; | ||||
case 'p': | case 'p': | ||||
f_slash = 1; | f_slash = 1; | ||||
f_type = 1; | f_type = 1; | ||||
break; | break; | ||||
case 'q': | case 'q': | ||||
f_nonprint = 1; | f_nonprint = 1; | ||||
f_octal = 0; | f_octal = 0; | ||||
▲ Show 20 Lines • Show All 583 Lines • Show Last 20 Lines |
ls(1) says it cannot find an option for this although I compiled and installed it. Any ideas?