From 872d416547f20c6fefccc1b07c8bdc226632704c Mon Sep 17 00:00:00 2001 From: ru Date: Wed, 16 Nov 2005 07:13:37 +0000 Subject: 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 --- bin/ls/ls.1 | 12 +++++------- bin/ls/ls.c | 18 +++++++----------- bin/ls/util.c | 4 ++-- 3 files changed, 14 insertions(+), 20 deletions(-) (limited to 'bin/ls') diff --git a/bin/ls/ls.1 b/bin/ls/ls.1 index abace9e..3f1b084 100644 --- a/bin/ls/ls.1 +++ b/bin/ls/ls.1 @@ -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 -.Fl A -option. Usually used by super-user when +Prevent .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. 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; } diff --git a/bin/ls/util.c b/bin/ls/util.c index 914b030..01ae6cb 100644 --- a/bin/ls/util.c +++ b/bin/ls/util.c @@ -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); -- cgit v1.1