diff --git a/cmd.c b/cmd.c index 45f83c2c..e432ae4a 100644 --- a/cmd.c +++ b/cmd.c @@ -200,6 +200,15 @@ const struct cmd_entry *cmd_table[] = { NULL }; +void +cmd_log_argv(int argc, char **argv, const char *prefix) +{ + int i; + + for (i = 0; i < argc; i++) + log_debug("%s: argv[%d]=%s", prefix, i, argv[i]); +} + int cmd_pack_argv(int argc, char **argv, char *buf, size_t len) { @@ -208,6 +217,7 @@ cmd_pack_argv(int argc, char **argv, char *buf, size_t len) if (argc == 0) return (0); + cmd_log_argv(argc, argv, __func__); *buf = '\0'; for (i = 0; i < argc; i++) { @@ -240,9 +250,11 @@ cmd_unpack_argv(char *buf, size_t len, int argc, char ***argv) arglen = strlen(buf) + 1; (*argv)[i] = xstrdup(buf); + buf += arglen; len -= arglen; } + cmd_log_argv(argc, *argv, __func__); return (0); } @@ -401,6 +413,7 @@ retry: xasprintf(cause, "unknown command: %s", name); return (NULL); } + cmd_log_argv(argc, argv, entry->name); args = args_parse(entry->args.template, argc, argv); if (args == NULL) diff --git a/tmux.h b/tmux.h index 7e46bfeb..aad11ffe 100644 --- a/tmux.h +++ b/tmux.h @@ -1764,6 +1764,7 @@ int cmd_find_from_mouse(struct cmd_find_state *, int cmd_find_from_nothing(struct cmd_find_state *, int); /* cmd.c */ +void cmd_log_argv(int, char **, const char *); int cmd_pack_argv(int, char **, char *, size_t); int cmd_unpack_argv(char *, size_t, int, char ***); char **cmd_copy_argv(int, char **); diff --git a/window.c b/window.c index 8a509c28..16c973b2 100644 --- a/window.c +++ b/window.c @@ -924,8 +924,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv, log_debug("%s: shell=%s", __func__, wp->shell); log_debug("%s: cmd=%s", __func__, cmd); log_debug("%s: cwd=%s", __func__, cwd); - for (i = 0; i < wp->argc; i++) - log_debug("%s: argv[%d]=%s", __func__, i, wp->argv[i]); + cmd_log_argv(wp->argc, wp->argv, __func__); environ_log(env, "%s: environment ", __func__); memset(&ws, 0, sizeof ws);