diff --git a/bin/ls/ls.h b/bin/ls/ls.h --- a/bin/ls/ls.h +++ b/bin/ls/ls.h @@ -56,6 +56,7 @@ extern int f_size; /* list size in short listing */ extern int f_slash; /* append a '/' if the file is a directory */ extern int f_sortacross; /* sort across rows, not down columns */ +extern int f_sowner; /* disable showing the owner's name */ extern int f_statustime; /* use time of last mode change */ extern int f_thousands; /* show file sizes with thousands separators */ extern char *f_timeformat; /* user-specified time format */ diff --git a/bin/ls/ls.1 b/bin/ls/ls.1 --- a/bin/ls/ls.1 +++ b/bin/ls/ls.1 @@ -301,14 +301,9 @@ .Fl s options. .It Fl g -This option has no effect. -It is only available for compatibility with -.Bx 4.3 , -where it was used to display the group name in the long +Display the long .Pq Fl l -format output. -This option is incompatible with -.St -p1003.1-2008 . +format output without the file owner's name or number. .It Fl h When used with the .Fl l diff --git a/bin/ls/ls.c b/bin/ls/ls.c --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -144,6 +144,7 @@ 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 */ @@ -402,7 +403,11 @@ 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; @@ -421,6 +426,9 @@ break; case 'n': f_numericonly = 1; + f_longform = 1; + f_singlecol = 0; + f_stream = 0; break; case 'o': f_flags = 1; diff --git a/bin/ls/print.c b/bin/ls/print.c --- a/bin/ls/print.c +++ b/bin/ls/print.c @@ -234,9 +234,11 @@ strmode(sp->st_mode, buf); aclmode(buf, p); np = p->fts_pointer; - (void)printf("%s %*ju %-*s %-*s ", buf, dp->s_nlink, - (uintmax_t)sp->st_nlink, dp->s_user, np->user, dp->s_group, - np->group); + (void)printf("%s %*ju ", buf, dp->s_nlink, + (uintmax_t)sp->st_nlink); + if (!f_sowner) + (void)printf("%-*s ", dp->s_user, np->user); + (void)printf("%-*s ", dp->s_group, np->group); if (f_flags) (void)printf("%-*s ", dp->s_flags, np->flags); if (f_label)