commit:     cd1c4421557b64a8bbef675d8802e283fa1c3a8b
Author:     Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Thu Sep 25 17:52:02 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Sep 30 20:14:05 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cd1c4421

app-shells/bash: revbump 5.2, 5.3 and 5.4 for improved title setting

This commit introduces the following versions.

- 5.2_p37-r5
- 5.3_p3-r3
- bash-5.4_alpha_pre20250918-r2 (replacing -r1)

They improve the window title setting behaviour by using the ${param@P}
form of expansion to expand "\u@\h \W" as a prompt string. A notable
consequence of this is that, upon switching to the home directory, the
current working directory will be shown as the <tilde> character again.

The value of PROMPT_DIRTRIM is now respected. If this variable is unset,
the use of the \W prompt string escape will prevail, with the current
working directory typically being shown as its basename. If set to 0 or
greater, \w will be used instead, which may be trimmed. This means that
the title can be made to show the full path by setting PROMPT_DIRTRIM=0.

Also, whitelist xterm-ghostty for XTWINOPS support.

Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../{bash-9999.ebuild => bash-5.2_p37-r5.ebuild}   | 53 +++++++++++++--
 .../{bash-9999.ebuild => bash-5.3_p3-r3.ebuild}    | 33 +++++++++-
 ...ebuild => bash-5.4_alpha_pre20250918-r2.ebuild} | 33 +++++++++-
 app-shells/bash/bash-9999.ebuild                   | 28 +++++++-
 app-shells/bash/files/bashrc-r1                    | 29 --------
 .../bash/files/bashrc.d/10-gentoo-title-r3.bash    | 77 ++++++++++++++++++++++
 6 files changed, 214 insertions(+), 39 deletions(-)

diff --git a/app-shells/bash/bash-9999.ebuild 
b/app-shells/bash/bash-5.2_p37-r5.ebuild
similarity index 85%
copy from app-shells/bash/bash-9999.ebuild
copy to app-shells/bash/bash-5.2_p37-r5.ebuild
index 6211b96f2a29..1891112ab1bb 100644
--- a/app-shells/bash/bash-9999.ebuild
+++ b/app-shells/bash/bash-5.2_p37-r5.ebuild
@@ -15,7 +15,7 @@ MY_PV=${MY_PV/_/-}
 MY_P=${PN}-${MY_PV}
 MY_PATCHES=()
 
-# Determine the patchlevel.
+# Determine the patchlevel. See https://ftp.gnu.org/gnu/bash/bash-5.2-patches/.
 case ${PV} in
        9999|*_alpha*|*_beta*|*_rc*)
                # Set a negative patchlevel to indicate that it's a pre-release.
@@ -33,7 +33,7 @@ esac
 
 # The version of readline this bash normally ships with. Note that we only use
 # the bundled copy of readline for pre-releases.
-READLINE_VER="8.3"
+READLINE_VER="8.2_p1"
 
 DESCRIPTION="The standard GNU Bourne again shell"
 HOMEPAGE="https://tiswww.case.edu/php/chet/bash/bashtop.html 
