OSDN Git Service

Command line files without paths were attempting to use stdin as their dirfd,
authorRob Landley <rob@landley.net>
Fri, 15 Jan 2016 22:59:06 +0000 (16:59 -0600)
committerRob Landley <rob@landley.net>
Fri, 15 Jan 2016 22:59:06 +0000 (16:59 -0600)
(because ls uses nonstandard directory recursion which collates all the
command line arguments under a fake top node, which needs more thorough
initialization).

toys/posix/ls.c

index 2f44d24..08ae695 100644 (file)
@@ -541,6 +541,7 @@ void ls_main(void)
   // Iterate through command line arguments, collecting directories and files.
   // Non-absolute paths are relative to current directory.
   TT.files = dirtree_start(0, 0);
+  TT.files->dirfd = AT_FDCWD;
   for (s = *toys.optargs ? toys.optargs : noargs; *s; s++) {
     dt = dirtree_start(*s, !(toys.optflags&(FLAG_l|FLAG_d|FLAG_F)) ||
                             (toys.optflags&(FLAG_L|FLAG_H)));