summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2010-02-08 15:42:55 +0000
committerjh <jh@FreeBSD.org>2010-02-08 15:42:55 +0000
commitb245e1e6ed36169a0aece5c3e57c8e1170e564c7 (patch)
tree51eaf0fba5b250bfc99de52c72f9142b2abfad2d /bin
parentd40177139efc3459342296494d92f3bbee157649 (diff)
downloadFreeBSD-src-b245e1e6ed36169a0aece5c3e57c8e1170e564c7.zip
FreeBSD-src-b245e1e6ed36169a0aece5c3e57c8e1170e564c7.tar.gz
Make sure that FTS_COMFOLLOW is not set when the -P option is in effect.
Otherwise the -i option will show the inode number of the referenced file for symbolic links given on the command line. Similarly, the file color was printed according to the link target in colorized output. PR: bin/102394 Reviewed by: jilles MFC after: 2 weeks
Diffstat (limited to 'bin')
-rw-r--r--bin/ls/ls.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index ea0ba6d..e482e22 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -113,6 +113,7 @@ static int f_listdir; /* list actual directory, not contents */
static int f_listdot; /* list files beginning with . */
static int f_noautodot; /* do not automatically enable -A for root */
int f_longform; /* long listing format */
+static int f_nofollow; /* don't follow symbolic link arguments */
int f_nonprint; /* show unprintables as ? */
static int f_nosort; /* don't sort output */
int f_notabs; /* don't use tab-separated multi-col output */
@@ -234,6 +235,7 @@ main(int argc, char *argv[])
break;
case 'H':
fts_options |= FTS_COMFOLLOW;
+ f_nofollow = 0;
break;
case 'G':
setenv("CLICOLOR", "", 1);
@@ -241,11 +243,13 @@ main(int argc, char *argv[])
case 'L':
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
+ f_nofollow = 0;
break;
case 'P':
fts_options &= ~FTS_COMFOLLOW;
fts_options &= ~FTS_LOGICAL;
fts_options |= FTS_PHYSICAL;
+ f_nofollow = 1;
break;
case 'R':
f_recursive = 1;
@@ -396,10 +400,10 @@ main(int argc, char *argv[])
fts_options |= FTS_NOSTAT;
/*
- * If not -F, -d or -l options, follow any symbolic links listed on
+ * If not -F, -P, -d or -l options, follow any symbolic links listed on
* the command line.
*/
- if (!f_longform && !f_listdir && (!f_type || f_slash))
+ if (!f_nofollow && !f_longform && !f_listdir && (!f_type || f_slash))
fts_options |= FTS_COMFOLLOW;
/*
OpenPOWER on IntegriCloud