const char *ttyname;
const char *ttytype;
+ const char *command;
int ttycols;
int ttylines;
switch (log->format) {
case SCRIPT_FMT_RAW:
{
+ int x = 0;
char buf[FORMAT_TIMESTAMP_MAX];
time_t tvec = script_time((time_t *)NULL);
strtime_iso(&tvec, ISO_TIMESTAMP, buf, sizeof(buf));
fprintf(log->fp, _("Script started on %s ["), buf);
+ if (ctl->command)
+ x += fprintf(log->fp, "COMMAND=\"%s\"", ctl->command);
+
if (ctl->isterm) {
init_terminal_info(ctl);
if (ctl->ttytype)
- fprintf(log->fp, "TERM=\"%s\" ", ctl->ttytype);
+ x += fprintf(log->fp, "%*sTERM=\"%s\"", !!x, "", ctl->ttytype);
if (ctl->ttyname)
- fprintf(log->fp, "TTY=\"%s\" ", ctl->ttyname);
+ x += fprintf(log->fp, "%*sTTY=\"%s\"", !!x, "", ctl->ttyname);
- fprintf(log->fp, "COLUMNS=\"%d\" LINES=\"%d\"", ctl->ttycols, ctl->ttylines);
+ fprintf(log->fp, "%*sCOLUMNS=\"%d\" LINES=\"%d\"", !!x, "",
+ ctl->ttycols, ctl->ttylines);
} else
fprintf(log->fp, _("<not executed on terminal>"));
struct ul_pty_callbacks *cb;
int ch, format = 0, caught_signal = 0, rc = 0, echo = 1;
const char *outfile = NULL, *infile = NULL;
- const char *timingfile = NULL, *shell = NULL, *command = NULL;
+ const char *timingfile = NULL, *shell = NULL;
enum { FORCE_OPTION = CHAR_MAX + 1 };
ctl.append = 1;
break;
case 'c':
- command = optarg;
+ ctl.command = optarg;
break;
case 'E':
if (strcmp(optarg, "auto") == 0)
shname = shname ? shname + 1 : shell;
if (access(shell, X_OK) == 0) {
- if (command)
- execl(shell, shname, "-c", command, (char *)NULL);
+ if (ctl.command)
+ execl(shell, shname, "-c", ctl.command, (char *)NULL);
else
execl(shell, shname, "-i", (char *)NULL);
} else {
- if (command)
- execlp(shname, "-c", command, (char *)NULL);
+ if (ctl.command)
+ execlp(shname, "-c", ctl.command, (char *)NULL);
else
execlp(shname, "-i", (char *)NULL);
}
log_info(&ctl, "LINES", "%d", ctl.ttylines);
}
log_info(&ctl, "SHELL", "%s", shell);
- if (command)
- log_info(&ctl, "COMMAND", "%s", command);
+ if (ctl.command)
+ log_info(&ctl, "COMMAND", "%s", ctl.command);
log_info(&ctl, "TIMING_LOG", "%s", timingfile);
if (outfile)
log_info(&ctl, "OUTPUT_LOG", "%s", outfile);