summaryrefslogtreecommitdiffstats
path: root/bin/ls/ls.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2005-11-16 07:13:37 +0000
committerru <ru@FreeBSD.org>2005-11-16 07:13:37 +0000
commit872d416547f20c6fefccc1b07c8bdc226632704c (patch)
treef8a073dcb68bb1c6eeda6441f96f5fe0e538d385 /bin/ls/ls.c
parent3d724a19e420e0a62fbcb58bf82dfee3837147c9 (diff)
downloadFreeBSD-src-872d416547f20c6fefccc1b07c8bdc226632704c.zip
FreeBSD-src-872d416547f20c6fefccc1b07c8bdc226632704c.tar.gz
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
Diffstat (limited to 'bin/ls/ls.c')
-rw-r--r--bin/ls/ls.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 1e7586b..f354fc2 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -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;
}
OpenPOWER on IntegriCloud