Having three options (-a, -A, -I) controlling the output of dotted

files is too much and hard to follow.  Instead, make the -I option
just mean "do not automatically set -A for root".  That is, if -A
is explicitly set, -I is ignored.  Also, document -I in usage().
(The ls.c diff is better viewed relative to rev. 1.80.)

No objection:	mux
Silence from:	mnag
MFC after:	3 days
This commit is contained in:
Ruslan Ermilov 2005-11-16 07:13:37 +00:00
parent c76b3c840a
commit 390a478eb0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152469
3 changed files with 14 additions and 20 deletions

View File

@ -32,7 +32,7 @@
.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
.\" $FreeBSD$
.\"
.Dd November 10, 2005
.Dd November 16, 2005
.Dt LS 1
.Os
.Sh NAME
@ -72,9 +72,9 @@ List all entries except for
.Pa \&.
and
.Pa .. .
Always set for the super-user.
Automatically set for the super-user unless
.Fl I
cancel this option.
is specified.
.It Fl B
Force printing of non-printable characters (as defined by
.Xr ctype 3
@ -120,11 +120,9 @@ or
.Fl l
options are specified.
.It Fl I
This option cancels the
Prevent
.Fl A
option. Usually used by super-user when
.Fl A
is not necessary.
from being automatically set for the super-user.
.It Fl L
If argument is a symbolic link, list the file or directory the link references
rather than the link itself.

View File

@ -110,8 +110,7 @@ int termwidth = 80; /* default terminal width */
static int f_kblocks; /* print size in kilobytes */
static int f_listdir; /* list actual directory, not contents */
static int f_listdot; /* list files beginning with . */
static int f_nolistdot; /* don't list files beginning with . */
static int f_forcelistdot; /* force list files beginning with . */
static int f_noautodot; /* do not automatically enable -A for root */
int f_longform; /* long listing format */
int f_nonprint; /* show unprintables as ? */
static int f_nosort; /* don't sort output */
@ -241,13 +240,12 @@ main(int argc, char *argv[])
break;
case 'a':
fts_options |= FTS_SEEDOT;
f_forcelistdot = 1;
break;
/* FALLTHROUGH */
case 'A':
f_listdot = 1;
break;
case 'I':
f_nolistdot = 1;
f_noautodot = 1;
break;
/* The -d option turns off the -R option. */
case 'd':
@ -328,8 +326,8 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
/* Root is -A automatically. */
if (!getuid() && !f_nolistdot)
/* Root is -A automatically unless -I. */
if (!f_listdot && getuid() == (uid_t)0 && !f_noautodot)
f_listdot = 1;
/* Enabling of colours is conditional on the environment. */
@ -496,8 +494,7 @@ traverse(int argc, char *argv[], int options)
break;
case FTS_D:
if (p->fts_level != FTS_ROOTLEVEL &&
p->fts_name[0] == '.' && ((!f_listdot ||
f_nolistdot) && !f_forcelistdot))
p->fts_name[0] == '.' && !f_listdot)
break;
/*
@ -657,8 +654,7 @@ display(const FTSENT *p, FTSENT *list, int options)
}
} else {
/* Only display dot file if -a/-A set. */
if (cur->fts_name[0] == '.' && ((!f_listdot ||
f_nolistdot) && !f_forcelistdot)) {
if (cur->fts_name[0] == '.' && !f_listdot) {
cur->fts_number = NO_PRINT;
continue;
}

View File

@ -222,9 +222,9 @@ usage(void)
{
(void)fprintf(stderr,
#ifdef COLORLS
"usage: ls [-ABCFGHLPRSTWZabcdfghiklmnopqrstuwx1]"
"usage: ls [-ABCFGHILPRSTWZabcdfghiklmnopqrstuwx1]"
#else
"usage: ls [-ABCFHLPRSTWZabcdfghiklmnopqrstuwx1]"
"usage: ls [-ABCFHILPRSTWZabcdfghiklmnopqrstuwx1]"
#endif
" [file ...]\n");
exit(1);