aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-01-15 16:59:06 -0600
committerRob Landley <rob@landley.net>2016-01-15 16:59:06 -0600
commit7d6f210aa38afe2a9a370f1e0f23edf72a1735bb (patch)
tree2a7b3cbf7f8fee1cd70c1e4cb391b20d91047ff8
parentdeb31c82944c1fa98ea2942691c53c9d841c1a66 (diff)
downloadtoybox-7d6f210aa38afe2a9a370f1e0f23edf72a1735bb.tar.gz
Command line files without paths were attempting to use stdin as their dirfd,
(because ls uses nonstandard directory recursion which collates all the command line arguments under a fake top node, which needs more thorough initialization).
-rw-r--r--toys/posix/ls.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 2f44d247..08ae695d 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -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)));