summary refs log tree commit diff
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2022-04-03 18:34:02 +0200
committerMikael Magnusson <mikachu@gmail.com>2022-04-03 18:34:02 +0200
commit853773820766a69d7a15c1c0349e6d24de553322 (patch)
treeb07664df94acc3f66cdd950e06377e2a72a9bd7b
parent6900dded09ddfdfda14c68093256db9021720d23 (diff)
downloadzsh-853773820766a69d7a15c1c0349e6d24de553322.tar.gz
zsh-853773820766a69d7a15c1c0349e6d24de553322.tar.xz
zsh-853773820766a69d7a15c1c0349e6d24de553322.zip
49966: _adb: Parse device spec correctly
This was particularly annoying when trying to complete logtags after adb logcat -s
-rw-r--r--ChangeLog3
-rw-r--r--Completion/Unix/Command/_adb11
2 files changed, 8 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index dc7b1174b..49708d7d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -20,6 +20,9 @@
 	* 49965: Completion/Unix/Command/_adb: _adb: use $CURRENT instead
 	of $#words
 
+	* 49966: Completion/Unix/Command/_adb: _adb: Parse device spec
+	correctly
+
 2022-04-02  dana  <dana@dana.is>
 
 	* unposted (see 48073): Completion/Zsh/Command/_fc: Complete
diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb
index b8b2470a6..b31b84c89 100644
--- a/Completion/Unix/Command/_adb
+++ b/Completion/Unix/Command/_adb
@@ -82,6 +82,7 @@ _adb() {
   if ! adb ${ADB_DEVICE_SPECIFICATION} shell exit 2>/dev/null; then
       # early bail-out until a single valid device/emulator is specified and up-and-running
       [[ $words[CURRENT-1] = -s ]] || _message -r "No (started) device specified, completions do not yet work"
+      #TODO handle -t transport-id
       _arguments \
 	'-s[serial]: :_adb_device_serial' \
 	'(   -e)-d[device]' \
@@ -165,13 +166,11 @@ _adb_sanitize_context () {
 
 (( $+functions[_adb_device_specification] )) ||
 _adb_device_specification () {
-  local -a word
-  word=($words[(R)-[des]])
-  if [[ $words[(R)-s] == -s ]]; then
-    local i=$words[(I)-s]
-    word=($words[i,i+1])
+  if [[ $words[2] == -[de] ]]; then
+    ADB_DEVICE_SPECIFICATION=($words[2])
+  elif [[ $words[2] == -[st] ]]; then
+    ADB_DEVICE_SPECIFICATION=($words[2,3])
   fi
-  ADB_DEVICE_SPECIFICATION=($word)
 }
 
 (( $+functions[_adb_dispatch_shell] )) ||