* [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/, app-shells/bash/files/bashrc.d/
@ 2024-04-27 23:15 Sam James
0 siblings, 0 replies; 4+ messages in thread
From: Sam James @ 2024-04-27 23:15 UTC (permalink / raw
To: gentoo-commits
commit: 3b57965e7f470622da200da16761f522e57c7991
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Apr 27 20:58:38 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Apr 27 23:09:49 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3b57965e
app-shells/bash: prefixify bashrc.d files, whitelist st-256color, drop [ef]grep aliases
The ebuilds that install "${FILESDIR}/bashrc.d/10-gentoo-color.bash"
were neglecting to prefixify it. That is, to replace instances of "/etc"
with "${EPREFIX}/etc". After reviewing the prefix eclass, I found it to
be wanting in all of its chief respects: interface, correctness, safety
and robustness. Consequently, I rejected the notion of using it on
principle. Instead, I elected to create a custom function, which is now
used to prefixify both "bashrc" and "10-gentoo-color.bash". Among its
virtues are that it writes an amended stream to the standard output,
which may be directly processed by newins.
Whitelist st-256color for Set Text Parameters support. Also, add it to
the list of terminals known to support colour.
Drop the egrep and fgrep aliases again. Previously, they had been
dropped by Mike Gilbert but were inadvertently re-introduced through my
being thorough rather than prudent. Given that both are non-standard, I
certainly have no wish to provide users with any additional excuses for
their continued use.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Fixes: 268b2e7c07d97bd9e833d239d786a0314c3b09ec
Signed-off-by: Sam James <sam <AT> gentoo.org>
...sh-5.1_p16-r8.ebuild => bash-5.1_p16-r9.ebuild} | 14 ++++++++--
...sh-5.2_p26-r1.ebuild => bash-5.2_p26-r2.ebuild} | 14 ++++++++--
...h-5.3_alpha.ebuild => bash-5.3_alpha-r1.ebuild} | 14 ++++++++--
.../bash/files/bashrc.d/10-gentoo-color.bash | 31 +++++++++++-----------
.../bash/files/bashrc.d/10-gentoo-title.bash | 1 +
5 files changed, 53 insertions(+), 21 deletions(-)
diff --git a/app-shells/bash/bash-5.1_p16-r8.ebuild b/app-shells/bash/bash-5.1_p16-r9.ebuild
similarity index 96%
rename from app-shells/bash/bash-5.1_p16-r8.ebuild
rename to app-shells/bash/bash-5.1_p16-r9.ebuild
index 41b73878797e..fefec1f7e54d 100644
--- a/app-shells/bash/bash-5.1_p16-r8.ebuild
+++ b/app-shells/bash/bash-5.1_p16-r9.ebuild
@@ -249,16 +249,26 @@ src_install() {
default
+ my_prefixify() {
+ while read -r; do
+ if [[ $REPLY == *$1* ]]; then
+ REPLY=${REPLY/"/etc/"/"${EPREFIX}/etc/"}
+ fi
+ printf '%s\n' "${REPLY}" || ! break
+ done < "$2" || die
+ }
+
dodir /bin
mv "${ED}"/usr/bin/bash "${ED}"/bin/ || die
dosym bash /bin/rbash
insinto /etc/bash
doins "${FILESDIR}"/bash_logout
- newins "$(prefixify_ro "${FILESDIR}"/bashrc-r1)" bashrc
+ my_prefixify bashrc.d "${FILESDIR}"/bashrc-r1 | newins - bashrc
insinto /etc/bash/bashrc.d
- doins "${FILESDIR}"/bashrc.d/*.bash
+ my_prefixify DIR_COLORS "${FILESDIR}"/bashrc.d/10-gentoo-color.bash | newins - 10-gentoo-color.bash
+ doins "${FILESDIR}"/bashrc.d/10-gentoo-title.bash
insinto /etc/skel
for f in bash{_logout,_profile,rc} ; do
diff --git a/app-shells/bash/bash-5.2_p26-r1.ebuild b/app-shells/bash/bash-5.2_p26-r2.ebuild
similarity index 96%
rename from app-shells/bash/bash-5.2_p26-r1.ebuild
rename to app-shells/bash/bash-5.2_p26-r2.ebuild
index 0e803fa5048c..64cfa30c6113 100644
--- a/app-shells/bash/bash-5.2_p26-r1.ebuild
+++ b/app-shells/bash/bash-5.2_p26-r2.ebuild
@@ -296,16 +296,26 @@ src_install() {
default
+ my_prefixify() {
+ while read -r; do
+ if [[ $REPLY == *$1* ]]; then
+ REPLY=${REPLY/"/etc/"/"${EPREFIX}/etc/"}
+ fi
+ printf '%s\n' "${REPLY}" || ! break
+ done < "$2" || die
+ }
+
dodir /bin
mv "${ED}"/usr/bin/bash "${ED}"/bin/ || die
dosym bash /bin/rbash
insinto /etc/bash
doins "${FILESDIR}"/bash_logout
- newins "$(prefixify_ro "${FILESDIR}"/bashrc-r1)" bashrc
+ my_prefixify bashrc.d "${FILESDIR}"/bashrc-r1 | newins - bashrc
insinto /etc/bash/bashrc.d
- doins "${FILESDIR}"/bashrc.d/*.bash
+ my_prefixify DIR_COLORS "${FILESDIR}"/bashrc.d/10-gentoo-color.bash | newins - 10-gentoo-color.bash
+ doins "${FILESDIR}"/bashrc.d/10-gentoo-title.bash
insinto /etc/skel
for f in bash{_logout,_profile,rc} ; do
diff --git a/app-shells/bash/bash-5.3_alpha.ebuild b/app-shells/bash/bash-5.3_alpha-r1.ebuild
similarity index 96%
rename from app-shells/bash/bash-5.3_alpha.ebuild
rename to app-shells/bash/bash-5.3_alpha-r1.ebuild
index 036e48751a1f..9b535f0e39eb 100644
--- a/app-shells/bash/bash-5.3_alpha.ebuild
+++ b/app-shells/bash/bash-5.3_alpha-r1.ebuild
@@ -295,16 +295,26 @@ src_install() {
default
+ my_prefixify() {
+ while read -r; do
+ if [[ $REPLY == *$1* ]]; then
+ REPLY=${REPLY/"/etc/"/"${EPREFIX}/etc/"}
+ fi
+ printf '%s\n' "${REPLY}" || ! break
+ done < "$2" || die
+ }
+
dodir /bin
mv "${ED}"/usr/bin/bash "${ED}"/bin/ || die
dosym bash /bin/rbash
insinto /etc/bash
doins "${FILESDIR}"/bash_logout
- newins "$(prefixify_ro "${FILESDIR}"/bashrc-r1)" bashrc
+ my_prefixify bashrc.d "${FILESDIR}"/bashrc-r1 | newins - bashrc
insinto /etc/bash/bashrc.d
- doins "${FILESDIR}"/bashrc.d/*.bash
+ my_prefixify DIR_COLORS "${FILESDIR}"/bashrc.d/10-gentoo-color.bash | newins - 10-gentoo-color.bash
+ doins "${FILESDIR}"/bashrc.d/10-gentoo-title.bash
insinto /etc/skel
for f in bash{_logout,_profile,rc} ; do
diff --git a/app-shells/bash/files/bashrc.d/10-gentoo-color.bash b/app-shells/bash/files/bashrc.d/10-gentoo-color.bash
index 5a6df5690c08..66afdcaa9557 100644
--- a/app-shells/bash/files/bashrc.d/10-gentoo-color.bash
+++ b/app-shells/bash/files/bashrc.d/10-gentoo-color.bash
@@ -14,20 +14,21 @@ elif unset -v COLORTERM; ! gentoo_color=$(tput colors 2>/dev/null); then
# and which remain (somewhat) popular. This will rarely happen, so the
# list need not be exhaustive.
case ${TERM} in
- *color* |\
- *direct* |\
- [Ekx]term* |\
- alacritty |\
- aterm |\
- dtterm |\
- foot* |\
- jfbterm |\
- linux |\
- mlterm |\
- rxvt* |\
- screen* |\
- tmux* |\
- wsvt25* ) gentoo_color=1
+ *color* |\
+ *direct* |\
+ [Ekx]term* |\
+ alacritty |\
+ aterm |\
+ dtterm |\
+ foot* |\
+ jfbterm |\
+ linux |\
+ mlterm |\
+ rxvt* |\
+ screen* |\
+ st-256color |\
+ tmux* |\
+ wsvt25* ) gentoo_color=1
esac
elif (( gentoo_color == 16777216 )); then
# Truecolor support is available. Advertise it.
@@ -47,7 +48,7 @@ fi
if (( gentoo_color > 0 )); then
# Colorize the output of grep and several coreutils utilities.
- for _ in diff dir egrep fgrep grep ls vdir; do
+ for _ in diff dir grep ls vdir; do
alias "$_=$_ --color=auto"
done
diff --git a/app-shells/bash/files/bashrc.d/10-gentoo-title.bash b/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
index 56afcf213045..1fbf17c26327 100644
--- a/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
+++ b/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
@@ -45,6 +45,7 @@ case ${TERM} in
foot* |\
rxvt-unicode* |\
screen* |\
+ st-256color |\
tmux* |\
xterm* )
genfun_set_win_title() {
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/, app-shells/bash/files/bashrc.d/
@ 2024-06-15 4:40 Sam James
0 siblings, 0 replies; 4+ messages in thread
From: Sam James @ 2024-06-15 4:40 UTC (permalink / raw
To: gentoo-commits
commit: b35701d05b15a831d8319c046203f7a70be339cb
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jun 15 03:59:11 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 15 04:39:29 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b35701d0
app-shells/bash: declare the genfun_set_win_title function unconditionally
Presently, revisions 5.1_p16-r10, 5.2_p26-r3 and bash-5.3_alpha-r2
refrain from declaring the genfun_set_win_title function at all in the
case that the tty belongs to sshd(8). This is to avoid cluttering the
shell's operating environment in situations where the decision is made
not to append 'genfun_set_win_title' to the PROMPT_COMMANDS array.
One might ask why it should not always be appended to the array. The
explanation for this is that Gentoo Linux does not exist in a vacuum;
not all operating systems default to initialising bash in such a way
that it can be assumed that the title will be set at each prompt (or at
all). Where SSH is involved, the server has no knowledge whatsoever of
the particulars of the client OS or its operating environment. This
would previously give rise to the following scenario.
1. User runs ssh(1) from non-Gentoo to connect to sshd(8) on Gentoo
2. The remote shell alters the window title
3. The user eventually exits the remote shell.
4. The window title is never restored to its prior value
Put simply, there is no way for the remote side to know what the
existing window title is, much less guarantee that it be restored on the
client side.
All that being said - and rather unsurprisingly - some Gentoo users will
care nothing for these considerations or are simply operating in a
homogenous environment where they are not an immediate concern. Try to
accommodate the wishes of such users more effectively by declaring the
function unconditionally. Consequently, they will have the option of
restoring Gentoo's historical behaviour in a somewhat straightforward
manner. That is, by setting PROMPT_COMMAND in ~/.bashrc or in an
/etc/bash/bashrc.d/ drop-in to the effect of the following.
PROMPT_COMMAND=(genfun_set_win_title)
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Bug: https://bugs.gentoo.org/934309
Signed-off-by: Sam James <sam <AT> gentoo.org>
...-5.1_p16-r10.ebuild => bash-5.1_p16-r11.ebuild} | 0
...sh-5.2_p26-r3.ebuild => bash-5.2_p26-r4.ebuild} | 0
....3_alpha-r2.ebuild => bash-5.3_alpha-r3.ebuild} | 0
.../bash/files/bashrc.d/10-gentoo-title.bash | 49 +++++++++++++---------
4 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/app-shells/bash/bash-5.1_p16-r10.ebuild b/app-shells/bash/bash-5.1_p16-r11.ebuild
similarity index 100%
rename from app-shells/bash/bash-5.1_p16-r10.ebuild
rename to app-shells/bash/bash-5.1_p16-r11.ebuild
diff --git a/app-shells/bash/bash-5.2_p26-r3.ebuild b/app-shells/bash/bash-5.2_p26-r4.ebuild
similarity index 100%
rename from app-shells/bash/bash-5.2_p26-r3.ebuild
rename to app-shells/bash/bash-5.2_p26-r4.ebuild
diff --git a/app-shells/bash/bash-5.3_alpha-r2.ebuild b/app-shells/bash/bash-5.3_alpha-r3.ebuild
similarity index 100%
rename from app-shells/bash/bash-5.3_alpha-r2.ebuild
rename to app-shells/bash/bash-5.3_alpha-r3.ebuild
diff --git a/app-shells/bash/files/bashrc.d/10-gentoo-title.bash b/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
index 1fbf17c26327..0246d4fa36f0 100644
--- a/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
+++ b/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
@@ -1,5 +1,31 @@
# /etc/bash/bashrc.d/10-gentoo-title.bash
+genfun_set_win_title() {
+ # Assigns the basename of the current working directory, having
+ # sanitised it with @Q parameter expansion. Useful for paths containing
+ # newlines and such. As a special case, names consisting entirely of
+ # graphemes shall not undergo the expansion, for reasons of cleanliness.
+ genfun_sanitise_cwd() {
+ _cwd=${PWD##*/}
+ if [[ ! ${_cwd} ]]; then
+ _cwd=${PWD}
+ elif [[ ${_cwd} == *[![:graph:]]* ]]; then
+ _cwd=${_cwd@Q}
+ fi
+ }
+
+ # Sets the window title with the Set Text Parameters sequence. For
+ # screen, the sequence defines the hardstatus (%h) and for tmux, the
+ # window_name (#W). For graphical terminal emulators, it is normal for
+ # the title bar be affected.
+ genfun_set_win_title() {
+ genfun_sanitise_cwd
+ printf '\033]2;%s@%s - %s\007' "${USER}" "${HOSTNAME%%.*}" "${_cwd}"
+ }
+
+ genfun_set_win_title
+}
+
# Set window title with the Title Definition String sequence. For screen, the
# sequence defines the window title (%t) and for tmux, the pane_title (#T).
# For tmux to be affected requires that its allow-rename option be enabled.
@@ -15,27 +41,14 @@ case ${TERM} in
# If the TTY is that of sshd(8) then proceed no further. Alas,
# there exist many operating environments in which the window
# title would otherwise not be restored upon ssh(1) exiting.
+ # Users wishing to coerce the historical behaviour have the
+ # option of setting PROMPT_COMMAND=(genfun_set_win_title).
if [[ ${SSH_TTY} && ${SSH_TTY} == "$(tty)" ]]; then
return
fi
esac
-# Assigns the basename of the current working directory, having sanitised it
-# with @Q parameter expansion. Useful for paths containing newlines and such.
-# As a special case, names consisting entirely of graphemes shall not undergo
-# the parameter expansion, for reasons of cleanliness.
-genfun_sanitise_cwd() {
- _cwd=${PWD##*/}
- if [[ ! ${_cwd} ]]; then
- _cwd=${PWD}
- elif [[ ${_cwd} == *[![:graph:]]* ]]; then
- _cwd=${_cwd@Q}
- fi
-}
-
-# Set window title with the Set Text Parameters sequence. For screen, the
-# sequence defines the hardstatus (%h) and for tmux, the window_name (#W).
-# For graphical terminal emulators, it is normal for the title bar be affected.
+# 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.
@@ -48,9 +61,5 @@ case ${TERM} in
st-256color |\
tmux* |\
xterm* )
- genfun_set_win_title() {
- genfun_sanitise_cwd
- printf '\033]2;%s@%s - %s\007' "${USER}" "${HOSTNAME%%.*}" "${_cwd}"
- }
PROMPT_COMMAND+=('genfun_set_win_title')
esac
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/, app-shells/bash/files/bashrc.d/
@ 2024-06-30 17:31 Sam James
0 siblings, 0 replies; 4+ messages in thread
From: Sam James @ 2024-06-30 17:31 UTC (permalink / raw
To: gentoo-commits
commit: 1d15b220376e9da1251127d71f78203f5da3f9d7
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jun 29 12:58:33 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jun 30 17:25:03 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1d15b220
app-shells/bash: fix title setting heuristic; set both icon name and title
In bug #934732, Sven Wegener requested for bash to refrain from setting
the "internal" window title. That is, the window title (%t) of GNU
screen and the window_name (#W) of tmux. A patch was attached to the
bug, which I acknowledged and which was subsequently applied by Sven.
Unfortunately - and perhaps owing to my eagerness to have the matter be
resolved - I did not notice that the patch introduces a regression. The
regression is that both screen and tmux are no longer exempted from the
sshd(8) check, resulting in neither the hardstatus (%h) being set for
the former, nor the pane_title (#T) for the latter. This commit restores
the intended behaviour.
In comment #10 of bug #550104, Heui-mun Park makes a compelling case
that the "\033]0;" variant of the Set Text Parameters sequence should be
preferred over other variants. The difference is that it sets the "icon
name" in addition to the "window title". Indeed, I have found that most
applications that employ the sequence make use of this more
comprehensive variant. For many users, such a distinction would amount
to being little more than an artifact of history. Nevertheless, it makes
perfect sense for 10-gentoo-title.bash to be aligned with the practices
of others in this regard. Make it so.
Improve the commentary in 10-gentoo-title.bash, along with the accuracy
and utility of the information conveyed by the ewarn comands in the
ebuilds.
Have the live ebuild (version 9999) install 15-gentoo-bashrc-check.bash,
just as the other recent ebuilds do. It's simpler from a maintenance
standpoint for there to be as few differences between them as is
possible.
Fixes: 9ff9f8199ccf9d55fb1cf066cbbc791101894ab0
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
...-5.1_p16-r12.ebuild => bash-5.1_p16-r13.ebuild} | 37 ++++++++++++--------
...sh-5.2_p26-r5.ebuild => bash-5.2_p26-r6.ebuild} | 37 ++++++++++++--------
....3_alpha-r4.ebuild => bash-5.3_alpha-r5.ebuild} | 37 ++++++++++++--------
app-shells/bash/bash-9999.ebuild | 40 ++++++++++++++--------
.../bash/files/bashrc.d/10-gentoo-title.bash | 13 +++----
5 files changed, 102 insertions(+), 62 deletions(-)
diff --git a/app-shells/bash/bash-5.1_p16-r12.ebuild b/app-shells/bash/bash-5.1_p16-r13.ebuild
similarity index 89%
rename from app-shells/bash/bash-5.1_p16-r12.ebuild
rename to app-shells/bash/bash-5.1_p16-r13.ebuild
index cc9ce6983938..38b7451addc3 100644
--- a/app-shells/bash/bash-5.1_p16-r12.ebuild
+++ b/app-shells/bash/bash-5.1_p16-r13.ebuild
@@ -328,22 +328,31 @@ pkg_postinst() {
read -r old_ver <<<"${REPLACING_VERSIONS}"
if [[ ! $old_ver ]]; then
:
- elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r1"; then
+ elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r6"; then
return
- elif ver_test "$old_ver" -lt "5.2" && ver_test "$old_ver" -ge "5.1_p16-r8"; then
+ elif ver_test "$old_ver" -lt "5.2" && ver_test "$old_ver" -ge "5.1_p16-r13"; then
return
fi
- ewarn "Files situated under /etc/bash/bashrc.d must now have a suffix of .sh or .bash."
- ewarn ""
- ewarn "Gentoo now defaults to defining PROMPT_COMMAND as an array. Depending on the"
- ewarn "characteristics of the operating environment, this array may contain commands"
- ewarn "to set the window and pane title. Users that choose to customise this variable"
- ewarn "in ~/.bashrc are advised to append their commands, using the following syntax."
- ewarn ""
- ewarn "PROMPT_COMMAND+=('custom command goes here')"
- ewarn ""
- ewarn "Alternatively, users that wish to opt out of Gentoo's window title setting"
- ewarn "behaviour may now do so by either unsetting PROMPT_COMMAND or by re-defining it"
- ewarn "as desired. Previously, there was no formally supported method of opting out."
+ while read -r; do ewarn "${REPLY}"; done <<'EOF'
+Files situated under /etc/bash/bashrc.d must now have a suffix of .sh or .bash.
+
+Gentoo now defaults to defining PROMPT_COMMAND as an array. Depending on the
+characteristics of the operating environment, this array may contain a command
+to set the terminal's window title. Those already choosing to customise the
+PROMPT_COMMAND variable are now advised to append their commands like so:
+
+PROMPT_COMMAND+=('custom command goes here')
+
+Gentoo no longer defaults to having bash manipulate the window title in the case
+that the terminal is controlled by sshd(8), unless screen or tmux are in use.
+Those wanting to set the title unconditionally may adjust ~/.bashrc - or create
+a custom /etc/bash/bashrc.d drop-in - to set PROMPT_COMMMAND like so:
+
+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
}
diff --git a/app-shells/bash/bash-5.2_p26-r5.ebuild b/app-shells/bash/bash-5.2_p26-r6.ebuild
similarity index 90%
rename from app-shells/bash/bash-5.2_p26-r5.ebuild
rename to app-shells/bash/bash-5.2_p26-r6.ebuild
index e8eaa353cf21..4350a8a719c3 100644
--- a/app-shells/bash/bash-5.2_p26-r5.ebuild
+++ b/app-shells/bash/bash-5.2_p26-r6.ebuild
@@ -372,22 +372,31 @@ pkg_postinst() {
read -r old_ver <<<"${REPLACING_VERSIONS}"
if [[ ! $old_ver ]]; then
:
- elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r1"; then
+ elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r6"; then
return
- elif ver_test "$old_ver" -lt "5.2" && ver_test "$old_ver" -ge "5.1_p16-r8"; then
+ elif ver_test "$old_ver" -lt "5.2" && ver_test "$old_ver" -ge "5.1_p16-r13"; then
return
fi
- ewarn "Files situated under /etc/bash/bashrc.d must now have a suffix of .sh or .bash."
- ewarn ""
- ewarn "Gentoo now defaults to defining PROMPT_COMMAND as an array. Depending on the"
- ewarn "characteristics of the operating environment, this array may contain commands"
- ewarn "to set the window and pane title. Users that choose to customise this variable"
- ewarn "in ~/.bashrc are advised to append their commands, using the following syntax."
- ewarn ""
- ewarn "PROMPT_COMMAND+=('custom command goes here')"
- ewarn ""
- ewarn "Alternatively, users that wish to opt out of Gentoo's window title setting"
- ewarn "behaviour may now do so by either unsetting PROMPT_COMMAND or by re-defining it"
- ewarn "as desired. Previously, there was no formally supported method of opting out."
+ while read -r; do ewarn "${REPLY}"; done <<'EOF'
+Files situated under /etc/bash/bashrc.d must now have a suffix of .sh or .bash.
+
+Gentoo now defaults to defining PROMPT_COMMAND as an array. Depending on the
+characteristics of the operating environment, this array may contain a command
+to set the terminal's window title. Those already choosing to customise the
+PROMPT_COMMAND variable are now advised to append their commands like so:
+
+PROMPT_COMMAND+=('custom command goes here')
+
+Gentoo no longer defaults to having bash manipulate the window title in the case
+that the terminal is controlled by sshd(8), unless screen or tmux are in use.
+Those wanting to set the title unconditionally may adjust ~/.bashrc - or create
+a custom /etc/bash/bashrc.d drop-in - to set PROMPT_COMMMAND like so:
+
+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
}
diff --git a/app-shells/bash/bash-5.3_alpha-r4.ebuild b/app-shells/bash/bash-5.3_alpha-r5.ebuild
similarity index 90%
rename from app-shells/bash/bash-5.3_alpha-r4.ebuild
rename to app-shells/bash/bash-5.3_alpha-r5.ebuild
index 9699a659026a..c0e5e68f43a5 100644
--- a/app-shells/bash/bash-5.3_alpha-r4.ebuild
+++ b/app-shells/bash/bash-5.3_alpha-r5.ebuild
@@ -371,22 +371,31 @@ pkg_postinst() {
read -r old_ver <<<"${REPLACING_VERSIONS}"
if [[ ! $old_ver ]]; then
:
- elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r1"; then
+ elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r6"; then
return
- elif ver_test "$old_ver" -lt "5.2" && ver_test "$old_ver" -ge "5.1_p16-r8"; then
+ elif ver_test "$old_ver" -lt "5.2" && ver_test "$old_ver" -ge "5.1_p16-r13"; then
return
fi
- ewarn "Files situated under /etc/bash/bashrc.d must now have a suffix of .sh or .bash."
- ewarn ""
- ewarn "Gentoo now defaults to defining PROMPT_COMMAND as an array. Depending on the"
- ewarn "characteristics of the operating environment, this array may contain commands"
- ewarn "to set the window and pane title. Users that choose to customise this variable"
- ewarn "in ~/.bashrc are advised to append their commands, using the following syntax."
- ewarn ""
- ewarn "PROMPT_COMMAND+=('custom command goes here')"
- ewarn ""
- ewarn "Alternatively, users that wish to opt out of Gentoo's window title setting"
- ewarn "behaviour may now do so by either unsetting PROMPT_COMMAND or by re-defining it"
- ewarn "as desired. Previously, there was no formally supported method of opting out."
+ while read -r; do ewarn "${REPLY}"; done <<'EOF'
+Files situated under /etc/bash/bashrc.d must now have a suffix of .sh or .bash.
+
+Gentoo now defaults to defining PROMPT_COMMAND as an array. Depending on the
+characteristics of the operating environment, this array may contain a command
+to set the terminal's window title. Those already choosing to customise the
+PROMPT_COMMAND variable are now advised to append their commands like so:
+
+PROMPT_COMMAND+=('custom command goes here')
+
+Gentoo no longer defaults to having bash manipulate the window title in the case
+that the terminal is controlled by sshd(8), unless screen or tmux are in use.
+Those wanting to set the title unconditionally may adjust ~/.bashrc - or create
+a custom /etc/bash/bashrc.d drop-in - to set PROMPT_COMMMAND like so:
+
+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
}
diff --git a/app-shells/bash/bash-9999.ebuild b/app-shells/bash/bash-9999.ebuild
index ae661e409da8..7ef121e1c56f 100644
--- a/app-shells/bash/bash-9999.ebuild
+++ b/app-shells/bash/bash-9999.ebuild
@@ -311,6 +311,9 @@ src_install() {
insinto /etc/bash/bashrc.d
my_prefixify DIR_COLORS "${FILESDIR}"/bashrc.d/10-gentoo-color.bash | newins - 10-gentoo-color.bash
doins "${FILESDIR}"/bashrc.d/10-gentoo-title.bash
+ if [[ ! ${EPREFIX} ]]; then
+ doins "${FILESDIR}"/bashrc.d/15-gentoo-bashrc-check.bash
+ fi
insinto /etc/skel
for f in bash{_logout,_profile,rc}; do
@@ -368,22 +371,31 @@ pkg_postinst() {
read -r old_ver <<<"${REPLACING_VERSIONS}"
if [[ ! $old_ver ]]; then
:
- elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r1"; then
+ elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r6"; then
return
- elif ver_test "$old_ver" -lt "5.2" && ver_test "$old_ver" -ge "5.1_p16-r8"; then
+ elif ver_test "$old_ver" -lt "5.2" && ver_test "$old_ver" -ge "5.1_p16-r13"; then
return
fi
- ewarn "Files situated under /etc/bash/bashrc.d must now have a suffix of .sh or .bash."
- ewarn ""
- ewarn "Gentoo now defaults to defining PROMPT_COMMAND as an array. Depending on the"
- ewarn "characteristics of the operating environment, this array may contain commands"
- ewarn "to set the window and pane title. Users that choose to customise this variable"
- ewarn "in ~/.bashrc are advised to append their commands, using the following syntax."
- ewarn ""
- ewarn "PROMPT_COMMAND+=('custom command goes here')"
- ewarn ""
- ewarn "Alternatively, users that wish to opt out of Gentoo's window title setting"
- ewarn "behaviour may now do so by either unsetting PROMPT_COMMAND or by re-defining it"
- ewarn "as desired. Previously, there was no formally supported method of opting out."
+ while read -r; do ewarn "${REPLY}"; done <<'EOF'
+Files situated under /etc/bash/bashrc.d must now have a suffix of .sh or .bash.
+
+Gentoo now defaults to defining PROMPT_COMMAND as an array. Depending on the
+characteristics of the operating environment, this array may contain a command
+to set the terminal's window title. Those already choosing to customise the
+PROMPT_COMMAND variable are now advised to append their commands like so:
+
+PROMPT_COMMAND+=('custom command goes here')
+
+Gentoo no longer defaults to having bash manipulate the window title in the case
+that the terminal is controlled by sshd(8), unless screen or tmux are in use.
+Those wanting to set the title unconditionally may adjust ~/.bashrc - or create
+a custom /etc/bash/bashrc.d drop-in - to set PROMPT_COMMMAND like so:
+
+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
}
diff --git a/app-shells/bash/files/bashrc.d/10-gentoo-title.bash b/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
index 003e364ff072..2b2e23347784 100644
--- a/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
+++ b/app-shells/bash/files/bashrc.d/10-gentoo-title.bash
@@ -20,17 +20,18 @@ genfun_set_win_title() {
# the title bar to be affected.
genfun_set_win_title() {
genfun_sanitise_cwd
- printf '\033]2;%s@%s - %s\007' "${USER}" "${HOSTNAME%%.*}" "${_cwd}"
+ printf '\033]0;%s@%s - %s\007' "${USER}" "${HOSTNAME%%.*}" "${_cwd}"
}
genfun_set_win_title
}
-# If the TTY is that of sshd(8) then proceed no further. Alas, there exist many
-# operating environments in which the window title would otherwise not be
-# restored upon ssh(1) exiting. Users wishing to coerce the historical
-# behaviour have the option of setting PROMPT_COMMAND=(genfun_set_win_title).
-if [[ ${SSH_TTY} && ${SSH_TTY} == "$(tty)" ]]; then
+# Proceed no further if the TTY is that of sshd(8) and if not running a terminal
+# multiplexer. Alas, there exist many operating environments in which the window
+# title would otherwise not be restored upon ssh(1) exiting. Those who wish for
+# the title to be set unconditionally may adjust ~/.bashrc - or create a custom
+# bashrc.d drop-in - to define PROMPT_COMMAND=(genfun_set_win_title).
+if [[ ${SSH_TTY} && ${TERM} != @(screen|tmux)* && ${SSH_TTY} == "$(tty)" ]]; then
return
fi
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/, app-shells/bash/files/bashrc.d/
@ 2024-07-07 0:18 Sam James
0 siblings, 0 replies; 4+ messages in thread
From: Sam James @ 2024-07-07 0:18 UTC (permalink / raw
To: gentoo-commits
commit: b40811ec316a630d6a48f185e6459f235c83413d
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jul 6 22:59:56 2024 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sun Jul 7 00:18:08 2024 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b40811ec
app-shells/bash: add 5.2_p26-r8 with non-preliminary XTWINOPS support
The 5.2_p26-r7 revision contained (harmless) changes that were not yet
intended to be applied to the gentoo repo, owing to a miscommunication
between Sam and I. This commit applies the changes as were eventually
intended and, for this reason, the remainder of this commit message
shall be written accordingly. That is, as if no preceding commit had
been involved to get to this point.
...
Xterm is able to push and pop window titles to a stack and there are
several other terminal emulators that can do so, such as alacritty, foot
and tmux. Take advantage of this feature so as to reinstate automatic
window title setting in the case that the PTY is owned by sshd(8).
Unfortunately, there are a lot of terminal emulators that falsely
advertise themselves as being xterm-compatible, making it impossible to
reliably identify xterm itself. However, we can reliably identify
alacritty, foot and tmux so let's support those three to begin with.
The benefits conferred upon tmux are of a distinct nature, since it was
already the case that it was being whitelisted for title support.
Specifcally, the benefits are as follows:
- title restoration is supported even where tmux(1) is launched prior to ssh(1)
- title restoration is supported for nested instances of tmux
It should be noted that tmux does not forward titles to the outer
terminal emulator by default. Such can be arranged for with the
following configuration.
set -g set-titles on
set -g set-titles-string "#T"
Don't enable title setting for GNU screen in the case that the PTY is
owned by sshd(8) and screen(1) was launched prior to connecting with
ssh(1). This is a distinction that can be made by checking whether the
WINDOW variable is set in the environment.
Have the genfun_set_win_title function export a variable named
SHELL_SETS_TITLE upon the first occasion that it is called. Presently,
nothing responds to this variable but the intention is to eventually
have portage respond to it. Portage implements heuristics and behaviours
that are horrifyingly broken. For instance, it considers the mere
presence of PROMPT_COMMAND as somehow proving that the interactive shell
uses it for nothing other than to set the title, despite the fact that:
- the contents of PROMPT_COMMAND may be arbitrarily defined by the user
- the purpose of PROMPT_COMMAND is whatever the user may wish it to be
- nobody in their right mind would export PROMPT_COMMAND
- PROMPT_COMMAND can be an array since 5.1 (making it unexportable)
Worse still, in the event that portage is somehow able to ascertain the
value of PROMPT_COMMAND, it takes its first element and proceeds to
inject its value into an invocation of either sh, $SHELL or bash -c,
irrespective of the consequences. No, I'm not making this up.
As such, the purpose of the SHELL_SETS_TITLE variable is to act as a
straightforward indicator that an interactive shell exists as an
ancestor process and that it will take it upon itself to set a fresh
window title upon its primary prompt being displayed.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
.../bash/{bash-5.2_p26-r7.ebuild => bash-5.2_p26-r8.ebuild} | 12 ++++++------
app-shells/bash/files/bashrc.d/10-gentoo-title-r1.bash | 13 ++++++++++---
2 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/app-shells/bash/bash-5.2_p26-r7.ebuild b/app-shells/bash/bash-5.2_p26-r8.ebuild
similarity index 96%
rename from app-shells/bash/bash-5.2_p26-r7.ebuild
rename to app-shells/bash/bash-5.2_p26-r8.ebuild
index c46a593c82b0..1926aee81671 100644
--- a/app-shells/bash/bash-5.2_p26-r7.ebuild
+++ b/app-shells/bash/bash-5.2_p26-r8.ebuild
@@ -372,7 +372,7 @@ pkg_postinst() {
read -r old_ver <<<"${REPLACING_VERSIONS}"
if [[ ! $old_ver ]]; then
:
- elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r7"; then
+ elif ver_test "$old_ver" -ge "5.2" && ver_test "$old_ver" -ge "5.2_p26-r8"; then
return
fi
@@ -387,11 +387,11 @@ PROMPT_COMMAND variable are now advised to append their commands like so:
PROMPT_COMMAND+=('custom command goes here')
Gentoo no longer defaults to having bash set the window title in the case
-that the terminal is controlled by sshd(8), unless screen or tmux are in use
-or the terminal reliably supports saving and restoring the title (as
-alacritty and foot do). Those wanting to set the title unconditionally may
-adjust ~/.bashrc - or create a custom /etc/bash/bashrc.d drop-in - to set
-PROMPT_COMMMAND like so:
+that the terminal is controlled by sshd(8), unless screen is launched on the
+remote side or the terminal reliably supports saving and restoring the title
+(as alacritty, foot and tmux do). Those wanting for the title to be set
+regardless may adjust ~/.bashrc - or create a custom /etc/bash/bashrc.d
+drop-in - to set PROMPT_COMMMAND like so:
PROMPT_COMMAND=(genfun_set_win_title)
diff --git a/app-shells/bash/files/bashrc.d/10-gentoo-title-r1.bash b/app-shells/bash/files/bashrc.d/10-gentoo-title-r1.bash
index 1dc7b63bf422..8e78b09a9daf 100644
--- a/app-shells/bash/files/bashrc.d/10-gentoo-title-r1.bash
+++ b/app-shells/bash/files/bashrc.d/10-gentoo-title-r1.bash
@@ -42,9 +42,7 @@ unset -v SHELL_SETS_TITLE
# 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
- screen*|tmux*)
- ;;
- alacritty|foot*)
+ alacritty|foot*|tmux*)
# 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
@@ -66,6 +64,15 @@ case ${TERM} in
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-07 0:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-15 4:40 [gentoo-commits] repo/gentoo:master commit in: app-shells/bash/, app-shells/bash/files/bashrc.d/ Sam James
-- strict thread matches above, loose matches on Subject: below --
2024-07-07 0:18 Sam James
2024-06-30 17:31 Sam James
2024-04-27 23:15 Sam James
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox