[PATCH] consistent BASH_COMMAND, DEBUG trap, xtrace order

2023-08-25 Thread Grisha Levit
There is some inconsistency betweeen various command types in the order of (1) setting the value used for BASH_COMMAND (2) running the DEBUG trap and checking its return value and (3) printing the PS4 string. While simple, arithmetic, and conditional commands follow the order above, `for', `select

give_terminal_to() / maybe_give_terminal_to() race

2023-08-25 Thread Earl Chew
A newly created process of a foreground job races the parent shell to configure the controlling terminal. This can result in the parent shell stealing the controlling terminal from a grandchild, and giving it to the child. I think stop_pipeline() needs to be fixed to be more cautious. What might

[PATCH] Use SIGCONT to avoid fg tcsetpgrp() SIGTTIN/SIGTTOU race

2023-08-25 Thread Earl Chew
A running background job can be stopped by SIGTTOU or SIGTTIN, just as the fg command issues tcsetprgp() to give the job the controlling terminal. This causes the fg command to appear to have caused the job to stop. Prevent this from happening by always issuing SIGCONT after the fg command calls t

Re: using exec to close a fd in a var crashes bash

2023-08-25 Thread Chet Ramey
On 8/23/23 9:50 AM, Zachary Santer wrote: In the Bash man page: varredir_close If set, the shell automatically closes file descriptors assigned using the {varname} redirection syntax (see REDIRECTION above) instead of leaving them open when the command completes. I feel like the man p

Re: heap-buffer-overflow in finfo.c

2023-08-25 Thread Chet Ramey
On 8/24/23 1:23 PM, Grisha Levit wrote: $ enable finfo $ finfo -P '' . ERROR: AddressSanitizer: heap-buffer-overflow ... READ of size 1 at 0x003b09b8d4d1 thread T0 #0 0x6e45535088 in octal examples/loadables/finfo.c:104:9 Thanks for the reports. -- ``The lyf so short, the craft so long to