Closed marcthe12 closed 4 years ago
One alternative is what?
$(basename $(tty))
Ah, you've either typoed "tty" as "try", or had something auto-incorrect it for you.
I encourage you to look at the POSIX definition of the ps
utility: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html
Now check how many of those options are supported by busybox ps
. You'll be tremendously disappointed.
Yep definitely disappointed. Still sx is not busybox compatible.
Things like this are the reason I'm generally hesitant to make busybox my /bin/sh implementation. It works for some things, and doesn't work for other things, and there's no real way to opt out of using the internal applet for commands which you'd prefer the system version of.
Still, the ps applet looks particularly lacking, so I guess it might make sense to disable it from the busybox config until the various FIXMEs in https://git.busybox.net/busybox/tree/procps/ps.c are implemented. This should be no great loss on a desktop system where every byte doesn't count.
(Since I am the archlinux maintainer of the busybox package, I can look into disabling it there.)
Funnily enough I had originally used tty
. The main concern I had with it was specifically because it returned the full path. Now one could just use basename
(${...##*/}
) but that assumes /dev
is the parent directory.
E.g. compare the two outputs:
% ps -o tty= -p $$
pts/10
% basename "$(tty)"
10
It may be a nonsense to worry about the mountpoints in such a way but I do want to make as few as possible assumptions on principle alone.
Nevertheless it's a fair point about ps
not accepting PIDs as positional and I should use -p
for that. (See release 2.1.2)
I'm not going to change sx
for the sake of busybox (or any non-POSIX software) unless you know of a method to produce an equivalent output without making more assumptions (or making fewer assumptions which would be even better).
If there are no other suggestions I'll close this as fixed.
Edit: Alrighty, closed as fixed in https://github.com/Earnestly/sx/commit/521d3c92d05b98ba596e73ecbd7347cd107276e5
Thanks for the report.
See #11 for the argument in favor of using tty
, which is now in the latest release.
The posix ps command does not take PID as a argument. This fails in busybox for example. One alternative is try command which POSIX. To get the try, we need to basename it