From 7cff05c7ac4efe30a34f7f1bc5d5aa7463cb4f16 Mon Sep 17 00:00:00 2001 From: orcus <29999282+orcus-de@users.noreply.github.com> Date: Mon, 24 Jan 2022 18:38:21 +0100 Subject: [PATCH] Add -q/-- flags to /execwrite to EXECWRITE and cmd_execW (#2675) added two flags to EXECWRITE and cmd_execw -q : (quiet) to allow suppressing of additional (debug) output at the text box -- : (stop parsing for further flags) for the edge cases where -q itself migh be part of used data and the user wants to show that at the text box Closes #2666 --- src/common/outbound.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/common/outbound.c b/src/common/outbound.c index da57ea33..6f0241be 100644 --- a/src/common/outbound.c +++ b/src/common/outbound.c @@ -1579,9 +1579,26 @@ cmd_execw (struct session *sess, char *tbuf, char *word[], char *word_eol[]) EMIT_SIGNAL (XP_TE_NOCHILD, sess, NULL, NULL, NULL, NULL, 0); return FALSE; } - len = strlen(word_eol[2]); - temp = g_strconcat (word_eol[2], "\n", NULL); - PrintText(sess, temp); + if (strcmp (word[2], "--") == 0) + { + len = strlen(word_eol[3]); + temp = g_strconcat (word_eol[3], "\n", NULL); + PrintText(sess, temp); + } + else + { + if (strcmp (word[2], "-q") == 0) + { + len = strlen(word_eol[3]); + temp = g_strconcat (word_eol[3], "\n", NULL); + } + else + { + len = strlen(word_eol[2]); + temp = g_strconcat (word_eol[2], "\n", NULL); + PrintText(sess, temp); + } + } write(sess->running_exec->myfd, temp, len + 1); g_free(temp); @@ -3977,7 +3994,7 @@ const struct commands xc_cmds[] = { N_("EXECKILL [-9], kills a running exec in the current session. If -9 is given the process is SIGKILL'ed")}, #ifndef __EMX__ {"EXECSTOP", cmd_execs, 0, 0, 1, N_("EXECSTOP, sends the process SIGSTOP")}, - {"EXECWRITE", cmd_execw, 0, 0, 1, N_("EXECWRITE, sends data to the processes stdin")}, + {"EXECWRITE", cmd_execw, 0, 0, 1, N_("EXECWRITE [-q|--], sends data to the processes stdin; use -q flag to quiet/suppress output at text box; use -- flag to stop interpreting arguments as flags, needed if -q itself would occur as data")}, #endif #endif #if 0