diff options
Diffstat (limited to 'Completion/Unix/Command/_awk')
| -rw-r--r-- | Completion/Unix/Command/_awk | 134 |
1 files changed, 116 insertions, 18 deletions
diff --git a/Completion/Unix/Command/_awk b/Completion/Unix/Command/_awk index c493c3b04..a3b242295 100644 --- a/Completion/Unix/Command/_awk +++ b/Completion/Unix/Command/_awk @@ -1,21 +1,119 @@ -#compdef awk +#compdef awk gawk -# completions for awk -# This only aims to complete POSIX awk options, as described in -# awk(P). Most awk implementations, such as gawk and mawk, will have -# additional options that this does not complete. Also, currently -# this completion does not allow everything that POSIX allows. For -# example, awk(P) states that the user may specify assignments -# without using the -v option; this does not support that. +# For gawk ver.3 and 4, in addition to POSIX. # -# In addition, the "program text" completion is not perfect. For -# instance, type "awk -" and then hit tab. You will be presented -# both with the dashed options and with the "program text" option. -# Fixing this is beyond my current _arguments expertise--help -# appreciated. +# gawk's options '-W ...' (such as '-W help') are not supported. +# gawk3 has some synomyms for long options (e.g., --compat is a synomym +# for --traditional). These are not supported either. +# +# 'gawk -f<TAB>' will complete files in AWKPATH in addition to those in +# the current directory. If this is annoying, you may try +# zstyle ':completion:*:*:gawk:option-f-1:*' tag-order program-files + +local variant curcontext="$curcontext" state state_descr line ret=1 +local -A opt_args +local -a args + +_pick_variant -r variant gawk4='GNU Awk 4' gawk3='GNU Awk 3' posix --version + +args=( + {-F+,--field-separator}'[define input field separator by extended regex]:extended regular expression:' + '*'{-v+,--assign}'[assign values to variables]:assignment:' + '(1)*'{-f+,--file}'[read program file]:program file:->script' + '1: :_guard "^-*" "program text"' + '*:input files:_files' +) + +case $variant in + (gawk*) + args+=( + {-c,--traditional}'[run in compatibility mode]' + '(- : *)'{-C,--copyright}'[print copyright info and exit]' + {-d-,--dump-variables=-}'[print a sorted list of global variables]::output file:_files' + {-e,--source}'[pass program text in arg]:program text:' + '(1)'{-E+,--exec}'[like -f, but safer for CGI]:program file:->script' + '(- : *)'{-h,--help}'[print usage message and exit]' + {-L-,--lint=-}'[warn about dubious or non-portable constructs]::flag:((fatal\:"treat warnings as fatal error" invalid\:"warn only about thigs that are actually invalid"))' + {-n,--non-decimal-data}'[auto-detect octal/hexadecimal values in input]' + {-N,--use-lc-numeric}"[force use of locale's decimal point character]" + {-O,--optimize}'[enable optimization]' + {-p-,--profile=-}'[output profiling data to file]::output file:_files' + {-P,--posix}'[run in strict POSIX mode]' + {-r,--re-interval}'[enable interval expressions in regex matching]' + {-t,--lint-old}'[warn about non-portable constructs]' + '(- : *)'{-V,--version}'[print version info and exit]' + ) + ;| + (gawk4) + args+=( + {-b,--characters-as-bytes}'[treat all input data as single-byte characters]' + {-D-,--debug=-}'[enable debugging]::debugger command file:_files' + {-g,--gen-pot}'[scan awk program and generate .po file on stdout]' + '*'{-i+,--include}'[load source library]:library file:->script' + '*'{-l+,--load}'[load dynamic extension]:extension:-> |
