[PATCH] Correct error message when using -n and -o ignoreeof in interactive mode

2024-08-17 Thread Milana

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



wrong word tokenization in case of arithmetic expressions

2024-09-23 Thread Milana

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt 
-fexceptions -Wp,-D_FORTIFY_SOURCE=3 -Wformat 
-Werror=format-security -fstack-clash-protection -fcf-protection 
-fno-om
it-frame-pointer -mno-omit-leaf-frame-pointer -flto=auto 
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin' 
-DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc' 
-DSYS_BASH_LOGOUT='/etc/b

ash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
uname output: Linux milana-laptop 6.1.103-1-MANJARO #1 SMP 
PREEMPT_DYNAMIC Sat Aug  3 10:06:55 UTC 2024 x86_64 GNU/Linux

Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2
Patch Level: 26
Release Status: release

Description:
   simple arithmetic expressions tokenized incorrectly when 
referred by history expansion


Repeat-By:
   try to enter a simple command with one of arguments is an 
arithmetic expression, for instance `echo $((1+2))`. Then enter anything 
with history substitution of !!:1 (or the word designator of the arithm
etic expression). Insted of printing $((1+2)) as expected it prints 
$((1+2) as the word 1, and ) as the word 2