]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
zsh: busctl: fix flags parsing for properties
authorRonan Pigott <ronan@rjp.ie>
Fri, 8 Sep 2023 22:27:39 +0000 (15:27 -0700)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 9 Sep 2023 00:28:07 +0000 (01:28 +0100)
I'm not quite sure what the original intent of this line was, but it
doesn't work in the one call-site the "required" argument is actually
used. The "writable" flag was indexed as a scalar leaving only the
"e" to compare against.

Instead, let's just sort the parsed flags and compare the whole thing.
Also substitute "required" as a pattern, so that pattern based
comparisons may be supported.

shell-completion/zsh/_busctl

index b0cd4d5db51b9cfe00912b8eba8a4360a7482783..70f9e74036961be7ab64ef21daf3dd3ae1beb74c 100644 (file)
@@ -118,7 +118,7 @@ __dbus_matchspec() {
     __busctl introspect "$1" "$2" "$3" |
     while read NAME TYPE SIGNATURE VALUE FLAGS; do
         [[ -z "$member" || ${TYPE} == "$member" ]] &&
-        [[ -z "$required" || ${${(s: :)FLAGS}[-1]} == "$required" ]] &&
+        [[ -z "$required" || "${${(os: :)FLAGS}}" == $~required ]] &&
         echo ${NAME#.}
     done
 }
@@ -244,7 +244,7 @@ __dbus_matchspec() {
             ;;
         5)
             _wanted property expl 'property' \
-            compadd "$@" - $(_busctl_get_members $words[2,4] "property" "writable")
+            compadd "$@" - $(_busctl_get_members $words[2,4] "property" "*writable*")
             ;;
         6)
             compadd "$@" - $(_busctl_get_signature $words[2,5])