aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-10-09 15:35:56 -0500
committerRob Landley <rob@landley.net>2016-10-09 15:35:56 -0500
commit48c75324f758e77ca3ba64072a48a7407e765570 (patch)
tree4b4140f79501a59c2a23c1543b61677a399f8a03 /toys/posix
parent75ebbd1571c85a06c0f4767beb7c20a19068f0b6 (diff)
downloadtoybox-48c75324f758e77ca3ba64072a48a7407e765570.tar.gz
Izabera pointed out that ls defaults to -q when output is a tty.
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/ls.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/toys/posix/ls.c b/toys/posix/ls.c
index ab1251a8..d2cef263 100644
--- a/toys/posix/ls.c
+++ b/toys/posix/ls.c
@@ -5,7 +5,7 @@
*
* See http://opengroup.org/onlinepubs/9699919799/utilities/ls.html
-USE_LS(NEWTOY(ls, USE_LS_COLOR("(color):;")"ZgoACFHLRSabcdfhiklmnpqrstux1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][!qb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
+USE_LS(NEWTOY(ls, USE_LS_COLOR("(color):;")"(show-control-chars)ZgoACFHLRSabcdfhiklmnpqrstux1[-Cxm1][-Cxml][-Cxmo][-Cxmg][-cu][-ftS][-HL][!qb]", TOYFLAG_BIN|TOYFLAG_LOCALE))
config LS
bool "ls"
@@ -534,12 +534,15 @@ void ls_main(void)
if (toys.optflags&FLAG_b) TT.escmore = " \\";
// Do we have an implied -1
- if (!isatty(1)) {
+ if (isatty(1)) {
+ if (!(toys.optflags&FLAG_show_control_chars)) toys.optflags |= FLAG_q;
+ if (toys.optflags&(FLAG_l|FLAG_o|FLAG_n|FLAG_g)) toys.optflags |= FLAG_1;
+ else if (!(toys.optflags&(FLAG_1|FLAG_x|FLAG_m))) toys.optflags |= FLAG_C;
+ } else {
if (!(toys.optflags & FLAG_m)) toys.optflags |= FLAG_1;
if (TT.color) toys.optflags ^= FLAG_color;
- } else if (toys.optflags&(FLAG_l|FLAG_o|FLAG_n|FLAG_g))
- toys.optflags |= FLAG_1;
- else if (!(toys.optflags&(FLAG_1|FLAG_x|FLAG_m))) toys.optflags |= FLAG_C;
+ }
+
// The optflags parsing infrastructure should really do this for us,
// but currently it has "switch off when this is set", so "-dR" and "-Rd"
// behave differently