chiark / gitweb /
bash-completion: avoid appending space after field competion
authorDave Reisner <dreisner@archlinux.org>
Sat, 20 Oct 2012 22:36:06 +0000 (18:36 -0400)
committerDave Reisner <dreisner@archlinux.org>
Sat, 20 Oct 2012 22:38:28 +0000 (18:38 -0400)
Resolves the TODO, and also uses compgen's -S flag to append the
trailing equals, rather than relying on an array-wide parameter
expansion.

Suggested-by: Ran Benita <ran234@gmail.com>
bash-completion/systemd-bash-completion.sh

index a034332..82c25a3 100644 (file)
@@ -331,11 +331,8 @@ _journalctl() {
                 mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )
         else
                 mapfile -t field_vals < <(journalctl -F "${COMP_WORDS[COMP_CWORD-2]}" 2>/dev/null)
                 COMPREPLY=( $(compgen -W '${field_vals[*]}' -- "$cur") )
         else
-                # append an '=' to the end of the completed field
-                # TODO: would be nice to be able to tell readline here not to
-                # append an extra space after the completed word, if such an
-                # option exists.
-                COMPREPLY=( $(compgen -W '${journal_fields[*]/%/=}' -- "$cur") )
+                compopt -o nospace
+                COMPREPLY=( $(compgen -W '${journal_fields[*]}' -S= -- "$cur") )
         fi
 }
 complete -F _journalctl journalctl
         fi
 }
 complete -F _journalctl journalctl