* [9front] [PATCH] Kill, kill, slay: banish sed, long live awk!
@ 2023-07-02 1:44 Amavect
2023-07-02 7:43 ` sirjofri
0 siblings, 1 reply; 9+ messages in thread
From: Amavect @ 2023-07-02 1:44 UTC (permalink / raw)
To: 9front
[-- Attachment #1: Type: text/plain, Size: 162 bytes --]
I'd like to claim 9front's best commit message for the most mundane patch.
Fixes regexp being parsed in kill. A bit more readable.
See attached.
Thanks,
Amavect
[-- Attachment #2.1: Type: text/plain, Size: 379 bytes --]
from postmaster@9front:
The following attachment had content that we can't
prove to be harmless. To avoid possible automatic
execution, we changed the content headers.
The original header was:
Content-Type: text/x-patch; charset="US-ASCII"; name="kill.patch"
Content-Disposition: attachment; filename="kill.patch"
Content-Transfer-Encoding: base64
Content-ID: <f_ljkrol6l0>
[-- Attachment #2.2: kill.patch.suspect --]
[-- Type: application/octet-stream, Size: 1148 bytes --]
From: Amavect <amavect@gmail.com>
Date: Sun, 02 Jul 2023 01:36:23 +0000
Subject: [PATCH] Kill, kill, slay: banish sed, long live awk!
Regexp shall parse no more.
---
diff 47d3af71a33e242099a6a6130dcbe7ab4de9a895 f00e4a39c5d1ae11f2aefbfe23e70eae2d67e426
--- a/rc/bin/Kill
+++ b/rc/bin/Kill
@@ -1,5 +1,5 @@
#!/bin/rc
rfork e
for(i){
- ps | sed -n '/ '^$i^'$/s%^[^ ]* *([^ ]*).*%chmod 666 /proc/\1/ctl;@{echo kill>/proc/\1/ctl}%p'
+ ps | awk -v 'prog='$i '$7 == prog {print "chmod 666 /proc/" $2 "/ctl;@{echo kill>/proc/" $2 "/ctl} # " $7}'
}
--- a/rc/bin/kill
+++ b/rc/bin/kill
@@ -1,7 +1,5 @@
#!/bin/rc
rfork e
for(i){
- ps | sed -n '/^'$user' .* '$i'$/s%[^ ]* *%~>/proc/%
- s% *.* (.*)%/note} # \1%
- s%~%@{echo kill%p'
+ ps | awk -v 'user='$user -v 'prog='$i '$1 == user && $7 == prog {print "@{echo kill>/proc/" $2 "/note} # " $7}'
}
--- a/rc/bin/slay
+++ b/rc/bin/slay
@@ -1,7 +1,5 @@
#!/bin/rc
rfork e
for(i){
- ps | sed -n '/^'$user' .* '$i'$/s%[^ ]* *%~>/proc/%
- s% *.* (.*)%/ctl} # \1%
- s%~%@{echo kill%p'
+ ps | awk -v 'user='$user -v 'prog='$i '$1 == user && $7 == prog {print "@{echo kill>/proc/" $2 "/ctl} # " $7}'
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9front] [PATCH] Kill, kill, slay: banish sed, long live awk!
2023-07-02 1:44 [9front] [PATCH] Kill, kill, slay: banish sed, long live awk! Amavect
@ 2023-07-02 7:43 ` sirjofri
2023-07-02 16:17 ` Amavect
0 siblings, 1 reply; 9+ messages in thread
From: sirjofri @ 2023-07-02 7:43 UTC (permalink / raw)
To: 9front
Hello,
out of curiosity, why s/sed/awk? What's wrong about sed?
sirjofri
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9front] [PATCH] Kill, kill, slay: banish sed, long live awk!
2023-07-02 7:43 ` sirjofri
@ 2023-07-02 16:17 ` Amavect
2023-07-02 18:32 ` Stuart Morrow
0 siblings, 1 reply; 9+ messages in thread
From: Amavect @ 2023-07-02 16:17 UTC (permalink / raw)
To: 9front
On Sun, Jul 2, 2023 at 2:46 AM sirjofri <sirjofri+ml-9front@sirjofri.de> wrote:
>
> Hello,
>
> out of curiosity, why s/sed/awk? What's wrong about sed?
>
> sirjofri
The command line arguments are passed to sed through a sed expression,
so the program name is parsed as a sed expression and not as a string.
This affects program names with a dot (6.out).
In practice, this almost never results in name conflicts,
so the real reason is that I find the sed version hard to read.
For fun, I rewrote the sed version, which makes the command generation obvious:
ps | sed -n '/^'$user' .* '$i'$/s%[^ ]* *([0-9]+) .* (.*)$%@{echo
kill>/proc/\1/note} # \2%p'
Compare to the original:
ps | sed -n '/^'$user' .* '$i'$/s%[^ ]* *%~>/proc/%s% *.*
(.*)%/note} # \1%s%~%@{echo kill%p'
Compare to awk:
ps | awk -v 'user='$user -v 'prog='$i '$1 == user && $7 == prog {print
"@{echo kill>/proc/" $2 "/note} # " $7}'
Thanks,
Amavect
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9front] [PATCH] Kill, kill, slay: banish sed, long live awk!
2023-07-02 16:17 ` Amavect
@ 2023-07-02 18:32 ` Stuart Morrow
2023-07-02 21:01 ` Steve Simon
0 siblings, 1 reply; 9+ messages in thread
From: Stuart Morrow @ 2023-07-02 18:32 UTC (permalink / raw)
To: 9front
Can awk even build on (actual)386? (no floating point)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9front] [PATCH] Kill, kill, slay: banish sed, long live awk!
2023-07-02 18:32 ` Stuart Morrow
@ 2023-07-02 21:01 ` Steve Simon
2023-07-03 22:46 ` Stuart Morrow
2023-08-01 5:36 ` mkf9
0 siblings, 2 replies; 9+ messages in thread
From: Steve Simon @ 2023-07-02 21:01 UTC (permalink / raw)
To: 9front
i think you are correct.
i have a distant memory that awk was one of the few bits of plan9 that did not work on a 386 without a 387.
-Steve
> On 2 Jul 2023, at 8:39 pm, Stuart Morrow <morrow.stuart@gmail.com> wrote:
>
> Can awk even build on (actual)386? (no floating point)
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9front] [PATCH] Kill, kill, slay: banish sed, long live awk!
2023-07-02 21:01 ` Steve Simon
@ 2023-07-03 22:46 ` Stuart Morrow
2023-08-01 5:36 ` mkf9
1 sibling, 0 replies; 9+ messages in thread
From: Stuart Morrow @ 2023-07-03 22:46 UTC (permalink / raw)
To: 9front
9front has awk in bootfs so being cautious of awk in utilities is pretty moot.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9front] [PATCH] Kill, kill, slay: banish sed, long live awk!
2023-07-02 21:01 ` Steve Simon
2023-07-03 22:46 ` Stuart Morrow
@ 2023-08-01 5:36 ` mkf9
2023-08-01 22:10 ` [9front] Kill, kill, slay: banish sed, long live awk: Now historic plan9 Steve Simon
1 sibling, 1 reply; 9+ messages in thread
From: mkf9 @ 2023-08-01 5:36 UTC (permalink / raw)
To: 9front
Steve Simon wrote:
> i have a distant memory that awk was one of the few bits of plan9 that did not work on a 386 without a 387.
did it ever built/booted in literal 386?
wow.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9front] Kill, kill, slay: banish sed, long live awk: Now historic plan9
2023-08-01 5:36 ` mkf9
@ 2023-08-01 22:10 ` Steve Simon
2023-08-02 4:56 ` Roberto E. Vargas Caballero
0 siblings, 1 reply; 9+ messages in thread
From: Steve Simon @ 2023-08-01 22:10 UTC (permalink / raw)
To: 9front
i certainly ran plan9 on 386s in the beginning, i cannot be sure if you could rebuild the system on a 386 but i think so.
the 386 linker used its own allocator (maybe still does) which is fast but greedy, i remember tweaking it to used malloc so i could link a kernel on a small RAM system, though i have forgotten how small.
the biggest pain in those days was finding a supported VGA card.
-Steve
> On 1 Aug 2023, at 6:38 am, mkf9 <mkf9@riseup.net> wrote:
>
> Steve Simon wrote:
>> i have a distant memory that awk was one of the few bits of plan9 that did not work on a 386 without a 387.
>
> did it ever built/booted in literal 386?
> wow.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9front] Kill, kill, slay: banish sed, long live awk: Now historic plan9
2023-08-01 22:10 ` [9front] Kill, kill, slay: banish sed, long live awk: Now historic plan9 Steve Simon
@ 2023-08-02 4:56 ` Roberto E. Vargas Caballero
0 siblings, 0 replies; 9+ messages in thread
From: Roberto E. Vargas Caballero @ 2023-08-02 4:56 UTC (permalink / raw)
To: 9front
Hi,
On Tue, Aug 01, 2023 at 11:10:18PM +0100, Steve Simon wrote:
>
> i certainly ran plan9 on 386s in the beginning, i cannot be sure if you could rebuild the system on a 386 but i think so.
I run 9front in a soekris that is a 386. I rebuilt the system a few times and I can
ensure that it works.
Regards,
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2023-08-02 4:57 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-02 1:44 [9front] [PATCH] Kill, kill, slay: banish sed, long live awk! Amavect
2023-07-02 7:43 ` sirjofri
2023-07-02 16:17 ` Amavect
2023-07-02 18:32 ` Stuart Morrow
2023-07-02 21:01 ` Steve Simon
2023-07-03 22:46 ` Stuart Morrow
2023-08-01 5:36 ` mkf9
2023-08-01 22:10 ` [9front] Kill, kill, slay: banish sed, long live awk: Now historic plan9 Steve Simon
2023-08-02 4:56 ` Roberto E. Vargas Caballero
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).