Running a no-fork command substitution currently causes verbose mode to
stay disabled after it finishes.

    $ set -v
    $ : ${ :; }
    : ${ :; }
    $ echo X
    X
---
 subst.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/subst.c b/subst.c
index 121a7a3c..51dabe9d 100644
--- a/subst.c
+++ b/subst.c
@@ -7008,6 +7008,13 @@ uw_restore_errexit (void *eflag)
   set_shellopts ();
 }
 
+static void
+uw_restore_verbose (void *vflag)
+{
+  change_flag ('v', (intptr_t) vflag ? FLAG_ON : FLAG_OFF);
+  set_shellopts ();
+}
+
 /* Quote the output of nofork varsub command substitution in the way that the
    caller of function_substitute expects. The caller guarantees that STRING
    is non-null. This is equivalent to what read_comsub does to the output it
@@ -7146,7 +7153,7 @@ function_substitute (char *string, int quoted, int flags)
   push_context (lambdafunc.name, 1, temporary_env);            /* make local 
variables work */
   this_shell_function = &lambdafunc;
 
-  unwind_protect_int (verbose_flag);
+  add_unwind_protect (uw_restore_verbose, (void *) (intptr_t) verbose_flag);
   change_flag ('v', FLAG_OFF);
 
   /* When inherit_errexit option is not enabled, command substitution does
-- 
2.54.0


Reply via email to