From 3501e103b3b1f9d79f733976e338d59478d2e6f6 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Sat, 8 Aug 2015 17:55:02 -0500 Subject: [PATCH] Fix ls -l user/group field ordering. It's user then group, not the other way round. --- toys/posix/ls.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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); -- 2.7.4