Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Completion: _opkg: Support gain-privileges
- X-seq: zsh-workers 43993
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: dana <dana@xxxxxxx>
- Subject: Re: [PATCH] Completion: _opkg: Support gain-privileges
- Date: Sat, 12 Jan 2019 19:24:50 +0000
- Cc: Zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:in-reply-to; s=fm2; bh=tDY /q4H3irn3t8KtJQ3br22etSguQPZYWyoUcoZ/Yqk=; b=QJ6URATIOX87k6RiEhR 40HFV2gBcAHZrpQw3eqoT/Wl6r/IYlYPbRzs98cgRGs+QMt/ySo2QXFyGDp8+eZt tomkn8MtfaQA7Gfdll3ecn0Rl3U5PPyELLn0+mKcEbY+kBExq8SnjpAyYTM3VGzh ZawWNAMFCzYTN/+WCMy+X6vsWMvs3BICZQECRTX11/COAq3xkUL4DMoC4hjMKw7A Iugj0GVE0LWd1n08y/b1pi/1H8klTyLFHmGzmT0lAxX972pkxurM3j/7YO9KuxqF 9QSpyoVc9IZ4R4L07tRBQZonAIShUXrB7sbkuDkTTjix2JO475SnUC0hd5pnmNsu utA==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=tDY/q4 H3irn3t8KtJQ3br22etSguQPZYWyoUcoZ/Yqk=; b=DstguMI2kgVsCwJ0qZb4mh rPI2a1PVkZQvyXkgX5/V92SQaJfWfHXiXEl2H1LHu3AmwmGoW/RTm/IxGH39rU1w +aRQ2kkgprpqcSruOok0oWJKl/KsfJLGd4QPifigV9ZcTIHD7OpY3a171/5CiABo FPT3fPuVsXpPN2Ds26KwZhA0dFgjy+MGSL5+W4DF12ZqvBaRJAixB5azSMcNKv6r ZlnW4Z1oOYnAZXCzaaMOMFxChKCp9lQAhRdogBlk/YBJOW5gKFCZpobsaU4gTX5F eF35QrgspsfwTTBW2e+M3TZ0x27BWUrLsuHwqPLOnKdb4Y9b16SUhfiRhe9Gd/ow ==
- In-reply-to: <55BD7A82-303D-4C2A-AF6F-350EF34E5E57@dana.is>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <E1AAD4A3-482A-4173-8579-05F0B38951B1@dana.is> <20190112171028.36htyrmgrxat4jle@tarpaulin.shahaf.local2> <55BD7A82-303D-4C2A-AF6F-350EF34E5E57@dana.is>
dana wrote on Sat, Jan 12, 2019 at 13:08:30 -0600:
> On 12 Jan 2019, at 11:10, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> >I don't think so. Even an "empty" result could be expensive to compute:
> >for example, it might require a network round-trip. I think _opkg
> >shouldn't call _store_cache when _call_program returns non-zero.
>
> Well, i think that's effectively the same thing in this case and certain
> others i'm imagining. (Or at least i assume so; there's not really any
> documentation for opkg that i'm aware of, so who knows what actually causes it
> to return non-zero.) Just felt like it might save some boiler-plate, which the
> caching logic is extremely heavy in already, to have a standard option handle
> it. I can just add the guard to each _store_cache call myself, though, obv
Sorry, I thought you meant making that the default behaviour. My bad.
I don't think expecting callers to check the exit code of commands they
call is an unusual or onerous requirement, not that it adds much
boilerplate:
diff --git a/Completion/Linux/Command/_opkg b/Completion/Linux/Command/_opkg
index d64567681..deeb766d9 100644
--- a/Completion/Linux/Command/_opkg
+++ b/Completion/Linux/Command/_opkg
@@ -181,12 +181,11 @@ _opkg_pkg_all() {
copts=( "$@" )
{ (( ! $#_opkg_cache_pkg_all )) || _cache_invalid opkg-pkg-all } &&
- ! _retrieve_cache opkg-pkg-all && {
- _opkg_cache_pkg_all=( ${(f)"$( _call_program pkg-all ${svc:-opkg} list )"} )
+ _retrieve_cache opkg-pkg-all || if _opkg_cache_pkg_all=( ${(f)"$( _call_program pkg-all ${svc:-opkg} list )"} ); then
_opkg_cache_pkg_all=( ${(@)_opkg_cache_pkg_all##[[:space:]]*} )
_opkg_cache_pkg_all=( ${(@)_opkg_cache_pkg_all%%[[:space:]]*} )
_store_cache opkg-pkg-all _opkg_cache_pkg_all
- }
+ fi
(( $#upd )) && return 0
(( $#_opkg_cache_pkg_all )) || {
But all that said, if the proposed new --option would be useful to many
callers, then of course we could/should add it.
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author