This broke a netd test (but sadly in postsubmit rather than presubmit).

Also add a trivial test that would at least have caught this bug.

Bug: http://b/140453237
---
 tests/ls.test   | 1 +
 toys/posix/ls.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
From ed13f4c7a2158614fc19919d08b23110784b4bdd Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Wed, 4 Sep 2019 10:51:17 -0700
Subject: [PATCH] ls: fix -Z, add a test.

This broke a netd test (but sadly in postsubmit rather than presubmit).

Also add a trivial test that would at least have caught this bug.

Bug: http://b/140453237
---
 tests/ls.test   | 1 +
 toys/posix/ls.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/ls.test b/tests/ls.test
index 6c8e0efe..cba0a3de 100755
--- a/tests/ls.test
+++ b/tests/ls.test
@@ -31,6 +31,7 @@ testing "with -k" "$IN && ls -k; $OUT" "dir1\ndir2\nfile1.txt\nfile2.txt\n" "" "
 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" "" "" ""
 
 ln -s file1.txt lstest/slink
 testing "-l symlink" \
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 4ae352af..340971e5 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -467,7 +467,7 @@ static void listfiles(int dirfd, struct dirtree *indir)
       }
     }
     if (flags & FLAG_Z)
-      printf(" %-*s", -(int)totals[7], (char *)sort[next]->extra);
+      printf("%-*s ", -(int)totals[7], (char *)sort[next]->extra);
 
     if (flags & (FLAG_l|FLAG_o|FLAG_n|FLAG_g)) {
       struct tm *tm;
-- 
2.23.0.187.g17f5b7556c-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to