[dev] I didn't know that you could use the shell like this: compound pipe?

2024-01-15 Thread Greg Reagle
I didn't know that you could use the shell like this.  What a delightful 
surprise.  Here is the code for bash/dash:

command | (read -r; printf "%s\n" "$REPLY"; sort)

The purpose of this is to keep the header and not sort it, but sort the rest.  
It is for a command that produces a header when you want to keep the header.  
From 
https://unix.stackexchange.com/questions/11856/sort-but-keep-header-line-at-the-top

Inspired by this, I came up with this for my favorite shell, rc (of Plan9Port):

ps aux | {printf '%s' `{read -n 1}; sort -k4 -n} | awk '$4>=0.5 || $0~"USER"' | 
less -S

This shows processes sorted by column 4 which is percent of memory.  The awk 
command excludes processes using less than one half of a percent of memory and 
includes the header line.  This is running on Debian fyi.  I think that the 
read command is from Plan9Port, and all the rest of the commands are the Debian 
standards, i.e. belonging to either Linux or GNU.  Here is a simpler version 
that shows all processes:

ps aux | {printf '%s' `{read -n 1}; sort -k4 -n} | less -S




Re: [dev] Presenting some more software

2024-01-15 Thread Страхиња Радић
On 24/01/15 09:58AM, Hiltjo Posthuma wrote:
> I would recommend doas and for Linux the fork opendoas.

Of course; there are several disadvantages to note about sup:

- it doesn't check credentials; it is like
permit nopass cmd1
permit nopass cmd2
permit nopass cmd3
  in doas; but having those in doas.conf is similar to using sup anyway

- the switch -l gives the list of supported commands "on a platter"

Still, I think that with a couple of tweaks it might be a replacement for doas?


signature.asc
Description: PGP signature


Re: [dev] Presenting some more software

2024-01-15 Thread Hiltjo Posthuma
On Mon, Jan 15, 2024 at 06:22:21AM +0100, Страхиња Радић wrote:
> On 24/01/13 09:19PM, stefan1 wrote:
> > https://github.com/stefan1/su
> > https://github.com/stefan1/rootdo
> > https://github.com/stefan1/rdoedit
> 
> I find sup[1] (~120-ish LoC) very useful, and in line with suckless 
> philosophy.
> 
> [1]: https://oldgit.suckless.org/sup/


I would recommend doas and for Linux the fork opendoas.

-- 
Kind regards,
Hiltjo