=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-run-shell.c,v retrieving revision 1.4 retrieving revision 1.5 diff -c -r1.4 -r1.5 *** src/usr.bin/tmux/cmd-run-shell.c 2009/11/01 23:20:37 1.4 --- src/usr.bin/tmux/cmd-run-shell.c 2009/11/04 21:04:43 1.5 *************** *** 1,4 **** ! /* $OpenBSD: cmd-run-shell.c,v 1.4 2009/11/01 23:20:37 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha --- 1,4 ---- ! /* $OpenBSD: cmd-run-shell.c,v 1.5 2009/11/04 21:04:43 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha *************** *** 77,107 **** { struct cmd_run_shell_data *cdata = job->data; struct cmd_ctx *ctx = &cdata->ctx; ! char *cmd, *msg, *line, *buf; ! size_t off, len, llen; int retcode; ! buf = BUFFER_OUT(job->out); ! len = BUFFER_USED(job->out); ! cmd = cdata->cmd; ! if (len != 0) { ! line = buf; ! for (off = 0; off < len; off++) { ! if (buf[off] == '\n') { ! llen = buf + off - line; ! if (llen > INT_MAX) ! break; ! ctx->print(ctx, "%.*s", (int) llen, line); ! line = buf + off + 1; ! } ! } ! llen = buf + len - line; ! if (llen > 0 && llen < INT_MAX) ! ctx->print(ctx, "%.*s", (int) llen, line); } msg = NULL; if (WIFEXITED(job->status)) { if ((retcode = WEXITSTATUS(job->status)) != 0) --- 77,109 ---- { struct cmd_run_shell_data *cdata = job->data; struct cmd_ctx *ctx = &cdata->ctx; ! char *cmd, *msg, *line; ! size_t size; int retcode; + u_int lines; ! lines = 0; ! do { ! if ((line = evbuffer_readline(job->event->input)) != NULL) { ! ctx->print(ctx, "%s", line); ! lines++; ! } ! } while (line != NULL); ! size = EVBUFFER_LENGTH(job->event->input); ! if (size != 0) { ! line = xmalloc(size + 1); ! memcpy(line, EVBUFFER_DATA(job->event->input), size); ! line[size] = '\0'; ! ctx->print(ctx, "%s", line); ! lines++; ! ! xfree(line); } + cmd = cdata->cmd; + msg = NULL; if (WIFEXITED(job->status)) { if ((retcode = WEXITSTATUS(job->status)) != 0) *************** *** 111,117 **** xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode); } if (msg != NULL) { ! if (len != 0) ctx->print(ctx, "%s", msg); else ctx->info(ctx, "%s", msg); --- 113,119 ---- xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode); } if (msg != NULL) { ! if (lines != 0) ctx->print(ctx, "%s", msg); else ctx->info(ctx, "%s", msg);