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> --- 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); } -- 2.41.0.rc0.172.g3f132b7071-goog -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility Contribution Guidelines: https://github.com/crash-utility/crash/wiki