[Toybox] [PATCH] Implement ps -O.
Rob Landley
rob at landley.net
Sun Jan 24 19:41:17 PST 2016
On 01/24/2016 08:19 PM, enh wrote:
> I should probably expand on the weird -O behavior... The desktop takes
> it to mean "insert this list of fields after pid and before a short
> fixed list of other fields" (so that's what this patch does for
> non-Android), but what I want is a way to move folks off the historical
> Android abuse of various single-letter flags to add sets of fields that
> there's no standard flag for. So -c can be replaced by -O psr, for example.
>
> One difference is that the desktop doesn't enforce the exclusive or of
> -O with other flags that would affect the list of fields --- it just
> ignores -O in case of conflict. But that seems clearly a bug, so I
> didn't copy it.
The toybox one will happily accept "ps -o pid,pid,pid,pid" if you really
want to. (Dunno _why_, I'm sure someone will eventually want to for some
strange reason...)
> On Jan 24, 2016 10:50 AM, "enh" <enh at google.com <mailto:enh at google.com>>
> wrote:
>
> Also hard-code -W for Android to match traditional behavior,
This change disables the tty width logic completely. Would setting the
default width when it can't probe terminal size to 99999 instead of 80
count work here instead?
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -966,7 +966,7 @@ static void shared_main(void)
TT.ticks = sysconf(_SC_CLK_TCK);
if (!TT.width) {
- TT.width = 80;
+ TT.width = 99999;
TT.height = 25;
terminal_size(&TT.width, &TT.height);
}
I'm hoping that in future Android grows a userbase plugging their phone
into a USB hub with hdmi adapter, mouse, and keyboard (or chromecasting
to their TV with bluetooth keyboard and mouse) that can actually pop up
a terminal window. I'd like android devices to grow into the workstation
space and organically displace PC hardware. Your suggested change works
against that goal, when you _do_ have a terminal size, it's good to use
it...
(I can also make sure it's specifically checking for a terminal on
stdout, so "ps | thing" also forces -w output. The downside is that
makes "ps | less" force -w too...)
Rob
1453693277.0
More information about the Toybox
mailing list