summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-03-24 06:23:26 +0000
committerJim Meyering <jim@meyering.net>1993-03-24 06:23:26 +0000
commit89ed6c2fec63c608f356403a406dd1bde5a33937 (patch)
tree80ae462aaf7fc4b8328f2d0a7434155e81be81a7 /src/ls.c
parent82bdb546d9a76094f1c40413fa2bd56cbbd93eaa (diff)
downloadcoreutils-89ed6c2fec63c608f356403a406dd1bde5a33937.tar.xz
(gobble_file): Don't stat symlinks unless we need to.
From Mike Rendell <michael@mercury.cs.mun.ca>.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ls.c b/src/ls.c
index 202e16c6f..f4ae904b7 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -942,7 +942,12 @@ gobble_file (name, explicit_arg, dirname)
get_link_name (path, &files[files_index]);
linkpath = make_link_path (path, files[files_index].linkname);
- if (linkpath && stat (linkpath, &linkstats) == 0)
+ /* Avoid following symbolic links when possible, ie, when
+ they won't be traced and when no indicator is needed. */
+ if (linkpath
+ && ((explicit_arg && format != long_format)
+ || indicator_style != none)
+ && stat (linkpath, &linkstats) == 0)
{
/* Symbolic links to directories that are mentioned on the
command line are automatically traced if not being