aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ls.c
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-08-08 17:55:02 -0500
committerRob Landley <rob@landley.net>2015-08-08 17:55:02 -0500
commit3501e103b3b1f9d79f733976e338d59478d2e6f6 (patch)
tree2ec63f08e6bb6f463e32a8d7f4598d990c1af157 /toys/posix/ls.c
parent8a30303771fc2a9a95bf086713c51f9b7b85b3c1 (diff)
downloadtoybox-3501e103b3b1f9d79f733976e338d59478d2e6f6.tar.gz
Fix ls -l user/group field ordering.
It's user then group, not the other way round.
Diffstat (limited to 'toys/posix/ls.c')
-rw-r--r--toys/posix/ls.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index 44915fa7..f9511989 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);