diff options
| author | tv <tv@nomic.retiolum> | 2014-03-14 14:14:40 +0100 | 
|---|---|---|
| committer | tv <tv@nomic.retiolum> | 2014-03-14 14:14:40 +0100 | 
| commit | 617c75df73f02cc951e63f87926a42d11cb3079a (patch) | |
| tree | f0e9ce0bd7b94700adad4543f0726a2e3b52a36a /git/gitolite-hooks/irc-announce | |
| parent | 890e81bea3b7ada20871913053a86fa0672a44e4 (diff) | |
irc-announce: properly wait for MODE message^_^
Diffstat (limited to 'git/gitolite-hooks/irc-announce')
| -rwxr-xr-x | git/gitolite-hooks/irc-announce | 20 | 
1 files changed, 16 insertions, 4 deletions
diff --git a/git/gitolite-hooks/irc-announce b/git/gitolite-hooks/irc-announce index 1e7ecc2b..9c98b330 100755 --- a/git/gitolite-hooks/irc-announce +++ b/git/gitolite-hooks/irc-announce @@ -57,6 +57,19 @@ cat2() { tee /dev/stderr; }  # privmsg_cat transforms stdin to a privmsg  privmsg_cat() { awk '{ print "PRIVMSG "ENVIRON["IRC_CHANNEL"]" :"$0 }'; } +# ircin is used to feed the output of netcat back to the "irc client" +# so we can implement expect-like behavior with sed^_^ +# XXX mkselfdestructingtmpfifo would be nice instead of this cruft +tmpdir="$(mktemp -d irc-announce_XXXXXXXX)" +cd "$tmpdir" +mkfifo ircin +trap " +  rm ircin +  cd '$OLDPWD' +  rmdir '$tmpdir' +  trap - EXIT INT QUIT +" EXIT INT QUIT +  #  #  # @@ -65,8 +78,7 @@ privmsg_cat() { awk '{ print "PRIVMSG "ENVIRON["IRC_CHANNEL"]" :"$0 }'; }    echo2 "NICK $IRC_NICK"    # wait for MODE message -  # CAVEAT 10 second was enough while testing...^_^ -  sleep 10 +  sed -n '/^:[^ ]* MODE /q'    echo2 "JOIN $IRC_CHANNEL" @@ -102,5 +114,5 @@ privmsg_cat() { awk '{ print "PRIVMSG "ENVIRON["IRC_CHANNEL"]" :"$0 }'; }    printf     sleep 1    exit -} \ -  | nc "$IRC_SERVER" "$IRC_PORT" +} < ircin \ +  | nc "$IRC_SERVER" "$IRC_PORT" | tee -a ircin  | 
