sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

ii-1.4-exec.diff (1050B)


      1 diff -r d93eaacde742 ii.1
      2 --- a/ii.1	Fri Jun 25 10:55:05 2010 +0200
      3 +++ b/ii.1	Wed Jul 21 15:57:23 2010 -0700
      4 @@ -70,6 +70,9 @@
      5  .FN /a " [<message>]"
      6  mark yourself as away
      7  .TP
      8 +.FN /e " cmd"
      9 +execute cmd and write output to current channel
     10 +.TP
     11  .FN /j " #channel/nickname [<message>]"
     12  join a channel or open private conversation with user
     13  .TP
     14 diff -r d93eaacde742 ii.c
     15 --- a/ii.c	Fri Jun 25 10:55:05 2010 +0200
     16 +++ b/ii.c	Wed Jul 21 15:57:23 2010 -0700
     17 @@ -284,6 +284,26 @@
     18  			rm_channel(c);
     19  			return;
     20  			break;
     21 +		case 'e':
     22 +			if(strlen(buf)>=3) {
     23 +				char newbuf[PIPE_BUF];
     24 +				FILE *fp;
     25 +				int len;
     26 +
     27 +				if(!(fp = popen(&buf[3], "r"))) {
     28 +					fprintf(stderr, "error running %s\n", &buf[3]);
     29 +					return;
     30 +				}
     31 +				while (fgets(newbuf, sizeof(newbuf), fp)) {
     32 +					len = strlen(newbuf);
     33 +					if (newbuf[len - 1] == '\n')
     34 +						newbuf[len - 1] = '\0';
     35 +					proc_channels_privmsg(c->name, newbuf);
     36 +				}
     37 +				pclose(fp);
     38 +			}
     39 +			return;
     40 +			break;
     41  		default:
     42  			snprintf(message, PIPE_BUF, "%s\r\n", &buf[1]);
     43  			break;