Date: Sun, 12 Oct 2025 19:27:34 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 46441] sh(1): Does not support PS1, PS2, PS4 parameter expansion Message-ID: <bug-46441-227-suuT6SgrQo@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-46441-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | previous in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=46441 Matthew Phillips <matthew@matthewphillips.info> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #264417|0 |1 is obsolete| | Attachment #264503| |maintainer-approval?(jilles Flags| |@FreeBSD.org) --- Comment #21 from Matthew Phillips <matthew@matthewphillips.info> --- Created attachment 264503 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=264503&action=edit PS1/PS2 parameter expansion patch v2 Uploaded revised patch (v2) that addresses the review feedback. As mentioned, this patch maintains the localized approach within getprompt() and avoids full parser reentry. While this means we don't support advanced expansions like ${parameter#pattern}, it provides POSIX-compliant basic parameter expansion without the complexity of making the parser reentrant. This is sufficient for the vast majority of use cases and aligns with the existing PS4 implementation strategy. The original patch claimed to support special parameters ($$, $?, $!, $#) and positional parameters ($0-$9), but only called lookupvar() which cannot handle these parameter types. This has been fixed. Special parameters now properly implemented: - $$ → rootpid - $? → oexitstatus - $# → shellparam.nparam - $! → backgndpidval() Positional parameters now properly implemented: - $0 → arg0 (shell name) - $1-$9 → shellparam.p[num-1] Added tests as well: - ps1-expand1.0: Regular variable expansion ($testvar) - ps1-expand2.0: Braced variable expansion (${testvar}) - ps1-expand3.0: Special parameter $$ (PID) - ps1-expand4.0: Special parameter $? (exit status) - ps1-expand5.0: Positional parameter $0 (shell name) - ps2-expand1.0: PS2 continuation prompt expansion -- You are receiving this mail because: You are the assignee for the bug.help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-46441-227-suuT6SgrQo>
