irssi-import / bugs.irssi.org

bugs.irssi.org archive
https://github.com/irssi/irssi/issues
0 stars 0 forks source link

Empty lines in output of "exec" command cause "Not enough parameters given" errors #902

Open irssibot opened 10 years ago

irssibot commented 10 years ago

If a command is run by the exec function with output to the channel (i. e. /exec -o), empty lines in the process output will cause an error ("Not enough parameters given") because the "command msg" signal expects three parameters but only receives two.

In normal chat mode, an empty line is caught and ignored in the function "event_text":

irssi-0.8.16-rc1/src/fe-common/core/chat-completion.c (1065ff)
    if (*data == '\0') {
        /* empty line, forget it. */
                signal_stop();
        return;
    }

For exec, there's no test for the length of the string (function sig_exec_input). In some cases (no -o option used) empty lines are OK, but when the output is sent to the channel, it will fail.

It is not completely obvious to me what the correct behaviour should be. Possible options:

The latter would probably give the "expected" behaviour (at least visually).

Diff of proposed patch attached.

irssibot commented 10 years ago

irssi-0.8.16-rc1-exec.patch

--- irssi-0.8.16-rc1.orig/src/fe-common/core/fe-exec.c  2013-06-25 23:50:41.000000000 +0200
+++ irssi-0.8.16-rc1/src/fe-common/core/fe-exec.c   2013-09-19 23:38:52.000000000 +0200
@@ -615,7 +615,7 @@

        str = g_strconcat(rec->target_nick ? "-nick " :
                  rec->target_channel ? "-channel " : "",
-                 rec->target, " ", text, NULL);
+                 rec->target, " ", *text ? text : " ", NULL);
        signal_emit(rec->notice ? "command notice" : "command msg",
                3, str, server, item);
                 g_free(str);