zsh-workers
 help / color / mirror / code / Atom feed
From: "Nikolai Weibull" <now@bitwi.se>
To: "Oliver Kiddle" <okiddle@yahoo.co.uk>
Cc: "Zsh Workers" <zsh-workers@sunsite.dk>
Subject: Re: rm(1) completion definition
Date: Wed, 8 Oct 2008 11:29:40 +0200	[thread overview]
Message-ID: <dbfc82860810080229w33a766dao21cff080f012ad5a@mail.gmail.com> (raw)
In-Reply-To: <dbfc82860810010621sd44b17fifbeadd4789831976@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 900 bytes --]

On Wed, Oct 1, 2008 at 15:21, Nikolai Weibull <now@bitwi.se> wrote:

> On Wed, Oct 1, 2008 at 11:38, Oliver Kiddle <okiddle@yahoo.co.uk> wrote:

>> Nikolai Weibull wrote:

>>> 1.  It seems that my trick to disable --force and --recursive on
>>> non-GNU systems doesn't work.

>> This is better done as:
>>  args=( ${args:#*--(force|recursive)\[*} )

> Thanks, will change to that.

Done.

>> The right way to do this would be to work out exactly what can't be
>> completed and build up a suitable glob pattern to pass to _files with
>> -g.
>
> Ugh.  That sounds complicated.

Done.

>> One other point: I really hope that running rm --version can't possibly
>> actually result in a file or files being removed on some system. I'm a
>> bit uneasy about it. Perhaps you should try using rm --help instead
>> because there's no `r' in help.

> OK, sounds reasonable.

Done.

How about including it now?

[-- Attachment #2: _rm --]
[-- Type: application/octet-stream, Size: 1414 bytes --]

#compdef rm

declare -a opts args
args=(
  '(-f --force)'{-f,--force}'[ignore nonexistent files, never prompt]'
  '(-I --interactive)-i[prompt before every removal]'
  '(-r -R --recursive)'{-r,-R,--recursive}'[remove directories and their contents recursively]'
  '*:files:->file'
)
if _pick_variant gnu=gnu unix --help; then
  opts+=(-S)
  args+=(
    '(-i --interactive)-I[prompt when removing many files]'
    '(-i -I)--interactive=-[prompt under given condition (defaulting to always)]::when:((once\:"prompt when removing many files"
                                                                                         always\:"prompt before every removal"))'
    '--one-file-system[stay within filesystems of files given as arguments]'
    '(                   --preserve-root)--no-preserve-root[do not treat / specially]'
    '(--no-preserve-root                )--preserve-root[do not remove / (default)]'
    '(-v --verbose)'{-v,--verbose}'[explain what is being done]'
    '(- *)--help[display help message and exit]'
    '(- *)--version[output version information and exit]'
  )
else
  args=(${args:#*--(force|recursive)\[*})
fi

local curcontext=$curcontext state line ret=1
declare -A opt_args

_arguments -C $opts \
  $args && ret=0

case $state in
  (file)
    declare -a ignored
    ignored=(${line//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH})
    _path_files -F ignored && ret=0
    ;;
esac

return $ret

      reply	other threads:[~2008-10-08  9:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-30 21:03 Nikolai Weibull
2008-10-01  9:38 ` Oliver Kiddle
2008-10-01 13:21   ` Nikolai Weibull
2008-10-08  9:29     ` Nikolai Weibull [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=dbfc82860810080229w33a766dao21cff080f012ad5a@mail.gmail.com \
    --to=now@bitwi.se \
    --cc=okiddle@yahoo.co.uk \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.vuxu.org/mirror/zsh/

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).