aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ls.c
diff options
context:
space:
mode:
authorAndrew Ilijic <ilijic.andrew@gmail.com>2019-10-28 22:20:38 -0400
committerRob Landley <rob@landley.net>2019-10-28 23:36:36 -0500
commitab3e920602e447ad85e17923095b886e07dd586e (patch)
tree1c47e47ee1c6ab11d0fed6cd396e0ab534f30319 /toys/posix/ls.c
parentf95d580892e253655cd8298ad03d0fed65ca5026 (diff)
downloadtoybox-ab3e920602e447ad85e17923095b886e07dd586e.tar.gz
ls: Add `-w` which sets the column width
Diffstat (limited to 'toys/posix/ls.c')
-rw-r--r--toys/posix/ls.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index d4c0211a..809e2504 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -12,13 +12,13 @@
* Posix says the -l date format should vary based on how recent it is
* and we do --time-style=long-iso instead
-USE_LS(NEWTOY(ls, "(color):;(full-time)(show-control-chars)ZgoACFHLRSabcdfhikl@mnpqrstux1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][!qb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
+USE_LS(NEWTOY(ls, "(color):;(full-time)(show-control-chars)ZgoACFHLRSabcdfhikl@mnpqrstuw#=80<0x1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][!qb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
config LS
bool "ls"
default y
help
- usage: ls [-ACFHLRSZacdfhiklmnpqrstux1] [--color[=auto]] [directory...]
+ usage: ls [-ACFHLRSZacdfhiklmnpqrstuwx1] [--color[=auto]] [directory...]
List files.
@@ -37,7 +37,8 @@ config LS
-g like -l but no owner -h human readable sizes
-l long (show full details) -m comma separated
-n like -l but numeric uid/gid -o like -l but no group
- -x columns (horizontal sort) -ll long with nanoseconds (--full-time)
+ -w set column width -x columns (horizontal sort)
+ -ll long with nanoseconds (--full-time)
--color device=yellow symlink=turquoise/red dir=blue socket=purple
files: exe=green suid=red suidfile=redback stickydir=greenback
=auto means detect if output is a tty.
@@ -54,6 +55,7 @@ config LS
// ls -lR starts .: then ./subdir:
GLOBALS(
+ long w;
long l;
char *color;
@@ -564,7 +566,10 @@ void ls_main(void)
}
TT.screen_width = 80;
- terminal_size(&TT.screen_width, NULL);
+ if (FLAG(w)) {
+ // TODO (ilijic): Add test for setting w flag
+ TT.screen_width = TT.w;
+ } else { terminal_size(&TT.screen_width, NULL); }
if (TT.screen_width<2) TT.screen_width = 2;
if (FLAG(b)) TT.escmore = " \\";