Skip to content

headerless ps options result in spurious output #7

@treyharris

Description

@treyharris

I forked and was about to write a fix to send you a pull request, but then in reading the code I noticed the -n option, which up till now I'd missed. Still, this seems to qualify as a bug, so I thought I'd mention it.

On MacOS If you give options such that the ps header is suppressed completely, you get the PID 1 line from psgrep as the first line of output:

% psgrep -o 'pid=,ppid=,comm=' mosh
    1     0 /sbin/launchd
60243     1 mosh-server
83177  1277 /usr/local/Cellar/mobile-shell/1.2.6/bin/mosh-client my-mbp |
55353  5322 /usr/local/Cellar/mobile-shell/1.2.6/bin/mosh-client trey-mbp-my.local |

clearly it's just interpreting the top line as the header, because giving -n suppresses that:

% psgrep -n -o 'pid=,ppid=,comm=' mosh
60243     1 mosh-server
83177  1277 /usr/local/Cellar/mobile-shell/1.2.6/bin/mosh-client my-mbp |
55353  5322 /usr/local/Cellar/mobile-shell/1.2.6/bin/mosh-client trey-mbp-my.local |

Since the only reason I can see to care about this is when you're trying to suppress the output, and there's an easier way in -n, this is pretty low-priority, but again I thought I'd let you know.

(I don't think this bug can arise on Linux because the only way to create a headerless ps output using options requires passing -o multiple times, which psgrep doesn't support. I haven't tried any other operating systems.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions