From 0578c26bd68fa729d0d198b6e9f864b3b317e419 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 2 Jan 2025 11:48:58 +0900 Subject: [PATCH 1/2] bash-completion/journalctl: list user units when --user is already specified Follow-up for 52051dd84c45c745ca877d8893be6f71aa27bf97. Fixes #35794. --- shell-completion/bash/journalctl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl index 5d1cc174c9..e70d799905 100644 --- a/shell-completion/bash/journalctl +++ b/shell-completion/bash/journalctl @@ -94,7 +94,11 @@ _journalctl() { compopt -o nosort ;; --unit|-u) - comps=$(journalctl -F '_SYSTEMD_UNIT' 2>/dev/null) + if __contains_word "--user" ${COMP_WORDS[*]}; then + comps=$(journalctl -F '_SYSTEMD_USER_UNIT' 2>/dev/null) + else + comps=$(journalctl -F '_SYSTEMD_UNIT' 2>/dev/null) + fi # Similarly to systemctl, we need to distinguish between # escaped and unescaped names in order to be able to correctly # complete them. In this particular case, if the name we're From bbe1d1bcb0f5b639faef8b38e9f5ae81518c7c3a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 2 Jan 2025 11:50:38 +0900 Subject: [PATCH 2/2] bash-completion/journalctl: also escape the current input of user unit Follow-up for cec82cb943d0fd23dd09309be62c6bcde6b47839. --- shell-completion/bash/journalctl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl index e70d799905..e7b8d57902 100644 --- a/shell-completion/bash/journalctl +++ b/shell-completion/bash/journalctl @@ -113,6 +113,10 @@ _journalctl() { ;; --user-unit) comps=$(journalctl -F '_SYSTEMD_USER_UNIT' 2>/dev/null) + if ! [[ $cur =~ '\\' ]]; then + cur="$(printf '%q' $cur)" + fi + compopt -o filenames ;; --identifier|-t|--exclude-identifier|-T) comps=$(journalctl -F 'SYSLOG_IDENTIFIER' 2>/dev/null)