diff --git a/sic.1 b/sic.1 index aba8db8..bf72026 100644 --- a/sic.1 +++ b/sic.1 @@ -12,6 +12,7 @@ sic \- simple irc client .RB [ \-k .IR pass ] .RB [ \-v ] +.RB [ commands... ] .SH DESCRIPTION .B sic is an extremely fast, small and simple irc client. It reads commands from @@ -19,6 +20,8 @@ standard input and prints all server output to standard output. It also multiplexes all channel traffic into one output. That way you don't have to switch different channel buffers. So that's actually a feature. .SH OPTIONS +Any non-option arguments will be treated as though they were statements entered +at the command prompt and executed before yielding control to the user. .TP .BI \-h " host" Overrides the default host (irc.oftc.net) diff --git a/sic.c b/sic.c index 7a3edee..18d44af 100644 --- a/sic.c +++ b/sic.c @@ -135,16 +135,28 @@ parsesrv(char *cmd) { int main(int argc, char *argv[]) { - int i, c; + int i, c, j; + char **commands; struct timeval tv; const char *user = getenv("USER"); fd_set rd; + if(!(commands = malloc((sizeof (char *)) * argc))) { + fputs("malloc failed\n", stderr); + return 1; + } else { + j = 0; + } + strlcpy(nick, user ? user : "unknown", sizeof nick); for(i = 1; i < argc; i++) { c = argv[i][1]; - if(argv[i][0] != '-' || argv[i][2]) + if(argv[i][0] != '-') { + commands[j++] = argv[i]; + continue; + } else if(argv[i][2]) { c = -1; + } switch(c) { case 'h': if(++i < argc) host = argv[i]; @@ -161,7 +173,7 @@ main(int argc, char *argv[]) { case 'v': eprint("sic-"VERSION", ?? 2005-2012 Kris Maglione, Anselm R. Garbe, Nico Golde\n"); default: - eprint("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v]\n"); + eprint("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v] [command...]\n"); } } /* init */ @@ -175,6 +187,12 @@ main(int argc, char *argv[]) { fflush(srv); setbuf(stdout, NULL); setbuf(srv, NULL); + + for(c = 0; c < j; c++) { + parsein(commands[c]); + } + free(commands); + for(;;) { /* main loop */ FD_ZERO(&rd); FD_SET(0, &rd);