summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-03-27 11:54:55 +0200
committerErich Eckner <git@eckner.net>2018-03-27 11:54:55 +0200
commit181654d44ff2db96eac470c9de4b1f6f6125660c (patch)
treece0a1696c20cf1ac3441327cf46a558a09d1ebe1 /bin
parenta9a3d766d05b6c7d24763e9276c5f7cc6ef1b981 (diff)
downloadbuilder-181654d44ff2db96eac470c9de4b1f6f6125660c.tar.xz
bin/ii-connect: use inotify-wait, interprete "wtf"
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ii-connect36
1 files changed, 36 insertions, 0 deletions
diff --git a/bin/ii-connect b/bin/ii-connect
index 5f8aacc..7ac589c 100755
--- a/bin/ii-connect
+++ b/bin/ii-connect
@@ -37,7 +37,18 @@ fi
# watch if asked to
if [ "$1" = 'watch' ]; then
+ done_something=false
while pgrep -x 'ii' > /dev/null; do
+ # this avoids missing modifications during our last execution
+ if ! ${done_something}; then
+ # shellcheck disable=SC2046
+ inotifywait -e 'CLOSE_WRITE,CLOSE' $(
+ find "${irc_dir}" \
+ -type f \
+ -name 'out'
+ )
+ fi
+ done_something=false
find "${irc_dir}" \
-type f \
-name 'out' \
@@ -52,6 +63,7 @@ if [ "$1" = 'watch' ]; then
fi
regex='^\(\S\+ \)\?\S\+ <\S\+> '"${prefix}"'why[- ]don'"'"'\?t[- ]you \(build\|stabilize\|unstage\|keep\|stubbornly_keep\) '
if grep -q "${regex}" "${out_file}"; then
+ done_something=true
sed -n '
s/'"${regex}"'/\2 /
T
@@ -73,6 +85,30 @@ if [ "$1" = 'watch' ]; then
done
sed -i "/${regex}/d" "${out_file}"
fi
+ regex='^\(\S\+ \)\?\S\+ <\S\+> '"${prefix}"'wtf '
+ if grep -q "${regex}" "${out_file}"; then
+ done_something=true
+ sed -n '
+ s/'"${regex}"'//
+ T
+ p
+ ' "${out_file}" | \
+ while read -r line; do
+ reason=$(
+ echo "${line}" | \
+ xargs "${base_dir}/bin/wtf" 2>&1
+ )
+ if [ "$(echo "${reason}" | wc -l)" -le 5 ]; then
+ echo "${reason}"
+ else
+ echo "${reason}" | \
+ head -n5
+ printf '... (%s lines total)\n' "$(echo "${reason}" | wc -l)"
+ fi | \
+ sponge "${out_file%/out}/in"
+ done
+ sed -i "/${regex}/d" "${out_file}"
+ fi
done
sleep 1
done