On 2023/05/31 3:13, Hsin-Yi Wang wrote: > When stdin is not a TTY, prompt ("crash> ") won't be displayed. If > another process interact with crash with piped stdin/stdout, it will not > get the prompt as a delimiter. > > Compared to other debugger like gdb, crash seems intended to give a > prompt in this case in the beginning of process_command_line(). It > checks if pc->flags does NOT have any of > READLINE|SILENT|CMDLINE_IFILE|RCHOME_IFILE|RCLOCAL_IFILE, a > prompt should be printed. The check will never be true since READLINE is > set in setup_environment() unconditionally. It makes more sense to > change the READLINE flag in the check to TTY instead. > > Additionally, when stdin is not TTY, repeat the command line from user > after prompt, which can give more context. > > The prompt and command line can be opt out by using the silent (-s) flag. > > Signed-off-by: Hsin-Yi Wang <hsinyi@xxxxxxxxxxxx> Thanks, but I found a case that prints two prompts, after a fatal error: # cat ~/.crashrc sys config <<-- any command that fails with error(FATAL) sys # echo quit | crash ... 2 crash> sys config sys: kernel_config_data does not exist in this kernel 1 crash> 2 crash> sys KERNEL: /usr/lib/debug/lib/modules/4.18.0-305.el8.x86_64/vmlinux ... where the crash has this: --- a/cmdline.c +++ b/cmdline.c @@ -66,7 +66,7 @@ process_command_line(void) if (!(pc->flags & (TTY|SILENT|CMDLINE_IFILE|RCHOME_IFILE|RCLOCAL_IFILE))) - fprintf(fp, "%s", pc->prompt); + fprintf(fp, "1 %s", pc->prompt); fflush(fp); /* @@ -1487,7 +1487,7 @@ exec_input_file(void) continue; if (!(pc->flags & SILENT)) { - fprintf(fp, "%s%s", pc->prompt, buf); + fprintf(fp, "2 %s%s", pc->prompt, buf); fflush(fp); } Can we avoid this? Thanks, Kazu > --- > v1: > - The original discussion: https://listman.redhat.com/archives/crash-utility/2023-May/010710.html > - Kazu: provide the idea to print the command line as well. > --- > cmdline.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/cmdline.c b/cmdline.c > index ded6551..9821d86 100644 > --- a/cmdline.c > +++ b/cmdline.c > @@ -65,7 +65,7 @@ process_command_line(void) > BZERO(pc->command_line, BUFSIZE); > > if (!(pc->flags & > - (READLINE|SILENT|CMDLINE_IFILE|RCHOME_IFILE|RCLOCAL_IFILE))) > + (TTY|SILENT|CMDLINE_IFILE|RCHOME_IFILE|RCLOCAL_IFILE))) > fprintf(fp, "%s", pc->prompt); > fflush(fp); > > @@ -139,6 +139,10 @@ process_command_line(void) > } else { > if (fgets(pc->command_line, BUFSIZE-1, stdin) == NULL) > clean_exit(1); > + if (!(pc->flags & SILENT)) { > + fprintf(fp, "%s", pc->command_line); > + fflush(fp); > + } > clean_line(pc->command_line); > strcpy(pc->orig_line, pc->command_line); > } -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility Contribution Guidelines: https://github.com/crash-utility/crash/wiki