https://git.savannah.gnu.org/cgit/bash.git";
@@ -103,6 +103,13 @@ PATCHES=(
 
        # Patches to or from Chet, posted to the bug-bash mailing list.
        "${FILESDIR}/${PN}-5.0-syslog-history-extern.patch"
+       "${FILESDIR}/${PN}-5.2_p15-random-ub.patch"
+       "${FILESDIR}/${PN}-5.2_p15-configure-clang16.patch"
+       "${FILESDIR}/${PN}-5.2_p21-wpointer-to-int.patch"
+       "${FILESDIR}/${PN}-5.2_p32-memory-leaks.patch"
+       
"${FILESDIR}/${PN}-5.2_p32-invalid-continuation-byte-ignored-as-delimiter-1.patch"
+       
"${FILESDIR}/${PN}-5.2_p32-invalid-continuation-byte-ignored-as-delimiter-2.patch"
+       "${FILESDIR}/${PN}-5.2_p32-erroneous-delimiter-pushback-condition.patch"
 )
 
 pkg_setup() {
@@ -147,6 +154,15 @@ src_prepare() {
        # Include official patches.
        (( PLEVEL > 0 )) && eapply -p0 "${MY_PATCHES[@]}"
 
+       # Clean out local libs so we know we use system ones w/releases. The
+       # touch utility is invoked for the benefit of config.status.
+       if (( PLEVEL >= 0 )); then
+               rm -rf lib/{readline,termcap}/* \
+               && touch lib/{readline,termcap}/Makefile.in \
+               && sed -i -E 
's:\$[{(](RL|HIST)_LIBSRC[)}]/[[:alpha:]_-]*\.h::g' Makefile.in \
+               || die
+       fi
+
        # Prefixify hardcoded path names. No-op for non-prefix.
        hprefixify pathnames.h.in
 
@@ -174,6 +190,10 @@ src_configure() {
        # https://lists.gnu.org/archive/html/bug-bash/2025-08/msg00115.html
        unset -v YACC
 
+       # bash 5.3 drops unprototyped functions, earlier versions are
+       # incompatible with C23.
+       append-cflags $(test-flags-CC -std=gnu17)
+
        if tc-is-cross-compiler; then
                export CFLAGS_FOR_BUILD="${BUILD_CFLAGS} -std=gnu17"
        fi
@@ -201,7 +221,6 @@ src_configure() {
        append-cppflags \
                
-DDEFAULT_PATH_VALUE=\'\""${EPREFIX}"/usr/local/sbin:"${EPREFIX}"/usr/local/bin:"${EPREFIX}"/usr/sbin:"${EPREFIX}"/usr/bin:"${EPREFIX}"/sbin:"${EPREFIX}"/bin\"\'
 \
                
-DSTANDARD_UTILS_PATH=\'\""${EPREFIX}"/bin:"${EPREFIX}"/usr/bin:"${EPREFIX}"/sbin:"${EPREFIX}"/usr/sbin\"\'
 \
-               
-DDEFAULT_LOADABLE_BUILTINS_PATH=\'\""${EPREFIX}"/usr/local/$(get_libdir)/bash:"${EPREFIX}"/usr/$(get_libdir)/bash\"\'
 \
                -DSYS_BASHRC=\'\""${EPREFIX}"/etc/bash/bashrc\"\' \
                -DSYS_BASH_LOGOUT=\'\""${EPREFIX}"/etc/bash/bash_logout\"\' \
                -DNON_INTERACTIVE_LOGIN_SHELLS \
@@ -316,7 +335,7 @@ src_install() {
 
        insinto /etc/bash/bashrc.d
        my_prefixify DIR_COLORS "${FILESDIR}"/bashrc.d/10-gentoo-color-r2.bash 
| newins - 10-gentoo-color.bash
-       newins "${FILESDIR}"/bashrc.d/10-gentoo-title-r2.bash 
10-gentoo-title.bash
+       newins "${FILESDIR}"/bashrc.d/10-gentoo-title-r3.bash 
10-gentoo-title.bash
 
        insinto /etc/profile.d
        doins "${FILESDIR}/profile.d/00-prompt-command.sh"
@@ -423,6 +442,32 @@ PROMPT_COMMAND=(genfun_set_win_title)
 Those who would prefer for bash never to interfere with the window title may
 now opt out of the default title setting behaviour, either with the "unset -v
 PROMPT_COMMAND" command or by re-defining PROMPT_COMMAND as desired.
+EOF
+               fi
+
+               if ver_test "${old_ver}" -ge "5.3" \
+                       && ver_test "${old_ver}" -ge "5.3_p3-r3"
+               then
+                       :
+               elif ver_test "${old_ver}" -lt "5.3" \
+                       && ver_test "${old_ver}" -ge "5.2_p37-r5"
+               then
+                       :
+               else
+                       cat <<'EOF'
+The window title setting behaviour has been improved. It is now formatted as
+"\u@\h \W", in accordance with the prompting mechanism of bash. For example,
+after switching to the home directory, the current working directly will be
+shown as the <tilde> character.
+
+The value of PROMPT_DIRTRIM is now respected. If this variable is unset, the
+use of the \W prompt string escape will prevail, with the current working
+directory typically being shown as its basename. If set to 0 or greater, \w
+will be used instead, which may be trimmed. This also means that the title
+can be made to show the full path by setting PROMPT_DIRTRIM=0.
+
+For further information, run info '(bash)Bash Variables' or visit
+https://www.gnu.org/software/bash/manual/bash.html#index-PROMPT_005fDIRTRIM.
 EOF
                fi
        } \

diff --git a/app-shells/bash/bash-9999.ebuild 
b/app-shells/bash/bash-5.3_p3-r3.ebuild
similarity index 90%
copy from app-shells/bash/bash-9999.ebuild
copy to app-shells/bash/bash-5.3_p3-r3.ebuild
index 6211b96f2a29..4218315eebfc 100644
--- a/app-shells/bash/bash-9999.ebuild
+++ b/app-shells/bash/bash-5.3_p3-r3.ebuild
@@ -15,7 +15,7 @@ MY_PV=${MY_PV/_/-}
 MY_P=${PN}-${MY_PV}
 MY_PATCHES=()
 
-# Determine the patchlevel.
+# Determine the patchlevel. See https://ftp.gnu.org/gnu/bash/bash-5.3-patches/.
 case ${PV} in
        9999|*_alpha*|*_beta*|*_rc*)
                # Set a negative patchlevel to indicate that it's a pre-release.
@@ -102,7 +102,8 @@ PATCHES=(
        #"${WORKDIR}"/${PN}-${GENTOO_PATCH_VER}/
 
        # Patches to or from Chet, posted to the bug-bash mailing list.
-       "${FILESDIR}/${PN}-5.0-syslog-history-extern.patch"
+       "${FILESDIR}"/${PN}-5.0-syslog-history-extern.patch
+       "${FILESDIR}"/${PN}-5.3-read-sys.patch
 )
 
 pkg_setup() {
@@ -316,7 +317,7 @@ src_install() {
 
        insinto /etc/bash/bashrc.d
        my_prefixify DIR_COLORS "${FILESDIR}"/bashrc.d/10-gentoo-color-r2.bash 
| newins - 10-gentoo-color.bash
-       newins "${FILESDIR}"/bashrc.d/10-gentoo-title-r2.bash 
10-gentoo-title.bash
+       newins "${FILESDIR}"/bashrc.d/10-gentoo-title-r3.bash 
10-gentoo-title.bash
 
        insinto /etc/profile.d
        doins "${FILESDIR}/profile.d/00-prompt-command.sh"
@@ -423,6 +424,32 @@ PROMPT_COMMAND=(genfun_set_win_title)
 Those who would prefer for bash never to interfere with the window title may
 now opt out of the default title setting behaviour, either with the "unset -v
 PROMPT_COMMAND" command or by re-defining PROMPT_COMMAND as desired.
+EOF
+               fi
+
+               if ver_test "${old_ver}" -ge "5.3" \
+                       && ver_test "${old_ver}" -ge "5.3_p3-r3"
+               then
+                       :
+               elif ver_test "${old_ver}" -lt "5.3" \
+                       && ver_test "${old_ver}" -ge "5.2_p37-r5"
+               then
+                       :
+               else
+                       cat <<'EOF'
+The window title setting behaviour has been improved. It is now formatted as
+"\u@\h \W", in accordance with the prompting mechanism of bash. For example,
+after switching to the home directory, the current working directly will be
+shown as the <tilde> character.
+
+The value of PROMPT_DIRTRIM is now respected. If this variable is unset, the
+use of the \W prompt string escape will prevail, with the current working
+directory typically being shown as its basename. If set to 0 or greater, \w
+will be used instead, which may be trimmed. This also means that the title
+can be made to show the full path by setting PROMPT_DIRTRIM=0.
+
+For further information, run info '(bash)Bash Variables' or visit
+https://www.gnu.org/software/bash/manual/bash.html#index-PROMPT_005fDIRTRIM.
 EOF
                fi
        } \

diff --git a/app-shells/bash/bash-5.4_alpha_pre20250918-r1.ebuild 
b/app-shells/bash/bash-5.4_alpha_pre20250918-r2.ebuild
similarity index 91%
rename from app-shells/bash/bash-5.4_alpha_pre20250918-r1.ebuild
rename to app-shells/bash/bash-5.4_alpha_pre20250918-r2.ebuild
index 10edeed625e6..5a30defbc42f 100644
--- a/app-shells/bash/bash-5.4_alpha_pre20250918-r1.ebuild
+++ b/app-shells/bash/bash-5.4_alpha_pre20250918-r2.ebuild
@@ -312,11 +312,14 @@ src_install() {
 
        insinto /etc/bash
        doins "${FILESDIR}"/bash_logout
-       my_prefixify bashrc.d "${FILESDIR}"/bashrc-r1 | newins - bashrc
+       my_prefixify bashrc.d "${FILESDIR}"/bashrc-r2 | newins - bashrc
 
        insinto /etc/bash/bashrc.d
        my_prefixify DIR_COLORS "${FILESDIR}"/bashrc.d/10-gentoo-color-r2.bash 
| newins - 10-gentoo-color.bash
-       newins "${FILESDIR}"/bashrc.d/10-gentoo-title-r2.bash 
10-gentoo-title.bash
+       newins "${FILESDIR}"/bashrc.d/10-gentoo-title-r3.bash 
10-gentoo-title.bash
+
+       insinto /etc/profile.d
+       doins "${FILESDIR}/profile.d/00-prompt-command.sh"
 
        insinto /etc/skel
        for f in bash{_logout,_profile,rc}; do
@@ -420,6 +423,32 @@ PROMPT_COMMAND=(genfun_set_win_title)
 Those who would prefer for bash never to interfere with the window title may
 now opt out of the default title setting behaviour, either with the "unset -v
 PROMPT_COMMAND" command or by re-defining PROMPT_COMMAND as desired.
+EOF
+               fi
+
+               if ver_test "${old_ver}" -ge "5.3" \
+                       && ver_test "${old_ver}" -ge "5.3_p3-r3"
+               then
+                       :
+               elif ver_test "${old_ver}" -lt "5.3" \
+                       && ver_test "${old_ver}" -ge "5.2_p37-r5"
+               then
+                       :
+               else
+                       cat <<'EOF'
+The window title setting behaviour has been improved. It is now formatted as
+"\u@\h \W", in accordance with the prompting mechanism of bash. For example,
+after switching to the home directory, the current working directly will be
+shown as the <tilde> character.
+
+The value of PROMPT_DIRTRIM is now respected. If this variable is unset, the
+use of the \W prompt string escape will prevail, with the current working
+directory typically being shown as its basename. If set to 0 or greater, \w
+will be used instead, which may be trimmed. This also means that the title
+can be made to show the full path by setting PROMPT_DIRTRIM=0.
+
+For further information, run info '(bash)Bash Variables' or visit
+https://www.gnu.org/software/bash/manual/bash.html#index-PROMPT_005fDIRTRIM.
 EOF
                fi
        } \

diff --git a/app-shells/bash/bash-9999.ebuild b/app-shells/bash/bash-9999.ebuild
index 6211b96f2a29..7f5ca499dd43 100644
--- a/app-shells/bash/bash-9999.ebuild
+++ b/app-shells/bash/bash-9999.ebuild
@@ -316,7 +316,7 @@ src_install() {
 
        insinto /etc/bash/bashrc.d
        my_prefixify DIR_COLORS "${FILESDIR}"/bashrc.d/10-gentoo-color-r2.bash 
| newins - 10-gentoo-color.bash
-       newins "${FILESDIR}"/bashrc.d/10-gentoo-title-r2.bash 
10-gentoo-title.bash
+       newins "${FILESDIR}"/bashrc.d/10-gentoo-title-r3.bash 
10-gentoo-title.bash
 
        insinto /etc/profile.d
        doins "${FILESDIR}/profile.d/00-prompt-command.sh"
@@ -423,6 +423,32 @@ PROMPT_COMMAND=(genfun_set_win_title)
 Those who would prefer for bash never to interfere with the window title may
 now opt out of the default title setting behaviour, either with the "unset -v
 PROMPT_COMMAND" command or by re-defining PROMPT_COMMAND as desired.
+EOF
+               fi
+
+               if ver_test "${old_ver}" -ge "5.3" \
+                       && ver_test "${old_ver}" -ge "5.3_p3-r3"
+               then
+                       :
+               elif ver_test "${old_ver}" -lt "5.3" \
+                       && ver_test "${old_ver}" -ge "5.2_p37-r5"
+               then
+                       :
+               else
+                       cat <<'EOF'
+The window title setting behaviour has been improved. It is now formatted as
+"\u@\h \W", in accordance with the prompting mechanism of bash. For example,
+after switching to the home directory, the current working directly will be
+shown as the <tilde> character.
+
+The value of PROMPT_DIRTRIM is now respected. If this variable is unset, the
+use of the \W prompt string escape will prevail, with the current working
+directory typically being shown as its basename. If set to 0 or greater, \w
+will be used instead, which may be trimmed. This also means that the title
+can be made to show the full path by setting PROMPT_DIRTRIM=0.
+
+For further information, run info '(bash)Bash Variables' or visit
+https://www.gnu.org/software/bash/manual/bash.html#index-PROMPT_005fDIRTRIM.
 EOF
                fi
        } \

diff --git a/app-shells/bash/files/bashrc-r1 b/app-shells/bash/files/bashrc-r1
deleted file mode 100644
index deb0ce97d4a7..000000000000
--- a/app-shells/bash/files/bashrc-r1
+++ /dev/null
@@ -1,29 +0,0 @@
-# /etc/bash/bashrc
-
-# Proceed no further in the case of a non-interactive shell.
-if [[ $- != *i* ]]; then
-       return
-fi
-
-# Disable errexit in case the user enabled it then chose to re-source this 
file.
-shopt -u -o errexit
-
-# Disable completion when the input buffer is empty. Mute STDERR because this
-# option is only present in the case that bash was built with readline support.
-shopt -s no_empty_cmd_completion 2>/dev/null &&
-
-# Append to HISTFILE rather than overwrite upon exiting, per bug #139609. This
-# option also requires for bash to have been built with readline support.
-shopt -s histappend
-
-# Initialise PROMPT_COMMAND as an array, which is permitted as of bash 5.1.
-PROMPT_COMMAND=()
-
-# Don't let the user influence the order of sourcing for bash 5.3 or greater.
-unset -v GLOBSORT
-
-for _ in /etc/bash/bashrc.d/*; do
-       if [[ $_ == *.@(bash|sh) && -r $_ ]]; then
-               source "$_"
-       fi
-done

diff --git a/app-shells/bash/files/bashrc.d/10-gentoo-title-r3.bash 
b/app-shells/bash/files/bashrc.d/10-gentoo-title-r3.bash
new file mode 100644
index 000000000000..186763d07d9d
--- /dev/null
+++ b/app-shells/bash/files/bashrc.d/10-gentoo-title-r3.bash
@@ -0,0 +1,77 @@
+# /etc/bash/bashrc.d/10-gentoo-title.bash
+
+# For information regarding the control sequences used, please refer to
+# https://invisible-island.net/xterm/ctlseqs/ctlseqs.html.
+
+genfun_set_win_title() {
+       # Advertise the fact that the presently running interactive shell will
+       # update the title. Doing so allows for its subprocesses to determine
+       # whether it is safe to set the title of their own accord. Note that 0
+       # refers to the value of Ps within the OSC Ps ; Pt BEL sequence.
+       export SHELL_SETS_TITLE=0
+
+       # Sets the window title with the Set Text Parameters control sequence.
+       # For screen, the sequence defines the hardstatus (%h) and for tmux, the
+       # pane_title (#T). For graphical terminal emulators, it is normal for
+       # the title bar to be affected.
+       genfun_set_win_title() {
+               local prompt
+
+               if [[ ${PROMPT_DIRTRIM} ]]; then
+                       # Respect the value of PROMPT_DIRTRIM. If set as 0, the
+                       # current working directory shall be shown in full.
+                       prompt='\u@\h \w'
+               else
+                       # Show the basename of the current working directory.
+                       prompt='\u@\h \W'
+               fi
+               printf '\033]0;%s\007' "${prompt@P}"
+       }
+
+       genfun_set_win_title
+}
+
+unset -v SHELL_SETS_TITLE
+
+# Determine whether the terminal can handle the Set Text Parameters sequence.
+# The only terminals permitted here are those for which there is empirical
+# evidence that the sequence is supported and that the UTF-8 character encoding
+# is handled correctly. Quite rightly, this precludes many vintage terminals.
+case ${TERM} in
+       alacritty*|contour|foot*|tmux*|xterm-ghostty)
+               # The terminal emulator also supports XTWINOPS. If the PTY was
+               # created by sshd(8) then push the current window title to the
+               # stack and arrange for it to be popped upon exiting. Xterm also
+               # supports this but there are far too many terminal emulators
+               # that falsely identify as being xterm-compatible.
+               if [[ ${SSH_TTY} && ${SSH_TTY} == "$(tty)" ]]; then
+                       trap 'printf "\033[23;0t"' EXIT
+                       printf '\033[22;0t'
+               fi
+               ;;
+       rxvt-unicode*|st-256color|xterm*)
+               # If the PTY was created by sshd(8) then proceed no further.
+               # Alas, there exist many operating environments in which the
+               # title would otherwise not be restored upon ssh(1) exiting.
+               # Those wanting for the title to be set regardless may adjust
+               # ~/.bashrc or create a bashrc.d drop-in to set PROMPT_COMMAND.
+               # For example, PROMPT_COMMAND=(genfun_set_win_title).
+               if [[ ${SSH_TTY} && ${SSH_TTY} == "$(tty)" ]]; then
+                       return
+               fi
+               ;;
+       screen*)
+               # If the PTY was created by sshd(8) and screen(1) was launched
+               # prior to the SSH session beginning, as opposed to afterwards,
+               # proceed no further. It is another case in which there would be
+               # no guarantee of the title being restored upon ssh(1) exiting.
+               if [[ ! ${WINDOW} && ${SSH_TTY} && ${SSH_TTY} == "$(tty)" ]]; 
then
+                       return
+               fi
+               ;;
+       *)
+               return
+esac
+
+# Arrange for the title to be updated each time the primary prompt is 
displayed.
+PROMPT_COMMAND+=('genfun_set_win_title')

Reply via email to