]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
profile/osc-context: move and extend check for TERM=dumb 39588/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 6 Nov 2025 10:56:01 +0000 (11:56 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 7 Nov 2025 13:47:49 +0000 (14:47 +0100)
Let's do the check early and skip most of the file if appropriate. Also, treat
missing $TERM same as "dumb". We're almost certainly at a dump terminal in that
case.

profile.d/80-systemd-osc-context.sh

index 60ab9904f1d3207c520d647cd6000a70a56ed159..c83e0d3c4273ebfcfecd5c1bdc73c659606b42ad 100644 (file)
 # Not bash?
 [ -n "${BASH_VERSION:-}" ] || return 0
 
+# If we're on a "dumb" terminal, do not install the prompt.
+# Treat missing $TERM same as "dumb".
+[ "${TERM:-dumb}" = "dumb" ] && return 0
+
 __systemd_osc_context_escape() {
     # Escape according to the OSC 3008 spec. Since this requires shelling out
     # to 'sed' we'll only do it where it's strictly necessary, and skip it when
@@ -56,7 +60,7 @@ __systemd_osc_context_precmdline() {
     read -r systemd_osc_context_cmd_id </proc/sys/kernel/random/uuid
 }
 
-if [[ -n "${BASH_VERSION:-}" ]] && [[ "${TERM:-}" != "dumb" ]]; then
+if [ -n "${BASH_VERSION:-}" ]; then
     # Legacy bashrc will assign PROMPT_COMMAND=, which is equivalent to assigning
     # index 0 in the array. Leave an empty spot to handle this gracefully.
     [ -n "$(declare -p PROMPT_COMMAND 2>/dev/null)" ] || PROMPT_COMMAND+=('')