summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command/_csplit
diff options
context:
space:
mode:
authorAxel Beckert <abe@deuxchevaux.org>2022-04-11 00:17:48 +0200
committerAxel Beckert <abe@deuxchevaux.org>2022-04-11 00:17:48 +0200
commitb09f4483416c54c1782824633dfabaf2ec0265b6 (patch)
tree304bc82642862525ae680c7fbaa249663b10ad57 /Completion/Unix/Command/_csplit
parent12eb3e5356f2fc3351eed58ef1cef1b8fb83b504 (diff)
parent6e55c920503071e917619b8cb1a188cd35d772db (diff)
downloadzsh-b09f4483416c54c1782824633dfabaf2ec0265b6.tar.gz
zsh-b09f4483416c54c1782824633dfabaf2ec0265b6.zip
New upstream version 5.8.1.2-test
Diffstat (limited to 'Completion/Unix/Command/_csplit')
-rw-r--r--Completion/Unix/Command/_csplit51
1 files changed, 51 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_csplit b/Completion/Unix/Command/_csplit
new file mode 100644
index 000000000..5f72232bb
--- /dev/null
+++ b/Completion/Unix/Command/_csplit
@@ -0,0 +1,51 @@
+#compdef csplit
+
+local curcontext=$curcontext cnt_info ret=1
+local -a state state_descr line specs optA
+typeset -A opt_args
+
+# common specs
+specs=(
+ '(hv -f --prefix)'{-f+,--prefix=}'[specify prefix for output file names]:prefix [xx]: '
+ '(hv -n --digits -b --suffix-format)'{-n+,--digits=}'[specify number of digits in output file names]:number [2]: '
+ '(hv -k --keep-files)'{-k,--keep-files}'[do not remove output files on errors]'
+ '(hv -s --quiet --silent)'{-s,--quiet,--silent}'[do not print counts of output file sizes]'
+ '(hv)1: :_files'
+ '(hv)*: :->patterns'
+)
+
+if _pick_variant gnu=GNU unix --version; then
+ # GNU coreutils 8.32
+ specs+=(
+ '(hv -b --suffix-format -n --digits)'{-b+,--suffix-format=}'[specify format for numbers in output file names]:format [%%02d]: '
+ '(hv)--suppress-matched[suppress the lines matching the pattern]'
+ '(hv -z --elide-empty)'{-z,--elide-empty-files}'[remove empty output files]'
+ + hv
+ '(: * -)--help[display help and exit]'
+ '(: * -)--version[output version information and exit]'
+ )
+ cnt_info="(integer or '*')"
+else
+ # POSIX ({Free,Open}BSD, DragonFly, macOS)
+ specs=( ${specs:#(|*\))--*} ) # remove long options
+ optA=( -A '-?*' ) # a single '-' is a valid file name (stdin)
+fi
+
+_arguments -C -s -S $optA : $specs && ret=0
+
+case $state in
+ patterns)
+ if compset -P '(/?*/|%?*%)'; then
+ _message '[+|-]offset' && ret=0
+ elif compset -P '[/%]'; then
+ _message 'regex' && ret=0
+ elif compset -P '(|\\){'; then
+ _message "count $cnt_info" && ret=0
+ elif compset -P '[0-9]*'; then
+ _message 'line number' && ret=0
+ elif [[ ${words[CURRENT]} != -* ]] then
+ _message "line_number, '/regex/[offset]', '%%regex%%[offset]', or '{count}'" && ret=0
+ fi
+esac
+
+return ret