[Toybox] [PATCH] Fix ls -l user/group field ordering

enh enh at google.com
Fri Aug 7 14:04:49 PDT 2015


Fix ls -l user/group field ordering.

It's user then group, not the other way round.

diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 44915fa..f951198 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -422,6 +422,13 @@ static void listfiles(int dirfd, struct dirtree *indir)
       mode_to_string(mode, perm);
       printf("%s% *ld", perm, totals[2]+1, (long)st->st_nlink);

+      // print user
+      if (!(flags&FLAG_g)) {
+        if (flags&FLAG_n) sprintf(ss = thyme, "%u", (unsigned)st->st_uid);
+        else strwidth(ss = getusername(st->st_uid));
+        printf(" %*s", (int)totals[3], ss);
+      }
+
       // print group
       if (!(flags&FLAG_o)) {
         if (flags&FLAG_n) sprintf(ss = thyme, "%u", (unsigned)st->st_gid);
@@ -429,12 +436,6 @@ static void listfiles(int dirfd, struct dirtree *indir)
         printf(" %*s", (int)totals[4], ss);
       }

-      if (!(flags&FLAG_g)) {
-        if (flags&FLAG_n) sprintf(ss = thyme, "%u", (unsigned)st->st_uid);
-        else strwidth(ss = getusername(st->st_uid));
-        printf(" %*s", (int)totals[3], ss);
-      }
-
       if (flags & FLAG_Z)
         printf(" %*s", -(int)totals[7], (char *)sort[next]->extra);


-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

 1438981489.0


More information about the Toybox mailing list