change posix-mode implicit redirection from /dev/null for asynchronous commands so that 0<&0 does not count as an explicit redirection for austin-group interp 1913; fix spurious debug message about job notification for -c command; fix error handling for wait builtin if there are no children in a subshell

This commit is contained in:
Chet Ramey
2026-01-06 10:46:14 -05:00
parent a43e08df2d
commit e7c3acf108
12 changed files with 174 additions and 28 deletions
+10 -11
View File
@@ -847,7 +847,8 @@ execute_command_internal (COMMAND *command, int asynchronous, int pipe_in, int p
#endif /* COMMAND_TIMING */
/* Is this a compound command with a redirection from stdin? POSIX interp
1913 makes it matter. */
1913 makes it matter. There is an exception for 0<&0 or <&0 or equivalent
when in posix mode. */
if (shell_control_structure (command->type) && command->redirects)
{
stdin_redirected = stdin_redirects (command->redirects);
@@ -4876,13 +4877,11 @@ run_builtin:
{
if ((cmdflags & CMD_STDIN_REDIR) &&
pipe_in == NO_PIPE &&
#if 0 /*TAG:bash-5.4 POSIX interp 1913 */
/* POSIX interp 1913 says that the redirection of fd 0
from /dev/null is unconditional. */
(posixly_correct || stdin_redirects (simple_command->redirects) == 0))
#else
from /dev/null is performed unless the command has
a redirection that's something like 0<&0 or <&0.
See redir.c:stdin_redirection() for the details. */
(stdin_redirects (simple_command->redirects) == 0))
#endif
async_redirect_stdin ();
setup_async_signals ();
}
@@ -5917,15 +5916,15 @@ execute_disk_command (WORD_LIST *words, REDIRECT *redirects, char *command_line,
in asynchronous children. */
if (async)
{
/*itrace("execute_disk_command: async = 1 cmd_stdin_redir = %d stdin_redirects (redirects) = %d",
(cmdflags & CMD_STDIN_REDIR), stdin_redirects (redirects));*/
if ((cmdflags & CMD_STDIN_REDIR) &&
pipe_in == NO_PIPE &&
#if 0 /*TAG:bash-5.4 POSIX interp 1913 */
/* POSIX interp 1913 says that the redirection of fd 0
from /dev/null is unconditional. */
(posixly_correct || stdin_redirects (redirects) == 0))
#else
from /dev/null is performed unless the command has
a redirection that's something like 0<&0 or <&0.
See redir.c:stdin_redirection() for the details. */
(stdin_redirects (redirects) == 0))
#endif
async_redirect_stdin ();
setup_async_signals ();
}