From: Guiorgy Date: Wed, 31 Dec 2025 14:58:58 +0000 (+0400) Subject: Support Bash completions for short option group in journalctl (#40214) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5530c10b87c465db44dc1d562872bd31fa5f212;p=thirdparty%2Fsystemd.git Support Bash completions for short option group in journalctl (#40214) Currently, the Bash completions for journalctl tries to match the previous word _**exactly**_, which leads to the following issue: `journalctl -u dock` correctly auto completes to `journalctl -u docker.service`, but `journalctl -eu` provides no completions at all, which is a shame since I never use the `-u` option alone (almost always `-eu` or `-efu`, I wish the `-e` option was the default but I digress). The proposed solution is to assume words that start with only a single dash and consist of only letters are short option groups and handle them as if the previous word was the short option using the last character, e.g. `-efu` -> `-u`. --- diff --git a/shell-completion/bash/journalctl b/shell-completion/bash/journalctl index fc0fbba6642..f33f938e300 100644 --- a/shell-completion/bash/journalctl +++ b/shell-completion/bash/journalctl @@ -65,6 +65,13 @@ _journalctl() { return 0 fi + # If the previous word looks like a short options group, + # handle it as if it were just the last short option. + # e.g. "-aefu" -> "-u" + if [[ "$prev" =~ ^-[a-zA-Z]{2,}$ ]]; then + prev="-${prev:(-1)}" + fi + if __contains_word "$prev" ${OPTS[ARG]} ${OPTS[ARGUNKNOWN]}; then case $prev in --boot|-b)