[BACK]Return to cmd-run-shell.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-run-shell.c between version 1.13 and 1.14

version 1.13, 2012/07/11 07:10:15 version 1.14, 2012/11/27 15:09:35
Line 30 
Line 30 
  */   */
   
 enum cmd_retval  cmd_run_shell_exec(struct cmd *, struct cmd_ctx *);  enum cmd_retval  cmd_run_shell_exec(struct cmd *, struct cmd_ctx *);
 void             cmd_run_shell_callback(struct job *);  
 void             cmd_run_shell_free(void *);  
   
   void    cmd_run_shell_callback(struct job *);
   void    cmd_run_shell_free(void *);
   void    cmd_run_shell_print(struct job *, const char *);
   
 const struct cmd_entry cmd_run_shell_entry = {  const struct cmd_entry cmd_run_shell_entry = {
         "run-shell", "run",          "run-shell", "run",
         "", 1, 1,          "t:", 1, 1,
         "command",          CMD_TARGET_PANE_USAGE " command",
         0,          0,
         NULL,          NULL,
         NULL,          NULL,
Line 46 
Line 48 
 struct cmd_run_shell_data {  struct cmd_run_shell_data {
         char            *cmd;          char            *cmd;
         struct cmd_ctx   ctx;          struct cmd_ctx   ctx;
           u_int            wp_id;
 };  };
   
   void
   cmd_run_shell_print(struct job *job, const char *msg)
   {
           struct cmd_run_shell_data       *cdata = job->data;
           struct cmd_ctx                  *ctx = &cdata->ctx;
           struct window_pane              *wp;
   
           wp = window_pane_find_by_id(cdata->wp_id);
           if (wp == NULL) {
                   ctx->print(ctx, "%s", msg);
                   return;
           }
   
           if (window_pane_set_mode(wp, &window_copy_mode) == 0)
                   window_copy_init_for_output(wp);
           if (wp->mode == &window_copy_mode)
                   window_copy_add(wp, "%s", msg);
   }
   
 enum cmd_retval  enum cmd_retval
 cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)  cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
 {  {
         struct args                     *args = self->args;          struct args                     *args = self->args;
         struct cmd_run_shell_data       *cdata;          struct cmd_run_shell_data       *cdata;
         const char                      *shellcmd = args->argv[0];          const char                      *shellcmd = args->argv[0];
           struct window_pane              *wp;
   
           if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
                   return (CMD_RETURN_ERROR);
   
         cdata = xmalloc(sizeof *cdata);          cdata = xmalloc(sizeof *cdata);
         cdata->cmd = xstrdup(args->argv[0]);          cdata->cmd = xstrdup(args->argv[0]);
           cdata->wp_id = wp->id;
         memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);          memcpy(&cdata->ctx, ctx, sizeof cdata->ctx);
   
         if (ctx->cmdclient != NULL)          if (ctx->cmdclient != NULL)
Line 87 
Line 114 
         lines = 0;          lines = 0;
         do {          do {
                 if ((line = evbuffer_readline(job->event->input)) != NULL) {                  if ((line = evbuffer_readline(job->event->input)) != NULL) {
                         ctx->print(ctx, "%s", line);                          cmd_run_shell_print (job, line);
                         lines++;                          lines++;
                 }                  }
         } while (line != NULL);          } while (line != NULL);
Line 98 
Line 125 
                 memcpy(line, EVBUFFER_DATA(job->event->input), size);                  memcpy(line, EVBUFFER_DATA(job->event->input), size);
                 line[size] = '\0';                  line[size] = '\0';
   
                 ctx->print(ctx, "%s", line);                  cmd_run_shell_print(job, line);
                 lines++;                  lines++;
   
                 free(line);                  free(line);
Line 115 
Line 142 
                 xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);                  xasprintf(&msg, "'%s' terminated by signal %d", cmd, retcode);
         }          }
         if (msg != NULL) {          if (msg != NULL) {
                 if (lines != 0)                  if (lines == 0)
                         ctx->print(ctx, "%s", msg);  
                 else  
                         ctx->info(ctx, "%s", msg);                          ctx->info(ctx, "%s", msg);
                   else
                           cmd_run_shell_print(job, msg);
                 free(msg);                  free(msg);
         }          }
 }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14