*** ../bash-5.2-patched/subst.c 2022-10-05 10:22:02.000000000 -0400 --- subst.c 2022-10-06 15:19:08.000000000 -0400 *************** *** 1799,1802 **** --- 1804,1810 ---- } + #define PARAMEXPNEST_MAX 32 // for now + static int dbstate[PARAMEXPNEST_MAX]; + /* Extract a parameter expansion expression within ${ and } from STRING. Obey the Posix.2 rules for finding the ending `}': count braces while *************** *** 1829,1832 **** --- 1837,1842 ---- return (extract_heredoc_dolbrace_string (string, sindex, quoted, flags)); + dbstate[0] = dolbrace_state; + pass_character = 0; nesting_level = 1; *************** *** 1853,1856 **** --- 1863,1868 ---- if (string[i] == '$' && string[i+1] == LBRACE) { + if (nesting_level < PARAMEXPNEST_MAX) + dbstate[nesting_level] = dolbrace_state; nesting_level++; i += 2; *************** *** 1865,1868 **** --- 1877,1881 ---- if (nesting_level == 0) break; + dolbrace_state = (nesting_level < PARAMEXPNEST_MAX) ? dbstate[nesting_level] : dbstate[0]; /* Guess using initial state */ i++; continue;