From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43502-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=FREEMAIL_FROM, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 96db7e58 for ; Wed, 19 Sep 2018 20:36:37 +0000 (UTC) Received: (qmail 3164 invoked by alias); 19 Sep 2018 20:36:25 -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: 43502 Received: (qmail 5165 invoked by uid 1010); 19 Sep 2018 20:36:25 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr1-f65.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.221.65):SA:0(-1.2/5.0):. Processed in 1.394525 secs); 19 Sep 2018 20:36:25 -0000 X-Envelope-From: maximilian.bosch.27@gmail.com X-Qmail-Scanner-Mime-Attachments: |signature.asc| X-Qmail-Scanner-Zip-Files: | 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:references :mime-version:content-disposition:in-reply-to:user-agent; bh=h4iARmkaRQQoYYFh+j9RT1MCqZjkmp9MFTKD8oumd7o=; b=QQTZg9eiS+6hFCNFthe2UJ6d8Vtlr7BjpZCibSKOP7Z0if6ZWK+TqPx5XDavcWvu72 voT3/g9JgSUREONQP703d74rKtAvyod357AVnC+V8sWnO/JmrBHz3RuMGd4gXvQkAb+g akpaQuD3RAqLMo6qraJ33CvvUHYhZoXapL6fua47LixeDoCEM9ZtPPYbKbVnMY1zO9YE xcpZKNk2hg0hFHKx4gbmIaxIwBL9DoZwnPocosRBgRWIghPHKHv8YM8gG0HQbq2/CIDy x00YkXNH5NuAagMro9y6m6oc2rBrm8nPi1fLWSZ2IBqJS5AmM2wTvZX1Bh/n/Jss1fBB ESZQ== X-Gm-Message-State: APzg51ACMTrMYpi0TDsReXuGS4ig+0zjeY+sAQvGX/MKkXpec6HwaDBt DiYvrgjuotD6/Cb46npqG+3OEKSH X-Google-Smtp-Source: ANB0VdZO7lbYwfgtDKlaYAdPmaQBFas1Hs3uFlP4a7K7QAhSwAGQtNaXnoGA7BuNOqX02xB8lxVSNA== X-Received: by 2002:a5d:4185:: with SMTP id m5-v6mr5452045wrp.8.1537389379952; Wed, 19 Sep 2018 13:36:19 -0700 (PDT) Date: Wed, 19 Sep 2018 22:36:17 +0200 From: Maximilian Bosch To: zsh-workers@zsh.org Subject: Re: PATCH: search XDG_DATA_DIRS in _setxkbmap completion Message-ID: <20180919203617.u7qqocenjurq73l3@hauptschuhle> References: <20180918124951.4nbyjhbuqnkioqrt@hauptschuhle> <1537287030.1158541.1512325000.0C43F9DE@webmail.messagingengine.com> <20180918190516.2w3tyiugdmx6wzqw@hauptschuhle> <1537299172.1213094.1512566000.19322CCD@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="7wgc3lkw2xz54iov" Content-Disposition: inline In-Reply-To: <1537299172.1213094.1512566000.19322CCD@webmail.messagingengine.com> User-Agent: NeoMutt/20180716 --7wgc3lkw2xz54iov Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > Depends on how empty elements should be handled. In some contexts an > empty element means "look in the current working directory", and I > wasn't sure how the XDG spec defines this case. It's not a blocker but > it would be nice to get this right while we're here. I had a look at the XDG specification[1], unfortunately it doesn't mention the case of empty search path entries. Do you know what's the preferred default behavior? Again, thanks a lot for your feedback, I've implemented your suggestions. Best regards, Maximilian [1] https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html diff --git a/Completion/X/Command/_setxkbmap b/Completion/X/Command/_setxkb= map index f7310ecdd..486268ed7 100644 --- a/Completion/X/Command/_setxkbmap +++ b/Completion/X/Command/_setxkbmap @@ -9,10 +9,12 @@ _setxkbmap() { setopt extendedglob =20 # xkb files may be in different places depending on system - local dir sourcedir - for dir in /usr/lib/X11/xkb /usr/share/X11/xkb; do - if [ -d $dir ] ; then - sourcedir=3D$dir + local dir sourcedir fullname + local -a searchdirs=3D(${XDG_DATA_HOME:-~/.local/share} ${(s.:.)XDG_DA= TA_DIRS:-/usr/lib:/usr/share:/usr/local/lib:/usr/local/share}) + for dir in $searchdirs; do + fullname=3D"$dir/X11/xkb" + if [ -d $fullname ] ; then + sourcedir=3D$fullname break fi done On Tue, Sep 18, 2018 at 07:32:52PM +0000, Daniel Shahaf wrote: > Maximilian Bosch wrote on Tue, 18 Sep 2018 21:05 +0200: > > Thanks a lot for your feedback! > >=20 > > I use ZSH as interactive shell quite excessively, but as you might've > > noticed, I'm not that experienced with ZSH scripting, so thanks for > > your patience :D > >=20 >=20 > You're welcome. >=20 > > I applied your suggestions and re-checked the patch. > >=20 > > > How should empty array elements in XDG_DATA_DIRS be handled? E.g., > > > XDG_DATA_DIRS=3D/foo:/bar::/baz ? > >=20 > > Isn't this handled by `[ -d $fullname ]`? >=20 > Depends on how empty elements should be handled. In some contexts an > empty element means "look in the current working directory", and I > wasn't sure how the XDG spec defines this case. It's not a blocker but > it would be nice to get this right while we're here. > =20 > > +++ b/Completion/X/Command/_setxkbmap > > @@ -9,10 +9,12 @@ _setxkbmap() { > > setopt extendedglob > > =20 > > # xkb files may be in different places depending on system > > - local dir sourcedir > > - for dir in /usr/lib/X11/xkb /usr/share/X11/xkb; do > > - if [ -d $dir ] ; then > > - sourcedir=3D$dir > > + local dir sourcedir fullname > > + local searchdirs=3D"${XDG_DATA_DIRS:-/usr/lib:/usr/share:/usr/loca= l/lib:/usr/local/share}:${XDG_DATA_HOME:-~/.local/share}" >=20 > Two tweaks here: >=20 > 1. XDG_DATA_HOME should be listed before XDG_DATA_DIRS, according to > the XDG spec. >=20 > 2. I'd use an array, both because it's cleaner and in case > $XDG_DATA_HOME contains colons (not likely, but there's no > maintenance cost to supporting that). Thus: >=20 > local -a searchdirs=3D( ${XDG_DATA_HOME:-...} ${(s.:.)XDG_DATA_DIRS:-= =2E..} ) > for dir in $searchdirs; do >=20 > > + for dir in ${(s.:.)searchdirs}; do > > + fullname=3D"$dir/X11/xkb" > > + if [ -d $fullname ] ; then > > + sourcedir=3D$fullname > > break > > fi > > done >=20 > Cheers, >=20 > Daniel --7wgc3lkw2xz54iov Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCAAdFiEEPg3TILK+tBEQDaTVCR2/TR/Ea44FAluisz4ACgkQCR2/TR/E a45hgwgAs8+zn2AEo+sgknWT3JxXQH/+t4HHv9v5QURK2hhWe1irBP/tWiV7Lro9 1vj3GZAkD1rSARh3xw/SKIlnvV0OlWVYeBKKCX0uFIG7zaqH42HRxoVSzxazQjMs knxvw/zqUsQwAdC96gKHqLjCxBh8m8olf1FR79lGJS0VnBqzIf3LKZDOnbcG60zj gnOYMtflMJCq1ioPKEQfEJmHt2MUzVntKCCmjFtJ41cgDZAxzxLFAZ7WoSq55Cwd oBkCHAqo+Fu3BLBii+rUlnpvkYsUG9OCSU97KQ8b27Odk4aLEAUVpUKxzgjJGrDR u7pLLPjCo+d0f5g8aF+H2cuadcDlkg== =UXLK -----END PGP SIGNATURE----- --7wgc3lkw2xz54iov--