From f0a451d667da59780a2376e9b0f395e7c06a70a3 Mon Sep 17 00:00:00 2001 From: ppatience0 Date: Tue, 29 Jan 2013 23:56:29 -0500 Subject: [PATCH 1/3] Fixed some ircrc bugs. Only the last channel given to the -t flag is set as target. Unknown commands are not sent to the server. Control-D can be used to exit the client. When the connection is lost, an error message is displayed and the client waits for user input before exiting. Manual page updated. --- rc/bin/ircrc | 32 +++++++++++++++++++++++-------- sys/man/1/ircrc | 51 ++++++++++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 30 deletions(-) diff --git a/rc/bin/ircrc b/rc/bin/ircrc index 9be2bc4e7..0a4a29196 100755 --- a/rc/bin/ircrc +++ b/rc/bin/ircrc @@ -38,9 +38,18 @@ fn work { title echo JOIN $target > $netdir/data } - while (cmd=`{read}) { - msg=() - out=() + if(~ $target *,*) + target = `{echo $target | awk -F',' '{print $NF}'} + while () { + cmd=`{read} + if(! ~ `{cat $netdir/status} *Established*) + exit + if(~ $#cmd 0) { + echo QUIT : Leaving... > $netdir/data + exit + } + msg=() + out=() switch ($cmd(1)) { case /! eval `{mshift $cmd} | while(rc=`{read})echo 'PRIVMSG '^$target^' :' $rc | tee $netdir/data @@ -61,6 +70,8 @@ fn work { target=$cmd(2) title msg = (JOIN `{mshift $cmd}) + if(~ $target *,*) + target = `{echo $target | awk -F',' '{print $NF}'} } case /l msg = (LIST `{mshift $cmd}) @@ -91,6 +102,8 @@ fn work { case /x echo QUIT : Leaving... > $netdir/data exit + case /* + echo unknown command case * msg = 'PRIVMSG '^$target^' :'^$"cmd out = '('^$target^') ⇐ '^$"cmd @@ -148,19 +161,22 @@ fn privmsg { s = s ":" $i; printf("%s\n", s); }' - } fn pretty { while (~ `{cat $netdir/status} *Established*) { - line=`{read} + if(! line=`{read}) { + echo Connection lost + date + exit + } switch ($line) { + case *PRIVMSG* + line = `{echo -n $line | privmsg} case *JOIN* *QUIT* *PART* *NICK* line = `{echo -n $line | misc} case *NOTICE* line = `{echo -n $line | notice} - case *PRIVMSG* - line = `{echo -n $line | privmsg} case *PING* echo -n $line | sed 's/PING/PONG/' > $netdir/data line = () @@ -235,6 +251,6 @@ if(~ $#userpass 2 && ~ $nick $user) { netdir=`{basename -d $clonefile} ^ / ^ `{cat /fd/4} echo connect $ip!$port >$netdir/ctl || exit 'cannot connect' echo connected to tcp!$ip!$port on $netdir - cat $netdir/data | tr -d ' ' | pretty & + cat $netdir/data | tr -d '\x2\xd\x1f' | pretty & work } diff --git a/sys/man/1/ircrc b/sys/man/1/ircrc index 828a8f0c1..fbcee5e95 100644 --- a/sys/man/1/ircrc +++ b/sys/man/1/ircrc @@ -25,15 +25,15 @@ ircrc \- internet relay chat client .SH DESCRIPTION .I Ircrc is an IRC client. -Messages are sent from stdin and received from stdout. +Messages are sent from standard input and +received from standard output. The default server is .BR irc.freenode.net . -.I Ircrc -expands +The arguments .B bitlbee and .B oftc -to +are expanded to .B im.bitlbee.org and .BR irc.oftc.net , @@ -49,15 +49,23 @@ Change the default name .RB ( ). .TP .BI -t " target -Set and join the target channel -(multiple channels may be separated by commas). +Set and join the target channel. +If multiple channels are specified, +only the last one will be set as +.IR target . +Messages are sent to +.I target +unless they are commands. .TP .BI -n " nick Change the default nickname .RB ( $user ). .SS Commands .I Ircrc -understands the following commands: +commands begin with a slash. +Unrecognized commands result in an error message +and send nothing to the server. +The commands are: .TP .BI /! " cmd Send the output of the shell command @@ -110,11 +118,11 @@ Send the raw IRC command to the server. .TP .BI /t " target -Set the current target. -Messages are sent to +Set +.IR target . +If .I target -unless they are commands. -If the current target is more than one channel, +is more than one channel, any messages are sent to all of them. .TP .B /u @@ -128,8 +136,8 @@ command. .B /x .B QUIT command. +Control-D also sends this command. .PP -Anything else is sent as a message to the current target. See RFC 1459 and RFC 2812 for detailed information about IRC commands. .SH EXAMPLES @@ -147,9 +155,7 @@ as a different user: % ircrc -r glenda -n glenda irc.oftc.net .EE .PP -Join two channels on login -(remember to set the target to a single channel, -otherwise messages are sent to both): +Join two channels on login: .IP .EX % ircrc -t '#cat-v,#plan9' @@ -162,12 +168,13 @@ otherwise messages are sent to both): .B http://tools.ietf.org/html/rfc2812 .SH BUGS .PP -.I Ircrc -calls the inexistent -.IR auth/userpasswd . -.PP -Some of -.BR irc.freenode.net 's -welcome messages contain control characters. +.I Auth/userpasswd +(which is called by +.IR ircrc ) +isn't compiled by default. .PP Some fonts do not support the nickname delimiters. +.PP +If the connection is lost, +.I ircrc +waits for input before exiting. From b8f88c803cdce340623d0dba3572704db045fa58 Mon Sep 17 00:00:00 2001 From: mveety Date: Tue, 29 Jan 2013 19:03:10 -0500 Subject: [PATCH 2/3] made the timesync failure more obvious on the rpi. --- rc/bin/termrc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/rc/bin/termrc b/rc/bin/termrc index 18a46fce8..046dde487 100755 --- a/rc/bin/termrc +++ b/rc/bin/termrc @@ -65,8 +65,14 @@ if(! test -e /net/dns) if(! ~ $terminal *vx32*){ # start timesync if it isn't running and we weren't told not to if(! ps|grep -s timesync) - if(! ~ $TIMESYNCARGS '') - aux/timesync $TIMESYNCARGS + if(! ~ $TIMESYNCARGS ''){ + # afaik the only arm platform we support is the rpi + # and time sync doesn't work on it. + if(! ~ $objtype arm) + aux/timesync $TIMESYNCARGS + if(~ $objtype arm) + echo 'timesync: use another source for time' + } } fn ask { From e322e84f5f2c046dffa3613aa54be574c3a80fdd Mon Sep 17 00:00:00 2001 From: mveety Date: Tue, 29 Jan 2013 21:48:57 -0500 Subject: [PATCH 3/3] reverted changes to termrc --- rc/bin/termrc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/rc/bin/termrc b/rc/bin/termrc index 046dde487..18a46fce8 100755 --- a/rc/bin/termrc +++ b/rc/bin/termrc @@ -65,14 +65,8 @@ if(! test -e /net/dns) if(! ~ $terminal *vx32*){ # start timesync if it isn't running and we weren't told not to if(! ps|grep -s timesync) - if(! ~ $TIMESYNCARGS ''){ - # afaik the only arm platform we support is the rpi - # and time sync doesn't work on it. - if(! ~ $objtype arm) - aux/timesync $TIMESYNCARGS - if(~ $objtype arm) - echo 'timesync: use another source for time' - } + if(! ~ $TIMESYNCARGS '') + aux/timesync $TIMESYNCARGS } fn ask {