From: Amavect <amavect@gmail.com>
To: 9front@9front.org
Subject: [9front] [PATCH] Kill, kill, slay: banish sed, long live awk!
Date: Sat, 1 Jul 2023 20:44:43 -0500 [thread overview]
Message-ID: <CAGOW0YNNCwdZGCvf8dCNTFZw-bi8Q4S=Zjs6O+oLMfho31XFRg@mail.gmail.com> (raw)
[-- 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}'
}
next reply other threads:[~2023-07-02 7:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-02 1:44 Amavect [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGOW0YNNCwdZGCvf8dCNTFZw-bi8Q4S=Zjs6O+oLMfho31XFRg@mail.gmail.com' \
--to=amavect@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).