[Bug 46441] sh(1): Does not support PS1, PS2, PS4 parameter expansion

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 28 Feb 2022 07:31:24 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=46441

--- Comment #11 from Nathaniel Barragan <contact@nathanielbarragan.xyz> ---
I took a look at the code super fast (not planning on any changes yet), and it
seems that command substitution was not added on $PS1/PS2 because the parser
relies on PS1 and PS2 not doing command substitution on those variables. From
what it seems, the parser would need to be redone to become re-entrant. This is
because it has some state stored in static global variables, which are cleared
each parse.
A possible solution, and one that frankly doesn't sound fun would be to figure
out which variables are the ones that hold state local to parsing, and which
are really required to be static and global, and move these state-keeping
variables to a structure, then pass that structure to each parsing function.

-- 
You are receiving this mail because:
You are the assignee for the bug.