Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: completion utility functions that take options generally do not work
- X-seq: zsh-workers 54667
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: completion utility functions that take options generally do not work
- Date: Wed, 3 Jun 2026 21:07:09 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TNXiWfTCnOhzgpi15YWGHgyai/2X7lI1gxnOwj7tBeM=; fh=ypR9UOQG+mY/0DncH1Wy+ARUWZ4koA9IfxljZur8JTc=; b=Fu97mZWLDOFVmSc1IMnRnN/g0Y5GhBs4Nyjz655QT5lQ5kwz+iJxvhQkaRTkiyAHoO J+CKs3H9IoW+GdLwaIPPIF9/NXWJiB197egUhPxyVQz0iy39iYmBMRDV/YeWkbS8yj/4 6B/pZ57r635qvh5iT2TpNROeVrO4+icqNbDPeEUBFemyn2Ez05fBEaF/zzslmIjgp39n /VGMCFdKmFCaW9OhMFYuQBC8OirE8gVfcQ+v/VaEb8a2qZxkKDFwYnfxPS3hoIweiTue CkDhzWt1V5VYwi6FBNgT2TqF4Hdg4Rlg9pYsJM2gMthI2L4P6Ajn8zis1ny00YsDoGXy pAug==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1780546040; cv=none; d=google.com; s=arc-20240605; b=T84MdPd/GXtNeoWPlW/MFBOdPMa8mEs6RktK6X2NPFP8KQG07bIHb8CvrTeATKx1qp k2TxjvDgRYzFLQzJBAj9nYu3sXxIzKQF2aB4VYVESHiH0Fu7QAZTa6+jsMYCnJI/RYyA k6K6Rwm1d+tN/zj5iAolH76DzxU8CoFjGeu/WgbACjkKrXwd9EdoFQk7gmCzQzWPbfHZ cWZ89y3oeeKDeXMzb4tKp2vQV7tKp3KDBnDa1izbgC1U8QE3Dh6HFQxyJUPN+2mLq9dg 0pqepoMgc+C2yXqtf969b8F6dHbG8dNOEUX0A70ge0RQefTnQmaJ/qvNVACgaSJXcsfT mvPA==
- Archived-at: <https://zsh.org/workers/54667>
- In-reply-to: <CAHYJk3QqNof4mS3zUcZaB8=kuVkACaRL9d_wKO-TTXe27x8jHg@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAHYJk3QqNof4mS3zUcZaB8=kuVkACaRL9d_wKO-TTXe27x8jHg@mail.gmail.com>
On Wed, Jun 3, 2026 at 6:01 PM Oliver Kiddle <opk@xxxxxxx> wrote:
>
> This is a change I've used privately for a while and Mikael's recent
> post about utility functions taking compadd options reminded me.
Thanks for mentioning that, it reminded me that I intended to reply here.
On Mon, May 25, 2026 at 1:52 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> When you call a utility function from _arguments, like this (this is a
> bad example, it's only used on IRIX):
> '-b[mount all filesystems in /etc/fstab except those
> listed]:mount point:_dir_list -s,'
> _arguments helpfully adds some compadd options to the argument list
> for you to pass on to compadd "$@". However, it adds these between the
> first word and the rest of the words, so the resulting command would
> be something like _dir_list -J mygroup -1 -s or so.
[...]
> If you add a space after the colon in your _arguments spec, then it
> will not add the compadd options, and the argument parsing in the
> utility function will work. But since it doesn't add the compadd
> options, the compadd calls will obviously pass on an empty "$@", this
> would also not be great, plus we'll never get anyone to remember to
> add this space.
>
> I'm not sure if there's an obvious solution here, unfortunately.
It would mean a small amount of rewriting in each of a number of
functions, but could we eliminate the the literal compadd "$@"
practice entirely and instead pass the compadd arguments around in a
"localized global" array, after the manner of curcontext? _arguments
does that kind of thing already when supplying "$expl[@]".
For the utilities that already work mostly correctly, it would (I
think) primarily be a matter of adding
local -a compaddargs=( "$compaddargs[@]" )
and then after the utility's own arguments have been interpreted do
set -- "$compaddargs[@]"
and thereafter compadd "$@" works as previously expected.
I haven't thoroughly reviewed the 113 files that might need this
editing, so perhaps there's a flaw in this approach.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author