help / color / mirror / code / Atom feed
From: Vorpal <zsh@vorpal.se>
To: zsh-workers@zsh.org
Subject: [Bug] Errors in find completion
Date: Wed, 6 Apr 2022 17:54:52 +0200	[thread overview]
Message-ID: <2012c0c3-78e0-7116-0972-6121d3c68203@vorpal.se> (raw)


While implementing completion for an alternative to find I found some
bugs in the standard completion file for find (Completion/Unix/_find)
that I was using as a reference when doing my implementation.

These were things that were incorrect on my Arch Linux system using GNU
find. They may or may not be correct for other find implementations.

1. Missing handling of -newerXY:

 From the man page:


-newerXY reference
         Succeeds if timestamp X of the file being considered is newer
than timestamp Y of the file reference.  The letters X and Y can be any
of the following letters:

         a   The access time of the file reference
         B   The birth time of the file reference
         c   The inode status change time of reference
         m   The modification time of the file reference
         t   reference is interpreted directly as a time

         Some combinations are invalid; for example, it is invalid for X
to be t.  Some combinations are not implemented on all systems; for
example B is not supported on all systems.  If an invalid or
unsupported  combination of  XY is specified, a fatal error results.
Time specifications are interpreted as for the argument to the -d option
of GNU date.  If you try to use the birth time of a reference file, and
the birth time cannot be determined, a fatal error message results.  If
you specify a test which refers to the birth time of files being
examined, this test will fail for any files where the birth time is


I suggest the following addition to find implementations that support
this option:

'*-newer'{a,B,c,m}{a,B,c,m}'[succeeds if timestamp 1 is newer than 
timestamp 2 of FILE]:reference file:_files'
'*-newer'{a,B,c,m}t'[succeeds if timestamp 1 is newer than 

However! I'm not sure if ->times is correct. The code for that state is
a bit cryptic to me, and I don't know if -newerXt supports quite the
same things as other time parameters.

It is also possible that you want to rewrite this to make the help text
more specific to each entry.

2. Incorrect handling of -exec, -execdir, -ok etc:

These completion entries are on the following form:
'*-exec:program: _command_names -e:*\;::program arguments: _normal'

However it is not only ; that will terminate arguments to the program in
question. + also works. The difference is that ; will only pass a single
argument per invocation while + passes as many as will fit on the
command line.

Thus a more correct line would be:
'*-exec:program: _command_names -e:*(\;|+)::program arguments: _normal'

Similar changes must also be made for -execdir, -ok and -okdir

Best regards,
Arvid Norlander

             reply	other threads:[~2022-04-06 15:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06 15:54 Vorpal [this message]
2022-04-06 21:11 ` Bart Schaefer
2022-04-06 21:39   ` Vorpal
2022-04-06 22:07   ` Lawrence Velázquez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2012c0c3-78e0-7116-0972-6121d3c68203@vorpal.se \
    --to=zsh@vorpal.se \
    --cc=zsh-workers@zsh.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).