summaryrefslogtreecommitdiff
path: root/bin/ii-answer
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-06-15 13:15:46 +0200
committerErich Eckner <git@eckner.net>2018-06-15 13:15:46 +0200
commitf0baa933d31d3c80b168752ede43b6d305a005f5 (patch)
treecce1da80774f33058d9548ebfa008a44b92341be /bin/ii-answer
parent331e7dca60916e65188060ad2a612c8341b69453 (diff)
downloadbuilder-f0baa933d31d3c80b168752ede43b6d305a005f5.tar.xz
bin/ii-answer: remove found regexes atomically if possible
Diffstat (limited to 'bin/ii-answer')
-rwxr-xr-xbin/ii-answer20
1 files changed, 9 insertions, 11 deletions
diff --git a/bin/ii-answer b/bin/ii-answer
index ec234f1..5a7bc53 100755
--- a/bin/ii-answer
+++ b/bin/ii-answer
@@ -10,17 +10,15 @@
# welcome devs (in #archlinux32 only)
welcome_user_regex='^\S\+ -!- \(abaumann\|deep42thought\|tyzoid\|phrik\)(.* has joined \S\+$'
new_users=$(
- sed -n '
+ sed -i '
s/'"${welcome_user_regex}"'/\1/
T
- p
+ w /dev/stdout
+ d
' "${irc_dir}/#archlinux32/out" | \
sort -u
)
if [ -n "${new_users}" ]; then
- sed -i '
- /'"${welcome_user_regex}"'/ d
- ' "${irc_dir}/#archlinux32/out"
printf '%s\n' "${new_users}" | \
sed '
s/^/Hi /
@@ -46,10 +44,11 @@ find "${irc_dir}" \
# answer "why don't you?"
regex='^\(\S\+ \)\?\S\+ <\S\+> '"${prefix}"'why[- ]don'"'"'\?t[- ]you \(build\|stabilize\|unstage\|keep\|stubbornly_keep\) '
if grep -q "${regex}" "${out_file}"; then
- sed -n '
+ sed -i '
s/'"${regex}"'/\2 /
T
- p
+ w /dev/stdout
+ d
' "${out_file}" | \
while read -r line; do
reason=$(
@@ -65,15 +64,15 @@ find "${irc_dir}" \
fi | \
irc_say "${channel}" 'copy'
done
- sed -i "/${regex}/d" "${out_file}"
fi
# answer "wtf?"
regex='^\(\S\+ \)\?\S\+ <\S\+> '"${prefix}"'wtf '
if grep -q "${regex}" "${out_file}"; then
- sed -n '
+ sed -i '
s/'"${regex}"'//
T
- p
+ w /dev/stdout
+ d
' "${out_file}" | \
while read -r line; do
reason=$("${base_dir}/bin/wtf" "${line}");
@@ -89,7 +88,6 @@ find "${irc_dir}" \
fi | \
irc_say "${channel}" 'copy'
done
- sed -i "/${regex}/d" "${out_file}"
fi
# answer "What's up?"
regex='^\(\S\+ \)\?\S\+ <\S\+> .*[Ww]hat'"'"'\?s *[Uu]p'