Apply a patch from Matt Kraai:
authorEric Andersen <andersen@codepoet.org>
Mon, 9 Oct 2000 17:51:25 +0000 (17:51 -0000)
committerEric Andersen <andersen@codepoet.org>
Mon, 9 Oct 2000 17:51:25 +0000 (17:51 -0000)
    "The -L option to ls doesn't behave correctly for files listed explicitly
    on the command line, only those in directories that are listed.  The
    appended patch fixes this problem.  Would someone please commit it?"
 -Erik

coreutils/ls.c
ls.c

index 385d6b2de39737f3b6f239597f780fe5beb40b5f..8d975fd13590f1b356cada7f6ff64820cbb18514 100644 (file)
@@ -790,7 +790,17 @@ extern int ls_main(int argc, char **argv)
        for (oi=0 ; oi < ac; oi++) {
                cur= (struct dnode *)xmalloc(sizeof(struct dnode));
                cur->fullname= xstrdup(av[oi]);
-               cur->name= cur->fullname ;
+               cur->name= cur->fullname;
+#ifdef BB_FEATURE_LS_FOLLOWLINKS
+               if (follow_links == TRUE) {
+                       if (stat(av[oi], &cur->dstat)) {
+                               errorMsg("%s: %s\n", av[oi], strerror(errno));
+                               free(cur->fullname);
+                               free(cur);
+                               continue;
+                       }
+               } else
+#endif
                if (lstat(av[oi], &cur->dstat)) {  /* get file info into node */
                        errorMsg("%s: %s\n", av[oi], strerror(errno));
                        free(cur->fullname);
diff --git a/ls.c b/ls.c
index 385d6b2de39737f3b6f239597f780fe5beb40b5f..8d975fd13590f1b356cada7f6ff64820cbb18514 100644 (file)
--- a/ls.c
+++ b/ls.c
@@ -790,7 +790,17 @@ extern int ls_main(int argc, char **argv)
        for (oi=0 ; oi < ac; oi++) {
                cur= (struct dnode *)xmalloc(sizeof(struct dnode));
                cur->fullname= xstrdup(av[oi]);
-               cur->name= cur->fullname ;
+               cur->name= cur->fullname;
+#ifdef BB_FEATURE_LS_FOLLOWLINKS
+               if (follow_links == TRUE) {
+                       if (stat(av[oi], &cur->dstat)) {
+                               errorMsg("%s: %s\n", av[oi], strerror(errno));
+                               free(cur->fullname);
+                               free(cur);
+                               continue;
+                       }
+               } else
+#endif
                if (lstat(av[oi], &cur->dstat)) {  /* get file info into node */
                        errorMsg("%s: %s\n", av[oi], strerror(errno));
                        free(cur->fullname);