Two more spacing bugs here, one before the security context for -Z, and
one after the size with --full-time.

Before:

  $ ./toybox ls -lZ --full-time Config.
  -rw-r----- 1 enh primarygroup?    56162019-09-07 21:09:32.892215100
-0700 Config.in

After:

  $ ./toybox ls -lZ --full-time Config.
  -rw-r----- 1 enh primarygroup ?  5616 2019-09-07 21:09:32.892215100
-0700 Config.in
---
 tests/ls.test   | 1 +
 toys/posix/ls.c | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)
From 0c1f667b665ebcb7c879676fc41b7921791e8ac9 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Sat, 7 Sep 2019 21:36:28 -0700
Subject: [PATCH] ls: fix spacing of -lZ and --full-time.

Two more spacing bugs here, one before the security context for -Z, and
one after the size with --full-time.

Before:

  $ ./toybox ls -lZ --full-time Config.
  -rw-r----- 1 enh primarygroup?    56162019-09-07 21:09:32.892215100 -0700 Config.in

After:

  $ ./toybox ls -lZ --full-time Config.
  -rw-r----- 1 enh primarygroup ?  5616 2019-09-07 21:09:32.892215100 -0700 Config.in
---
 tests/ls.test   | 1 +
 toys/posix/ls.c | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tests/ls.test b/tests/ls.test
index cba0a3de..91f69183 100755
--- a/tests/ls.test
+++ b/tests/ls.test
@@ -32,6 +32,7 @@ testing "with -m" "$IN && ls -m; $OUT" "dir1, dir2, file1.txt, file2.txt\n" "" "
 testing "with -F" "$IN && ls -F; $OUT" "dir1/\ndir2/\nfile1.txt\nfile2.txt\n" "" ""
 testing "with -dk *" "$IN && ls -dk *; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" ""
 testing "with -Z" "$IN && ls -Z file1.txt | egrep -q '^[^ ]+ file1.txt' || echo fail; $OUT" "" "" ""
+testing "with -lZ" "$IN && ls --full-time -lZ file1.txt | egrep -q '^-[rwx-]+ +[0-9]+ +[^ ]+ +[^ ]+ +[^ ]+ +[0-9]+ [0-9][0-9][0-9][0-9]-[0-9][0-9]-.* file1.txt' || echo fail; $OUT" "" "" ""
 
 ln -s file1.txt lstest/slink
 testing "-l symlink" \
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 25b77ad7..1640ea70 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -466,8 +466,8 @@ static void listfiles(int dirfd, struct dirtree *indir)
                            crunch_qb);
       }
     }
-    if (flags & FLAG_Z)
-      printf("%-*s ", -(int)totals[7], (char *)sort[next]->extra);
+    if (FLAG(Z))
+      printf(" %-*s "+!FLAG(l), -(int)totals[7], (char *)sort[next]->extra);
 
     if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g)) {
       struct tm *tm;
@@ -483,7 +483,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
 
       // print time, always in --time-style=long-iso
       tm = localtime(&(st->st_mtime));
-      strftime(tmp, sizeof(tmp), "%F %H:%M", tm);
+      strftime(tmp, sizeof(tmp), " %F %H:%M", tm);
       if (TT.l>1) {
         char *s = tmp+strlen(tmp);
 
-- 
2.23.0.187.g17f5b7556c-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to