[Toybox] [PATCH] ls: Fix -t to also sort by st_mtim.tv_nsec.

Peter Collingbourne pcc at google.com
Tue Jan 8 15:22:50 PST 2019


---
 toys/posix/ls.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 91d35f4f..c24d5bcc 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -169,6 +169,8 @@ static int compare(void *a, void *b)
   if (toys.optflags & FLAG_t) {
     if (dta->st.st_mtime > dtb->st.st_mtime) ret = -1;
     else if (dta->st.st_mtime < dtb->st.st_mtime) ret = 1;
+    else if (dta->st.st_mtim.tv_nsec > dtb->st.st_mtim.tv_nsec) ret = -1;
+    else if (dta->st.st_mtim.tv_nsec < dtb->st.st_mtim.tv_nsec) ret = 1;
   }
   if (!ret) ret = strcmp(dta->name, dtb->name);
   return ret * reverse;
-- 
2.20.1.97.g81188d93c3-goog




More information about the Toybox mailing list