Hi, Feng
Thank you for the patch.
For this one: Ack.
Lianbo
On 1/28/26 9:42 AM, devel-request(a)lists.crash-utility.osci.io wrote:
> Date: Thu, 4 Dec 2025 14:34:37 +0800
> From: neilfsun<loyou85(a)gmail.com>
> Subject: [Crash-utility] [PATCH] Fix prompt output interfering with
> piped commands in input files
> To:devel@lists.crash-utility.osci.io
> Cc: neilfsun<neilfsun(a)tencent.com>, Feng Sun<loyou85(a)gmail.com>
> Message-ID:<20251204063437.4008-1-neilfsun@tencent.com>
>
> When executing piped commands from input files, the prompt text was
> incorrectly written to the pipe instead of stdout.
> This caused commands read the prompt as their first line,
> consuming it instead of the actual command output.
>
> crash> p cpu_info:0 | head -1
> per_cpu(cpu_info, 0) = $29 = {
> crash> p cpu_info:0 | head -2
> per_cpu(cpu_info, 0) = $4 = {
> x86 = 0x6,
> crash> cat crashrc1
> p cpu_info:0 | head -1
> crash> < crashrc1
> crash> p cpu_info:0 | head -1
>
> crash> cat crashrc2
> p cpu_info:0 | head -2
> crash> < crashrc2
> crash> p cpu_info:0 | head -2
> per_cpu(cpu_info, 0) = $30 = {
> crash>
>
> Fix: Output prompt to incoming_fp (stdout) instead of fp (which may be the pipe
> after setup_redirect()), ensuring prompts display on terminal while command output
> goes to the pipe as intended.
>
> Signed-off-by: neilfsun<neilfsun(a)tencent.com>
> Signed-off-by: Feng Sun<loyou85(a)gmail.com>
> ---
> cmdline.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/cmdline.c b/cmdline.c
> index 4add548..030ae56 100644
> --- a/cmdline.c
> +++ b/cmdline.c
> @@ -1488,8 +1488,8 @@ exec_input_file(void)
> continue;
>
> if (!(pc->flags & SILENT)) {
> - fprintf(fp, "%s%s", pc->prompt, buf);
> - fflush(fp);
> + fprintf(incoming_fp, "%s%s", pc->prompt,
buf);
> + fflush(incoming_fp);
> }
>
> exec_command();
> -- 2.50.1
--
Crash-utility mailing list -- devel(a)lists.crash-utility.osci.io
To unsubscribe send an email to devel-leave(a)lists.crash-utility.osci.io
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines:
https://github.com/crash-utility/crash/wiki