9front - general discussion about 9front
 help / color / mirror / Atom feed
* [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

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).