mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-28 16:09:51 +02:00
fix for printing ambiguous redirection >& with declare -f
This commit is contained in:
@@ -3670,3 +3670,14 @@ lib/sh/shmatch.c
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- BASH_REMATCH: add caveat about making it a local variable
|
||||
|
||||
6/6
|
||||
---
|
||||
print_cmd.c
|
||||
- print_redirection: if the redirectee for r_duplicating_output_word
|
||||
(r_duplicating_input_word) is 1 (0), don't print it; only print a
|
||||
non-default file descriptor number
|
||||
- print_redirection_list: remove the code that tries to temporarily
|
||||
translate a >&word redirection to >&word now that we won't print a
|
||||
non-default file descriptor number. Fixes issue with `declare -f' and
|
||||
function export reported by Namikaze Minato <lloydsensei@gmail.com>
|
||||
|
||||
@@ -100,6 +100,7 @@ sh_regmatch (string, pattern, flags)
|
||||
unbind_global_variable_noref ("BASH_REMATCH");
|
||||
rematch = make_new_array_variable ("BASH_REMATCH");
|
||||
#else
|
||||
/* TAG:bash-5.3 */
|
||||
rematch = builtin_find_indexed_array ("BASH_REMATCH", 1);
|
||||
#endif
|
||||
amatch = rematch ? array_cell (rematch) : (ARRAY *)0;
|
||||
|
||||
+9
-1
@@ -1,6 +1,6 @@
|
||||
/* print_command -- A way to make readable commands from a command tree. */
|
||||
|
||||
/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -1055,6 +1055,9 @@ print_redirection_list (redirects)
|
||||
else
|
||||
hdtail = heredocs = newredir;
|
||||
}
|
||||
#if 0
|
||||
/* Remove this heuristic now that the command printing code doesn't
|
||||
unconditionally put in the redirector file descriptor. */
|
||||
else if (redirects->instruction == r_duplicating_output_word && (redirects->flags & REDIR_VARASSIGN) == 0 && redirects->redirector.dest == 1)
|
||||
{
|
||||
/* Temporarily translate it as the execution code does. */
|
||||
@@ -1064,6 +1067,7 @@ print_redirection_list (redirects)
|
||||
print_redirection (redirects);
|
||||
redirects->instruction = r_duplicating_output_word;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
print_redirection (redirects);
|
||||
|
||||
@@ -1222,6 +1226,8 @@ print_redirection (redirect)
|
||||
case r_duplicating_input_word:
|
||||
if (redirect->rflags & REDIR_VARASSIGN)
|
||||
cprintf ("{%s}<&%s", redir_word->word, redirectee->word);
|
||||
else if (redirector == 0)
|
||||
cprintf ("<&%s", redirectee->word);
|
||||
else
|
||||
cprintf ("%d<&%s", redirector, redirectee->word);
|
||||
break;
|
||||
@@ -1229,6 +1235,8 @@ print_redirection (redirect)
|
||||
case r_duplicating_output_word:
|
||||
if (redirect->rflags & REDIR_VARASSIGN)
|
||||
cprintf ("{%s}>&%s", redir_word->word, redirectee->word);
|
||||
else if (redirector == 1)
|
||||
cprintf (">&%s", redirectee->word);
|
||||
else
|
||||
cprintf ("%d>&%s", redirector, redirectee->word);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user