https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=46441
--- Comment #20 from Jilles Tjoelker <[email protected]> --- (In reply to Matthew Phillips from comment #18) > I've implemented parameter expansion support for PS1/PS2/PS4 prompts. This is PS1 and PS2 only, since PS4 already supports expansions. > The patch adds support for: > - Simple variables: $USER, $PWD, $HOSTNAME > - Braced variables: ${USER}, ${HOME} > - Special parameters: $$, $?, $! > - Positional parameters: $0, $1, etc. It looks like this only supports simple and braced variables, since lookupvar() only looks up variables and not special or positional parameters. > Tested via some shell scripts. The tests in tests/ weren't interactive and > PS1 > requires it. Please advice if some test cases are needed and how to add > them. Some of the existing tests are for interactive features. Look for ${SH} -i +m and ${SH} +m -i in existing tests. Something like case $(testvar=abcdef PS1=\$testvar: ${SH} +m -i) in *abcdef*) ;; *) echo failed ;; esac could work as a test. The exact output can't be relied on; definitely not when it is desired to check and compare other shells as well. > Note: This implements parameter expansion only. Command substitution $(cmd) > is > not yet supported and would require additional work. Interesting choice to re-implement expansion, but this keeps the changes local and ensures the interaction with the existing backslash sequences is correct (i.e. neither a backslash from parameter expansion nor a dollar sign from a prompt backslash sequence are special). Implementing the varieties like ${parameter#pattern} and ${parameter:-default} will not be tenable this way. If people are happy with this restricted form, it could be nice. -- You are receiving this mail because: You are the assignee for the bug.
