From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 24374 invoked from network); 3 Jun 2020 16:38:07 -0000 Received: from ns1.primenet.com.au (HELO primenet.com.au) (203.24.36.2) by inbox.vuxu.org with ESMTPUTF8; 3 Jun 2020 16:38:07 -0000 Received: (qmail 26264 invoked by alias); 3 Jun 2020 16:37:56 -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: List-Unsubscribe: X-Seq: 45954 Received: (qmail 20226 invoked by uid 1010); 3 Jun 2020 16:37:56 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr1-f68.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.3/25828. spamassassin: 3.4.4. Clear:RC:0(209.85.221.68):SA:0(-0.7/5.0):. Processed in 1.752425 secs); 03 Jun 2020 16:37:56 -0000 X-Envelope-From: doron.behar@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.221.68 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to; bh=vvd5gPbouUk5iqEcnEd+Gsgkulyv0/VCFW9RVGYM7Jg=; b=Ny3J8LY51dcctewr6OCCXFvKwO4B2FYLCQejHUhwTTfKin4ZGh/D/CXcAVq0Td9roK 9b81vSlC6gVeDizjbXpIR/VtLmUWAO5ExspFyNs4zuNrOFr+eWlZ3r45y6aNuH+la/fD ylr8EjIFFkDCb6HK2mrFYlT6BwMEk2vZTaFYoip7erxvSWmHyFOPCddZtbBboLkD+kQT xwhSHc9fcTgtK4eAJukmXJcGDrKUftzo85A253FQwSte6rGWMnNAsKxPOxz12dJs733b 0kkdzL10imZGBd359IgPzQWUjvqehGy3vF+fg+DX1MdOG39jNsClepIDBdoIzFHyt58U S8jQ== X-Gm-Message-State: AOAM532UwXQCmzNyc8IAxESyXIJ/shQqKPzuu8wCFZka7VYmhRyBPBF3 BisOD9R744OzDCdPS1+4YC+b6JLJjRE= X-Google-Smtp-Source: ABdhPJyA5LJygOO0Z4dzb2kPRRPiLcd5hMRxmZ8bHd9IkCkDxheboLCcMosrldADU8NFwBRDz/1o8g== X-Received: by 2002:adf:e90b:: with SMTP id f11mr315344wrm.248.1591202239673; Wed, 03 Jun 2020 09:37:19 -0700 (PDT) Date: Mon, 1 Jun 2020 20:56:07 +0300 From: Doron Behar To: zsh-workers@zsh.org Subject: Re: [PATCH] modutils completion: Fix FHS assumption Message-ID: <20200601175607.aupj4suxv5l7tk5x@NUX> Mail-Followup-To: zsh-workers@zsh.org References: <20200601170519.7665-1-doron.behar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200601170519.7665-1-doron.behar@gmail.com> This Patch has been previously discussed at https://gitlab.com/zsh-org/zsh/-/merge_requests/15 but Daniel Shahaf and I wish to get more feedback as to whether this brakes and `modutils` related command for anyone. Basically, the $modules_dir is set just like before, but if `/run/booted-system/kernel-modules/lib/modules` exists, it's being used instead of the default `/lib/modules` - the 1st directory is the directory used on NixOS and Guix. This patch fixes an ugly error for NixOS and Guix utils which goes like this: $ modinfo _modutils:102: no such file or directory: /lib/modules/5.6.15/modules.alias On Mon, Jun 01, 2020 at 08:05:19PM +0300, doron.behar@gmail.com wrote: > From: Doron Behar > > --- > Completion/Linux/Command/_modutils | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils > index ff6844f41..a0ed7b210 100644 > --- a/Completion/Linux/Command/_modutils > +++ b/Completion/Linux/Command/_modutils > @@ -12,7 +12,18 @@ _modules_caching_policy() > _modutils() { > local curcontext="$curcontext" expl state line modules modaliases ign args ret=1 > local -A opt_args > - local -r modules_dir=/lib/modules > + local -a possible_modules_dirs=( > + # NixOS & possibly Guix > + /run/booted-system/kernel-modules/lib/modules > + # Mostly every other distro > + /lib/modules > + ) > + local modules_dir tested_modules_dir > + for tested_modules_dir in "${possible_modules_dirs[@]}"; do > + if [[ -d "$tested_modules_dir" ]]; then > + modules_dir="$tested_modules_dir" > + fi > + done > > local update_policy > zstyle -s ":completion:*:*:$service:*" cache-policy update_policy > @@ -108,6 +119,9 @@ _modutils() { > all-modules) > local kver=${opt_args[(i)(-S|-k|--set-version)]:-$(uname -r)} > > + if [[ -z "$modules_dir" ]]; then > + return > + fi I _think_ this addition will also gracefully catch the edge case of a modules directory not found at all. > if _cache_invalid modules-$kver || ! _retrieve_cache modules-$kver; > then > modules=( $modules_dir/$kver/(*~(source|build))/**/*.(o|ko|ko.gz|ko.xz)(.:t:r:r) ) > -- > 2.26.2 >