Hi Bash Maintainers,
I recently encountered an issue while experimenting with different shell
options in Bash. When launching Bash with both the `-n` (noexec) and `-o
ignoreeof` flags in interactive mode (with no pipes or redirection),
pressing `^D` (EOF) results in the message: "Use 'exit' to leave the
shell."
Since no commands can be executed in this state due to the `noexec`
option, this message might be misleading.
To address this, I've created a small patch that adjusts the error
message depending on whether Bash is in command execution mode or not.
This patch does not include translations of the new error message for
other supported languages, as I wanted to avoid potential inaccuracies
from machine translations.
Please find the patch attached. I am happy to make any further
adjustments based on your feedback.
Thank you for your time and consideration.
Best regards,
Milana
From 69e0980edaca197e64e1aba26f6a72251e4dd479 Mon Sep 17 00:00:00 2001
From: Milana <948...@gmail.com>
Date: Sun, 18 Aug 2024 01:47:19 +0200
Subject: [PATCH] fix the message displayed when trying to do ^D inside
interactive mode with both -n and -o ignoreeof flags
---
y.tab.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/y.tab.c b/y.tab.c
index 793686e7..6d800a18 100644
--- a/y.tab.c
+++ b/y.tab.c
@@ -8669,8 +8669,16 @@ handle_eof_input_unit ()
{
if (eof_encountered < eof_encountered_limit)
{
- fprintf (stderr, _("Use \"%s\" to leave the shell.\n"),
- login_shell ? "logout" : "exit");
+ if (executing)
+ {
+ fprintf (stderr, _("Use \"%s\" to leave the shell.\n"),
+ login_shell ? "logout" : "exit");
+ }
+ else
+ {
+ fprintf(stderr, "No executing, enter EOF %d more times in row to leave the shell.\n",
+ eof_encountered_limit - eof_encountered);
+ }
eof_encountered++;
/* Reset the parsing state. */
last_read_token = current_token = '\n';
--
2.46.0