]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(gobble_file): Don't stat symlinks unless we need to.
authorJim Meyering <jim@meyering.net>
Wed, 24 Mar 1993 06:23:26 +0000 (06:23 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 24 Mar 1993 06:23:26 +0000 (06:23 +0000)
From Mike Rendell <michael@mercury.cs.mun.ca>.

src/ls.c

index 202e16c6f41680887f23635f5be43a85477adf1c..f4ae904b7f8a0c14bf10d6763bf282a7f0b2068e 100644 (file)
--- 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