From 88c4d57d6c4d71675f0061918db62ac595bcc2f5 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 2 Aug 2018 18:35:21 +0000 Subject: [PATCH] Log command arguments. --- usr.bin/tmux/cmd.c | 15 ++++++++++++++- usr.bin/tmux/tmux.h | 3 ++- usr.bin/tmux/window.c | 5 ++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/usr.bin/tmux/cmd.c b/usr.bin/tmux/cmd.c index ac69f21db24..b152e81840e 100644 --- a/usr.bin/tmux/cmd.c +++ b/usr.bin/tmux/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.139 2017/05/30 21:44:59 nicm Exp $ */ +/* $OpenBSD: cmd.c,v 1.140 2018/08/02 18:35:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -201,6 +201,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) { @@ -209,6 +218,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++) { @@ -241,9 +251,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); } @@ -402,6 +414,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/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 145125576c0..0ca227a317c 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.835 2018/08/02 11:56:12 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.836 2018/08/02 18:35:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1760,6 +1760,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/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index 4df0bddd172..d931af5819a 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.210 2018/05/24 09:42:49 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.211 2018/08/02 18:35:21 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -920,8 +920,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); -- 2.20.1