Skip to content

Commit 0bd3432

Browse files
author
Jim Tang
committed
Adb and fastboot completion supports zsh users.
Builtin command "type" in zsh doesn't support -t option and this is resolved by checking the shell type prior to sourcing them. Instead of using "type -t" explicitly, check_type() knows the the type of the current shell and behaves accordingly. Bug: 110629292 Test: (zsh) source build/envsetup.sh && lunch aosp_arm (bash) source build/envsetup.sh && lunch aosp_arm Change-Id: Ie39e130e9cc87135cfd522abedba11ad5ac25261
1 parent 17a02a3 commit 0bd3432

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

adb/adb.bash

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
#
1717

1818
_adb() {
19-
if ! type -t "$1" >/dev/null; then
19+
if ! check_type "$1" >/dev/null; then
2020
return
2121
fi
2222

23-
if type -t _init_completion >/dev/null; then
23+
if check_type _init_completion >/dev/null; then
2424
_init_completion || return
2525
fi
2626

@@ -435,7 +435,7 @@ _adb_util_list_files() {
435435
fi
436436

437437
# Since we're probably doing file completion here, don't add a space after.
438-
if [[ $(type -t compopt) = "builtin" ]]; then
438+
if [[ $(check_type compopt) == "builtin" ]]; then
439439
compopt -o nospace
440440
fi
441441

@@ -451,7 +451,7 @@ _adb_util_complete_local_file()
451451
xspec=$2
452452

453453
# Since we're probably doing file completion here, don't add a space after.
454-
if [[ $(type -t compopt) = "builtin" ]]; then
454+
if [[ $(check_type compopt) == "builtin" ]]; then
455455
compopt -o plusdirs
456456
if [[ "${xspec}" == "" ]]; then
457457
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -f -- "${cur}") )
@@ -492,7 +492,7 @@ _adb_util_complete_local_file()
492492
}
493493

494494

495-
if [[ $(type -t compopt) = "builtin" ]]; then
495+
if [[ $(check_type compopt) == "builtin" ]]; then
496496
complete -F _adb adb
497497
else
498498
complete -o nospace -F _adb adb

fastboot/fastboot.bash

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
#
1717

1818
_fastboot() {
19-
if ! type -t "$1" >/dev/null; then
19+
if ! check_type "$1" >/dev/null; then
2020
return
2121
fi
2222

23-
if type -t _init_completion >/dev/null; then
23+
if check_type _init_completion >/dev/null; then
2424
_init_completion || return
2525
fi
2626

@@ -135,7 +135,7 @@ _fastboot_util_complete_local_file() {
135135
xspec=$2
136136

137137
# Since we're probably doing file completion here, don't add a space after.
138-
if [[ $(type -t compopt) = "builtin" ]]; then
138+
if [[ $(check_type compopt) == "builtin" ]]; then
139139
compopt -o plusdirs
140140
if [[ "${xspec}" == "" ]]; then
141141
COMPREPLY=( ${COMPREPLY[@]:-} $(compgen -f -- "${cur}") )
@@ -175,7 +175,7 @@ _fastboot_util_complete_local_file() {
175175
fi
176176
}
177177

178-
if [[ $(type -t compopt) = "builtin" ]]; then
178+
if [[ $(check_type compopt) == "builtin" ]]; then
179179
complete -F _fastboot fastboot
180180
else
181181
complete -o nospace -F _fastboot fastboot

0 commit comments

Comments
 (0)