Fix ls -l user/group field ordering.
authorElliott Hughes <enh@google.com>
Sat, 8 Aug 2015 22:55:02 +0000 (17:55 -0500)
committerRob Landley <rob@landley.net>
Sat, 8 Aug 2015 22:55:02 +0000 (17:55 -0500)
It's user then group, not the other way round.

toys/posix/ls.c

index 44915fa..f951198 100644 (file)
@@ -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);