From c749a06bc9f15b5153d55b7f5e6f9a3a252e39f6 Mon Sep 17 00:00:00 2001 From: dana Date: Mon, 1 Apr 2019 14:42:07 -0500 Subject: 44158: Completion: Add _postgresql Adjusted to fix minor copy/paste error in __pgsql_cfg_params --- Completion/Unix/Command/_postgresql | 1148 +++++++++++++++++++++++++++++++++++ 1 file changed, 1148 insertions(+) create mode 100644 Completion/Unix/Command/_postgresql (limited to 'Completion/Unix/Command/_postgresql') diff --git a/Completion/Unix/Command/_postgresql b/Completion/Unix/Command/_postgresql new file mode 100644 index 000000000..f0c70a164 --- /dev/null +++ b/Completion/Unix/Command/_postgresql @@ -0,0 +1,1148 @@ +#compdef clusterdb createdb createuser dropdb dropuser initdb pg_config pg_ctl pg_dump pg_dumpall pg_isready pg_restore pg_upgrade postgres postmaster psql reindexdb vacuumdb + +# Notes: +# - @todo We don't complete postgres:// URIs or conninfo strings, and we don't +# account for postgres:// URIs when calling psql +# - @todo We don't handle a few less-used tools like ecpg and pgbench +# - @todo We don't handle Debian's wrapper tools (pg_ctlcluster, &al.) + +# Construct conninfo string for use with completion helper functions +# +# -o => include only specified parameters +# -O => exclude specified parameters +# $1 => scalar parameter to store result in (conninfo by default) +# +# Explanation: +# +# Postgres supports a dizzying number of ways to specify connection parameters; +# in roughly ascending order of precedence, they are (where applicable): +# +# - PG* environment variables +# - Database name as first operand +# - User name as second operand +# - Options -d/-h/-p/-U +# - Conninfo string as first operand +# - URI as first operand -- authority/path component +# - URI as first operand -- query component +# +# The following command demonstrates four ways to pass the user name: +# +# PGUSER=foo1 psql 'postgres://foo2@localhost/mydb?user=foo3' -U foo4 +# +# In this case, per the above, the query component of the URI wins, and foo3 +# gets used. +# +# Many connection parameters can only be supplied via conninfo string, URI, or +# environment variable. Thus, in order for our helper functions to accurately +# obtain completion possibilities, it's preferable to normalise the various +# methods of supplying parameters. Since conninfo strings are easiest to +# construct, we'll use those. +# +# See also: +# +# - https://www.postgresql.org/docs/current/static/libpq-envars.html +# - https://www.postgresql.org/docs/current/static/libpq-connect.html +# - https://github.com/postgres/postgres/blob/master/src/bin/psql/startup.c +(( $+functions[__pgsql_get_conninfo] )) || +__pgsql_get_conninfo() { + local i_ + local -a conninfo_ + local -aU incl_ excl_ + + zparseopts -D -E -- o+:-=incl_ O+:-=excl_ + + (( $#incl_ )) && + incl_=( ${(@s<,>)${(@)${(@)incl_#-o}//[[:punct:][:space:]]/,}} ) + (( $#excl_ )) && + excl_=( ${(@s<,>)${(@)${(@)excl_#-O}//[[:punct:][:space:]]/,}} ) + + # Parameters supplied via options. We must quote parameter values for conninfo + # strings like foo='bar\'baz'. Should we also handle -l/--maintenance-db here? + [[ -n ${opt_args[(i)c-(-d|--dbname)]} ]] && + conninfo_+=( dbname="'${(Q)${(v)opt_args[(i)c-(-d|--dbname)]}//\'/\\\'}'" ) + [[ -n ${opt_args[(i)c-(-h|--host)]} ]] && + conninfo_+=( host="${(Q)${(v)opt_args[(i)c-(-h|--host)]}//\'/\\\'}'" ) + [[ -n ${opt_args[(i)c-(-p|--port)]} ]] && + conninfo_+=( port="'${(Q)${(v)opt_args[(i)c-(-p|--port)]}//\'/\\\'}'" ) + [[ -n ${opt_args[(i)c-(-U|--user)]} ]] && + conninfo_+=( user="'${(Q)${(v)opt_args[(i)c-(-U|--user)]}//\'/\\\'}'" ) + + # Parameters supplied via operands -- since these have such a high precedence + # they can't do much for completing the above options, but they're still + # useful for the helper functions + case ${(Q)line[1]} in + # First operand is URI + postgres(ql|)://*) + # @todo To parse this properly we need to handle percent-encoding; it + # might be nice to have a utility function for that some day + ;; + # First operand is conninfo string. The user should have already properly + # quoted any parameter values here, so we don't need to re-quote + *'='*) + conninfo_+=( ${(z)${(Q)line[1]}} ) + # Normalise parameter pairs (note that empty values must be quoted) + for (( i_ = 1; i_ < $#conninfo_; i_++ )); do + # Parameter pair already one word (`param=value`) + if [[ $conninfo_[i_] == *?'='?* ]]; then + continue + # Parameter pair in three words (`param = value`) + elif [[ $conninfo_[(i_+1)] == '=' ]]; then + conninfo_[i_]+="=${conninfo_[(i_+2)]}" + conninfo_[(i_+1)]= + conninfo_[(i_+2)]= + (( i_ += 2 )) + # Parameter pair in two words (`param= value` or `param =value`) + else + conninfo_[i_]+=${conninfo_[(i_+1)]} + conninfo_[(i_+1)]= + (( i_ += 1 )) + fi + done + conninfo_=( $conninfo_ ) + ;; + # First and second operands may be database/user + *) + (( $+line[1] )) && conninfo_+=( dbname="'${(Q)line[1]//\'/\\\'}'" ) + (( $+line[2] )) && conninfo_+=( user="'${(Q)line[2]//\'/\\\'}'" ) + ;; + esac + + (( $#conninfo_ && $#incl_ )) && + conninfo_=( ${(M@)conninfo_:#(${(~j<|>)incl_})=*} ) + (( $#conninfo_ && $#excl_ )) && + conninfo_=( ${(@)conninfo_:#(${(~j<|>)excl_})=*} ) + + : ${(P)${1:-conninfo}::=${(j< >)conninfo_}} + return $(( $#conninfo_ ? 0 : 1 )) +} + +# Call psql and return results +# -f => keep empty lines +# $1 => array parameter to store results in +# $2 => _call_program tag +# $3 => preferred conninfo string (use '' if none) +# $4 ... => arguments to psql (usually -c ...); automatically quoted for eval +__pgsql_call_psql() { + local c_ f_ psql_=psql + local -a tmp_ + + [[ $1 == -f ]] && { + f_=1 + shift + } + + (( $# >= 4 )) || { + print -ru2 "$0: bad argument count" + return 1 + } + + # Use the psql from the command line if we can + [[ $service == psql ]] && psql_=$words[1] + + # Make a few attempts with common settings in case the first fails. Maybe this + # behaviour could be controlled by a user style + for c_ in $3{,' dbname=template1',' dbname=template1 user=postgres'}; do + c_+=' connect_timeout=4' + tmp_=( "${(@f)"$( + _call_program $2 $psql_ -qtAX ${(q)c_} ${(@q)@[4,-1]} + )"}" ) + (( f_ )) || tmp_=( $tmp_ ) + (( $#tmp_ )) && break + done + + : ${(PA)1::="${(@)tmp_}"} + return $(( $#tmp ? 0 : 1 )) +} + +# Complete PostgreSQL authentication methods +(( $+functions[__pgsql_auth_methods] )) || +__pgsql_auth_methods() { + # See https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html + local -a tmp=( + 'trust:allow unconditionally' + 'reject:reject unconditionally' + 'scram-sha-256:authenticate via SCRAM-SHA-256 challenge-response' + 'md5:authenticate via MD5 or SCRAM-SHA-256 challenge-response' + 'password:authenticate via clear-text password' + 'gss:authenticate via GSSAPI (TCP/IP only)' + 'sspi:authenticate via SSPI (Windows only)' + 'ident:authenticate via ident user name (TCP/IP only; local peer fall-back)' + 'peer:authenticate via local OS user name (local only)' + 'ldap:authenticate via LDAP' + 'radius:authenticate via RADIUS' + 'cert:authenticate via SSL client certificate' + 'pam:authenticate via PAM' + 'bsd:authenticate via BSD Authentication' + ) + _describe -t auth-methods 'PostgreSQL authentication method' tmp "$@" +} + +# Complete PostgreSQL run-time configuration parameters +(( $+functions[__pgsql_cfg_params] )) || +__pgsql_cfg_params() { + local conninfo + local -a expl tmp + + __pgsql_get_conninfo + __pgsql_call_psql tmp parameters "$conninfo" -c ' + SELECT name + FROM pg_catalog.pg_settings; + ' + + _wanted -x parameters expl 'PostgreSQL run-time configuration parameter' \ + compadd -a "$@" - tmp +} + +# Complete PostgreSQL run-time configuration parameters (name=value format) +(( $+functions[__pgsql_cfg_params_values] )) || +__pgsql_cfg_params_values() { + if compset -P '*='; then + _message -e values 'PostgreSQL run-time configuration-parameter value' + else + compset -S '=*' + __pgsql_cfg_params "$@" -qS= + fi +} + +# Complete PostgreSQL character encodings +(( $+functions[__pgsql_encodings] )) || +__pgsql_encodings() { + # These rarely change, and they're most needed when creating a new database, + # so trying to pull them from an existing one doesn't seem that helpful; see + # https://www.postgresql.org/docs/current/static/multibyte.html#CHARSET-TABLE + local -a expl tmp=( + BIG5 {WIN,Windows}950 + EUC_{CN,JP,JIS_2004,KR,TW} + GB18030 + GBK {WIN,Windows}936 + ISO_8859_{5..8} + JOHAB + KOI8{,R,U} + LATIN{1..10} ISO8859{{1..4},9,10,{13..16}} + MULE_INTERNAL + SJIS Mskanji ShiftJIS {WIN,Windows}932 + SHIFT_JIS_2004 + SQL_ASCII + UHC {WIN,Windows}949 + UTF8 Unicode + WIN{866,874,{1250..1258}} ALT WIN ABC TCVN{,5712} VSCII + ) + _wanted encodings expl 'PostgreSQL character encoding' compadd -a "$@" - tmp +} + +# Complete PostgreSQL server hosts +# -/ => exclude TCP/IP hosts (include directories only) +# -a => include UNIX-domain socket directories +(( $+functions[__pgsql_hosts] )) || +__pgsql_hosts() { + local -a copts tmp alts + local -A opts + + # We want the compadd options from _sequence, but -J screws with grouping + zparseopts -A opts -D -E -- / a J: + copts=( "$@" ) + + (( $+opts[-/] )) || { + tmp=( ${(s<,>)PGHOST} $${(s<,>)PGHOSTADDR} ) + (( $#tmp )) && alts+=( + "hosts:PostgreSQL server host:(${(j< >)${(@uq-)tmp}})" + ) + alts=( 'hosts:PostgreSQL server host:_hosts' ) + } + (( $+opts[-/] || $+opts[-a] )) && alts+=( + 'directories:PostgreSQL UNIX-domain socket directory:_directories' + ) + + _alternative -O copts $alts +} + +# Complete sequence of PostgreSQL host addresses and directories +(( $+functions[__pgsql_hosts_seq] )) || +__pgsql_hosts_seq() { + local -a opts + zparseopts -a opts -D -E -- / a + _sequence "$@" -s , __pgsql_hosts "${(@)opts}" +} + +# Complete PostgreSQL server port numbers +(( $+functions[__pgsql_ports] )) || +__pgsql_ports() { + local -a tmp=( + $PGPORT $PGPORTOLD $PGPORTNEW + 5432 # Customary + /tmp/.s.PGSQL.<->(#qN:e) # Customary + /var/run/postgresql/.s.PGSQL.<->(#qN:e) # Debian/Ubuntu + /var/pgsql_socket/.s.PGSQL.<->(#qN:e) # Weird macOS systems + /var/lib/pgsql/.s.PGSQL.<->(#qN:e) # Weird Linux systems + /var/lib/postgresql/.s.PGSQL.<->(#qN:e) # Weird Linux systems + ) + tmp=( ${(onu)tmp} ) + _wanted -2V ports expl 'PostgreSQL server port' compadd -a "$@" - tmp +} + +# Complete PostgreSQL special variables. This is brittle and over-engineered, +# but it suits the purpose for now +# --pset => complete \pset options +# --set => complete \set options (default) +(( $+functions[__pgsql_variables] )) || +__pgsql_variables() { + local which tmp2 + local -a expl tmp + local -A opts + + zparseopts -A opts -D -E -- -pset -set + + if (( $+opts[--pset] )); then + which=--pset + else + which=--set + fi + + __pgsql_call_psql -f tmp help-variables '' --help=variables + tmp+=( '' ) + + # `psql --help=variables` produces three sections like this: + # psql variables: + # Usage: + # psql --set=NAME=VALUE + # or \set NAME VALUE inside psql + # + # AUTOCOMMIT ... + # Here, we strip up to the --set= line, then remove the next few lines so they + # don't confuse us + tmp2=${${(F)tmp}#*[[:space:]]${which}=*$'\n'} + [[ $tmp2 == [[:space:]]#or\ * ]] && tmp2=${tmp2#*$'\n'} + [[ $tmp2 == [[:space:]]#$'\n'* ]] && tmp2=${tmp2#*$'\n'} + # Now we strip any following sections + tmp2=${tmp2%%$'\n\n'*} + # Now we extract the variable names + tmp=( ${(f)tmp2} ) + tmp=( ${(M)tmp:#\ \ [^[:space:]]##((#e)|[[:space:]]*)} ) + tmp=( ${(@)tmp#\ \ } ) + tmp=( ${(@)tmp%%[[:space:]]*} ) + + _wanted -x variables expl 'PostgreSQL special variable' \ + compadd -a "$@" - tmp +} + +# Complete PostgreSQL special variables (name=value format) +(( $+functions[__pgsql_variables_values] )) || +__pgsql_cfg_variables_values() { + if compset -P '*='; then + _message -e values 'PostgreSQL special-variable value' + else + compset -S '=*' + __pgsql_variables "$@" -qS= + fi +} + +# Complete PostgreSQL databases +(( $+functions[__pgsql_databases] )) || +__pgsql_databases() { + local conninfo + local -a expl tmp + + __pgsql_get_conninfo -O dbname + __pgsql_call_psql tmp databases "$conninfo" -c ' + SELECT datname + FROM pg_catalog.pg_database; + ' + # We can probably just assume that template0/1 will always exist; it's useful + # for database creation, anyway + tmp+=( $PGDATABASE template0 template1 ) + + _wanted databases expl 'PostgreSQL database' compadd -a "$@" - tmp +} + +# Complete PostgreSQL indexes +(( $+functions[__pgsql_indexes] )) || +__pgsql_indexes() { + local conninfo + local -a expl tmp + + __pgsql_get_conninfo + __pgsql_call_psql tmp indexes "$conninfo" -c ' + SELECT indexname + FROM pg_catalog.pg_indexes; + ' + + _wanted -x indexes expl 'PostgreSQL index' compadd -a "$@" - tmp +} + +# Complete PostgreSQL roles/users +# -a => include non-user (NOLOGIN) roles +(( $+functions[__pgsql_roles] )) || +__pgsql_roles() { + local conninfo which=role where + local -a expl tmp + local -A opts + + zparseopts -A opts -D -E -- a + (( $+opts[-a] )) || { + which=user + where='WHERE rolcanlogin = true' + } + + __pgsql_get_conninfo -O user + __pgsql_call_psql tmp users "$conninfo" -c " + SELECT rolname + FROM pg_catalog.pg_roles + $where; + " + tmp+=( $PGUSER ) + + _wanted -x users expl "PostgreSQL $which" compadd -a "$@" - tmp +} + +# Complete PostgreSQL schemas +(( $+functions[__pgsql_schemas] )) || +__pgsql_schemas() { + local conninfo + local -a expl tmp + + __pgsql_get_conninfo + __pgsql_call_psql tmp schemas "$conninfo" -c " + SELECT nspname + FROM pg_catalog.pg_namespace + WHERE nspname NOT LIKE 'pg_%' + AND nspname != 'information_schema'; + " + # Again, safe to assume this exists + tmp+=( public ) + + _wanted schemas expl 'PostgreSQL schema' compadd -a "$@" - tmp +} + +# Complete PostgreSQL tables +(( $+functions[__pgsql_tables] )) || +__pgsql_tables() { + local conninfo + local -a expl tmp + + __pgsql_get_conninfo + __pgsql_call_psql tmp tables "$conninfo" -c " + SELECT n.nspname || '.' || c.relname + FROM pg_catalog.pg_class AS c + LEFT JOIN pg_catalog.pg_namespace AS n + ON n.oid = c.relnamespace + WHERE c.relkind in ('r', '') + AND n.nspname != 'pg_catalog' + AND n.nspname != 'information_schema' + AND n.nspname NOT LIKE 'pg_toast%' + AND pg_catalog.pg_table_is_visible(c.oid); + " + + _wanted -x tables expl 'PostgreSQL table' compadd -a "$@" - tmp +} + +# Complete PostgreSQL tablespaces +(( $+functions[__pgsql_tablespaces] )) || +__pgsql_tablespaces() { + local conninfo + local -a expl tmp + + __pgsql_get_conninfo + __pgsql_call_psql tmp tablespaces "$conninfo" -c ' + SELECT spcname + FROM pg_catalog.pg_tablespace; + ' + # Again, safe to assume these exist + tmp+=( pg_default pg_global ) + + _wanted tablespaces expl 'PostgreSQL tablespace' compadd -a "$@" - tmp +} + +# Complete PostgreSQL text-search configurations +(( $+functions[__pgsql_ts_configs] )) || +__pgsql_ts_configs() { + local conninfo + local -a expl tmp + + __pgsql_get_conninfo + __pgsql_call_psql tmp ts-configs "$conninfo" -c " + SELECT n.nspname || '.' || t.cfgname + FROM pg_catalog.pg_ts_config AS t + LEFT JOIN pg_catalog.pg_namespace AS n + ON t.cfgnamespace = n.oid; + " + # We'll assume these exist since this tends to be needed on cluster init + tmp+=( pg_catalog.simple pg_catalog.english ) + + _wanted ts-configs expl 'PostgreSQL text-search configuration' \ + compadd -a "$@" - tmp +} + +# Complete clusterdb command +(( $+functions[_pgsql_clusterdb] )) || +_pgsql_clusterdb() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options (not actually usable with --all) + $common_opts_connm + + '(d)' # Database connection options + '(a o)'{-d+,--dbname=}'[specify database name]: :__pgsql_databases' + + C # Misc. common options + $common_opts_echo + # -q and -v are NOT exclusive + '(-q --quiet)'{-q,--quiet}'[do not display progress messages]' + '(-v --verbose)'{-v,--verbose}'[display detailed information during processing]' + + a # --all-mode options + '(c d n -a --all)'{-a,--all}'[reindex all databases]' + + n # Normal-mode options + '(a)*'{-t+,--table=}'[cluster specified table only]: :__pgsql_tables' + + o # Operands + '(a d)1: :__pgsql_databases' + ) + _arguments -s -S : $args +} + +# Complete createdb command +(( $+functions[_pgsql_createdb] )) || +_pgsql_createdb() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options + $common_opts_connm + + l # Locale options + '(l)'{-l+,--locale=}'[specify locale (both LC_COLLATE and LC_CTYPE)]: :_locales' + '(-l --locale)--lc-collate=[specify LC_COLLATE setting]: :_locales' + '(-l --locale)--lc-ctype=[specify LC_CTYPE setting]: :_locales' + + o # Other arguments + $common_opts_echo + '(-D --tablespace)'{-D+,--tablespace=}'[specify default tablespace]: :__pgsql_tablespaces' + '(-E --encoding)'{-E+,--encoding=}'[specify character encoding]: :__pgsql_encodings' + '(-O --owner)'{-O+,--owner=}'[specify owner]: :__pgsql_roles -a' + '(-T --template)'{-T+,--template=}'[specify template database to build from]: :__pgsql_databases' + # Possibly not useful to complete existing databases here + '1: :__pgsql_databases' + '2: :_guard "^-*" "database description"' + ) + _arguments -s -S : $args +} + +# Complete createuser command +(( $+functions[_pgsql_createuser] )) || +_pgsql_createuser() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options + $common_opts_conn + + '(d)' # CREATEDB options + {-d,--createdb}'[grant ability to create new databases (CREATEDB)]' + {-D,--no-createdb}'[do not grant ability to create new databases (NOCREATEDB)]' + + '(i)' # INHERIT options + {-i,--inherit}'[grant automatic privilege inheritance from role memberships (INHERIT)]' + {-I,--no-inherit}'[do not grant automatic privilege inheritance from role memberships (NOINHERIT)]' + + '(l)' # LOGIN options + {-l,--login}'[grant ability to log in as user (LOGIN)]' + {-L,--no-login}'[do not grant ability to log in as user (NOLOGIN)]' + + '(r)' # CREATEROLE options + {-r,--createrole}'[grant ability to create new roles (CREATEROLE)]' + {-R,--no-createrole}'[do not grant ability to create new roles (NOCREATEROLE)]' + + '(R)' # REPLICATION options + '--replication[grant replication privileges (REPLICATION)]' + '--no-replication[do not grant replication privileges (NOREPLICATION)]' + + '(s)' # SUPERUSER options + {-s,--superuser}'[grant super-user privileges (SUPERUSER)]' + {-S,--no-superuser}'[do not grant super-user privileges (NOSUPERUSER)]' + + o # Other arguments + $common_opts_echo + '(-c --connection-limit)'{-c+,--connection-limit=}'[specify connection limit for new role]:number of connections' + # No effect, kept for backwards compatibility + '!'{-E,--encrypted} + '*'{-g+,--role=}'[grant membership to specified role]: :__pgsql_roles -a' + '--interactive[prompt for settings not specified on command line]' + '(-P --pwprompt)'{-P,--pwprompt}'[prompt for new user password]' + # Again, possibly not useful to complete these + '1: :__pgsql_roles' + ) + _arguments -s -S : $args +} + +# Complete dropdb command +(( $+functions[_pgsql_dropdb] )) || +_pgsql_dropdb() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options + $common_opts_connm + + o # Other arguments + $common_opts_echo + '(-i --interactive)'{-i,--interactive}'[prompt for confirmation]' + '--if-exists[skip non-existent database]' + '1: :__pgsql_databases' + ) + _arguments -s -S : $args +} + +# Complete dropuser command +(( $+functions[_pgsql_dropuser] )) || +_pgsql_dropuser() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options + $common_opts_conn + + o # Other arguments + $common_opts_echo + '(-i --interactive)'{-i,--interactive}'[prompt for confirmation (and user name if not specified)]' + '--if-exists[skip non-existent user]' + # We could use -a here, but it seems questionable + '1: :__pgsql_roles' + ) + _arguments -s -S : $args +} + +# Complete initdb command +(( $+functions[_pgsql_initdb] )) || +_pgsql_initdb() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + '(l)' # Locale options (general) + {-l+,--locale=}'[specify locale (all catgories)]: :_locales' + '--no-locale[equivalent to --locale=C]' + + lc # Locale options (specific) -- unlike createdb, NOT exclusive with -l + '--lc-collate=[specify LC_COLLATE setting]: :_locales' + '--lc-ctype=[specify LC_CTYPE setting]: :_locales' + '--lc-messages=[specify LC_MESSAGES setting]: :_locales' + '--lc-monetary=[specify LC_MONETARY setting]: :_locales' + '--lc-numeric=[specify LC_NUMERIC setting]: :_locales' + '--lc-time=[specify LC_TIME setting]: :_locales' + + o # Other arguments + '(-A --auth)'{-A+,--auth=}'[specify authentication method (local and host)]: :__pgsql_auth_methods' + '--auth-host=[specify host (TCP/IP) authentication method]: :__pgsql_auth_methods' + '--auth-local=[specify local authentication method]: :__pgsql_auth_methods' + '(-d --debug)'{-d,--debug}'[output debug information]' + '(1 -D --pgdata)'{-D+,--pgdata=}'[specify data directory]:data directory:_directories' + '(-E --encoding)'{-E+,--encoding=}'[specify default character encoding]: :__pgsql_encodings' + '(-k --data-checksums)'{-k,--data-checksums}'[enable checksums on data pages]' + '-L+[specify input-file directory]:input-file directory:_directories' + '(-n --no-clean)'{-n,--no-clean}'[do not clean up after errors]' + '(-N --no-sync)'{-N,--no-sync}'[do not wait for disk sync]' + '(-W --pwprompt)--pwfile=[read super-user password from specified file]:password file:_files' + # This should be exclusive with everything but -D/1 + '(-S --sync-only)'{-S,--sync-only}'[safely write all database files and exit]' + '(-T --text-search-config)'{-T+,--text-search-config=}'[specify default text-search configuration]: :__pgsql_ts_configs' + # We could just use the OS user name here, idk + '(-U --username)'{-U+,--username=}'[specify super-user name]: :__pgsql_roles' + '(-W --pwfile --pwprompt)'{-W,--pwprompt}'[prompt for super-user password]' + '(-X --waldir)'{-X+,--waldir=}'[specify write-ahead log directory]:write-ahead log directory:_directories' + '(-D --pgdata)1:database data directory:_directories' + ) + _arguments -s -S : $args +} + +# Complete pg_config command +(( $+functions[_pgsql_pg_config] )) || +_pgsql_pg_config() { + local -a args=( + + x # Exclusive options + ${(@M)common_opts_excl:#*(-\?|--help)*} + + o # Other options + ${(@)${(@M)common_opts_excl:#*--version*}#\(*\)} + '--bindir[display location of user executables]' + '--cc[display C compiler (CC) used during build]' + '--cflags[display C compiler flags (CFLAGS) used during build]' + '--cflags_sl[display C compiler flags for shared libraries (CFLAGS_SL) used during build]' + '--configure[display configure options used during build]' + '--cppflags[display C preprocessor flags (CPPFLAGS) used during build]' + '--docdir[display location of documentation files]' + '--htmldir[display location of HTML documentation files]' + '--includedir[display location of C header files for client interfaces]' + '--includedir-server[display location of C header files for server interfaces]' + '--ldflags[display linker flags (LDFLAGS) used during build]' + '--ldflags_ex[display linker flags used executables (LDFLAGS_EX) used during build]' + '--ldflags_sl[display linker flags used shared libraries (LDFLAGS_SL) used during build]' + '--libs[display linker flags for external libraries (LIBS) used during build]' + '--libdir[display location of library object files]' + '--localedir[display location of locale support files]' + '--mandir[display location of manual pages]' + '--pgxs[display location of extension makefiles]' + '--pkgincludedir[display location of other C header files]' + '--pkglibdir[display location of module object files]' + '--sharedir[display location of architecture-independent support files]' + '--sysconfdir[display location of system-wide configuration files]' + ) + _arguments -s -S : $args +} + +# Complete pg_ctl command +# @todo Exclusivity isn't great here -- it's annoying to handle properly +# because pg_ctl accepts options interspersed with the sub-command name +(( $+functions[_pgsql_pg_ctl] )) || +_pgsql_pg_ctl() { + local -a cmds modes args + + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + + cmds=( + {init,initdb}'\:initialize database cluster' + 'kill\:kill process' + 'promote\:promote database server from stand-by to read/write mode' + 'reload\:reload database-server configuration' + 'restart\:restart database server' + 'start\:start database server' + 'status\:check status of database server' + 'stop\:stop database server' + ) + modes=( + {f,fast}'\:shut down cleanly, but without waiting for clients to disconnect' + {i,immediate}'\:shut down immediately and uncleanly' + {s,smart}'\:shut down cleanly after waiting for clients to disconnect' + ) + args=( + + x # Exclusive options + $common_opts_excl + + nk # Non-kill options + '(-D --pgdata)'{-D+,--pgdata=}'[specify data directory]:data directory:_directories' + + nks # Non-kill/status options + '(-s --silent)'{-s,--silent}'[suppress informational messages]' + + ikprs # Wait options + '(-t -W --no-wait --timeout)'{-t+,--timeout=}'[specify time-out interval (with -w)]:time-out interval (seconds)' + '(-w -W --no-wait --wait)'{-w,--wait}'[wait for operation to complete]' + '(-t -w -W --no-wait --timeout --wait)'{-W,--no-wait}'[do not wait for operation to complete]' + + isr # init/start/restart options + '*'{-o+,--options=}'[specify command-line options to initdb/postgres]:initdb/postgres command-line options' + '-p+[specify path to initdb/postgres executable]:initdb/postgres executable:_files -g "*(#q*)"' + + sr # start/restart options + '(-c --core-files)'{-c,--core-files}'[produce core files (where supported)]' + '(-l --log)'{-l+,--log=}'[log to specified file]:log file:_files' + + tr # stop/restart options + '(-m --mode)'{-m+,--mode=}"[specify shut-down mode]:shut-down mode:((${(j< >)${(@qq)modes}}))" + + o # Operands + "1:pg_ctl sub-command:((${(j< >)${(@qq)cmds}}))" + ) + [[ -n ${words[(r)*kill*]} ]] && args+=( '2: :_pids' ) + + _arguments -s -S : $args +} + +# Complete pg_dump/pg_dumpall commands +(( $+functions[_pgsql_pg_dump] )) || +_pgsql_pg_dump() { + local -a fmts args + + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + + fmts=( + {p,plain}'\:plain-text SQL script' + {c,custom}'\:custom-format archive' + {d,directory}'\:directory-format archive' + {t,tar}'\:tar-format archive' + ) + args+=( + + x # Exclusive options + $common_opts_excl + + c # Connection options + $common_opts_conn + '--role=[specify role used to create dump]: :__pgsql_roles -a' + ) + # pg_dump-specific connection options + [[ $service == pg_dump ]] && args+=( + '(1 -d --dbname)'{-d+,--dbname=}'[specify database name]: :__pgsql_databases' + # @todo Complete this properly + '(-d --dbname)1:PostgreSQL database name, conninfo string, or URI:__pgsql_databases' + ) + # pg_dumpall-specific connection options + [[ $service == pg_dumpall ]] && args+=( + # Despite the name, -d here this actually takes a conninfo string + # @todo Complete this + '(1 -d --dbname)'{-d+,--dbname=}'[specify conninfo string]:conninfo string' + '(l --database)'{-l+,--database=}'[specify maintenance database name]: :__pgsql_databases' + ) + args+=( + + '(ds)' # Data/schema options + '(-c --clean)'{-a,--data-only}'[dump only data (not schema/definitions)]' + {-s,--schema-only}'[dump only schema/definitions (not data)]' + + '(in)' # Insert options + '(-o --oids)--column-inserts[output INSERT command with explicit column names for each row]' + # Equivalent to above? + '!(-o --oids)--attribute-inserts' + '(-o --oids)--inserts[output INSERT command for each row]' + ) + [[ $service == pg_dumpall ]] && args+=( + + '(grt)' # Globals/roles/tablespaces options + {-g,--globals-only}'[dump only roles and tablespaces (not databases)]' + {-r,--roles-only}'[dump only roles (not databases or tablespaces)]' + {-t,--tablespaces-only}'[dump only tablespaces (not databases or roles)]' + ) + # It would be nice to add '(with -Fp)' and so on where applicable, but it's + # tedious because of pg_dumpall + args+=( + + o # Other options + '(-a -c --clean --data-only)'{-c,--clean}'[output commands to clean objects before creating them]' + '(-o --oids in)'{-o,--oids}'[dump table object IDs]' + '(-O --no-owner)'{-O,--no-owner}'[do not output commands to set ownership of objects]' + '(-S --superuser)'{-S+,--superuser=}'[specify super-user name]: :__pgsql_roles' + '(-v --verbose)'{-v,--verbose}'[output verbosely]' + '(-x --no-acl --no-privileges)'{-x,--no-acl,--no-privileges}'[do not dump access privileges]' + # Not meant for use by humans + '!--binary-upgrade' + '--disable-dollar-quoting[disable dollar-quoting of function bodies]' + '--disable-triggers[output commands to disable triggers before restoring (with -a)]' + '--if-exists[use conditional commands when cleaning objects (with -c)]' + '--lock-wait-timeout=[specify table-lock time-out interval]:time-out interval (milliseconds)' + '--no-publications[do not dump publications]' + '--no-security-labels[do not dump security labels]' + '--no-subscriptions[do not dump subscriptions]' + '--no-sync[do not wait for disk sync]' + '--no-tablespaces[do not output commands to select tablespaces]' + '--no-unlogged-table-data[do not dump data of unlogged tables]' + '--quote-all-identifiers[force quoting of all identifiers]' + '--use-set-session-authorization[output SET SESSION AUTHORIZATION commands to set ownership of objects]' + ) + [[ $service == pg_dump ]] && args+=( + # -b and -B are NOT exclusive + '(-b --blobs)'{-b,--blobs}'[dump large objects]' + '(-B --no-blobs)'{-B,--no-blobs}'[do not dump large objects]' + '(-C --create)'{-C,--create}'[output commands to create and reconnect to database]' + '(-E --encoding)'{-E+,--encoding=}'[specify dump character encoding]: :__pgsql_encodings' + '(-f --file)'{-f+,--file=}'[dump to specified file (or directory with -Fd)]:dump file/directory:_files' + '(-F --format)'{-F+,--format=}"[dump using specified output format]:output format:((${(j< >)${(@qq)fmts}}))" + '(-j --jobs)'{-j+,--jobs=}'[dump specified number of tables in parallel (with -Fd)]:number of jobs/tables' + '*'{-n+,--schema=}'[dump only objects in schema matching specified pattern]: :__pgsql_schemas' + '*'{-N+,--exclude-schema=}'[do not dump objects in schema matching specified pattern]: :__pgsql_schemas' + # No effect, kept for backwards compatibility + '!'{-R,--no-reconnect} + '*'{-t+,--table=}'[dump only tables matching specified pattern]: :__pgsql_tables' + '*'{-T+,--exclude-table=}'[do not dump tables matching specified pattern]: :__pgsql_tables' + '(-Z --compress)'{-Z+,--compress=}"[specify output compression level]:compression level:(${(j< >):-{0..9}})" + '--enable-row-security[dump with row security enabled]' + '*--exclude-table-data=[do not dump data for tables matching specified pattern]: :__pgsql_tables' + '--no-synchronized-snapshots[support -j with pre-9.2 servers]' + '*--section=[dump only specified section]:section:(pre-data data post-data)' + '--serializable-deferrable[dump using serializable transaction, avoiding failure]' + # @todo Complete this + '--snapshot=[dump from specified snapshot]: :__pgsql_snapshots' + '--strict-names[require -n/-t patterns to match at least one schema/table]' + ) + [[ $service == pg_dumpall ]] && args+=( + '(-f --file)'{-f+,--file=}'[dump to specified file]:dump file:_files' + '--no-role-passwords[do not dump passwords for roles]' + ) + _arguments -s -S : $args +} + +# Complete pg_isready command +(( $+functions[_pgsql_pg_isready] )) || +_pgsql_pg_isready() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options + ${(@)common_opts_conn:#*--*password*} + # @todo Complete this properly + '(-d --dbname)'{-d+,--dbname=}'[specify database name, conninfo string, or URI]:PostgreSQL database name, conninfo string, or URI:__pgsql_databases' + '(-t --timeout)'{-t+,--timeout=}'[specify time-out interval]:time-out interval (seconds)' + + C # Misc. common options + '(-q --quiet)'{-q,--quiet}'[suppress normal output]' + ) + _arguments -s -S : $args +} + +# Complete pg_restore command +(( $+functions[_pgsql_pg_restore] )) || +_pgsql_pg_restore() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a fmts=( + # Plain-text is intentionally missing here + {c,custom}'\:custom-format archive' + {d,directory}'\:directory-format archive' + {t,tar}'\:tar-format archive' + ) + # It probably isn't that helpful to complete indexes, &c., from existing + # databases, but oh well + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options + $common_opts_conn + '(-d --dbname)'{-d+,--dbname=}'[restore to specified database]: :__pgsql_databases' + '--role=[specify role used to perform restore]: :__pgsql_roles -a' + + '(ds)' # Data/schema options + '(-c --clean)'{-a,--data-only}'[restore only data (not schema/definitions)]' + {-s,--schema-only}'[restore only schema/definitions (not data)]' + + o # Other arguments + '(-1 --single-transaction)'{-1,--single-transaction}'[perform restore as a single transaction]' + '(-a -c --clean --data-only)'{-c,--clean}'[clean objects before creating them]' + '(-C --create)'{-C,--create}'[create database before restoring to it]' + '(-e --exit-on-error)'{-e,--exit-error}'[exit immediately on error]' + '(-f --file)'{-f+,--file=}'[specify output file for generated script or listing]:output file:_files' + '(-F --format)'{-F+,--format=}"[specify archive format]:archive format:((${(j< >)${(@qq)fmts}}))" + '*'{-I+,--index=}'[restore only definition of specified index]: :__pgsql_indexes' + '(-j --jobs)'{-j+,--jobs=}'[restore in parallel with specified number of jobs]:number of jobs' + '(-l --list)'{-l,--list}'[list archive table of contents]' + '(-L --use-list)'{-L+,--use-list=}'[restore only archive elements in specified list file]:list file:_files' + '*'{-n+,--schema=}'[restore only objects in specified schema]: :__pgsql_schemas' + '*'{-N+,--exclude-schema=}'[do not restore objects in specified schema]: :__pgsql_schemas' + '(-O --no-owner)'{-O,--no-owner}'[do not restore ownership of objects from archive]' + '*'{-P+,--function=}'[restore only the specified function]:PostgreSQL function' + # No effect, kept for backwards compatibility + '!'{-R,--no-reconnect} + '(-S --superuser)'{-S+,--superuser=}'[specify super-user name]: :__pgsql_roles' + '*'{-t+,--table=}'[restore only specified table]: :__pgsql_tables' + '*'{-T+,--trigger=}'[restore only specified trigger]:PostgreSQL trigger' + '(-v --verbose)'{-v,--verbose}'[output verbosely]' + '(-x --no-acl --no-privileges)'{-x,--no-acl,--no-privileges}'[do not dump access privileges]' + '--disable-triggers[disable triggers before restoring (with -a)]' + '--enable-row-security[restore with row security enabled]' + '--if-exists[use conditional commands when cleaning objects (with -c)]' + '--no-data-for-failed-tables[do not restore data if table creation failed]' + '--no-publications[do not restore publications]' + '--no-security-labels[do not restore security labels]' + '--no-subscriptions[do not restore subscriptions]' + '--no-tablespaces[do not restore tablespaces]' + '*--section=[dump only specified section]:section:(pre-data data post-data)' + '--strict-names[require -n/-t qualifiers to match at least one schema/table]' + '--use-set-session-authorization[use SET SESSION AUTHORIZATION commands to set ownership of objects]' + '1:archive file:_files' + ) + _arguments -s -S : $args +} + +# Complete pg_upgrade command +(( $+functions[_pgsql_pg_upgrade] )) || +_pgsql_pg_upgrade() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + o # Other options + '(-b --old-bindir)'{-b+,--old-bindir=}'[specify old executable directory]:old executable directory:_directories' + '(-B --new-bindir)'{-B+,--new-bindir=}'[specify new executable directory]:new executable directory:_directories' + '(-c --check)'{-c,--check}"[check clusters only (don't change any data)]" + '(-d --old-datadir)'{-d+,--old-datadir=}'[specify old data directory]:old data directory:_directories' + '(-D --new-datadir)'{-D+,--new-datadir=}'[specify new data directory]:new data directory:_directories' + '(-j --jobs)'{-j+,--jobs=}'[upgrade in parallel with specified number of jobs]:number of jobs' + '(-k --link)'{-k,--link}'[use hard links instead of copying files to new cluster]' + '*'{-o+,--old-options=}'[specify command-line options to old postgres]:old postgres command-line options' + '*'{-O+,--new-options=}'[specify command-line options to new postgres]:new postgres command-line options' + '(-p --old-port)'{-p+,--old-port=}'[specify old port number]:old port number:__pgsql_ports' + '(-P --new-port)'{-P+,--new-port=}'[specify new port number]:new port number:__pgsql_ports' + '(-r --retain)'{-r,--retain}'[retain SQL and log files even after successful completion]' + '(-U --username)'{-U+,--username=}'[specify cluster install user name]: :__pgsql_roles' + '(-v --verbose)'{-v,--verbose}'[log verbosely]' + ) + _arguments -s -S : $args +} + +# Complete postgres/postmaster commands +(( $+functions[_pgsql_postgres] )) || +_pgsql_postgres() { + local -a args + + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + args=( + + x # Exclusive options + $common_opts_excl + '--describe-config[dump internal configuration variables, descriptions, and defaults]' + + o # Other options + '-B+[specify number of shared buffers used by server processes]:number of shared buffers' + '*-c+[set specified run-time configuration parameter]: :__pgsql_cfg_params_values' + '-C+[display value of specified run-time configuration parameter]: :__pgsql_cfg_params' + '-d+[specify debug level]:debug level:(0 1 2 3 4 5)' + '-D+[specify configuration directory]:PostgreSQL configuration directory:_directories' + '-e[set default date style to European (DMY)]' + '-F[disable fsync calls]' + '(-i)-h+[specify TCP/IP address to listen on]:listening addresses:__pgsql_hosts_seq' + '(-h)-i[allow remote connections via TCP/IP]' + '-k+[specify directory of UNIX-domain socket to listen on]:UNIX-domain socket directory:__pgsql_hosts_seq -/' + '-l[enable secure connections using SSL]' + '-N+[specify max number of client connections]:number of client connections' + '*-o+[specify extra command-line options to pass down to postgres]:postgres command-line options' + '-p+[specify TCP/IP port or UNIX-domain socket file extension to listen on]: :__pgsql_ports' + '-s[display time information and other statistics after each command]' + '-S+[specify amount of memory for sort/hash operations]:amount of memory' + # These are 'semi-internal' options that we don't really complete, but we'll + # account for them anyway + '!'{-f+,-n,-O,-P,-t+,-T,-v+,-W+} + ) + # --single must be the first argument on the command line + (( CURRENT == 2 )) && args+=( + '--single[enter single-user mode]' + ) + (( CURRENT > 2 )) && [[ ${(Q)words[2]} == --single ]] && args+=( + '-E[echo SQL commands to stdout]' + '-j[use semicolon followed by two newlines as command-entry terminator]' + '-r+[send server log output to specified file]:log file:_files' + ) + + _arguments -s -S : $args +} + +# Complete psql command +(( $+functions[_pgsql_psql] )) || +_pgsql_psql() { + local -a args=( + + x # Exclusive options + ${(@M)common_opts_excl:#*version*} + '(: * -)'{-\?,--help=-}'[display help information]::help topic:(commands options variables)' + + c # Connection options + ${(@)common_opts_conn/#\(-U/(2 -U} + '(1 -d --dbname)'{-d+,--dbname=}'[specify database name]: :__pgsql_databases' + # @todo Complete this properly + '(-d --dbname)1:PostgreSQL database name, conninfo string, or URI:__pgsql_databases' + # @todo This shouldn't be offered if the first operand isn't a dbname + '(-U --username)2: :__pgsql_roles' + + '(e)' # Echo options (ECHO variable) + {-a,--echo-all}'[echo all non-empty input lines back to stdout]' + {-b,--echo-errors}'[echo failed SQL commands to stderr]' + {-e,--echo-queries}'[echo SQL commands to stdout]' + + '(f)' # Format options + '(x)'{-A,--no-align}'[display results in unaligned format]' + '(sf sr)'{-H,--html}'[display results in HTML table format]' + + '(sf)' # Field-separator options + '(-H --html x)'{-F+,--field-separator=}'[specify field separator (with -A)]:field separator' + '(-H --html x)'{-z,--field-separator-zero}'[use NUL as field separator (with -A)]' + + '(sr)' # Record-separator options + '(-H --html x)'{-R+,--record-separator=}'[specify record separator (with -A)]:record separator' + '(-H --html x)'{-0,--record-separator-zero}'[use NUL as record separator (with -A)]' + + '(t)' # HTML-table options + '(-A --no-align sf sr)'{-T+,--table-attr=}'[specify HTML table attributes]:HTML attributes' + + '(x)' # Expanded-table-formatting options + '(-A --no-align sf sr)'{-x,--expanded}'[enable expanded table formatting]' + + o # Other options + '(-1 --single-transaction)'{-1,--single-transaction}'[wrap all commands in a single transaction (with -c/-f)]' + '*'{-c+,--command=}'[execute specified command string]:command string' + '(-E --echo-hidden)'{-E,--echo-hidden}'[echo queries generated by backslash commands]' + '*'{-f+,--file=}'[execute commands from specified file]:SQL file:_files' + # The documentation says that all other 'non-connection' options are ignored + # when this one is given... but it lies. There *are* several options that + # get ignored, but it's irritating to enumerate them + '(-l --list)'{-l,--list}'[display available databases]' + '(-L --log-file)'{-L+,--log-file=}'[also log query output to specified file]:log file:_files' + '(-n --no-readline)'{-n,--no-readline}'[do not use Readline for line editing and history]' + '(-o --output)'{-o+,--output=}'[write query output to specified file]:output file:_files' + '*'{-P+,--pset=}'[specify printing option]: :__pgsql_cfg_variables_values --pset' + '(-q --quiet)'{-q,--quiet}'[suppress informational output]' + '(-s --single-step)'{-s,--single-step}'[prompt before executing each command]' + '(-S --single-line)'{-S,--single-line}'[treat newlines as semicolons]' + '(-t --tuples-only)'{-t,--tuples-only}'[do not output columns names, row counts, etc.]' + '*'{-v+,--set=,--variable=}'[perform specified variable assignment]: :__pgsql_cfg_variables_values --set' + '(-X --no-psqlrc)'{-X,--no-psqlrc}'[do not read start-up files]' + ) + _arguments -s -S : $args +} + +# Complete reindexdb command +(( $+functions[_pgsql_reindexdb] )) || +_pgsql_reindexdb() { + (( CURRENT > 2 )) && local -a common_opts_excl=( '!---null' ) + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options (not actually usable with --all) + $common_opts_connm + + '(d)' # Database connection options + '(a o)'{-d+,--dbname=}'[specify database name]: :__pgsql_databases' + + C # Misc. common options + $common_opts_echo + # -q and -v are NOT exclusive. -q only seems to affect --all mode + '(-q --quiet)'{-q,--quiet}'[do not display progress messages]' + '(-v --verbose)'{-v,--verbose}'[display detailed information during processing]' + + a # --all-mode options + '(c d n o s -a --all)'{-a,--all}'[reindex all databases]' + + n # Normal-mode options + '(a s)*'{-i+,--index=}'[re-create specified index only]: :__pgsql_indexes' + '(a s)*'{-S+,--schema=}'[reindex specified schema only]: :__pgsql_schemas' + '(a s)*'{-t+,--table=}'[reindex specified table only]: :__pgsql_tables' + + s # --system-mode options + '(a n -s --system)'{-s,--system}"[reindex database's system catalogs]" + + o # Operands + '(a d)1: :__pgsql_databases' + ) + _arguments -s -S : $args +} + +# Complete vacuumdb command +(( $+functions[_pgsql_vacuumdb] )) || +_pgsql_vacuumdb() { + local -a args=( + + x # Exclusive options + $common_opts_excl + + c # Connection options (not actually usable with --all) + $common_opts_connm + + '(d)' # Database connection options + '(a o)'{-d+,--dbname=}'[specify database name]: :__pgsql_databases' + + C # Misc. common options + $common_opts_echo + '(-j --jobs)'{-j+,--jobs=}'[run specified number of vacuum/analyze commands in parallel]:number of jobs' + '--min-mxid-age=[specify minimum MXID age of tables to vacuum]:minimum MXID age' + '--min-xid-age=[specify minimum XID age of tables to vacuum]:minimum XID age' + '--skip-locked[skip relations that cannot be immediately locked]' + # -q and -v are NOT exclusive + '(-q --quiet)'{-q,--quiet}'[do not display progress messages]' + '(-v --verbose)'{-v,--verbose}'[display detailed information during processing]' + + f # Options incompatible with analyse-only options + '(Z)--disable-page-skipping[disable all page-skipping behavior]' + '(Z -f --full)'{-f,--full}'[perform full vacuum]' + '(Z -F --freeze)'{-F,--freze}'[aggressively freeze tuples]' + + '(z)' # Analyse options + {-z,--analyze}'[also calculate statistics for use by optimizer]' + + '(Z)' # Analyse-only options + '(f)'{-Z,--analyze-only}'[only calculate statistics for use by optimizer (no vacuum)]' + '(f)--analyze-in-stages[like -Z, but analyze in stages for faster results]' + + a # --all-mode options + '(c d n -a --all)'{-a,--all}'[reindex all databases]' + + n # Normal-mode options + # @todo When used with -z, &al., this accepts a column name in brackets. We + # don't complete that + '(a)*'{-t+,--table=}'[vacuum/analyze specified table(column) only]: :__pgsql_tables' + + o # Operands + '(a d)1: :__pgsql_databases' + ) + _arguments -s -S : $args +} + +# Router +_postgresql() { + # Common exclusive options + local -a common_opts_excl=( + '(: * -)'{-\?,--help}'[display help information]' + '(: * -)'{-V,--version}'[display version information]' + ) + # Common connection options + local -a common_opts_conn=( + '(-h --host)'{-h+,--host=}'[specify database server host or socket directory]: :__pgsql_hosts_seq -a' + '(-p --port)'{-p+,--port=}'[specify database server port]: :__pgsql_ports' + '(-U --username)'{-U+,--username=}'[specify user name to connect with]: :__pgsql_roles' + '(-w -W --no-password --password)'{-w,--no-password}'[never prompt for password on connect]' + '(-w -W --no-password --password)'{-W,--password}'[force prompt for password on connect]' + ) + # Common connection options + --maintenance-db + local -a common_opts_connm=( + $common_opts_conn + '--maintenance-db=[specify maintenance database name]: :__pgsql_databases' + ) + # Common echo options + local -a common_opts_echo=( + '(-e --echo)'{-e,--echo}'[echo generated commands to stdout]' + ) + + # Special case: pg_dumpall is handled as pg_dump + if [[ $service == pg_dumpall ]]; then + _pgsql_pg_dump "$@" + # Special case: postmaster is handled as postgres + elif [[ $service == postmaster ]]; then + _pgsql_postgres "$@" + elif (( $+functions[_pgsql_$service] )); then + _pgsql_$service "$@" + else + _message "unsupported PostgreSQL service: $service" + _default + fi +} + +_postgresql "$@" -- cgit v1.2.3 From 11dbe4c286330f81fae5ac6d5f698f5ddb748710 Mon Sep 17 00:00:00 2001 From: Jens Schleusener Date: Thu, 9 Jan 2020 13:39:44 +0000 Subject: 45269: Fix misspellings in completions and elsewhere. --- ChangeLog | 33 +++++++++++++++++++++++ Completion/BSD/Command/_mixerctl | 2 +- Completion/Darwin/Command/_fs_usage | 2 +- Completion/Darwin/Type/_mac_files_for_application | 2 +- Completion/Debian/Command/_sbuild | 2 +- Completion/Linux/Command/_brctl | 2 +- Completion/Linux/Command/_findmnt | 2 +- Completion/Linux/Command/_ltrace | 2 +- Completion/Mandriva/Command/_urpmi | 6 ++--- Completion/Redhat/Command/_yum | 2 +- Completion/Unix/Command/_attr | 2 +- Completion/Unix/Command/_git | 10 +++---- Completion/Unix/Command/_graphicsmagick | 8 +++--- Completion/Unix/Command/_iconv | 2 +- Completion/Unix/Command/_imagemagick | 10 +++---- Completion/Unix/Command/_links | 2 +- Completion/Unix/Command/_luarocks | 4 +-- Completion/Unix/Command/_objdump | 4 +-- Completion/Unix/Command/_od | 2 +- Completion/Unix/Command/_pandoc | 2 +- Completion/Unix/Command/_ping | 2 +- Completion/Unix/Command/_pkg-config | 2 +- Completion/Unix/Command/_postgresql | 2 +- Completion/Unix/Command/_rubber | 2 +- Completion/Unix/Command/_transmission | 6 ++--- Completion/Unix/Type/_baudrates | 2 +- Completion/Unix/Type/_path_files | 2 +- Etc/FAQ.yo | 2 +- Functions/Zftp/zfautocheck | 2 +- Misc/c2z | 2 +- Src/Modules/curses.c | 2 +- Src/Modules/db_gdbm.c | 2 +- Src/Modules/parameter.c | 2 +- Src/Zle/comp.h | 6 ++--- Src/Zle/compcore.c | 2 +- Src/Zle/compctl.c | 2 +- Src/Zle/complete.c | 2 +- Src/Zle/compresult.c | 2 +- Src/Zle/computil.c | 2 +- Src/Zle/zle_keymap.c | 2 +- Src/Zle/zle_main.c | 2 +- Src/Zle/zle_refresh.c | 2 +- Src/pattern.c | 2 +- Src/zsh.h | 2 +- Src/ztype.h | 2 +- Test/B01cd.ztst | 2 +- Test/D04parameter.ztst | 2 +- 47 files changed, 98 insertions(+), 65 deletions(-) (limited to 'Completion/Unix/Command/_postgresql') diff --git a/ChangeLog b/ChangeLog index 2e1bfb8ad..64e3ee82f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2020-01-09 Jens Schleusener + + * 45269: Completion/BSD/Command/_mixerctl, + Completion/Darwin/Command/_fs_usage, + Completion/Darwin/Type/_mac_files_for_application, + Completion/Debian/Command/_sbuild, + Completion/Linux/Command/_brctl, + Completion/Linux/Command/_findmnt, + Completion/Linux/Command/_ltrace, + Completion/Mandriva/Command/_urpmi, + Completion/Redhat/Command/_yum, + Completion/Unix/Command/_attr, Completion/Unix/Command/_git, + Completion/Unix/Command/_graphicsmagick, + Completion/Unix/Command/_iconv, + Completion/Unix/Command/_imagemagick, + Completion/Unix/Command/_links, + Completion/Unix/Command/_luarocks, + Completion/Unix/Command/_objdump, Completion/Unix/Command/_od, + Completion/Unix/Command/_pandoc, Completion/Unix/Command/_ping, + Completion/Unix/Command/_pkg-config, + Completion/Unix/Command/_postgresql, + Completion/Unix/Command/_rubber, + Completion/Unix/Command/_transmission, + Completion/Unix/Type/_baudrates, + Completion/Unix/Type/_path_files, Etc/FAQ.yo, + Functions/Zftp/zfautocheck, Misc/c2z, Src/Modules/curses.c, + Src/Modules/db_gdbm.c, Src/Modules/parameter.c, Src/Zle/comp.h, + Src/Zle/compcore.c, Src/Zle/compctl.c, Src/Zle/complete.c, + Src/Zle/compresult.c, Src/Zle/computil.c, Src/Zle/zle_keymap.c, + Src/Zle/zle_main.c, Src/Zle/zle_refresh.c, Src/pattern.c, + Src/zsh.h, Src/ztype.h, Test/B01cd.ztst, Test/D04parameter.ztst: + Fix misspellings in completions and elsewhere. + 2020-01-08 dana * 45261: Completion/Unix/Command/_gcc: Detect clang-as-gcc diff --git a/Completion/BSD/Command/_mixerctl b/Completion/BSD/Command/_mixerctl index a43aed4cb..d2a9ea3ee 100644 --- a/Completion/BSD/Command/_mixerctl +++ b/Completion/BSD/Command/_mixerctl @@ -8,4 +8,4 @@ _arguments -s -S -A "-*" \ '(-a -n -v)-q[Suppress all printing when setting a variable]' \ '(-a -n -v)-t[Attempt to select the next possible value of an enum]' \ '(-q -t)-v[Show all possible values of variables]' \ - '(-a)*:mixerctl varible:_multi_parts -i -S = -q . _cache_mixerctlvars' + '(-a)*:mixerctl variable:_multi_parts -i -S = -q . _cache_mixerctlvars' diff --git a/Completion/Darwin/Command/_fs_usage b/Completion/Darwin/Command/_fs_usage index 956816169..1d76cf86d 100644 --- a/Completion/Darwin/Command/_fs_usage +++ b/Completion/Darwin/Command/_fs_usage @@ -6,7 +6,7 @@ typeset -A opt_args _arguments -s -C -A '-*' : \ '-e[exclude fs_usage and the specified processes from sampling]' \ '-w[use wider output]' \ - '*-f+[specify output filtering mode]:mode:(nework filesys pathname exec diskio cachehit)' \ + '*-f+[specify output filtering mode]:mode:(network filesys pathname exec diskio cachehit)' \ '-b[annotate disk I/O events with BootCache info]' \ '(-R -S -E)-t+[specify run timeout]:seconds' \ '(-t)-R+[specify raw trace file to process]:raw trace file:_files' \ diff --git a/Completion/Darwin/Type/_mac_files_for_application b/Completion/Darwin/Type/_mac_files_for_application index 44516b4db..885b064fe 100644 --- a/Completion/Darwin/Type/_mac_files_for_application +++ b/Completion/Darwin/Type/_mac_files_for_application @@ -44,7 +44,7 @@ _mac_files_for_application() { local -a glob_patterns glob_patterns=() - # Try to get extentions from "Info.plist" XML file. + # Try to get extensions from "Info.plist" XML file. if [[ -f "$app_path/Contents/Info.plist" ]]; then local -a exts types _mac_parse_info_plist diff --git a/Completion/Debian/Command/_sbuild b/Completion/Debian/Command/_sbuild index 0cb3dc3b9..b38eda0ee 100644 --- a/Completion/Debian/Command/_sbuild +++ b/Completion/Debian/Command/_sbuild @@ -115,7 +115,7 @@ _sbuild() { '--finished-build-commands=[run commands after package is built]:commands' \ '--build-failed-commands=[run commands after dpkg-buildpackage fails]:commands' \ '--chroot-cleanup-commands=[run commands after chroot cleanup]:commands' \ - '--post-build-commands=[run commands after package is build sucessfuly]:commands' \ + '--post-build-commands=[run commands after package is build successfully]:commands' \ '--post-build-failed-commands[run commands after package failed to build]:commands' \ '--anything-failed-commands=[run commands for all --xxx-failed-commands option]:commands' \ '--log-external-command-output[external commands output are logged]' \ diff --git a/Completion/Linux/Command/_brctl b/Completion/Linux/Command/_brctl index 6e65d122c..4d053d5cb 100644 --- a/Completion/Linux/Command/_brctl +++ b/Completion/Linux/Command/_brctl @@ -13,7 +13,7 @@ if (( CURRENT == 2 )); then hairpin:toggle\ hairpin\ mode\ on\ a\ port showmacs:show\ a\ list\ of\ learned\ MAC\ addresses setageing:set\ MAC\ address\ ageing\ time - setgcint:set\ grabage\ collection\ interval + setgcint:set\ garbage\ collection\ interval stp:control\ use\ of\ spanning\ tree\ protocol showstp:show\ bridge\ stp\ info setbridgeprio:set\ bridge\ priority diff --git a/Completion/Linux/Command/_findmnt b/Completion/Linux/Command/_findmnt index 1e570aabd..9f13e695f 100644 --- a/Completion/Linux/Command/_findmnt +++ b/Completion/Linux/Command/_findmnt @@ -32,7 +32,7 @@ _arguments -s -C \ '(H -U --uniq)'{-U,--uniq}'[ignore filesystems with duplicated mount targets]' \ '(H -u --notruncate)'{-u,--notruncate}'[do not truncate text in columns]' \ '(H -v --nofsroot)'{-v,--nofsroot}'[do not print \[/dir\] in the SOURCE column]' \ - '(H -w --timeout)'{-w+,--timeout}'[specify timeout for --poll]:miliseconds: ' \ + '(H -w --timeout)'{-w+,--timeout}'[specify timeout for --poll]:milliseconds: ' \ '(H -x --verify)'{-x,--verify}'[check mount table content]' \ '(H)--verbose[print more information]' \ '(H)1: :->sources_targets' \ diff --git a/Completion/Linux/Command/_ltrace b/Completion/Linux/Command/_ltrace index e48d8ec98..b60f8c355 100644 --- a/Completion/Linux/Command/_ltrace +++ b/Completion/Linux/Command/_ltrace @@ -5,7 +5,7 @@ local root hlp="-h --help -V --version" (( EUID )) && root='!' _arguments -s -S $args \ - "(-c -a --align $hlp)"{-a+,--align=}"[align return values in a secific column]:column [$((COLUMNS*5/8))]" \ + "(-c -a --align $hlp)"{-a+,--align=}"[align return values in a specific column]:column [$((COLUMNS*5/8))]" \ "(-c $hlp)-A+[specify maximum number of array elements to print]:elements" \ "(-c -b --no-signals $hlp)"{-b,--no-signals}"[don't print signals]" \ "(-a --align -A -b --no-signals -i -n --indent -r -s -t -tt -ttt -T $hlp)-c[count time and calls, and report a summary on exit]" \ diff --git a/Completion/Mandriva/Command/_urpmi b/Completion/Mandriva/Command/_urpmi index 00994c70f..d897f2c4b 100644 --- a/Completion/Mandriva/Command/_urpmi +++ b/Completion/Mandriva/Command/_urpmi @@ -87,7 +87,7 @@ _urpmi() { "($help)--auto[automatically select a package in choices]" "($help)--force[force invocation even if some packages do not exist]" "($help)--parallel[distributed urpmi across machines of alias]:urpmi alias name:_urpmi_parallel_alias" - "($help)--root[use another root for rpm installation]:root diretory:_files -/" + "($help)--root[use another root for rpm installation]:root directory:_files -/" "($help)--test[test only, do not modify system]" "($help)-a[select all matches on command line]" ) @@ -147,7 +147,7 @@ _urpmi() { "($help : -)"{--help,-h}"[print usage information]" \ "($help :)-a[select all media]" \ "($help)-c[clean headers cache directory]" \ - "($help)-y[fuzzy mathing on media names]" \ + "($help)-y[fuzzy matching on media names]" \ "(-a)"{,\*}":media:_sequence _urpmi_media" \ && ret=0 ;; @@ -189,7 +189,7 @@ _urpmi() { "($help)--more-choices[propose more choices than the default]" \ "($help --no-resume)--resume[resume transfer of partially-downloaded files]" \ "($help --resume)--no-resume[do not resume transfer of partially-downloaded files]" \ - "($help)--root[use another root for rpm installation]:root diretory:_files -/" \ + "($help)--root[use another root for rpm installation]:root directory:_files -/" \ "($help)--skip[packages which installation should be skipped]:packages: " \ "($help)--split-length[small transaction length]:transaction length: " \ "($help)--split-level[split in small transaction]:transaction size: " \ diff --git a/Completion/Redhat/Command/_yum b/Completion/Redhat/Command/_yum index 8abd23ebb..a30aa579f 100644 --- a/Completion/Redhat/Command/_yum +++ b/Completion/Redhat/Command/_yum @@ -39,7 +39,7 @@ _yum() { '--color=[control whether color is used]:(always auto never)' \ '--releasever=[set value of $releasever in yum config and repo files]:value' \ "--downloadonly[don't update, just download]" \ - '--downloaddir=[specify alternate directory to store packages]:directort:_directories' \ + '--downloaddir=[specify alternate directory to store packages]:directory:_directories' \ '--setopt=[set arbitrary config and repo options]:option' \ '--bugfix[include bugfix relevant packages in updates]' \ '--security[include security relevant packages in updates]' \ diff --git a/Completion/Unix/Command/_attr b/Completion/Unix/Command/_attr index d8d4ed260..121c0c539 100644 --- a/Completion/Unix/Command/_attr +++ b/Completion/Unix/Command/_attr @@ -56,7 +56,7 @@ case $service in '-r[act recursively]' \ '-s[act on symbolic links]' \ '(-w)-v[always display file name]' \ - '(-c -d)-x[use hexademical format for value input and output]' \ + '(-c -d)-x[use hexadecimal format for value input and output]' \ '*: :_files' \ + '(op)' \ '(-l -x)-c[remove all attributes]' \ diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index be0c810cc..40d10f431 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1187,7 +1187,7 @@ _git-log () { fi # TODO: Write a wrapper function that checks whether we have a - # committish range or comittish and calls __git_tree_files + # committish range or committish and calls __git_tree_files # appropriately. if __git_is_committish_range $line[1]; then __git_tree_files ${PREFIX:-.} $(__git_committish_range_last $line[1]) && ret=0 @@ -1671,7 +1671,7 @@ _git-shortlog () { ;; (*) # TODO: Write a wrapper function that checks whether we have a - # committish range or comittish and calls __git_tree_files + # committish range or committish and calls __git_tree_files # appropriately. if __git_is_committish_range $line[1]; then __git_tree_files ${PREFIX:-.} $(__git_committish_range_last $line[1]) && ret=0 @@ -2101,7 +2101,7 @@ _git-switch() { case $state in branches) if [[ -n ${opt_args[(i)--guess]} ]]; then - # --guess is the default but if it has been explictly specified, + # --guess is the default but if it has been explicitly specified, # we'll only complete remote branches __git_remote_branch_names_noprefix && ret=0 else @@ -5432,7 +5432,7 @@ _git-daemon () { '--strict-paths[match paths exactly]' \ '--access-hook=-[allow an external tool to accept or decline service]:path:_directories' \ '--base-path=-[remap all the path requests as relative to the given path]:path:_directories' \ - '--base-path-relaxed[allow lookup of base path witout prefix]' \ + '--base-path-relaxed[allow lookup of base path without prefix]' \ '--interpolated-path=-[dynamically construct alternate paths]:path:_directories' \ '--export-all[allow pulling from all repositories without verification]' \ '(--port --listen --user --group)--inetd[run server as an inetd service]' \ @@ -6100,7 +6100,7 @@ _git_column_layouts() { '(always never)auto[show in columns if the output is to the terminal]' \ '(row plain)column[fill columns before rows]' \ '(column plain)row[fill rows before columns]' \ - '(column row)plain[show in one colum]' \ + '(column row)plain[show in one column]' \ '(nodense)dense[make unequal size columns to utilize more space]' \ '(dense)nodense[make equal size columns]' } diff --git a/Completion/Unix/Command/_graphicsmagick b/Completion/Unix/Command/_graphicsmagick index cc541d891..dc799085b 100644 --- a/Completion/Unix/Command/_graphicsmagick +++ b/Completion/Unix/Command/_graphicsmagick @@ -40,7 +40,7 @@ case "$words[2]" in '*-dispose:GIF disposal method:((0:no\ disposal 1\:don'\''t\ dispose\ between\ frames 2\:overwrite\ frame\ with\ background\ color 3\:overwrite\ with\ previous\ frame))' \ '*-dither[apply dithering]' \ '*-edge:edge detection factor (0.0 - 99.9%%)' \ - '*-endian:image endianess:(MSB LSB)' \ + '*-endian:image endianness:(MSB LSB)' \ '*+endian' \ '*-enhance[enhance noisy image]' \ '*-filter:filter type for resizing:(Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc)' \ @@ -162,7 +162,7 @@ case "$words[2]" in '-descend[descend window hierarchy]' \ '-dispose:GIF disposal method:((0:no\ disposal 1\:don'\''t\ dispose\ between\ frames 2\:overwrite\ frame\ with\ background\ color 3\:overwrite\ with\ previous\ frame))' \ '-dither[apply dithering]' \ - '(+endian)-endian:image endianess:(MSB LSB)' \ + '(+endian)-endian:image endianness:(MSB LSB)' \ '(-endian)+endian' \ '-frame[include window manager frame]' \ '(- *)-help[display help information]' \ @@ -214,7 +214,7 @@ case "$words[2]" in '*-dither[apply dithering]' \ '*+dither[render Postscript without aliasing]' \ '*-draw:drawing primitive:compadd -S "\\ " - rectangle circle ellipse polygon color matte text image' \ - '*-endian:image endianess:(MSB LSB)' \ + '*-endian:image endianness:(MSB LSB)' \ '*+endian' \ '*-filter:filter type for resizing:(Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc)' \ '*-frame[draw frame around image]' \ @@ -293,7 +293,7 @@ case "$words[2]" in '-draw:drawing primitive:compadd -S "\\ " - rectangle circle ellipse polygon color matte text image' \ '-edge:edge detection factor (0.0 - 99.9%%)' \ '-emboss[emboss image]' \ - '(+endian)-endian:image endianess:(MSB LSB)' \ + '(+endian)-endian:image endianness:(MSB LSB)' \ '(-endian)+endian' \ '-enhance[enhance image]' \ '-equalize[histogram equalization]' \ diff --git a/Completion/Unix/Command/_iconv b/Completion/Unix/Command/_iconv index e6daad938..bf04acfe4 100644 --- a/Completion/Unix/Command/_iconv +++ b/Completion/Unix/Command/_iconv @@ -38,7 +38,7 @@ if _pick_variant -r variant libiconv='GNU*libiconv' glibc='(Free Soft|GNU*libc|G _arguments -C -S -s : $args && return 0 if [[ $state = *_codeset ]]; then - # suffix is meaningfull only for output encoding + # suffix is meaningful only for output encoding if [[ $state = to_codeset ]] && compset -P '*[^/]/'; then _wanted suffix expl suffix compadd "$@" /TRANSLIT /IGNORE && ret=0 else diff --git a/Completion/Unix/Command/_imagemagick b/Completion/Unix/Command/_imagemagick index c2c9dc478..3afa108ae 100644 --- a/Completion/Unix/Command/_imagemagick +++ b/Completion/Unix/Command/_imagemagick @@ -44,7 +44,7 @@ case "$service" in '*-dispose:GIF disposal method:((0:no\ disposal 1\:don'\''t\ dispose\ between\ frames 2\:overwrite\ frame\ with\ background\ color 3\:overwrite\ with\ previous\ frame))' \ '*-dither[apply dithering]' \ '*-edge:edge detection factor (0.0 - 99.9%%)' \ - '*-endian:image endianess:(MSB LSB)' \ + '*-endian:image endianness:(MSB LSB)' \ '*+endian' \ '*-enhance[enhance noisy image]' \ '*-filter:filter type for resizing:(Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc)' \ @@ -166,7 +166,7 @@ case "$service" in '-descend[descend window hierarchy]' \ '-dispose:GIF disposal method:((0:no\ disposal 1\:don'\''t\ dispose\ between\ frames 2\:overwrite\ frame\ with\ background\ color 3\:overwrite\ with\ previous\ frame))' \ '-dither[apply dithering]' \ - '(+endian)-endian:image endianess:(MSB LSB)' \ + '(+endian)-endian:image endianness:(MSB LSB)' \ '(-endian)+endian' \ '-frame[include window manager frame]' \ '(- *)-help[display help information]' \ @@ -218,7 +218,7 @@ case "$service" in '*-dither[apply dithering]' \ '*+dither[render Postscript without aliasing]' \ '*-draw:drawing primitive:compadd -S "\\ " - rectangle circle ellipse polygon color matte text image' \ - '*-endian:image endianess:(MSB LSB)' \ + '*-endian:image endianness:(MSB LSB)' \ '*+endian' \ '*-filter:filter type for resizing:(Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc)' \ '*-frame[draw frame around image]' \ @@ -297,7 +297,7 @@ case "$service" in '-draw:drawing primitive:compadd -S "\\ " - rectangle circle ellipse polygon color matte text image' \ '-edge:edge detection factor (0.0 - 99.9%%)' \ '-emboss[emboss image]' \ - '(+endian)-endian:image endianess:(MSB LSB)' \ + '(+endian)-endian:image endianness:(MSB LSB)' \ '(-endian)+endian' \ '-enhance[enhance image]' \ '-equalize[histogram equalization]' \ @@ -511,7 +511,7 @@ case "$service" in '-file:output file:_files' \ '-get[get files]' \ '-port:port: _ports' \ - '-proxy:host of proxy ftp deamon:_hosts' \ + '-proxy:host of proxy ftp daemon:_hosts' \ '-print[print files]' \ '-prune[process files from remote directory]' \ '-put[put files]' \ diff --git a/Completion/Unix/Command/_links b/Completion/Unix/Command/_links index 3f55e9c8b..495937709 100644 --- a/Completion/Unix/Command/_links +++ b/Completion/Unix/Command/_links @@ -37,7 +37,7 @@ _arguments -C \ '-memory-cache-size[cache memory]:size (bytes) [1048576]' \ '-image-cache-size[image cache memory]:size (bytes) [1048576]' \ '-font-cache-size[specify font cache size]:size (bytes) [2097152]' \ - "-aggressive-cache[cache everything regardless of server's caching recomendations]:enable [1]:((1\\:on 0\\:off))" \ + "-aggressive-cache[cache everything regardless of server's caching recommendations]:enable [1]:((1\\:on 0\\:off))" \ '-address-preference[specify IP version preference]:preference:(( 0\:system\ default 1\:prefer\ IPv4 diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks index c73a75a03..0b8e45803 100644 --- a/Completion/Unix/Command/_luarocks +++ b/Completion/Unix/Command/_luarocks @@ -135,7 +135,7 @@ ___luarocks_installed_rocks_cache_policy(){ # ) if configuration files are newer: # * set and cache the values from the commands above # ) else: - # * retrive from cache the values of the commands above + # * retrieve from cache the values of the commands above # ) end if # ) end if @@ -190,7 +190,7 @@ ___luarocks_installed_rocks_cache_policy(){ } (( $+functions[__luarocks_installed_rocks] )) || __luarocks_installed_rocks(){ - # This function optionally recieves one argument of the tree in which + # This function optionally receives one argument of the tree in which # installed rocks are searched for. If this argument is used, the installed # rocks which will be completed by this function will not use the cache which # is valid only for installed rocks on default trees like /usr/lib/luarocks diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump index 987b10bb0..989cd3f0b 100644 --- a/Completion/Unix/Command/_objdump +++ b/Completion/Unix/Command/_objdump @@ -52,8 +52,8 @@ case $variant in '(-m --architecture)'{-m+,--architecture=}'[specify the target architecture]:architecture:->architectures' \*{-M+,--disassembler-options=}'[pass target specific information to the disassembler]:option:->disassembler_options' - "(-E --endian)-E+[assume endianess when disassembling]:endianess:((B\:\"assume big endian format when disassembling\" L\:\"assume little endian format when disassembling\"))" - "(-E --endian)--endian=[assume endianess when disassembling]:endianess:((big\:\"assume big endian format when disassembling\" little\:\"assume little endian format when disassembling\"))" + "(-E --endian)-E+[assume endianness when disassembling]:endianness:((B\:\"assume big endian format when disassembling\" L\:\"assume little endian format when disassembling\"))" + "(-E --endian)--endian=[assume endianness when disassembling]:endianness:((big\:\"assume big endian format when disassembling\" little\:\"assume little endian format when disassembling\"))" '--file-start-context[include context from start of file (with -S)]' \*{-I+,--include=}'[add directory to search list for source files]:directory:_files -/' diff --git a/Completion/Unix/Command/_od b/Completion/Unix/Command/_od index 046018131..7673a225b 100644 --- a/Completion/Unix/Command/_od +++ b/Completion/Unix/Command/_od @@ -26,7 +26,7 @@ if _pick_variant gnu=GNU unix --version; then args=( ${(R)args:#(|\*)(|\(*\))-[hBIL]*} ) args+=( '--traditional' - '--endian=[swap input bytes]:endianess:(big little)' + '--endian=[swap input bytes]:endianness:(big little)' {-S+,--strings=-}'[output strings of at least specified bytes long]:length' {-w-,--width=-}'[output specified bytes per line]:bytes' '(- : *)--help[display help and exit]' diff --git a/Completion/Unix/Command/_pandoc b/Completion/Unix/Command/_pandoc index d70d3cf0a..24fee9969 100644 --- a/Completion/Unix/Command/_pandoc +++ b/Completion/Unix/Command/_pandoc @@ -335,7 +335,7 @@ _arguments -C \ '--data-dir=[specify the user data directory to search for pandoc data files]:dir:_pandoc_data_dir' \ '--base-header-level=[specify the base level for headers (defaults to 1)]:number:_pandoc_header_level' \ '--strip-empty-paragraphs[deprecated. Use the +empty_paragraphs extension instead]: :' \ - '--indented-code-classes=[classes to use for indented code blocks]:class:{_message "Classes seperated with ,"}' \ + '--indented-code-classes=[classes to use for indented code blocks]:class:{_message "Classes separated with ,"}' \ '*--filter=[specify an executable to be used as a filter transforming the pandoc AST after the input is parsed and before the output is written]:file:_pandoc_filter' \ '*--lua-filter=[transform the document in a similar fashion as JSON filters (see --filter), but use pandoc'"'"'s build-in lua filtering system]:file:_pandoc_lua_filter' \ {-p,--preserve-tabs}'[preserve tabs instead of converting them to spaces]: :' \ diff --git a/Completion/Unix/Command/_ping b/Completion/Unix/Command/_ping index 3cb6e1008..274204264 100644 --- a/Completion/Unix/Command/_ping +++ b/Completion/Unix/Command/_ping @@ -139,7 +139,7 @@ case ${variant}:${${service#ping}:-4} in darwin*:6) args+=( '-B+[bind the socket to specified interface for sending]:interface:_net_interfaces' - '-G+[specify max,min,increment size for ICMP payload for sweeping pings]:max,min,incr (defalt min=0 incr=1)' + '-G+[specify max,min,increment size for ICMP payload for sweeping pings]:max,min,incr (default min=0 incr=1)' '-z+[specify traffic class]:traffic class' ) ;| diff --git a/Completion/Unix/Command/_pkg-config b/Completion/Unix/Command/_pkg-config index 43773967e..cae6a6293 100644 --- a/Completion/Unix/Command/_pkg-config +++ b/Completion/Unix/Command/_pkg-config @@ -36,7 +36,7 @@ arguments=( "--print-requires[list all modules the package requires]" "--print-requires-private[list all modules the package requires for static linking (see --static)]" # "--msvc-syntax[output linker flags in a form compatible with MSVC++ (Windows only)]" -# "--dont-define-prefix[disables automatic overiding of the variable \"prefix\" (Windows only)]" +# "--dont-define-prefix[disables automatic overriding of the variable \"prefix\" (Windows only)]" # "--prefix-variable=[set the name of the variable \"prefix\" (Windows only)]:prefix value" "*: :->packages" ) diff --git a/Completion/Unix/Command/_postgresql b/Completion/Unix/Command/_postgresql index f0c70a164..595eb1cb4 100644 --- a/Completion/Unix/Command/_postgresql +++ b/Completion/Unix/Command/_postgresql @@ -610,7 +610,7 @@ _pgsql_initdb() { + x # Exclusive options $common_opts_excl + '(l)' # Locale options (general) - {-l+,--locale=}'[specify locale (all catgories)]: :_locales' + {-l+,--locale=}'[specify locale (all categories)]: :_locales' '--no-locale[equivalent to --locale=C]' + lc # Locale options (specific) -- unlike createdb, NOT exclusive with -l '--lc-collate=[specify LC_COLLATE setting]: :_locales' diff --git a/Completion/Unix/Command/_rubber b/Completion/Unix/Command/_rubber index f66540a9f..bd97470dd 100644 --- a/Completion/Unix/Command/_rubber +++ b/Completion/Unix/Command/_rubber @@ -59,7 +59,7 @@ case "$service" in '--boxes[report overfull and underfull boxes]' \ '--check[report errors or warnings default action]' \ '--deps[show the target file s dependencies]' \ - '--errors[show all errors that occured during compilation]' \ + '--errors[show all errors that occurred during compilation]' \ '--refs[show the list of undefined references]' \ '--warnings[show all LaTeX warnings]' \ ':LaTeX file:_files -g "*.(tex|dtx|lhs|w)(-.)"' diff --git a/Completion/Unix/Command/_transmission b/Completion/Unix/Command/_transmission index bd9c44c6f..8a4bebec3 100644 --- a/Completion/Unix/Command/_transmission +++ b/Completion/Unix/Command/_transmission @@ -50,7 +50,7 @@ local global_only_actions=( '(- :)'{-m,--portmap}'[enable portmapping via NAT-PMP or UPnP]' '(- :)'{-M,--no-portmap}'[disable portmapping]' '(- :)'{-o,--dht}'[enable distributed hash table]' - '(- :)'{-O,--no-dht}'[disable distribued hash table]' + '(- :)'{-O,--no-dht}'[disable distributed hash table]' '(- :)'{-u,--uplimit}'[limit the maximum upload speed to limit kB/s]:limit:{_message "limit in kB/sec"}' '(- :)'{-U,--no-uplimit}'[disable upload speed limits]' '(- :)--utp[enable uTP for peer connections]' @@ -69,7 +69,7 @@ local torrent_add_options=( '(-c --incomplete-dir)'{-C,--no-incomplete-dir}'[don'"'"'t store incomplete torrents in a different directory]' {-w-,--download-dir=}'[when used in conjunction with --add, set the new torrent'"'"'s download folder]:dir:{_files -/}' ) -# `torrent_action_only_actions`: *actions* that can be speficied only when explicitly selecting a specific set of torrents +# `torrent_action_only_actions`: *actions* that can be specified only when explicitly selecting a specific set of torrents local torrent_action_only_actions=( {-f,--files}'[get a file list for the current torrent(s)]' {-g,--get}'[mark file(s) for download]:torrent_file:_transmission-remote_torrent_get' @@ -154,7 +154,7 @@ _transmission-remote_torrent(){ local torrents_list_lines=(${(f)"$(transmission-remote "${authentication_args}" --list 2> /dev/null)"}) local -a parts local -a torrents_ids torrents_names - # While itereating through every line in the output above, we don't need the + # While iterating through every line in the output above, we don't need the # first and last line which are just a header and summary for (( t = 2; t < ${#torrents_list_lines[@]} - 1; ++t )); do parts=(${(@s. .)torrents_list_lines[$t]}) diff --git a/Completion/Unix/Type/_baudrates b/Completion/Unix/Type/_baudrates index 6e9ba4d97..a9d7fe541 100644 --- a/Completion/Unix/Type/_baudrates +++ b/Completion/Unix/Type/_baudrates @@ -11,7 +11,7 @@ # # -l LIMIT Lower limit. Like -u but for the lower boundary. # -# -f FUNCTION If given FUNCION is used as a predicate to filter the +# -f FUNCTION If given FUNCTION is used as a predicate to filter the # value in the complete list to generate an arbitrary # sub-set. # diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files index 19ae59629..06d9d8d51 100644 --- a/Completion/Unix/Type/_path_files +++ b/Completion/Unix/Type/_path_files @@ -425,7 +425,7 @@ for prepath in "$prepaths[@]"; do tmp1=( "$prepath$realpath$donepath$tmp2" ) - # count of attemps for pws non-canonical hack + # count of attempts for pws non-canonical hack (( npathcheck = 0 )) while true; do diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo index 5c28b4089..d1f8b7d83 100644 --- a/Etc/FAQ.yo +++ b/Etc/FAQ.yo @@ -2244,7 +2244,7 @@ sect(What is multibyte input?) zsh will be able to use any such encoding as long as it contains ASCII as a single-octet subset and the system can provide information about other characters. However, in the case of Unicode, UTF-8 is the only one you - are likely to enounter that is useful in zsh. + are likely to encounter that is useful in zsh. (In case you're confused: Unicode is the character set, while UTF-8 is an encoding of it. You might hear about other encodings, such as UCS-2 diff --git a/Functions/Zftp/zfautocheck b/Functions/Zftp/zfautocheck index e53fde8d2..a8b24ef0b 100644 --- a/Functions/Zftp/zfautocheck +++ b/Functions/Zftp/zfautocheck @@ -4,7 +4,7 @@ # With first argument including n, don't change to the old directory; else do. # # Set do_close to 1 if the connection was not previously open, 0 otherwise -# With first arguemnt including d, don't set do_close to 1. Broadly +# With first argument including d, don't set do_close to 1. Broadly # speaking, we use this mechanism to shut the connection after use # if the connection had been explicitly closed (i.e. didn't time out, # which zftp test investigates) and we are not using a directory diff --git a/Misc/c2z b/Misc/c2z index 534137296..ce699da8a 100755 --- a/Misc/c2z +++ b/Misc/c2z @@ -10,7 +10,7 @@ # uses the csh to parse its own dot-files, then processes csh output to # convert the csh settings to zsh. # -# When run as a zsh fuction, c2z runs csh as if it were an interactive +# When run as a zsh function, c2z runs csh as if it were an interactive # shell whenever the parent zsh is interactive. When run as a shell # script, the -i switch can be used to force this behavior. # diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c index a60dfcbf8..19f285e34 100644 --- a/Src/Modules/curses.c +++ b/Src/Modules/curses.c @@ -1519,7 +1519,7 @@ zccmd_resize(const char *nam, char **args) // is not available. return 0; } else { - // Without this call some window moves are innacurate. Tested on + // Without this call some window moves are inaccurate. Tested on // OS X ncurses 5.4, Homebrew ncursesw 6.0-2, Arch Linux ncursesw // 6.0, Ubuntu 14.04 ncurses 5.9, FreeBSD ncursesw.so.8 // diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c index 12dd839cf..b8e7c76c6 100644 --- a/Src/Modules/db_gdbm.c +++ b/Src/Modules/db_gdbm.c @@ -766,7 +766,7 @@ static int remove_tied_name( const char *name ) { /* * Unmetafy that: - * - duplicates bufer to work on it, + * - duplicates buffer to work on it, * - does zalloc of exact size for the new string, * - restores work buffer to original content, to restore strlen */ diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index 76824cf58..ef9148d7b 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -1552,7 +1552,7 @@ setpmnameddirs(Param pm, HashTable ht) } } - /* The INTERACTIVE stuff ensures that the dirs are not immediatly removed + /* The INTERACTIVE stuff ensures that the dirs are not immediately removed * when the sub-pms are deleted. */ i = opts[INTERACTIVE]; diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h index 743a2e3ac..2e3249b52 100644 --- a/Src/Zle/comp.h +++ b/Src/Zle/comp.h @@ -35,7 +35,7 @@ typedef struct cexpl *Cexpl; typedef struct cmgroup *Cmgroup; typedef struct cmatch *Cmatch; -/* This is for explantion strings. */ +/* This is for explanation strings. */ struct cexpl { int always; /* display even without matches */ @@ -126,8 +126,8 @@ struct cmatch { #define CMF_FILE (1<< 0) /* this is a file */ #define CMF_REMOVE (1<< 1) /* remove the suffix */ -#define CMF_ISPAR (1<< 2) /* is paramter expansion */ -#define CMF_PARBR (1<< 3) /* paramter expansion with a brace */ +#define CMF_ISPAR (1<< 2) /* is parameter expansion */ +#define CMF_PARBR (1<< 3) /* parameter expansion with a brace */ #define CMF_PARNEST (1<< 4) /* nested parameter expansion */ #define CMF_NOLIST (1<< 5) /* should not be listed */ #define CMF_DISPLINE (1<< 6) /* display strings one per line */ diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 9b8545360..7e3badc57 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -1492,7 +1492,7 @@ set_comp_sep(void) * are specially handled (but currently only if RCQUOTES is not * set, which isn't necessarily correct if the quotes were typed by * the user). - * osq: c.f. odq, taking account of Snull's and embeded "'"'s. + * osq: c.f. odq, taking account of Snull's and embedded "'"'s. * qttype: type of quotes using standard QT_* definitions. * lsq: when quoting is single quotes (QT_SINGLE), counts the offset * adjustment needed in the word being examined in the lexer loop. diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c index 1dcec387d..08355d1b9 100644 --- a/Src/Zle/compctl.c +++ b/Src/Zle/compctl.c @@ -1726,7 +1726,7 @@ static Patprog patcomp, filecomp; * lppre/lpsuf -- the path prefix/suffix, unexpanded * * fpre/fsuf -- prefix/suffix of the pathname component the cursor is in * * prpre -- ppre in expanded form usable for opendir * - * qipre, qisuf-- ingnored quoted string * + * qipre, qisuf-- ignored quoted string * * * * The integer variables hold the lengths of lpre, lsuf, rpre, rsuf, * * fpre, fsuf, lppre, and lpsuf. noreal is non-zero if we have rpre/rsuf. */ diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c index 7d9751fa6..7beb6d847 100644 --- a/Src/Zle/complete.c +++ b/Src/Zle/complete.c @@ -84,7 +84,7 @@ char *compiprefix, Param *comprpms; /* - * An array of Param structures for elemens of $compstate; see + * An array of Param structures for elements of $compstate; see * 'compkparams' below. * * See CP_KEYPARAMS. diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index 05799399d..30fc60b78 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -827,7 +827,7 @@ do_ambiguous(void) * if the completion is completely ambiguous') is set, and some * * prefix was inserted, return now, bypassing the list-displaying * * code. On the way, invalidate the list and note that we don't * - * want to enter an AUTO_MENU imediately. */ + * want to enter an AUTO_MENU immediately. */ if ((uselist == 3 || (!uselist && isset(BASHAUTOLIST) && isset(LISTAMBIGUOUS))) && la && iforcemenu != -1) { diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index cb1c01042..90db8b4b8 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -967,7 +967,7 @@ struct caarg { #define CAA_RARGS 4 #define CAA_RREST 5 -/* The cache of parsed descriptons. */ +/* The cache of parsed descriptions. */ #define MAX_CACACHE 8 static Cadef cadef_cache[MAX_CACACHE]; diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index a5cf1011b..d13aed594 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -55,7 +55,7 @@ struct keymapname { HashNode next; /* next in the hash chain */ char *nam; /* name of the keymap */ int flags; /* various flags (see below) */ - Keymap keymap; /* the keymap itsef */ + Keymap keymap; /* the keymap itself */ }; /* Can't be deleted (.safe) */ diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 22cb21be3..be68f4722 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -893,7 +893,7 @@ getbyte(long do_keytmout, int *timeout, int full) break; if (r == 0) { /* The test for IGNOREEOF was added to make zsh ignore ^Ds - that were typed while commands are running. Unfortuantely + that were typed while commands are running. Unfortunately this caused trouble under at least one system (SunOS 4.1). Here shells that lost their xterm (e.g. if it was killed with -9) didn't fail to read from the terminal but instead diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index 9d46378cf..7b8593dec 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -388,7 +388,7 @@ zle_free_highlight(void) /* * Interface to the region_highlight ZLE parameter. - * Converts betwen a format like "P32 42 underline,bold" to + * Converts between a format like "P32 42 underline,bold" to * the format in the region_highlights variable. Note that * the region_highlights variable stores the internal (point/mark) * region in element zero. diff --git a/Src/pattern.c b/Src/pattern.c index 95e5a79a0..c7c2c8bea 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -2492,7 +2492,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, * Optimization: if we didn't find any Meta characters * to begin with, we don't need to look for them now. * - * For patstralloc pased in, we want the unmetafied length. + * For patstralloc passed in, we want the unmetafied length. */ if (patstralloc == &patstralloc_struct && patstralloc->unmetalen != origlen) { diff --git a/Src/zsh.h b/Src/zsh.h index 657e6d8ec..89b393945 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -1254,7 +1254,7 @@ enum { /* * Assignment has value? - * If the assignment is an arrray, then it certainly has a value --- we + * If the assignment is an array, then it certainly has a value --- we * can only tell if there's an explicit assignment. */ diff --git a/Src/ztype.h b/Src/ztype.h index ae7236774..5c85b0cd7 100644 --- a/Src/ztype.h +++ b/Src/ztype.h @@ -66,7 +66,7 @@ * shell initialisation. */ #define ZTF_INIT (0x0001) /* One-off initialisation done */ -#define ZTF_INTERACT (0x0002) /* Shell interative and reading from stdin */ +#define ZTF_INTERACT (0x0002) /* Shell interactive and reading from stdin */ #define ZTF_SP_COMMA (0x0004) /* Treat comma as a special characters */ #define ZTF_BANGCHAR (0x0008) /* Treat bangchar as a special character */ diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst index 977cbdfe5..3312f8707 100644 --- a/Test/B01cd.ztst +++ b/Test/B01cd.ztst @@ -53,7 +53,7 @@ # stderr. # # The rules for '<', '>' and '?' lines are the same: only the first -# character is stripped (with the excpetion for '*' noted below), with +# character is stripped (with the exception for '*' noted below), with # subsequent whitespace being significant; lines are not subject to any # substitution unless the `q' flag (see below) is set. # diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 83ac7ebf4..76f3e77a1 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -2512,7 +2512,7 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888 local -a x : <<< ${(F)x/y} } -0:Separation / join logic regresssion test +0:Separation / join logic regression test testpath=/one/two/three/four for (( i = 0; i <= 6; ++i )); do -- cgit v1.2.3