Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: search XDG_DATA_DIRS in _setxkbmap completion
- X-seq: zsh-workers 43492
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Maximilian Bosch <maximilian@xxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: PATCH: search XDG_DATA_DIRS in _setxkbmap completion
- Date: Tue, 18 Sep 2018 19:32:52 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=nz2zVk iHnIWj1XcOIeHbtZAZHKPB0VI1jkYGAjJvVmI=; b=cjNMufPtQy768L9d/T4fDA KR5NU5tuaQaN/k7h8C+94V6fuJYcBfV8nWBIWpopbEZmo7fsvPSPPEvBumUyHJv3 /GGqkLh2AdMvp5D9oZgnk0log2b3YpeI8BLcZ51NraR5MyJQ0de4qHRgqG4aLjNE TChtBFYMjOjvSlSyoVs5OZrLFbX1sWBJAMghAY4V8MD4J4My6TbEr+cF5FyHQv/5 IkmJj4vHLVNM5yjsxmwW5AJJw9TJxS8i/RVHJqrfjuq36yTMTS3DoV2hA0+qPRdh 8egasBOTzXI1qu354YLHSGl3iFpPH20kxMigePCwENWNoSM6OWF/Wz61IVaUj4jA ==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=nz2zVk iHnIWj1XcOIeHbtZAZHKPB0VI1jkYGAjJvVmI=; b=rzBkWnBpQqWw3mtrJ+bxad k9ZG63LKBhXM9JY6XA738cxBhPY2cb3HiKoTL/c9kyWe/61wZ9RczzF+XMxd0Nt9 c34iw+AGZgfVvewVR9q/c7Aj6qu8uPci3XnEOkEiibh8Bbe3ilCdvVVNtdRMjnpN Bai/5casl0w1y/0S1p0JYpVp6cpoxkyWVz/DFDmqN3BK5yTfteWCPhTlHuei42Ll XpsMTRhBWPxCtSoSuI/pxY4IOXBa5w9w90l9UFO9clhO+LNOuW4d8jdcyTsOodt+ UoxJA7tizU6/p/9pCAPzkezjK5RZlx4Awjfze8+ldqbtOASpCcBK9wbQBNjm0pnQ ==
- In-reply-to: <20180918190516.2w3tyiugdmx6wzqw@hauptschuhle>
- 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: <20180918124951.4nbyjhbuqnkioqrt@hauptschuhle> <1537287030.1158541.1512325000.0C43F9DE@webmail.messagingengine.com> <20180918190516.2w3tyiugdmx6wzqw@hauptschuhle>
Maximilian Bosch wrote on Tue, 18 Sep 2018 21:05 +0200:
> Thanks a lot for your feedback!
>
> 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
>
You're welcome.
> I applied your suggestions and re-checked the patch.
>
> > How should empty array elements in XDG_DATA_DIRS be handled? E.g.,
> > XDG_DATA_DIRS=/foo:/bar::/baz ?
>
> Isn't this handled by `[ -d $fullname ]`?
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.
> +++ b/Completion/X/Command/_setxkbmap
> @@ -9,10 +9,12 @@ _setxkbmap() {
> setopt extendedglob
>
> # 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=$dir
> + local dir sourcedir fullname
> + local searchdirs="${XDG_DATA_DIRS:-/usr/lib:/usr/share:/usr/local/lib:/usr/local/share}:${XDG_DATA_HOME:-~/.local/share}"
Two tweaks here:
1. XDG_DATA_HOME should be listed before XDG_DATA_DIRS, according to
the XDG spec.
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:
local -a searchdirs=( ${XDG_DATA_HOME:-...} ${(s.:.)XDG_DATA_DIRS:-...} )
for dir in $searchdirs; do
> + for dir in ${(s.:.)searchdirs}; do
> + fullname="$dir/X11/xkb"
> + if [ -d $fullname ] ; then
> + sourcedir=$fullname
> break
> fi
> done
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author