From f0baa933d31d3c80b168752ede43b6d305a005f5 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 15 Jun 2018 13:15:46 +0200 Subject: bin/ii-answer: remove found regexes atomically if possible --- bin/ii-answer | 20 +++++++++----------- 1 file 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' -- cgit v1.2.3