From: Karel Zak Date: Tue, 25 Jan 2022 15:18:31 +0000 (+0100) Subject: script: don't use \n when we log COMMAND X-Git-Tag: v2.38-rc1~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bfcdfccf8af0ac822e1f4d927138b9b8225930e6;p=thirdparty%2Futil-linux.git script: don't use \n when we log COMMAND The timing file format as well as typescript header do not expect line breaks. Replaces it white-space. Signed-off-by: Karel Zak --- diff --git a/term-utils/script.c b/term-utils/script.c index 6542314121..afd43eb515 100644 --- a/term-utils/script.c +++ b/term-utils/script.c @@ -132,6 +132,7 @@ struct script_control { const char *ttyname; const char *ttytype; const char *command; + char *command_norm; /* normalized (without \n) */ int ttycols; int ttylines; @@ -398,7 +399,7 @@ static int log_start(struct script_control *ctl, fprintf(log->fp, _("Script started on %s ["), buf); if (ctl->command) - x += fprintf(log->fp, "COMMAND=\"%s\"", ctl->command); + x += fprintf(log->fp, "COMMAND=\"%s\"", ctl->command_norm); if (ctl->isterm) { init_terminal_info(ctl); @@ -818,6 +819,8 @@ int main(int argc, char **argv) break; case 'c': ctl.command = optarg; + ctl.command_norm = xstrdup(ctl.command); + strrep(ctl.command_norm, '\n', ' '); break; case 'E': if (strcmp(optarg, "auto") == 0) @@ -1017,7 +1020,7 @@ int main(int argc, char **argv) } log_info(&ctl, "SHELL", "%s", shell); if (ctl.command) - log_info(&ctl, "COMMAND", "%s", ctl.command); + log_info(&ctl, "COMMAND", "%s", ctl.command_norm); log_info(&ctl, "TIMING_LOG", "%s", timingfile); if (outfile) log_info(&ctl, "OUTPUT_LOG", "%s", outfile);