From: Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
To: zsh-workers@sunsite.auc.dk (Zsh hackers list)
Subject: _cpio
Date: Sun, 25 Mar 2001 21:41:59 +0100 [thread overview]
Message-ID: <20010325204200.076C8139CA@pwstephenson.fsnet.co.uk> (raw)
This is probably suboptimal, but it's about time we had one.
Why do I need the * before the destination directory completion for -p? It
should work with a 1 or just the bare colon, but for some reason it doesn't
for me.
Index: Completion/User/_cpio
===================================================================
RCS file: _cpio
diff -N _cpio
--- /dev/null Mon Dec 11 17:26:27 2000
+++ _cpio Sun Mar 25 12:39:57 2001
@@ -0,0 +1,143 @@
+#compdef cpio
+
+(( $+_is_gnu )) || typeset -gA _is_gnu
+
+local cmd=$service args ig context curcontext="$curcontext" state line opt_args
+local expl ret
+local fmts='(bar bin odc newc crc tar ustar hpbin hpodc)'
+
+if (( ! $+_is_gnu[$cmd] )); then
+ if [[ $(_call version $cmd --version </dev/null 2>/dev/null) = *GNU* ]]
+ then
+ _is_gnu[$cmd]=yes
+ else
+ _is_gnu[$cmd]=
+ fi
+fi
+ig=$_is_gnu[$cmd]
+
+if (( $CURRENT == 2 )); then
+ # Complete arguments
+ args=('-o[create archive]' '-i[extract from archive]'
+ '-p[run as filter on directory tree]')
+ [[ -n $ig ]] && args=($args '--create[create archive]'
+ '--extract[extract from archive]'
+ '--pass-through[run as filter on directory tree]'
+ '--help[show help text]' '--version[show version information]')
+else
+ if [[ -n ${words[(r)(-o*|-[^-]*o*|--create)]} ]]; then
+ # Optiona for creating archive
+ if [[ -n $ig ]]; then
+ args=(
+ '--file=:archive file:->afile'
+ "--format=:format type:$fmts"
+ '--message=:message at end of volume:'
+ '--null' '--reset-access-time'
+ '--verbose' '--dot' '--append'
+ '--block-size=:block size in 512 byte units:'
+ '--dereference'
+ '--io-size=:block size in bytes'
+ '--quiet' '--force-local' '--help' '--version')
+ fi
+ args=($args
+ '-A[append files to archive]'
+ '-B[block size 5120 bytes with special file]'
+ '-C[set block size per record]:block size in bytes:(8192)'
+ '-F[set archive file to use]:archive file:->afile'
+ '(-H)-c[read/write header in ASCII]'
+ "(-c)-H[set format type for archive header]:$fmts"
+ '-L[follow symbolic links]'
+ '-M[print message at end of volume]:message to print:'
+ '-O[set output archive file]:output archive file:_files'
+ )
+ elif [[ -n ${words[(r)(-i*|-[^-]*i*|--extract)]} ]]; then
+ if [[ -n $ig ]]; then
+ args=('--file=:archive file:->afile'
+ "--format=:format type:$fmts"
+ '--make-directories' '--nonmatching'
+ '--preserve-modification-time' '--numeric'
+ '--rename' '--list' '--swap-bytes' '--swap-halfwords'
+ '--dot' '--unconditional' '--verbose'
+ '--block-size=:block size in 512 byte units:'
+ '--swap-halfwords'
+ '--io-size=:block size in bytes:'
+ '--pattern-file=:file with list of patterns:_files'
+ '--owner=:user (and group) for files:->user' '--no-preserve-owner'
+ '--message=:message at end of volume:'
+ '--force-local'
+ '--no-absolute-filenames' '--sparse' '--only-verify-crc'
+ '--quiet' '--help' '--version')
+ fi
+ args=($args
+ '-b[reverse bytes in word]'
+ '-B[block size 5120 bytes with special file]'
+ '-d[create directories as needed]'
+ '-C[set block size per record]:block size in bytes:(8192)'
+ '-E[read filenames from file]:file name for list of files:_files'
+ '-f[only copy files not matching patterns]'
+ '-F[set archive file to use]:archive file:->afile'
+ '(-H)-c[read/write header in ASCII]'
+ "(-c)-H[set format type for archive header]:$fmts"
+ '-I[set input archive file]:input archive file:_files'
+ '-m[preserve file modification times]'
+ '-M[print message at end of volume]:message to print:'
+ '-n[show UID and GID numerically]'
+ '-r[interactively rename files]'
+ '-R[set user and group for files]:user (and group) for files:->user'
+ '-s[swap bytes within each halfword]'
+ '-S[swap bytes within each word]'
+ '-t[print a table of contents]'
+ '*:pattern to extract'
+ )
+ elif [[ -n ${words[(r)(-p*|-[^-]*p*|--pass-through)]} ]]; then
+ if [[ -n $ig ]]; then
+ args=('--null' '--reset-access-time' '--make-directories'
+ '--link' '--quiet' '--preserve-modification-time'
+ '--unconditional' '--verbose' '--dot' '--dereference'
+ '--owner=:user (and group) for files:->user'
+ '--no-preserve-owner' '--sparse' '--help' '--version')
+ fi
+ args=($args
+ '-d[create directories as needed]'
+ '-l[link files instead of copying]'
+ '-L[follow symbolic links]'
+ '-m[preserve file modification times]'
+ '-R[set user and group for files]:user (and group) for files:->user'
+ '*:destination directory:_files -/'
+ )
+ else
+ return 1
+ fi
+ args=($args
+ '-a[reset access time of input files]'
+ )
+fi
+
+ret=1
+_arguments -s "$args[@]" && ret=0
+
+if [[ $state = afile ]]; then
+ if compset -P '*:'; then
+ # TODO: doesn't need to be rsh.
+ _wanted files expl 'remote files' \
+ compadd $(rsh ${words[CURRENT]%:*} echo ${words[CURRENT]#*:}\*) && ret=0
+ elif compset -P '*@'; then
+ _wanted hosts expl 'remote host name' _hosts && ret=0
+ else
+ _alternative \
+ 'files:: _files' \
+ 'hosts:remote host name:_hosts -S:' \
+ 'users:user name:_users -qS@' && ret=0
+ fi
+elif [[ $state = user ]]; then
+ if compset -P '*[:.]'; then
+ _groups
+ else
+ local suf=.
+ [[ $OSTYPE = (solaris|hpux)* ]] && suf=:
+ compset -S '.*' && unset suf
+ _users -S "$suf" -q
+ fi
+fi
+
+return ret
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
Work: pws@csr.com
Web: http://www.pwstephenson.fsnet.co.uk
next reply other threads:[~2001-03-25 20:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-25 20:41 Peter Stephenson [this message]
2001-03-26 11:10 _cpio Sven Wischnowsky
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=20010325204200.076C8139CA@pwstephenson.fsnet.co.uk \
--to=pws@pwstephenson.fsnet.co.uk \
--cc=zsh-workers@sunsite.auc.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).