From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14903 invoked by alias); 19 Jun 2015 16:34:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 35531 Received: (qmail 17810 invoked from network); 19 Jun 2015 16:34:33 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1434731331; bh=reTV/Cfa7BgeqMjqDLHt514KhPMofLlmjqmjxj4kJec=; h=cc:In-reply-to:From:References:To:Subject:Date:From:Subject; b=TD5KHbaC/mEq0WWqUmvAOO21OGJwhDVNbg2VyezxGYAzvTI/pUcpx6fLsF7gL4b5H5leVIxY0/yzAM5Lolfe8BZV8OHmyZhMAOo4bntyhJL/+Ka/M6nndcLrl+pKUKcWqalApC5kV6clDz/SrEqv9Xgagys0m31EIn/BtN9zubG4FTR5PGOZ4SE8t2T4jGZW3VgLeOPrHbgLKnp8TtupBE2laFK0ONPwOR5Z09tGreM1KvHK+yL3Pi15dglu0RsuqAoJsu1+octv/XT4qyo7/c4hYAuKTQhDJ0fGdn40sPKfh6DRhsxBP69/rsMOI2Cbzr6LFq5LuInHIs64yuJAMA== X-Yahoo-Newman-Id: 20693.35850.bm@smtp128.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: bXNvNI4VM1mesdLkA6k5b40b5fS3qRMH_Fkc3CIi5O8iP2T AfNdzXH6rTqbcbZZ2UE8ZHBfkGPPYQNL1VeCd78qAj4DgNfByVx2CFoh0sV5 4S3Q3vmZ066tSmkG02MBeqngoU_XXGuV84FrU_0Qgo_.FhAAUbGeSnxL5JiM W8dyc3MVne6vMg_8nZyK2Gq4q.XpjduCqZSsVmD7jSBWm_0N8YYKKxEHUbGD 1Md.T6GUvVTSHMCpuKHVy_6sNsL_aPfMun8qRwulfSGMLKPkqnOeYez0Iz2T XGxJ8QqHr6nEdCrgImuIw8rISJSn4drIll9y6xtoY2Qm5HqbtvfcTHVGbqEc k3Aqd0IavjwEV6DSbjg8IdAzIetTXm9PU39NuixBfFusAwvcmokZ_dZ5Sx15 pbSDwPuZZFzoNG4RHdZa6.0GoxBZ.Ybxrjr1acHml46BuG7Dy5xsM5bUcPRl JGn2ATE_Kox7rzxXHOR1TSz_y6VdevEITCKB0mfGZMdsr8Uf4gwZRCUbSIBJ MgZd7agfFQdylSQLsf82r8IX94Fg6gw-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- cc: zsh-workers@zsh.org In-reply-to: <1434644016.21351.10.camel@posteo.net> From: Oliver Kiddle References: <1434644016.21351.10.camel@posteo.net> To: Isgar Subject: Re: [BUG] adb sideload completion incorrect MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <6680.1434731329.1@thecus.kiddle.eu> Date: Fri, 19 Jun 2015 18:28:49 +0200 Message-ID: <6681.1434731329@thecus.kiddle.eu> Isgar wrote: > > currently the completion tries > adb sideload [adb command] > > the correct syntax is > adb sideload [filename] Sigh. Not breaking file completion where it might be wanted is probably the most important rule for writing completion functions. > Seems like an easy fix? I'm not familiar with adb and as it all requires a device to connect to I can't easily install it to play with. This patch will hopefully do the trick. It adds two fallback calls to _default. In the first case, it should perhaps instead be _alternative for both subcommands and files but it would really need more doing to it than that. I mostly tried to make the minimal changes to get back file completion. The one aside fix is to the format of $curcontext which it was breaking by using : to separate command and subcommand. Oliver diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb index e687762..c05cc02 100644 --- a/Completion/Unix/Command/_adb +++ b/Completion/Unix/Command/_adb @@ -76,7 +76,8 @@ _adb() { '(-d -e )-s[serial]: :_adb_device_serial' \ '( -e -s)-d[device]' \ '(-d -s)-e[emulator]' \ - '*:"options":_adb_options_handler' + '1:"options":_adb_options_handler' \ + '*: : _default' return; } @@ -99,27 +100,30 @@ _adb_dispatch_command () { fi case ${curcontext} in - (*:adb:shell) + (*:adb-shell) (( $+functions[_adb_dispatch_shell] )) && _adb_dispatch_shell ;; - (*:adb:connect|*:adb:disconnect) + (*:adb-connect|*:adb-disconnect) (( $+functions[_adb_dispatch_connection_handling] )) && _adb_dispatch_connection_handling ;; - (*:adb:logcat) + (*:adb-logcat) (( $+functions[_adb_dispatch_logcat] )) && _adb_dispatch_logcat ;; - (*:adb:push) + (*:adb-push) (( $+functions[_adb_dispatch_push] )) && _adb_dispatch_push ;; - (*:adb:pull) + (*:adb-pull) (( $+functions[_adb_dispatch_pull] )) && _adb_dispatch_pull ;; - (*:adb:install) + (*:adb-install) (( $+functions[_adb_dispatch_install] )) && _adb_dispatch_install ;; - (*:adb:uninstall) + (*:adb-uninstall) (( $+functions[_adb_dispatch_uninstall] )) && _adb_dispatch_uninstall ;; + (*:adb-*) + _default + ;; (*) _arguments \ '(-d -e)-s["serial"]: :_adb_device_serial' \ @@ -143,7 +147,7 @@ _adb_sanitize_context () { done ##expand unquoted to remove sparse elements mywords=( ${mywords[@]} ) - curcontext="${curcontext}${mywords[-1]}" + (( $#mywords )) && curcontext="${curcontext%:*}-${mywords[-1]}:" } (( $+functions[_adb_device_specification] )) || @@ -373,9 +377,9 @@ _adb_dispatch_connection_handling () { fi } -(( $+functions[adb_check_log_redirect] )) || +(( $+functions[_adb_check_log_redirect] )) || _adb_check_log_redirect () { - LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio)// + LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio 2>/dev/null)// /} [[ ${LOG_REDIRECT[1,4]} == "true" ]] && _message -r "Notice: stdio log redirection enabled on the device, so some completions will not work" }