diff options
362 files changed, 11357 insertions, 4671 deletions
@@ -1,5 +1,1335 @@ +2020-02-06 dana <dana@dana.is> + + * unposted: Config/version.mk: Update for 5.7.1-test-3 + + * Roman Perepelitsa: 45382: Src/Modules/system.c: Fix infinite + loop in sysread + + * Martin von Wittich: 45388 (tweaked): + Completion/Unix/Type/_diff_options: Restore -w completion lost + in workers/43351 + +2020-02-03 Daniel Shahaf <danielsh@apache.org> + + * 45368: Test/B01cd.ztst, Test/D02glob.ztst: Add tests for + workers/45367's issue about double slashes in 'cd -P' and + $PWD. + +2020-02-02 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 45373: Src/loop.c, Test/C03traps.ztst: ERR_EXIT failed on + command substitution in else branch. + +2020-02-02 Daniel Shahaf <danielsh@apache.org> + + * 45372: Etc/BUGS: Record a symlink loop bug involving :P + +2020-02-02 WGH <wgh@torlan.ru> + + * 45365: Completion/Unix/Command/_git: Fix __git_recent_branches + for the case when a commit has an empty message + +2020-01-29 Daniel Shahaf <danielsh@apache.org> + + * 45343: Src/exec.c, Src/math.c: Queue signals around arithmetic + evaluations + + * 45344: INSTALL: Document where third-party completion functions + should be installed. + +2020-01-28 Daniel Shahaf <danielsh@apache.org> + + * 45345: Util/ztst-syntax.vim: internal: ztst.vim: Fix + highlighting of zsh comments in test payload + +2020-01-26 Daniel Shahaf <danielsh@apache.org> + + * unposted: Src/init.c: internal: Add some comments and fix + indentation. No functional change. + +2020-01-23 Daniel Shahaf <danielsh@apache.org> + + * 45340: Src/params.c: internal: Document the difference between + paramtab and realparamtab. + +2020-01-19 Eitan Adler <lists@eitanadler.com> + + * 45332: Completion/Unix/Command/_git: add completion for + git-version + +2020-01-19 Mikael Magnusson <mikachu@gmail.com> + + * unposted: _brace_parameter: add missing \ + +2020-01-16 Daniel Shahaf <danielsh@apache.org> + + * 45305: Test/A01grammar.ztst: Add an XFail test: The + exec-last-command optimization is applied to try/always. + + * 45307: Doc/Zsh/mod_zutil.yo: zstyle docs: Unoverload a + placeholder variable name. + + * 45306: Doc/Zsh/mod_zutil.yo: zstyle docs: Introduce the first + synopsis in the same way as all others: with an item()(). + + * unposted: Doc/Zsh/options.yo, Doc/Zsh/params.yo: docs: Fix + a cross-reference. + +2020-01-15 Daniel Shahaf <danielsh@apache.org> + + * 45287: Doc/Zsh/expn.yo: zshexpn: Describe parameter elision + and add some introductory prose + + * 45302: Src/builtin.c: bin_umask(): Queue signals around + umask(). + +2020-01-14 Daniel Shahaf <d.s@daniel.shahaf.name> + + * users/24656: Doc/Zsh/mod_zutil.yo: docs: Add an example of + setting and querying zstyles + +2020-01-14 Peter Stephenson <p.stephenson@samsung.com> + + * users/24659: Doc/Zsh/compsys.yo: Cross-reference use of + matcher and matcher-list with tag-order. + +2020-01-13 dana <dana@dana.is> + + * 45296: Test/D02glob.ztst: Clean up after test from users/24633 + +2020-01-13 Daniel Shahaf <danielsh@apache.org> + + * 45290: Test/list-XFails: New helper script for listing + XFail tests. + +2020-01-12 Daniel Shahaf <danielsh@apache.org> + + * users/24633: Test/D02glob.ztst: Add an xfail test for + users/24619. + +2020-01-11 Oliver Kiddle <okiddle@yahoo.co.uk> + + * unposted: Completion/Unix/Command/_cat: additional typo fix + + * Eitan: 45280: Completion/Unix/Command/_git: add -local + variants to completed date formats + +2020-01-11 Peter Stephenson <p.stephenson@samsung.com> + + * users/24628 (fixed up): Doc/Zsh/contrib.yo: Add example of how + to bind word matching widget with a fixed style. + +2020-01-10 Daniel Shahaf <danielsh@apache.org> + + * 45266: Completion/Linux/Command/_losetup: Fix losetup + completion, broken in da085b7a20729401c725f91ae930200d0deda64f + (41720). + + * unposted: Doc/Zsh/mod_zpty.yo: Fix punctuation. + +2020-01-10 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 45264: configure.ac: use /dev/fd on Cygwin for process + substitution + +2020-01-09 Daniel Shahaf <danielsh@apache.org> + + * unposted: Completion/Debian/Command/_sbuild, + Completion/Unix/Command/_growisofs: Two additional typo fixes. + +2020-01-09 Jens Schleusener <Jens.Schleusener@fossies.org> + + * 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 Mikael Magnusson <mikachu@gmail.com> + + * 45272, 45273: Fix more typos. + +2020-01-08 dana <dana@dana.is> + + * 45261: Completion/Unix/Command/_gcc: Detect clang-as-gcc + +2020-01-07 Daniel Shahaf <danielsh@apache.org> + + * unposted: Test/X04zlehighlight.ztst: internal: Remove Vim + modeline that interferes with ztst.vim. + + * unposted: Util/ztst-syntax.vim: internal: ztst.vim: Use + :syn-sync to work around (#x) and "`\\\\\\\\`" confusing the + highlighting. + + * unposted: Util/zyodl.vim: internal: zyodl.vim: Support glob + qualifiers in example()'s + + * unposted: Util/zyodl.vim: internal: zyodl.vim: Support yodl + comments. + +2020-01-07 Damien Thébault <damien.thebault@gmail.com> + + * github #44: Completion/Unix/Command/_picocom: Allow completion + for picocom to list symlinks to character devices + +2020-01-06 dana <dana@dana.is> + + * Eitan Adler: 45245: Completion/Unix/Command/_gcc: add some + clang specific warnings + +2020-01-06 Daniel Shahaf <danielsh@apache.org> + + * 45231: Completion/Unix/Command/_rsync: When completing remote + modules, ignore more of the motd. + +2020-01-05 dana <dana@dana.is> + + * unposted: Completion/Unix/Command/_tac: Eliminate superfluous + variable + + * 45226 (with Daniel, 45223): Completion/Unix/Command/_man: + Improve completion of file paths + + * 45184: Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo: Clarify + documentation of %-sequences understood by compadd -[Xx] + +2020-01-05 Andrey Butirsky <butirsky@gmail.com> + + * 45239: Functions/Newuser/zsh-newuser-install: Remove + 'appendhistory' from zsh-newuser-install + +2020-01-03 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 45218: Completion/Unix/Command/_swaks: add more options + + * 45196: Completion/Unix/Command/_make: fix completion after + make -C, allowing for -C being used multiple times + +2020-01-02 Daniel Shahaf <danielsh@apache.org> + + * unposted (after 45183): Doc/Zsh/contrib.yo: Fix yodl error: + "contrib.yo:4457: No macro: back(...)". + + * 45181: Src/glob.c, Test/D04parameter.ztst: Fix workers/45164: + ${(S)%%} will now consider the empty string as a potential match. + +2020-01-01 dana <dana@dana.is> + + * Stephane: 45183: Doc/Zsh/builtins.yo, Doc/Zsh/contrib.yo, + Doc/Zsh/expn.yo: Improve documentation examples + +2020-01-01 Daniel Shahaf <danielsh@apache.org> + + * unposted: Test/D04parameter.ztst: Add some tests for ${(S)}, + including a regression test for workers/45164. + + * 45169/0002 (tweaked for trailing newlines): Etc/BUGS, + Test/C03traps.ztst: Add an expected-to-fail test for + workers/44007. + + * 45169/0001: Test/B01cd.ztst, Test/ztst.zsh, + Util/ztst-syntax.vim: In the test suite, allow test cases to + be marked as expected to fail. + +2019-12-31 Daniel Shahaf <danielsh@apache.org> + + * users/24582 + users/24583: Test/D04parameter.ztst, + Test/Y01completion.ztst: Add regression tests for the previous + commit. + +2019-12-30 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * users/24581: Src/Zle/zle_tricky.c, Src/hist.c: Array assignments + after the first weren't parsed correctly by ${(z)...} or by + completion. + +2019-12-31 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 45160: Doc/Zsh/expn.yo: zshexpn: Expand documentation + of (S) + +2019-12-28 Sebastian Gniazdowski <sgniazdowski@gmail.com> + + * 45150 + 45152: Doc/Zsh/expn.yo: zshexpn: Use a more minimal + example in the documentation of (#b). + +2019-12-27 Daniel Shahaf <danielsh@apache.org> + + * unposted: Test/B01cd.ztst, Util/ztst-ftplugin.vim, + Util/ztst-syntax.vim: internal: Vim ztst support: Add an ftplugin + in addition to the syntax highlighter. + +2019-12-26 dana <dana@dana.is> + + * 45130: Completion/Base/Utility/_multi_parts: Always pass -f + to compadd if given by caller + + * unposted: Src/utils.c: Fix macro guard missed in previous + commit + +2019-12-26 Daniel Shahaf <danielsh@apache.org> + + * unposted: Src/utils.c: internal: Allow %L in zerrmsg() in + non-debug builds, too. + +2019-12-23 Daniel Shahaf <danielsh@apache.org> + + * unposted: Completion/Unix/Command/_stdbuf: Fix mismatch + between the long options on the one hand, and the short options + and descriptions on the other hand. + +2019-12-22 Daniel Shahaf <danielsh@apache.org> + + * unposted: Test/B01cd.ztst, Util/ztst.vim: Fix broken build: + 45109 (!) broke Test/Y01completion.ztst. + + * 45110: Doc/Zsh/grammar.yo: zshmisc(1): Fix markup of "try-list" + and "always-list". + + * 45111: Doc/Zsh/grammar.yo, Etc/BUGS, NEWS, + Test/A01grammar.ztst: zshmisc(1): Clarify the documentation of + 'return' and 'exit' in conjunction with try/always + + * 45112: Doc/Zsh/mod_zutil.yo: zshmodules: Explicitly document + the return values of the 'zstyle' getters -s, -b, and -a. + + * 45113: Doc/Zsh/contrib.yo: vcs_info docs: Clarify documentation + of the %p/%u/%a patch-format expandos. + + * 45114: Functions/VCS_Info/VCS_INFO_patch2subject: vcs_info + quilt: Improve support for svn-style patch headers. + + * 45115: Misc/vcs_info-examples: vcs_info examples: Make the + quilt-patch-dir example friendlier. + + * 45116: Misc/vcs_info-examples: vcs_info examples: Add an + example of showing Git environment variables. + + * 45107: Test/ztst.vim: Highlight some more special variables + + * 45108: Test/ztst.vim: Conceal the '>' or '?' on pattern + expected output / expected errput lines. + + * 45109: Test/B01cd.ztst, Test/ztst.vim, Util/zyodl.vim: Add + Vim highlighting file for Test/*.ztst files. + +2019-12-21 dana <dana@dana.is> + + * unposted: Config/version.mk: Update for 5.7.1-test-2 + + * 45101: Etc/creating-a-release.txt: Adjust white space + + * 45101 (tweaked per 45104): Etc/creating-a-release.txt: + Document new dev/test versioning scheme, clarify other release + steps. New versioning scheme not to be used until after 5.8 + +2019-12-21 Daniel Shahaf <danielsh@apache.org> + + * unposted: Test/A01grammar.ztst: Group related tests. + No functional change. + + * unposted: Etc/BUGS: Add two bugs discussed on -workers@ + this week + +2019-12-20 dana <dana@dana.is> + + * 45055: Doc/Zsh/compsys.yo: Clarify _files documentation + +2019-12-18 Peter Stephenson <p.stephenson@samsung.com> + + * 45083: Src/exec.c: execarith() needs signal protection as + it sets variables. + +2019-12-18 Daniel Shahaf <danielsh@apache.org> + + * 45076: Src/loop.c: internal: Simplify handling of + try_tryflag. No functional change. + + * 45066: Src/builtin.c, Src/exec.c, Src/params.c: internal: + Document forklevel, locallevel, and exit_pending. + + * 45065: Src/Makefile.in: Make 'make -s' print nothing when it + does nothing. + + * 45064: Src/utils.c: Fix the mktemp() warning, in debug + builds only. + + * 45073: Doc/Zsh/contrib.yo: regex-replace docs: Simplify grammar + (avoid a double negative, state defaults first). + +2019-12-17 Daniel Shahaf <danielsh@apache.org> + + * 45058: Src/Modules/zpty.c, Src/Zle/zle_main.c, Src/builtin.c, + Src/exec.c, Src/init.c, Src/signals.c, Src/subst.c, Src/zsh.h: + internal: Add symbolic names to possible values of zexit()'s + "from_where" parameter. No functional change. + + * unposted: Src/builtin.c: Update comment to reflect variable + rename in 41012 (zsh-5.3.1-182-gd7110d8f0). + +2019-12-16 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44698, 45000: Baptiste BEAUPLAT: Completion for sbuild + + * github #36: Aurélien Olivier: Add completion file for GNU Stow + + * 45035: Doc/Zsh/zle.yo: be explicit about the need for + a # in colours specified as hex triplets + +2019-12-15 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 45025: Src/exec.c: fix re-entrancy problem with memory + management in readoutput(). This could cause a signal + received during $(...) to corrupt memory. + +2019-12-14 dana <dana@dana.is> + + * unposted: Config/version.mk, Etc/FAQ.yo, README: Update for + 5.7.1-test-1 + +2019-12-12 Peter Stephenson <p.stephenson@samsung.com> + + * Martijn: 45009: Src/builtin.c, Doc/Zsh/builtins.yo, + Doc/Zsh/options.yo: POSIX_CD needs to suppress special + use of options so that POSIX-allowed argument forms work as + expected. + + * 45001: Src/glob.c, Test/D04parameter.ztst: ${...%...} didn't + test for zero-length matches, which should be preferred where + possible. + +2019-12-11 Martijn Dekker <martijn@inlv.org> + + * 45004: Src/builtin.c, Src/compat.c, Src/exec.c, Src/glob.c, + Src/hashtable.c, Src/hist.c, Src/init.c, Src/jobs.c, + Src/lex.c, Src/main.c, Src/mem.c, Src/module.c, Src/params.c, + Src/parse.c, Src/pattern.c, Src/prompt.c, Src/subst.c, + Src/text.c, Src/watch.c, Src/zsh.h, Test/A02alias.ztst, + Test/C01arith.ztst, Test/C02cond.ztst, Test/D03procsubst.ztst, + Test/D06subscript.ztst, Test/D08cmdsubst.ztst, + Test/E01options.ztst, Test/V10private.ztst: Fix typos in comments + + * 45003: Etc/FAQ.yo, Etc/zsh-development-guide, + Functions/Prompts/prompt_oliver_setup, + Functions/Zle/insert-composed-char, NEWS, README: Fix more + documentation typos + +2019-12-10 Peter Stephenson <p.stephenson@samsung.com> + + * 44997: Src/Zle/compctl.c: prefix needed extra munging for + hyphen with GLOB_COMPLETE in compctl. + +2019-12-04 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44976: Src/Zle/zle_main.c: describe-key-briefly in visual mode + + * Sebastian: 44970: Completion/Zsh/Context/_brace_parameter: + Update the description of S flag + +2019-12-04 Martijn Dekker <martijn@inlv.org> + + * 44981: Doc/Zsh/cond.yo, Doc/Zsh/contrib.yo, Doc/Zsh/expn.yo, + Doc/Zsh/mod_mapfile.yo, Doc/Zsh/mod_parameter.yo, + Doc/Zsh/params.yo, Doc/intro.ms: Fix some typos in the + documentation. + +2019-12-03 Daniel Shahaf <danielsh@apache.org> + + * 44960: Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs: + vcs_info cvs: Fix infinite loop when /CVS exists. + + * 44961: Functions/VCS_Info/Backends/VCS_INFO_get_data_svn: + vcs_info svn: Fix infinite loop when /.svn exists. + + * 44962: Functions/VCS_Info/VCS_INFO_bydir_detect, + Functions/VCS_Info/vcs_info: vcs_info: Document internal function + and variable + + * 44964: Doc/Zsh/redirect.yo: zshmisc(1): Document APPEND_CREATE + under the append redirection operators, >> and >>!. + +2019-12-02 dana <dana@dana.is> + + * 44969: Etc/completion-style-guide: Mention defaults and + superfluous descriptions + + * unposted (cf. 44967): Completion/Linux/Command/_alsa-utils: + Fix minor syntax error in arg spec + +2019-12-02 Daniel Shahaf <danielsh@apache.org> + + * unposted: Misc/vcs_info-examples: vcs_info: Add an example + of using $functions to find hooks by name. + +2019-12-01 Oliver Kiddle <okiddle@yahoo.co.uk> + + * unposted: Completion/Unix/Command/_killall: another place + to complete selinux contexts that was missed in 44781 + + * 44968: Completion/Unix/Command/_objdump, + Completion/Unix/Command/_readelf: cleanup and update objdump + and readelf completions + + * Sebastian: 44967: Completion/Linux/Command/_alsa-utils: + Completion for aplay from alsa-utils + +2019-12-01 Daniel Shahaf <danielsh@apache.org> + + * unposted: Src/Modules/zutil.c, Test/V05styles.ztst: zstyle: + Add a unit test and some comments. + + * unposted: Completion/Unix/Command/_sqlite: Fix syntax error + +2019-11-30 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 44958: Functions/VCS_Info/VCS_INFO_quilt, README: vcs_info + quilt: Avoid forks + + * 44945: Functions/VCS_Info/Backends/VCS_INFO_detect_git: + vcs_info git: Optimize detection by running fewer external + commands. + +2019-11-29 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 44948: Completion/Unix/Command/_subversion: Make + _svn_controlled offer everything rather than nothing. + + * 44947: Completion/Unix/Command/_subversion: Complete the + 'auth', 'changelist', 'patch', 'resolve', and 'x-unshelve' + subcommands. + + * 44946: Completion/Unix/Command/_subversion: Make _svn_conflicts + not offer all files in the directory. + +2019-11-26 Wayne Davison <wayned@users.sourceforge.net> + + * 44912: Completion/Base/Completer/_expand: Don't set done_quote=1 + if the glob result is empty. Fixes more cases of missing quotes. + +2019-11-24 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44923: Completion/Unix/Command/_git: update options for 2.24 + + * 44896: Completion/Unix/Command/_make: use opt_args to find + base directory and use it for $(CURDIR) + +2019-11-19 Daniel Shahaf <d.s@daniel.shahaf.name> + + * users/24451: Src/compat.c: zgetcwd: Add a guard against + returning an empty string. + + * unposted: Test/W01history.ztst: Add smoke test for :P history + modifier. + +2019-11-18 Peter Stephenson <p.stephenson@samsung.com> + + * users/24445: Src/hist.c: Add missing support for :P to history + code (was already present in glob qualifiers and variables). + +2019-11-11 skirit <skirit@dump.cz> + + * unposted (salsa.debian.org MR!1): Completion/Unix/Command/_ip: + Complete the -brief option + +2019-11-08 Daniel Shahaf <d.s@daniel.shahaf.name> + + * unposted: Doc/Zsh/compsys.yo: _values: Use the formal + parameter's name in the docstring. + +2019-11-07 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 44897: Completion/Unix/Command/_subversion: Complete + --show-item=changelist + +2019-11-06 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44895: Completion/Solaris/Command/_svccfg: complete options + for state change notifications and other improvements + + * Eitan Adler: 44882: Completion/Unix/Command/_gcc: add + completion of -save-stats flag + + * unposted: Completion/Base/Utility/_sequence: fix missing local + declarations + +2019-10-29 Oliver Kiddle <okiddle@yahoo.co.uk> + + * github #41: Sebastian: Extend _dbus with dbus-launch completion + + * unposted: Completion/Unix/Command/_zfs: tweak to check for + openzfs rather than Solaris + + * github #40: Teddy Heinen: Completion/Unix/Command/_zfs: + adjust zfs completion to use acltype on linux instead of aclmode + +2019-10-28 Peter Stephenson <p.stephenson@samsung.com> + + * 44864: Src/jobs.c: Avoid infinite loop in interactive mode + when trying to grab terminal. Fail after 100 goes (arbitrary + choice). + + * Sebastian: 44865: configure.ac: Try harder to link in curses + even if not needed for termcap variables. + +2019-10-18 dana <dana@dana.is> + + * 44846: Completion/Unix/Type/_dates: Fix regression caused by + workers/44274 + +2019-10-18 Oliver Kiddle <okiddle@yahoo.co.uk> + + * c.f. 44831: Completion/Linux/Command/_tpconfig, + Completion/Unix/Command/_elm, Completion/Unix/Command/_flasher, + Completion/Unix/Command/_prcs, Completion/Unix/Command/_raggle, + Completion/Unix/Command/_uzbl, Completion/Unix/Command/_vux, + Completion/Unix/Command/_sablotron: remove completion functions + for long dead projects + + * c.f. 44831: Completion/Unix/Command/_notmuch, + Completion/Unix/Command/_hg, Completion/X/Command/_zathura: + remove completion functions included in upstream projects + + * 44849: Completion/Unix/Command/_dhclient, + Completion/Unix/Command/_date, Completion/Unix/Command/_grep, + Completion/Unix/Command/_ssh, Completion/BSD/Command/_vmctl: + completion updates for changes in OpenBSD 6.6 + +2019-10-16 Peter Stephenson <p.stephenson@samsung.com> + + * _RuRo_ (Андрей Стоцкий): 44841: Src/exec.c: Better error + checking of nice, since return value can be negative. + +2019-10-14 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 44812: Completion/Unix/Command/_subversion: Fix syntax error + in 44726/0001 + + * 44809: Completion/Zsh/Command/_typeset: Complete 'functions -c' + +2019-10-12 dana <dana@dana.is> + + * 44767: Completion/Base/Core/_description: Ignore -J + + * 44681 (tweaked): Completion/Unix/Command/_composer: Eliminate + questionable eval, fix quoting issue + +2019-10-10 Daniel Shahaf <d.s@daniel.shahaf.name> + + * unposted: Src/builtin.c: functions -c: Fix typo + +2019-10-04 Roman Perepelitsa <roman.perepelitsa@gmail.com> + + * 44784: Src/Zle/zle_main.c: Fix infinite loop when TTY + disappears + +2019-10-02 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 44797: Completion/Unix/Command/_git: _git-config: Complete + unknown options from 'git help -c'. + +2019-10-01 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44800: Completion/Unix/Command/_tmux: complete tmux formats + + * 44799: Completion/Unix/Command/_pv: new pv completion + + * 44798: Completion/Unix/Command/_netstat, + Completion/Linux/Command/_strace, Completion/X/Command/_xterm + Completion/Linux/Command/_kpartx, Completion/Linux/Command/_ss, + Completion/Linux/Command/_btrfs, Completion/X/Command/_xrandr, + Completion/Unix/Command/_gnutls, Completion/Unix/Command/_make, + Completion/Unix/Command/_xargs, Completion/Unix/Type/_ld_debug: + completion option update + +2019-09-30 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44783, 44791: Completion/Solaris/Command/_dladm, + Completion/Unix/Command/_dsh, Completion/Unix/Command/_ssh, + Completion/Unix/Command/_ansible: mark some repeatable + options with * in the _arguments specs + + * 44788: Completion/Redhat/Command/_rpm: handle newer rpm + commands like rpmkeys, rpmsign and update options + +2019-09-26 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44782: Completion/BSD/Command/_pkgin, + Completion/Unix/Command/_avahi: new completions + + * Gautam Iyer: gitlab !9: Completion/Unix/Command/_seafile: + Rudimentary seafile client completion + + * Doron Behar: gitlab !11: Completion/Unix/Command/_luarocks: + Fix/improve logic of cache validation + + * 44781: Completion/Linux/Type/_selinux_contexts, + Completion/Linux/Type/_selinux_roles, + Completion/Linux/Type/_selinux_types, + Completion/Linux/Type/_selinux_users, + Completion/Linux/Command/_chcon, Completion/Unix/Command/_cp, + Completion/Unix/Command/_find, Completion/Unix/Command/_install, + Completion/Unix/Command/_mkdir, Completion/Unix/Command/_mkfifo, + Completion/Unix/Command/_mknod, Completion/Unix/Command/_sudo: + add completion of SELinux contexts + + * 44780: Completion/Unix/Command/_getent: add completion to + getent for the utmpx key on FreeBSD. + + * 44779: Completion/Unix/Command/_git: completion for new + git switch and git restore commands + +2019-09-24 Bart Schaefer <schaefer@brasslantern.com> + + * unposted (see 44772): Functions/Zle/bracketed-paste-magic: + quote the string argument to zle -U + +2019-09-20 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44768: Completion/Unix/Command/_tar: improve completion of + long options + +2019-09-18 Tobias Schulte <tobias.schulte@gliderpilot.de> + + * github #38: Completion/Unix/Command/_git: fix completion text + for git update-index --chmod + +2019-09-06 Daniel Hahler <zsh@thequod.de> + + * 44722: Completion/Unix/Command/_make: use --always-make + instead of .PHONY for GNU make. + +2019-09-04 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 44726/0002: Completion/Unix/Command/_subversion: Update + --show-item= completion to 1.12.0. + + * 44726/0001: Completion/Unix/Command/_subversion: Use + 'svn help -v' to show global options, experimental options, + and experimental subcommands (upstream issue SVN-4828, to be + released in Subversion 1.13.0) + +2019-09-04 Ned Batchelder <ned@nedbatchelder.com> + + * github #37: Doc/Zsh/builtins.yo: Make it easier to understand + what "fc -e" does. + +2019-08-29 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44714 (tweaked): Src/utils.c: Take account of CDABLE_VARS + while checking spelling + +2019-08-28 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44710: Src/Builtins/rlimits.awk, Src/Builtins/rlimits.c, + configure.ac: support RLIMIT_UMTXP on FreeBSD + + * 44709: Src/zsh_system.h: incluce sys/capability.h only if + HAVE_CAP_GET_PROC is defined + +2019-08-27 Peter Stephenson <p.stephenson@samsung.com> + + * Sebastian: 44712: configure.ac: prefer any form of ncurses to + other terminal library as we rely on its features to provide + modules. + +2019-08-19 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44614: Completion/Debian/Command/_apt: apt list option completion + + * Lajos Koszti: 44633: Completion/Unix/Command/_ansible: + complete ansible-vault actions like create, edit, etc. + + * 44587: Completion/Linux/Command/_btrfs, + Completion/Linux/Command/_networkmanager, + Completion/Linux/Command/_ss, Completion/Linux/Command/_sshfs, + Completion/Linux/Command/_strace, Completion/Unix/Command/_ansible, + Completion/Unix/Command/_awk, Completion/Unix/Command/_gcore, + Completion/Unix/Command/_gnutls, Completion/Unix/Command/_ifconfig, + Completion/Unix/Command/_less, Completion/Unix/Command/_ln, + Completion/Unix/Command/_lsof, Completion/Unix/Command/_mpc, + Completion/Unix/Command/_rclone, Completion/Unix/Command/_sqlite, + Completion/Unix/Command/_tmux: completion option updates + +2019-08-17 dana <dana@dana.is> + + * 44675: Completion/Unix/Command/_find: Fix return status + + * unposted: NEWS: Mention `functions -c` + +2019-08-14 Peter Stephenson <p.stephenson@samsung.com> + + * 44664: Src/params.c, Test/D04parameter.ztst: Ensure + temporary assignment around builtin in function doesn't + trash global variable. + +2019-08-03 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 44635: Src/exec.c: don't apply STAT_NOPRINT to backgrounded + jobs. + +2019-08-03 Peter Stephenson <p.stephenson@samsung.com> + + * 44637: Shlomi Fish: Src/makepro.awk: "=" doesn't need quoting + in awk regexp and can cause warnings. + +2019-07-30 Peter Stephenson <p.stephenson@samsung.com> + + * Eric Cook: 24102: Completion/Unix/Command/_user_admin: subuids + / subgids completion. + +2019-07-26 Peter Stephenson <p.stephenson@samsung.com> + + * Kamil: 44582: Src/Zle/zle_utils.c: update to foregoing to + use DPUTS() properly. + +2019-07-24 Peter Stephenson <p.stephenson@samsung.com> + + * Kamil: 44566: Src/Zle/zle_utils.c: make failed searches of + history in Zle robust. + +2019-07-19 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44356: Completion/Unix/Command/_ansible: complete ansible + callback plugins for the relevant environment variable's value + + * 44551: Completion/Unix/Command/_git: update for new git changes + +2019-07-16 Peter Stephenson <p.stephenson@samsung.com> + + * 44523: Test/Makefile.in: allow ZTST_handler to be something + other than runtests.zsh to accommodate alternative test modes. + +2019-07-15 Peter Stephenson <p.stephenson@samsung.com> + + * 44509: Src/params.c: Prevent crash with modified PATH / path + combination in function. + +2019-07-10 Peter Stephenson <p.stephenson@samsung.com> + + * 44505: Functions/Chpwd/zsh_directory_name_generic: Longest + prefix matching was broken if there were suffixes indicating + further handling. + +2019-07-09 Peter Stephenson <p.stephenson@samsung.com> + + * unposted: Etc/FAQ.yo: typo. also updates to outdated notes on + multibyte support. + +2019-07-08 Bart Schaefer <schaefer@brasslantern.com> + + * 43755: Functions/Zle/smart-insert-last-word: (Belated commit) + Fix state management for repeat uses to avoid clobbering command + line when NOT a repeat + + * 44502: Src/builtin.c: Quote function name for "autoload -X" + + * 44495: Doc/Zsh/params.yo: Mention coproc under $! + +2019-07-08 Peter Stephenson <p.stephenson@samsung.com> + + * users/24030: Etc/FAQ.yo: Note that *.{bla,hbl,ahb} is an + expansion, not a pattern match, and what to do instead. + +2019-07-02 Peter Stephenson <p.stephenson@samsung.com> + + * 44480: Doc/Zsh/mod_socket.yo, Doc/Zsh/mod_system.yo, + Doc/Zsh/redirect.yo, Src/Modules/system.c, Src/exec.c: + Don't automatically close FDT_EXTERNAL file descriptors. + All sysopen-created fd's become FDT_EXTERNAL. =(...) + calls closem() consistent with other substitutions. + +2019-07-01 Peter Stephenson <p.stephenson@samsung.com> + + * Martijn: 44469: Src/builtin.c, Test/B10getopts.ztst: correct + error on missing option argument. + +2019-06-24 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 44446: Src/parse.c, Test/A04redirect.ztst: fix here document + with file descriptor declarator. + +2019-06-23 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * Martijn: 44443: Src/builtin.c: POSIX allows exporting readonly + variables. + +2019-06-20 Peter Stephenson <p.stephenson@samsung.com> + + * 44435: Doc/Zsh/expn.yo, NEWS, README, Src/Zle/compctl.c, + Src/glob.c, Src/hist.c, Src/subst.c, Test/D02glob.ztst, + Test/D04parameter.ztst, Test/W01history.ztst: Handle + trailing digit arguments of :t and :h modifiers. + +2019-06-19 Peter Stephenson <p.stephenson@samsung.com> + + * Roman Perepelitsa: 44430: Src/prompt.c: various problems with + countprompt() including wide characters, split tabs and trailing + Meta characters. + +2019-06-10 Peter Stephenson <p.stephenson@samsung.com> + + * Eitan Adler: 44409: config.guess, config.sub: update to + 2019-05-28. + +2019-06-06 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * Stephane (44387, edited): Doc/Zsh/restricted.yo: Describe some + problems with restricted mode. + +2019-06-03 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44389: Completion/BSD/Type/_bsd_disks, + Completion/BSD/Type/_fbsd_device_types, + Completion/Unix/Command/_iostat, Completion/Unix/Command/_vmstat: + update _iostat and _vmstat for BSD + +2019-05-28 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 44361: Src/pattern.c: Ensure variables used recursively are + initialised in pattern matching. + +2019-05-28 Peter Stephenson <p.stephenson@samsung.com> + + * Jim Murphy: 44364: Doc/Zsh/intro.yo: refer to main zsh page in + zshall doc. + +2019-05-23 Oliver Kiddle <okiddle@yahoo.co.uk> + + * unposted: Completion/Linux/Command/_iptables: remove spurious + reference to nonexistent completion function + + * 44349: Completion/Linux/Command/_cryptsetup, + Completion/X/Command/_x_utils, Completion/Linux/Command/_lsblk, + Completion/Linux/Command/_ss, Completion/Linux/Command/_valgrind, + Completion/Linux/Command/_strace, Completion/Unix/Command/_bash, + Completion/Unix/Command/_dhclient, Completion/Unix/Command/_dig, + Completion/Unix/Command/_entr, Completion/Unix/Command/_env, + Completion/Unix/Command/_gem, Completion/Unix/Command/_gnutls, + Completion/Unix/Command/_links, Completion/Unix/Command/_nm, + Completion/Unix/Command/_objdump, Completion/Unix/Command/_ruby, + Completion/Unix/Command/_sed, Completion/Unix/Command/_sqlite, + Completion/Unix/Command/_ssh, Completion/Unix/Command/_tiff, + Completion/Unix/Command/_tree, Completion/Unix/Command/_wget, + Completion/Linux/Command/_ethtool: completion option updates + + * 44345: Src/text.c, Test/A01grammar.ztst: fix wordcode traversal + where ! without a following command could result in a crash + +2019-05-20 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44307: Src/exec.c, Src/init.c, Src/params.c, Src/utils.c: + allow for atoi() returning a negative number + + * 44308: Completion/Linux/Command/_modutils: update Linux + modutils completion + +2019-05-14 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44284: Src/builtin.c: combination of -T and -p to typeset + crashed the shell. + + * 44290: Src/jobs.c: job number exceeding int range and wrapping + to a negative number crashed the shell. + + * 44291: Src/builtin.c: printf with argument specifier out of + range for an int crashed the shell. + +2019-05-14 Peter Stephenson <p.stephenson@samsung.com> + + * 44296: Src/parse.c, Test/B02typeset.ztst: "typeset Q= {X}" + crashed the shell. + +2019-05-13 Peter Stephenson <p.stephenson@samsung.com> + + * 44259: Src/signals.c: Ensure we can set signal to default + even if it was ignored on entry to the shell. + +2019-05-08 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44279: Completion/BSD/Command/_cu, Completion/BSD/Command/_gstat, + Completion/BSD/Command/_procstat, Completion/BSD/Command/_signify, + Completion/BSD/Command/_sockstat, Completion/BSD/Command/_vmctl, + Completion/Unix/Command/_arp, Completion/Unix/Command/_arping, + Completion/Unix/Command/_cp, Completion/Unix/Command/_date, + Completion/Unix/Command/_gcore, Completion/Unix/Command/_install, + Completion/Unix/Command/_ls, Completion/Unix/Command/_netstat, + Completion/Unix/Command/_ping, Completion/Unix/Command/_script, + Completion/Unix/Command/_tcpdump, Completion/Unix/Command/_top, + Completion/Unix/Command/_vmstat, Completion/Unix/Command/_zpool: + completion updates for Dragonfly 5.4, FreeBSD 12 and OpenBSD 6.5 + +2019-05-08 dana <dana@dana.is> + + * unposted: Test/Y01completion.ztst: Fix bad encoding + + * Oliver Kiddle: unposted: Test/Y01completion.ztst: Add compset tests + related to workers/44275 + + * 44275: Doc/Zsh/compwid.yo, Src/Zle/complete.c: Fix compset -p/-s + multibyte inconsistency and documentation + +2019-05-07 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 44274: Completion/Base/Core/_description, + Completion/Base/Utility/_describe, Completion/Base/Utility/_guard, + Completion/Base/Utility/_multi_parts, + Completion/Base/Utility/_sep_parts, + Completion/Base/Utility/_sequence, Completion/Zsh/Command/_compadd, + Completion/Darwin/Type/_mac_files_for_application, + Completion/Redhat/Command/_yum, Completion/Unix/Command/_git, + Completion/Unix/Type/_canonical_paths, + Completion/Unix/Type/_baudrates, Completion/Unix/Type/_files, + Completion/Unix/Type/_list_files, Completion/Unix/Type/_path_files, + Completion/Zsh/Type/_file_descriptors, + Doc/Zsh/compsys.yo, Doc/Zsh/compwid.yo, NEWS, + Src/Zle/comp.h, Src/Zle/compcore.c, Src/Zle/complete.c: + allow finer control of completion match sorting with + arguments to compadd's -o option + + * Gautam Iyer: gitlab !6: Completion/Unix/Command/_rclone: + Rudimentary rclone completion + +2019-05-06 Oliver Kiddle <okiddle@yahoo.co.uk> + + * Gautam Iyer: gitlab !7: Completion/Unix/Command/_lp, + Completion/X/Command/_gv: Minor fixes to lp and gv completion + + * Doron Behar: gitlab !8: Completion/Unix/Command/_luarocks: + Support completion of installed lua rocks' versions + + * Doron Behar: gitlab !4: Completion/Unix/Command/_pandoc: + Add pandoc completion + + * Doron Behar: gitlab !3: Completion/Unix/Command/_transmission: + Transmission remote completion + + * Aurélien Olivier: github #33: Completion/Unix/Command/_myrepos: + Add completion file for myrepos (mr) + + * Laurent Arnoud: github #35: Completion/Unix/Command/_gem: + fix _arguments spec for gem push completion (tweaked) + +2019-05-03 dana <dana@dana.is> + + * 44267: Src/sort.c, Test/Y01completion.ztst: Restore option to + ignore backslashes when sorting + +2019-05-03 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 44271: Src/loop.c, Test/A01grammar.ztst: until with positive + and while with negative status propagated breaks too far after a + return, causing code in enclosing scope not to run. + +2019-04-26 dana <dana@dana.is> + + * 44234: Completion/Unix/Command/_ssh: Update for OpenSSH 8.0 + + * 44249: Completion/Unix/Command/_mv, + Completion/Unix/Command/_rmdir, + Completion/Unix/Type/_directories: Handle zsh/files built-ins + in _mv and _rmdir + + * 44250: Completion/Unix/Command/_chmod, + Completion/Unix/Command/_chown, Completion/Unix/Command/_ln, + Completion/Unix/Command/_mkdir, Completion/Unix/Command/_mv, + Completion/Unix/Command/_rm, Completion/Unix/Command/_rmdir: + Fix use of -A and -S options to _arguments + + * 44251: Completion/Unix/Command/_chmod, + Completion/Unix/Command/_chown, Completion/Unix/Command/_mkdir, + Completion/Unix/Command/_mv, Completion/Unix/Command/_rmdir: + Fix various wording issues + +2019-04-25 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 44248: Src/init.c: Mark SIGQUIT as ignored if ignored at + shell start, so we don't enable it after a fork. + +2019-04-25 Peter Stephenson <p.stephenson@samsung.com> + + * 44254: Src/compat.c: make quite sure we've reached "/" + in zgetdir(), else report an error. + +2019-04-22 Matthew Martin <phy1729@gmail.com> + + * unposted: Completion/Base/Utility/_pick_variant: Use + ${(P) ::= rather than eval. + + * 44242: Completion/Unix/Command/_chown, + Completion/Unix/Command/_ln, Completion/Unix/Command/_mv, + Completion/Unix/Command/_rm, Completion/Unix/Command/_rmdir: + Use _pick_variant -b to detect builtins. + +2019-04-18 Mikael Magnusson <mikachu@gmail.com> + + * dana: 43288: Src/prompt.c: fix line-broken prompts + +2019-04-12 dana <dana@dana.is> + + * unposted: NEWS: Document recent feature additions + + * 44198: Doc/Zsh/options.yo, Src/builtin.c, Src/options.c, + Src/zsh.h: Add cd_silent option to suppress all cd output + +2019-04-10 Peter Stephenson <p.stephenson@samsung.com> + + * Eric Freese: 44214: Src/exec.c: <(...) substitutions shouldn't + grab the terminal. + + * Roman Perepelitsa: 44215: Doc/Zsh/zle.yo, + Src/Zle/iwidgets.list, Src/Zle/zle.h, Src/Zle/zle_main.c, + Src/Zle/zle_thingy.c, Src/Zle/zle_utils.c, Src/Zle/zle_vi.c: + Maintain LASTWIDGET across reset-prompt, avoiding side effects + of asynchronous notifications. + + * 44202: Src/Zle/compctl.c: Rewrite to use memmove() + for possibly overlapping copy. + +2019-04-10 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44210: Completion/Linux/Command/_findmnt, + Completion/Linux/Command/_lsblk: Add _findmnt and update _lsblk. + +2019-04-04 Matthew Martin <phy1729@gmail.com> + + * 44202 (tweaked): Completion/Base/Core/_normal, + Doc/Zsh/compsys.yo: Add -P to reset precommands. + + * 44201: Completion/Base/Core/_main_complete, + Completion/Base/Utility/_pick_variant, + Completion/Linux/Command/_setsid, + Completion/Zsh/Command/_command, + Completion/Zsh/Type/_command_names: Check for external forcing + precommand. + + * 44200 (tweaked): Completion/Base/Core/_normal, + Completion/Linux/Command/_setsid, + Completion/Zsh/Command/_builtin, + Completion/Zsh/Command/_command, Completion/Zsh/Command/_exec, + Completion/Zsh/Command/_precommand, Doc/Zsh/compsys.yo: Append + to precommands in _normal. + + * 44199: Completion/Base/Core/_normal: Use zparseopts. + +2019-04-01 dana <dana@dana.is> + + * 44158 (tweaked): Completion/Unix/Command/_postgresql: Add + completion for PostgreSQL + +2019-03-27 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 44168 (tweaked to remove modification to errflag): + Src/Zle/zle_main.c: Ignore bad return if errno EINTR as this is + recoverable. +g +2019-03-25 dana <dana@dana.is> + + * 44160 (tweaked): Completion/Debian/Command/_apt, + Completion/Debian/Command/_apt-file, + Completion/Debian/Command/_debdiff, + Completion/Debian/Command/_dpkg, + Completion/Debian/Command/_lintian, + Completion/Debian/Command/_piuparts, + Completion/Debian/Type/_deb_files: Add _deb_files helper with + support for *.ddeb, use it where applicable + +2019-03-25 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44176: Src/Modules/zftp.c: warn only if off_t is longer than long + + * Wesley Schwengle: 44162 (tweaked): Src/Modules/zftp.c: Avoid + format-overflow warning by using ztrftime() + + * Wesley Schwengle: 44164: Src/params.c: Avoid stringop-truncation + warning by replacing strncpy() by memcpy() + +2019-03-24 dana <dana@dana.is> + + * unposted: Completion/Unix/Command/_chmod: Adjust _guard pattern + +2019-03-22 dana <dana@dana.is> + + * unposted: Completion/Unix/Command/_chmod: Use _guard for mode + operand + + * Clinton Bunch: 44156 (tweaked): Doc/Zsh/mod_system.yo: Add + note about potential flock side-effects + +2019-03-22 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44147: Completion/Linux/Command/_free, + Completion/Linux/Command/_pmap, Completion/Linux/Command/_slabtop, + Completion/Linux/Command/_tload, Completion/Unix/Command/_top, + Completion/Unix/Type/_pids: add/update completions for procps-ng. + +2019-03-21 Matthew Martin <phy1729@gmail.com> + + * 44153: Doc/Zsh/mod_files.yo, Src/Modules/files.c: rm: Accept + -R as equivalent to -r. + + * 44149: Completion/Unix/Command/_mkdir, + Completion/Unix/Command/_stat: Use _pick_variant -b. + + * 44144: Completion/Zsh/Command/_builtin: Append "builtin" to + precommands. + + * 44155: Completion/Base/Utility/_pick_variant: Update builtin + check. + +2019-03-21 dana <dana@dana.is> + + * 44111: Completion/Unix/Command/_git: Use `git rev-list` for log + messages + +2019-03-19 Peter Stephenson <p.stephenson@samsung.com> + + * unposted: Make the doc change in the foregoing clearer. + + * Charles Blake: 44132: Src/exec.c, Doc/Zsh/builtins.yo: don't + hash commands beginning with a '/'. + + * 44142: Src/hist.c: fix bug stripping spaces on line with only + comment. + +2019-03-18 Matthew Martin <phy1729@gmail.com> + + * 44135: Completion/Unix/Command/_chmod, Doc/Zsh/mod_files.yo, + Src/Modules/files.c: Add chmod builtin. + +2019-03-15 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44118: configure.ac: use /usr/include/tirpc/ if headers for + RPC is not found in the standard location. + +2019-03-14 Peter Stephenson <p.stephenson@samsung.com> + + * Kamil: 44122: Src/parse.c: turn an int into a long to avoid + overflow. + +2019-03-12 dana <dana@dana.is> + + * 44100: Completion/Zsh/Command/_zparseopts, Doc/Zsh/mod_zutil.yo, + Src/Modules/zutil.c, Test/V12zparseopts.ztst: Add `zparseopts -F`, + completion, tests, documentation + +2019-03-08 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 44101: Completion/Unix/Command/_vim: better support for nvim + +2019-03-06 dana <dana@dana.is> + + * unposted: Completion/Zsh/Command/_zftp: Use 'post' pattern + matching to avoid clobbering other functions + + * 44099: Completion/Darwin/Command/_trash: Add completion for + macOS trash utility + +2019-03-01 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * unposted: Test/ztst.zsh: fix a typo + +2019-02-27 dana <dana@dana.is> + + * 44087: Completion/Unix/Command/_getconf: Complete options, + complete config variables on more systems + + * 44090 (re: 44085): Completion/Unix/Type/_remote_files: Don't + set QUOTING_STYLE -- syntax incompatible with some shells + +2019-02-26 dana <dana@dana.is> + + * 44085: Completion/Unix/Type/_remote_files: Prevent ls/alias + settings from mangling file listings + + * 44080: Completion/BSD/Command/_bsd_pkg, + Completion/BSD/Command/_fetch, Completion/Darwin/Command/_hdiutil, + Completion/Darwin/Command/_otool, + Completion/Darwin/Command/_sc_usage, + Completion/Debian/Command/_aptitude, + Completion/Debian/Command/_dpkg, + Completion/Debian/Command/_vim-addons, + Completion/Linux/Command/_btrfs, Completion/Linux/Command/_cpupower, + Completion/Linux/Command/_iptables, + Completion/Mandriva/Command/_urpmi, Completion/Unix/Command/_chsh, + Completion/Unix/Command/_cksum, Completion/Unix/Command/_git, + Completion/Unix/Command/_gnutls, Completion/Unix/Command/_initctl, + Completion/Unix/Command/_java, Completion/Unix/Command/_ldconfig, + Completion/Unix/Command/_lp, Completion/Unix/Command/_lz4, + Completion/Unix/Command/_nkf, Completion/Unix/Command/_objdump, + Completion/Unix/Command/_perforce, Completion/Unix/Command/_python, + Completion/Unix/Command/_smartmontools, + Completion/Unix/Command/_surfraw, Completion/Unix/Command/_sysctl, + Completion/Unix/Command/_unison, Completion/Unix/Command/_xmlsoft, + Completion/X/Command/_setxkbmap, Completion/X/Command/_vnc: Fix + several option-description typos + +2019-02-24 dana <dana@dana.is> + + * unposted: Completion/Unix/Command/_less: Fix typo + +2019-02-22 dana <dana@dana.is> + + * 44077: Completion/Unix/Command/_getent, + Completion/Unix/Command/_iconv, Completion/Unix/Command/_ldd, + Completion/Unix/Command/_locale, + Completion/Unix/Command/_localedef: Fix outdated _pick_variant + patterns, partially fix `getent -s` + + * 44076 (tweaked): Completion/Unix/Command/_column: Support + Debian column, add missing util-linux options, adjust wording + +2019-02-18 Peter Stephenson <p.stephenson@samsung.com> + + * Yutian Li: 44067: Src/hist.c: If history read was interrupted, + don't assume next time it was correctly read. + +2019-02-14 Peter Stephenson <p.stephenson@samsung.com> + + * see 44062: back off change to ZLE per-line initiialisation, + causing problems after failed reads and apparently not needed + for the intended fix of interrupt handling (40305 / 34656ec2). + +2019-02-09 Doron Behar <doron.behar@gmail.com> + + * gitlab !5: Completion/Unix/Command/_abcde: + New abcde completion. + +2019-02-09 Hiroki Noda <kubo39@gmail.com> + + * github #31: Completion/Unix/Command/_nm, + Completion/Unix/Command/_objdump: Add new demangle + style, rust and dlang + 2019-02-03 dana <dana@dana.is> + * unposted: Config/version.mk: Post-release version bump + * unposted: Config/version.mk, Etc/FAQ.yo, README: Update for 5.7.1 diff --git a/Completion/BSD/Command/_bsd_pkg b/Completion/BSD/Command/_bsd_pkg index d8928afaf..25d4f346a 100644 --- a/Completion/BSD/Command/_bsd_pkg +++ b/Completion/BSD/Command/_bsd_pkg @@ -215,7 +215,7 @@ _bsd_pkg() { '-N[show which packages each package was built with]' '-n[show which packages each package needs]' '-p[show installation prefixes]' - '-Q[show the definition of the speficied variable from the build information]:variable:' + '-Q[show the definition of the specified variable from the build information]:variable:' '-r[show list of installed requiring packages recursively]' '-S[show total size occupied by each package and its dependents]' '-u[show information for all user-installed packages]' @@ -227,7 +227,7 @@ _bsd_pkg() { flags+=( '(:)-A[show all installed packages, including internal packages]' '-C[show certificate information]' - '-E[show the package that contains the speficied file]:file:_files' + '-E[show the package that contains the specified file]:file:_files' # XXX only with -L '-K[prefix filenames with category keywords]' '-M[show the install-message file]' diff --git a/Completion/BSD/Command/_cu b/Completion/BSD/Command/_cu index df38d6ed7..5876820e5 100644 --- a/Completion/BSD/Command/_cu +++ b/Completion/BSD/Command/_cu @@ -10,6 +10,7 @@ case $variant in args+=( "-d[don't block waiting for a carrier to be detected]" '-r[start cu in restricted mode - prevent local operations]' + '-E+[specify escape character]:escape character [~]' ) ;; taylor|(net|free)bsd*) @@ -18,7 +19,7 @@ case $variant in '(-e -P --parity)-o[use odd parity]' ) ;| - (net|free)bsd*) + dragonfly*|(net|free)bsd*) args+=( '-t[connect via a hard-wired connection to a host on a dial-up line]' ) ;| taylor|netbsd*) @@ -53,12 +54,8 @@ case $variant in '(-e -o --parity)-P+[set parity]:parity [none]:(even odd none)' ) ;; - freebsd*) - args=( -A "-*" $args - '-a[set the acu port]:acu' - '-h[echo characters locally]' - ) - ;; + dragonfly*|freebsd*) args+=( '-a[set the acu port]:acu' ) ;| + freebsd*) args=( -A "-*" $args '-h[echo characters locally]' ) ;; esac _arguments -s $args \ diff --git a/Completion/BSD/Command/_fetch b/Completion/BSD/Command/_fetch index ac1264bf8..eef5ffd96 100644 --- a/Completion/BSD/Command/_fetch +++ b/Completion/BSD/Command/_fetch @@ -23,7 +23,7 @@ _arguments -s -S \ '(-N --netrc)'{-N+,--netrc=}'[use file instead of ~/.netrc to look up login names and pass- words for FTP sites]' \ '(-n --no-mtime)'{-n,--no-mtime}"[don't preserve the modification time]" \ '--no-passive[force FTP code to use active mode]' \ - '--no-proxy=[hosts on which to disable proxoes]:host:_sequence _hosts' \ + '--no-proxy=[hosts on which to disable proxies]:host:_sequence _hosts' \ '--no-sslv3' '--no-tlsv1' --no-verify-hostname --no-verify-peer \ '(-o --output)'{-o+,--output=}'[set the output file name]:file:_files' \ '-P' \ diff --git a/Completion/BSD/Command/_gstat b/Completion/BSD/Command/_gstat index c60e54422..238defce4 100644 --- a/Completion/BSD/Command/_gstat +++ b/Completion/BSD/Command/_gstat @@ -5,6 +5,7 @@ _arguments -s : \ '(-B)-b[batch mode]' \ '(-b)-B[endless batch mode]' \ '-c[enable the display geom(4) consumers]' \ + '(-b -B)-C[CSV output mode]' \ '-d[enable the display delete operations]' \ '-f+[filter by regex]:regex' \ '-o[enable the display for other operations]' \ 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/BSD/Command/_pkgin b/Completion/BSD/Command/_pkgin new file mode 100644 index 000000000..5cb12baea --- /dev/null +++ b/Completion/BSD/Command/_pkgin @@ -0,0 +1,79 @@ +#compdef pkgin + +local curcontext="$curcontext" pkgin=$words[1] cmd ret=1 +local -a state state_descr line expl cmds short pkgs +local -A opt_args + +_arguments -s -S -C \ + '-c+[enable chrooting pkgin in the given repository]:chroot path:_directories' \ + '-d[download only]' \ + '-f[force database update]' \ + '-F[force package reinstall]' \ + '(- 1 *)-h[display usage information]' \ + '-l+[only include the packages with the specified status flags]:limit chars:(( + \=\:installed\ version\ is\ current + \<\:installed\ version\ is\ older + \>\:installed\ version\ is\ newer + ))' \ + '(-y)-n[assume "no" as default answer and print results of actions to be taken line per line]' \ + '-p[display results in a parsable format]' \ + '-P[display packages versions instead of globs (sd, sfd, srd)]' \ + '-t+[log package browsing (dependencies and impact) to specified log file]:log file:_files' \ + '(- 1 *)-v[display version information]' \ + '-V[be verbose when (un)installing]' \ + '(-n)-y[assume "yes" as default answer, except for autoremove]' \ + '1:command:->subcommands' \ + '*:: :->restargs' && ret=0 + +if [[ -n $state ]]; then + cmds=( ${${${(f)"$(_call_program commands $pkgin -h 2>&1)"}[3,-1]/ - (#b)(?)/:$match:l}%.} ) + short=( ${${cmds#*\(}/ #\)/} ) + cmds=( ${cmds// #\(*\)/} ) + if [[ $state = subcommands && ! -prefix - ]]; then + _describe -t commands "command" short -- cmds -M 'r:|-=* r:|=*' && ret=0 + return ret + fi + + cmd=${short[(I)${words[1]}:*]} + if (( cmd )); then + cmd=${cmds[cmd]%%:*} + else + cmd=$words[1] + fi + curcontext="${curcontext%:*}-$cmd" + case $cmd in + avail|autoremove|clean|export|(full-|)upgrade|show(|-no)-keep|update) + _nothing + ;; + import) + _wanted files expl file _files && ret=0 + ;; + install|pkg-(content|descr|build-defs)|provides|requires|show(|-full|-rev)-deps|show-pkg-category) + _wanted packages expl package compadd - \ + ${${(f)"$(_call_program packages $pkgin avail)"}%%-[^- ]# *} && ret=0 + ;; + keep) + _wanted packages expl package compadd - \ + ${${(f)"$(_call_program packages $pkgin show-no-keep)"}%%-[^- ]# *} && ret=0 + ;; + remove) + _wanted packages expl package compadd - \ + ${${(f)"$(_call_program packages $pkgin list)"}%%-[^- ]# *} && ret=0 + ;; + search) + _message -e patterns pattern + ;; + show-category) + _wanted -x categories expl category compadd - /usr/pkgsrc/*~*/CVS(N/:t) && ret=0 + ;; + unkeep) + _wanted packages expl package compadd - \ + ${${(f)"$(_call_program packages $pkgin show-keep)"}%%-[^- ]# *} && ret=0 + ;; + *) + _default && ret=0 + ;; + esac +fi + +return ret diff --git a/Completion/BSD/Command/_procstat b/Completion/BSD/Command/_procstat index e16057635..a1708f6ac 100644 --- a/Completion/BSD/Command/_procstat +++ b/Completion/BSD/Command/_procstat @@ -6,8 +6,10 @@ _arguments -s -A "-*" -S \ '-e[show environment variables]' \ '-f[show file descriptor information]' \ '-i[show signal pending and disposition]' \ + '-j[show signal pending and blocked information for process threads]' \ '-k[show stacks of kernel threads]' \ '-l[show resource limits]' \ + "-L[show LWP info for the process pertaining to it's signal driven exit]" \ '-r[show resource usage]' \ '-s[show security credential information]' \ '-S[show cpuset information]' \ diff --git a/Completion/BSD/Command/_signify b/Completion/BSD/Command/_signify index 26571aa2a..6a786e2e1 100644 --- a/Completion/BSD/Command/_signify +++ b/Completion/BSD/Command/_signify @@ -3,29 +3,30 @@ _arguments -s -S -A "-*" : \ - checksum \ '-C[verify a signed checksum list and the checksum for each file]' \ - '-p[public key]:public key:_files' \ + '-p+[public key]:public key:_files' \ '-q[quiet mode]' \ - '-x[signature file]:signature file:_files' \ + '-x+[specify signature file]:signature file:_files' \ '*:file:_files' \ - generate \ '-G[generate a new key pair]' \ - '-c[specify comment]:comment:' \ - '-n[do not ask for passphrase]' \ - '-p[public key]:public key:_files' \ - '-s[secret key]:secret key:_files' \ + '-c+[specify comment]:comment' \ + "-n[don't ask for passphrase]" \ + '-p+[specify public key file]:public key:_files' \ + '-s+[specify secret key file]:secret key:_files' \ - sign \ '-S[sign a message and create a signature]' \ '-e[embed the message after the signature]' \ - '-m[file containing message]:message file:_files' \ - '-s[secret key]:secret key:_files' \ - '-x[signature file]:signature file:_files' \ + '-n[store a zero time stamp in the gzip(1) header (with -z)]' \ + '-m+[specify file containing message to sign]:message file:_files' \ + '-s+[specify secret key file]:secret key:_files' \ + '-x+[specify signature file]:signature file:_files' \ '-z[embed signature in gzip header]' \ - verify \ '-V[verify the message and signature match]' \ '-e[extract the message from the signature]' \ - '-m[file containing message to verify or destination to extract]:message file:_files' \ - '-p[public key]:public key:_files' \ + '-m+[specify file containing message to verify or destination to extract]:message file:_files' \ + '-p+[specify public key file]:public key:_files' \ '-q[quiet mode]' \ - '-t[restrict verification to specified key type]:key type:((base\:"base sets" fw\:firmware pkg\:packages syspatch\:syspatches))' \ - '-x[signature file]:signature file:_files' \ + '-t+[restrict verification to specified key type]:key type:((base\:"base sets" fw\:firmware pkg\:packages syspatch\:syspatches))' \ + '-x+[specify signature file]:signature file:_files' \ '-z[verify signature in gzip header]' diff --git a/Completion/BSD/Command/_sockstat b/Completion/BSD/Command/_sockstat index 913f3eb05..1d7973db7 100644 --- a/Completion/BSD/Command/_sockstat +++ b/Completion/BSD/Command/_sockstat @@ -13,6 +13,14 @@ case $OSTYPE in '-u[show AF_LOCAL (UNIX) sockets]' ) ;| + freebsd<12->.*) + args+=( + '-S[display the protocol stack if applicable]' + '-U[display the remote UDP encapsulation port number if applicable]' + '-v[verbose mode]' + '-w[use wider field size for displaying addresses]' + ) + ;| freebsd*) for proto in ${${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]*}}; do case $proto in diff --git a/Completion/BSD/Command/_vmctl b/Completion/BSD/Command/_vmctl index 66d9081b0..873bb5670 100644 --- a/Completion/BSD/Command/_vmctl +++ b/Completion/BSD/Command/_vmctl @@ -29,6 +29,7 @@ subcommands=( start:'start a VM' stop:'stop a VM' unpause:'resume a VM' + wait:'wait until specified VM has stopped' ) if (( CURRENT == 2 )); then @@ -37,21 +38,18 @@ else local curcontext="${curcontext%:*}-${words[2]}:" shift words; (( CURRENT-- )) case $words[1] in - console|pause|send|show|status|unpause) + console|pause|send|show|status|unpause|wait) _vm_names ;; create) - if (( CURRENT == 2 )); then - compset -P '(raw|qcow2):' || alts=( - 'prefixes:prefix:compadd -S: raw qcow2' - ) - _alternative 'files:path:_files' $alts - else - shift words; (( CURRENT-- )) - _arguments \ - '-s+[specify size]:size' \ - '-b+[specify base disk]:base image:_files' - fi + compset -P '(raw|qcow2):' || alts=( + 'prefixes:prefix:compadd -S: raw qcow2' + ) + _arguments \ + '-s+[specify size]:size' \ + '(-i)-b+[specify base disk]:base image:_files' \ + '(-b)-i+[copy and convert input disk]:disk image:_files' \ + '1:disk: _alternative "files:path:_files" $alts' ;; load) _arguments ':configuration file:_files' @@ -70,33 +68,28 @@ else ))' ;; start) - if (( CURRENT == 2 )); then - _vm_names - else - shift words; (( CURRENT-- )) - _arguments -s \ - '-b+[boot with the specified kernel or BIOS image]:boot image:_files' \ - '-c[automatically connect to the VM console]' \ - '*-d+[disk image file]:disk image:_files' \ - '-i+[number of network interfaces]:number: ' \ - '-L[add a local network interface]' \ - '-m+[memory size in megabytes]:megabytes: ' \ - '-n+[specify switch to attach]: :_vm_switches' \ - '-r+[ISO image file for virtual CD-ROM]:ISO image:_files' \ - '-t+[use existing VM as a template]: :_vm_names' - fi + _arguments -s \ + '-B+[force system to boot from specified device for this boot]:device:(cdrom disk net)' \ + '-b+[boot with the specified kernel or BIOS image]:boot image:_files' \ + '-c[automatically connect to the VM console]' \ + '*-d+[disk image file]:disk image:_files' \ + '-i+[number of network interfaces]:number: ' \ + '-L[add a local network interface]' \ + '-m+[specify memory size]:memory size (megabytes) [512]' \ + '-n+[specify switch to attach]: :_vm_switches' \ + '-r+[specify ISO image file for virtual CD-ROM]:ISO image:_files -g "*.iso(-.)"' \ + '-t+[use existing VM as a template]: :_vm_names' \ + '1: :_vm_names' ;; stop) - if (( CURRENT == 2 )); then - _alternative \ - 'all:all:(-a)' \ - 'virtual-machines: :_vm_names' - else - shift words; (( CURRENT-- )) - _arguments \ - '-f[forcefully stop without attempting a graceful shutdown]' \ - '-w[wait until the VM has been terminated]' - fi + _arguments \ + '(1)-a[stop all running VMs]' \ + '-f[forcefully stop without attempting a graceful shutdown]' \ + '-w[wait until the VM has been terminated]' \ + '(-a)1: :_vm_names' + ;; + *) + _default ;; esac fi diff --git a/Completion/BSD/Type/_bsd_disks b/Completion/BSD/Type/_bsd_disks new file mode 100644 index 000000000..986d36e45 --- /dev/null +++ b/Completion/BSD/Type/_bsd_disks @@ -0,0 +1,26 @@ +#autoload +# disk device names on BSDs +local -a disks + +case $OSTYPE in + freebsd*) + disks=( ${${(M)${(f)"$(geom disk list)"}\:#Geom name\:*}#*\: } ) + ;; + dragonfly*) + disks=( $(sysctl -n kern.disks) ) + ;; + openbsd*) + disks=( ${${(s.,.)"$(sysctl -n hw.disknames)"}%\:*} ) + ;; + netbsd*) + disks=( $(sysctl -n hw.disknames) ) + ;; +esac + +if (( $#disks )); then + local expl + _wanted disk-devices expl 'disk device' compadd "$@" $disks + return +fi + +return 1 diff --git a/Completion/BSD/Type/_fbsd_device_types b/Completion/BSD/Type/_fbsd_device_types new file mode 100644 index 000000000..f1897f6a7 --- /dev/null +++ b/Completion/BSD/Type/_fbsd_device_types @@ -0,0 +1,31 @@ +#autoload +# +# device types on FreeBSD/DragonFly +# (for commands using devstat_buildmatch(), such as iostat and vmstat) +# +local -a d i types + +d=( da sa printer proc worm cd scanner optical changer + comm array enclosure floppy) +i=( IDE SCSI other ) +types=( + "($d)da[direct access devices]" + "($d)sa[sequential access devices]" + "($d)printer[printers]" + "($d)proc[processor devices]" + "($d)worm[write once read multiple devices]" + "($d)cd[CD devices]" + "($d)scanner[scanner devices]" + "($d)optical[optical memory devices]" + "($d)changer[medium changer devices]" + "($d)comm[communication devices]" + "($d)array[storage array devices]" + "($d)enclosure[enclosure services devices]" + "($d)floppy[floppy devices]" + "($i)IDE[Integrated Drive Electronics devices]" + "($i)SCSI[Small Computer System Interface devices]" + "($i)other[any other device interface]" + 'pass[passthrough devices]' +) + +_values -s , 'device type' $types diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand index f4909826a..def522a76 100644 --- a/Completion/Base/Completer/_expand +++ b/Completion/Base/Completer/_expand @@ -108,7 +108,7 @@ integer done_quote local orig_exp=$exp if [[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob; then eval 'exp=( ${~exp//(#b)\\([ \"'"\'"' -])/$match[1]} ); exp=( ${(q)exp} )' 2>/dev/null && done_quote=1 +])/$match[1]} ); exp=( ${(q)exp} )' 2>/dev/null && (( $#exp )) && done_quote=1 fi # If the globbing failed, or we didn't try globbing, we'll do # it again without the "~" so globbing is simply omitted. diff --git a/Completion/Base/Core/_description b/Completion/Base/Core/_description index 304c747a6..bdb4007a6 100644 --- a/Completion/Base/Core/_description +++ b/Completion/Base/Core/_description @@ -1,13 +1,13 @@ #autoload -local name gropt nopt xopt format gname hidden hide match opts tag sort +local name nopt xopt format gname hidden hide match opts tag +local -a ign gropt sort opts=() -gropt=(-J) xopt=(-X) nopt=() -zparseopts -K -D -a nopt 1 2 V=gropt J=gropt x=xopt +zparseopts -K -D -a nopt 1 2 V=gropt J=ign x=xopt 3="${${3##[[:blank:]]#}%%[[:blank:]]#}" [[ -n "$3" ]] && _lastdescr=( "$_lastdescr[@]" "$3" ) @@ -33,14 +33,18 @@ zstyle -s ":completion:${curcontext}:$1" matcher match && # Use sort style, but ignore `menu' value to help _expand. # Also don't override explicit use of -V. -if { zstyle -s ":completion:${curcontext}:$1" sort sort || - zstyle -s ":completion:${curcontext}:" sort sort; } && - [[ "$gropt" = -J && $sort != menu ]]; then - if [[ "$sort" = (yes|true|1|on) ]]; then - gropt=(-J) - else - gropt=(-V) +if [[ -z "$gropt" ]]; then + if zstyle -a ":completion:${curcontext}:$1" sort sort || + zstyle -a ":completion:${curcontext}:" sort sort + then + if [[ -z "${(@)sort:#(match|numeric|reverse)}" ]]; then + gropt=( -o ${(j.,.)sort} ) + elif [[ "$sort" != (yes|true|1|on|menu) ]]; then + gropt=( -o nosort ) fi + fi +else + gropt=( -o nosort ) fi if [[ -z "$_comp_no_ignore" ]]; then @@ -79,15 +83,15 @@ fi if [[ -n "$gname" ]]; then if [[ -n "$format" ]]; then - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" "$xopt" "$format" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J "$gname" "$xopt" "$format" else - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" "$gname" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J "$gname" fi else if [[ -n "$format" ]]; then - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- "$xopt" "$format" + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J -default- "$xopt" "$format" else - set -A "$name" "$opts[@]" "$nopt[@]" "$gropt" -default- + set -A "$name" "$opts[@]" "$nopt[@]" "$gropt[@]" -J -default- fi fi diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index aa2486236..6b2cf2bcf 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -45,6 +45,12 @@ unset _comp_priv_prefix # _precommand sets this to indicate we are following a precommand modifier local -a precommands +# Precommands which allow their wrapped command to be a builtin. +# All of these are necessarily builtins or reserved words themselves, +# but not all builtin precommands are listed here: +# for one, the 'command' builtin is excluded. +local -ar builtin_precommands=(- builtin eval exec nocorrect noglob time) + typeset -U _lastdescr _comp_ignore _comp_colors { diff --git a/Completion/Base/Core/_normal b/Completion/Base/Core/_normal index dd607d2b2..0d84eae87 100644 --- a/Completion/Base/Core/_normal +++ b/Completion/Base/Core/_normal @@ -1,13 +1,12 @@ #compdef -command-line- -local _comp_command1 _comp_command2 _comp_command skip +local _comp_command1 _comp_command2 _comp_command precommand +local -A opts -if [[ "$1" = -s ]]; then - skip=(-s) -else - skip=() - _compskip='' -fi +zparseopts -A opts -D - P p+:-=precommand s +(( $+opts[-s] )) || _compskip= +(( $+opts[-P] )) && precommands=() +(( $#precommand )) && precommands+=(${precommand#-p}) # Check for a history reference to complete modifiers. # $PREFIX has a quoted form of the !, so we can't test that @@ -37,5 +36,5 @@ fi _set_command -_dispatch "$skip[@]" "$_comp_command" \ +_dispatch ${(k)opts[-s]} "$_comp_command" \ "$_comp_command1" "$_comp_command2" -default- diff --git a/Completion/Base/Utility/_describe b/Completion/Base/Utility/_describe index 76ab1d995..c12eb0eab 100644 --- a/Completion/Base/Utility/_describe +++ b/Completion/Base/Utility/_describe @@ -108,10 +108,10 @@ while _tags; do fi if [[ -n $_mats ]]; then - compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs -O $_mats - \ + compadd "$_opts[@]" -2 -o nosort "${_expl[@]}" -D $_strs -O $_mats - \ "${(@)${(@M)${(@P)_mats}##([^:\\]|\\?)##}//\\(#b)(?)/$match[1]}" else - compadd "$_opts[@]" "${(@)_expl:/-J/-2V}" -D $_strs - \ + compadd "$_opts[@]" -2 -o nosort "${_expl[@]}" -D $_strs - \ "${(@)${(@M)${(@P)_strs}##([^:\\]|\\?)##}//\\(#b)(?)/$match[1]}" fi done diff --git a/Completion/Base/Utility/_guard b/Completion/Base/Utility/_guard index ff62981ce..1cbd4f39b 100644 --- a/Completion/Base/Utility/_guard +++ b/Completion/Base/Utility/_guard @@ -2,7 +2,7 @@ local garbage -zparseopts -K -D -a garbage M: J: V: 1 2 n F: X: +zparseopts -K -D -a garbage M+: J+: V+: 1 2 o+: n F: X+: [[ "$PREFIX$SUFFIX" != $~1 ]] && return 1 diff --git a/Completion/Base/Utility/_multi_parts b/Completion/Base/Utility/_multi_parts index 12ff965ed..8a77ff0f0 100644 --- a/Completion/Base/Utility/_multi_parts +++ b/Completion/Base/Utility/_multi_parts @@ -14,8 +14,8 @@ typeset -U tmp1 matches # Get the options. zparseopts -D -a sopts \ - 'J+:=group' 'V+:=group' 'X+:=expl' 'P:=opts' 'F:=opts' \ - S: r: R: q 1 2 n f 'M+:=matcher' 'i=imm' + 'J+:=group' 'V+:=group' 'x+:=expl' 'X+:=expl' 'P:=opts' 'F:=opts' \ + S: r: R: q 1 2 o+: n 'f=opts' 'M+:=matcher' 'i=imm' sopts=( "$sopts[@]" "$opts[@]" ) if (( $#matcher )); then diff --git a/Completion/Base/Utility/_pick_variant b/Completion/Base/Utility/_pick_variant index 9099e3599..9d705cf10 100644 --- a/Completion/Base/Utility/_pick_variant +++ b/Completion/Base/Utility/_pick_variant @@ -1,6 +1,6 @@ #autoload -local output cmd pat +local output cmd pat pre local -a var local -A opts @@ -13,29 +13,37 @@ while [[ $1 = *=* ]]; do var+=( "${1%%\=*}" "${1#*=}" ) shift done -if (( $+_cmd_variant[$opts[-c]] )); then - (( $+opts[-r] )) && eval "${opts[-r]}=${_cmd_variant[$opts[-c]]}" - [[ $_cmd_variant[$opts[-c]] = "$1" ]] && return 1 + +if (( ${#precommands:|builtin_precommands} )); then + pre=command +elif (( $+opts[-b] && ( $precommands[(I)builtin] || $+builtins[$opts[-c]] ) )); then + (( $+opts[-r] )) && : ${(P)opts[-r]::=$opts[-b]} return 0 +elif (( $precommands[(I)builtin] )); then + pre=builtin +else + # Neither builtin nor command-forcing precommand specified, + # so no prefix is needed. + pre= fi -if [[ $+opts[-b] -eq 1 && -n $builtins[$opts[-c]] ]]; then - _cmd_variant[$opts[-c]]=$opts[-b] - (( $+opts[-r] )) && eval "${opts[-r]}=${_cmd_variant[$opts[-c]]}" +if [[ $pre != builtin ]] && (( $+_cmd_variant[$opts[-c]] )); then + (( $+opts[-r] )) && : ${(P)opts[-r]::=${_cmd_variant[$opts[-c]]}} + [[ $_cmd_variant[$opts[-c]] = "$1" ]] && return 1 return 0 fi -output="$(_call_program variant $opts[-c] "${@[2,-1]}" </dev/null 2>&1)" +output="$(_call_program variant $pre $opts[-c] "${@[2,-1]}" </dev/null 2>&1)" for cmd pat in "$var[@]"; do if [[ $output = *$~pat* ]]; then - (( $+opts[-r] )) && eval "${opts[-r]}=$cmd" + (( $+opts[-r] )) && : ${(P)opts[-r]::=$cmd} _cmd_variant[$opts[-c]]="$cmd" return 0 fi done -(( $+opts[-r] )) && eval "${opts[-r]}=$1" -_cmd_variant[$opts[-c]]="$1" +(( $+opts[-r] )) && : ${(P)opts[-r]::=$1} +[[ $pre != builtin ]] && _cmd_variant[$opts[-c]]="$1" return 1 diff --git a/Completion/Base/Utility/_sep_parts b/Completion/Base/Utility/_sep_parts index de836a696..6fcf54ec4 100644 --- a/Completion/Base/Utility/_sep_parts +++ b/Completion/Base/Utility/_sep_parts @@ -22,8 +22,8 @@ local matchflags opt group expl nm=$compstate[nmatches] opre osuf opts matcher # Get the options. -zparseopts -D -a opts \ - 'J+:=group' 'V+:=group' P: F: S: r: R: q 1 2 n 'X+:=expl' 'M+:=matcher' +zparseopts -D -a opts 'J+:=group' 'V+:=group' P: F: S: r: R: q 1 2 o+: n \ + 'x+:=expl' 'X+:=expl' 'M+:=matcher' # Get the string from the line. diff --git a/Completion/Base/Utility/_sequence b/Completion/Base/Utility/_sequence index f52955f46..c1ff32184 100644 --- a/Completion/Base/Utility/_sequence +++ b/Completion/Base/Utility/_sequence @@ -8,9 +8,10 @@ # -d : duplicate values allowed local curcontext="$curcontext" nm="$compstate[nmatches]" pre qsep nosep minus -local -a sep num pref suf end uniq dedup +local -a opts sep num pref suf cont end uniq dedup -zparseopts -D -a opts s:=sep n:=num p:=pref i:=pref P:=pref I:=suf S:=suf q=suf r:=suf R:=suf C:=cont d=uniq M: J: X: x: +zparseopts -D -a opts s:=sep n:=num p:=pref i:=pref P:=pref I:=suf S:=suf \ + q=suf r:=suf R:=suf C:=cont d=uniq M+: J+: V+: 1 2 o+: X+: x+: (( $#cont )) && curcontext="${curcontext%:*}:$cont[2]" (( $#sep )) || sep[2]=, 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/Command/_hdiutil b/Completion/Darwin/Command/_hdiutil index 13133b1f9..c31808716 100644 --- a/Completion/Darwin/Command/_hdiutil +++ b/Completion/Darwin/Command/_hdiutil @@ -220,7 +220,7 @@ _hdiutil(){ "-uid[uid of root directory]:uid in number" \ "-gid[gid of root directory]:gid in number" \ "-mode[mode of root directory]:mode" \ - "-nouuid[suppress addiing a UUID]" \ + "-nouuid[suppress adding a UUID]" \ "(-noautostretch)-autostretch" \ "(-autostretch)-noautostretch" \ "-stretch[max_stretch]: :_hdiutil_imagesize" \ diff --git a/Completion/Darwin/Command/_otool b/Completion/Darwin/Command/_otool index 8c6c00867..c3fc70b91 100644 --- a/Completion/Darwin/Command/_otool +++ b/Completion/Darwin/Command/_otool @@ -20,7 +20,7 @@ _arguments \ '-I[display the indirect symbol table]' \ '-T[display the table of contents for a dynamic shared library]' \ '-R[display the reference table of a dynamic shared library]' \ - '-M[display the module table of dymamic shared library]' \ + '-M[display the module table of dynamic shared library]' \ '-H[display the two-level namespace hints table]' \ '-G[display the data in code table]' \ '-C[display the linker optimization hints]' \ @@ -35,7 +35,7 @@ _arguments \ '-j[with disassembly, print opcode bytes]' \ "-Q[use otool's disassembler]" \ '-arch[select the specified architecture from a universal file]:arch:(i386 x86_64)' \ - '-m[object file names are not assuemd to be in archive(member) syntax]' \ + '-m[object file names are not assumed to be in archive(member) syntax]' \ '(- *)--version[print version of otool]' \ '*:file:_object_files' && return 0 diff --git a/Completion/Darwin/Command/_sc_usage b/Completion/Darwin/Command/_sc_usage index 3a11a1bff..17909ce6f 100644 --- a/Completion/Darwin/Command/_sc_usage +++ b/Completion/Darwin/Command/_sc_usage @@ -5,6 +5,6 @@ _arguments -s -A '-*' : \ '-e[sort output by call count]' \ '-l[use scrolling output style instead of window updating style]' \ '-s+[specify sampling interval]:seconds' \ - '(- :)-E[specify command path and args to excute]: :_absolute_command_paths:*:: :_normal' \ + '(- :)-E[specify command path and args to execute]: :_absolute_command_paths:*:: :_normal' \ '1: : _alternative "processes:: _pids" "processes-names:: _process_names -a"' diff --git a/Completion/Darwin/Command/_trash b/Completion/Darwin/Command/_trash new file mode 100644 index 000000000..658716432 --- /dev/null +++ b/Completion/Darwin/Command/_trash @@ -0,0 +1,22 @@ +#compdef trash + +# We only provide completion for Ali Rantakari's trash utility. There are/were a +# few others floating around with that name, but this is the one available as +# `trash` in Homebrew and MacPorts +_pick_variant ali='(Rantakari|hasseg)' other --version && { + # The hidden options here are options to rm that trash silently (and + # undocumentedly) ignores. Some options are not made mutually exclusive where + # they technically could be, for compatibility with aliases, etc. + _arguments -s -S -A '-*' : \ + '!-'{d,f,i,r,P,R,W} \ + '(: * -F -l -v)-e[empty trash]' \ + '-F[use Finder instead of system API]' \ + '(: * -e -F -s -y)-l[list items in trash]' \ + '(: * -F -l -v)-s[securely empty trash]' \ + '-v[increase output verbosity]' \ + '-y[skip confirmation prompts (with -e or -s)]' \ + '*: :_files' + return +} + +_default diff --git a/Completion/Darwin/Type/_mac_files_for_application b/Completion/Darwin/Type/_mac_files_for_application index 299d8ff5c..885b064fe 100644 --- a/Completion/Darwin/Type/_mac_files_for_application +++ b/Completion/Darwin/Type/_mac_files_for_application @@ -35,7 +35,7 @@ _mac_parse_info_plist() { # Try to complete files for the specified application. _mac_files_for_application() { local -a opts - zparseopts -D -a opts q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+: + zparseopts -D -a opts q n 1 2 o+: P: S: r: R: W: x+: X+: M+: F: J+: V+: local app_path _retrieve_mac_apps @@ -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/_apt b/Completion/Debian/Command/_apt index dd837379c..4d60cd249 100644 --- a/Completion/Debian/Command/_apt +++ b/Completion/Debian/Command/_apt @@ -399,7 +399,13 @@ _apt-cmd () { -o,--option:arbitem \ -t,--target-release:release \ -- \ - /$'list\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ + /$'list\0'/ \( \ + \( \ + /$'--installed\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# /'[]'/ \| \ + // %-% /$'--[^\0]#\0'/ ':options:option:(--installed --upgradable --all-versions)' \ + \| \) \ + /$'[^-\0][^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \ + \) \| \ /$'search\0'/ /$'[^\0]#\0'/ ':strings:pattern:' \| \ /$'showsrc\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ /$'show\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ @@ -409,15 +415,14 @@ _apt-cmd () { /$'update\0'/ \| \ \( \ /$'(install|download|source|build-dep)\0'/ -'subcmd=${match%?}' \ - /$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=" "$expl_packages[@]" avail' \# \ + /$'[^\0]#\0'/ ':packages::_deb_packages -qr "\n\t\- /=+-" "$expl_packages[@]" avail' \# \ \( \ - // '%(.|)/%' -'[[ $subcmd = install ]]' /'[]'/ ':files:package file:_files -g "*.(changes|deb|dsc)(-.)"' \| \ + // '%(.|)/%' -'[[ $subcmd = install ]]' /'[]'/ ':files: :_deb_files -c' \| \ /$'[^\0/=]#\/'/ /'[]'/ ':apt-releases:release name:_apt_releases' \| \ /$'[^\0/=]#='/ /'[]'/ ':apt-package-versions:package version:_apt_versions_of_binary_package' \| \ \) \ \) \| \ - /$'remove\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ - /$'purge\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ + /$'(remove|reinstall|purge)\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ /$'upgrade\0'/ \| \ /$'autoclean\0'/ \| \ /$'changelog\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \| \ @@ -425,7 +430,7 @@ _apt-cmd () { /$'full-upgrade\0'/ \| \ /$'dist-upgrade\0'/ \| \ /$'edit-sources\0'/ \| \ - /"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autoremove purge' + /"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install reinstall download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autoremove purge' _apt-cmd () { local expl_action expl_packages subcmd diff --git a/Completion/Debian/Command/_apt-file b/Completion/Debian/Command/_apt-file index 98a93fdd3..5b24707d2 100644 --- a/Completion/Debian/Command/_apt-file +++ b/Completion/Debian/Command/_apt-file @@ -36,7 +36,7 @@ case $state in case $line[1] in search|find) if (( $#opt_args[(I)(-D|--from-deb)] )); then - _wanted files expl 'debian package' _files -g '*.deb(-.)' + _deb_files elif (( $#opt_args[(I)(-f|--from-file)] )); then _files else diff --git a/Completion/Debian/Command/_aptitude b/Completion/Debian/Command/_aptitude index f79a100a8..bbaa8ebbd 100644 --- a/Completion/Debian/Command/_aptitude +++ b/Completion/Debian/Command/_aptitude @@ -56,7 +56,7 @@ _arguments -C \ '(-F --display-format)'{-F,--display-format}'[specify output format for search command]:format:_aptitude_format_strings' \ '(-O --sort)'{-O,--sort}'[specify sort order]:sort order:()' \ '(-w --width)'{-w,--width}'[specify output width]:width' \ - '-f[aggressivley try to fix dependencies of broken packages]' \ + '-f[aggressively try to fix dependencies of broken packages]' \ '(-V --show-versions)'{-V,--show-versions}'[show which versions of packages will be installed]' \ '(-D --show-deps)'{-D,--show-deps}'[show brief explanations of automatic installations and removals]' \ '-Z[show disk space changes for each package]' \ diff --git a/Completion/Debian/Command/_debdiff b/Completion/Debian/Command/_debdiff index 6f8519a4a..9e8ffd594 100644 --- a/Completion/Debian/Command/_debdiff +++ b/Completion/Debian/Command/_debdiff @@ -17,6 +17,6 @@ _arguments \ '(-h --help)'{-h,--help}'[show help]' \ '(-v --version)'{-v,--version}'[show version]' \ '(-q --quiet)'{-q,--quiet}'[be quiet if no differences]' \ - '--from:debs:_files -g "*.deb(-.)"' \ - '--to:debs:_files -g "*.deb(-.)"' \ - '*:file to compare:_files -g "*.(deb|changes|dsc)(-.)"' + '--from: :_deb_files' \ + '--to: :_deb_files' \ + '*:file to compare:_deb_files -c' diff --git a/Completion/Debian/Command/_dpkg b/Completion/Debian/Command/_dpkg index 3503d09b9..3477e6116 100644 --- a/Completion/Debian/Command/_dpkg +++ b/Completion/Debian/Command/_dpkg @@ -18,24 +18,24 @@ _dpkg_deb_only_actions=( _dpkg_deb_actions=( '(--build -b)'{--build,-b}'[build archive]:directory:_files -/' - '(--contents -c)'{--contents,-c}'[list contents]:Debian package:_files -g "*.u#deb(-.)"' - '(--info -I)'{--info,-I}'[show info]:Debian package:_files -g "*.u#deb(-.)"' - '(--field -f)'{--field,-f}'[show fields]:Debian package:_files -g "*.u#deb(-.)"' - '(--control -e)'{--control,-e}'[extract control]:Debian package:_files -g "*.u#deb(-.)"' - '(--extract -x)'{--extract,-x}'[extract files]:Debian package:_files -g "*.u#deb(-.)"' - '(--vextract -X)'{--vextract,-X}'[extract and list files]:Debian package:_files -g "*.u#deb(-.)"' - '--fsys-tarfile[output fs tarfile]:Debian package:_files -g "*.u#deb(-.)"' + '(--contents -c)'{--contents,-c}'[list contents]: :_deb_files' + '(--info -I)'{--info,-I}'[show info]: :_deb_files' + '(--field -f)'{--field,-f}'[show fields]: :_deb_files' + '(--control -e)'{--control,-e}'[extract control]: :_deb_files' + '(--extract -x)'{--extract,-x}'[extract files]: :_deb_files' + '(--vextract -X)'{--vextract,-X}'[extract and list files]: :_deb_files' + '--fsys-tarfile[output fs tarfile]: :_deb_files' ) _dpkg_common_actions=( '--help[show help]' '--version[show version]' - '(--license --licence)'{--license,--licence}'[show licencing]' + '(--license --licence)'{--license,--licence}'[show licensing]' ) _dpkg_actions=( '(--install -i)'{--install,-i}'[install packages]:*:Debian packages:->install' - '--unpack[unpack package]:Debian package:_files -g "*.deb(-.)"' + '--unpack[unpack package]: :_deb_files' '--configure[reconfigure specified packages]:*:package:->configure' '(--remove -r)'{--remove,-r}'[remove package]:*:package:->remove' '(--purge -P)'{--purge,-P}'[purge package]:*:package:->purge' @@ -76,7 +76,7 @@ _dpkg_options=( _dpkg_options_recursive=( '(--recursive -R)'{--recursive,-R}'[recursive]' ) _dpkg_deb_and_query_only_actions=( - '(--show -W)'{--show,-W}'[show package info]:Debian package:_files -g \*.u\#deb\(-.\)' + '(--show -W)'{--show,-W}'[show package info]: :_deb_files' ) _dpkg_deb_and_query_only_options=( @@ -147,7 +147,7 @@ case "$state" in "$_dpkg_options_recursive[@]" \ '*:directory:_path_files -/' \ - nonrecur \ - '*:Debian package:_path_files -g "*.deb(-.)"' + '*: :_deb_files' ;; remove|status|listfiles) _call_function ret _dpkg_$state && return ret diff --git a/Completion/Debian/Command/_lintian b/Completion/Debian/Command/_lintian index d60acc9ed..71e71ee3d 100644 --- a/Completion/Debian/Command/_lintian +++ b/Completion/Debian/Command/_lintian @@ -38,7 +38,7 @@ case "$service" in '(-s --source)'{-s,--source}'[the following packages are source]' \ '--udeb[the following packages are udebs]' \ '(-p --packages-file)'{-p,--packages-file}'[process packages listed in file]:list:_files' \ - '*:package:_files -g "*.(changes|deb|dsc)(-.)"' && return 0 + '*: :_deb_files -c' && return 0 ;; (lintian-info) diff --git a/Completion/Debian/Command/_piuparts b/Completion/Debian/Command/_piuparts index a1b6666a3..1da0e85e9 100644 --- a/Completion/Debian/Command/_piuparts +++ b/Completion/Debian/Command/_piuparts @@ -24,7 +24,7 @@ case "$state" in if (( $+opt_args[-a] )); then _deb_packages avail else - _files -g '*.deb(-.)' + _deb_files fi ;; esac diff --git a/Completion/Debian/Command/_sbuild b/Completion/Debian/Command/_sbuild new file mode 100644 index 000000000..a32b5e8c5 --- /dev/null +++ b/Completion/Debian/Command/_sbuild @@ -0,0 +1,141 @@ +#compdef sbuild + +_sbuild_distributions() { + _deb_codenames + compadd "$@" -- unstable +} + +_deb_identities() { + local identity + + if [[ -n "${DEBEMAIL}" ]]; then + if [[ -n "${DEBFULLNAME}" ]]; then + identity="${DEBFULLNAME} <${DEBEMAIL}>" + else + identity="${DEBEMAIL}" + fi + compadd "$@" -- "${identity}" + fi +} + +_sbuild_signing_keys() { + local -a expl lines uids + local line + + lines=( ${(M)${(f)"$(_call_program keys gpg -K --with-colons)"}:#uid:u*} ) + + for line in "${lines[@]}"; do + uids+=("${${(s.:.)line}[5][(ws:<:)2,(ws:>:)1]}") + done + + _description keys expl "gpg key" + compadd "$@" "$expl[@]" -- "${uids[@]}" +} + +_sbuild() { + _arguments \ + '(-h --help)'{-h,--help}'[show help message]' \ + '(-V --version)'{-V,--version}'[show version information]' \ + '(-D --debug)'{-D,--debug}'[enable debug output]' \ + '--add-depends=[add dependencies to source package]:packages' \ + '--add-conflicts=[add conflicts to source package]:packages' \ + '--add-depends-arch=[add arch dependencies to source package]:packages' \ + '--add-conflicts-arch=[add arch conflicts to source package]:packages' \ + '--add-depends-indep=[add indep dependencies to source package]:packages' \ + '--add-conflicts-indep=[add indep conflicts to source package]:packages' \ + '--arch=[architecture]:architecture:_deb_architectures' \ + '--host=[host architecture]:architecture:_deb_architectures' \ + '--build=[build architecture]:architecture:_deb_architectures' \ + '(-A --arch-all --no-arch-all)'{-A,--arch-all}'[build Architecture: all packages]' \ + '(-A --arch-all --no-arch-all)--no-arch-all[do not build Architecture: all packages]' \ + '(--arch-any --no-arch-any)--arch-any[build Architecture: any packages]' \ + '(--arch-any --no-arch-any)--no-arch-any[do not build Architecture: any packages]' \ + '(-b --batch)'{-b,--batch}'[operate in batchmode]' \ + '(-c --chroot)'{-c=,--chroot=}'[chroot to use]:chroot' \ + '(--chroot-mode)--chroot-mode=[chroot mode]:mode:(schroot sudo autopkgtest unshare)' \ + '(-d --dist)'{-d=,--dist=}'[distribution]:distribution:_sbuild_distributions' \ + '--archive=[use specified archive]' \ + '(--apt-clean --no-apt-clean)--apt-clean[force apt-get clean]' \ + '(--apt-clean --no-apt-clean)--no-apt-clean[do not apt-get clean]' \ + '(--apt-upgrade --no-apt-upgrade)--apt-upgrade[force apt-get upgrade]' \ + '(--apt-upgrade --no-apt-upgrade)--no-apt-upgrade[do not apt-get upgrade]' \ + '(--apt-distupgrade --no-apt-distupgrade)--apt-distupgrade[force apt-get distupgrade]' \ + '(--apt-distupgrade --no-apt-distupgrade)--no-apt-distupgrade[do not apt-get distupgrade]' \ + '(-m --maintainer)'{-m=,--maintainer=}'[maintainer field for .changes]:maintainer:_deb_identities' \ + '(-e --uploader)'{-e=,--uploader=}'[uploader field for .changes]:uploader:_deb_identities' \ + '(-k --keyid)'{-k=,--keyid=}'[GPG Key to sign packages]: :_sbuild_signing_keys' \ + '(-j --jobs)'{-j=,--jobs=}'[jobs to run simultaneously]:number of jobs' \ + '--debbuildopt=[option to dpkg-buildpackage]:option' \ + '--debbuildopts=[options to dpkg-buildpackage]:options' \ + '--dpkg-source-opt=[option to dpkg-source]:option' \ + '--dpkg-source-opts=[options to dpkg-source]:options' \ + '--mail-log-to=[send log to mail]:recipient:_email_addresses -c' \ + '--mailfrom=[mail from]:sender:_email_addresses -c' \ + '(-n --nolog)'{-n,--nolog}'[no build log file]' \ + '--profiles=[profiles for dpkg-buildpackage]:profile list (comma separated)' \ + '(-p --purge)'{-p=,--purge=}'[purge mode]:purge mode:(never successful always)' \ + '--purge-build=[build purge mode]:purge mode:(never successful always)' \ + '--purge-deps=[deps purge mode]:purge mode:(never successful always)' \ + '--purge-session=[session purge mode]:purge mode:(never successful always)' \ + '(-s --source --no-source)'{-s,--source}'[build source package]' \ + '(-s --source --no-source)--no-source[do not build source package]' \ + '--force-orig-source[force orig.tar.gz in .changes]' \ + '--use-snapshot[use latest gcc snapshot]' \ + '(-v --verbose)'{-v,--verbose}'[be verbose]' \ + '(-q --quiet)'{-q,--quiet}'[be quiet]' \ + '--make-binNMU=[create binNMU with changelog entry]:changelog entry' \ + '--binNMU=[binNMU version]:version' \ + '--append-to-version=[append string to version]:string' \ + '--binNMU-timestamp=[binNMU timestamp]:timestamp' \ + '--binNMU-changelog=[use this file as binNMU changelog]:file:_files' \ + '--build-dir=[build directory]:directory:_files -/' \ + '(--clean-source --no-clean-source)--clean-source[clean inside an unpacked source tree]' \ + '(--clean-source --no-clean-source)--no-clean-source[do not clean inside an unpacked source tree]' \ + '(--run-lintian --no-run-lintian)--run-lintian[run lintian]' \ + '(--run-lintian --no-run-lintian)--no-run-lintian[do not run lintian]' \ + '(--no-run-lintian --lintian-opt)--lintian-opt=[option for lintian]:option' \ + '(--no-run-lintian --lintian-opts)--lintian-opts=[options for lintian]:options' \ + '(--run-piuparts --no-run-piuparts)--run-piuparts[run piuparts]' \ + '(--run-piuparts --no-run-piuparts)--no-run-piuparts[do not run piuparts]' \ + '(--no-run-piuparts --piuparts-opt)--piuparts-opt=[option for piuparts]:option' \ + '(--no-run-piuparts --piuparts-opts)--piuparts-opts=[options for piuparts]:options' \ + '(--no-run-piuparts --piuparts-root-arg)--piuparts-root-arg=[root-argion for piuparts]:argument' \ + '(--no-run-piuparts --piuparts-root-args)--piuparts-root-args=[root-argions for piuparts]:arguments' \ + '(--run-autopkgtest --no-run-autopkgtest)--run-autopkgtest[run autopkgtest]' \ + '(--run-autopkgtest --no-run-autopkgtest)--no-run-autopkgtest[do not run autopkgtest]' \ + '(--no-run-autopkgtest --autopkgtest-opt)--autopkgtest-opt=[option for autopkgtest]:option' \ + '(--no-run-autopkgtest --autopkgtest-opts)--autopkgtest-opts=[options for autopkgtest]:options' \ + '(--no-run-autopkgtest --autopkgtest-root-arg)--autopkgtest-root-arg=[root-argion for autopkgtest]:argument' \ + '(--no-run-autopkgtest --autopkgtest-root-args)--autopkgtest-root-args=[root-argions for autopkgtest]:arguments' \ + '--pre-build-commands=[run commands before starting anything]:commands' \ + '--chroot-setup-commands=[run commands after chroot initialization]:commands' \ + '--chroot-update-failed-commands=[run commands after chroot update fails]:commands' \ + '--build-deps-failed-commands=[run commands after installing build deps fails]:commands' \ + '--starting-build-commands=[run commands after dependencies are installed]:commands' \ + '--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 built 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]' \ + '--log-external-command-error[external commands error output are logged]' \ + '--build-dep-resolver=[resolver for build dependency]:resolver:(apt aptitude aspcud xapt null)' \ + '--aspcud-criteria=[Optimization for aspcud]:criteria' \ + '(--resolve-alternatives --no-resolve-alternatives)--resolve-alternatives[allow alternatives in Build-Depends*]' \ + '(--resolve-alternatives --no-resolve-alternatives)--no-resolve-alternatives[disallow alternatives in Build-Depends*]' \ + '--extra-package=[make a package or directory available to the resolver]:package:_files -g "*deb(-.)' \ + '--extra-repository=[add a repository to the resolver]:url' \ + '--extra-repository-key=[add key to the resolver]:key:_files -g "*.asc(-.)"' \ + '--build-path=[place to build the package inside chroot]:path:_files -/' \ + '--autopkgtest-virt-server=[autopkgtest virtualization server]:type:(schroot lxc chroot qemu ssh)' \ + '--autopkgtest-virt-server-opt=[option for autopkgtest virtialization server]:option' \ + '--autopkgtest-virt-server-opts=[options for autopkgtest virtialization server]:options' \ + '--sbuild-mode=[switch to buildd mode]:mode:(user buildd)' \ + '--stats-dir=[write stats to directory]:path:_files -/' \ + '--purge-extra-packages[remove all but strictly required dependencies (experimental)]' \ + '--bd-uninstallable-explainer=[choose the method to explain why dependencies failed]:method:(dose3 apt)' \ + '*:dsc file:_files -g "*.dsc(-.)"' + } + +_sbuild "$@" diff --git a/Completion/Debian/Command/_vim-addons b/Completion/Debian/Command/_vim-addons index 0ad39955d..76f701491 100644 --- a/Completion/Debian/Command/_vim-addons +++ b/Completion/Debian/Command/_vim-addons @@ -12,7 +12,7 @@ _arguments \ '(y --system-dir)'{-y,--system-dir}'[set system-wide target directory]' \ '(-)'{-h,--help}'[show help information]' \ '(-w --system-wide -t --target-dir)'{-w,--system-wide}'[use system-wide target directory]' \ - '(-z --silent -v --verbose)'{-z,--silent}'[supress most output]' \ + '(-z --silent -v --verbose)'{-z,--silent}'[suppress most output]' \ '1:commands:(( install\:install\ specified\ addons remove\:remove\ specified\ addons diff --git a/Completion/Debian/Type/_deb_files b/Completion/Debian/Type/_deb_files new file mode 100644 index 000000000..e84871cc4 --- /dev/null +++ b/Completion/Debian/Type/_deb_files @@ -0,0 +1,17 @@ +#autoload + +# This function is used to generate file names for Debian package files (.deb +# and friends). In addition to the options supported by _files, it understands +# the following: +# +# -c Include .changes and .dsc files + +local -a _expl _fopts _c _exts=( deb ddeb udeb ) + +zparseopts -a _fopts -D -E - \ + c=_c 1 2 F+: J+: M+: n P+: q r+: R+: S+: V+: W+: X+: + +(( $#_c )) && _exts+=( changes dsc ) + +_description files _expl 'Debian package' +_files "${(@)_fopts}" "${(@)_expl}" -g "*.(${(j<|>)_exts})(-.)" diff --git a/Completion/Linux/Command/_alsa-utils b/Completion/Linux/Command/_alsa-utils new file mode 100644 index 000000000..91bb0b86c --- /dev/null +++ b/Completion/Linux/Command/_alsa-utils @@ -0,0 +1,54 @@ +#compdef aplay arecord +# Copyright (c) 2019 Sebastian Gniazdowski + +setopt localoptions warncreateglobal typesetsilent + +local -a opts +opts=( + '(- : *)'{-h,--help}'[print help message]' + '(- : *)'--version'[print current version]' + # -l/--list-devices doesn't benefit from -v/--verbose + '(- : *)'{-l,--list-devices}'[list all soundcards and digital audio devices]' + + '(-L --list-pcms)'{-L,--list-pcms}'[list device names]' + '(-D --device)'{-D+,--device=}'[select PCM by name]' + '(-q --quiet)'{-q,--quiet}'[quiet mode]' + '(-t --file-type)'{-t+,--file-type=}'[file type (voc, wav, raw or au)]' + '(-c --channels)'{-c+,--channels=}'[channels]' + '(-r --rate)'{-r+,--rate=}'[sample rate]' + '(-f --format)'{-f+,--format=}'[sample format (case insensitive)]' + '(-d --duration)'{-d+,--duration=}'[interrupt after # seconds]' + '(-s --samples)'{-s+,--samples=}'[interrupt after # samples per channel]' + '(-M --mmap)'{-M,--mmap}'[mmap stream]' + '(-N --nonblock)'{-N,--nonblock}'[nonblocking mode]' + '(-F --period-time)'{-F+,--period-time=}'[distance between interrupts is # microseconds]' + '(-B --buffer-time)'{-B+,--buffer-time=}'[buffer duration is # microseconds]' + --period-size='[distance between interrupts is # frames]' + --buffer-size='[buffer duration is # frames]' + '(-A --avail-min)'{-A+,--avail-min=}'[min available space for wakeup is # microseconds]' + '(-R --start-delay)'{-R+,--start-delay=}'[delay for automatic PCM start is # microseconds]' + '(-T --stop-delay)'{-T+,--stop-delay=}'[delay for automatic PCM stop is # microseconds from xrun]' + '*'{-v,--verbose}'[show PCM structure and setup (accumulative)]' + '(-V --vumeter)'{-V+,--vumeter=}'[enable VU meter (TYPE: mono or stereo)]' + '(-I --separate-channels)'{-I,--separate-channels}'[file for each channel]' + '(-i --interactive)'{-i,--interactive}'[allow interactive operation from stdin]' + '(-m --chmap)'{-m+,--chmap=}'[give the channel map to override or follow]' + --disable-resample'[disable automatic rate resample]' + --disable-channels'[disable automatic channel conversions]' + --disable-format'[disable automatic format conversions]' + --disable-softvol'[disable software volume control (softvol)]' + --test-position'[test ring buffer position]' + --test-coef='[test coefficient for ring buffer position (default 8)]' + --test-nowait'[do not wait for ring buffer - eats whole CPU]' + --max-file-time='[start another output file when the old file has recorded]' + --process-id-file='[write the process ID here]' + --use-strftime'[apply the strftime facility to the output file name]' + --dump-hw-params'[dump hw_params of the device]' + --fatal-errors'[treat all errors as fatal]' + + '*:sound file:_files' +) + +_arguments -s -S $opts + +# The return value passes through 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/_btrfs b/Completion/Linux/Command/_btrfs index 3ecebe62a..eb31580ad 100644 --- a/Completion/Linux/Command/_btrfs +++ b/Completion/Linux/Command/_btrfs @@ -109,16 +109,16 @@ while (( $#state )); do '(-u --uuid)'{-u,--uuid}'[uuid of the subvolume]' '1:subvolume path:_directories' ) - ;; + ;| subvolume:sync) args+=( '-s[sleep between checks]:delay (seconds) [1]' );; subvolume:find-new) args+=( '1:subvol:_files -/' '2:lastgen: _message "last gen"' );; - (device|filesystem|qgroup):(df|du|show|usage)) + (device|filesystem|qgroup|subvolume):(df|du|show|usage)) args+=( '--iec[use 1024 as a base]' '--si[use 1000 as a base]' ) ;| - (device|filesystem):(df|usage)) + (device|filesystem):(df|usage)|subvolume:show) args+=( '(-b --raw)'{-b,--raw}'[output raw numbers in bytes]' '(-h --human-readable -H)'{-h,--human-readable}'[output human friendly numbers, base 1024]' @@ -172,11 +172,17 @@ while (( $#state )); do ) [[ ${${(P)group}[cmd]} == add ]] && args+=( - {-K,--nodiscard}"[don't perform discard]" + {-K,--nodiscard}"[don't perform whole device TRIM]" {-f,--force}'[force overwrite of existing filesystem]' ) ;; - device:scan) args+=( '(1 -)'{-d,--all-devices}'[scan all devices in /dev]' '1:device:_files -g "*(-%)"' );; + device:scan) + args+=( + '(-)'{-u,--forget}'[unregister all stale devices or a given device]' + '(1 -)'{-d,--all-devices}'[enumerate and register all devices]' + '1:device:_files -g "*(-%)"' + ) + ;; device:stats) args+=( '(-c --check)'{-c,--check}'[return non-zero if any stat counter is not zero]' @@ -214,7 +220,7 @@ while (( $#state )); do '(-d -s)-m+[act on metadata chunks]:filter:->filters' '(-d -m)-s+[act on system chunks (only under -f)]:filters:->filters' '-v[verbose mode]' - '-f[force reducing of metadata integrity]' + '-f[force a reduction of metadata integrity]' "--full-balance[don't print warning and don't delay start]" '(--background --bg)'{--background,--bg}'[run balance operation asynchronously in the background]' '1:path:_files -/' @@ -227,7 +233,7 @@ while (( $#state )); do property:list) args+=( '-t[specify object type]:object type:(subvol filesystem inode device)' - '1:object' + '1: : _guard "^-*" object' ) ;; quota:(enable|disable)) args+=( '1:path:_files -/' );; @@ -241,7 +247,7 @@ while (( $#state )); do qgroup:(assign|remove)) args+=( '1:source path:_files -/' '2:destination path:_files -/' '3:path:_files -/' );| qgroup:assign) args+=( \!--rescan - "--no-rescan[don't do a rescan, even if the assignment will make the quotas inconsitent]" ) + "--no-rescan[don't do a rescan, even if the assignment will make the quotas inconsistent]" ) ;; qgroup:(create|destroy)) args+=( '1:qgroupid:' '2:path:_files -/' );; qgroup:show) @@ -286,9 +292,10 @@ while (( $#state )); do '(-r --roots)'{-r,--roots}'[print only short root node info]' '(-R --backups)'{-R,--backups}'[same as --roots plus print backup root info]' '(-u --uuid)'{-u,--uuid}'[print only the uuid tree]' - '(-b --block)'{-b,--block}'[print info from the specified block only]:block' + \*{-b,--block}'[print info from the specified block only]:block number' '(-t --tree)'{-t,--tree}'[print only tree with the given id (string or number)]:tree id' '--follow[use with -b, to show all children tree blocks of the block]' + "--noscan[don't scan devices from the filesystem, use only the listed ones]" ) ;; inspect*:dump-super) @@ -337,7 +344,7 @@ while (( $#state )); do '--init-csum-tree[create a new CRC tree]' '--init-extent-tree[create a new extent tree]' '--clear-space-cache[clear space cache for v1 or v2]:version:(v1 v2)' - '--check-data-csum[verify checkums of data blocks]' + '--check-data-csum[verify checksums of data blocks]' '(-Q --qgroup-report)'{-Q,--qgroup-report}'[verify qgroup accounting and compare against filesystem accounting]' '(-E --subvol-extents)'{-E,--subvol-extents}'[show extent state for the given subvolume]:subvolume id' '(-p --progress)'{-p,--progress}'[indicate progress at various checking phases]' @@ -366,6 +373,9 @@ while (( $#state )); do '2:path:_files -/' ) ;; + send|receive) + args+=( '(-q --quiet)'{-q,--quiet}'[suppress all messages except errors]' ) + ;| send) args+=( '*-v[verbose mode]' @@ -375,7 +385,6 @@ while (( $#state )); do '-f[specify output file]:file:_files' '--no-data[send in NO_FILE_DATA mode]' '(-v --verbose)'{-v,--verbose}'[enable verbose output]' - '(-q --quiet)'{-q,--quiet}'[suppress all messages except errors]' '1:subvolume:_files -/' ) ;; @@ -391,7 +400,11 @@ while (( $#state )); do '1:mount:->mounts' ) ;; - h(|e(|l(|p)))) args+=( '--full[display detailed help]' );; + h(|e(|l(|p)))) args+=( + '--full[display detailed help on every command]' + '--box[show list of built-in tools (busybox style)]' + ) + ;; *) args+=( '*: :_default' );; # fallback for unknown subcommands esac if ! (( shift )); then diff --git a/Completion/Linux/Command/_chcon b/Completion/Linux/Command/_chcon new file mode 100644 index 000000000..2d523f287 --- /dev/null +++ b/Completion/Linux/Command/_chcon @@ -0,0 +1,24 @@ +#compdef chcon + +local ign + +(( $#words > 2 )) && ign='!' +_arguments -C -s -S \ + '(-h --no-dereference)--dereference[dereference symlinks]' \ + '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks themselves]' \ + '(1 -u --user -r --role -l --range -t --type)--reference=[copy security context of specified file]:file:_files' \ + '(1 --reference -u --user)'{-u+,--user=}'[set user in the target security context]: :_selinux_users' \ + '(1 --reference -r --role)'{-r+,--role=}'[set role in the target security context]: :_selinux_roles' \ + '(1 --reference -t --type)'{-t+,--type=}'[set type in the target security context]: :_selinux_types' \ + '(1 --reference -l --range)'{-l+,--range=}'[set range in the target security context]:selinux range' \ + '(--recursive -R)'{--recursive,-R}'[recurse subdirectories]' \ + '(-v --verbose)'{-v,--verbose}'[output a diagnostic for every file processed]' \ + '(-H -L -P)-H[follow symlinks on the command line]' \ + '(-H -L -P)-L[follow all symlinks]' \ + "(-H -L -P)-P[don't follow symlinks (default)]" \ + '!(--preserve-root)--no-preserve-root' \ + "--preserve-root[fail to operate recursively on '/']" \ + '(--reference -u --user -r --role -l --range -t --type)1:security context:_selinux_contexts' \ + "${ign}--help[display help information]" \ + "${ign}--version[display version information]" \ + '*:file:_files' diff --git a/Completion/Linux/Command/_cpupower b/Completion/Linux/Command/_cpupower index 6713323cb..ae1f1d3d1 100644 --- a/Completion/Linux/Command/_cpupower +++ b/Completion/Linux/Command/_cpupower @@ -44,7 +44,7 @@ case $state in {-l,--hwlimits}'[show min/max frequency allowed]' {-d,--driver}'[show the kernel driver in use]' {-p,--policy}'[show the current cpufreq policy]' - {-g,--governors}'[show available governers]' + {-g,--governors}'[show available governors]' {-r,--related-cpus}'[show cpus that run at the same frequency]' {-a,--affected-cpus}'[show software controlled cpus]' {-s,--stats}'[show cpufreq statistics]' diff --git a/Completion/Linux/Command/_cryptsetup b/Completion/Linux/Command/_cryptsetup index ddb2ad3a9..45159d0be 100644 --- a/Completion/Linux/Command/_cryptsetup +++ b/Completion/Linux/Command/_cryptsetup @@ -6,7 +6,8 @@ local -a actions state line expl (( $#words > 2 )) && ign='!' _arguments -s \ '(-v --verbose)'{-v,--verbose}'[enable verbose mode]' \ - '--debug[enable debug mode]' \ + '--debug[show debug messages]' \ + '--debug-json[show debug messages including JSON metadata]' \ '(-c --cipher)'{-c+,--cipher=}'[set cipher]:cipher specification' \ '(-h --hash)'{-h+,--hash=}'[hash algorithm]:hash algorithm' \ '(-y --verify-passphrase)'{-y,--verify-passphrase}'[query for password twice]' \ @@ -48,6 +49,7 @@ _arguments -s \ '--perf-same_cpu_crypt[use dm-crypt same_cpu_crypt performance compatibility option]' \ '--perf-submit_from_crypt_cpus[use dm-crypt submit_from_crypt_cpus performance compatibility option]' \ '--deferred[device removal is deferred until the last user closes it]' \ + '--serialize-memory-hard-pbkdf[use global lock to serialize memory]' \ '--pbkdf=[specify PBKDF algorithm for LUKS2]:algorithm:(argon2i argon2id pbkdf2)' \ '--pbkdf-memory=[specify PBKDF memory cost limit]:limit (kilobytes)' \ '--pbkdf-parallel=[specify PBKDF parallel cost]:threads' \ @@ -67,6 +69,19 @@ _arguments -s \ '--subsystem=[set subsystem label for the LUKS2 device]:subsystem' \ '--unbound[create unbound (no assigned data segment) LUKS2 keyslot]' \ '--json-file=[read or write token to json file]:json file:_files -g "*.json(-.)"' \ + '--luks2-metadata-size=[specify LUKS2 header metadata area size]:size (bytes)' \ + '--luks2-keyslots-size=[specify LUKS2 header keyslots area size]:size (bytes)' \ + '--refresh[refresh (reactivate) device with new parameters]' \ + '--keyslot-key-size=[specify size of the encryption key]:size (bits)' \ + '--keyslot-cipher=[specify cipher used for LUKS2 keyslot encryption]:cipher' \ + '--encrypt[Encrypt LUKS2 device (in-place encryption)]' \ + '--decrypt[decrypt LUKS2 device (remove encryption)]' \ + '--init-only[initialize LUKS2 reencryption in metadata only]' \ + '--reduce-device-size=[reduce data device size (move data offset)]:size (bytes)' \ + '--hotzone-size=[specify maximal reencryption hotzone size]:size (bytes)' \ + '--resilience=[specify reencryption hotzone resilience type]:resilience type:(checksum journal none)' \ + '--resilience-hash=[specify reencryption hotzone checksums hash]:string' \ + '--active-name=[override device autodetection of dm device to be reencrypted]:string' \ "${ign}(- : *)--version[show version information]" \ "${ign}(- : *)"{-\?,--help}'[display help information]' \ "${ign}(- : *)--usage[display brief usage]" \ @@ -82,6 +97,7 @@ case $state in 'resize:resize an active mapping' 'benchmark:benchmark cipher' 'repair:try to repair on-disk metadata' + 'reencrypt:reencrypt LUKS2 device' 'erase:erase all keyslots' 'convert:convert LUKS from/to LUKS2 format' 'config:set permanent configuration options for LUKS2' @@ -114,7 +130,7 @@ case $state in benchmark) args=( '--cipher=:cipher' );; luksKillSlot) args=( $device ':key slot number' );; remove|status|resize|*lose|luksSuspend|luksResume) args=( $mapping );; - erase|convert|config|repair|(luks(AddKey|Erase|RemoveKey|DelKey|UUID|Dump)|isLuks)) + erase|convert|config|repair|reencrypt|(luks(AddKey|Erase|RemoveKey|DelKey|UUID|Dump)|isLuks)) args=( $device ) ;; luks(Format|AddKey|RemoveKey|ChangeKey|ConvertKey)) diff --git a/Completion/Linux/Command/_ethtool b/Completion/Linux/Command/_ethtool index 33b7681dc..dccda4684 100644 --- a/Completion/Linux/Command/_ethtool +++ b/Completion/Linux/Command/_ethtool @@ -48,7 +48,8 @@ _arguments -C \ '--get-phy-tunable[get PHY tunable]' \ '--reset[reset hardware components]' \ '--show-fec[query device for forward error correction support]' \ - '--set-fec[configure forward error correction for device]' && return + '--set-fec[configure forward error correction for device]' \ + {-Q,--per-queue}'[apply per-queue command]' && return if [[ -n $state ]]; then case $words[CURRENT-1] in @@ -61,7 +62,7 @@ if [[ -n $state ]]; then _wanted onoff expl 'enabled' compadd off on fi ;; - autoneg|adaptive-[rt]x|raw|hex|sg|tso|ufo|gso|lro|eee|tx-lpi|downshift) + autoneg|adaptive-[rt]x|raw|hex|sg|tso|ufo|gso|lro|eee|tx-lpi|downshift|fast-link-down) _wanted onoff expl 'enabled' compadd off on ;; rx-usecs|rx-frames|rx-usecs-irq|rx-frames-irq|tx-usecs|tx-frames) ;& @@ -70,7 +71,7 @@ if [[ -n $state ]]; then rx-frames-high|tx-usecs-high|tx-frames-high|sample-interval|dmac|rx-mini) ;& rx-jumbo|offset|length|magic|value|phyad|proto|tos|tclass|l4proto|src-port) ;& dst-port|spi|l4data|vlan-etype|vlan|user-def|action|vf|queue|loc) ;& - other|combined|tx-timer|count) + other|combined|tx-timer|count|msecs) _message -e numbers 'number' ;; speed) @@ -279,10 +280,10 @@ if [[ -n $state ]]; then _wanted behaviours expl behaviour compadd -F line - eee advertise tx-lpi tx-timer ;; --set-phy-tunable) - _wanted options expl tunable compadd -F line - downshift count + _wanted options expl tunable compadd -F line - downshift count fast-link-down msecs ;; --get-phy-tunable) - _wanted options expl tunable compadd downshift + _wanted options expl tunable compadd downshift fast-link-down ;; --reset) _wanted components expl component compadd flags dedicated all \ @@ -295,6 +296,13 @@ if [[ -n $state ]]; then _wanted encodings expl encoding compadd -F line auto off rs baser fi ;; + -Q|--pre-queue) + if (( CURRENT == 4 )); then + _wanted options expl option compadd - queue_mask + elif (( CURRENT == 6)); then + _wanted options expl option compadd -c --show-coalescing -C --coalesce + fi + ;; esac ;; esac diff --git a/Completion/Linux/Command/_findmnt b/Completion/Linux/Command/_findmnt new file mode 100644 index 000000000..9f13e695f --- /dev/null +++ b/Completion/Linux/Command/_findmnt @@ -0,0 +1,114 @@ +#compdef findmnt +# +# Note for customization: +# Options -N -k -m -s are in a group 'S' and need be specified as +# 'S-option-N' etc. in the context for zstyle. For example, if you want +# all PIDs to be completed for 'findmnt -N<TAB>', then +# zstyle ':completion:*:findmnt:S-option-N-1:processes' command 'ps -A' +# +local curcontext=$curcontext state state_descr line ret=1 +typeset -A opt_args + +_arguments -s -C \ + '(H -A --all)'{-A,--all}'[print all filesystems]' \ + '(H -a --ascii)'{-a,--ascii}'[use ascii characters for tree formatting]' \ + '(H -b --bytes)'{-b,--bytes}'[print SIZE etc. in bytes]' \ + '(H -c --nocanonicalize)'{-c,--nocanonicalize}'[do not canonicalize path]' \ + '(H -d --direction)'{-d+,--direction=}'[specify the search direction]:direction:(forward backward)' \ + '(H -e --evaluate)'{-e,--evaluate}'[convert LABEL/UUID/PARTLABEL/PARTUUID to the device name]' \ + '(H -F --tab-file)*'{-F+,--tab-file=}'[search in the specified tab file]:tab file:_files' \ + '(H -f --first-only)'{-f,--first-only}'[print the first matching filesystem only]' \ + '(H -i --invert)'{-i,--invert}'[invert the sense of matching]' \ + '(H -M --mountpoint :)'{-M+,--mountpoint=}'[specify the mountpoint]: :->targets' \ + '(H -n --noheadings)'{-n,--noheadings}'[do not print a header line]' \ + '(H -O --options)'{-O+,--options=}'[only print the filesystems with the specified options]:list of options: ' \ + '(H -o --output)'{-o+,--output=}'[specify output columns]: :->columns' \ + '(H -p --poll)'{-p+,--poll=}'[monitor changes in /proc/self/mountinfo]::action:(mount umount remount move)' \ + '(H -R --submounts)'{-R,--submounts}'[print recursively all submounts]' \ + '(H -S --source :)'{-S+,--source=}'[specify the mount source]: :->sources' \ + '(H -T --target :)'{-T+,--target=}'[specify the mount target]:target:_files' \ + '(H -t --types)'{-t+,--types=}'[specify the type of filesystems]:filesystem types:_sequence -s , _file_systems' \ + '--tree[use tree-like output if possible]' \ + '(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]:milliseconds: ' \ + '(H -x --verify)'{-x,--verify}'[check mount table content]' \ + '(H)--verbose[print more information]' \ + '(H)1: :->sources_targets' \ + '(H)2:: :->targets' \ + + '(format)' \ + '(H)'{-D,--df}'[imitate the output of df command]' \ + '(H)'{-J,--json}'[use JASON output format]' \ + '(H)'{-l,--list}'[use list output format]' \ + '(H)'{-P,--pairs}'[use key="value" output format]' \ + '(H)'{-r,--raw}'[use raw output format]' \ + + '(S)' \ + '(H)'{-k,--kernel}'[search in /proc/self/mountinfo (default)]' \ + '(H)'{-m,--mtab}'[search in /etc/mtab]' \ + '(H)'{-N+,--task=}'[search /proc/<pid>/mountinfo]: :_pids' \ + '(H)'{-s,--fstab}'[search in /etc/fstab]' \ + + '(H)' \ + '(- :)'{-h,--help}'[display help text and exit]' \ + '(- :)'{-V,--version}'[display version and exit]' \ + && ret=0 + +__findmnt_mountpoints () { + compadd "$@" \ + ${(f)"$(_call_program mount-points findmnt $opts -oTARGET)"} +} + +case $state in + columns) + compset -P '+' || _describe -t list-prefixes prefix \ + '( +:"not replace but extend the list" )' -S '' && ret=0 + local -a columns=( + ${${${(f)"$(_call_program columns findmnt -h)"}[(r)Available*,-2]}[2,-1]} + ) + columns=( ${${${${${${columns## #}//:/\\:}//\[/\\[}//]/\\]}/ /[}/%/]} ) + _values -s , -M 'm:{a-z}={A-Z}' column $columns && ret=0 + ;; + *) # call "findmnt $opts" to get possible sources/targets + local opts='-lnve' + if [[ -n $opt_args[(I)S-(-m|--mtab)] ]]; then + opts+=' -m' + elif [[ -n $opt_args[(I)S-(-s|--fstab)] ]]; then + opts+=' -s' + elif [[ -n $opt_args[(I)S-(-N|--task)] ]]; then + opts+=" -N${(v)opt_args[(I)S-(-N|--task)]}" + fi + ;| + sources*) # 'sources' or 'sources_targets' + local -a val + if compset -P 'LABEL='; then + val=( ${(f)"$(_call_program labels findmnt $opts -oLABEL)"} ) + _describe -t labels 'LABEL' val && ret=0 + elif compset -P 'PARTLABEL='; then + val=( ${(f)"$(_call_program labels findmnt $opts -oPARTLABEL)"} ) + _describe -t labels 'PARTLABEL' val && ret=0 + elif compset -P 'UUID='; then + val=( ${(f)"$(_call_program uuids findmnt $opts -oUUID)"} ) + _describe -t uuids 'UUID' val && ret=0 + elif compset -P 'PARTUUID='; then + val=( ${(f)"$(_call_program uuids findmnt $opts -oPARTUUID)"} ) + _describe -t uuids 'PARTUUID' val && ret=0 + else + local -a alts=( + 'devices:device:compadd \ + $(_call_program devices findmnt $opts -oSOURCE)' + 'device-numbers:major-minor:compadd \ + ${$(_call_program device-numbers findmnt $opts -oMAJ:MIN)// /}' + 'prefixes:prefix:compadd -S "" LABEL= UUID= PARTLABEL= PARTUUID=' + ) + [[ $state = sources_targets ]] && + alts+=( 'mount-points:moutpoint:__findmnt_mountpoints' ) + _alternative $alts && ret=0 + fi + ;; + targets) + local expl + _wanted mount-points expl 'mountpoint' __findmnt_mountpoints && ret=0 + ;; +esac + +return ret diff --git a/Completion/Linux/Command/_free b/Completion/Linux/Command/_free new file mode 100644 index 000000000..cc5bcf3bd --- /dev/null +++ b/Completion/Linux/Command/_free @@ -0,0 +1,25 @@ +#compdef free +# based on procps-ng-3.3.15 + +_arguments -s \ + '(-l --lohi)'{-l,--lohi}'[show detailed low and high memory statistics]' \ + '(-t --total)'{-t,--total}'[show total for RAM + swap]' \ + '(-w --wide)'{-w,--wide}'[wide mode]' \ + '(-s --seconds)'{-s,--seconds}'[specify the delay between display]:seconds: ' \ + '(-c --count)'{-c+,--count=}'[specify the display count]:count: ' \ + '--si[use power of 1000 instead of power of 1024]' \ + '(-)--help[print help and exit]' \ + '(-)'{-V,--version}'[print version information and exit]' \ + + '(unit)' \ + {-b,--bytes}'[display the amount of memory in bytes]' \ + {-k,--kibi}'[display the amount of memory in kibibytes (default)]' \ + {-m,--mebi}'[display the amount of memory in mebibytes]' \ + {-g,--gibi}'[display the amount of memory in gibibytes]' \ + '--tebi[display the amount of memory in tebibytes]' \ + '--pebi[display the amount of memory in pebibytes]' \ + '(--si)--kilo[display the amount of memory in kilobytes]' \ + '(--si)--mega[display the amount of memory in megabytes]' \ + '(--si)--giga[display the amount of memory in gigabytes]' \ + '(--si)--tera[display the amount of memory in terabytes]' \ + '(--si)--peta[display the amount of memory in petabytes]' \ + {-h,--human}'[automatically select unit]' diff --git a/Completion/Linux/Command/_iptables b/Completion/Linux/Command/_iptables index ae8d66ea4..27c801da1 100644 --- a/Completion/Linux/Command/_iptables +++ b/Completion/Linux/Command/_iptables @@ -47,7 +47,7 @@ case ${prev[${prev[(I)-p|--protocol]}+1]}; in esac case ${prev[${prev[(I)-j|--jump]}+1]}; in - DNAT) args+=( '(--to --to-destination)'{--to,--to-destination}':address:_users-ports' ) ;; + DNAT) args+=( '(--to --to-destination)'{--to,--to-destination}':address' ) ;; DSCP) args+=( '--set-dscp[set the DSCP field]:value' @@ -67,7 +67,7 @@ case ${prev[${prev[(I)-j|--jump]}+1]}; in MARK) args+=( '--set-mark[set fwmark in packet]:number' ) ;; REDIRECT|MASQUERADE) args+=( '--to-ports[port (range) to map to]:port range:_ports' ) ;; REJECT) args+=( '--reject-with[drop packet and send reply]:reject type:->reject-types' ) ;; - SNAT) args+=( '(--to --to-source)*'{--to,--to-source}'[specify address to map source to]:address:_users-ports' ) ;; + SNAT) args+=( '(--to --to-source)*'{--to,--to-source}'[specify address to map source to]:address' ) ;; TCPMSS) args+=( '--set-mss[explicitly set MSS option]:value' @@ -102,7 +102,7 @@ while '--ctreplsrc[match reply source address]:*^!:network:_hosts' '--ctrepldst[match reply destination address]:*^!:network:_hosts' '--ctstatus[match internal conntrack states]:state:(NONE EXPECTED SEEN_REPLY ASSURED)' - '--ctexpire[match remaing lifetime]:time' + '--ctexpire[match remaining lifetime]:time' ) ;; dscp) diff --git a/Completion/Linux/Command/_kpartx b/Completion/Linux/Command/_kpartx index 8f09c416d..79a8dd8a7 100644 --- a/Completion/Linux/Command/_kpartx +++ b/Completion/Linux/Command/_kpartx @@ -1,11 +1,11 @@ #compdef kpartx _arguments -s -S : \ - '-a[add partition mappings]' \ + '(-d -u -l)-a[add partition mappings]' \ '-r[read-only partition mappings]' \ - '-d[delete partition mappings]' \ - '-u[update partition mappings]' \ - '-l[list partition mappings]' \ + '(-a -u -l)-d[delete partition mappings]' \ + '(-a -d -l)-u[update partition mappings]' \ + '(-a -d -u)-l[list partition mappings]' \ '-p[set device name-partition number delimiter]' \ '-f[force creation of mappings]' \ '-g[force GUID partition table]' \ diff --git a/Completion/Linux/Command/_losetup b/Completion/Linux/Command/_losetup index d826e8d51..54debe19e 100644 --- a/Completion/Linux/Command/_losetup +++ b/Completion/Linux/Command/_losetup @@ -1,4 +1,4 @@ -#lcompdef losetup -value-,LOOPDEV_DEBUG,-default- +#compdef losetup -value-,LOOPDEV_DEBUG,-default- if [[ $service = *LOOPDEV_DEBUG* ]]; then local expl diff --git a/Completion/Linux/Command/_lsblk b/Completion/Linux/Command/_lsblk index 1a3687c45..8a9bc18bf 100644 --- a/Completion/Linux/Command/_lsblk +++ b/Completion/Linux/Command/_lsblk @@ -1,11 +1,12 @@ #compdef lsblk local sep ret=1 -local -a values dedup suf=( -qS , ) +local -a values dedup suf local curcontext="$curcontext" state line expl typeset -A opt_args _arguments -C -s -S \ + '(H -E --dedup)'{-E+,--dedup=}'[de-duplicate output by specified column]:column:->columns' \ '(H -a --all)'{-a,--all}'[print all devices]' \ '(H -b --bytes)'{-b,--bytes}'[print size in bytes rather than in human readable format]' \ '(H -d --nodeps)'{-d,--nodeps}"[don't print slaves or holders]" \ @@ -30,7 +31,7 @@ _arguments -C -s -S \ '(H)'{-i,--ascii}'[output ascii characters only]' \ '(H)'{-J,--json}'[use JSON output format]' \ '(H)'{-l,--list}'[use list format output]' \ - '(H)'{-t,--tree}'[use tree format output]' \ + '(H)'{-T+,--tree=}'[use tree format output]:column:->columns' \ '(H)'{-P,--pairs}'[use key="value" output format]' \ '(H)'{-r,--raw}'[use raw output format]' \ + 'H' \ @@ -38,14 +39,19 @@ _arguments -C -s -S \ '(* -)'{-V,--version}'[display version information]' && ret=0 case $state in + columnlist) + compset -P '+' || _describe -t list-prefixes prefix \ + '( +:"not replace but extend the list" )' -S '' && ret=0 + ;| *list) dedup=( ${(Ms.,.)PREFIX##*,} ${(Ms.,.)SUFFIX%%,*} ) + suf=( -qS , ) compset -S ',*' && suf=() compset -P '*,' ;| column*) values=( - ${${${${(f)"$(_call_program columns lsblk -h)"}[(r)Available*,-3]## #}[2,-1]//:/\\:}/ /:} + ${${${${(f)"$(_call_program columns lsblk -h)"}[(r)Available*,-2]## #}[2,-1]//:/\\:}/ /:} ) _describe -t fields column values -M 'm:{a-z}={A-Z}' $suf -F dedup && ret=0 ;; 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/Linux/Command/_modutils b/Completion/Linux/Command/_modutils index 9a37fcae1..ff6844f41 100644 --- a/Completion/Linux/Command/_modutils +++ b/Completion/Linux/Command/_modutils @@ -10,138 +10,146 @@ _modules_caching_policy() } _modutils() { - local curcontext="$curcontext" expl state line modules ign args ret=1 - local -r modules_dir=/lib/modules - - local update_policy - zstyle -s ":completion:*:*:$service:*" cache-policy update_policy - if [[ -z "$update_policy" ]]; then - zstyle ":completion:*:*:$service:*" cache-policy _modules_caching_policy - fi - - args=( - '(-)'{-V,--version}'[print version]' - '(-)'{-h,--help}'[print help text]' - ) - - case "$service" in - lsmod) _arguments -s "$args[@]" && return ;; - - modinfo) - _arguments -s -C "$args[@]" \ - '(-)'{-a,--author}"[display the module's author]" \ - '(-)'{-d,--description}"[display the module's description]" \ - '(-)'{-l,--license}"[display the module's license]" \ - '(-)'{-n,--filename}"[display the module's filename]" \ - '(-)'{-p,--parameters}'[display the typed parameters that a module may support]' \ - '(-)'{-F,--field}"[display only selected module's information]:module_field:(alias author depends description filename license parm)" \ - '(-)-k[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \ - '1:module file:->all_modules' && ret=0 - ;; - - modprobe) - ign='-h --help -V --version -c --showconfig' - _arguments -s -C "$args[@]" \ - "(-a --all $ign)"{-a,--all}'[load all matching modules]' \ - '(-)'{-c,--showconfig}'[show current configuration]' \ - "(-d --debug $ign)"{-d,--debug}'[print debug info]' \ - "(-k --autoclean $ign)"{-k,--autoclean}'[set autoclean]' \ - "(-n --show $ign)"{-n,--show}"[don't actually perform action]" \ - "(-q --quiet $ign)"{-q,--quiet}"[don't complain about insmod failures]" \ - "(-s --syslog $ign)"{-s,--syslog}'[report via syslog instead of stderr]' \ - "(* -t --type $ign)"{-t,--type}'[module type]:module type' \ - "(-v --verbose $ign)"{-v,--verbose}'[print all commands as executed]' \ - '(-C --config)'{-C,--config}'[specify config file]:config file:_files' \ - "(-r --remove -l --list -t --type -a --all $ign)"{-r,--remove}'[remove module (stacks)]' \ - "(-l --list -t --type -a --all $ign)"{'-i[ignore install/remove commands in config file]','--ignore-install[ignore install commands in config file]','--ignore-remove[ignore remove commands in config file]'} \ - "(* -l --list -r --remove $ign)"{-l,--list}'[list matching modules]' \ - "(-c $ign)1:modules:->loadable_modules" \ - "(-c -l --list -t --type $ign)*:params:->params" && ret=0 - - [[ -n $state ]] && (( $+opt_args[-r] )) && state=loaded_modules - ;; - - rmmod) - _arguments -s -C "$args[@]" \ - '(-a --all)'{-a,--all}'[remove all unused autocleanable modules]' \ - '(-e --persist)'{-e,--persist}'[save persistent data]' \ - '(-r --stacks)'{-r,--stacks}'[remove a module stack]' \ - '(-s --syslog)'{-s,--syslog}'[output to syslog]' \ - '(-v --verbose)'{-v,--verbose}'[be verbose]' \ - '*:loaded module:->loaded_modules' && ret=0 - ;; - - insmod) - _arguments \ - '1:module file:_files' \ - '*:module parameters:' && ret=0 - ;; - esac - - case "$state" in - loaded_modules|loadable_modules) - if [[ -r /proc/modules ]]; then - loaded_modules=(${${(f)"$(</proc/modules)"}%% *}) - elif [[ -x /sbin/lsmod ]]; then - loaded_modules=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *}) - else - return 1 - fi - - if [[ $state = loaded_modules ]]; then - _wanted modules expl 'loaded module' compadd -a loaded_modules \ - && return - return ret - fi - ;& - - all_modules) - local kver - integer kver_idx - if (( kver_idx=${words[(I)-k]} )); then - kver=${words[kver_idx+1]} - else - kver=$(uname -r) - fi - - if _cache_invalid modules-$kver || ! _retrieve_cache modules-$kver; - then - # 2011-01-02 gi1242: Do we need .o files? Or is .ko enough? - modules=( $modules_dir/$kver/(*~(source|build))/**/*.(o|ko|ko.gz|ko.xz)(.:t:r:r) ) - _store_cache modules-$kver modules - fi - - if [[ $state = loadable_modules ]]; then - modules=( ${modules:#(${(j:|:)~${=loaded_modules//_/-}})} ) - fi - - _tags files modules - while _tags; do - _requested files expl "module file" _files -g '*.ko(-.)' && ret=0 - _requested modules expl module compadd -a modules && ret=0 - (( ret )) || break - done - ;; - - params) - if compset -P 1 '*='; then - _message -e value 'parameter value' - else - local params - params=( ${${(M)${(f)"$(_call_program module_parameter /sbin/modinfo "$words[2]" 2>/dev/null)"}:#parm:*}##parm:[[:space:]]##} ) - if [[ $#params -eq 0 ]]; then - _message -e parameter "This modules doesn't have parameters" - else - typeset -A val_args - - _values -S = -C -w 'module parameter' \ - ${${${(M)params:#*(:bool|\(bool\))}/:/[}/(bool| \(bool\))/]} ${^${params:#*(:bool|\(bool\))}/:/[}"]:auto added argument: " && ret=0 - fi - fi - ;; - esac - - return ret + local curcontext="$curcontext" expl state line modules modaliases ign args ret=1 + local -A opt_args + local -r modules_dir=/lib/modules + + local update_policy + zstyle -s ":completion:*:*:$service:*" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:*:*:$service:*" cache-policy _modules_caching_policy + fi + + args=( + '(-)'{-V,--version}'[display version information]' + '(-)'{-h,--help}'[display usage information]' + ) + + case "$service" in + lsmod) _arguments -s "$args[@]" && return ;; + + modinfo) + _arguments -s -C "$args[@]" \ + '(-)'{-k+,--set-version=}'[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \ + {-b+,--basedir=}'[use specified directory as filesystem root]:path:_directories' \ + '1:module file:->all-modules' \ + + '(field)' \ + {-a,--author}"[display the module's author]" \ + {-d,--description}"[display the module's description]" \ + {-l,--license}"[display the module's license]" \ + {-n,--filename}"[display the module's filename]" \ + {-p,--parameters}'[display the typed parameters that a module may support]' \ + {-F+,--field}"[display only selected module's information]:module_field:(alias author depends description filename intree license name parm sig_hashalgo sig_key signat signer srcversion vermagic)" \ + {-0,--null}'[use a null instead of newline in output]' && ret=0 + ;; + + modprobe) + ign='-h --help -V --version -c --showconfig --show-config' + _arguments -s -C "$args[@]" \ + "(-a --all $ign)"{-a,--all}'[load all matching modules]' \ + "(-n --show $ign)"{-n,--show}"[don't actually perform action]" \ + "(-q --quiet $ign)"{-q,--quiet}"[don't complain about insmod failures]" \ + "(-s --syslog $ign)"{-s,--syslog}'[report via syslog instead of stderr]' \ + "(-v --verbose $ign)"{-v,--verbose}'[print all commands as executed]' \ + '(-C --config)'{-C+,--config=}'[specify config file]:config file:_files' \ + "(-r --remove -a --all $ign)"{-r,--remove}'[remove module (stacks)]' \ + '--remove-dependencies[also remove modules depending on it]' \ + '(* -R --resolve-alias)'{-R,--resolve-alias}'[only lookup and print alias and exit]' \ + '--first-time[fail if module already inserted or removed]' \ + "(-a --all $ign)"{'-i[ignore install/remove commands in config file]','--ignore-install[ignore install commands in config file]','--ignore-remove[ignore remove commands in config file]'} \ + '(-b --use-blacklist)'{-b,--use-blacklist}'[apply blacklist to resolved alias]' \ + '(-f --force --force-modversions --force-vermagic)'{-f,--force}'[force module insertion or removal]' \ + "(-f --force)--force-modversion[ignore module's version]" \ + "(-f --force)--force-vermagic[ignore module's version magic]" \ + '(-D --show-depends)'{-D,--show-depends}'[only print module dependencies and exit]' \ + '(-)'{-c,--showconfig,--show-config}'[show current configuration]' \ + --{show,dump}'-modversions[dump module symbol version and exit]' \ + {-d+,--dirname=}'[use specified directory as filesystem root]:path:_directories' \ + {-S+,--set-version=}'[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \ + '--show-exports[only print module exported symbol versions and exit]' \ + '(-n --dry-run --show)'{-n,--dry-run,--show}"[don't execute operations, just print]" \ + "(-c $ign)1:modules:->loadable-modules" \ + "(-c $ign)*:params:->params" && ret=0 + + [[ -n $state && -n ${opt_args[(i)(-r|--remove)]} ]] && state=loaded-modules + ;; + + rmmod) + _arguments -s -C "$args[@]" \ + '(-f --force)'{-f,--force}'[allow modules that are in use to be removed]' \ + '(-s --syslog)'{-s,--syslog}'[send errors to syslog]' \ + '(-v --verbose)'{-v,--verbose}'[be verbose]' \ + '*:loaded module:->loaded-modules' && ret=0 + ;; + + insmod) + _arguments "$args[@]" \ + '1:module file:_files' \ + '*:module parameters' && ret=0 + ;; + esac + + case "$state" in + loaded-modules|loadable-modules) + if [[ -r /proc/modules ]]; then + loaded_modules=(${${(f)"$(</proc/modules)"}%% *}) + elif [[ -x /sbin/lsmod ]]; then + loaded_modules=(${${(f)"$(/sbin/lsmod)"}[2,-1]%% *}) + else + return 1 + fi + + if [[ $state = loaded-modules ]]; then + _wanted modules expl 'loaded module' compadd -a loaded_modules && ret=0 + return ret + fi + ;& + + all-modules) + local kver=${opt_args[(i)(-S|-k|--set-version)]:-$(uname -r)} + + if _cache_invalid modules-$kver || ! _retrieve_cache modules-$kver; + then + modules=( $modules_dir/$kver/(*~(source|build))/**/*.(o|ko|ko.gz|ko.xz)(.:t:r:r) ) + modaliases=( ${${${(M)${(f)"$(<$modules_dir/$kver/modules.alias)"}:#alias*}#alias }%% *} ) + _store_cache modules-$kver modules modaliases + fi + + if (( ${+opt_args[(k)(-R|--resolve-alias)]} )); then + _tags module-aliases + else + _tags files modules module-aliases + fi + if [[ $state = loadable-modules ]]; then + modules=( ${modules:#(${(j:|:)~${=loaded_modules//_/-}})} ) + fi + + while _tags; do + _requested modules expl module compadd -a modules && ret=0 + _requested module-aliases expl 'module alias' compadd -a modaliases && ret=0 + _requested files expl "module file" _files -g '*.ko(-.)' && ret=0 + (( ret )) || break + done + ;; + + params) + if compset -P 1 '*='; then + _message -e value 'parameter value' + else + local params + params=( ${${(M)${(f)"$(_call_program module-parameters /sbin/modinfo "$words[2]" 2>/dev/null)"}:#parm:*}##parm:[[:space:]]##} ) + compset -S '=*' + if (( $#params )); then + _values -S = -w 'module parameter' \ + ${${${(M)params:#*(:bool|\(bool\))}/:/[}/(bool| \(bool\))/]} ${^${params:#*(:bool|\(bool\))}/:/[}"]:auto added argument: " && ret=0 + else + _message -e parameter "module doesn't take parameters" + fi + fi + ;; + esac + + return ret } _modutils "$@" diff --git a/Completion/Linux/Command/_networkmanager b/Completion/Linux/Command/_networkmanager index fa9301971..c9b09d145 100644 --- a/Completion/Linux/Command/_networkmanager +++ b/Completion/Linux/Command/_networkmanager @@ -4,6 +4,7 @@ _networkmanager() { local curcontext="$curcontext" state line + local nmcli="$words[1]" _arguments -C \ '(-o -overview)-o'{,verview}'[overview mode (hide default values)]' \ @@ -107,10 +108,22 @@ _nm_connection_down() { } _nm_connection_modify() { - # TODO: add support for options and properties - _arguments \ + local curcontext="$curcontext" ret=1 + local -a state line expl properties + + _arguments -A "-*" \ "--temporary" \ - "1:connection:_nm_connection_specs" + "1:connection:_nm_connection_specs" \ + '2:option:->properties' \ + '3:value' && ret=0 + + if [[ -n "$state" ]]; then + properties=( ${${(f)"$(_call_program properties $nmcli -t connection show $line[1])"}%%:*} ) + _description properties expl property + _multi_parts "$expl[@]" . properties && ret=0 + fi + + return ret } _nm_connection_clone() { @@ -245,6 +258,7 @@ _nm_device_wifi() { _nm_device_wifi_list() { # TODO: support bssid on its own _arguments \ + '--rescan[force or disable network scan]:network scan:(yes no auto)' \ "1: :(ifname)" \ "2:interface:_nm_device_ifnames" \ "3: :(bssid)" \ diff --git a/Completion/Linux/Command/_pmap b/Completion/Linux/Command/_pmap new file mode 100644 index 000000000..ba3321531 --- /dev/null +++ b/Completion/Linux/Command/_pmap @@ -0,0 +1,20 @@ +#compdef pmap +# based on procps-ng-3.3.15 + +_arguments -s \ + '(exit -A --range)'{-A+,--range}'[limit results to the specified address range]:low,high: ' \ + '(exit -q --quiet)'{-q,--quiet}'[do not display some header or footer lines]' \ + '(exit -p --show-path)'{-p,--show-path}'[show full path to files in the mapping column]' \ + '(exit)*: :_pids' \ + + '(format)' \ + '(exit)'{-d,--device}'[show the device format]' \ + '(exit)'{-x,--extended}'[show the extended format]' \ + '(exit)-X[show even more details than -x option]' \ + '(exit)-XX[show everything the kernel provides]' \ + '(exit)'{-c,--read-rc}'[read the default configuration]' \ + '(exit)'{-C+,--read-rc-from=}'[read the configuration from the specified file]: :_files' \ + + '(exit)' \ + '(- *)'{-n,--create-rc}'[create new default configuration and exit]' \ + '(- *)'{-N+,--create-rc-to=}'[create new configuration to the specified file and exit]: :_files' \ + '(- *)'{-h,--help}'[display help text and exit]' \ + '(- *)'{-V,--version}'[display version information and exit]' diff --git a/Completion/Linux/Command/_rpmbuild b/Completion/Linux/Command/_rpmbuild deleted file mode 100644 index 74d4464d8..000000000 --- a/Completion/Linux/Command/_rpmbuild +++ /dev/null @@ -1,53 +0,0 @@ -#compdef rpmbuild - -local -a cmds b_cmds t_cmds options b_options - -cmds=(--rebuild --recompile) -b_cmds=(-ba -bb -bp -bc -bi -bl -bs) -t_cmds=(-ta -tb -tp -tc -ti -tl -ts) -options=(--quiet -v -vv --verbose --rcfile --pipe --dbpath -r --root --buildroot --clean --nobuild --nodeps --nodigest --nosignature --macros - --rmsource --rmspec --short-circuit --sign --target -D --define -E --eval --with --without --debug --bcond --install-build-tree) -b_options=(--clean --nobuild --nodeps --nodigest --nosignature --rmsource --rmspec --short-circuit --sign --target --debug --with --without) - -_arguments \ - "($cmds $b_cmds $t_cmds)"{-ba,-ta}'[build binary and source packages]' \ - "($cmds $b_cmds $t_cmds)"{-bb,-tb}'[build a binary package]' \ - "($cmds $b_cmds $t_cmds)"{-bp,-tp}'[execute the "%prep" stage]' \ - "($cmds $b_cmds $t_cmds)"{-bc,-tc}'[do the "%build" stage]' \ - "($cmds $b_cmds $t_cmds)"{-bi,-ti}'[do the "%install" stage]' \ - "($cmds $b_cmds $t_cmds)"{-bl,-tl}'[do a "list check"]' \ - "($cmds $b_cmds $t_cmds)"{-bs,-ts}'[build just the source package]' \ - "($cmds $b_cmds $t_cmds * $b_options $options)"{-\?,--help}'[show help message]' \ - "($cmds $b_cmds $t_cmds * $b_options $options)"--querytags'[display known query tags]' \ - "($cmds $b_cmds $t_cmds * $b_options)"--showrc'[display final rpmrc and macro configuration]' \ - "($cmds $b_cmds $t_cmds * $b_options $options)"--usage'[display brief usage message]' \ - "($cmds $b_cmds $t_cmds * $b_options $options)"--version'[print the version of rpm being used]' \ - "(-v --verbose -vv)"--quiet'[print as little as possible]' \ - "(-v --verbose --quiet)"{-v,--verbose}'[print verbose information]' \ - "(-v --verbose --quiet)"-vv'[print lots of ugly debugging information]' \ - --rcfile'[RC files]:RC files:_files -S\:' \ - --macros'[macros files]:macros files:_files -S\:' \ - --pipe'[command to pipe the output of rpm to]:command' \ - --dbpath'[set database directory]:database directory:_files -/' \ - "(-r --root)"{-r,--root}'[root file system tree]:chroot directory:_files -/' \ - --buildroot'[override the BuildRoot]:BuildRoot directory:_files -/' \ - --clean'[remove the build tree after the packages are made]' \ - --nobuild'[do not execute any build stages (for spec testing purposes]' \ - --nodeps'[do not verify build dependencies]' \ - --nodigest"[don't verify package digest(s)]" \ - --nosignature"[don't verify package signature(s)]" \ - --rmsource'[remove the sources after the build]' \ - --rmspec'[remove the spec file after the build]' \ - --short-circuit'[skip straight to specified stage (-bc, -bi or -bb in PLD Linux]' \ - --sign'[embed a GPG signature]' \ - --target='[set target platform]:arch-vendor-os:' \ - {'*-D','*--define='}'[define MACRO with value EXPR]:MACRO EXPR' \ - {'*-E','*--eval='}'[print macro expansion of EXPR]:EXPR' \ - '*--with[enable configure option for build]:option' \ - '*--without[disable configure option for build]:option' \ - "($cmds $b_cmds $t_cmds * $b_options)"--bcond'[find all --with/--without values]' \ - --debug'[build packages with debug information]' \ - "($cmds $b_cmds $t_cmds * $b_options)"--install-build-tree'[make all needed dirs for building binary rpms]' \ - "(--clean $b_cmds $t_cmds --rebuild)"--recompile'[recompile source package]' \ - "(--clean $b_cmds $t_cmds --recompile)"--rebuild'[rebuild source package]' \ - "*:file:_files -g '(#i)*.(spec|srpm|tgz|tar|tar.gz|tar.bz2)(-.)'" && ret=0 diff --git a/Completion/Linux/Command/_setsid b/Completion/Linux/Command/_setsid index a8107e582..d248925aa 100644 --- a/Completion/Linux/Command/_setsid +++ b/Completion/Linux/Command/_setsid @@ -1,12 +1,9 @@ #compdef setsid -[[ $service == setsid ]] && precommands+=( setsid ) - _arguments -s -S -A '-*' : \ '(: * -)'{-h,--help}'[display help information]' \ '(: * -)'{-V,--version}'[display version information]' \ '(-c --ctty)'{-c,--ctty}'[set controlling terminal to current one]' \ '(-f --fork)'{-f,--fork}'[always fork]' \ '(-w --wait)'{-w,--wait}'[wait for program to exit, and use same return code]' \ - '1: :_path_commands' \ - '*:: : _normal' + '*:: : _normal -p $service' diff --git a/Completion/Linux/Command/_slabtop b/Completion/Linux/Command/_slabtop new file mode 100644 index 000000000..5c8919d12 --- /dev/null +++ b/Completion/Linux/Command/_slabtop @@ -0,0 +1,22 @@ +#compdef slabtop +# based on procps-ng-3.3.15 + +local -a criteria=( + 'a:number of active objects' + 'b:objects per slab' + 'c:cache size' + 'l:number of slabs' + 'v:number of active slabs' + 'n:name' + 'o:number of objects' + 'p:page per slab' + 's:object size' + 'u:cache utilization' +) + +_arguments -s \ + '(-d --delay -o --once)'{-d+,--delay=}'[specify the delay between updates]:seconds: ' \ + '(-s --sort)'{-s+,--sort=}'[specify the sort criteria]:criteria:(($criteria))' \ + '(-d --delay -o --once)'{-o,--once}'[display the output once and exit]' \ + '(-)'{-V,--version}'[display version information and exit]' \ + '(-)'{-h,--help}'[display usage information and exit]' diff --git a/Completion/Linux/Command/_ss b/Completion/Linux/Command/_ss index b1bfa207c..2a1cfcb78 100644 --- a/Completion/Linux/Command/_ss +++ b/Completion/Linux/Command/_ss @@ -20,6 +20,7 @@ _arguments -C -s \ "($info -i --info)"{-i,--info}'[show internal TCP information]' \ "($info)--tipcinfo[show internal tipc socket information]" \ "($info -s --summary)"{-s,--summary}'[print summary statistics]' \ + "($info)--tos[show tos and priority information]" \ "($info -b --bpf)"{-b,--bpf}'[show bpf filter socket information]' \ "($info -E --events)"{-E,--events}'[continually display sockets as they are destroyed]' \ "($info -Z --context)"{-Z,--context}'[display process SELinux security contexts]' \ @@ -35,10 +36,12 @@ _arguments -C -s \ "($info -w --raw)"{-w,--raw}'[display RAW sockets]' \ "($info -x --unix)"{-x,--unix}'[display Unix domain sockets]' \ "($info)--tipc[display only TIPC sockets]" \ + "($info)--xdp[display only XDP sockets]" \ "($info)--vsock[display only vsock sockets]" \ - "($info -f --family)"{-f+,--family=}'[display sockets of specified type]:family:(unix inet inet6 link netlink unix vsock tipc)' \ + "($info -f --family)"{-f+,--family=}'[display sockets of specified type]:family:(inet inet6 link unix netlink vsock tipc xdp help)' \ "($info -K --kill)"{-K,--kill}'[forcibly close sockets, display what was closed]' \ "($info -H --no-header)"{-H,--no-header}'[suppress header line]' \ + "($info -O --oneline)"{-O,--oneline}"[print socket's data on a single line]" \ "($info -A --query --socket)"{-A+,--query=,--socket=}'[specify socket tables to show]: :_values -s , socket\ table all inet tcp udp raw unix packet netlink unix_dgram unix_stream unix_seqpacket packet_raw packet_dgram vsock_stream vsock_dgram tipc' \ "($info -D)"{-D+,--diag=}'[dump raw info to file]:file:_files' \ "($info -F)"{-F+,--filter=}'[read filter information from a file]:file:_files' \ diff --git a/Completion/Linux/Command/_sshfs b/Completion/Linux/Command/_sshfs index 6e889cf49..3363ecdc0 100644 --- a/Completion/Linux/Command/_sshfs +++ b/Completion/Linux/Command/_sshfs @@ -12,7 +12,7 @@ _arguments -C -S : \ '-C[enable compression]' \ '-F[specify ssh config file]:file:_files' \ '*-o[specify mount options]:options:->options' \ - '(-f)-d[enable debug output]' \ + '(-d --debug -f)'{-d,--debug}'[enable debug output]' \ '-f[foreground]' \ '-s[disable multithreaded operation]' \ ':remote directory:_user_at_host -S:' \ @@ -20,14 +20,14 @@ _arguments -C -S : \ if [[ $state == options ]]; then _values -s , "sshfs or fuse or mount options" \ - debug reconnect delay_connect sshfs_sync no_readahead sync_readdir sshfs_debug \ - 'cache:cache setting:(yes no)' \ - 'cache_max_size:size [10000]' \ - 'cache_timeout:timeout (seconds) [20]' \ - cache_{stat,dir,link}_timeout:'timeout (seconds)' \ - 'cache_clean_interval:interval [60]' \ - 'cache_min_clean_interval:interval [5]' \ - 'workaround:workaround:(none all rename delaysrv truncate nobuflimit)' \ + reconnect delay_connect sshfs_sync no_readahead sync_readdir \ + 'dir_cache:cache setting:(yes no)' \ + 'dcache_max_size:size [10000]' \ + 'dcache_timeout:timeout (seconds) [20]' \ + dcache_{stat,dir,link}_timeout:'timeout (seconds)' \ + 'dcache_clean_interval:interval [60]' \ + 'dcache_min_clean_interval:interval [5]' \ + 'workaround:workaround:(none all rename renamexdev delaysrv truncate nobuflimit fstat createmode)' \ 'idmap:user/group mapping:(none user file)' \ uidfile:file:_files \ gidfile:file:_files \ diff --git a/Completion/Linux/Command/_strace b/Completion/Linux/Command/_strace index 83ccc6afb..7d4595a33 100644 --- a/Completion/Linux/Command/_strace +++ b/Completion/Linux/Command/_strace @@ -19,15 +19,18 @@ _arguments -C -s \ '(-c)-T[show the time spent in system calls]' \ '(-xx)-x[print all non-ASCII strings in hexadecimal string format]' \ '(-x)-xx[print all strings in hexadecimal string format]' \ + '-X+[set the format for printing of named constants and flags]:format:(raw abbrev verbose)' \ '(-c -yy)-y[print paths associated with file descriptor arguments]' \ '(-c -y)-yy[print protocol specific information associated with socket file descriptors]' \ '(-C -i -k -r -ff -t -tt -ttt -T -y -yy)-c[count time, calls, and errors for each system call and report a summary]' \ '(-c)-C[count time, calls, and errors for each system call and report a summary in addition to regular output]' \ '-O+[overhead for tracing system calls]:overhead (microseconds)' \ - '-S+[sort the output of the histogram (-c option) by the specified criterion]:sort criterion:(time calls name nothing)' \ + '-S+[sort the output of the histogram (-c option) by the specified criterion]:sort criterion [time]:(time calls errors name nothing)' \ '-w[summarise syscall latency]' \ '*-e+[select events to trace or how to trace]:system call:->expressions' \ '*-P+[trace only system calls accessing given path]:path:_files' \ + '(-Z)-z[trace only system calls that return success]' \ + '(-z)-Z[trace only system calls that return an error]' \ '-b+[detach from process on specified syscall]:syscall:(execve)' \ '-f[trace child processes as they are created by currently traced processes]' \ '(-c -C)-ff[write each process trace to <filename>.<pid> (when using -o <filename>]' \ @@ -36,6 +39,7 @@ _arguments -C -s \ '*-E+[set or remove exported environment variable]:variable:->envars' \ "${root}-u+[run as specified user]:user:_users" \ '(:)*-p+[attach to the process with specified process ID and begin tracing]:process ID:_pids' \ + '--seccomp-bpf[enable seccomp-bpf filtering]' \ '-d[show debug output of strace itself on standard error]' \ '-v[print unabbreviated versions of environment, stat, termios, etc. calls]' \ '(- 1 *)-h[display help information]' \ @@ -56,25 +60,44 @@ case $state in 'write[perform a full hex and ASCII dump of all the data written to listed file descriptors]:file descriptor:_sequence _file_descriptors' \ 'fault[perform syscall fault injection]:system call:_sys_calls -a -n' \ 'inject[perform syscall tampering]:system call:_sys_calls -a -n' \ + 'status[trace system calls with given return status]:status:->status' \ 'kvm[print the exit reason of kvm vcpu]: :(vcpu)' && ret=0 - if [[ $words[CURRENT] != *=* || $state = syscalls ]]; then + if [[ $state = status ]]; then + _values -s , 'return status [all]' \ + all successful failed \ + "unfinished[system calls that don't return]" \ + 'unavailable[system calls that return but strace fails to fetch the error]' \ + 'detached[system calls where strace detaches before the return]' && ret=0 + elif [[ $words[CURRENT] != *=* || $state = syscalls ]]; then local dedup sets suf="-qS," compset -P '!' dedup=( ${(Ms.,.)PREFIX##*,} ${(Ms.,.)SUFFIX%%,*} ) compset -S ',*' || suf="" compset -P '*,' - sets=( - 'file:trace all system calls which take a file name as an argument' - 'process:trace all system calls which involve process management' - 'network:trace all the network related system calls' - 'signal:trace all signal related system calls' - 'ipc:trace all IPC related system calls' - 'desc:trace all file descriptor related system calls' - 'memory:trace all memory mapping related system calls' - ) - _alternative \ - "related system call:sets: _describe -t traces 'related system call' sets -F dedup $suf" \ - "system call:syscalls:_sys_calls -a -n $suf -F dedup" && ret=0 + if compset -P /; then + _wanted syscalls expl "system call (regex)" _sys_calls -a -n $suf -F dedup && ret=0 + else + sets=( + {%,}'file:trace all system calls which take a file name as an argument' + {%,}'process:trace all system calls which involve process management' + {%net,{%,}network}':trace all the network related system calls' + {%,}'signal:trace all signal related system calls' + {%,}'ipc:trace all IPC related system calls' + {%,}'desc:trace all file descriptor related system calls' + {%,}'memory:trace all memory mapping related system calls' + '%stat:trace variants of stat' + '%lstat:trace variants of lstat' + '%fstat:trace variants of fstat and fstatat' + '%%stat:trace variants of all syscalls used for requesting file status' + '%statfs:trace variants of statfs' + '%fstatfs:trace variants of fstatfs' + '%%statfs:trace variants of all syscalls used for file system statistics' + '%pure:trace syscalls that always succeed and have no arguments' + ) + _alternative \ + "sets:related system call: _describe -t traces 'related system call' sets -F dedup $suf" \ + "syscalls:system call:_sys_calls -a -n $suf -F dedup" && ret=0 + fi fi ;; file-pipe) diff --git a/Completion/Linux/Command/_tload b/Completion/Linux/Command/_tload new file mode 100644 index 000000000..29fddfc3d --- /dev/null +++ b/Completion/Linux/Command/_tload @@ -0,0 +1,9 @@ +#compdef tload +# based on procps-ng-3.3.15 + +_arguments -s \ + '(-s --scale)'{-s+,--scale=}'[specify the vertical scale]:number of characters between tics: ' \ + '(-d --delay)'{-d+,--delay=}'[specify the delay between updates]:seconds: ' \ + '(- *)'{-h,--help}'[display help and exit]' \ + '(- *)'{-V,--version}'[display version information and exit]' \ + '1: :_ttys -o' diff --git a/Completion/Linux/Command/_tpconfig b/Completion/Linux/Command/_tpconfig deleted file mode 100644 index 62f216107..000000000 --- a/Completion/Linux/Command/_tpconfig +++ /dev/null @@ -1,24 +0,0 @@ -#compdef tpconfig - -_arguments \ - '--help' \ - '(-D --debug)'{-D,--debug=}':debug level:(1 2 3)' \ - '(-d --device)'{-d,--device=}':mouse device:_files' \ - '--version' \ - '(-i --info)'{-i,--info}'[display current touchpad config]' \ - '(-x --reset)'{-x,--reset}'[perform a software reset on the touchpad]' \ - '(-q --quiet --silent)'{-q,--quiet,--silent}'[suppress verbose output]' \ - '-a::packet mode:(0 1)' \ - '--absolute[set packet mode to absolute]' \ - '--relative[set packet mode to relative]' \ - '-r::reporting rate:(0 1)' \ - '-t::tapping mode:(0 1 2 3)' \ - '-s::sleep mode:(0 1)' \ - '(-2 --two-button)'{-2,--two-button}'[set two-button mode]' \ - '(-3 --three-button)'{-3,--three-button}'[set three-button mode]' \ - '(-c --corner)'{-c,--corner=}'::corner-tap mode:(0 1)' \ - '(-e --edgemode)'{-e,--edgemode=}'::edge motion:(0 1 3)' \ - '-m[display which mouse button is simulated by corner taps]' \ - '--middle-button[make corner taps simulate the middle mouse button]' \ - '--right-button[make corner taps simulate the right mouse button]' \ - '(-z --zthreshold)'{-z,--zthreshold=}'::tap sensitivity:' diff --git a/Completion/Linux/Command/_valgrind b/Completion/Linux/Command/_valgrind index 21b7d88c7..4a710e7f7 100644 --- a/Completion/Linux/Command/_valgrind +++ b/Completion/Linux/Command/_valgrind @@ -39,6 +39,8 @@ common_report_errors=( '--exit-on-first-error=-[exit on the first error]:enable:(yes no)' \ '--error-exitcode=-[exit code to return if errors found]:exit code' \ '--error-markers=-[add lines with begin/end markers before/after]:markers (begin,end)' \ + '(--show-error-list)-s[show detected errors list and suppression counts at exit]' \ + '--show-error-list=-[show detected errors list and suppression counts at exit]:enable [no]:(yes no)' '--keep-debuginfo=-[keep symbols etc for unloaded code]:enable:(yes no)' \ '--show-below-main=-[continue stack traces below main()]:enable [no]:(yes no)' \ '--default-suppression=-[load default suppressions]:enable [yes]:(yes no)' \ @@ -84,6 +86,7 @@ args_addrcheck=( args_drd=( $common_own_malloc $common_read_varinfo + $common_report_errors '--check-stack-var=-[detect data races on stack variables]:enable [no]:(yes no)' '--exclusive-threshold=-[print an error if any mutex or writer lock is held longer than specified time]:time (ms)' '--first-race-only=-[report only the first detected data race]:enable [no]:(yes no)' @@ -111,6 +114,7 @@ args_drd=( args_memcheck=( $args_addrcheck $common_read_varinfo + $common_report_errors ) args_cachegrind=( @@ -125,6 +129,7 @@ args_cachegrind=( args_helgrind=( $common_own_malloc $common_read_varinfo + $common_report_errors '--free-is-write=-[treat heap frees as writes]:enable [no]:(yes no)' '--track-lockorders=-[show lock ordering errors]:enable [yes]:(no yes)' '--history-level=-[specify amount of history to show for data races]:level [full]:(( @@ -186,6 +191,7 @@ args_exp_dhat=( args_exp_sgcheck=( $common_partial + $common_report_errors '--enable-sg-checks=-[enable stack & global array checking]:enable [yes]:(yes no)' ) diff --git a/Completion/Linux/Type/_selinux_contexts b/Completion/Linux/Type/_selinux_contexts new file mode 100644 index 000000000..4c2cf4288 --- /dev/null +++ b/Completion/Linux/Type/_selinux_contexts @@ -0,0 +1,14 @@ +#autoload + +local -a parts suf + +parts=( users roles types ) +while compset -P 1 '*:' && (( $+parts[1] )) ; do + shift parts +done +if (( $+parts[1] )); then + compset -S ':*' || suf=( -S : ) + _selinux_$parts[1] $suf +else + _message -e selinux-ranges 'selinux range' +fi diff --git a/Completion/Linux/Type/_selinux_roles b/Completion/Linux/Type/_selinux_roles new file mode 100644 index 000000000..92b4c36cb --- /dev/null +++ b/Completion/Linux/Type/_selinux_roles @@ -0,0 +1,7 @@ +#autoload + +local -a seroles expl + +seroles=( ${(f)"$(_call_program selinux-roles seinfo --flat -r)"} ) +_description selinux-roles expl "selinux role" +compadd "$@" "$expl[@]" -a seroles diff --git a/Completion/Linux/Type/_selinux_types b/Completion/Linux/Type/_selinux_types new file mode 100644 index 000000000..ef31f45d2 --- /dev/null +++ b/Completion/Linux/Type/_selinux_types @@ -0,0 +1,7 @@ +#autoload + +local -a setypes expl + +setypes=( ${(f)"$(_call_program selinux-types seinfo --flat -t)"} ) +_description selinux-types expl "selinux type" +compadd "$@" "$expl[@]" -a setypes diff --git a/Completion/Linux/Type/_selinux_users b/Completion/Linux/Type/_selinux_users new file mode 100644 index 000000000..f046c92cf --- /dev/null +++ b/Completion/Linux/Type/_selinux_users @@ -0,0 +1,8 @@ +#autoload + +local -a seusers expl + +seusers=( ${(f)"$(_call_program selinux-users seinfo --flat -u)"} ) +(( $#seusers )) || seusers=( guest_u root staff_u sysadm_u system_u unconfined_u user_u ) +_description selinux-users expl "selinux user" +compadd "$@" "$expl[@]" -a seusers diff --git a/Completion/Mandriva/Command/_urpmi b/Completion/Mandriva/Command/_urpmi index 7951e6a9f..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 ;; @@ -176,7 +176,7 @@ _urpmi() { "($help : -)"{--help,-h}"[print usage information]" \ "($help)--allow-force[allow asking user to install packages without dependencies checking and integrity]" \ "($help)--allow-nodeps[allow asking user to install packages without dependencies checking]" \ - "($help)--auto-select[utomatically select packages to upgrade the system]" \ + "($help)--auto-select[automatically select packages to upgrade the system]" \ "($help --env)--bug[output a bug report in given directory]:directory for bug report:_files -/" \ "($help -X)--best-output[automatically select text or X interface]" \ "($help --noclean)--clean[remove rpm from cache before anything else]" \ @@ -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/_rpm b/Completion/Redhat/Command/_rpm index a9306aa6c..e3469245f 100644 --- a/Completion/Redhat/Command/_rpm +++ b/Completion/Redhat/Command/_rpm @@ -1,4 +1,4 @@ -#compdef rpm +#compdef rpm rpmbuild rpmkeys rpmsign rpmspec rpmquery rpmverify # This uses `_arguments' in a state-machine kind of way. These states # have names and before executing the default action for such a state @@ -8,6 +8,8 @@ # these functions. # The states (and possible values for the `<state>' above) are: # +# common +# complete for basic options like --querytags and --showrc # query # complete for `rpm -q' query # verify @@ -19,19 +21,17 @@ # uninstall # complete for `rpm -e' or `rpm --erase' # build_b -# complete for `rpm -bx' (the stage `x' is already completed) +# complete for `rpmbuild -bx' (the stage `x' is already completed) +# build_r +# complete for `rpmbuild -rx' (the stage `x' is already completed) # build_t -# complete for `rpm -tx' (the stage `x' is already completed) -# sigcheck -# complete for `rpm --sigcheck' -# rebuild -# complete for `rpm --rebuild' +# complete for `rpmbuild -tx' (the stage `x' is already completed) +# checksig +# complete for `rpm --checksig' # package # complete a RPM package name # package_file # complete a RPM package file name -# package_or_file -# the previous two together # file_or_package # an absolute path to any file (not a package file) or a package # tags @@ -40,24 +40,34 @@ # complete a capability # relocate # complete a `old=new' pair of paths +# setattrs +# complete for --setperms, --setugids, --setcaps and --restore +# public_keys +# complete for `rpmkeys --import' +# query_specs +# complete for `rpmspec --query' _rpm () { local curcontext="$curcontext" state lstate line nm="$compstate[nmatches]" typeset -A opt_args - local ret=1 - local -a tmp expl commonopts selectopts pathopts + local ret + local -a tmp expl opts commonopts selectopts fileopts pathopts buildopts queryopts commonopts=( '(-v --verbose)--quiet[print as little as possible]' '(--quiet)*'{-v,--verbose}'[verbose output]' - '--rcfile:resource file:_files' - '--ftpproxy:ftp proxy server:_hosts' - '--ftpport:ftp port number' - '--httpproxy:http proxy server:_hosts' - '--httpport:http port number' - {-\?,--help}'[print help information]' - '--version[print version number]' - '--pipe:pipe command:->command' + '--rcfile=:configuration file:_sequence -s \: _files' + '--httpproxy=:http proxy server:_hosts' + '--httpport=:http port number' + '--pipe=[pipes the output of rpm to the specified command]:pipe command:_cmdstring' + \*{-D,--define=}'[define a macro]:macro value' + '*--undefine=[undefine a macro]:macro:->macros' + '--target=[specify target platform]:arch-vendor-os' + '--macros=[read macros from specified files instead of the defaults]:file:_sequence -s \: _files' + '--load=[load a single macro file]:file:_files' + "--noplugins[don't enable any plugins]" + "--nodigest[don't verify package digest(s)]" + "--nosignature[don't verify package signature(s)]" ) # package selection options of which only one can be used @@ -66,10 +76,17 @@ _rpm () { {-f,--file}'[query packages that own specified files]' {-p,--package}'[query uninstalled packages]' {-g,--group}'[query packages in one of specified groups]' - --fileid --hdrid --pkgid --tid --querybynumber + --pkgid --hdrid --tid --querybynumber '--triggeredby' - '--whatprovides:*:provided file:->file_or_package' + '--whatconflicts' '--whatrequires' + '--whatobsoletes' + '--whatprovides' + '--whatrecommends' + '--whatsuggests' + '--whatsupplements' + '--whatenhances' + '--nomanifest' ) sopts=${selectopts%\[*}\ --specfile selectopts=( @@ -78,31 +95,106 @@ _rpm () { '(-a --all)*: :->package-select' ) + fileopts=( + '(-c --configfiles)'{-c,--configfiles}'[configuration files only]' + '(-d --docfiles)'{-d,--docfiles}'[documentation files only]' + '(-L --licensefiles)'{-L,--licensefiles}'[license files only]' + '(-A --artifactfiles)'{-A,--artifactfiles}'[artifact files only]' + '--noghost[exclude ghost files]' + '--noconfig[exclude config files]' + '--noartifact[exclude artifact files]' + ) + pathopts=( - '--root:rpm root directory:_files -/' - '--dbpath:rpm database path:_files -/' + {-r,--root=}'[specify rpm root directory]:directory:_directories' + '--dbpath=[specify rpm database path]:path:_directories' + ) + + buildopts=( + '--rpmfcdebug[debug dependencies generation]' + '--buildroot=[override the build root]:build root directory:_directories' + '--build-in-place[run build in current directory]' + '--clean[remove the build tree after the packages are made]' + "--nobuild[don't execute any stages of the build]" + '--nodeps[do not verify build dependencies]' + '--nodirtokens[generate package header(s) compatible with (legacy) rpm v3 packaging]' + "--noclean[don't execute %clean stage of the build]" + "--noprep[don't execute %prep stage of the build]" + "--nocheck[don't execute %check stage of the build]" + '--rmsource[remove sources when done]' + '--rmspec[remove the spec file when done]' + '--short-circuit[skip straight to specified stage (only for c,i)]' + '*--with=[enable configure option for build]:option' + '*--without=[disable configure option for build]:option' + '--scm=[select the SCM to use with %autosetup]:scm [patch]:(patch gendiff git quilt)' + '*--buildpolicy=[set buildroot policy]:policy:->brp_policies' + '!--sign' + "--nodebuginfo[don't generate debuginfo for this package]" ) - _arguments -C -s \ - "${commonopts[@]}" \ - {-q+,--query}'[query mode]:*:query:->query' \ - '(-V -y --verify)'{-V+,-y+,--verify}'[verify mode]:*:verify:->verify' \ - '--import:*:public key' \ - '(-K --checksig)'{-K,--checksig}'[signature check mode]:*:sigcheck:->sigcheck' \ - '(-i --install)'{-i+,--install}'[install mode]:*:install:->install' \ - '(-U --upgrade)'{-U+,--upgrade}'[upgrade mode]:*:upgrade:->upgrade' \ - '(-F --freshen)'{-F+,--freshen}'[freshen mode]:*:upgrade:->upgrade' \ - '(-e --erase)'{-e+,--erase}'[uninstall mode]:*:uninstall:->uninstall' \ - --{initdb,querytags,showrc} \ - '--rebuilddb:*:rebuild:->rebuild' \ - --{resign,addsign}':*:package:->package_file' \ - '--setperms[set file permissions]:*:package:->setattrs' \ - '--setugids[set file owner/group]:*:package:->setattrs' \ - '-b+[build mode (spec file)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_b' \ - '(-b)-t+[build mode (tar file)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_t' \ - '--rmsource:*:spec file:->spec_files' \ - --{rebuild,recompile}':*:source rpm file:->package_src' \ - '--eval:macro:->macros' && ret=0 + queryopts=( + '--conflicts' + '--obsoletes[list packages obsoleted by package]' + '--provides[list capabilities provided by package]' + '(-R)--requires[list capabilities on which packages depend]' + ) + + case $service in + rpm|rpmkeys) + opts+=( + '--import[import an armored public key]:*: :->public_keys' + {-K,--checksig}'[signature check mode]:*:sigcheck:->checksig' + ) + ;| + rpm|rpmdb) + opts+=( --{init,rebuild}'db:*: :->common' ) + ;| + rpm|rpmsign) + opts+=( + --{add,re}sign'[sign package(s)]:*: :->sign' + '--delsign[delete package signatures]:*: :->sign' + ) + ;| + rpm) + opts+=( + {-q+,--query}'[query mode]:*:query:->query' + {-V+,-y+,--verify}'[verify mode]:*:verify:->verify' + {-i+,--install}'[install mode]:*:install:->install' + {-U+,--upgrade}'[upgrade mode]:*:upgrade:->upgrade' + {-F+,--freshen}'[freshen mode]:*:upgrade:->upgrade' + {-e+,--erase}'[uninstall mode]:*:uninstall:->uninstall' + '--reinstall[reinstall mode]:*:install:->install' + '--setperms[set file permissions]:*:package:->setattrs' + '--setugids[set file owner/group]:*:package:->setattrs' + '--setcaps[set capabilities of files in the given package]:*:package:->setattrs' + '--restore[restore owner, group, permissions and capabilities of files in the given package]:*:package:->setattrs' + ) + ;; + rpmbuild) + [[ -prefix -r ]] && pathopts[1]= + opts+=( $buildopts + '(-r -t)-b+[build mode (spec file)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages s\:build\ source\ package\ only r\:build\ source\ package\ only\ -\ calculate\ build\ requires)):*:build:->build_b' + '(-b -t)-r+[build mode (source package)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages s\:build\ source\ package\ only r\:build\ source\ package\ only\ -\ calculate\ build\ requires)):*:build:->build_b' + '(-b -r)-t+[build mode (tar file)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages s\:build\ source\ package\ only r\:build\ source\ package\ only\ -\ calculate\ build\ requires)):*:build:->build_t' + --{rebuild,recompile}':*:source rpm file:->build_r' + ) + ;; + rpmspec) + opts+=( + {-P,--parse}'[parse spec files]:*: :->spec_files' + {-q,--query}'[query spec files]:*: :->query_specs' + ) + ;; + rpmquery) state=query ;; + rpmverify) state=verify ;; + esac + + [[ -z $state ]] && _arguments -C -s $pathopts $opts $commonopts \ + '(-)'{-\?,--help}'[print help information]' \ + '(-)--usage[print brief usage message]' \ + '(-)--version[print version number]' \ + \*{-E,--eval=}'[print macro expansion of given expression]:expression:->tags' \ + --{querytags,showrc}':*: :->common' # As long as we have a state name... @@ -121,84 +213,92 @@ _rpm () { # Dispatch... case "$lstate" in + common) + _arguments -s -C $commonopts + ;; query) # --dump requires one of -{l,c,d} # --triggers requires --script _arguments -s -C \ - \!{-q,--query} "${commonopts[@]}" "${selectopts[@]}" "${pathopts[@]}" \ - "($sopts)--specfile[query specified spec file as if it were a package]" \ - '(-i --info)'{-i,--info}'[display package information]' \ - '--changelog[display change log]' \ - '(-s --state -l --list --filesbypkg)'{-l,--list}'[display package file list]' \ - '(-s --state -l --list --filesbypkg)'{-s,--state}'[show file states]' \ - '(-s --state -l --list)--filesbypkg[list files with package names]' \ - {-d,--docfiles}'[documentation files only]' \ - {-c,--configfiles}'[configuration files only]' \ - '--dump[show all information]' \ - '--provides[show capabilities provided]' \ - \*--{qf,queryformat}'[specify format for package information]:rpm query format:->tags' \ - -{R,-requires}'[list dependencies]' \ - '--scripts[show (un)install scripts]' \ - {--triggers,--triggerscripts}'[show trigger scripts]' && ret=0 + \!{-q,--query} $commonopts $selectopts $fileopts $pathopts $queryopts \ + '--dump[dump basic file information]' \ + \*--{qf,queryformat}'[specify format for package information]:rpm query format:->tags' \ + "($sopts)--specfile[query specified spec file as if it were a package]" \ + '(-i --info)'{-i,--info}'[display package information]' \ + '--changelog' '--changes' '--dupes' \ + '--last[order packages by install time]' \ + '--xml' \ + '--recommends[list capabilities recommended by packages]' \ + '(--requires)-R[list capabilities on which packages depend]' \ + '--suggests[list capabilities suggested by packages]' \ + '--supplements[list capabilities supplemented by packages]' \ + '(-s --state -l --list --filesbypkg)'{-l,--list}'[list files in package]' \ + '(-s --state -l --list)'{-s,--state}'[show file states]' \ + '--fileclass' '--filecolor' '--fileprovide' '--filerequire' \ + '--filecaps' '--filesbypkg[list files with package names]' \ + '--filetriggers[list filetrigger scriptlets]' \ + '--scripts[show (un)install scripts]' \ + {--triggers,--triggerscripts}'[show trigger scripts]' ;; + query_specs) + _arguments -s -C \ + \!{-q,--query} $commonopts $pathopts $queryopts \ + --buildconflicts --buildrequires --trace \ + '*:spec file:->spec_files' + ;; setattrs) - _arguments -s -C --set{perm,ugids} "${selectopts[@]}" && ret=0 + _arguments -s -C '!--set{perm,ugids,caps}' '!--restore' $selectopts ;; verify) - _arguments -s -C \!-{y,V} \ - "${commonopts[@]}" "${selectopts[@]}" "${pathopts[@]}" \ - --no{deps,files,scripts,digest,signature,linkto,md5,size,user,group,mtime,mode,rdev} && ret=0 + _arguments -s -C \ + \!{-V,--verify} $commonopts $selectopts $fileopts $pathopts \ + --no{deps,digest,files,scripts,signature,linkto,filedigest,size,user,group,mtime,mode,rdev,caps} ;; upgrade) tmp=( '(--force)--oldpackage' ) ;& install) - _arguments -s -C \!-{i,U} "$tmp[@]" \ - "${commonopts[@]}" "${pathopts[@]}" \ - '--excludepath:file to exclude:_files -/' \ + _arguments -s -C \!{-i,--install,-U,--upgrade,-F,--freshen} $tmp \ + $commonopts $pathopts \ + '--excludepath=:file to exclude:_files -/' \ '--relocate:relocate:->relocate' \ - '--prefix:package prefix directory:_files -/' \ - '(-h --hash)'{-h,--hash} \ + '--prefix=[relocate the package]:package prefix directory:_files -/' \ + '(-h --hash)'{-h,--hash}'[print hash marks as package installs]' \ '(--replacepkgs --replacefiles --oldpackage)--force' \ '(--force)--'{replacefiles,replacepkgs} \ - --{aid,allfiles,badreloc,excludedocs,ignorearch,ignoreos,ignoresize,includedocs,justdb,percent,repackage,test} \ - --no{digest,signature,deps,suggest,order,pre,post,preun,postun,trigger{s,in,un,postun}} \ + --{aid,allfiles,badreloc,excludedocs,ignorearch,ignoreos,ignoresize,includedocs,justdb,percent,test} \ + --no{deps,filedigest,contexts,caps,order,suggest,pre,post,preun,postun,trigger{s,in,un,postun}} \ '(--nopre --nopost --nopreun --nopostun)--noscripts' \ - '*:pkg file:->package_file' && ret=0 + '*:pkg file:->package_file' ;; uninstall) - _arguments -s -C \!-e \ + _arguments -s -C \!{-e,--erase} \ "${commonopts[@]}" "${pathopts[@]}" \ --{allmatches,justdb,repackage,test} \ --no{deps,scripts,preun,postun,trigger{s,un,postun}} \ - '*:package:->package' && ret=0 + '*:package:->package' ;; - build_b) - tmp=( '*:spec file:_files -g "*.spec(-.)"' ) - ;& - build_t) - (( $#tmp )) || tmp=( '*:tar file:_files -g "*.(#i)tar(.*|)(-.)"' ) - - _arguments -s -C \ - "${commonopts[@]}" "${pathopts[@]}" \ - --{short-circuit,clean,nobuild,rmsource,sign,test} \ - '--target:specify a build target:->target'\ - '--buildroot:build root directory:_files -/' \ - '--buildarch:architecture for which to build:->target' \ - '--buildos:operating system for which to build:' \ - '--timecheck:time check (seconds):' "$tmp[1]" && ret=0 + build_b) tmp=( '*:spec file:_files -g "*.spec(-.)"' ) ;| + build_r) tmp=( '*:source package:_files -g "*.(#i)src.rpm(-.)"' ) ;| + build_t) tmp=( '*:tar file:_files -g "*.(#i)tar(.*|)(-.)"' ) ;| + build_?) + _arguments -s -C $buildopts $commonopts $pathopts \ ;; - sigcheck) + checksig) _arguments -s -C \!-K \ "${commonopts[@]}" \ - --no{gpg,pgp,md5,signature,digest} \ - '*:package file:->package_file' && ret=0 - ;; - rebuild) - _arguments -s -C \ - "${commonopts[@]}" "${pathopts[@]}" \ - '*:source package file:->package_file' && ret=0 + --no{gpg,pgp,md5,digest} \ + '*:package file:->package_file' ;; + sign) + _arguments -s -C $commonopts $pathopts \ + '--signfiles[sign package(s) files]' \ + '--fskpath=[use file signing key]:key:_files' \ + '--fskpass[prompt for file signing key password]' \ + '--key-id=[specify key id/name to sign with]:key id' \ + '--digest-algo=[override default digest algorithm]:algorithm:(sha1 sha256 sha384 sha512)' \ + '*:package file:_files -g "*.(#i)rpm(-.)"' + ;; package-select) case "${opt_args[(i)${sopts// /|}]}" in -f|--file) _files ;; @@ -207,6 +307,7 @@ _rpm () { --fileid|--pkgid) _message -e md5 md5 ;; --hdrid) _message -e sha1 sha1 ;; --querybynumber) _message -e value number ;; + --tid) _message -e ids 'transaction id' ;; --what*) state=capabilities ;; --specfile) state=spec_files ;; *) state=package ;; @@ -214,24 +315,18 @@ _rpm () { ;; macros) local -a macros - local mfile - for mfile in {/usr/lib/rpm/{,redhat/}macros,/etc/rpm/macros,~/.rpmmacros}(N); do - macros+=( ${${(M)${(f)"$(<$mfile)"}:#%[^\{]*}%%[[:blank:]]*} ) - done + macros=( ${${${(M)${(f)"$(_call_program macros rpm --showrc)"}:#(-|)[0-9]##[:=] ##*}#* }%%[[:blank:](]*} ) + _description macros expl macro if zstyle -t ":completion:${curcontext}:macros" prefix-hidden; then - macros=( ${macros#%} ) - _wanted macros expl macro compadd -p '%' -a - macros + compadd "$expl[@]" -p '%' -a - macros else - _wanted macros expl macro compadd -a - macros + macros=( %${^macros} ) + compadd "$expl[@]" -a - macros fi - ;; - command) - compset -q - _normal - ;; + ;; target) _wanted targets expl 'target platform' compadd \ - ${${(M)${(f)"$(_call_programs targets rpm --showrc)"}:#compatible archs*}##*: } && ret=0 + ${${(M)${(f)"$(_call_programs targets rpm --showrc)"}:#compatible archs*}##*: } ;; groups) if ( (( ! $+_rpm_groups )) || _cache_invalid rpm-groups ) && @@ -243,11 +338,8 @@ _rpm () { ) _store_cache RPM-groups _rpm_groups fi - _wanted groups expl 'group' _multi_parts / _rpm_groups && ret=0 + _wanted groups expl 'group' _multi_parts / _rpm_groups ;; - package_or_file) - state=package_file - ;; file_or_package) if [[ $PREFIX = /* ]]; then _wanted files expl 'file' _files @@ -259,43 +351,57 @@ _rpm () { if ( [[ ${+_rpms} -eq 0 ]] || _cache_invalid RPMs ) && ! _retrieve_cache RPMs; then - _rpms=( $(_call_program packages rpm -qa 2>/dev/null) ) + _rpms=( $(_call_program packages rpm -qa) ) _store_cache RPMs _rpms fi _wanted packages expl 'package' \ - compadd -M 'r:|-=* r:|=*' - "$_rpms[@]" && ret=0 + compadd -M 'r:|-=* r:|=*' - "$_rpms[@]" ;; spec_files) _wanted specfiles expl 'spec file' \ - _files -g '*.spec(-.)' && ret=0 + _files -g '*.spec(-.)' ;; package_file) _wanted files expl 'package file' \ - _files -g '*.(#i)rpm(-.)' && ret=0 + _files -g '*.(#i)rpm(-.)' if [[ -prefix 1 (f|ht)tp:// ]]; then _wanted urls expl 'URL of rpm package file' \ - _urls -f -g '*.(#i)rpm(-.)' "${expl[@]}" && ret=0 + _urls -f -g '*.(#i)rpm(-.)' "${expl[@]}" else _wanted urls expl 'URL of rpm package file' \ - compadd -S '' "${expl[@]}" ftp:// http:// && ret=0 + compadd -S '' "${expl[@]}" ftp:// http:// fi ;; package_src) - _files -g '(#i)*.src.rpm(-.)' && ret=0 + _wanted files expl 'source package' _files -g '(#i)*.src.rpm(-.)' ;; tags) local -a suf if compset -P "*%*${${QIPREFIX:+{}:-\{}"; then - compset -S '(|\\)}*' || suf=( -qS ${${QIPREFIX:+\}}:-\\\}} ) - _wanted tags expl 'rpm tag' compadd -M 'm:{a-z}={A-Z}' "$suf[@]" - \ - "${(L@)${(@f)$(_call_program tags rpm --querytags 2>/dev/null)}#RPMTAG_}" && ret=0 + compset -S '(|\\)}*' || suf=( -S ${${QIPREFIX:+\}}:-\\\}} -r ": \}\t\n\-" ) + if compset -P '*:'; then + _wanted formats expl format compadd $suf - \ + armor arraysize base64 date day depflags deptype expand \ + fflags fstate fstatus hex octal humaniec humansi perms \ + pgpsig shescape triggertype vflags xml + else + _wanted tags expl 'rpm tag' compadd -M 'm:{a-z}={A-Z}' "$suf[@]" - \ + "${(L@)${(@f)$(_call_program tags rpm --querytags)}#RPMTAG_}" + fi else - _message -e formats 'rpm query format' + _message -e formats 'rpm query format' fi ;; capabilities) - _wanted capabilities expl capability compadd \ - ${(f)"$(_call_program capabilities rpm -qa --queryformat '%\{requirename}\\n' 2>/dev/null)"} && ret=0 + local match mbegin mend + if [[ "${opt_args[(i)${sopts// /|}]}" = --what(#b)(*) ]]; then + if [[ $match[1] = provides && -prefix / ]]; then + _wanted files expl file _files + else + _description capabilities expl capability + compadd ${${(f)"$(_call_program capabilities rpm -qa --queryformat '%\{$match[1]}\\n')"}:#\(none\)} + fi + fi ;; relocate) if compset -P 1 '*='; then @@ -304,11 +410,19 @@ _rpm () { _description directories expl 'old path' fi - _files "$expl[@]" -/ && ret=0 + _files "$expl[@]" -/ ;; + public_keys) + _arguments -s -C \!--import $commonopts \ + '*:public key:_files' + ;; + brp_policies) + local rpmconfigdir=$(_call_program policies rpm -E '%\{_rpmconfigdir\}') + _wanted policies expl policy compadd $rpmconfigdir/brp-*(N:t:s/brp-//) + ;; esac - [[ ret -eq 0 || $nm -ne $compstate[nmatches] ]] && return 0 + [[ $nm -ne $compstate[nmatches] ]] && return 0 done return ret diff --git a/Completion/Redhat/Command/_yum b/Completion/Redhat/Command/_yum index 34a337109..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]' \ @@ -212,7 +212,7 @@ _yum_ids() { # `${(@)@[...]}' selects a subrange from $@ # `${(@)@[1,-2]}' are all except the last argument # `$@[$#]' is the last argument, e.g. the first suggestable ID - compadd "${(@)@[1,-2]:/-J/-V}" -M "B:0=" {$@[$#]..$maxid} + compadd "${(@)@[1,-2]}" -o numeric -M "B:0=" {$@[$#]..$maxid} } _yum_ranges() { diff --git a/Completion/Solaris/Command/_dladm b/Completion/Solaris/Command/_dladm index cb598de03..5ce9872d2 100644 --- a/Completion/Solaris/Command/_dladm +++ b/Completion/Solaris/Command/_dladm @@ -288,7 +288,7 @@ _dladm() { _arguments -A "-*" \ '(-t --temporary)'{-t,--temporary}'[aggregation should be temporary]' \ '(-R --root)'{-R,--root}'[root directory]:directory:_path_files -/' \ - '(-l --link)'{-l,--link}'[component link]:link:_dladm_links' \ + \*{-l,--link}'[component link]:link:_dladm_links' \ '(-m --mode)'{-m,--mode}'[aggregation mode]:mode:(dlmp trunk)' \ '(-P --policy)'{-P,--policy}'[port selection policy]:policy:_values -s , "policy" L2 L3 L4' \ '(-L --lacp-mode)'{-L,--lacp-mode}'[LACP mode]:lacp mode:(off active passive)' \ diff --git a/Completion/Solaris/Command/_svccfg b/Completion/Solaris/Command/_svccfg index 360fc2091..00dad366d 100644 --- a/Completion/Solaris/Command/_svccfg +++ b/Completion/Solaris/Command/_svccfg @@ -1,103 +1,131 @@ #compdef svccfg -_svccfg_properties() { - local -a props fmris - local fmri="$argv[$#]" - - # If There's more than one possible FMRI, bail - fmris=( ${(f)"$(svcs -H -o fmri $fmri)"} ) - if [[ $#fmris -gt 1 ]]; then - _message "'$fmri' is ambiguous" - return 1 - fi - - # Get all the property names for the FMRI - props=( ${${${(f)"$(svccfg -s $fmri describe)"}:# *}%% *} ) - - _multi_parts "$@" - / props -} - -_svccfg() { - local context state line subcmds - typeset -A opt_args - - # Subcommands that don't make sense on the commandline are missing - subcmds=( - apply export extract import inventory validate - add delete list - addpg addpropvalue delcust delpg delprop delpropvalue describe - editprop listpg listprop listcust setenv setprop unsetenv - setnotify listnotify delnotify - listsnap revert selectsnap - refresh - ) - - if [[ $service == "svccfg" ]]; then - _arguments -s \ - '-?[help]' \ - '-v[verbose]' \ - '-s[FMRI on which to operate]:fmri:_svcs_fmri -c' \ - - set1 \ - '-f[read commands from file]:command file:_files' \ - - set2 \ - '*::command:->subcmd' && return 0 - - if (( CURRENT == 1 )); then - _wanted commands expl 'svccfg subcommand' compadd -a subcmds - return - fi - service="$words[1]" - curcontext="${curcontext%:*}=$service:" - fi - - case $service in - (import) - _arguments \ - '-V[verify property updates]' \ - ':file:_files' - ;; - - (apply|inventory) - _files - ;; - - (validate) - _alternative 'files:file:_files' 'fmris:fmri:_svcs_fmri -c' - ;; - - (export) - _svcs_fmri -c - ;; - - (delete) - _arguments \ - '-f[force deletion if online or degraded]' \ - '*:FMRI:_svcs_fmri -c' - ;; - - (describe) - local fmri=$opt_args[-s] - _arguments -A "-*" \ - '-v[give all information]' \ - '-t[show only template data]' \ - ":property group or property:_svccfg_properties $fmri" - ;; - - (extract|add|delete|list|addpg|addpropvalue|delcust|delpg|delprop) - ;; - - (delpropvalue|editprop|listpg|listprop|listcust|setenv|setprop|unsetenv) - ;; - - (setnotify|listnotify|delnotify|listsnap|revert|selectsnap|refresh) - ;; - - (*) - _message "unknown svccfg subcommand: $service" - ;; - esac -} - -_svccfg "$@" - -# vi:tw=0 +local curcontext="$curcontext" ret=1 +local -a state line expl subcmds args +local -A opt_args + +# Subcommands that don't make sense on the commandline are missing +subcmds=( + apply export extract import inventory validate + add delete list + addpg addpropvalue delcust delpg delprop delpropvalue describe + editprop listpg listprop listcust setenv setprop unsetenv + setnotify listnotify delnotify + listsnap revert selectsnap + refresh + help +) + +_arguments -s -A "-*" \ + '-v[verbose]' \ + '-s+[specify fmri on which to operate]:fmri:_svcs_fmri -c' \ + '(1 *)-f+[read commands from file]:command file:_files' \ + '1: :->subcmds' \ + '*:: :->args' && ret=0 + +case $state in + subcmds) + _wanted commands expl 'svccfg subcommand' compadd -a subcmds && ret=0 + ;; + args) + curcontext="${curcontext%:*}-$words[1]:" + + case $words[1] in + import) + _arguments \ + '-V[verify property updates]' \ + ':file:_files' + ;; + + apply|inventory) _files ;; + + validate) + _alternative 'files:file:_files' 'fmris:fmri:_svcs_fmri -c' + ;; + + export) _svcs_fmri -c ;; + + delete) + _arguments \ + '-f[force deletion if online or degraded]' \ + '*:fmri:_svcs_fmri -c' + ;; + + describe) + local fmri=$opt_args[-s] + _arguments -A "-*" \ + '-v[give all information]' \ + '-t[show only template data]' \ + ':property group or property:->properties' + + if [[ -n $state ]]; then + fmris=( ${(f)"$(_call_program properties svcs -H -o fmri $fmri)"} ) + if (( $#fmris > 1 )); then + _message "'$fmri' is ambiguous" + return 1 + fi + + # Get all the property names for the FMRI + props=( ${${${(f)"$(_call_program properties svccfg -s $fmri describe)"}:# *}%% *} ) + + _multi_parts "$@" - / props && ret=0 + fi + ;; + + extract|add|delete|list|addpg|addpropvalue|delcust|delpg|delprop) + ;; + + delpropvalue|editprop|listpg|listcust|setenv|setprop|unsetenv) + ;; + + listprop) + _arguments \ + '-l+[print the layer the value came from]:layer:(manifest system-profile enterprise-profile site-profile node-profile sysconfig-profile admin current all)' \ + '(-o)-f[print the file a property came from]' \ + '(-f)-o+[select fields to print]:field:_sequence compadd - propname pgname instname servicename layer proptype value file masked time' \ + '*-G+[specify property group]:property group' \ + '-P+[specify property name]:property name' && ret=0 + ;; + + setnotify) + args=( '2:notification parameter:->parameters' ) + ;& + listnotify|delnotify|selectsnap) + _arguments $args \ + '-g[apply to notification parameters in svc:/system/svc/global:default]' \ + '1: :->tsets-classes' + + case $state in + tsets-classes) + local states=( uninitialized offline online degraded maintenance disabled ) + _alternative \ + 'state-transitions:state transition:_sequence compadd - all {to-,from-,}$^states' \ + 'event-classes:event class:_sequence compadd - problem-{diagnosed,updated,repaired,resolved}' && ret=0 + ;; + parameters) + if compset -P 'mailto:'; then + _email_addresses -c && ret=0 + elif compset -P 'snmp:'; then + _wanted values expl value compadd active inactive && ret=9 + else + _wanted uri-formats expl 'URI format' compadd -S: mailto snmp && ret=0 + fi + ;; + esac + ;; + + revert) + _wanted snapshots expl snapshot compadd initial previous running start && ret=0 + ;; + + refresh|listsnap) + _message 'no more arguments' + ;; + *) # fallback to default completion for unknown subcommands + _default && ret=0 + ;; + esac + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_abcde b/Completion/Unix/Command/_abcde new file mode 100644 index 000000000..361b43091 --- /dev/null +++ b/Completion/Unix/Command/_abcde @@ -0,0 +1,50 @@ +#compdef abcde + +(( $+functions[_abcde_fields] )) || +_abcde_fields(){ + _values -s , field year genre +} + +(( $+functions[_abcde_actions] )) || +_abcde_actions(){ + _values -s , action cddb cue read getalbumart embedalbumart normalize encode tag move replaygain playlist clean +} + +_arguments -s \ + '(-t -T -p)-1[encode the whole CD in a single file]' \ + '-a[comma-delimited list of actions to perform]:action:_abcde_actions' \ + '-b[enable batch mode normalization]' \ + '-B[enable automatic embedding of album art with certain containers]' \ + '-c[specify an additional configuration file to parse]:config:_files' \ + '-C[resume a session for discid when you no longer have the CD available]:discid' \ + '-d[CD-ROM block device that contains audio tracks to be read]:cd-rom-file:_files' \ + '-D[capture debugging information]' \ + '-e[erase information about encoded tracks from the internal status file]' \ + '-f[force the removal of the temporary ABCDETEMPDIR directory]' \ + "-g[enable lame's --nogap option]" \ + '-G[download album art using the getalbumart function]' \ + '(- :)-h[get help information]' \ + '-j[start a specified number of encoder processes at once]:number' \ + '-k[keep the wav files after encoding]' \ + '-l[use the low-diskspace algorithm]' \ + '-L[use a local CDDB repository]' \ + '-m[create DOS-style playlists, modifying the resulting one by adding CRLF line endings those to work]' \ + "-n[don't query CDDB database]" \ + '-N[non interactive mode]' \ + '-o[select output type]:outputtype:(vorbis ogg mp3 flac spx mpc m4a wav wv ape opus mka aiff)' \ + "-p[pads track numbers with 0's]" \ + '-P[use Unix PIPES to read and encode in one step]' \ + '-r[remote encode on this comma-delimited list of machines using distmp3]:hosts:_sequence _hosts' \ + '-s[fields to be shown in the CDDB parsed entries]:field:_abcde_fields' \ + '-S[set the speed of the CD drive]:speed' \ + '-t[start the numbering of the tracks at a given number]:track-number' \ + '-T[start the numbering of the tracks at a given number and change internal tag numbering]:track-number' \ + '-U[set CDDBPROTO to version 5]' \ + '(- :)-v[show the version and exit]' \ + '-V[be more verbose]' \ + '-x[eject the CD when all tracks have been read]' \ + '-X[use an alternative "cue2discid" implementation]:cue2discid' \ + '-w[add a comment to the tracks ripped from the CD]:comment' \ + "-W[concatenate CD's]:cd-number" \ + '-z[debug mode]' \ + '*:tracks:' diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index 89a4998b7..f1e13a813 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -1,10 +1,14 @@ -#compdef ansible ansible-config ansible-console ansible-doc ansible-galaxy ansible-inventory ansible-playbook ansible-pull ansible-vault +#compdef ansible ansible-config ansible-console ansible-doc ansible-galaxy ansible-inventory ansible-playbook ansible-pull ansible-vault -value-,ANSIBLE_STDOUT_CALLBACK,-default- local curcontext="$curcontext" plug plugvar ign ret=1 local -a args state line local -A opt_args case $service in + *,ANSIBLE_STDOUT_CALLBACK,*) + plug=callback + state=plugins + ;; ansible|ansible-console|ansible-doc|ansible-playbook) args=( \*{-M+,--module-path=}'[specify path to modules]:module path:_dir_list' @@ -30,7 +34,7 @@ case $service in '(-D --diff)'{-D,--diff}'[show differences when changing small files and templates]' '(-b --become)'{-b,--become}'[escalate privileges on remote system]' '(-f --forks)'{-f+,--forks=}'[specify number of parallel processes to use]:processes [5]' - '--become-method=[specify privilege escalation method to use]:method [sudo]:(sudo su pbrun pfexec doas dzdo ksu runas pmrun enable machinectl)' + '--become-method=[specify privilege escalation method to use]:method [sudo]:(sesu sudo su pbrun pfexec doas dzdo ksu runas pmrun enable machinectl)' '--become-user=[specify remote user for running operations]:user:_users' "--syntax-check[perform a syntax check on the playbook, but don't execute it]" '!(-R --su-user -U --sudo-user)'{-R,-U,--su-user,--sudo-user}':user [root]:_users' @@ -45,7 +49,7 @@ case $service in ;| ansible|ansible-console|ansible-inventory|ansible-playbook|ansible-pull) args+=( - '(-i --inventory)'{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files" + \*{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files" "hosts\:host\: _sequence _hosts"' '!(-i --inventory)--inventory-file=:inventory file:_files' ) @@ -106,7 +110,7 @@ case $service in '(-l --list -F --list_files -s --snippet)'{-l,--list}'[list available plugins]' '(-l --list -F --list_files -s --snippet)'{-F,--list_files}'[show plugin names and their source files without summaries]' '(-l --list -F --list_files -s --snippet)'{-s,--snippet}'[show playbook snippet for specified plugins]' - '(-t --type)'{-t+,--type=}'[choose plugin type]:plugin type [module]:(cache callback connection inventory lookup module strategy vars)' + '(-t --type)'{-t+,--type=}'[choose plugin type]:plugin type [module]:(become cache callback cliconf connection httpapi inventory lookup shell module strategy vars)' '*:plugin:->plugins' ) ;; @@ -115,9 +119,11 @@ case $service in '--export[when doing an --list, represent in a way that is optimized for export]' '(-y --yaml)--graph[output inventory graph]' '--host[output specific host information]' + '--output=[with --list, specify output file]:file:_files' '--list[output all hosts information]' + '(-y --yaml --vars --graph)--toml[use TOML format instead of JSON]' '(-y --yaml)--vars[add variables to the graph display]' - '(-y --yaml --vars --graph)'{-y,--yaml}'[use YAML format instead of JSON]' + '(-y --yaml --toml --vars --graph)'{-y,--yaml}'[use YAML format instead of JSON]' ) ;; ansible-galaxy) @@ -162,6 +168,7 @@ case $service in ;; ansible-vault) args=( -A "-*" $args + '::action:(create decrypt edit encrypt encrypt_string rekey view)' '--new-vault-id=[specify new vault identity to use for rekey]:vault id' '--new-vault-password-file=[specify new vault password file to use for rekey]:file:_files' '*::args:->vault' @@ -170,12 +177,15 @@ case $service in esac (( $#words > 2 )) && ign='!' -_arguments -s -S -C $args \ - "${ign}(- :)--version[display version information]" \ - "${ign}(- :)"{-h,--help}'[display usage information]' \ - \*{-v,--verbose}"[verbose mode (repeat to increase)]" && ret=0 +if (( $#args )); then + _arguments -s -S -C $args \ + "${ign}(- :)--version[display version information, config and module locations]" \ + "${ign}(- :)"{-h,--help}'[display usage information]' \ + \*{-v,--verbose}"[verbose mode (repeat to increase)]" && ret=0 + + plug=${(v)opt_args[(i)-(t|-type)]:-module} +fi -plug=${(v)opt_args[(i)-(t|-type)]:-module} case $state in args) case ${(v)opt_args[(I)-(m|module)]} in @@ -265,6 +275,7 @@ case $state in ;; install) args+=( + "--force-with-deps[force overwriting an existing role and it's dependencies]" '(-n --no-deps)'{-n,--no-deps}"[don’t download roles listed as dependencies]" '(-i --ignore-errors)'{-i,--ignore-errors}'[ignore errors and continue with the next specified role]' '(-g --keep-scm-meta)'{-g,--keep-scm-meta}'[use tar instead of the scm archive option when packaging the role]' @@ -303,6 +314,9 @@ case $state in '(-n --name)'{-n+,--name=}'[specify the variable name]:variable' '--stdin-name=[specify the variable name for stdin]:variable' ) + ;| + create|edit|rekey|view) args+=( ':file:_files' ) ;| + (en|de)crypt) args+=( '::file:_files' ) ;; esac _arguments -s -S $args && ret=0 diff --git a/Completion/Unix/Command/_arp b/Completion/Unix/Command/_arp index 90e30d6c2..389f1099b 100644 --- a/Completion/Unix/Command/_arp +++ b/Completion/Unix/Command/_arp @@ -38,8 +38,6 @@ case $OSTYPE in ;; darwin*|freebsd*|dragonfly*) cmds+=( '(-n -i)-S[create an arp entry, replacing any existing entry]' ) - ;| - darwin*|freebsd*) args+=( '(-s -Q -f)-i+[select an interface]:interface:_net_interfaces' ) ;| darwin*) diff --git a/Completion/Unix/Command/_arping b/Completion/Unix/Command/_arping index 66ce7bc18..4974a408a 100644 --- a/Completion/Unix/Command/_arping +++ b/Completion/Unix/Command/_arping @@ -12,6 +12,7 @@ _arguments -s \ '-V[print version and exit]' \ '-c[how many packets to send]:count' \ '-w[how long to wait for a reply]:timeout' \ + '-i[specify interval between packets]:interval (seconds)' \ '-I[interface]:ethernet interface:_net_interfaces' \ '-s[source ip address]:source IP address:_hosts' \ ':destination:_hosts' 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/_avahi b/Completion/Unix/Command/_avahi new file mode 100644 index 000000000..562ec3647 --- /dev/null +++ b/Completion/Unix/Command/_avahi @@ -0,0 +1,52 @@ +#compdef avahi-browse avahi-browse-domains avahi-resolve avahi-resolve-address avahi-resolve-host-name + +local curcontext="$curcontext" pri ret=1 +local -A opt_args +local -a state line args serv desc disp + +args=( + '(- 1)'{-h,--help}'[display usage information]' + '(- 1)'{-V,--version}'[display version information]' + '(-v --verbose)'{-v,--verbose}'[enable verbose mode]' +) + +case $service in + *-browse*) + serv=( ${(f)"$(_call_program service-types avahi-browse -bk)"} ) + desc=( ${(f)"$(_call_program service-types-description avahi-browse -b)"} ) + (( $#desc )) && print -v disp -f '%s:%s' ${serv:^desc} + + _arguments -s -S -C $args \ + '(-D --browse-domains -a --all -b --dump-db)'{-D,--browse-domains}'[browse for browsing domains instead of services]' \ + '(-D --browse-domains -a --all -b --dump-db)'{-a,--all}'[show all services, regardless of the type]' \ + '(-d --domain)'{-d+,--domain=}'[specify domain to browse in]:domain' \ + '(-t --terminate)'{-t,--terminate}'[terminate after dumping a more or less complete list]' \ + '(-c --cache)'{-c,--cache}'[terminate after dumping all entries from the cache]' \ + '(-l --ignore-local)'{-l,--ignore-local}'[ignore local services]' \ + '(-r --resolve)'{-r,--resolve}'[resolve services found]' \ + '(-f --no-fail)'{-f,--no-fail}"[don't fail if the daemon is not available]" \ + '(-p --parsable)'{-p,--parsable}'[output in parsable format]' \ + '(-k --no-db-lookup)'{-k,--no-db-lookup}"[don't lookup service types]" \ + '(-D --browse-domains -a --all -b --dump-db)'{-b,--dump-db}'[dump service type database]' \ + '1: :->service-types' && ret=0 + + [[ -n $state ]] && _describe -t services "service type" disp && ret=0 + ;; + *-resolve*) + if (( ${words[(I)(-n|--name)]} )) || [[ $service = *-host-name ]]; then + args=( '*:host:_hosts' ) + pri=1 + fi + if (( ${words[(I)(-a|--address)]} )) || [[ $service = *-address && -n $pri ]]; then + args=( '*: :_guard "^-*" address' ) + fi + + _arguments -s -S $args \ + '(-a --address -n --name -h --help -V --version)'{-a,--address}'[resolve address]' \ + '(-a --address -n --name -h --help -V --version)'{-n,--name}'[resolve host name]' \ + '(-4)-6[lookup IPv6 address]' \ + '(-6)-4[lookup IPv4 address]' && ret=0 + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_awk b/Completion/Unix/Command/_awk index b23ecdf9d..dcb2a6c21 100644 --- a/Completion/Unix/Command/_awk +++ b/Completion/Unix/Command/_awk @@ -33,7 +33,7 @@ case $variant in {-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 things that are actually invalid"))' + {-L-,--lint=-}'[warn about dubious or non-portable constructs]::flag:((fatal\:"treat warnings as fatal error" invalid\:"warn only about things that are actually invalid" no-ext\:"disable warnings about gawk extensions"))' {-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]' diff --git a/Completion/Unix/Command/_bash b/Completion/Unix/Command/_bash index cc219f788..383b369cb 100644 --- a/Completion/Unix/Command/_bash +++ b/Completion/Unix/Command/_bash @@ -22,6 +22,7 @@ args=( '--noprofile[do not load /etc/profile, ~/.bash_profile, etc.]' '--norc[do not load ~/.bashrc]' '--posix[enable POSIX mode]' + '--pretty-print[format a shell script]' '(-r --restricted)--restricted[act as restricted shell]' '(: -)--version[display version information]' # This is ugly, but this way the + variants have accurate descriptions. Note diff --git a/Completion/Unix/Command/_cat b/Completion/Unix/Command/_cat index c78dc4cd9..74d7278b8 100644 --- a/Completion/Unix/Command/_cat +++ b/Completion/Unix/Command/_cat @@ -51,7 +51,7 @@ elif [[ $OSTYPE = solaris* ]]; then '*: :_files' ) else - # POSIX reqires '-u', and most OSes may support '-n' + # POSIX requires '-u', and most OSes may support '-n' args=( '-n[number all output lines]' '-u[do not buffer output]' diff --git a/Completion/Unix/Command/_chmod b/Completion/Unix/Command/_chmod index af64b9eb9..3f6db7e91 100644 --- a/Completion/Unix/Command/_chmod +++ b/Completion/Unix/Command/_chmod @@ -1,54 +1,70 @@ -#compdef chmod gchmod +#compdef chmod gchmod zf_chmod -local curcontext="$curcontext" state line expl ret=1 -local -a args privs +local curcontext="$curcontext" state line expl ret=1 variant +local -a args privs aopts=( -A '-*' ) args=( '*: :->files' '1: :_file_modes' ) -if _pick_variant gnu=Free\ Soft unix --version; then - args+=( - '(-v --verbose -c --changes)'{-c,--changes}'[report changes made]' - '(-v --verbose -c --changes)'{-v,--verbose}'[output a diagnostic for every file processed]' - '(-f --silent --quiet)'{-f,--silent,--quiet}'[suppress most error messages]' - '(--no-preserve-root)--preserve-root[fail to operate recursively on /]' - "(--preserve-root)--no-preserve-root[don't treat / specially (default)]" - '(1)--reference=[copy permissions of specified file]:file:_files' - '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]' - '(- : *)--help[display help information]' - '(- : *)--version[display version information]' - ) -else - args+=( - '-f[suppress most error messages]' - '-R[change files and directories recursively]' - ) - case $OSTYPE in - freebsd*|dragonfly*|darwin*) - args+=( '-v[output a diagnostic for every file processed]') +_pick_variant -r variant -b zsh gnu=Free\ Soft $OSTYPE --version +case "$variant" in + zsh) + # Assign, not append because zf_chmod only supports octal modes. + args=( + '-R[change files and directories recursively]' + '-s[enable paranoid behavior]' + '1: :_guard "[0-7]#" "octal mode"' + '*: :->files' + ) + ;; + gnu) + aopts=() + args+=( + '(-v --verbose -c --changes)'{-c,--changes}'[report changes made]' + '(-v --verbose -c --changes)'{-v,--verbose}'[output a diagnostic for every file processed]' + '(-f --silent --quiet)'{-f,--silent,--quiet}'[suppress most error messages]' + '(--no-preserve-root)--preserve-root[fail to operate recursively on /]' + "(--preserve-root)--no-preserve-root[don't treat / specially (default)]" + '(1)--reference=[copy permissions of specified file]:file:_files' + '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]' + '(- : *)--help[display help information]' + '(- : *)--version[display version information]' + ) + ;; + *) + args+=( + '-f[suppress most error messages]' + '-R[change files and directories recursively]' + ) ;| - freebsd*|netbsd*|darwin*|dragonfly*) - args+=( "-h[operate on symlinks them self]" ) + freebsd*|dragonfly*|darwin*) + args+=( + '-v[output a diagnostic for every file processed]' + ) ;| - freebsd*|openbsd*|netbsd*|darwin*|dragonfly*) - args+=( - '(-H -L -P)-L[follow all symlinks]' - '(-H -L -P)-H[follow symlinks on the command line]' - '(-H -L -P)-P[do not follow symlinks (default)]' - ) + freebsd*|netbsd*|darwin*|dragonfly*) + args+=( + '-h[operate on symlinks themselves]' + ) ;| - darwin*) - args+=( - '(1)-C[returns false if any of the named files have ACLs]' - '(1)-N[remove ACLs from specified files]' - '(1)-E[read ACL info from stdin as a sequential list of ACEs]' - '(1)-i[removes inherited bit from all entries in named files ACLs]' - '(1)-I[removes all inherited entries from named files ACLs]' - ) + freebsd*|openbsd*|netbsd*|darwin*|dragonfly*) + args+=( + '(-H -L -P)-L[follow all symlinks]' + '(-H -L -P)-H[follow symlinks on the command line]' + '(-H -L -P)-P[do not follow symlinks (default)]' + ) + ;| + darwin*) + args+=( + '(1)-C[return false if any specified files have ACLs]' + '(1)-N[remove ACLs from specified files]' + '(1)-E[read ACL info from stdin as sequential list of ACEs]' + "(1)-i[remove inherited bit from all entries in specified files' ACLs]" + "(1)-I[remove all inherited entries from specified files' ACLs]" + ) ;; - esac -fi +esac -_arguments -C -s "$args[@]" && ret=0 +_arguments -C -s -S $aopts "$args[@]" && ret=0 case "$state" in files) @@ -62,12 +78,12 @@ case "$state" in local spec who op priv local -a specs for spec in ${(s:,:)line[1]}; do - if [[ ${spec#*[+-=]} != [rwxst]## ]]; then - _files && ret=0 - return ret - fi + if [[ ${spec#*[+-=]} != [rwxst]## ]]; then + _files && ret=0 + return ret + fi - specs+=( ${${(M)spec##[+-=]*}:+a}$spec ) + specs+=( ${${(M)spec##[+-=]*}:+a}$spec ) done _wanted files expl file _files -g "*(-.^f:${(j.,.)specs}:)" && ret=0 fi diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown index a97a0e0bf..9ebbf7bab 100644 --- a/Completion/Unix/Command/_chown +++ b/Completion/Unix/Command/_chown @@ -1,46 +1,72 @@ #compdef chown chgrp gchown=chown gchgrp=chgrp zf_chown=chown zf_chgrp=chgrp -local curcontext="$curcontext" state line expl ret=1 -local suf usr grp req deref pattern arg args +local curcontext="$curcontext" state line expl ret=1 variant +local suf usr grp req deref pattern arg args aopts=( -A '-*' ) -if _pick_variant gnu=Free\ Soft unix --version; then - args=( - '(-c --changes -v --verbose)'{-c,--changes}'[report each change made]' - '(-c --changes -v --verbose)'{-v,--verbose}'[output info for every file processed]' - '(-h --no-dereference)--dereference[dereference symlinks]' - '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks themselves]' - '(-f --silent --quiet)'{-f,--silent,--quiet}"[don't report errors]" - '--preserve-root[fail to operate recursively on /]' - '--reference=[copy ownership of specified file]:file:_files' - '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]' - '(-H -L -P)-L[follow all symlinks]' - '(-H -L -P)-H[follow symlinks on the command line]' - '(-H -L -P)-P[do not follow symlinks (default)]' - '(- : *)--help[display help information]' - '(- : *)--version[display version information]' - ) - [[ $service = chown ]] && - args+=( '--from=[restrict changes to files by current ownership]: :->owner' ) -else - args=( - "-h[operate on symlinks them self]" - '-R[change files and directories recursively]' - '(-H -L -P)-L[follow all symlinks]' - '(-H -L -P)-H[follow symlinks on the command line]' - '(-H -L -P)-P[do not follow symlinks (default)]' - ) - for pattern arg in \ - '(dragonfly|freebsd)*' "-x[don't traverse file systems]" \ - '(darwin|dragonfly|(free|net)bsd|solaris)*' "-f[don't report errors]" \ - '(darwin|dragonfly|(free|net)bsd)*' '-v[output info for every file processed]' \ - 'solaris2.<11->' '-s[owner and/or group are Windows SID strings]' - do - [[ $OSTYPE = $~pattern ]] && args+=( $arg ) - done -fi +_pick_variant -r variant -b zsh gnu=Free\ Soft $OSTYPE --version +case "$variant" in + gnu) + aopts=() + args=( + '(-c --changes -v --verbose)'{-c,--changes}'[report each change made]' + '(-c --changes -v --verbose)'{-v,--verbose}'[output info for every file processed]' + '(-h --no-dereference)--dereference[dereference symlinks]' + '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks themselves]' + '(-f --silent --quiet)'{-f,--silent,--quiet}"[don't report errors]" + '--preserve-root[fail to operate recursively on /]' + '--reference=[copy ownership of specified file]:file:_files' + '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]' + '(-H -L -P)-L[follow all symlinks]' + '(-H -L -P)-H[follow symlinks on the command line]' + '(-H -L -P)-P[do not follow symlinks (default)]' + '(- : *)--help[display help information]' + '(- : *)--version[display version information]' + ) + [[ $service = chown ]] && + args+=( '--from=[restrict changes to files by current ownership]: :->owner' ) + ;; + *) + args=( + '-h[operate on symlinks themselves]' + '-R[change files and directories recursively]' + ) + ;| + zsh) + args+=( + '-s[enable paranoid behavior]' + ) + ;; + *) + args+=( + '(-H -L -P)-L[follow all symlinks]' + '(-H -L -P)-H[follow symlinks on the command line]' + '(-H -L -P)-P[do not follow symlinks (default)]' + ) + ;| + dragonfly*|freebsd*) + args+=( + "-x[don't traverse file systems]" + ) + ;| + darwin*|dragonfly*|freebsd*|netbsd*|solaris*) + args+=( + "-f[don't report errors]" + ) + ;| + darwin*|dragonfly*|freebsd*|netbsd*) + args+=( + '-v[output info for every file processed]' + ) + ;| + solaris2.<11->) + args+=( + '-s[owner and/or group are Windows SID strings]' + ) + ;; +esac (( $+words[(r)--reference*] )) || args+=( '(--reference)1: :->owner' ) -_arguments -C -s "$args[@]" '*: :->files' && ret=0 +_arguments -C -s -S $aopts "$args[@]" '*: :->files' && ret=0 case $state in owner) diff --git a/Completion/Unix/Command/_chsh b/Completion/Unix/Command/_chsh index 006aa82a1..802369807 100644 --- a/Completion/Unix/Command/_chsh +++ b/Completion/Unix/Command/_chsh @@ -50,7 +50,7 @@ case $OSTYPE in args+=( '(-)'{-u,--usage}'[display short usage message]' '(-)--help[display help information]' - '(-D --binddn)'{-D+,--binddn=}'[specify LDAP disingushed name to bind]:binddn' + '(-D --binddn)'{-D+,--binddn=}'[specify LDAP distinguished name to bind]:binddn' '(-P --path)'{-P+,--path=}'[specify path to search for passwd and shadow files]:path:_directories' '(-q --quiet)'{-q,--quiet}"[don't be verbose]" '--service=[use specified name service]:service:(files nis nisplus ldap)' diff --git a/Completion/Unix/Command/_cksum b/Completion/Unix/Command/_cksum index bb2f60ac7..67f2a7896 100644 --- a/Completion/Unix/Command/_cksum +++ b/Completion/Unix/Command/_cksum @@ -91,7 +91,7 @@ case $OSTYPE in openbsd*) args+=( '-b[output in base64]' - '(-h)-C+[verify input files against checksums in specifed file]:checksum file:_files' + '(-h)-C+[verify input files against checksums in specified file]:checksum file:_files' '(-C)-h+[output checksums to specified file]:checksum file:_files' '(-n -r)-q[output checksum only, or suppress check success messages]' ) diff --git a/Completion/Unix/Command/_column b/Completion/Unix/Command/_column index a81684dba..94bdccf0a 100644 --- a/Completion/Unix/Command/_column +++ b/Completion/Unix/Command/_column @@ -1,33 +1,48 @@ #compdef column -local ret=1 -local -a context state line expl args columns MATCH +# Note: BSD and util-linux disagree on how to describe the behaviour of the -x +# option. We use our own wording to avoid confusion + +local variant ret=1 +local -a context state line expl args columns MATCH aopts=( -A '-*' ) local -i MBEGIN MEND local -A opt_args -case $OSTYPE in - linux-gnu) +# Debian and its derivatives (as of 2019) ship with a slightly customised +# version of the BSD column instead of the util-linux one. It can be identified +# by the presence of the custom option -n in the synopsis +_pick_variant -r variant \ + util-linux='(#i)util-linux' \ + debian='\[-[A-Za-z]#n[A-Za-z]#\]' \ + $OSTYPE \ +--version + +case $variant in + util-linux) + aopts=() args=( '(info json -c --output-width)'{-c+,--output-width=}'[format output to fit display of specified width]:width' '(info)'{-L,--table-empty-lines}"[don't ignore empty lines]" + fill - '(info table text json -x --fillrows)'{-x,--fillrows}'[fill rows before filling columns]' + '(info table text json -x --fillrows)'{-x,--fillrows}'[print across before down]' + table '(info fill -t --table)'{-t,--table}'[create a table]' + '(info fill -o --output-separator)'{-o+,--output-separator=}'[specify column separator for table output]:separator [two spaces]' '(info fill -s --separator)'{-s+,--separator=}'[specify column delimiters in input data]:delimiters' '(info fill -O --table-order)'{-O+,--table-order=}'[specify order of output columns]: :->columns' '(info fill -N --table-columns)'{-N+,--table-columns=}'[specify column names]:names' '(info fill -H --table-hide)'{-H+,--table-hide=}"[don't print specified columns]: :->columns" + text '(info fill json -d --table-noheadings)'{-d,--table-noheadings}"[don't print header]" - '(info fill json -E --table-noextreme)'{-E,--table-noextreme}"[specify columns where length can be ignored]: :->columns" + '(info fill json -E --table-noextreme)'{-E+,--table-noextreme}"[specify columns where length can be ignored]: :->columns" '(info fill json -e --table-header-repeat)'{-e,--table-header-repeat}'[repeat header for each page]' + '(info fill json -H --table-hide)'{-H+,--table-hide=}"[don't print specified columns]: :->columns" '(info fill json -R --table-right)'{-R+,--table-right=}'[right align text in these columns]: :->columns' '(info fill json -T --table-truncate)'{-T+,--table-truncate=}'[truncate text in the columns when necessary]: :->columns' '(info fill json -W --table-wrap)'{-W+,--table-wrap=}'[wrap text in the columns when necessary]: :->columns' - '(info fill json -r --tree)'{-r+,--tree=}'[specify column to format tree-like]: :->column' - '(info fill json -i --tree-id)'{-i+,--tree-id=}'[specify column containing ID for child-parent relations]: :->column' - '(info fill json -p --tree-parent)'{-p+,--tree-parent=}'[specify column containing reference to parent]: :->column' + '(info fill json -r --tree)'{-r+,--tree=}'[specify column to format tree-like]: :->columns' + '(info fill json -i --tree-id)'{-i+,--tree-id=}'[specify column containing ID for child-parent relations]: :->columns' + '(info fill json -p --tree-parent)'{-p+,--tree-parent=}'[specify column containing reference to parent]: :->columns' + json '(info fill text -n --table-name -c --output-width)'{-n+,--table-name=}'[specify table name for JSON output]:name' '(info fill text -J --json -c --output-width)'{-J,--json}'[use JSON output format for table]' @@ -36,17 +51,24 @@ case $OSTYPE in '(- *)'{-V,--version}'[display version information]' ) ;; - *) + debian) + aopts=() args=( + "(-x)-n[don't merge multiple adjacent delimiters]" + "-e[don't ignore empty lines]" + ) + ;& # FALL THROUGH + *) + args+=( '(-t -s)-c+[format output to fit display of specified width]:width' '(-c -x)-t[create a table]' '(-c -x)-s+[specify column delimiters in input data]:delimiters' - '(-t -s)-x[fill rows before filling columns]' + '(-n -t -s)-x[print across before down]' ) ;; esac -_arguments -s -S '*:file:_files' $args && ret=0 +_arguments -s -S $aopts '*:file:_files' $args && ret=0 if [[ -n $state ]]; then columns=( ${(s.,.)${(Q)${opt_args[table--N]:-$opt_args[table---table-columns]}//(#m)\\([\\:])/${MATCH[2]}}} ) diff --git a/Completion/Unix/Command/_composer b/Completion/Unix/Command/_composer index 2b9f2cd32..1cd3f3561 100644 --- a/Completion/Unix/Command/_composer +++ b/Completion/Unix/Command/_composer @@ -40,7 +40,7 @@ __composer_call() { __composer_update_work_dir - cmd=( ${_composer_cmd:-composer} -d${_composer_work_dir:-${(q)PWD}} ) + cmd=( ${_composer_cmd:-composer} -d${(q)${_composer_work_dir:-$PWD}} ) (( _composer_is_global )) && cmd+=( global ) _call_program $1 $cmd "${@[2,-1]}" @@ -115,7 +115,7 @@ __composer_prune_global_opts() { (( $+functions[__composer_update_work_dir] )) || __composer_update_work_dir() { if [[ -n ${(v)opt_args[(i)(-d|--working-dir)]} ]]; then - eval _composer_work_dir=${(v)opt_args[(i)(-d|--working-dir)]} + _composer_work_dir=${(Q)${(v)opt_args[(i)(-d|--working-dir)]}} elif [[ -z $_composer_work_dir ]]; then _composer_work_dir=$PWD fi diff --git a/Completion/Unix/Command/_cp b/Completion/Unix/Command/_cp index 88750b330..f7411055b 100644 --- a/Completion/Unix/Command/_cp +++ b/Completion/Unix/Command/_cp @@ -32,7 +32,7 @@ if _pick_variant gnu=GNU unix --version; then '(-v --verbose)'{-v,--verbose}'[explain what is being done]' \ '(-x --one-file-system)'{-x,--one-file-system}'[stay on this file system]' \ '(--context)-Z[set destination SELinux security context]' \ - '(-Z)--context=-[set destination SELinux security context]::context' \ + '(-Z)--context=-[set destination SELinux security context]:: :_selinux_contexts' \ '(- *)--help' '(- *)--version' \ '*:file or directory:_files' else @@ -53,7 +53,7 @@ else 'solaris2.<11->*' '-/[preserve extended attributes and extended system attributes]' \ '(darwin|dragonfly|freebsd)*' "(-f -i)-n[don't overwrite existing file]" \ 'netbsd*' "-N[don't copy file flags]" \ - '(darwin|dragonfly|freebsd|netbsd)*' '-a[archive mode, same as -RpP]' \ + '(darwin|dragonfly|freebsd|netbsd|openbsd)*' '-a[archive mode, same as -RpP]' \ '(dragonfly|freebsd)*' '-l[link files instead of copying]' \ '(darwin|dragonfly|*bsd)*' '-v[show file names as they are copied]' \ 'darwin*' "-X[don't copy extended attributes or resource forks]" \ diff --git a/Completion/Unix/Command/_date b/Completion/Unix/Command/_date index a3e933710..68bd357fb 100644 --- a/Completion/Unix/Command/_date +++ b/Completion/Unix/Command/_date @@ -31,7 +31,7 @@ else freebsd*|dragonfly*|darwin*|netbsd*|openbsd*) opts+=( -A '-*' ) args+=( - '-j[do not try to set date]' + "-j[don't try to set date]" '2:format or date:->fmt_date' ) ;| @@ -40,8 +40,7 @@ else ;| freebsd*|dragonfly*|darwin*|openbsd*) args+=( - '-d+:daylight saving time value' - '-t+:minutes west of GMT' + '-f+[use specified format for input]:parsing format:_date_formats:new date' ) ;| dragonfly*|darwin*|netbsd*|openbsd*) @@ -57,14 +56,16 @@ else ) args+=( '-r+[reference time: file modification or literal time]:reference: _alternative $alts' + '(-R)-I-[display in ISO 8601 format]::precision:(date hours minutes seconds)' ) ;| freebsd*|dragonfly*|darwin*) args+=( - '-f+[use specified format for input]:parsing format:_date_formats:new date:' - '*-v+[adjust and print (but not set) date]:[+-]value[ymwdHMS]:' + '-d+:daylight saving time value' + '-t+:minutes west of GMT' + "*-v+[adjust and print (but don't set) date]:[+-]value[ymwdHMS]" ) - ;; + ;| freebsd*|dragonfly*) args+=( '-R[display in RFC2822 format]' ) ;| diff --git a/Completion/Unix/Command/_dbus b/Completion/Unix/Command/_dbus index 3f106cb5c..37b5458d7 100644 --- a/Completion/Unix/Command/_dbus +++ b/Completion/Unix/Command/_dbus @@ -1,4 +1,4 @@ -#compdef dbus-send dbus-monitor +#compdef dbus-send dbus-monitor dbus-launch local curcontext="$curcontext" state line expl find end ret=1 typeset -A opt_args @@ -27,6 +27,20 @@ case $service in - '(format)' \ --monitor --profile --pcap --binary && ret=0 ;; + dbus-launch) + _arguments -C \ + --version"[print the version of dbus-launch]" \ + --help"[print the help info of dbus-launch]" \ + --sh-syntax"[emit bourne-shell compatible code to set up environment variables]" \ + --csh-syntax"[emit csh compatible code to set up environment variables]" \ + --auto-syntax"[choose --csh-syntax or --sh-syntax based on the SHELL environment variable]" \ + --binary-syntax"[use a nul-terminated syntax with the environment data]" \ + --close-stderr"[close stderr stream before starting the d-bus daemon]" \ + --exit-with-session"[create a persistent \"babysitter\" process]" \ + --exit-with-x11"[create a persistent \"babysitter\" process that will connect to the x server]" \ + --autolaunch="[scan for a previously-started session and reuse the values found there]:machine id:->machine-id" \ + --config-file="[pass --config-file=FILENAME to the bus daemon]" && ret=0 + ;; esac case $state in @@ -85,6 +99,14 @@ case $state in 'arg0namespace:namespace' \ 'eavesdrop:eavesdropping:(true false)' && ret=0 ;; + machine-id) + { local machine_id="$(</var/lib/dbus/machine-id)" } 2>/dev/null + if [[ -n "$machine_id" ]]; then + _wanted machine-ids expl machine-id compadd $machine_id && ret=0 + else + _message "No /var/lib/dbus/machine-id found" && ret=0 + fi + ;; esac return ret diff --git a/Completion/Unix/Command/_dhclient b/Completion/Unix/Command/_dhclient index ee309e1fd..d5ca5b271 100644 --- a/Completion/Unix/Command/_dhclient +++ b/Completion/Unix/Command/_dhclient @@ -6,12 +6,12 @@ case $OSTYPE in (open|free)bsd*) args+=( '-c+[specify configuration file]:file:_files' - '-l+[specify leases file]:file:_files' ) ;| freebsd*) args+=( '(-d)-b[immediately move to the background]' + '-l+[specify leases file]:file:_files' '-p+[specify PID file]:file:_files' '-u[reject leases with unknown options]' '-q[quiet]' @@ -45,7 +45,7 @@ case $OSTYPE in '-g[force giaddr field]:relay:_hosts' '-i[use a DUID with DHCPv4 clients]' '-I[use the standard DDNS scheme]' - '--version[display version number]' + '(-)--version[display version number]' '(-4)-S[use Information-request to get only stateless configuration]' '(-4)*-T[ask for IPv6 temporary addresses]' '(-4)-P[enable IPv6 prefix delegation]' @@ -67,6 +67,10 @@ case $OSTYPE in '--request-options[specify list of options the client is to request from the server]:options' '--timeout[specify time after which dhclient will decide that no DHCP servers can be contacted]:timeout' '--dad-wait-time[specify maximum time to wait for duplicate address detection]:time (seconds)' + '--prefix-len-hint[specify length to request when requesting new prefixes]:length' + '--decline-wait-time[specify time an IPv4 client should wait between declining an address and issuing a discover]:time (seconds)' + '--address-prefix-len[specify length of the prefix for IPv6 addresses]:length' + '(-)'{--help,-h}'[display usage information]' ) ;; esac diff --git a/Completion/Unix/Command/_dig b/Completion/Unix/Command/_dig index d37f18643..d2ffb0a33 100644 --- a/Completion/Unix/Command/_dig +++ b/Completion/Unix/Command/_dig @@ -78,6 +78,7 @@ _arguments -s -C $args \ '*-6[use IPv6 only]' \ '*-t+[specify type]:type:_dns_types' \ '*-q+[specify host name to query]:host:_hosts' \ + "-r[don't read ~/.digrc]" \ '*-x+[reverse lookup]:IP address' \ '*-k+[specify TSIG key file]:file:_files' \ '*-y+[specify TSIG key]:hmac\:name\:key' \ diff --git a/Completion/Unix/Command/_dsh b/Completion/Unix/Command/_dsh index fc7680062..2486b23fd 100644 --- a/Completion/Unix/Command/_dsh +++ b/Completion/Unix/Command/_dsh @@ -10,10 +10,10 @@ _arguments -s -C -S \ '(-M --show-machine-names)'{-M,--show-machine-names}'[prepend the host name on output]' \ '(-i --duplicate-input)'{-i,--duplicate-input}'[duplicate input given to dsh]' \ '(-b --bufsize)'{-b,--bufsize}'[change buffer size used in input duplication]:buffer size for -i (bytes)' \ - '(-m --machine)'{-m,--machine}'[execute on machine]:machine:{_hosts || _user_at_host}' \ + \*{-m,--machine}'[execute on machine]:machine:{_hosts || _user_at_host}' \ '(-n --num-topology)'{-n,--num-topology}'[how to divide the machines]:number' \ '(-a --all)'{-a,--all}'[execute on all machines]' \ - '(-g --group)'{-g,--group}'[execute on group member]:groupname:->groups' \ + \*{-g,--group}'[execute on group member]:groupname:->groups' \ '(-f --file)'{-f,--file}'[use the file as list of machines]:file:_files' \ '(-r --remoteshell)'{-r,--remoteshell}'[execute using shell]:remote shell:(rsh ssh)' \ '(-o --remoteshellopt)'{-o,--remoteshellopt}'[option to give to remote shell ]:option' \ diff --git a/Completion/Unix/Command/_ecasound b/Completion/Unix/Command/_ecasound index 7ad08d0e1..a39e426db 100644 --- a/Completion/Unix/Command/_ecasound +++ b/Completion/Unix/Command/_ecasound @@ -36,7 +36,7 @@ _arguments -C \ '*-eS\:-[audio stamp]:stamp-id (int)' \ '*-ea\:-[amplify signal]:amplification value (percent)' \ '*-eac\:-[amplify signal of channel]: :->eac' \ - '*-eaw\:-[amplify singal (clipping)]: :->eaw' \ + '*-eaw\:-[amplify signal (clipping)]: :->eaw' \ '*-eal\:-[limits audio level]:limit (percent)' \ '*-ec\:-[compressor (a simple one)]: :->ec' \ '*-eca\:-[a more advanced compressor]: :->eca' \ diff --git a/Completion/Unix/Command/_elm b/Completion/Unix/Command/_elm deleted file mode 100644 index 2918a5de0..000000000 --- a/Completion/Unix/Command/_elm +++ /dev/null @@ -1,18 +0,0 @@ -#compdef elm - -_arguments -s \ - '::recipient:_email_addresses' \ - '-a[use the arrow pointer regardless]' \ - '-A+[attach file]:file attachment:_files' \ - '-c[check the given aliases only]:*:alias' \ - '-d+[set debug level]:debug level' \ - '-f+[specify mailbox to load]:mailbox: _mailboxes' \ - '-h[display help]' \ - '-i+[specify file to include in message]:include file:_files' \ - '-m[turn off menu, using more of the screen]' \ - '-s+[specify a subject]:subject:' \ - "-t[don't use termcap/terminfo ti/te entries]" \ - '-V[enable sendmail voyeur mode]' \ - '-v[display elm version]' \ - '-w[write .elm/elmrc]' \ - '-z[start only if new messages]' diff --git a/Completion/Unix/Command/_entr b/Completion/Unix/Command/_entr index e1ba7cf2b..3e2261a18 100644 --- a/Completion/Unix/Command/_entr +++ b/Completion/Unix/Command/_entr @@ -4,11 +4,12 @@ local curcontext="$curcontext" state state_descr line ret=1 typeset -A opt_args _arguments -s -S \ + '(-r)-a[respond to all events rather than consolidating them to avoid looping]' \ '-c[execute clear before invoking utility]' \ '-d[track directories and exit if a new file is added]' \ "-n[non-interactive mode; don't access TTY]" \ '-p[postpone first execution of the utility]' \ - '-r[reload a persistent child process]' \ + '(-a)-r[reload a persistent child process]' \ '(*)-s[evaluate the first argument using interpreter specified by $SHELL]' \ '(-): :->command' \ '*::arguments:_normal' && ret=0 diff --git a/Completion/Unix/Command/_env b/Completion/Unix/Command/_env index 932a7fc89..27978d936 100644 --- a/Completion/Unix/Command/_env +++ b/Completion/Unix/Command/_env @@ -11,6 +11,10 @@ case $variant in '(--ignore-environment -i --help --version)*'{-u+,--unset=}'[remove variable from the environment]:env var to remove:_parameters -g "*export*"' '(-C --chdir)'{-C+,--chdir=}'[change working directory]:directory:_directories' '(-S --split-string)'{-S+,--split-string=}'[perform word splitting]:string to split' + '--block-signal=[block delivery of signals to command]:signal:_sequence _signals' + '--default-signal=[reset handling of signals to the default]:signal:_sequence _signals' + '--ignore-signal=[set handling of signals to do nothing]:signal:_sequence _signals' + '--list-signal-handling[list non default signal handling to stderr]' '(-v --debug)'{-v,--debug}'[print verbose information for each processing step]' "${ign}(- *)--help[display help information]" "${ign}(- *)--version[display version information]" diff --git a/Completion/Unix/Command/_find b/Completion/Unix/Command/_find index edd46ac1c..916fcf2e6 100644 --- a/Completion/Unix/Command/_find +++ b/Completion/Unix/Command/_find @@ -1,6 +1,6 @@ #compdef find gfind -local curcontext="$curcontext" state_descr variant default +local curcontext="$curcontext" state_descr variant default ret=1 local -a state line args alts disp smatch _pick_variant -r variant gnu=GNU $OSTYPE -version @@ -98,7 +98,7 @@ case $variant in args+=( '(- *)-help' '(-)--help' '(- *)-version' '(-)--version' - '-D[print diagnostics]:debug option:(help tree search stat rates opt exec)' + '-D[print diagnostics]:debug option:(exec opt rates search stat time tree all help)' '-O+[enable query optimisation]:level:(1 2 3)' '*-daystart' '-regextype:regexp syntax:(help findutils-default awk egrep ed emacs gnu-awk grep posix-awk posix-basic posix-egrep posix-extended posix-minimal-basic sed)' @@ -116,7 +116,7 @@ case $variant in '*-fprintf:output file:_files:output format' '*-printf:output format' ) - [[ $OSTYPE = linux-gnu ]] && args+=( '*-context:SELinux context' ) + [[ $OSTYPE = linux-gnu ]] && args+=( '*-context:SELinux context (glob pattern):_selinux_contexts' ) ;; esac @@ -147,7 +147,8 @@ _arguments -C $args \ '*-user:user:_users' \ '*-xdev' \ '*-a' '*-o' \ - '(-D -E -H -L -O -P -f -s -x --help --version)*:directory:_files -/' + '(-D -E -H -L -O -P -f -s -x --help --version)*:directory:_files -/' \ +&& ret=0 if [[ $state = times ]]; then if ! compset -P '[+-]' || [[ -prefix '[0-9]' ]]; then @@ -164,5 +165,7 @@ if [[ $state = times ]]; then alts=( "senses:sense${default}:compadd -V times -S '' -d disp -a smatch" ) fi alts+=( "times:${state_descr}:_dates -f d" ) - _alternative $alts + _alternative $alts && ret=0 fi + +return ret diff --git a/Completion/Unix/Command/_flasher b/Completion/Unix/Command/_flasher deleted file mode 100644 index d5820e116..000000000 --- a/Completion/Unix/Command/_flasher +++ /dev/null @@ -1,29 +0,0 @@ -#compdef flasher - -_arguments \ - '(--fiasco -F)'{--fiasco,-F}':location of a FIASCO image:_files' \ - '(--kernel -k)'{--kernel,-k}':location of kernel image:_files' \ - '(--initfs -n)'{--initfs,-n}':location of initfs image:_files' \ - '(--rootfs -r)'{--rootfs,-r}':location of root JFFS2 image:_files' \ - '(--xloader -x)'{--xloader,-x}':location of X-Loader image:_files' \ - '(--secondary -s)'{--secondary,-s}':location of NOLO secondary bootloader image:_files' \ - '(--2nd -2)'{--2nd,-2}':location of NOLO cold flasher ("2nd") image:_files' \ - '(--unpack -u)'{--unpack,-u}'::unpack a FIASCO image:_files' \ - '(--flash -f)'{--flash,-f}'[load and flash all supplied images]' \ - '(--load -l)'{--load,-l}'[only load all supplied images]' \ - '(--boot -b)'{--boot,-b}'::kernel cmdline' \ - '(--reboot -R)'{--reboot,-R}'[reboot the board]' \ - '(--read-board-id -i)'{--read-board-id,-i}'[print out the board type]' \ - '(--serial-port -S)'{--serial-port,-S}':serial port used for cold flashing' \ - '(--initialize-port -I)'{--initialize-port,-I}':something' \ - '(--cold-flash -c)'{--cold-flash,-c}'[cold flash the device]' \ - '--enable-rd-mode[enable R&D mode on the device]' \ - '--disable-rd-mode[disable R&D mode on the device]' \ - '--set-rd-flags::R&D mode flags to set' \ - '--clear-rd-flags::R&D mode flags to clear' \ - '--query-rd-mode[query the device R&D mode status and flags]' \ - '--set-root-device:default root device' \ - '--query-root-device[query the default root device]' \ - '--enable-usb-host-mode[set the device into USB host mode]' \ - '--disable-usb-host-mode[set the device into USB peripheral mode]' \ - '--flash-only:components' diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc index 9de0b79b1..9ec09200e 100644 --- a/Completion/Unix/Command/_gcc +++ b/Completion/Unix/Command/_gcc @@ -13,6 +13,11 @@ if [[ "$service" = -value-* ]]; then args2=() fi else + # On some systems (macOS), cc/gcc/g++ are actually clang; treat them accordingly + [[ $service != clang* ]] && + _pick_variant clang=clang unix --version && + service=clang-$service + args2=( '*:input file:_files -g "*.([cCmisSoak]|cc|cpp|cxx|ii|k[ih])(-.)"' ) fi @@ -350,10 +355,12 @@ if [[ "$service" = clang* ]]; then "-nostdinc[Do not search standard system directories or compiler builtin directories for include files]" "-nostdlibinc[Do not search standard system directories for include files]" "-nobuiltininc[Do not search builtin directory for include files]" + "--help[Display this information]" ) else args+=( '-flto=-[Enable link-time optimization]::jobs:' + '*--help=-[Display this information]:class:->help' ) fi @@ -427,7 +434,6 @@ args+=( '*-isystem:second include path directory (system):_files -/' '--sysroot=-[Use <directory> as the root directory for headers and libraries]:directory:_files -/' '-pass-exit-codes[Exit with highest error code from a phase]' - '*--help=-[Display this information]:class:->help' '--target-help[Display target specific command line options]' '-dumpspecs[Display all of the built in spec strings]' '-dumpversion[Display the version of the compiler]' @@ -440,6 +446,7 @@ args+=( '-print-multi-os-directory[Display the relative path to OS libraries]' '-print-sysroot[Display the target libraries directory]' '-print-sysroot-headers-suffix[Display the sysroot suffix used to find headers]' + '-save-stats=-[Save code generation statistics]:location:(cwd obj)' '-save-temps[Do not delete intermediate files]' '-no-canonical-prefixes[Do not canonicalize paths when building relative prefixes to other gcc components]' '-pipe[Use pipes rather than intermediate files]' @@ -675,7 +682,6 @@ args+=( '-Wunderflow[Warn about underflow of numerical constant expressions]' '-Wuninitialized[Warn about uninitialized automatic variables]' '-Wunknown-pragmas[Warn about unrecognized pragmas]' - '-Wunreachable-code[Does nothing. Preserved for backward compatibility]' '-Wunsafe-loop-optimizations[Warn if the loop cannot be optimized due to nontrivial assumptions]' '-Wunsuffixed-float-constants[Warn about unsuffixed float constants]' '-Wunused-but-set-parameter[Warn when a function parameter is only set, otherwise unused]' @@ -729,6 +735,20 @@ args+=( '-Werror=-[Treat specified warning as error (or all if none specified)]::warning:->werror' '-Wfatal-errors[Exit on the first error occurred]' ) +# clang specific warnings +if [[ "$service" = clang* ]]; then + args+=( + '-Wunreachable-code[Warn on code that will not be executed]' + '-Wunreachable-code-aggressive[Controls -Wunreachable-code, -Wunreachable-code-break, -Wunreachable-code-return]' + '-Wunreachable-code-break[Warn when break will never be executed]' + '-Wunreachable-code-loop-increment[Warn when loop will be executed only once]' + '-Wunreachable-code-return[Warn when return will not be executed]' + ) +else + args+=( + '-Wunreachable-code[Does nothing. Preserved for backward compatibility]' + ) +fi # optimizers (from --help=optimizers), except for -O args+=( # --help=optimizers,^joined diff --git a/Completion/Unix/Command/_gcore b/Completion/Unix/Command/_gcore index 4933ffee6..07a65cd9a 100644 --- a/Completion/Unix/Command/_gcore +++ b/Completion/Unix/Command/_gcore @@ -33,11 +33,19 @@ case $OSTYPE in '-c+[write core file to specified file]:file:_files' \ '*:pid:_pids' ;; + dragonfly*) + _arguments -s \ + '-c+[write core file to specified file]:file:_files' \ + '-l+[skip map segments larger than the specified limit]:limit (bytes)' \ + '-s[stop the process while gathering the core image]' \ + '-v[Verbosely print out the map segments being dumped]' \ + '::executable:' \ + ':pid:_pids' + ;; freebsd*) _arguments -s \ '-c+[write core file to specified file]:file:_files' \ '-f[dump all available segments]' \ - '-s[stop process while gathering image]' \ '::executable:' \ ':pid:_pids' ;; diff --git a/Completion/Unix/Command/_gem b/Completion/Unix/Command/_gem index 5b048f86d..b35a5c358 100644 --- a/Completion/Unix/Command/_gem +++ b/Completion/Unix/Command/_gem @@ -28,12 +28,12 @@ if [[ $state = command ]]; then else cmds=( build cert check cleanup contents dependency environment fetch - generate_index help install list lock mirror open outdated owner + generate_index help install info list lock mirror open outdated owner pristine push query rdoc search server signin signout sources specification stale uninstall unpack update which yank ) cmds=( ${(M)cmds:#${words[1]}*} ) - if (( ${#cmds} == 1 )); then + if (( ${#cmds} == 1 )) || [[ $cmds[1] = install ]]; then cmd="$cmds[1]" curcontext="${curcontext%:*:*}:gem-${cmd}:" fi @@ -56,7 +56,7 @@ if [[ $state = command ]]; then check|cleanup|contents|dependency|list|open|pristine|rdoc|uninstall|unpack|update) args+=( '(--all --skip)*:installed gem:->gems-local' ) ;| - fetch|install|lock|owner|push|search|yank) + fetch|install|lock|owner|search|yank) args+=( '*:gem:->gems-remote' ) ;| cleanup|uninstall) @@ -65,15 +65,19 @@ if [[ $state = command ]]; then contents|pristine|rdoc) args+=( '(*)--all[apply to all installed gems]' ) ;| - list|query) def[local]='!' ;| + info|list|query) def[local]='!' ;| search) def[remote]='!' ;| - list|query|search) + info|list|query|search) args+=( ${(e)lropts} '(-a --all)'{-a,--all}'[display all gem versions]' '(-e --exact)'{-e,--exact}'[use exact string matching instead of regex]' '(-I --no-installed -i --installed)'{-i,--installed}'[check if gem is installed]' '(-I --no-installed -i --installed)'{-I,--no-installed}'[check if gem is not installed]' '--no-versions[display only gem names]' + ) + ;| + list|query|search) + args+=( '(-d --details)'{-d,--details}'[display detailed gem information]' '!(-d --details)--no-details' ) @@ -114,11 +118,15 @@ if [[ $state = command ]]; then '--suggestions[suggest alternates when gems are not found]' ) ;| + (un|)install|pristine|update) + args+=( + '(-n --bindir)'{-n,--bindir=}'[specify directory where binary files are located]:directory:_directories' + ) + ;| (un|)install|update) args+=( '--ignore-dependencies[ignore dependency requirements]' '(-i --install-dir)'{-i,--install-dir=}'[specify gem repository directory to get installed gems]:directory:_directories' - '(-n --bindir)'{-n,--bindir=}'[specify directory where binary files are located]:directory:_directories' ) ;| owner|push) @@ -130,13 +138,18 @@ if [[ $state = command ]]; then owner|push|signin|yank) args+=( '--host=[use another gemcutter-compatible host]:host:_urls' ) ;| + owner|push|signin) + args+=( '--otp=[specify digit code for multifactor authentication]:code' ) + ;| install|pristine|update) args+=( '(-E --env-shebang)'{-E,--env-shebang}'[rewrite executables with a shebang of /usr/bin/env]' ) ;| - build) args+=( - '--force[skip validation of the spec]' + '(--strict)--force[skip validation of the spec]' + '(--force)--strict[consider warnings as errors when validating the spec]' + '(-o --output)'{-o+,--output=}'[output gem with the given filename]:file:_files' + '-C+[run as if specified directory was the current directory]:directory:_directories' '1:gemspec file:_files -g "*.gemspec(-.)"' ) ;; @@ -150,6 +163,7 @@ if [[ $state = command ]]; then '(-K --private-key)'{-K,--private-key=}'[specify key for --sign or --build]:key' '(-s --sign)'{-s,--sign=}'[sign specified certificate with the key from -K and the certificate from -C]:certificate' '(-d --days)'{-d,--days=}'[specify days before certificate expires]:days' + '(-R --re-sign)'{-R,--re-sign}'[re-sign the certificate]' ) ;; check) @@ -161,7 +175,10 @@ if [[ $state = command ]]; then ) ;; cleanup) - args+=( '(-n -d --dryrun)'{-n,-d,--dryrun}"[don't uninstall gems]" ) + args+=( + '(-n -d --dryrun)'{-n,-d,--dryrun}"[don't uninstall gems]" + "--user-install[cleanup in user's home directory instead of GEM_HOME]" + ) ;; contents) args+=( @@ -214,7 +231,7 @@ if [[ $state = command ]]; then ) ;; push) - args+=( '*:gem:_files -g "*.gem(-.)"' ) + args+=( '1:gem file:_files -g "*.gem(-.)"' ) ;; query) args+=( diff --git a/Completion/Unix/Command/_getconf b/Completion/Unix/Command/_getconf index f2c713a52..36f58226c 100644 --- a/Completion/Unix/Command/_getconf +++ b/Completion/Unix/Command/_getconf @@ -1,6 +1,8 @@ #compdef getconf -local expl ret=1 +local variant list_cmd ret=1 +local -a context expl line state state_descr args +local -A opt_args local -a syskeys posixkeys confkeys pathkeys1 pathkeys2 allkeys mykeys restkeys syskeys=(ARG_MAX BC_BASE_MAX BC_DIM_MAX BC_SCALE_MAX @@ -23,38 +25,85 @@ pathkeys1=(PIPE_BUF _POSIX_CHOWN_RESTRICTED pathkeys2=(LINK_MAX MAX_CANON MAX_INPUT NAME_MAX PATH_MAX PIPE_BUF) mykeys=($syskeys $posixkeys $confkeys $pathkeys1 $pathkeys2) -if [[ CURRENT -eq 2 ]]; then - _tags syswideconfig pathconfig standardsconfig confstring restconfig +if _pick_variant -r variant gnu='(Free Soft|GLIBC)' $OSTYPE --version; then + # GNU getconf doesn't use getopt(3), strangely + args+=( + '(: * -)--help[display help information]' + '(: * -)--version[display version information]' + '(1 -)-a[display all configuration variables and their values]' + '(-)-v[specify programming environment]: :->env' + ) + : ${list_cmd:='$words[1] -a'} - allkeys=(${${(f)"$(getconf -a 2>/dev/null)"}%%[: ]*}) - restkeys=(${allkeys:|mykeys}) +else + [[ $variant == (netbsd*|solaris*) ]] && { + args+=( '(1 -)-a[display all configuration variables and their values]' ) + : ${list_cmd:='$words[1] -a'} + } - while _tags; do - _requested -V syswideconfig expl 'systemwide configuration variables' \ - compadd -S '' $syskeys && ret=0 + [[ $variant == openbsd* ]] && { + args+=( + '(: - *)-l[display all system (non-path) configuration variables]' + '(: - *)-L[display all path configuration variables]' + ) + : ${list_cmd:='$words[1] -l; $words[1] -L'} + } - _requested -V standardsconfig \ - expl 'system-standards configuration variables' \ - compadd -S '' $posixkeys && ret=0 + [[ $variant == netbsd* ]] || + args+=( '(-)-v+[specify programming environment]: :->env' ) - _requested -V confstring \ - expl 'configuration-dependent string variables' \ - compadd -S '' $confkeys && ret=0 + # This is a bit silly, but actually pretty accurate, where available + : ${list_cmd:=' + command strings -- ${${(Q)words[1]}:c} | + LC_ALL=C GREP_OPTIONS= command grep -xE \ + "_*[A-Z][A-Z0-9_]*_[A-Z0-9_]*|NZERO|PATH|[A-Z]+(BITS|SIZE)" + '} +fi - _requested pathconfig && - while _next_label -V pathconfig expl 'system path configuration variables'; do - compadd "$expl[@]" -S '' $pathkeys1 && ret=0 - compadd "$expl[@]" -S ' ' $pathkeys2 && ret=0 - done +_arguments -S -A '-*' : $args '1: :->var' '2: :_files' && ret=0 - if (( ${#restkeys} )); then - _requested -V restconfig \ - expl 'remaining unclassified configuration variables' \ - compadd -S '' $restkeys && ret=0 - fi +case $state in + env) + _wanted environments expl 'programming environment' compadd - \ + POSIX_V{6,7}_ILP32_OFF32 \ + POSIX_V{6,7}_ILP32_OFFBIG \ + POSIX_V{6,7}_LP64_OFF64 \ + POSIX_V{6,7}_LPBIG_OFFBIG \ + && ret=0 + ;; + var) + _tags syswideconfig pathconfig standardsconfig confstring restconfig - (( ret )) || return 0 - done -else - _files -/ -fi + allkeys=(${${(f)"$( _call_program variables $list_cmd )"}%%[=:[:space:]]*}) + restkeys=(${allkeys:|mykeys}) + + while _tags; do + _requested -V syswideconfig expl 'system-wide configuration variable' \ + compadd -S '' $syskeys && ret=0 + + _requested -V standardsconfig \ + expl 'system-standards configuration variable' \ + compadd -S '' $posixkeys && ret=0 + + _requested -V confstring \ + expl 'configuration-dependent string variable' \ + compadd -S '' $confkeys && ret=0 + + _requested pathconfig && + while _next_label -V pathconfig expl 'system path configuration variable'; do + compadd "$expl[@]" -S '' $pathkeys1 && ret=0 + compadd "$expl[@]" -S ' ' $pathkeys2 && ret=0 + done + + if (( ${#restkeys} )); then + _requested -V restconfig \ + expl 'remaining unclassified configuration variable' \ + compadd -S '' $restkeys && ret=0 + fi + + (( ret )) || break + done + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_getent b/Completion/Unix/Command/_getent index 7f4e8bc9c..b96852db3 100644 --- a/Completion/Unix/Command/_getent +++ b/Completion/Unix/Command/_getent @@ -5,24 +5,28 @@ local services databases keys local -a args typeset -A opt_args -if _pick_variant -r is_gnu gnu='(GNU|EGLIBC|Gentoo)' unix --version; then +if _pick_variant -r is_gnu gnu='(Free Soft|GNU|GLIBC|Gentoo)' unix --version; then args+=( '(- 1 *)'{-\?,--help}'[display help information]' '(- 1 *)--usage[display a short usage message]' '(- 1 *)'{-V,--version}'[display version information]' - {-s,--service=}'[specify service configuration to use]:service:->services' + '*'{-s+,--service=}'[specify service configuration to use]: :->services' '(-i --no-idn)'{-i,--no-idn}'[disable IDN encoding]' ) fi -_arguments -C "$args[@]" \ +_arguments -s -S -C "$args[@]" \ '1:database:->databases' \ '*:key:->keys' && ret=0 case $state in services) - services=( /lib/libnss*(-.:fr:t:s/libnss_//) ) - _wanted services expl service compadd ${services%-*} && ret=0 + # @todo GNU getent supports both `-s svc` and `-s db:svc`; we only complete + # the former here + services=( {,/usr}/lib/{,*-linux-gnu/}libnss_*(N-.:fr:t:s/libnss_//) ) + _wanted services expl 'service or database:service' \ + compadd ${(u)services%-*} \ + && ret=0 ;; databases) if [[ $is_gnu = gnu ]]; then @@ -46,6 +50,13 @@ case $state in aliases|passwd|shadow|group) _wanted keys expl key compadd ${keys%%:*} && ret=0 ;; + utmpx) + if (( CURRENT > 3 )); then + _files && ret=0 + else + _wanted keys expl key compadd active lastlogin log && ret=0 + fi + ;; *) _message -e keys key;; esac ;; diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index b3e54f7f9..97ab26512 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -53,7 +53,7 @@ _git-add () { ignore_missing='--ignore-missing[check if files (even missing) are ignored in dry run]' fi - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '(-n --dry-run)'{-n,--dry-run}'[do not actually add files; only show which ones would be added]' \ '(-v --verbose)'{-v,--verbose}'[show files as they are added]' \ '(-f --force)'{-f,--force}'[allow adding otherwise ignored files]' \ @@ -100,7 +100,7 @@ _git-am () { # TODO: --patch-format is undocumented. # TODO: --rerere-autoupdate and --no-rerere-autoupdate are # undocumented (and not implemented here). - _arguments -S \ + _arguments -s -S $endopt \ '(-s --signoff)'{-s,--signoff}'[add Signed-off-by: line to the commit message]' \ '(-S --gpg-sign --no-gpg-sign)'{-S-,--gpg-sign=-}'[GPG-sign the commit]::key id' \ "(-S --gpg-sign --no-gpg-sign)--no-gpg-sign[don't GPG-sign the commit]" \ @@ -155,7 +155,7 @@ _git-archive () { esac fi - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '--format=-[format of the resulting archive]:archive format:__git_archive_formats' \ '(- :)'{-l,--list}'[list available archive formats]' \ '(-v --verbose)'{-v,--verbose}'[report progress to stderr]' \ @@ -177,18 +177,6 @@ _git-archive () { return ret } -(( $+functions[_git-applymbox] )) || -_git-applymbox () { - _arguments -A '-*' \ - '-k[do not modify "Subject:" header]' \ - '-m[apply patches with "git-apply" and fail if patch is unclean]' \ - '-q[apply patches interactively]' \ - '-u[encode commit information in UTF-8]' \ - '(1)-c[restart command after fixing an unclean patch]:patch:_files -g ".dotest/0*"' \ - ':mbox file:_files' \ - '::signoff file:__git_signoff_file' -} - (( $+functions[_git-bisect] )) || _git-bisect () { # TODO: next subcommand is undocumented. Git-bisect.sh mentions that the @@ -294,9 +282,9 @@ _git-bisect () { _git-branch () { declare l c m d e - l='--color --no-color -r --remotes -a -v --verbose --abbrev --no-abbrev --list --points-at --sort' + l='--color --no-color -r --remotes -a -v --verbose --abbrev --no-abbrev -l --list --points-at --sort' c='--create-reflog -f --force -t --track --no-track -u --set-upstream --set-upstream-to --unset-upstream --contains --no-contains --merged --no-merged' - m='-c --copy -C -m --move -M --edit-description' + m='-c --copy -C -m --move -M --edit-description --show-current' d='-d --delete -D' declare -a dependent_creation_args @@ -326,17 +314,18 @@ _git-branch () { '::new branch name:__git_branch_names') fi - _arguments -S -s \ + _arguments -S -s $endopt \ "($c $m $d --no-color :)--color=-[turn on branch coloring]:: :__git_color_whens" \ "($c $m $d : --color)--no-color[turn off branch coloring]" \ - "($c $m $d --no-column)"'--column=[display tag listing in columns]:column.branch option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \ + "($c $m $d --no-column)--column=-[display tag listing in columns]:: :_git_column_layouts" \ "($c $m $d --column)--no-column[don't display in columns]" \ - "($c $m $d )*--list[list only branches matching glob]:pattern" \ + "($c $m $d)*"{-l,--list}'[list only branches matching glob]:pattern' \ "($c $m -a)"{-r,--remotes}'[list or delete only remote-tracking branches]' \ "($c $m $d : -r --remotes)-a[list both remote-tracking branches and local branches]" \ "($c $m $d : -v -vv --verbose)"{-v,-vv,--verbose}'[show SHA1 and commit subject line for each head]' \ "($c $m $d :)--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length" \ "($c $m $d :)--no-abbrev[don't abbreviate sha1s]" \ + "(- :)--show-current[show current branch name]" \ "($l $m $d)--create-reflog[create the branch's reflog]" \ "($l $m $d -f --force)"{-f,--force}'[force the creation of a new branch]' \ "($l $m $d -t --track)"{-t,--track}'[setup configuration so that pull merges from the start point]' \ @@ -418,9 +407,15 @@ _git-bundle () { return ret } +(( $+functions[_git-version] )) || +_git-version () { + _arguments -S $endopt \ + '--build-options[also print build options]' +} + (( $+functions[_git-check-ignore] )) || _git-check-ignore () { - _arguments \ + _arguments -s -S $endopt \ '(-q --quiet)'{-q,--quiet}'[do not output anything, just set exit status]' \ '(-v --verbose)'{-v,--verbose}'[output details about the matching pattern (if any) for each pathname]' \ '--stdin[read file names from stdin instead of from the command-line]' \ @@ -432,7 +427,7 @@ _git-check-ignore () { (( $+functions[_git-check-mailmap] )) || _git-check-mailmap () { - _arguments \ + _arguments -S $endopt \ '--stdin[read contacts from stdin after those given on the command line]' } @@ -450,24 +445,27 @@ _git-checkout () { declare -A opt_args _arguments -C -s \ - '(-q --quiet --progress)'{-q,--quiet}'[suppress progress reporting]' \ + '(-q --quiet)'{-q,--quiet}'[suppress progress reporting]' \ '(-f --force -m --merge --conflict --patch)'{-f,--force}'[force branch switch/ignore unmerged entries]' \ '(-q --quiet -2 --ours -3 --theirs --patch)'{-2,--ours}'[check out stage #2 for unmerged paths]' \ '(-q --quiet -2 --ours -3 --theirs --patch)'{-3,--theirs}'[check out stage #3 for unmerged paths]' \ - '( -B --orphan -2 --ours -3 --theirs --conflict --patch --detach)-b+[create a new branch based at given commit]: :__git_branch_names' \ - '(-b --orphan -2 --ours -3 --theirs --conflict --patch --detach)-B+[create or update branch based at given commit]: :__git_branch_names' \ - '(-t --track --orphan --patch --detach)'{-t,--track}'[set up configuration so pull merges from the base commit]' \ + '( -B --orphan -2 --ours -3 --theirs --conflict --patch -d --detach)-b+[create a new branch based at given commit]: :__git_branch_names' \ + '(-b --orphan -2 --ours -3 --theirs --conflict --patch -d --detach)-B+[create or update branch based at given commit]: :__git_branch_names' \ + '(-t --track --orphan --patch -d --detach)'{-t,--track}'[set up configuration so pull merges from the base commit]' \ '(--patch)--no-track[override the branch.autosetupmerge configuration variable]' \ $new_branch_reflog_opt \ - '(-b -B -t --track --patch --orphan)--detach[detach the HEAD at named commit]' \ - '(-b -B -t --track --patch --detach)--orphan=[create a new orphan branch based at given commit]: :__git_branch_names' \ + '(-b -B -t --track --patch --orphan -d --detach)'{-d,--detach}'[detach the HEAD at named commit]' \ + '(-b -B -t --track --patch -d --detach)--orphan=[create a new orphan branch based at given commit]: :__git_branch_names' \ '(-q --quiet -f --force -m --merge --conflict --patch)'{-m,--merge}'[3way merge current branch, working tree and new branch]' \ '(-q --quiet -f --force -m --merge --patch)--conflict=[same as --merge, using given merge style]:style:(merge diff3)' \ '(-)'{-p,--patch}'[interactively select hunks in diff between given tree-ish and working tree]' \ "--ignore-skip-worktree-bits[don't limit pathspecs to sparse entries only]" \ + "--no-guess[don't second guess 'git checkout <no-such-branch>']" '!(--no-guess)--guess' \ "--ignore-other-worktrees[don't check if another worktree is holding the given ref]" \ '--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \ - '(-q --quiet)--progress[force progress reporting]' \ + '--no-overlay[remove files from index or working tree that are not in the tree-ish]' \ + '(-q --quiet --progress)--no-progress[suppress progress reporting]' \ + '--progress[force progress reporting]' \ '(-)--[start file arguments]' \ '*:: :->branch-or-tree-ish-or-file' && ret=0 @@ -481,7 +479,6 @@ _git-checkout () { if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then # TODO: Allow A...B local \ - remote_branch_noprefix_arg='remote-branch-names-noprefix::__git_remote_branch_names_noprefix' \ tree_ish_arg='tree-ishs::__git_commits_prefer_recent' \ file_arg='modified-files::__git_modified_files' @@ -489,13 +486,13 @@ _git-checkout () { _alternative $tree_ish_arg && ret=0 elif [[ -n $opt_args[(I)--track] ]]; then _alternative remote-branches::__git_remote_branch_names && ret=0 - elif [[ -n ${opt_args[(I)--ours|--theirs|-m|--conflict|--patch]} ]]; then + elif [[ -n ${opt_args[(I)--ours|--theirs|-m|--conflict|--patch|--no-guess]} ]]; then _alternative $tree_ish_arg $file_arg && ret=0 else _alternative \ $file_arg \ $tree_ish_arg \ - $remote_branch_noprefix_arg \ + 'remote-branch-names-noprefix::__git_remote_branch_names_noprefix' \ && ret=0 fi @@ -519,7 +516,9 @@ _git-cherry-pick () { _arguments \ '(- :)--quit[end revert or cherry-pick sequence]' \ '(- :)--continue[resume revert or cherry-pick sequence]' \ + '(- :)--skip[skip current commit and continue]' \ '(- :)--abort[cancel revert or cherry-pick sequence]' \ + '--cleanup=[specify how to strip spaces and #comments from message]:mode:_git_cleanup_modes' \ '--allow-empty[preserve initially empty commits]' \ '--allow-empty-message[allow replaying a commit with an empty message]' \ '--keep-redundant-commits[keep cherry-picked commits that will become empty]' \ @@ -547,7 +546,7 @@ _git-clean () { local curcontext=$curcontext state line ret=1 declare -A opt_args - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '-d[also remove untracked directories]' \ '(-f --force)'{-f,--force}'[required when clean.requireForce is true (default)]' \ '(-i --interactive)'{-i,--interactive}'[show what would be done and clean files interactively]' \ @@ -607,7 +606,7 @@ _git-clone () { # TODO: Argument to -o should be a remote name. # TODO: Argument to -b should complete branch names in the repository being # cloned (see __git_references()) - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '(-l --local --no-local)'{-l,--local}'[clone locally, hardlink refs and objects if possible]' \ '(-l --local --no-local)--no-local[override --local, as if file:/// URL was given]' \ '--no-hardlinks[copy files instead of hardlinking when doing a local clone]' \ @@ -637,9 +636,11 @@ _git-clone () { '--recursive[initialize all contained submodules]' \ '--recurse-submodules=-[initialize submodules in the clone]::file:__git_files' \ '--separate-git-dir[place .git dir outside worktree]:path to .git dir:_path_files -/' \ + \*--server-option='[send specified string to the server when using protocol version 2]:option' \ '(-4 --ipv4 -6 --ipv6)'{-4,--ipv4}'[use IPv4 addresses only]' \ '(-4 --ipv4 -6 --ipv6)'{-6,--ipv6}'[use IPv6 addresses only]' \ '--filter=[object filtering]:filter:_git_rev-list_filters' \ + '--remote-submodules[any cloned submodules will use their remote-tracking branch]' \ ': :->repository' \ ': :_directories' && ret=0 @@ -657,15 +658,15 @@ _git-clone () { } (( $+functions[_git-column] )) || -_git-column () { +_git-column() { _arguments -s \ - '--command=[look up layout mode using config vars column.<name> and column.ui]' \ - '--mode=[specify layout mode. See configuration variable column.ui for option syntax]' \ - '--raw-mode=[same as --mode but take mode encoded as a number]' \ - '--width=[specify the terminal width]' \ - '--indent=[string to be printed at the beginning of each line]' \ - '--nl[string to be printed at the end of each line, including newline character]' \ - '--padding[the number of spaces between columns. One space by default]' + '--command=[look up layout mode using in config vars using specified command]:command:(branch clean status tag ui)' \ + '--mode=[specify layout mode]: :_git_column_layouts' \ + '--raw-mode=[same as --mode but take mode encoded as a number]:mode' \ + "--width=[specify the terminal width]:width [${COLUMNS:-80}]" \ + '--indent=[specify string to be printed at the beginning of each line]:string' \ + '--nl=[specify string to be printed at the end of each line, including newline character]:string' \ + '--padding=[specify number of spaces between columns]:spaces [1]' } (( $+functions[_git-commit] )) || @@ -681,7 +682,7 @@ _git-commit () { fi # TODO: --interactive isn't explicitly listed in the documentation. - _arguments -S -s \ + _arguments -S -s $endopt \ '(-a --all --interactive -o --only -i --include *)'{-a,--all}'[stage all modified and deleted paths]' \ '--fixup=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_recent_commits' \ '--squash=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_recent_commits' \ @@ -699,11 +700,7 @@ _git-commit () { '(-n --no-verify)'{-n,--no-verify}'[bypass pre-commit and commit-msg hooks]' \ '--allow-empty[allow recording an empty commit]' \ '--allow-empty-message[allow recording a commit with an empty message]' \ - '--cleanup=[specify how the commit message should be cleaned up]:mode:((verbatim\:"do not change the commit message at all" - whitespace\:"remove leading and trailing whitespace lines" - strip\:"remove both whitespace and commentary lines" - scissors\:"same as whitespace but cut from scissor line" - default\:"act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise"))' \ + '--cleanup=[specify how the commit message should be cleaned up]:mode:_git_cleanup_modes' \ '(-e --edit --no-edit)'{-e,--edit}'[edit the commit message before committing]' \ '(-e --edit --no-edit)--no-edit[do not edit the commit message before committing]' \ '--no-post-rewrite[bypass the post-rewrite hook]' \ @@ -714,7 +711,7 @@ _git-commit () { all\:"show individual files in untracked directories"))' \ '(-q --quiet -v --verbose)'{-v,--verbose}'[show unified diff of all file changes]' \ '(-q --quiet -v --verbose)'{-q,--quiet}'[suppress commit summary message]' \ - '--dry-run[only show list of paths that are to be commited or not, and any untracked]' \ + '--dry-run[only show list of paths that are to be committed or not, and any untracked]' \ '( --no-status)--status[include the output of git status in the commit message template]' \ '(--status )--no-status[do not include the output of git status in the commit message template]' \ '(-S --gpg-sign --no-gpg-sign)'{-S-,--gpg-sign=}'[GPG-sign the commit]::key id' \ @@ -732,7 +729,7 @@ _git-commit () { (( $+functions[_git-describe] )) || _git-describe () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(*)--dirty=-[describe HEAD, adding mark if dirty]::mark' \ '(*)--broken=-[describe HEAD, adding mark if broken]::mark' \ '--all[use any ref found in "$GIT_DIR/refs/"]' \ @@ -759,7 +756,7 @@ _git-diff () { __git_setup_diff_options __git_setup_diff_stage_options - _arguments -C -s \ + _arguments -C -s $endopt \ $* \ $diff_options \ '(--exit-code)--quiet[disable all output]' \ @@ -863,7 +860,7 @@ _git-fetch () { local -a fetch_options __git_setup_fetch_options - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ $fetch_options \ '--shallow-since=[deepen history of shallow repository based on time]:time' \ '*--shallow-exclude=[deepen history of shallow clone by excluding revision]:revision' \ @@ -874,6 +871,7 @@ _git-fetch () { \*{-o+,--server-option=}'[send specified string to the server when using protocol version 2]:option' \ '--negotiation-tip=[only report refs reachable from specified object to the server]:commit:__git_commits' \ '--filter=[object filtering]:filter:_git_rev-list_filters' \ + "--auto-gc[run 'gc --auto' after fetching]" \ '*:: :->repository-or-group-or-refspec' && ret=0 case $state in @@ -904,7 +902,7 @@ _git-format-patch () { # TODO: -- is wrong. # TODO: Should filter out --name-only, --name-status, and --check from # $diff_options. - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ $diff_options \ '--[limit the number of patches to prepare]: :__git_guard_number "number of patches to prepare"' \ '(-o --output-directory --stdout)'{-o+,--output-directory=}'[store resulting files in given directory]: :_directories' \ @@ -941,6 +939,9 @@ _git-format-patch () { '--root[treat the revision argument as a range]' \ '--zero-commit[output all-zero hash in From header]' \ '--progress[show progress while generating patches]' \ + '--interdiff=[insert interdiff against previous patch series in cover letter or single patch]:reference to tip of previous series:__git_revisions' \ + '--range-diff=[insert range-diff against previous patch series in cover letter or single patch]:reference to tip ot previous series:__git_revisions' \ + '--creation-factor=[for range-diff, specify weighting for creation]:weighting (percent)' \ ': :->commit-or-commit-range' && ret=0 case $state in @@ -958,7 +959,7 @@ _git-format-patch () { (( $+functions[_git-gc] )) || _git-gc () { - _arguments -S -s \ + _arguments -S -s $endopt \ '--aggressive[more aggressively optimize]' \ '--auto[check whether housekeeping is required]' \ '( --no-prune)--prune=-[prune loose objects older than given date]::date [2 weeks ago]:__git_datetimes' \ @@ -983,7 +984,7 @@ _git-grep () { declare -A opt_args # TODO: Need to implement -<num> as a shorthand for -C<num> - _arguments -C -A '-*' \ + _arguments -C -A '-*' $endopt \ '(-O --open-files-in-pager --no-index)--cached[search blobs registered in index file instead of working tree]' \ '(--cached)--no-index[search files in current directory, not just tracked files]' \ '(--exclude-standard)--no-exclude-standard[search also in ignored files]' \ @@ -996,6 +997,7 @@ _git-grep () { "(--textconv --no-textconv)--no-textconv[don't honor textconv filter settings]" \ '(-i --ignore-case)'{-i,--ignore-case}'[ignore case when matching]' \ "-I[don't match pattern in binary files]" \ + '!-r' '!--recursive' \ '--max-depth=[descend at most given levels of directories]: :__git_guard_number depth' \ '(-w --word-regexp)'{-w,--word-regexp}'[match only whole words]' \ '(-v --invert-match)'{-v,--invert-match}'[select non-matching lines]' \ @@ -1132,7 +1134,7 @@ _git-gui () { (( $+functions[_git-init] )) || _git-init () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(-q --quiet)'{-q,--quiet}'[do not print any results to stdout]' \ '--bare[create a bare repository]' \ '--template=[directory to use as a template for the object database]: :_directories' \ @@ -1143,7 +1145,7 @@ _git-init () { (( $+functions[_git-interpret-trailers] )) || _git-interpret-trailers() { - _arguments \ + _arguments -S $endopt \ '--in-place[edit files in place]' \ '--trim-empty[trim empty trailers]' \ '--where[specify where to place the new trailer]' \ @@ -1153,6 +1155,7 @@ _git-interpret-trailers() { "--only-input[don't apply config rules]" \ '--unfold[join whitespace-continued values]' \ '--parse[set parsing options]' \ + "--no-divider[don't treat --- as the end of the commit message]" \ '--trailer[specify trailer(s) to add]' \ '*:file:_files' } @@ -1166,7 +1169,7 @@ _git-log () { __git_setup_log_options __git_setup_revision_options - _arguments -C -s \ + _arguments -C -s $endopt \ $log_options \ $revision_options \ '(-)--[start file arguments]' \ @@ -1190,7 +1193,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 @@ -1211,17 +1214,18 @@ _git-merge () { __git_setup_merge_options local -a git_commit_opts=(--all --not HEAD --not) - _arguments -S -s \ + _arguments -S -s $endopt \ $merge_options \ \*{-m+,--message=}'[set the commit message to be used for the merge commit]:merge message' \ \*{-F+,--file=}'[read commit message from a file]:file' \ '(--edit --no-edit)-e[open an editor to change the commit message]' \ '( --no-rerere-autoupdate)--rerere-autoupdate[allow the rerere mechanism to update the index]' \ '(--rerere-autoupdate )--no-rerere-autoupdate[do not allow the rerere mechanism to update the index]' \ - '--abort[restore the original branch and abort the merge operation]' \ - '--continue[continue the current in-progress merge]' \ + '(--quit --continue)--abort[restore the original branch and abort the merge operation]' \ + '(--abort --continue)--quit[--abort but leave index and working tree alone]' \ + '(--abort --quit)--continue[continue the current in-progress merge]' \ '--progress[force progress reporting]' \ - '--verify[verify commit-msg hook]' \ + '--no-verify[verify commit-msg hook]' \ '*: : __git_commits -O expl:git_commit_opts' } @@ -1230,7 +1234,7 @@ _git-mv () { local curcontext=$curcontext state line ret=1 declare -A opt_args - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '(-v --verbose)'{-v,--verbose}'[output additional information]' \ '(-f --force)'{-f,--force}'[rename/move even if targets exist]' \ '-k[skip rename/move that would lead to errors]' \ @@ -1254,7 +1258,7 @@ _git-notes () { local curcontext=$curcontext state line ret=1 declare -A opt_args - _arguments -C \ + _arguments -C $endopt \ '--ref=[manipulate the notes tree in given ref]: :__git_notes_refs' \ ': :->command' \ '*:: :->option-or-argument' && ret=0 @@ -1283,13 +1287,13 @@ _git-notes () { case $line[1] in (list|show) - _arguments \ + _arguments -S $endopt \ ': :__git_commits' && ret=0 ;; (add) # TODO: Only complete commits that don't have notes already, unless # -f or --force has been given. - _arguments -S -s \ + _arguments -S -s $endopt \ '*'{-m+,--message=}'[use given note message]:message' \ '*'{-F+,--file=}'[take note message from given file]:note message file:_files' \ '(-C --reuse-message)'{-C+,--reuse-message=}'[take note message from given blob object]: :__git_blobs' \ @@ -1299,7 +1303,7 @@ _git-notes () { ;; (copy) # TODO: --for-rewrite is undocumented. - _arguments -S -s \ + _arguments -S -s $endopt \ '(-f --force)'{-f,--force}'[replace existing note]' \ '(:)--stdin[read objects from stdin]' \ '(:--stdin)--for-rewrite=[load rewriting config for given command]:command:(amend rebase)' \ @@ -1307,10 +1311,10 @@ _git-notes () { ': :__git_commits' && ret=0 ;; (edit) - _arguments --allow-empty ':object:__git_commits' && ret=0 + _arguments -S $endopt --allow-empty ':object:__git_commits' && ret=0 ;; (merge) - _arguments -S -s \ + _arguments -S -s $endopt \ '(-s --strategy)--abort[abort an in-progress notes merge]' \ '(-s --strategy)--commit[finalize an in-progress notes merge]' \ '(-q --quiet)'{-q,--quiet}'[be quiet]' \ @@ -1319,24 +1323,27 @@ _git-notes () { ': :__git_notes_refs' && ret=0 ;; (prune) - _arguments -s \ + _arguments -s -S $endopt \ '(-v --verbose)'{-v,--verbose}'[be more verbose]' \ '(-n --dry-run)'{-n,--dry-run}"[don't remove anything, just report what would be deleted]" && ret=0 ;; (remove) - _arguments --ignore-missing --stdin ':object:__git_commits' && ret=0 + _arguments -S $endopt --ignore-missing --stdin ':object:__git_commits' && ret=0 ;; (append) - _arguments -S -s \ + _arguments -S -s $endopt \ '*'{-m+,--message=}'[use given note message]:message' \ '*'{-F+,--file=}'[take note message from given file]:note message file:_files' \ '(-C --reuse-message)'{-C+,--reuse-message=}'[take note message from given blob object]: :__git_blobs' \ '(-c --reedit-message)'{-c+,--reedit-message=}'[take note message from given blob object and edit it]: :__git_blobs' \ ': :__git_commits' && ret=0 ;; - (*) + (get-ref) _nothing ;; + (*) + _default && ret=0 + ;; esac ;; esac @@ -1350,7 +1357,7 @@ _git-pull () { __git_setup_merge_options __git_setup_fetch_options - _arguments \ + _arguments -S -s $endopt \ $merge_options \ '(-r --rebase --no-rebase)'{-r=-,--rebase=-}'[perform a rebase after fetching]::rebase after fetching:(( true\:"rebase after fetching" @@ -1380,7 +1387,7 @@ _git-push () { # only complete files on the local end, not the remote end. Still, it may be # helpful to get some sort of completion going, perhaps modifying the path # later on to match the remote end. - _arguments -S -s \ + _arguments -S -s $endopt \ '--all[push all refs under refs/heads/]' \ '--prune[remove remote branches that do not have a local counterpart]' \ '--mirror[push all refs under refs/heads/ and refs/tags/ and delete non-existing refs]' \ @@ -1435,7 +1442,7 @@ _git-range-diff () { local -a diff_options __git_setup_diff_options - _arguments -s \ + _arguments -s -S $endopt \ '--creation-factor=[specify weighting for creation]:weighting (percent)' \ '--no-dual-color[use simple diff colors]' \ $diff_options \ @@ -1454,7 +1461,7 @@ _git-rebase () { '(--autosquash )--no-autosquash[do not check for auto-squash boundaries]') fi - _arguments \ + _arguments -s -S $endopt \ - actions \ '(-)--continue[continue after resolving merge conflict]' \ '(-)--abort[abort current rebase]' \ @@ -1470,7 +1477,8 @@ _git-rebase () { '*'{-X+,--strategy-option=}'[pass merge-strategy-specific option to merge strategy]:option' \ '(-q --quiet -v --verbose --stat -n --no-stat)'{-q,--quiet}'[suppress all output]' \ '(-q --quiet -v --verbose --stat -n --no-stat)'{-v,--verbose}'[output additional information]' \ - '--rerere-autoupdate[allow rerere to update index with resolved conflicts]' \ + '(-n --no-stat)'{-n,--no-stat}"[don't show diffstat of what changed upstream]" \ + '--rerere-autoupdate[update the index with reused conflict resolution if possible]' \ '--no-verify[bypass the pre-rebase hook]' \ '-C-[ensure that given lines of surrounding context match]: :__git_guard_number "lines of context"' \ '(-f --force-rebase)'{-f,--force-rebase}'[force rebase even if current branch descends from commit rebasing onto]' \ @@ -1479,19 +1487,21 @@ _git-rebase () { '(-i --interactive)--committer-date-is-author-date[use author date as committer date]' \ '(-i --interactive --ignore-whitespace --whitespace --committer-date-is-author-date)'{-i,--interactive}'[make a list of commits to be rebased and open in $EDITOR]' \ '(-r --rebase-merges)'{-r-,--rebase-merges=-}'[try to rebase merges instead of skipping them]::option:(rebase-cousins no-rebase-cousins)' \ - '(-p --preserve-merges --interactive)'{-p,--preserve-merges}'[try to recreate merges instead of ignoring them]' \ + '!(-p --preserve-merges --interactive)'{-p,--preserve-merges} \ {-x+,--exec=}'[with -i\: append "exec <cmd>" after each line]:command:_command_names -e' \ '(-k --keep-empty)'{-k,--keep-empty}'[keep empty commits in the result]' \ '--allow-empty-message[allow rebasing commits with empty messages]' \ '(1)--root[rebase all reachable commits]' \ $autosquash_opts \ '(--autostash --no-autostash)--autostash[stash uncommitted changes before rebasing and apply them afterwards]' \ - '(--autostash --no-autostash)--no-autostash[do not stash uncommitted changes before rebasing and apply them afterwards]' \ + "(--autostash --no-autostash)--no-autostash[don't stash uncommitted changes before rebasing and apply them afterwards]" \ '--fork-point[use merge-base --fork-point to refine upstream]' \ '--ignore-date[use current timestamp for author date]' \ '--signoff[add Signed-off-by: line to the commit message]' \ '--no-ff[cherry-pick all rebased commits with --interactive, otherwise synonymous to --force-rebase]' \ - '--onto=[start new branch with HEAD equal to given revision]:newbase:__git_revisions' \ + '(--keep-base)--onto=[start new branch with HEAD equal to given revision]:newbase:__git_revisions' \ + '(--onto)--keep-base[use the merge-base of upstream and branch as the current base]' \ + "--reschedule-failed-exec[automatically re-schedule any 'exec' that fails]" \ ':upstream branch:__git_revisions' \ '::working branch:__git_revisions' } @@ -1501,7 +1511,7 @@ _git-reset () { local curcontext=$curcontext state line ret=1 typeset -A opt_args - _arguments -C -s -S \ + _arguments -C -s -S $endopt \ '( --mixed --hard --merge --keep -p --patch -- *)--soft[do not touch the index file nor the working tree]' \ '(--soft --hard --merge --keep -p --patch -- *)--mixed[reset the index but not the working tree (default)]' \ '(--soft --hard --merge --keep -p --patch -- *)'{-N,--intent-to-add}'[record only the fact that removed paths will be added later]' \ @@ -1532,12 +1542,58 @@ _git-reset () { return ret } +(( $+functions[_git-restore] )) || +_git-restore() { + local curcontext="$curcontext" state line expl ret=1 + local -A opt_args + + _arguments -C -s -S $endopt \ + '(-s --source)'{-s,--source}'[specify which tree-ish to checkout from]:source tree:->sources' \ + '(-S --staged)'{-S,--staged}'[restore the index]' \ + '(-W --worktree)'{-W,--worktree}'[restore the working tree (default)]' \ + '--ignore-unmerged[ignore unmerged entries]' \ + '--overlay[never remove files when restoring]' '!(--overlay)--no-overlay' \ + '(-q --quiet --no-progress)'{-q,--quiet}'[suppress feedback messages]' \ + '--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \ + '(-q --quiet --progress)--no-progress[suppress progress reporting]' \ + '(--no-progress)--progress[force progress reporting]' \ + '(-m --merge)'{-m,--merge}'[perform a 3-way merge with the new branch]' \ + '--conflict=[change how conflicting hunks are presented]:conflict style [merge]:(merge diff3)' \ + '(-2 --ours -3 --theirs -m --merge)'{-2,--ours}'[checkout our version for unmerged files]' \ + '(-2 --ours -3 --theirs -m --merge)'{-3,--theirs}'[checkout their version for unmerged files]' \ + '(-p --patch)'{-p,--patch}'[select hunks interactively]' \ + "--ignore-skip-worktree-bits[don't limit pathspecs to sparse entries only]" \ + '*:path spec:->pathspecs' && ret=0 + + case $state in + pathspecs) + if [[ -z ${opt_args[(I)-s|--source|-S|--staged]} ]] && + # use index as a default base unless -S is specified + __git_ignore_line __git_modified_files + then + ret=0 + else + __git_ignore_line __git_tree_files ${PREFIX:-.} ${(Qv)opt_args[(i)-s|--source]:-HEAD} && ret=0 + fi + ;; + sources) + # if a path has already been specified, use it to select commits + git_commit_opts=(-- $line) + __git_commits_prefer_recent -O expl:git_commit_opts && ret=0 + ;; + esac + + return ret +} + (( $+functions[_git-revert] )) || _git-revert () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(- :)--quit[end revert or cherry-pick sequence]' \ '(- :)--continue[resume revert or cherry-pick sequence]' \ '(- :)--abort[cancel revert or cherry-pick sequence]' \ + '(- :)--skip[skip current commit and continue]' \ + '--cleanup=[specify how to strip spaces and #comments from message]:mode:_git_cleanup_modes' \ '(-e --edit --no-edit)'{-e,--edit}'[edit the commit before committing the revert]' \ '(-e --edit --no-edit)--no-edit[do not edit the commit message before committing the revert]' \ '(-m --mainline)'{-m+,--mainline=}'[pick which parent is mainline]:parent number' \ @@ -1556,7 +1612,7 @@ _git-rm () { local curcontext=$curcontext state line ret=1 declare -A opt_args - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '(-f --force)'{-f,--force}'[override the up-to-date check]' \ '(-n --dry-run)'{-n,--dry-run}'[do not actually remove the files, just show if they exist in the index]' \ '-r[allow recursive removal when a leading directory-name is given]' \ @@ -1584,7 +1640,7 @@ _git-shortlog () { # TODO: should take all arguments found in setup_revisions() (probably more # or less what git-rev-list takes). - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '(: -)'{-h,--help}'[print a short usage message and exit]' \ '(-n --numbered)'{-n,--numbered}'[sort according to number of commits]' \ '(-s --summary)'{-s,--summary}'[suppress commit description]' \ @@ -1621,7 +1677,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 @@ -1646,7 +1702,7 @@ _git-show () { __git_setup_log_options __git_setup_revision_options - _arguments -C -s \ + _arguments -C -s $endopt \ $log_options \ $revision_options \ '(-q --quiet)'{-q,--quiet}'[suppress diff output]' \ @@ -1708,12 +1764,12 @@ _git-stash () { case $line[1] in (save) - _arguments -S \ + _arguments -S $endopt \ $save_arguments \ ':: :_guard "([^-]?#|)" message' && ret=0 ;; (push) - _arguments -S \ + _arguments -S $endopt \ $save_arguments \ '(-m --message)'{-m,--message}'[specify stash description]' \ ':: :__git_modified_files' && ret=0 @@ -1734,12 +1790,12 @@ _git-stash () { local diff_options __git_setup_diff_options - _arguments -S -s \ + _arguments -S -s $endopt \ $diff_options \ ':: :__git_stashes' && ret=0 ;; (pop|apply) - _arguments \ + _arguments -S $endopt \ '--index[try to reinstate the changes added to the index as well]' \ '(-q --quiet)'{-q,--quiet}'[suppress all output]' \ ':: :__git_stashes' && ret=0 @@ -1753,7 +1809,7 @@ _git-stash () { _nothing ;; (drop) - _arguments \ + _arguments -S $endopt \_git-notes '(-q --quiet)'{-q,--quiet}'[suppress all output]' \ ':: :__git_stashes' && ret=0 ;; @@ -1778,7 +1834,7 @@ _git-status () { branch_opts=('(-b --branch)'{-b,--branch}'[show branch and tracking info]') fi - _arguments -S -s \ + _arguments -S -s $endopt \ '(-s --short --column --no-column --show-stash)'{-s,--short}'[output in short format]' \ $branch_opts \ '(-s --short)--porcelain=-[produce machine-readable output]:version:(v1)' \ @@ -1791,7 +1847,7 @@ _git-status () { '--ignore-submodules[ignore changes to submodules]:: :__git_ignore_submodules_whens' \ '--ignored=-[show ignored files as well]:mode [traditional]:(traditional matching no)' \ '(-z --null --column --no-column)'{-z,--null}'[use NUL termination on output]' \ - '(--no-column -z --null)--column=-[display in columns]::column.status option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \ + '(--no-column -z --null)--column=-[display in columns]:: :_git_column_layouts' \ "(--column)--no-column[don't display in columns]" \ "(--no-renames -M --find-renames)--no-renames[don't detect renames]" \ '(--no-renames -M --find-renames)-M[detect renames]' \ @@ -1819,6 +1875,7 @@ _git-submodule () { init:'initialize a submodule' deinit:'unregister a submodule' update:'update a submodule' + set-branch:'set the default remote tracking branch for the submodule' summary:'show commit summary between given commit and working tree/index' foreach:'evaluate shell command in each checked-out submodule' absorbgitdirs:'move the git directory of a submodule into its superprojects' @@ -1875,7 +1932,13 @@ _git-submodule () { '--force[discard local changes by checking out the current up-to-date version]' \ '--init[initialize uninitialized submodules]' \ '*: :__git_ignore_line_inside_arguments __git_submodules' && ret=0 - ;; + ;; + (set-branch) + _arguments -C -A '-*' \ + '(-d --default)'{-d,--default}'[remove config key to cause the tracking branch to default to master]' \ + '(-b --branch)'{-b,--branch=}'[specify the remote branch]:remote branch' \ + '1:path:_directories' + ;; (summary) _arguments -C -A '-*' \ '(-q --quiet)'{-q,--quiet}'[suppress all output]' \ @@ -2015,9 +2078,61 @@ _git-subtree () { return ret } +(( $+functions[_git-switch] )) || +_git-switch() { + local curcontext="$curcontext" state line expl ret=1 + local -A opt_args + + _arguments -C -s -S $endopt \ + '(-c --create -C --force-create -d --detach --orphan --ignore-other-worktrees 1)'{-c,--create}'[create and switch to a new branch]:branch:->branches' \ + '(-c --create -C --force-create -d --detach --orphan --ignore-other-worktrees 1)'{-C,--force-create}'[create/reset and switch to a branch]:branch:->branches' \ + "(--guess --orphan 2)--no-guess[don't second guess 'git switch <no-such-branch>']" \ + "(--no-guess -t --track -d --detach --orphan 2)--guess[second guess 'git switch <no-such-branch> (default)]" \ + '(-f --force --discard-changes -m --merge --conflict)'{-f,--force,--discard-changes}'[throw away local modifications]' \ + '(-q --quiet --no-progress)'{-q,--quiet}'[suppress feedback messages]' \ + '--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \ + '(-q --quiet --progress)--no-progress[suppress progress reporting]' \ + '--progress[force progress reporting]' \ + '(-m --merge --discard-changes --orphan)'{-m,--merge}'[perform a 3-way merge with the new branch]' \ + '(--discard-changes --orphan)--conflict=[change how conflicting hunks are presented]:conflict style [merge]:(merge diff3)' \ + '(-d --detach -c --create -C --force-create --ignore-other-worktrees --orphan --guess --no-guess 1)'{-d,--detach}'[detach HEAD at named commit]' \ + '(-t --track --no-track --guess --orphan 1)'{-t,--track}'[set upstream info for new branch]' \ + "(-t --track --guess --orphan 1)--no-track[don't set upstream info for a new branch]" \ + '(-c --create -C --force-create -d --detach --ignore-other-worktrees -m --merge --conflict -t --track --guess --no-track -t --track)--orphan[create new unparented branch]: :__git_branch_names' \ + '!--overwrite-ignore' \ + "(-c --create -C --force-create -d --detach --orphan)--ignore-other-worktrees[don't check if another worktree is holding the given ref]" \ + '1: :->branches' \ + '2:start point:->start-points' && ret=0 + + case $state in + branches) + if [[ -n ${opt_args[(i)--guess]} ]]; then + # --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 + _alternative \ + 'branches::__git_branch_names' \ + 'remote-branch-names-noprefix::__git_remote_branch_names_noprefix' && ret=0 + fi + ;; + start-points) + if [[ -n ${opt_args[(I)-t|--track|--no-track]} ]]; then + # with an explicit --track, stick to remote branches + # same for --no-track because it'd be meaningless with anything else + __git_heads_remote && ret=0 + else + __git_revisions && ret=0 + fi + ;; + esac + + return ret +} + (( $+functions[_git-tag] )) || _git-tag () { - _arguments \ + _arguments -s -S $endopt \ - creation \ '(-a --annotate -s --sign -u --local-user)'{-a,--annotate}'[create an unsigned, annotated tag]' \ '(-e --edit)'{-e,--edit}'[force edit of tag message]' \ @@ -2025,7 +2140,7 @@ _git-tag () { '(-a --annotate -s --sign)'{-u+,--local-user=}'[create a tag, annotated and signed with the given key]: :__git_gpg_secret_keys' \ '(-f --force)'{-f,--force}'[replace existing tag]' \ '--create-reflog[create a reflog]' \ - '--cleanup=[cleanup message]:mode:((verbatim\:"no cleanup" whitespace\:"remove leading and trailing whitespace" strip\:"remove leading and trailing whitespace and comments"))' \ + '--cleanup=[specify how to strip spaces and #comments from message]:mode:_git_cleanup_modes' \ '(-m --message -F --file)'{-F+,--file=}'[read tag message from given file]:message file:_files' \ '(-m --message -F --file)'{-m+,--message=}'[specify tag message]:message' \ ': :__git_tags' \ @@ -2036,7 +2151,7 @@ _git-tag () { - listing \ '-n+[limit line output of annotation]: :__git_guard_number "limit"' \ '(-l --list)'{-l,--list}'[list tags matching pattern]' \ - '(--no-column)--column=-[display tag listing in columns]::column.tag option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \ + '(--no-column)--column=-[display tag listing in columns]:: :_git_column_layouts' \ '(--column)--no-column[do not display in columns]' \ '*--contains=[only list tags that contain the specified commit]: :__git_commits' \ "*--no-contains=[only list tags that don't contain the specified commit]: :__git_commits" \ @@ -2087,7 +2202,7 @@ _git-worktree() { else args=( ':commit:__git_commits' ) fi - _arguments -S \ + _arguments -S $endopt \ '(-f --force)'{-f,--force}'[checkout branch even if already checked out in another worktree]' \ '(-B --detach)-b+[create a new branch]: :__git_branch_names' \ '(-b --detach)-B+[create or reset a branch]: :__git_branch_names' \ @@ -2097,16 +2212,16 @@ _git-worktree() { ':path:_directories' $args && ret=0 ;; (prune) - _arguments -S \ + _arguments -S $endopt \ '(-n --dry-run)'{-n,--dry-run}"[don't remove, show only]" \ '(-v --verbose)'{-v,--verbose}'[report pruned objects]' \ '--expire[expire objects older than specified time]:time' && ret=0 ;; (list) - _arguments -S '--porcelain[machine-readable output]' && ret=0 + _arguments -S $endopt '--porcelain[machine-readable output]' && ret=0 ;; (lock) - _arguments -C -S '--reason=[specify reason for locking]:reason' ': :->worktrees' && ret=0 + _arguments -C -S $endopt '--reason=[specify reason for locking]:reason' ': :->worktrees' && ret=0 ;; (move) _arguments -C \ @@ -2114,7 +2229,7 @@ _git-worktree() { ':location:_directories' && ret=0 ;; (remove) - _arguments -C -S '--force[remove working trees that are not clean or that have submodules]' \ + _arguments -C -S $endopt '--force[remove working trees that are not clean or that have submodules]' \ ': :->worktrees' && ret=0 ;; (unlock) @@ -2167,12 +2282,13 @@ _git-config () { value_arg=': :->value' fi - _arguments -C -S -s \ - '( --system --local -f --file --blob)--global[use user-global config file]' \ - '(--global --local -f --file --blob)--system[use system-wide config file]' \ - '(--global --system -f --file --blob)--local[use local config file]' \ - '(--global --system --local --blob)'{-f+,--file=}'[use given config file]:config file:_files' \ - '(--global --system --local -f --file)--blob=[read config from given blob object]:blob:__git_blobs' \ + _arguments -C -S -s $endopt \ + '( --system --local --worktree -f --file --blob)--global[use user-global config file]' \ + '(--global --local --worktree -f --file --blob)--system[use system-wide config file]' \ + '(--global --system --worktree -f --file --blob)--local[use local config file]' \ + '(--global --system --local -f --file --blob)--worktree[use per-worktree config file]' \ + '(--global --system --local --worktree --blob)'{-f+,--file=}'[use given config file]:config file:_files' \ + '(--global --system --local --worktree -f --file)--blob=[read config from given blob object]:blob:__git_blobs' \ '(-t --type --bool --int --bool-or-int --path --expiry-date)'{-t+,--type=}'[ensure that incoming and outgoing values are canonicalize-able as the given type]:type:(bool int bool-or-int path expiry-date color)' \ '(-t --type --int --bool-or-int --path --expiry-date)--bool[setting is a boolean]' \ '(-t --type --bool --bool-or-int --path --expiry-date)--int[setting is an integer]' \ @@ -2241,32 +2357,46 @@ __git_config_option-or-value () { # TODO: .path options should take absolute paths. declare -a git_options git_options=( + advice.fetchShowForcedUpdates:'show advice when git-fetch takes time to calculate forced updates::->bool:true' advice.pushNonFastForward:'show advice when git push refuses non-fast-forward refs::->bool:true' advice.pushUpdateRejected:'combined setting for advice.push*::->bool:true' advice.pushNonFFCurrent:'show advice when git push fails due to a non-fast-forward update to the current branch::->bool:true' - advice.pushNonFFDefault:'show advice to set push.default to "upstream" or "current" after running git-push::->bool:true' advice.pushNonFFMatching:'show advice when running git-push and pushed matching refs explicitly::->bool:true' advice.pushAlreadyExists:'show advice when git-push rejects an update that does not qualify for fast-forwarding::->bool:true' advice.pushFetchFirst:'show advice when git-push rejects an update that tries to overwrite a remote ref that points at unknown object::->bool:true' advice.pushNeedsForce:'show advice when git-push rejects an update that tries to overwrite a remote ref that points a non-commitish::->bool:true' + advice.pushUnqualifiedRefname:'show advice when git-push gives up trying to guess a remote ref::->bool:true' advice.statusHints:'show advice in output of git status::->bool:true' advice.statusUoption:'show advice to consider using the "-u" option to git-status when it takes more than 2 seconds::->bool:true' advice.commitBeforeMerge:'show advice when git merge refuses to merge::->bool:true' + advice.resetQuiet:'show advice to consider using the --quiet option to git-reset::->bool:true' advice.resolveConflict:'show advice when conflict prevents operation from being performed::->bool:true' + advice.sequencerInUse:'show advice shown when a sequencer command is already in progress::->bool:true' advice.implicitIdentity:'show advice when identity is guessed from system settings::->bool:true' advice.detachedHead:'show advice when entering detached-HEAD state::->bool:true' + advice.checkoutAmbiguousRemoteBranchName:'show advice when argument for a remote tracking branch is ambiguous::->bool:true' advice.amWorkDir:'show the location of the patch file when git-am fails to apply it::->bool:true' advice.rmHints:'show directions in case of failure in the output of git-rm(1)::->bool:true' + advice.addEmbeddedRepo:"show advice on what to do when you’ve accidentally added one git repo inside of another::->bool:true" + advice.ignoredHook:'show advice if a hook is ignored because the hook is not set as executable::->bool:true' + advice.waitingForEditor:'print a message to the terminal whenever Git is waiting for editor input from the user::->bool:true' + advice.nestedTag:'show advice if a user attempts to recursively tag a tag object::->bool:true' + author.email:'email address used for author in commits::_email_addresses -c' + author.name:'full name used for author in commits:name:->string' blame.blankboundary:'show blank SHA-1 for boundary commits::->bool:false' + blame.coloring:'determine the coloring scheme to be applied to blame output:scheme [none]:->string' blame.showroot:'show root commits as normal commits::->bool:false' + blame.ignoreRevsFile:'ignore revisions listed in the file:file:_files' blame.date:'date format to use in output::__git_date_formats:iso' 'branch.*.description:branch description:branch description:->string' cvsexportcommit.cvsdir:'the default location of the CVS checkout to use for the export:cvs export dir:_directories' column.ui:'specify whether supported commands should output in columns.::->column:never' - column.branch:'specify whether to output branch listing in git branch in columns::->column:never' - column.clean:'specify the layout when listing items in git clean -i::->column:never' - column.status:'specify whether to output untracked files in git status in columns::->column:never' - column.tag:'specify whether to output tag listing in git tag in columns::->column:never' + column.branch:'specify whether to output branch listing in git branch in columns::_git_column_layouts:never' + column.clean:'specify the layout when listing items in git clean -i::_git_column_layouts:never' + column.status:'specify whether to output untracked files in git status in columns::_git_column_layouts:never' + column.tag:'specify whether to output tag listing in git tag in columns::_git_column_layouts:never' + committer.email:'email address used for committer in commits::_email_addresses -c' + committer.name:'full name used for committer in commits:name:->string' core.fileMode:'track changes to the executable bit of files::->bool:true' core.attributesfile:'look into this file for attributes in addition to .gitattributes:additional attributes file:_files' core.abbrev:'set the length object names are abbreviated to:length:->int:7' @@ -2379,7 +2509,7 @@ __git_config_option-or-value () { color.status.untracked:'color of files not currently being tracked::->color' color.status.nobranch:'color of no-branch warning::->color' color.ui:'color output of capable git commands::->color-bool:auto' - commit.cleanup:'default --cleanup option::->commit.cleanup:default' + commit.cleanup:'default --cleanup option::_git_cleanup_modes' commit.gpgsign:'always GPG-sign commits::->bool:false' commit.status:'include status information in commit message template::->bool:true' commit.template:'template file for commit messages:template:_files' @@ -2409,10 +2539,14 @@ __git_config_option-or-value () { difftool.prompt:'prompt before each invocation of the diff tool::->bool:true' diff.wordRegex:'regex used to determine what a word is when performing word-by-word diff:regular expression:->string' diff.guitool:'diff tool with gui to use::__git_difftools' + feature.experimental:'enable config options that are new to Git::->bool:false' + feature.manyFiles:'enable config options that optimize for repos with many files::->bool:false' + fetch.parallel:'specify maximum number of fetch operations to run in parallel:number:->int' fetch.prune:'remove any remote tracking branches that no longer exist remotely::->bool:false' fetch.unpackLimit:'maximum number of objects to unpack when fetching:unpack limit:->int' fetch.recurseSubmodules:'recurse into submodules (as needed) when fetching::->fetch.recurseSubmodules:on-demand' fetch.fsckObjects:'check all fetched objects::->bool:false' + fetch.writeCommitGraph:'write a commit-graph after every git fetch command that downloads a pack-file from a remote::->bool:false' 'filter.*.clean:command which is used to convert the content of a worktree file to a blob upon checkin::_cmdstring' 'filter.*.smudge:command which is used to convert the content of a blob object to a worktree file upon checkout::_cmdstring' format.attach:'use multipart/mixed attachments::->bool:false' @@ -2629,6 +2763,8 @@ __git_config_option-or-value () { receive.updateserverinfo:'run git update-server-info after receiving data::->bool:false' 'remote.pushdefault:URL of a remote repository to pushto::__git_any_repositories' 'remote.*.url:URL of a remote repository::__git_any_repositories' + 'remote.*.partialclonefilter:filter applied when fetching from this promisor remote:filter:->string' + 'remote.*.promisor:use this remote to fetch promisor objects::->bool:false' 'remote.*.pushurl:push URL of a remote repository::__git_any_repositories' 'remote.*.proxy:URL of proxy to use for a remote repository::_urls' 'remote.*.prune:remove any remote tracking branches that no longer exist remotely::->bool:false' @@ -2754,9 +2890,16 @@ __git_config_option-or-value () { declare -a git_present_options # 'present' is an adjective git_present_options=( ${${${(0)"$(_call_program gettable-options git config -z --list)"}%%$'\n'*}//:/\\:} + + # Remove the "'git help config' for more information" line. + # + # Change literal 'foo.<bar>.baz' to 'foo.*.baz'. With that, completing + # at foo.lorem.<TAB> will offer foo.lorem.baz. + ${${${(f)"$(_call_program all-known-options "git help -c")"}:#* *}/<*>/*} ) - # Add to $git_options options from the config file that aren't already in $git_options. + # Add to $git_options options from the config file, and from 'git help -c', + # that aren't already in $git_options. () { local -a -U sections_that_permit_arbitrary_subsection_names=( alias @@ -2936,12 +3079,15 @@ __git_config_option-or-value () { else sections=( advice:'options controlling advice' + author:'options controlling author identity' + committer:'options controlling committer identity' core:'options controlling git core' credential:'credential options' add:'git add options' alias:'command aliases' am:'git am options' apply:'git apply options' + blame:'git blame options' branch:'branch options' browser:'browser options' clean:'git clean options' @@ -2950,6 +3096,7 @@ __git_config_option-or-value () { commit:'git commit options' diff:'diff options' difftool:'difftools' + feature:'options modifying defaults for a group of other settings' fetch:'git fetch options' format:'format options' gc:'git gc options' @@ -3129,22 +3276,6 @@ __git_config_option-or-value () { always:"always $parts[2]" \ {auto,true,yes,on}:$parts[2] && ret=0 ;; - (column) - __git_config_values -- "$current" "$parts[5]" \ - always:'always show in columns' \ - never:'never show in columns' \ - auto:'show in columns if the output is to the terminal' \ - column:'fill columns before rows (implies "always")' \ - row:'fill rows before columns (implies "always")' \ - plain:'show in one column (implies "always")' && ret=0 - ;; - (commit.cleanup) - __git_config_values -- "$current" "$parts[5]" \ - strip:'remove both whitespace and commentary lines' \ - whitespace:'remove leading and trailing whitespace lines' \ - verbatim:'no not change the commit message at all' \ - default:'act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise' && ret=0 - ;; (compression) __git_compression_levels && ret=0 ;; @@ -3411,7 +3542,7 @@ __git_config_option-or-value () { (( $+functions[_git-fast-export] )) || _git-fast-export () { # TODO: * should be git-rev-arg and git-rev-list arguments. - _arguments -S -s \ + _arguments -S -s $endopt \ '--progress=[insert progress statements]: :__git_guard_number interval' \ '--signed-tags=[specify how to handle signed tags]:action:((verbatim\:"silently export" warn\:"export, but warn" @@ -3423,9 +3554,10 @@ _git-fast-export () { rewrite\:"tag ancestor commit"))' \ '-M-[detect moving lines in the file as well]: : :__git_guard_number "number of characters"' \ '-C-[detect copies as well as renames with given scope]: :__git_guard_number size' \ + '--reencode=[specify how to handle encoding header in commit objects]:mode [abort]:(yes no abort)' \ '--export-marks=[dump internal marks table when complete]: :_files' \ '--import-marks=[load marks before processing input]: :_files' \ - '--import-marks-if-exists=[silently skip if files does not exist]: :_files' \ + '--import-marks-if-exists=[load marks from file if it exists]: :_files' \ '--fake-missing-tagger=[fake a tagger when tags lack them]' \ '--use-done-feature[start with a "feature done" stanza, and terminate with a "done" command]' \ '--no-data[do not output blocb objects, instead referring to them via their SHA-1 hash]' \ @@ -3433,12 +3565,15 @@ _git-fast-export () { '(--get --get-all)--name-only[show variable names only]' \ '*--refspec=[apply refspec to exported refs]:refspec' \ '--anonymize[anonymize output]' \ + '--reference-excluded-parents[reference parents not in fast-export stream by object id]' \ + '--show-original-ids[show original object ids of blobs/commits]' \ + '--mark-tags[label tags with mark ids]' \ '*: :__git_commit_ranges' } (( $+functions[_git-fast-import] )) || _git-fast-import () { - _arguments -S -A '-*' \ + _arguments -S -A '-*' $endopt \ '--cat-blob-fd=-[write responses to cat-blob and ls queries to <fd> instead of stdout]:file descriptor' \ '--date-format=-[type of dates used in input]:format:((raw\:"native Git format" rfc2822\:"standard email format from RFC 2822" @@ -3464,7 +3599,7 @@ _git-filter-branch () { # TODO: --original should take subdirectory under .git named refs/* or some # such. # TODO: * should be git-rev-arg and git-rev-list arguments. - _arguments -S -A '-*' \ + _arguments -S -A '-*' $endopt \ '--setup[specify one time setup command]: :_cmdstring' \ '--env-filter[filter for modifying environment in which commit will be performed]: :_cmdstring' \ '--tree-filter[filter for rewriting tree and its contents]: :_cmdstring' \ @@ -3473,7 +3608,7 @@ _git-filter-branch () { '--msg-filter[filter for rewriting commit messages]: :_cmdstring' \ '--commit-filter[filter for rewriting commit]: :_cmdstring' \ '--tag-name-filter[filter for rewriting tag names]: :_cmdstring' \ - '--subdirectory-filter[only look at histor that touches given directory]: :_directories' \ + '--subdirectory-filter[only look at history that touches given directory]: :_directories' \ '--prune-empty[ignore empty generated commits]' \ '--original[namespace where original commits will be stored]:namespace:_directories' \ '-d[temporary directory used for rewriting]: :_directories' \ @@ -3490,13 +3625,15 @@ _git-mergetool () { '--tool-help[print a list of merge tools that may be used with "--tool"]' \ '(-y --no-prompt --prompt)'{-y,--no-prompt}'[do not prompt before invocation of merge resolution program]' \ '(-y --no-prompt)--prompt[prompt before invocation of merge resolution program]' \ + '(-g --gui)'{-g,--gui}'[use merge.guitool variable instead of merge.tool]' \ + '!(-g --gui)--no-gui' \ '-O-[process files in the order specified in file]:order file:_files' \ '*:conflicted file:_files' } (( $+functions[_git-pack-refs] )) || _git-pack-refs () { - _arguments \ + _arguments -S $endopt \ '( --no-all)--all[pack all refs]' \ '(--all )--no-all[do not pack all refs]' \ '( --no-prune)--prune[remove loose refs after packing them]' \ @@ -3505,7 +3642,7 @@ _git-pack-refs () { (( $+functions[_git-prune] )) || _git-prune () { - _arguments -S \ + _arguments -s -S $endopt \ '(-n --dry-run)'{-n,--dry-run}'[do not remove anything; just report what would be removed]' \ '(-v --verbose)'{-v,--verbose}'[report all removed objects]' \ '--progress[show progress]' \ @@ -3631,7 +3768,7 @@ _git-remote () { case $line[1] in (add) # TODO: -t and --track should really list branches at url. - _arguments -S -s \ + _arguments -S -s $endopt \ '(-f --fetch)'{-f,--fetch}'[run git fetch on new remote after it has been created]' \ '( --no-tags)--tags[tell git fetch to import every tag from remote repository]' \ '(--tags )--no-tags[tell git fetch to not import every tag from remote repository]' \ @@ -3642,7 +3779,7 @@ _git-remote () { ':repository:__git_repositories_or_urls' && ret=0 ;; (get-url) - _arguments -S -s \ + _arguments -S -s $endopt \ '--push[list push URL instead of fetch URL]' \ '--all[list all URLs for the remote]' \ ': :__git_remotes' && ret=0 @@ -3654,7 +3791,7 @@ _git-remote () { ;; (set-head) # TODO: Second argument should be a branch at url for remote. - _arguments -S -s \ + _arguments -S -s $endopt \ '(- 2)'{-d,--delete}'[delete default branch]' \ '(- 2)'{-a,--auto}'[determine default branch automatically]' \ ': :__git_remotes' \ @@ -3662,13 +3799,13 @@ _git-remote () { ;; (set-branches) # TODO: Branches should be at url. - _arguments -S -s \ + _arguments -S -s $endopt \ '--add[add branches to those already defined]' \ ': :__git_remotes' \ '*: :__git_branch_names' && ret=0 ;; (set-url) - _arguments -S \ + _arguments -S $endopt \ '--push[manipulate push URLs instead of fetch URLs]' \ '(3)--add[add URL to those already defined]' \ '(2)--delete[delete all matching URLs]' \ @@ -3677,17 +3814,17 @@ _git-remote () { '3:old url: __git_current_remote_urls ${(k)opt_args[--push]} $line[1]' && ret=0 ;; (show) - _arguments -S \ + _arguments -S $endopt \ '-n[do not contact the remote for a list of branches]' \ '*: :__git_remotes' && ret=0 ;; (prune) - _arguments -S -s \ + _arguments -S -s $endopt \ '(-n --dry-run)'{-n,--dry-run}'[do not actually prune, only list what would be done]' \ '*: :__git_remotes' && ret=0 ;; (update) - _arguments -S -s \ + _arguments -S -s $endopt \ '(-p --prune)'{-p,--prune}'[prune all updated remotes]' \ ': :__git_remote-groups' && ret=0 ;; @@ -3715,6 +3852,7 @@ _git-repack () { '(-q --quiet)'{-q,--quiet}'[pass -q option to git pack-objects]' \ '(-l --local)'{-l,--local}'[pass --local option to git pack-objects]' \ '(-b --write-bitmap-index)'{-b,--write-bitmap-index}'[write a bitmap index]' \ + '(-i --delta-islands)'{-i,--delta-islands}'[pass --delta-islands to git-pack-objects]' \ "--unpack-unreachable=[with -A, don't loosen objects older than specified time]:time" \ '(-k --keep-unreachable)'{-k,--keep-unreachable}'[with -a, repack unreachable objects]' \ '--window=[number of objects to consider when doing delta compression]:number of objects' \ @@ -3728,7 +3866,7 @@ _git-repack () { (( $+functions[_git-replace] )) || _git-replace () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(-d --delete -l --list -g --graft *)'{-f,--force}'[overwrite existing replace ref]' \ "(-d --delete -l --list -g --graft 2 *)--raw[don't pretty-print contents for --edit]" \ '(-d --delete -e --edit -g --graft --raw)--format=[use specified format]:format:(short medium long)' \ @@ -3759,7 +3897,7 @@ _git-blame () { __git_setup_revision_options # TODO: Not sure about __git_cached_files. - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '-b[show blank SHA-1 for boundary commits]' \ '--root[do not treat root commits as boundaries]' \ '--show-stats[include additional statistics at the end of blame output]' \ @@ -3781,6 +3919,8 @@ _git-blame () { '(-n --show-number)'{-n,--show-number}'[show the line number in the original commit]' \ '-s[suppress author name and timestamp]' \ '-w[ignore whitespace when finding lines]' \ + '--ignore-rev=[ignore specified revision when blaming]:revision:__git_revisions' \ + '--ignore-revs-file=[ignore revisions from file]:file:_files' \ '(--color-by-age)--color-lines[color redundant metadata from previous line differently]' \ '(--color-lines)--color-by-age[color lines by age]' \ '--indent-heuristic[use indent-based heuristic to improve diffs]' \ @@ -3809,7 +3949,7 @@ _git-blame () { (( $+functions[_git-cherry] )) || _git-cherry () { # TODO: --abbrev is undocumented. - _arguments \ + _arguments -S $endopt \ '(-v --verbose)'{-v,--verbose}'[output additional information]' \ '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length' \ ':upstream commit:__git_commits' \ @@ -3819,7 +3959,7 @@ _git-cherry () { (( $+functions[_git-count-objects] )) || _git-count-objects () { - _arguments \ + _arguments -s -S $endopt \ '(-v --verbose)'{-v,--verbose}'[also report number of in-pack objects and objects that can be removed]' \ {-H,--human-readable}'[print sizes in human readable format]' } @@ -3828,7 +3968,7 @@ _git-count-objects () { _git-difftool () { # TODO: Is this fine, or do we need to modify the context or similar? _git-diff \ - '(-d --dir-diff)'{-d,--dir-diff}'[diff a whole tree by preparing a temporary copy]' \ + '(-d --dir-diff --no-index)'{-d,--dir-diff}'[diff a whole tree by preparing a temporary copy]' \ '(-y --no-prompt --prompt)'{-y,--no-prompt}'[do not prompt before invocation of diff tool]' \ '(-y --no-prompt)--prompt[prompt before invocation of diff tool]' \ '(-t --tool -x --extcmd)'{-t,--tool=-}'[merge resolution program to use]: :__git_difftools' \ @@ -3842,8 +3982,7 @@ _git-difftool () { (( $+functions[_git-fsck] )) || _git-fsck () { - # TODO: -v is undocumented. - _arguments -S -s \ + _arguments -S -s $endopt \ '--unreachable[show objects that are unreferenced in the object database]' \ '(--dangling --no-dangling)--dangling[print dangling objects (default)]' \ '(--dangling --no-dangling)--no-dangling[do not print dangling objects]' \ @@ -3876,7 +4015,7 @@ _git-help () { '(-a --all -g --guides -c --config -i --info -m --man)'{-w,--web}'[display manual for the command in HTML format]' \ '(-g --guides -c --config -i --info -m --man -w --web)'{-g,--guides}'[prints a list of useful guides on the standard output]' \ '(-v --verbose)'{-v,--verbose}'[print command descriptions]' \ - ': : _alternative commands:command:_git_commands "guides:git guides:(attributes glossary ignore modules revisions tutorial workflows)"' + ': : _alternative commands:command:_git_commands "guides:git guides:(attributes cli core-tutorial cvs-migration diffcore everyday glossary hooks ignore modules namespaces repository-layout revisions tutorial tutorial-2 workflows)"' } (( $+functions[_git-instaweb] )) || @@ -3884,7 +4023,7 @@ _git-instaweb () { local curcontext=$curcontext state line ret=1 declare -A opt_args - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '(-l --local)'{-l,--local}'[bind the web server to 127.0.0.1]' \ '(-d --httpd)'{-d,--httpd=}'[HTTP-daemon command-line that will be executed]:command line' \ '(-m --module-path)'{-m,--module-path=}'[module path for the Apache HTTP-daemon]:module path:_directories' \ @@ -3925,7 +4064,7 @@ _git-rerere () { declare -A opt_args # TODO: --rerere-autoupdate is undocumented. - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '--rerere-autoupdate[register clean resolutions in index]' \ ': :->command' && ret=0 @@ -4024,7 +4163,7 @@ _git-show-branch () { local curcontext=$curcontext state line ret=1 declare -A opt_args - _arguments -C -S -s -A '-*' \ + _arguments -C -S -s $endopt \ '(--more --merge-base --independent)--list[do not show any ancestry (--more=-1)]' \ - branches \ '(-r --remotes -a --all)'{-r,--remotes}'[show remote-tracking branches]' \ @@ -4063,7 +4202,7 @@ _git-show-branch () { (( $+functions[_git-verify-commit] )) || _git-verify-commit () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(-v --verbose)'{-v,--verbose}'[print contents of the commit object before validating it]' \ '--raw[print raw gpg status output]' \ '*: :__git_commits' @@ -4071,7 +4210,7 @@ _git-verify-commit () { (( $+functions[_git-verify-tag] )) || _git-verify-tag () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(-v --verbose)'{-v,--verbose}'[print contents of the tag object before validating it]' \ '--raw[print raw gpg status output]' \ '--format=[specify format to use for the output]:format:__git_format_ref' \ @@ -4083,7 +4222,7 @@ _git-whatchanged () { local -a revision_options __git_setup_revision_options - _arguments -S \ + _arguments -s -S $endopt \ $revision_options \ '1:: :__git_commits' \ '*: :__git_cached_files' @@ -4169,7 +4308,7 @@ _git-cvsserver () { (( $+functions[_git-imap-send] )) || _git-imap-send () { - _arguments \ + _arguments -S $endopt \ '--curl[use libcurl to communicate with the IMAP server]' \ - '(out)' \ {-v,--verbose}'[be more verbose]' \ @@ -4178,16 +4317,17 @@ _git-imap-send () { (( $+functions[_git-quiltimport] )) || _git-quiltimport () { - _arguments -S \ + _arguments -S $endopt \ '(-n --dry-run)'{-n,--dry-run}'[check patches and warn if they cannot be imported]' \ '--author[default author name and email address to use for patches]: :_email_addresses' \ '--patches[set directory containing patches]:patch directory:_directories' \ - '--series[specify quilt series file]:series file:_files' + '--series[specify quilt series file]:series file:_files' \ + '--keep-non-patch[pass -b to git mailinfo]' } (( $+functions[_git-request-pull] )) || _git-request-pull () { - _arguments -S \ + _arguments -S $endopt \ '-p[display patch text]' \ ':start commit:__git_commits' \ ': :_urls' \ @@ -4196,7 +4336,7 @@ _git-request-pull () { (( $+functions[_git-send-email] )) || _git-send-email () { - _arguments -S \ + _arguments -S $endopt \ '--annotate[review and edit each patch before sending it]' \ '--bcc=[Bcc: value for each email]: :_email_addresses' \ '--cc=[starting Cc: value for each email]: :_email_addresses' \ @@ -4218,10 +4358,11 @@ _git-send-email () { '--smtp-pass=[specify password to use for SMTP-AUTH]::password' \ '--smtp-server=[specify SMTP server to connect to, or sendmail command]: : __git_sendmail_smtpserver_values' \ '--smtp-server-port=[specify port to connect to SMTP server on]:smtp port:_ports' \ - '--smtp-server-option=[specify the outgoing SMTP server option to use]:SMPT server option' \ + '--smtp-server-option=[specify the outgoing SMTP server option to use]:SMTP server option' \ '--smtp-ssl-cert-path=[path to ca-certificates (directory or file)]:ca certificates path:_files' \ '--smtp-user=[specify user to use for SMTP-AUTH]:smtp user:_users' \ - '--smtp-auth=[specify allowed AUTH mechanisms]:space-separated list of mechanisms' \ + '(--no-smtp-auth)--smtp-auth=[specify allowed AUTH mechanisms]:space-separated list of mechanisms' \ + '(--smtp-auth)--no-smtp-auth[disable SMTP authentication]' \ '--smtp-debug=[enable or disable debug output]:smtp debug:((0\:"disable" 1\:"enable"))' \ '--batch-size=[specify maximum number of messages per connection]:number' \ '--relogin-delay=[specify delay between successive logins]:delay (seconds)' \ @@ -4552,7 +4693,7 @@ _git-apply () { local -a apply_options __git_setup_apply_options - _arguments -S -s \ + _arguments -S -s $endopt \ $apply_options \ '(--index --cached --reject)'{-3,--3way}'[fall back on 3-way merge if patch fails]' \ '--stat[output diffstat for input (turns off "apply")]' \ @@ -4582,7 +4723,7 @@ _git-checkout-index () { z_opt='-z[paths are separated with NUL character when reading from standard input]' fi - _arguments -S -s \ + _arguments -S -s $endopt \ '(-u --index)'{-u,--index}'[update stat information in index]' \ '(-q --quiet)'{-q,--quiet}'[no warning for existing files and files not in index]' \ '(-f --force)'{-f,--force}'[force overwrite of existing files]' \ @@ -4596,9 +4737,35 @@ _git-checkout-index () { '*: :__git_cached_files' } +(( $+functions[_git-commit-graph] )) || +_git-commit-graph() { + local -a args progress + progress=( "--no-progress[don't show progress]" ) + if [[ $words[2] = write ]]; then + args=( $progress + '(--split --size-multiple --max-commits --expire-time)--append[include all commits present in existing commit-graph file]' + '(--append)--split[write the commit-graph as a chain of multiple commit-graph files]' + '(--stdin-packs --stdin-commits)--reachable[walk commits starting at all refs]' + '(--reachable --stdin-commits)--stdin-packs[only walk objects in pack-indexes read from input]' + '(--reachable --stdin-packs)--stdin-commits[walk commits starting at commits read from input]' + '(--append)--size-multiple=:commits [2]' + '(--append)--max-commits=:commits' + '(--append)--expire-time=:date/time:__git_datetimes' + ) + elif [[ $words[2] = verify ]]; then + args=( $progress + '--shallow[only check the tip commit-graph file in a chain of split commit-graphs]' + ) + fi + + _arguments -S $endopt $args \ + '--object-dir=[specify location of packfiles and commit-graph file]:directory:_directories' \ + '(-h)1:verb:(read verify write)' +} + (( $+functions[_git-commit-tree] )) || _git-commit-tree () { - _arguments \ + _arguments -S $endopt \ '-h[display usage]' \ '*-p+[specify parent commit]:parent commit:__git_objects' \ '(-S --gpg-sign --no-gpg-sign)'{-S-,--gpg-sign=-}'[GPG-sign the commit]::key id' \ @@ -4610,7 +4777,7 @@ _git-commit-tree () { (( $+functions[_git-hash-object] )) || _git-hash-object () { - _arguments -S \ + _arguments -s -S $endopt \ '-t[type of object to create]:object type:((blob\:"a blob of data" commit\:"a tree with parent commits" tag\:"a symbolic name for another object" @@ -4705,6 +4872,14 @@ _git-mktree () { '--batch[allow creation of more than one tree]' } +(( $+functions[_git-multi-pack-index] )) || +_git-multi-pack-index() { + _arguments \ + '--object-dir=[specify location of git objects]:directory:_directories' \ + '--batch-size=[during repack, select packs so as to have pack files of at least the specified size]:size' \ + '1:verb:(write verify expire repack)' +} + (( $+functions[_git-pack-objects] )) || _git-pack-objects () { local thin_opt= @@ -4740,6 +4915,7 @@ _git-pack-objects () { '(--unpack-unreachable)--keep-unreachable[keep unreachable ]' \ '--pack-loose-unreachable[pack loose unreachable objects]' \ '(--keep-unreachable)--unpack-unreachable=-[unpack unreachable objects newer than specified time]::time' \ + '--sparse[use sparse reachability algorithm]' \ '--include-tag[include tag objects that refer to objects to be packed]' \ $thin_opt \ '--shallow[create packs suitable for shallow fetches]' \ @@ -4752,6 +4928,7 @@ _git-pack-objects () { '--filter=[omit certain objects from pack file]:filter:_git_rev-list_filters' \ '--missing=[specify how missing objects are handled]:action:(error allow-any allow-promisor print)' \ "--exclude-promisor-objects[don't pack objects in promisor packfiles]" \ + '--delta-islands[respect islands during delta compression]' \ ':base-name:_files' } @@ -4800,6 +4977,7 @@ _git-read-tree () { '--no-sparse-checkout[display sparse checkout support]' \ '--debug-unpack[debug unpack-trees]' \ '--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \ + '(-q --quiet)'{-q,--quiet}'[suppress feedback messages]' \ '--empty[instead of reading tree object(s) into the index, just empty it]' \ '1:first tree-ish to be read/merged:__git_tree_ishs' \ '2::second tree-ish to be read/merged:__git_tree_ishs' \ @@ -4845,7 +5023,7 @@ _git-update-index () { '--ignore-missing[ignore missing files when refreshing the index]' \ '*--cacheinfo[insert information directly into the cache]: :_guard "[0-7]#" "octal file mode": :_guard "[[\:xdigit\:]]#" "object id": :_files' \ '(: -)--index-info[read index information from stdin]' \ - '--chmod=-[set execute permissions on updated files]:permission:((-x\:executable +x\:"not executable"))' \ + '--chmod=-[set execute permissions on updated files]:permission:((+x\:executable -x\:"not executable"))' \ '( --no-assume-unchanged)--assume-unchanged[set "assume unchanged" bit for given paths]' \ '(--assume-unchanged )--no-assume-unchanged[unset "assume unchanged" bit for given paths]' \ '(-q --unmerged --ignore-missing --refresh)--really-refresh[refresh index, unconditionally checking stat information]' \ @@ -4970,7 +5148,7 @@ _git-diff-tree () { _arguments -C -S -s \ $revision_options \ '-r[recurse into subdirectories]' \ - '(-r )-t[disply tree objects in diff output]' \ + '(-r )-t[display tree objects in diff output]' \ '--root[display root diff]' \ '-m[do not ignore merges]' \ '-s[do not show differences]' \ @@ -4978,6 +5156,7 @@ _git-diff-tree () { '--no-commit-id[do not display commit IDs]' \ '(-c --cc)-c[show differences from each of parents to merge result]' \ '(-c --cc)--cc[how differences from each of parents and omit differences from only one parent]' \ + '--combined-all-paths[show name of file in all parents for combined diffs]' \ '--always[always show commit itself and commit log message]' \ ': :__git_tree_ishs' \ '*:: :->files' && ret=0 @@ -5041,7 +5220,7 @@ _git-ls-files () { # TODO: --resolve-undo is undocumented. # TODO: Replace _files with something more intelligent based on seen options. # TODO: Apply excludes like we do for git-clean. - _arguments -S -s \ + _arguments -S -s $endopt \ '(-c --cached)'{-c,--cached}'[show cached files in output]' \ '(-d --deleted)'{-d,--deleted}'[show deleted files in output]' \ '(-m --modified)'{-m,--modified}'[show modified files in output]' \ @@ -5072,7 +5251,7 @@ _git-ls-files () { (( $+functions[_git-ls-remote] )) || _git-ls-remote () { # TODO: repository needs fixing - _arguments \ + _arguments -S -s $endopt \ '(-q --quiet)'{-q,--quiet}"[don't print remote URL]" \ '--upload-pack=[specify path to git-upload-pack on remote side]:remote path' \ '(-h --heads)'{-h,--heads}'[show only refs under refs/heads]' \ @@ -5092,7 +5271,7 @@ _git-ls-tree () { local curcontext=$curcontext state line ret=1 declare -A opt_args - _arguments -C -S -s \ + _arguments -C -S -s $endopt \ '(-t)-d[do not show children of given tree (implies -t)]' \ '-r[recurse into subdirectories]' \ '-t[show tree entries even when going to recurse them]' \ @@ -5116,7 +5295,7 @@ _git-ls-tree () { (( $+functions[_git-merge-base] )) || _git-merge-base () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(-a --all)'{-a,--all}'[display all common ancestors]' \ '--octopus[compute best common ancestors of all supplied commits]' \ '--is-ancestor[tell if A is ancestor of B (by exit status)]' \ @@ -5128,7 +5307,7 @@ _git-merge-base () { (( $+functions[_git-name-rev] )) || _git-name-rev () { - _arguments -S \ + _arguments -S $endopt \ '--tags[only use tags to name commits]' \ '*--refs=[only use refs matching given pattern]: :_guard "?#" "shell pattern"' \ '--no-refs[clear any previous ref patterns given]' \ @@ -5158,7 +5337,7 @@ _git-rev-list () { declare -a revision_options __git_setup_revision_options - _arguments -C -S \ + _arguments -C -S $endopt \ $revision_options \ '--no-filter[turn off any previous --filter argument]' \ '--filter-print-omitted[print a list of objects omitted by --filter]' \ @@ -5168,6 +5347,8 @@ _git-rev-list () { '--use-bitmap-index[try to speed traversal using pack bitmap index if available]' \ '--progress=-[show progress reports as objects are considered]:header' \ '(--pretty --quiet)--header[display contents of commit in raw-format]' \ + "--no-object-names[don't print the names of the object IDs that are found]" \ + '!(--no-object-names)--object-names)' \ '--timestamp[print raw commit timestamp]' \ '( --bisect-vars --bisect-all)--bisect[show only middlemost commit object]' \ '(--bisect)--bisect-vars[same as --bisect, displaying shell-evalable code]' \ @@ -5196,7 +5377,7 @@ _git_rev-list_filters() { 'blob\:none[omit all blobs]' \ 'blob\:limit[omit blobs larger than specified size]:size' \ 'sparse\:oid[uses a sparse-checkout specification contained in the blob]:blob-ish' \ - 'sparse\:path[uses a sparse-checkout specification contained in path]:path:_directories' + 'tree\:0[omit blobs and trees with depth exceeding limit]' } (( $+functions[_git-show-index] )) || @@ -5206,7 +5387,7 @@ _git-show-index () { (( $+functions[_git-show-ref] )) || _git-show-ref () { - _arguments -S \ + _arguments -S $endopt \ - list \ '--head[show the HEAD reference, even if it would normally be filtered out]' \ '--tags[show only refs/tags]' \ @@ -5240,13 +5421,13 @@ _git-var () { (( $+functions[_git-verify-pack] )) || _git-verify-pack () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(-v --verbose)'{-v,--verbose}'[show objects contained in pack]' \ '(-s --stat-only)'{-s,--stat-only}'[do not verify pack contents; only display histogram of delta chain length]' \ - '*:index file:_files -g "*.idx"' + '*:index file:_files -g "*.idx(-.)"' } -# Synching Repositories +# Syncing Repositories (( $+functions[_git-daemon] )) || _git-daemon () { @@ -5257,7 +5438,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]' \ @@ -5316,7 +5497,7 @@ _git-send-pack () { {no,false}'\:never' if-asked'\:iff\ supported\ by\ server' ) - _arguments -A '-*' \ + _arguments -S -A '-*' $endopt \ '(-v --verbose)'{-v,--verbose}'[produce verbose output]' \ '(-q --quiet)'{-q,--quiet}'[be more quiet]' \ '(--receive-pack --exec)'{--receive-pack=-,--exec=-}'[specify path to git-receive-pack on remote side]:remote path' \ @@ -5342,13 +5523,13 @@ _git-send-pack () { (( $+functions[_git-update-server-info] )) || _git-update-server-info () { - _arguments -S -s \ + _arguments -S -s $endopt \ '(-f --force)'{-f,--force}'[update the info files from scratch]' } (( $+functions[_git-http-fetch] )) || _git-http-fetch () { - _arguments \ + _arguments -s \ '-c[fetch commit objects]' \ '-t[fetch trees associated with commit objects]' \ '-a[fetch all objects]' \ @@ -5379,7 +5560,7 @@ _git-http-push () { _git-receive-pack () { # TODO: --advertise-refs is undocumented. # TODO: --stateless-rpc is undocumented. - _arguments -A '-*' \ + _arguments -S -A '-*' $endopt \ '(-q --quiet)'{-q,--quiet}'[be quiet]' \ '--advertise-refs[undocumented]' \ '--stateless-rpc[undocumented]' \ @@ -5439,7 +5620,7 @@ _git-upload-archive () { (( $+functions[_git-upload-pack] )) || _git-upload-pack () { - _arguments -S -A '-*' \ + _arguments -S -A '-*' $endopt \ '--stateless-rpc[quit after a single request/response exchange]' \ '--advertise-refs[exit immediately after initial ref advertisement]' \ "--strict[don't try <directory>/.git/ if <directory> is not a git directory]" \ @@ -5510,7 +5691,7 @@ _git-check-ref-format () { (( $+functions[_git-fmt-merge-msg] )) || _git-fmt-merge-msg () { - _arguments -S -s \ + _arguments -S -s $endopt \ '( --no-log)--log=-[display one-line descriptions from actual commits being merged]::number of commits [20]' \ '(--log )--no-log[do not display one-line descriptions from actual commits being merged]' \ '(-m --message)'{-m+,--message=}'[use given message instead of branch names for first line in log message]:message' \ @@ -5562,8 +5743,8 @@ _git-patch-id () { (( $+functions[_git-stripspace] )) || _git-stripspace () { _arguments \ - '(-s --strip-comments)'{-s,--strip-comments}'[also strip lines starting with #]' \ - '(-c --comment-lines)'{-c,--comment-lines}'[prepend comment character and blank to each line]' + '(-s --strip-comments -c --comment-lines)'{-s,--strip-comments}'[also strip lines starting with #]' \ + '(-c --comment-lines -s --strip-comments)'{-c,--comment-lines}'[prepend comment character and blank to each line]' } # INTERNAL GIT COMPLETION FUNCTIONS @@ -5652,7 +5833,7 @@ __git_describe_branch () { local __c local -a __commits for __c in ${(P)__commits_in}; do - __commits+=("${__c}:${$(_call_program describe git log -1 --oneline $__c)//:/\\:}") + __commits+=("${__c}:${$(_call_program describe git rev-list -1 --oneline $__c)//:/\\:}") done _describe -t $__tag $__desc __commits "$@" else @@ -5688,7 +5869,7 @@ __git_ignore_line () { __git_ignore_line_inside_arguments () { declare -a compadd_opts - zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F: + zparseopts -D -E -a compadd_opts V+: J+: 1 2 o+: n f x+: X+: M+: P: S: r: R: q F: __git_ignore_line $* $compadd_opts } @@ -5737,6 +5918,7 @@ _git_commands () { range-diff:'compare two commit ranges' rebase:'forward-port local commits to the updated upstream head' reset:'reset current HEAD to specified state' + restore:'restore working tree files' revert:'revert existing commits' rm:'remove files from the working tree and from the index' shortlog:'summarize git log output' @@ -5745,6 +5927,7 @@ _git_commands () { status:'show working-tree status' submodule:'initialize, update, or inspect submodules' subtree:'split repository into subtrees and merge them' + switch:'switch branches' tag:'create, list, delete or verify tag object signed with GPG' worktree:'manage multiple working dirs attached to the same repository' ) @@ -5763,21 +5946,19 @@ _git_commands () { ancillary_interrogator_commands=( blame:'show what revision and author last modified each line of a file' - cherry:'find commits not merged upstream' count-objects:'count unpacked objects and display their disk consumption' difftool:'show changes using common diff tools' fsck:'verify connectivity and validity of objects in database' - get-tar-commit-id:'extract commit ID from an archive created using git archive' help:'display help information about git' instaweb:'instantly browse your working repository in gitweb' interpret-trailers:'add or parse structured information in commit messages' merge-tree:'show three-way merge without touching index' rerere:'reuse recorded resolution of conflicted merges' - rev-parse:'pick out and massage parameters for other git commands' show-branch:'show branches and their commits' verify-commit:'check GPG signature of commits' verify-tag:'check GPG signature of tags' - whatchanged:'show commit-logs and differences they introduce') + whatchanged:'show commit-logs and differences they introduce' + version:'show git version') interaction_commands=( archimport:'import an Arch repository into git' @@ -5793,6 +5974,7 @@ _git_commands () { plumbing_manipulator_commands=( apply:'apply patch to files and/or to index' checkout-index:'copy files from index to working directory' + commit-graph:'write and verify Git commit-graph files' commit-tree:'create new commit object' hash-object:'compute object ID and optionally create a blob from a file' index-pack:'build pack index file for an existing packed archive' @@ -5800,6 +5982,7 @@ _git_commands () { merge-index:'run merge for files needing merging' mktag:'create tag object' mktree:'build tree-object from git ls-tree formatted text' + multi-pack-index:'write and verify multi-pack-indexes' pack-objects:'create packed archive of objects' prune-packed:'remove extra objects that are already in pack files' read-tree:'read tree information into directory index' @@ -5811,10 +5994,12 @@ _git_commands () { plumbing_interrogator_commands=( cat-file:'provide content or type information for repository objects' + cherry:'find commits not merged upstream' diff-files:'compare files in working tree and index' diff-index:'compare content and mode of blobs between index and repository' diff-tree:'compare content and mode of blobs found via two tree objects' for-each-ref:'output information on each ref' + get-tar-commit-id:'extract commit ID from an archive created using git archive' ls-files:'information about files in index/working directory' ls-remote:'show references in a remote repository' ls-tree:'list contents of a tree object' @@ -5822,6 +6007,7 @@ _git_commands () { name-rev:'find symbolic names for given revisions' pack-redundant:'find redundant pack files' rev-list:'list commit object in reverse chronological order' + rev-parse:'pick out and massage parameters for other git commands' show-index:'show packed archive index' show-ref:'list references in a local repository' unpack-file:'create temporary file with blob'\''s contents' @@ -5849,6 +6035,7 @@ _git_commands () { check-ignore:'debug gitignore/exclude files' check-mailmap:'show canonical names and email addresses of contacts' check-ref-format:'ensure that a reference name is well formed' + column:'display data in columns' fmt-merge-msg:'produce merge commit message' mailinfo:'extract patch and authorship from a single email message' mailsplit:'split mbox file into a list of files' @@ -5912,30 +6099,97 @@ __git_extract_aliases () { fi } +(( $+functions[_git_column_layouts] )) || +_git_column_layouts() { + _values -s , 'column layout [always,column,nodense]' \ + '(never auto)always[always show in columns]' \ + '(always auto)never[never show in columns]' \ + '(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 column]' \ + '(nodense)dense[make unequal size columns to utilize more space]' \ + '(dense)nodense[make equal size columns]' +} + (( $+functions[__git_date_formats] )) || __git_date_formats () { declare -a date_formats - if compset -P 'format:'; then + if compset -P 'format(-local|):'; then _strftime return fi date_formats=( relative:'show dates relative to the current time' - local:'show timestamps in local timezone' + local:'show timestamps in the local timezone' iso{,8601}:'show timestamps in ISO 8601 format' + iso{,8601}-local:'show timestamps in ISO 8601 format in the local timezone' iso-strict:'show timestamps in strict ISO 8601 format' + iso-strict-local:'show timestamps in strict ISO 8601 format in the local timezone' rfc{,2822}:'show timestamps in RFC 2822 format' + rfc{,2822}-local:'show timestamps in RFC 2822 format in the local timezone' short:'show only date but not time' + short-local:'show only date but not time in the local timezone' raw:'show date in internal raw git format (%s %z)' + raw-local:'show date in internal raw git format (%s %z) in the local timezone' + human:'elide some current and recent date elements' + human-local:'elide some current and recent date elements in the local timezone' unix:'show date as a Unix epoch timestamp' - default:'show timestamp in the original timezone' + default:'show timestamp in rfc-like format' + default-local:'show timestamp in rfc-like format in the local timezone' ) _describe -t date-formats 'date format' date_formats -- '( format\:custom\ format )' -S : } +(( $+functions[_git_diff_filters] )) || +_git_diff_filters() { + local sep + local -a dispinc dispexc exclude + typeset -A filters + exclude=( ${(s..)PREFIX:u} ${(s..)SUFFIX:u} ${(s..)PREFIX:l} ${(s..)SUFFIX:l} ) + compset -P \* + compset -S \* + filters=( A added C copied D deleted M modified R renamed T changed b "pairing broken" ) + if zstyle -T ":completion:${curcontext}:" verbose; then + zstyle -s ":completion:${curcontext}:" list-separator sep || sep=-- + print -v dispinc -f "%s $sep %s" ${(kv)filters} + print -v dispexc -f "%s $sep %s" ${(kv)filters:l} + else + dispinc=() + fi + _alternative \ + "included-file-types:included file type:compadd -S '' -d dispinc -F exclude -k filters" \ + "excluded-file-types:excluded file type:compadd -S '' -d dispexc -F exclude ${(k)filters:l}" +} + +(( $+functions[_git_dirstat_params] )) || +_git_dirstat_params() { + + _alternative \ + "limits: :_guard '(*,|)[0-9]#' 'minimum cut-off limit (percent)'" \ + "parameters: :_values -s , 'method for computing stats [changes]' + '(lines files)changes[count added/removed lines, ignoring moves]' + '(changes files)lines[count added/removed lines]' + '(changes lines)files[count number of files changed]' + 'cumulative[count changes in a child directory for the parent directory as well]'" +} + +(( $+functions[_git_cleanup_modes] )) || +_git_cleanup_modes() { + declare -a cleanup_modes + cleanup_modes=( + strip:'remove both whitespace and commentary lines' + whitespace:'remove leading and trailing whitespace lines' + verbatim:"don't change the commit message at all" + scissors:"same as whitespace but cut from scissor line" + default:'act as '\''strip'\'' if the message is to be edited and as '\''whitespace'\'' otherwise' + ) + _describe -t modes mode cleanup_modes +} + (( $+functions[__git_gpg_secret_keys] )) || __git_gpg_secret_keys () { local expl @@ -6160,7 +6414,7 @@ __git_ref_fields () { local match mbegin mend local -a cfields fields append opts all - zparseopts -D -E -a opts x: X: J: V: a=all + zparseopts -D -E -a opts M+: x+: X+: J+: V+: o+: 1 2 a=all if compset -P 1 '(#b)(*):'; then case $match[1] in @@ -6221,6 +6475,7 @@ __git_ref_fields () { fields=( 'objecttype:the type of the object' 'objectsize:the size of the object' + 'deltabase:object name of the delta base of the object' 'HEAD:* if HEAD matches ref or space otherwise' 'tree:the tree header-field' 'parent:the parent header-field' @@ -6407,8 +6662,8 @@ __git_recent_branches() { # 4. Obtain log messages for all of them in one shot. # TODO: we'd really like --sort=none here... but git doesn't support such a thing. - # The \n removal is because for-each-ref prints a \n after each entry. - descriptions=( ${(0)"$(_call_program all-descriptions "git --no-pager for-each-ref --format='%(refname)%00%(subject)%00'" refs/heads/${(q)^branches} "--")"//$'\n'} ) + local z=$'\0' + descriptions=( "${(0)"$(_call_program all-descriptions "git --no-pager for-each-ref --format='%(refname)%00%(subject)'" refs/heads/${(q)^branches} "--")"//$'\n'/$z}" ) # 5. Synthesize the data structure _describe wants. local -a branches_colon_descriptions @@ -6422,7 +6677,12 @@ __git_recent_branches() { (( $+functions[__git_commits_prefer_recent] )) || __git_commits_prefer_recent () { - _alternative 'recent-branches::__git_recent_branches' 'commits::__git_commits' + local -a argument_array_names + zparseopts -D -E O:=argument_array_names + + _alternative \ + 'recent-branches::__git_recent_branches' \ + "commits::__git_commits $argument_array_names" } (( $+functions[__git_commits] )) || @@ -6493,8 +6753,9 @@ __git_commit_objects () { # Note: the after-the-colon part must be unique across the entire array; # see workers/34768 - commits=(${(f)"$(_call_program commits git --no-pager log -1000 --all --reflog --format='%h:\[%h\]\ %s\ \(%cr\)')"}) + commits=(${(f)"$(_call_program commits git --no-pager rev-list -1000 --all --reflog --format='%h:\[%h\]\ %s\ \(%cr\)' HEAD)"}) __git_command_successful $pipestatus || return 1 + commits=(${commits:#commit [[:xdigit:]](#c40,)}) _describe -Vx -t commits 'commit object name' commits } @@ -6503,7 +6764,7 @@ __git_commit_objects () { __git_recent_commits () { local gitdir expl start declare -a descr tags heads commits argument_array_names commit_opts - local i j k ret + local h i j k ret integer distance_from_head local label local parents @@ -6517,10 +6778,11 @@ __git_recent_commits () { # Careful: most %d will expand to the empty string. Quote properly! # NOTE: we could use %D directly, but it's not available in git 1.9.1 at least. - commits=("${(f)"$(_call_program commits git --no-pager log ${(q)commit_opts} -20 --format='%h%n%d%n%s\ \(%cr\)%n%p')"}") + commits=("${(f)"$(_call_program commits git --no-pager rev-list -20 --format='%h%n%d%n%s\ \(%cr\)%n%p' HEAD ${(q)commit_opts})"}") __git_command_successful $pipestatus || return 1 - for i j k parents in "$commits[@]" ; do + # h => hard-coded 'commit abcdef1234567890...' -- just discarded + for h i j k parents in "$commits[@]" ; do # Note: the after-the-colon part must be unique across the entire array; # see workers/34768 if (( $#commit_opts )); then @@ -6582,7 +6844,7 @@ __git_recent_commits () { _wanted commit-tags expl 'commit tag' compadd "$@" -a - tags && ret=0 expl=() _wanted heads expl 'head' compadd -M "r:|/=* r:|=*" "$@" -a - heads && ret=0 - return $ret + return ret } (( $+functions[__git_blob_objects] )) || @@ -6729,7 +6991,7 @@ __git_tags_of_type () { tags=(${${(M)${(f)"$(_call_program ${(q)type}-tag-refs "git for-each-ref --format='%(*objecttype)%(objecttype) %(refname)' refs/tags 2>/dev/null")"}:#$type(tag|) *}#$type(tag|) refs/tags/}) __git_command_successful $pipestatus || return 1 - _wanted $type-tags expl "$type tag" compadd -M 'r:|/=* r:|=*' "$@" -a - tags + _wanted $type-tags expl "$type tag" compadd -M 'r:|/=* r:|=*' "$@" -o numeric -a - tags } # Reference Argument Types @@ -6824,7 +7086,7 @@ __git_files_relative () { __git_files () { local compadd_opts opts tag description gitcdup gitprefix files expl - zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F: + zparseopts -D -E -a compadd_opts V+: J+: 1 2 o+: n f x+: X+: M+: P: S: r: R: q F: zparseopts -D -E -a opts -- -cached -deleted -modified -others -ignored -unmerged -killed x+: --exclude+: tag=$1 description=$2; shift 2 @@ -6955,7 +7217,7 @@ __git_tree_files () { shift fi - zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F: + zparseopts -D -E -a compadd_opts V+: J+: 1 2 o+: n f x+: X+: M+: P: S: r: R: q F: [[ "$1" == */ ]] && Path="$1" || Path="${1:h}/" shift @@ -7035,7 +7297,7 @@ __git_any_repositories_or_references () { __git_guard () { declare -A opts - zparseopts -K -D -A opts M: J: V: 1 2 n F: X: + zparseopts -K -D -A opts M+: J+: V+: 1 2 o+: n F: x+: X+: [[ "$PREFIX$SUFFIX" != $~1 ]] && return 1 @@ -7073,7 +7335,7 @@ __git_guard_diff-stat-width () { __git_guard_number () { declare -A opts - zparseopts -K -D -A opts M: J: V: 1 2 n F: X: + zparseopts -K -D -A opts M+: J+: V+: 1 2 o+: n F: x+: X+: _guard '[[:digit:]]#' ${1:-number} } @@ -7131,15 +7393,21 @@ __git_setup_diff_options () { '(--minimal --patience --histogram --diff-algorithm)--minimal[spend extra time to make sure the smallest possible diff is produced]' '(--minimal --patience --histogram --diff-algorithm)--patience[generate diffs with patience algorithm]' '(--minimal --patience --histogram --diff-algorithm)--histogram[generate diffs with histogram algorithm]' + '(--minimal --patience --histogram --diff-algorithm)*--anchored=[generate diffs using the "anchored diff" algorithm]:text' '(--minimal --patience --histogram --diff-algorithm)--diff-algorithm=[choose a diff algorithm]:diff algorithm:((default\:"basic greedy diff algorithm" myers\:"basic greedy diff algorithm" minimal\:"spend extra time to make sure the smallest possible diff is produced" patience\:"generate diffs with patience algorithm" histogram\:"generate diffs with histogram algorithm"))' '--stat=-[generate diffstat instead of patch]:: :__git_guard_diff-stat-width' + '--stat-width=-[generate diffstat with a given width]:width' + '--stat-graph-width=-[generate diffstat with a given graph width]:width' + '--stat-count=[generate diffstat with limited lines]:lines' + '--compact-summary[generate compact summary in diffstat]' '--numstat[generate more machine-friendly diffstat]' '--shortstat[generate summary diffstat]' - '--dirstat=-[generate dirstat by amount of changes]:: :__git_guard_number limit' + '--dirstat=-[generate dirstat by amount of changes]:: :_git_dirstat_params' + '--cumulative[synonym for --dirstat=cumulative]' '--dirstat-by-file=-[generate dirstat by number of files]:: :__git_guard_number limit' '--summary[generate condensed summary of extended header information]' '--patch-with-stat[generate patch and prepend its diffstat]' @@ -7163,18 +7431,25 @@ __git_setup_diff_options () { blocks\:"greedily detect blocks of moved text of at least 20 characters" zebra\:"like blocks, with alternating colors between different blocks" dimmed-zebra\:"like zebra, uninteresting parts are dimmed"))' + '(--no-color-moved-ws)--color-moved-ws=[configure how whitespace is ignored when performing move detection for --color-moved]:mode:_sequence compadd - no ignore-space-at-eol ignore-space-change ignore-all-space allow-indentation-change' + "(--color-moved-ws)--no-color-moved-ws=[don't ignore whitespace when performing move detection]" + "--ita-invisible-in-index[hide 'git add -N' entries from the index]" + "!(--ita-invisible-in-index)--ita-visible-in-index" '--no-renames[turn off rename detection]' $exclusive_diff_options'--check[warn if changes introduce trailing whitespace or space/tab indents]' '--full-index[show full object name of pre- and post-image blob]' '(--full-index)--binary[in addition to --full-index, output binary diffs for git-apply]' + '--ws-error-highlight=[specify where to highlight whitespace errors]: :_values -s , "kind of line" all default none context old new' '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length' '(-B --break-rewrites)'{-B-,--break-rewrites=-}'[break complete rewrite changes into pairs of given size]:: :__git_guard_number size' '(-M --find-renames)'{-M-,--find-renames=-}'[detect renames with given scope]:: :__git_guard_number size' '(-C --find-copies)'{-C-,--find-copies=-}'[detect copies as well as renames with given scope]:: :__git_guard_number size' '--find-copies-harder[try harder to find copies]' '(-D --irreversible-delete)'{-D,--irreversible-delete}'[omit the preimage for deletes]' + '--rename-empty[use empty blobs as rename source]' + '--follow[continue listing the history of a file beyond renames]' '-l-[limit number of rename/copy targets to run]: :__git_guard_number' - '--diff-filter=-[select certain kinds of files for diff]: :_guard "[AaCcDdMmRrTtUuXxBb*]#" kinds' + '--diff-filter=-[select certain kinds of files for diff]: :_git_diff_filters' '-S-[look for differences that add or remove the given string]:string' '-G-[look for differences whose added or removed line matches the given regex]:pattern' '--find-object=[look for differences that change the number of occurrences of the specified object]:object:__git_blobs' @@ -7185,10 +7460,15 @@ __git_setup_diff_options () { '--relative=-[exclude changes outside and output relative to given directory]:: :_directories' '(-a --text)'{-a,--text}'[treat all files as text]' '--ignore-space-at-eol[ignore changes in whitespace at end of line]' + '--ignore-cr-at-eol[ignore carriage-return at end of line]' '(-b --ignore-space-change -w --ignore-all-space)'{-b,--ignore-space-change}'[ignore changes in amount of white space]' '(-b --ignore-space-change -w --ignore-all-space)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' '--ignore-blank-lines[do not show hunks that add or remove blank lines]' + '--no-indent-heuristic[disable heuristic that shifts diff hunk boundaries to make patches easier to read]' '--inter-hunk-context=[combine hunks closer than n lines]:n' + '--output-indicator-new=[specify the character to indicate a new line]:character [+]' + '--output-indicator-old=[specify the character to indicate a old line]:character [-]' + '--output-indicator-context=[specify the character to indicate a context line]:character [ ]' '--exit-code[report exit code 1 if differences, 0 otherwise]' '( --no-ext-diff)--ext-diff[allow external diff helper to be executed]' '(--ext-diff )--no-ext-diff[disallow external diff helper to be executed]' @@ -7197,6 +7477,7 @@ __git_setup_diff_options () { '--ignore-submodules[ignore changes to submodules]:: :__git_ignore_submodules_whens' '(--no-prefix)--src-prefix=[use given prefix for source]:prefix' '(--no-prefix)--dst-prefix=[use given prefix for destination]:prefix' + '--line-prefix=[prepend additional prefix to every line of output]:prefix' '(--src-prefix --dst-prefix)--no-prefix[do not show any source or destination prefix]' '(-c --cc)'{-c,--cc}'[combined diff format for merge commits]' @@ -7238,6 +7519,8 @@ __git_format_placeholders() { 'G?:indicate [G]ood, [B]ad, [U]ntrusted or [N]o signature' 'GS:name of signer' 'GK:signing key' + 'GF:fingerprint of signing key' + 'GP:fingerprint of primary key whose subkey was used to sign' ) disp=( -l ) elif [[ -prefix %g ]]; then @@ -7245,6 +7528,7 @@ __git_format_placeholders() { gD:'reflog selector' gd:'short reflog selector' gn:'reflog identity' + gN:'reflog identity name' ge:'reflog identity email' gE:'reflog identity email (use .mailmap)' gs:'reflog subject' @@ -7276,6 +7560,7 @@ __git_format_placeholders() { c:'committer details' d:'ref name in brackets' D:'ref name' + S:'ref name used to reach commit' e:encoding s:subject f:'sanitized subject' @@ -7409,6 +7694,7 @@ __git_setup_merge_options () { '(--commit )--no-commit[perform the merge but do not commit the result]' '( --no-edit -e)--edit[open an editor to change the commit message]' "(--edit -e)--no-edit[don't open an editor to change the commit message]" + '--cleanup=[specify how to strip spaces and #comments from message]:mode:_git_cleanup_modes' '( --no-ff)--ff[do not generate a merge commit if the merge resolved as a fast-forward]' '(--ff )--no-ff[generate a merge commit even if the merge resolved as a fast-forward]' '( --no-log)--log=-[add entries from shortlog to merge commit message]::entries to add' @@ -7444,7 +7730,7 @@ __git_setup_fetch_options () { '(-4 --ipv4 -6 --ipv6)'{-4,--ipv4}'[use IPv4 addresses only]' '(-4 --ipv4 -6 --ipv6)'{-6,--ipv6}'[use IPv6 addresses only]' '--dry-run[show what would be done, without making any changes]' - '(-f --force)'{-f,--force}'[allow refs that are not ancestors to be updated]' + '(-f --force)'{-f,--force}'[force overwrite of local reference]' '(-k --keep)'{-k,--keep}'[keep downloaded pack]' '(-p --prune)'{-p,--prune}'[remove any remote tracking branches that no longer exist remotely]' '(--no-tags -t --tags)'{-t,--tags}'[fetch remote tags]' @@ -7459,7 +7745,10 @@ __git_setup_fetch_options () { '--submodule-prefix=-[prepend <path> to paths printed in informative messages]:submodule prefix path:_files -/' '(-q --quiet -v --verbose --progress)'{-q,--quiet}'[suppress all output]' '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]' - '(-q --quiet)--progress[force progress reporting]') + '(-q --quiet)--progress[force progress reporting]' + '--show-forced-updates[check for forced-updates on all updated branches]' + '--set-upstream[set upstream for git pull/fetch]' + ) } (( $+functions[__git_setup_apply_options] )) || @@ -7658,6 +7947,7 @@ __git_diff-or-merge-tools () { p4merge tkdiff tortoisemerge + smerge vimdiff vimdiff2 vimdiff3 @@ -7761,6 +8051,7 @@ __git_sendemail_suppresscc_values () { cccmd:'avoid running --cc-cmd' \ tocmd:'avoid running --to-cmd' \ body:'equivalent to sob + bodycc' \ + misc-by:'avoid including anyone mentioned in various "-by" lines in the patch body' \ all:'avoid all auto Cc values' } @@ -7791,6 +8082,7 @@ _git() { local -a aliases local -A git_aliases local a k v + local endopt='!(-)--end-of-options' aliases=(${(0)"$(_call_program aliases git config -z --get-regexp '\^alias\.')"}) for a in ${aliases}; do k="${${a/$'\n'*}/alias.}" @@ -7835,7 +8127,7 @@ _git() { '(-p --paginate -P --no-pager)'{-P,--no-pager}"[don't pipe git output into a pager]" \ '--git-dir=-[path to repository]: :_directories' \ '--work-tree=-[path to working tree]: :_directories' \ - '--namespace=-[set the Git namespace]: :_directories' \ + '--namespace=-[set the Git namespace]:namespace' \ '--bare[use $PWD as repository]' \ '--no-replace-objects[do not use replacement refs to replace git objects]' \ '--literal-pathspecs[treat pathspecs literally, rather than as glob patterns]' \ diff --git a/Completion/Unix/Command/_gnutls b/Completion/Unix/Command/_gnutls index 1c14de791..6c9956b10 100644 --- a/Completion/Unix/Command/_gnutls +++ b/Completion/Unix/Command/_gnutls @@ -38,6 +38,8 @@ case "$service" in '*--x509keyfile=[specify X.509 key file to use]:file:_files' '*--x509certfile=[specify X.509 certificate file to use]:file:_files' '(-l --list -p --port)'{-l,--list}'[print list of the supported algorithms/modes]' + '--keymatexport=[specify label used for exporting keying material]:label' + '--keymatexportsize=[specify size of the exported keying material]:size' ) ;| gnutls-cli|gnutls-serv|certtool) @@ -60,6 +62,7 @@ case "$service" in '--no-ca-verification[disable CA certificate verification]' '!--ca-verification' '--ocsp[enable OCSP certificate verification]' '!--no-oscp' '(-r --resume)'{-r,--resume}'[establish a session and resume]' + '--earlydata=[send early data on resumption from the specified file]:file:_files' '(-e --rehandshake)'{-e,--rehandshake}'[connect, establish a session and rehandshake immediately]' "--verify-hostname-str=[specify server's hostname to use for validation]:hostname" '(-s --starttls)'{-s,--starttls}'[start TLS on EOF or SIGALRM]' @@ -82,13 +85,14 @@ case "$service" in '--benchmark-tls-ciphers[benchmark TLS ciphers]' '--priority-list[print list of the supported priority strings]' '*--alpn=[enable application layer protocol]:string' - '--recordsize=[specify maximum record size to advertize]:record size' + '--recordsize=[specify maximum record size to advertise]:record size (0-4096)' "--disable-sni[don't send a Server Name]" '--single-key-share[send a single key share under TLS1.3]' '--post-handshake-auth[enable post-handshake authentication under TLS1.3]' '--inline-commands[inline commands of the form ^<cmd>^]' '--inline-commands-prefix=[change delimiter used for inline commands]:delimiter [^]' '--fips140-mode[report status of FIPS140-2 mode in gnutls library]' + '--logfile=[redirect informational messages to a specific file]:file:_files' ) ;; @@ -97,6 +101,8 @@ case "$service" in '--sni-hostname-fatal[send fatal alert on sni-hostname mismatch]' '*--alpn=[specify ALPN protocol to be enabled by the server]:protocol' '--alpn-fatal[send fatal alert on non-matching ALPN name]' + '--earlydata[accept early data]' + '--maxearlydata=[specify maximum early data size to accept]:size' "--nocookie[don't require cookie on DTLS sessions]" '(-g --generate)'{-g,--generate}'[generate Diffie-Hellman parameters]' '(-q --quiet)'{-q,--quiet}'[suppress some messages]' @@ -113,6 +119,8 @@ case "$service" in '--pskhint=[specify PSK identity hint to use]:string' '*--ocsp-response=[specify OCSP response to send to client]:string:_files' '--ignore-ocsp-response-errors[ignore any errors when setting the OCSP response]' + '--recordsize=[specify maximum record size to advertise]:record size (0-16384)' + '--httpdata=[specify data to use as HTTP response]:file:_files' ) ;; @@ -189,6 +197,8 @@ case "$service" in '--stdout-info[print information to stdout instead of stderr]' '--ask-pass[enable interaction for entering password when in batch mode]' '--pkcs-cipher=[specify cipher to use for pkcs operations]:cipher:(3des 3des-pkcs12 aes-128 aes-192 aes-256 rc2-40 arcfour)' + '!(--no-text)--text' + "--no-text[don't output textual information before PEM-encoded certificates, private keys, etc]" ) ;; 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/_grep b/Completion/Unix/Command/_grep index d3e1b1a6e..81516b08a 100644 --- a/Completion/Unix/Command/_grep +++ b/Completion/Unix/Command/_grep @@ -109,7 +109,7 @@ case $variant:$OSTYPE in gpl2:*) arguments=( ${${arguments:#*\)-r}/\)-r/\)-R} ) ;; *:openbsd*) arguments=( - ${(M)arguments:#((#s)|*\))--(context|binary-files|line-buffered)*} + ${(M)arguments:#((#s)|*\))--(context|binary-files|line-buffered|label|max-count)*} ${${arguments:#((#s)|*\))(\*|)-[d-]*}/\)-r/\)-R} "-U[search binary files but don't print them]" '-Z[behave as zgrep]' diff --git a/Completion/Unix/Command/_growisofs b/Completion/Unix/Command/_growisofs index 741a7516b..8f4da4030 100644 --- a/Completion/Unix/Command/_growisofs +++ b/Completion/Unix/Command/_growisofs @@ -208,7 +208,7 @@ else '-G[specify path and file-name of a generic boot-image]:boot image:_files' \ '-hard-disk-boot[specify that the el torito boot-image is a hard-disk image]' \ '-no-emul-boot[specify that the el torito boot-image is a "no emulation" image]' \ - '-no-boot[specify that the el torito CD should be markes an non-bootable]' \ + '-no-boot[specify that the el torito CD should be marked non-bootable]' \ '-boot-load-seg[specify the load-segment address of the boot-image for a "no emulation" image]:segment address' \ '-boot-lead-size[specify the number of 512-byte sectors to load in "no emulation" mode]:load sectors' \ '-boot-info-table[specify that a 56-byte table of CD-ROM-layout information should be written]' \ diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg deleted file mode 100644 index 7b72605b3..000000000 --- a/Completion/Unix/Command/_hg +++ /dev/null @@ -1,1077 +0,0 @@ -#compdef hg - -# Zsh completion script for mercurial. Rename this file to _hg and copy -# it into your zsh function path (/usr/share/zsh/site-functions for -# instance) -# -# If you do not want to install it globally, you can copy it somewhere -# else and add that directory to $fpath. This must be done before -# compinit is called. If the file is copied to ~/.zsh.d, your ~/.zshrc -# file could look like this: -# -# fpath=("$HOME/.zsh.d" $fpath) -# autoload -U compinit -# compinit -# -# Copyright (C) 2005, 2006 Steve Borho <steve@borho.org> -# Copyright (C) 2006-9 Brendan Cully <brendan@kublai.com> -# -# Permission is hereby granted, without written agreement and without -# licence or royalty fees, to use, copy, modify, and distribute this -# software and to distribute modified versions of this software for any -# purpose, provided that the above copyright notice and the following -# two paragraphs appear in all copies of this software. -# -# In no event shall the authors be liable to any party for direct, -# indirect, special, incidental, or consequential damages arising out of -# the use of this software and its documentation, even if the authors -# have been advised of the possibility of such damage. -# -# The authors specifically disclaim any warranties, including, but not -# limited to, the implied warranties of merchantability and fitness for -# a particular purpose. The software provided hereunder is on an "as -# is" basis, and the authors have no obligation to provide maintenance, -# support, updates, enhancements, or modifications. - -emulate -LR zsh -setopt extendedglob - -local curcontext="$curcontext" state line -typeset -A _hg_cmd_globals - -_hg() { - local cmd _hg_root - integer i=2 - _hg_cmd_globals=() - - while (( i < $#words )) - do - case "$words[$i]" in - -R|--repository) - eval _hg_root="$words[$i+1]" - _hg_cmd_globals+=("$words[$i]" "$_hg_root") - (( i += 2 )) - continue - ;; - -R*) - _hg_cmd_globals+="$words[$i]" - eval _hg_root="${words[$i]#-R}" - (( i++ )) - continue - ;; - --cwd|--config) - # pass along arguments to hg completer - _hg_cmd_globals+=("$words[$i]" "$words[$i+1]") - (( i += 2 )) - continue - ;; - -*) - # skip option - (( i++ )) - continue - ;; - esac - if [[ -z "$cmd" ]] - then - cmd="$words[$i]" - words[$i]=() - (( CURRENT-- )) - fi - (( i++ )) - done - - if [[ -z "$cmd" ]] - then - _arguments -s -S : $_hg_global_opts \ - ':mercurial command:_hg_commands' - return - fi - - # resolve abbreviations and aliases - if ! (( $+functions[_hg_cmd_${cmd}] )) - then - local cmdexp - (( $#_hg_cmd_list )) || _hg_get_commands - - cmdexp=$_hg_cmd_list[(r)${cmd}*] - if [[ $cmdexp == $_hg_cmd_list[(R)${cmd}*] ]] - then - # might be nice to rewrite the command line with the expansion - cmd="$cmdexp" - fi - if [[ -n $_hg_alias_list[$cmd] ]] - then - cmd=$_hg_alias_list[$cmd] - fi - fi - - curcontext="${curcontext%:*:*}:hg-${cmd}:" - - zstyle -s ":completion:$curcontext:" cache-policy update_policy - - if [[ -z "$update_policy" ]] - then - zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy - fi - - if (( $+functions[_hg_cmd_${cmd}] )) - then - _hg_cmd_${cmd} - else - # complete unknown commands normally - _arguments -s -S : $_hg_global_opts \ - '*:files:_hg_files' - fi -} - -_hg_cache_policy() { - typeset -a old - - # cache for a minute - old=( "$1"(mm+10) ) - (( $#old )) && return 0 - - return 1 -} - -_hg_get_commands() { - typeset -ga _hg_cmd_list - typeset -gA _hg_alias_list - local hline cmd cmdalias - - _call_program hg hg debugcomplete -v | while read -A hline - do - cmd=$hline[1] - _hg_cmd_list+=($cmd) - - for cmdalias in $hline[2,-1] - do - _hg_cmd_list+=($cmdalias) - _hg_alias_list+=($cmdalias $cmd) - done - done -} - -_hg_commands() { - (( $#_hg_cmd_list )) || _hg_get_commands - _describe -t commands 'mercurial command' _hg_cmd_list -} - -_hg_revrange() { - compset -P 1 '*:' - _hg_tags "$@" -} - -_hg_tags_internal() { - local -a expl - typeset -a hgtags - hgtags=( ${(f)"$(_hg_cmd tags -q 2>/dev/null)"} ) - _wanted tags expl 'tags' compadd -a - hgtags -} - -_hg_bookmarks_internal() { - local -a expl - typeset -a hgbookmarks - hgbookmarks=( ${(f)"$(_hg_cmd bookmarks -q 2>/dev/null)"} ) - _wanted bookmarks expl 'bookmarks' compadd -a - hgbookmarks -} - -_hg_branches_internal() { - local -a expl - typeset -a hgbranches - hgbranches=( ${(f)"$(_hg_cmd branches -q 2>/dev/null)"} ) - _wanted branches expl 'branches' compadd -a - hgbranches -} - -_hg_tags() { - _alternative \ - 'bookmarks:bookmark:_hg_bookmarks_internal' \ - 'tags:tag:_hg_tags_internal' -} - -# likely merge candidates -_hg_mergerevs() { - typeset -a heads - local revset='sort(head() and not ., -rev)' - - heads=(${(f)"$(_hg_cmd log -r '$revset' --template '{rev}\\n')"}) - (( $#heads )) && _describe -t heads 'heads' heads -} - -_hg_files() { - if [[ -n "$_hg_root" ]] - then - [[ -d "$_hg_root/.hg" ]] || return - case "$_hg_root" in - /*) - _files -W $_hg_root - ;; - *) - _files -W $PWD/$_hg_root - ;; - esac - else - _files - fi -} - -_hg_status() { - [[ -d $PREFIX ]] || PREFIX=$PREFIX:h - status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX 2>/dev/null)"}) -} - -_hg_unknown() { - typeset -a status_files - _hg_status u - _wanted files expl 'unknown files' _multi_parts / status_files -} - -_hg_missing() { - typeset -a status_files - _hg_status d - _wanted files expl 'missing files' _multi_parts / status_files -} - -_hg_modified() { - typeset -a status_files - _hg_status m - _wanted files expl 'modified files' _multi_parts / status_files -} - -_hg_committable() { - typeset -a status_files - # A file is a candidate for `hg commit` if it is: - # - modified (m), or - # - added (a), or - # - removed (r) - _hg_status mar - _wanted files expl 'committable files' _multi_parts / status_files -} - -_hg_resolve() { - local rstate rpath - - [[ -d $PREFIX ]] || PREFIX=$PREFIX:h - - _hg_cmd resolve -l ./$PREFIX 2> /dev/null | while read rstate rpath - do - [[ $rstate == 'R' ]] && resolved_files+=($rpath) - [[ $rstate == 'U' ]] && unresolved_files+=($rpath) - done -} - -_hg_resolved() { - typeset -a resolved_files unresolved_files - _hg_resolve - _wanted files expl 'resolved files' _multi_parts / resolved_files -} - -_hg_unresolved() { - typeset -a resolved_files unresolved_files - _hg_resolve - _wanted files expl 'unresolved files' _multi_parts / unresolved_files -} - -_hg_config() { - typeset -a items - items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*}) - (( $#items )) && _describe -t config 'config item' items -} - -_hg_internal_merge_tools=( - \\:dump \\:fail \\:local \\:merge \\:merge-local \\:merge-other \\:merge3 - \\:other \\:prompt \\:tagmerge \\:union -) - -_hg_merge_tools() { - typeset -a external_tools - _describe -t internal_tools 'internal merge tools' _hg_internal_merge_tools - external_tools=(${(f)"$(_hg_cmd showconfig merge-tools | cut -d . -f 2)"}) - (( $#external_tools )) && _describe -t external_tools 'external merge tools' external_tools -} - -_hg_addremove() { - _alternative 'files:unknown files:_hg_unknown' \ - 'files:missing files:_hg_missing' -} - -_hg_ssh_urls() { - if [[ -prefix */ ]] - then - if zstyle -T ":completion:${curcontext}:files" remote-access - then - local host=${PREFIX%%/*} - typeset -a remdirs - compset -p $(( $#host + 1 )) - local rempath=${(M)PREFIX##*/} - local cacheid="hg:${host}-${rempath//\//_}" - cacheid=${cacheid%[-_]} - compset -P '*/' - if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" - then - remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/}) - _store_cache "$cacheid" remdirs - fi - _describe -t directories 'remote directory' remdirs -S/ - else - _message 'remote directory' - fi - else - if compset -P '*@' - then - _hosts -S/ - else - _alternative 'hosts:remote host name:_hosts -S/' \ - 'users:user:_users -S@' - fi - fi -} - -_hg_urls() { - if compset -P bundle:// - then - _files - elif compset -P ssh:// - then - _hg_ssh_urls - elif [[ -prefix *: ]] - then - _urls - else - local expl - compset -S '[^:]*' - _wanted url-schemas expl 'URL schema' compadd -S '' - \ - http:// https:// ssh:// bundle:// - fi -} - -_hg_paths() { - typeset -a paths pnames - _hg_cmd paths 2> /dev/null | while read -A pnames - do - paths+=($pnames[1]) - done - (( $#paths )) && _describe -t path-aliases 'repository alias' paths -} - -_hg_remote() { - _alternative 'path-aliases:repository alias:_hg_paths' \ - 'directories:directory:_files -/' \ - 'urls:URL:_hg_urls' -} - -_hg_clone_dest() { - _alternative 'directories:directory:_files -/' \ - 'urls:URL:_hg_urls' -} - -# Common options -_hg_global_opts=( - '(--repository -R)'{-R+,--repository=}'[repository root directory or name of overlay bundle file]:repository:_files -/' - '--cwd=[change working directory]:new working directory:_files -/' - '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, automatically pick the first choice for all prompts]' - '(--verbose -v)'{-v,--verbose}'[enable additional output]' - '*--config[set/override config option]:defined config items:_hg_config' - '(--quiet -q)'{-q,--quiet}'[suppress output]' - '(--help -h)'{-h,--help}'[display help and exit]' - '--debug[enable debugging output]' - '--debugger[start debugger]' - '--encoding=[set the charset encoding]:encoding' - '--encodingmode=[set the charset encoding mode]:encoding mode' - '--traceback[always print a traceback on exception]' - '--time[time how long the command takes]' - '--profile[print command execution profile]' - '--version[output version information and exit]' - '--hidden[consider hidden changesets]' -) - -_hg_pat_opts=( - '*'{-I+,--include=}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/' - '*'{-X+,--exclude=}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/') - -_hg_diff_opts=( - '(--text -a)'{-a,--text}'[treat all files as text]' - '(--git -g)'{-g,--git}'[use git extended diff format]' - '--nodates[omit dates from diff headers]' -) - -_hg_mergetool_opts=( - '(--tool -t)'{-t+,--tool=}'[specify merge tool]:merge tool:_hg_merge_tools' -) - -_hg_dryrun_opts=( - '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]') - -_hg_template_opts=( - '--template[display with template]:template' -) - -_hg_commit_opts=( - '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]' - '(-e --edit -l --logfile --message -m)'{-m+,--message=}'[use <text> as commit message]:message:' - '(-e --edit -m --message --logfile -l)'{-l+,--logfile=}'[read the commit message from <file>]:log file:_files') - -_hg_remote_opts=( - '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:command' - '--remotecmd=[specify hg command to run on the remote side]:remote command' - '--insecure[do not verify server certificate (ignoring web.cacerts config)]' -) - -_hg_subrepos_opts=( - '(--subrepos -S)'{-S,--subrepos}'[recurse into subrepositories]' -) - -_hg_cmd() { - _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \ - "$_hg_cmd_globals[@]" "$@" 2> /dev/null -} - -_hg_cmd_add() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \ - '*:unknown files:_hg_unknown' -} - -_hg_cmd_addremove() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \ - '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \ - '*:unknown or missing files:_hg_addremove' -} - -_hg_cmd_annotate() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ - '(--rev -r)'{-r+,--rev=}'[annotate the specified revision]:revision:_hg_tags' \ - "--no-follow[don't follow copies and renames]" \ - '(--text -a)'{-a,--text}'[treat all files as text]' \ - '(--user -u)'{-u,--user}'[list the author (long with -v)]' \ - '(--file -f)'{-f,--file}'[list the filename]' \ - '(--date -d)'{-d,--date}'[list the date (short with -q)]' \ - '(--number -n)'{-n,--number}'[list the revision number (default)]' \ - '(--changeset -c)'{-c,--changeset}'[list the changeset]' \ - '(--line-number -l)'{-l,--line-number}'[show line number at the first appearance]' \ - '*:files:_hg_files' -} - -_hg_cmd_archive() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ - '--no-decode[do not pass files through decoders]' \ - '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:prefix' \ - '(--rev -r)'{-r+,--rev=}'[revision to distribute]:revision:_hg_tags' \ - '(--type -t)'{-t+,--type=}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \ - '*:destination:_files' -} - -_hg_cmd_backout() { - _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \ - '--merge[merge with old dirstate parent after backout]' \ - '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ - '--parent[parent to choose when backing out merge]' \ - '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ - '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ - '(--message -m)'{-m+,--message=}'[specify commit message]:text' \ - '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' -} - -_hg_cmd_bisect() { - _arguments -s -S : $_hg_global_opts \ - '(-)'{-r,--reset}'[reset bisect state]' \ - '(--extend -e)'{-e,--extend}'[extend the bisect range]' \ - '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_tags \ - '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_tags \ - '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \ - '(--command -c --noupdate -U)'{-c+,--command=}'[use command to check changeset state]':commands:_command_names \ - '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]' -} - -_hg_cmd_bookmarks() { - _arguments -s -S : $_hg_global_opts \ - '(--force -f)'{-f,--force}'[force]' \ - '(--rev -r --delete -d --rename -m)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \ - '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \ - '(--rev -r --delete -d --rename -m)'{-m+,--rename=}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \ - '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \ - ':bookmark:_hg_bookmarks_internal' -} - -_hg_cmd_branch() { - _arguments -s -S : $_hg_global_opts \ - '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \ - '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]' -} - -_hg_cmd_branches() { - _arguments -s -S : $_hg_global_opts \ - '(--closed -c)'{-c,--closed}'[show normal and closed branches]' -} - -_hg_cmd_bundle() { - _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ - '(--force -f)'{-f,--force}'[run even when the destination is unrelated]' \ - '(2)*--base[a base changeset assumed to be available at the destination]:revision:_hg_tags' \ - '*'{-b+,--branch=}'[a specific branch you would like to bundle]:branch:_hg_branches_internal' \ - '*'{-r+,--rev=}'[a changeset intended to be added to the destination]:revision:_hg_tags' \ - '--all[bundle all changesets in the repository]' \ - '--type[bundle compression type to use (default: bzip2)]:bundle type' \ - ':output file:_files' \ - ':destination repository:_files -/' -} - -_hg_cmd_cat() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ - '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \ - '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ - '--decode[apply any matching decode filter]' \ - '*:file:_hg_files' -} - -_hg_cmd_clone() { - _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ - '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \ - '(--rev -r)'{-r+,--rev=}'[include the specified changeset]:revision' \ - '--uncompressed[use uncompressed transfer (fast over LAN)]' \ - ':source repository:_hg_remote' \ - ':destination:_hg_clone_dest' -} - -_hg_cmd_commit() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ - '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \ - '(--message -m)'{-m+,--message=}'[specify commit message]:text' \ - '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' \ - '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ - '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ - '--amend[amend the parent of the working directory]' \ - '--close-branch[mark a branch head as closed]' \ - '(--interactive -i)'{-i,--interactive}'[use interactive mode]' \ - '(--secret -s)'{-s,--secret}'[use the secret phase for committing]' \ - '*:file:_hg_committable' -} - -_hg_cmd_copy() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ - '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \ - '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ - '*:file:_hg_files' -} - -_hg_cmd_diff() { - local context state state_descr line ret=1 - typeset -A opt_args - - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts $_hg_subrepos_opts \ - '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \ - '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \ - '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \ - '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \ - '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \ - '*:file:->diff_files' && ret=0 - - if [[ $state == 'diff_files' ]] - then - if [[ -n ${opt_args[(I)-r|--rev]} ]] - then - _hg_files && ret=0 - else - _hg_modified && ret=0 - fi - fi - - return ret -} - -_hg_cmd_export() { - _arguments -s -S : $_hg_global_opts $_hg_diff_opts \ - '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \ - '--switch-parent[diff against the second parent]' \ - '*:revision:_hg_tags' -} - -_hg_cmd_forget() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ - '*:file:_hg_files' -} - -_hg_cmd_grep() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ - '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \ - '--all[print all revisions with matches]' \ - '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \ - '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \ - '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \ - '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \ - '*'{-r+,--rev=}'[search in given revision range]:revision:_hg_revrange' \ - '(--user -u)'{-u,--user}'[print user who committed change]' \ - '1:search pattern:' \ - '*:files:_hg_files' -} - -_hg_cmd_heads() { - _arguments -s -S : $_hg_global_opts $_hg_template_opts \ - '(--topo -t)'{-t,--topo}'[show topological heads only]' \ - '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \ - '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_tags' -} - -_hg_cmd_help() { - _arguments -s -S : $_hg_global_opts \ - '(--extension -e)'{-e,--extension}'[show only help for extensions]' \ - '(--command -c)'{-c,--command}'[show only help for commands]' \ - '(--keyword -k)'{-k,--keyword}'[show topics matching keyword]' \ - '*:mercurial command:_hg_commands' -} - -_hg_cmd_identify() { - _arguments -s -S : $_hg_global_opts \ - '(--rev -r)'{-r+,--rev=}'[identify the specified rev]:revision:_hg_tags' \ - '(--num -n)'{-n,--num}'[show local revision number]' \ - '(--id -i)'{-i,--id}'[show global revision id]' \ - '(--branch -b)'{-b,--branch}'[show branch]' \ - '(--tags -t)'{-t,--tags}'[show tags]' \ - '(--bookmarks -B)'{-B,--bookmarks}'[show bookmarks]' -} - -_hg_cmd_import() { - _arguments -s -S : $_hg_global_opts \ - '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count' \ - '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text:' \ - '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \ - '--bypass[apply patch without touching the working directory]' \ - '--no-commit[do not commit, just update the working directory]' \ - '--partial[commit even if some hunks fail]' \ - '--exact[abort if patch would apply lossily]' \ - '--import-branch[use any branch information in patch (implied by --exact)]' \ - '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ - '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ - '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \ - '*:patch:_files' -} - -_hg_cmd_incoming() { - _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_template_opts $_hg_subrepos_opts \ - '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \ - '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ - '(--patch -p)'{-p,--patch}'[show patch]' \ - '*'{-r+,--rev=}'[a remote changeset intended to be added]:revision:_hg_tags' \ - '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ - '--bundle[file to store the bundles into]:bundle file:_files' \ - ':source:_hg_remote' -} - -_hg_cmd_init() { - _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ - ':dir:_files -/' -} - -_hg_cmd_locate() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ - '(--rev -r)'{-r+,--rev=}'[search repository as it stood at revision]:revision:_hg_tags' \ - '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ - '(--fullpath -f)'{-f,--fullpath}'[print complete paths from the filesystem root]' \ - '*:search pattern:_hg_files' -} - -_hg_cmd_log() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_template_opts \ - '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \ - '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \ - '(--copies -C)'{-C,--copies}'[show copied files]' \ - '*'{-k+,--keyword=}'[search for a keyword]:keyword' \ - '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \ - '*'{-r+,--rev=}'[show the specified revision or revset]:revision:_hg_revrange' \ - '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \ - '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \ - '(--patch -p)'{-p,--patch}'[show patch]' \ - '*'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_tags' \ - '*:files:_hg_files' -} - -_hg_cmd_manifest() { - _arguments -s -S : $_hg_global_opts \ - '--all[list files from all revisions]' \ - ':revision:_hg_tags' -} - -_hg_cmd_merge() { - _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ - '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \ - '(--rev -r 1)'{-r+,--rev=}'[revision to merge]:revision:_hg_mergerevs' \ - '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \ - ':revision:_hg_mergerevs' -} - -_hg_cmd_outgoing() { - _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_template_opts $_hg_subrepos_opts \ - '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \ - '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ - '(--patch -p)'{-p,--patch}'[show patch]' \ - '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \ - '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ - ':destination:_hg_remote' -} - -_hg_cmd_parents() { - _arguments -s -S : $_hg_global_opts $_hg_template_opts \ - '(--rev -r)'{-r+,--rev=}'[show parents of the specified rev]:revision:_hg_tags' \ - ':last modified file:_hg_files' -} - -_hg_cmd_paths() { - _arguments -s -S : $_hg_global_opts \ - ':path:_hg_paths' -} - -_hg_cmd_phase() { - _arguments -s -S : $_hg_global_opts \ - '(--public -p --draft -d --secret -s)'{-p,--public}'[set changeset phase to public]' \ - '(--public -p --draft -d --secret -s)'{-d,--draft}'[set changeset phase to draft]' \ - '(--public -p --draft -d --secret -s)'{-s,--secret}'[set changeset phase to secret]' \ - '(--force -f)'{-f,--force}'[allow to move boundary backward]' \ - '*'{-r+,--rev=}'[target revision]:revision:_hg_tags' \ - '*:revision:_hg_tags' -} - -_hg_cmd_pull() { - _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ - '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ - '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision' \ - ':source:_hg_remote' -} - -_hg_cmd_push() { - _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ - '(--force -f)'{-f,--force}'[force push]' \ - '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \ - '*'{-B,--bookmark=}'[bookmark to push]:bookmark:_hg_bookmarks_internal' \ - '*'{-b,--branch=}'[branch to push]:branch:_hg_branches_internal' \ - '--new-branch[allow pushing a new branch]' \ - ':destination:_hg_remote' -} - -_hg_cmd_remove() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ - '(--after -A)'{-A,--after}'[record delete for missing files]' \ - '(--force -f)'{-f,--force}'[forget added files, delete modified files]' \ - '*:file:_hg_files' -} - -_hg_cmd_rename() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ - '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \ - '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ - '*:file:_hg_files' -} - -_hg_cmd_resolve() { - local context state state_descr line ret=1 - typeset -A opt_args - - _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ - '(--all -a)'{-a,--all}'[select all unresolved files]' \ - '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \ - '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \ - '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \ - '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[mark files as unresolved]:*:resolved files:_hg_resolved' \ - '*:file:_hg_unresolved' && ret=0 - - if [[ $state == 'resolve_files' ]] - then - _alternative 'files:resolved files:_hg_resolved' \ - 'files:unresolved files:_hg_unresolved' && ret=0 - fi - - return ret -} - -_hg_cmd_revert() { - local context state state_descr line ret=1 - typeset -A opt_args - - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ - '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \ - '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_tags' \ - '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \ - '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \ - '*:file:->diff_files' && ret=0 - - if [[ $state == 'diff_files' ]] - then - if [[ -n ${opt_args[(I)-r|--rev]} ]] - then - _hg_files && ret=0 - else - typeset -a status_files - _hg_status mard - _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files && ret=0 - fi - fi - - return ret -} - -_hg_cmd_serve() { - _arguments -s -S : $_hg_global_opts $_hg_subrepos_opts \ - '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file to write to]:log file:_files' \ - '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file to write to]:log file:_files' \ - '(--daemon -d)'{-d,--daemon}'[run server in background]' \ - '(--port -p)'{-p+,--port=}'[port to listen on (default: 8000)]:listen port' \ - '(--address -a)'{-a+,--address=}'[address to listen on (default: all interfaces)]:interface address' \ - '--prefix[prefix path to serve from (default: server root)]:prefix' \ - '(--name -n)'{-n+,--name=}'[name to show in web pages (default: working directory)]:repository name' \ - '--web-conf=[name of the hgweb config file]:config file:_files' \ - '--pid-file=[name of file to write process ID to]:pid file:_files' \ - '--cmdserver[for remote clients]' \ - '(--templates -t)'{-t+,--templates=}'[web template directory]:template dir:_files -/' \ - '--style=[web template style]:style' \ - '--stdio[for remote clients]' \ - '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]' \ - '--certificate=[SSL certificate file]:certificate file:_files' -} - -_hg_cmd_showconfig() { - _arguments -s -S : $_hg_global_opts \ - '(--untrusted -u)'{-u,--untrusted}'[show untrusted configuration options]' \ - '(--edit -e)'{-e,--edit}'[edit user config]' \ - '(--local -l --global -g)'{-l,--local}'[edit repository config]' \ - '(--local -l --global -g)'{-g,--global}'[edit global config]' \ - ':config item:_hg_config' -} - -_hg_cmd_status() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ - '(--all -A)'{-A,--all}'[show status of all files]' \ - '(--modified -m)'{-m,--modified}'[show only modified files]' \ - '(--added -a)'{-a,--added}'[show only added files]' \ - '(--removed -r)'{-r,--removed}'[show only removed files]' \ - '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \ - '(--clean -c)'{-c,--clean}'[show only files without changes]' \ - '(--unknown -u)'{-u,--unknown}'[show only unknown (not tracked) files]' \ - '(--ignored -i)'{-i,--ignored}'[show ignored files]' \ - '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \ - '(--copies -C)'{-C,--copies}'[show source of copied files]' \ - '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ - '*--rev=[show difference from revision]:revision:_hg_tags' \ - '--change=[list the changed files of a revision]:revision:_hg_tags' \ - '*:files:_files' -} - -_hg_cmd_summary() { - _arguments -s -S : $_hg_global_opts \ - '--remote[check for push and pull]' -} - -_hg_cmd_tag() { - _arguments -s -S : $_hg_global_opts \ - '(--local -l)'{-l,--local}'[make the tag local]' \ - '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message' \ - '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ - '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ - '(--rev -r)'{-r+,--rev=}'[revision to tag]:revision:_hg_tags' \ - '(--force -f)'{-f,--force}'[force tag]' \ - '--remove[remove a tag]' \ - ':tag name:' -} - -_hg_cmd_tip() { - _arguments -s -S : $_hg_global_opts $_hg_template_opts \ - '(--patch -p)'{-p,--patch}'[show patch]' -} - -_hg_cmd_unbundle() { - _arguments -s -S : $_hg_global_opts \ - '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \ - '*:files:_files' -} - -_hg_cmd_update() { - _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ - '(--clean -C)'{-C,--clean}'[discard uncommitted changes (no backup)]' \ - '(--check -c)'{-c,--check}'[require clean working directory]' \ - '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \ - '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ - ':revision:_hg_tags' -} - -# HGK -_hg_cmd_view() { - _arguments -s -S : $_hg_global_opts \ - '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \ - ':revision range:_hg_tags' -} - -# MQ -_hg_qseries() { - typeset -a patches - patches=(${(f)"$(_hg_cmd qseries 2> /dev/null)"}) - (( $#patches )) && _describe -t hg-patches 'patches' patches -} - -_hg_qapplied() { - typeset -a patches - patches=(${(f)"$(_hg_cmd qapplied 2> /dev/null)"}) - if (( $#patches )) - then - patches+=(qbase qtip) - _describe -t hg-applied-patches 'applied patches' patches - fi -} - -_hg_qunapplied() { - typeset -a patches - patches=(${(f)"$(_hg_cmd qunapplied 2> /dev/null)"}) - (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches -} - -# unapplied, including guarded patches -_hg_qdeletable() { - typeset -a unapplied - unapplied=(${(f)"$(_hg_cmd qseries 2> /dev/null)"}) - for p in $(_hg_cmd qapplied) - do - unapplied=(${unapplied:#$p}) - done - - (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied -} - -_hg_qguards() { - typeset -a guards - local guard - compset -P "+|-" - _hg_cmd qselect -s 2> /dev/null | while read guard - do - guards+=(${guard#(+|-)}) - done - (( $#guards )) && _describe -t hg-guards 'guards' guards -} - -_hg_qseries_opts=( - '(--summary -s)'{-s,--summary}'[print first line of patch header]') - -_hg_cmd_qapplied() { - _arguments -s -S : $_hg_global_opts $_hg_qseries_opts -} - -_hg_cmd_qdelete() { - _arguments -s -S : $_hg_global_opts \ - '(--keep -k)'{-k,--keep}'[keep patch file]' \ - '*'{-r+,--rev=}'[stop managing a revision]:applied patch:_hg_revrange' \ - '*:unapplied patch:_hg_qdeletable' -} - -_hg_cmd_qdiff() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ - '*:pattern:_hg_files' -} - -_hg_cmd_qfold() { - _arguments -s -S : $_hg_global_opts $_h_commit_opts \ - '(--keep -k)'{-k,--keep}'[keep folded patch files]' \ - '*:unapplied patch:_hg_qunapplied' -} - -_hg_cmd_qgoto() { - _arguments -s -S : $_hg_global_opts \ - '(--force -f)'{-f,--force}'[overwrite any local changes]' \ - ':patch:_hg_qseries' -} - -_hg_cmd_qguard() { - _arguments -s -S : $_hg_global_opts \ - '(--list -l)'{-l,--list}'[list all patches and guards]' \ - '(--none -n)'{-n,--none}'[drop all guards]' \ - ':patch:_hg_qseries' \ - '*:guards:_hg_qguards' -} - -_hg_cmd_qheader() { - _arguments -s -S : $_hg_global_opts \ - ':patch:_hg_qseries' -} - -_hg_cmd_qimport() { - _arguments -s -S : $_hg_global_opts \ - '(--existing -e)'{-e,--existing}'[import file in patch dir]' \ - '(--name -n 2)'{-n+,--name=}'[patch file name]:name:' \ - '(--force -f)'{-f,--force}'[overwrite existing files]' \ - '*'{-r+,--rev=}'[place existing revisions under mq control]:revision:_hg_revrange' \ - '*:patch:_files' -} - -_hg_cmd_qnew() { - _arguments -s -S : $_hg_global_opts $_hg_commit_opts \ - '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \ - ':patch:' -} - -_hg_cmd_qnext() { - _arguments -s -S : $_hg_global_opts $_hg_qseries_opts -} - -_hg_cmd_qpop() { - _arguments -s -S : $_hg_global_opts \ - '(--all -a :)'{-a,--all}'[pop all patches]' \ - '(--name -n)'{-n+,--name=}'[queue name to pop]:' \ - '(--force -f)'{-f,--force}'[forget any local changes]' \ - ':patch:_hg_qapplied' -} - -_hg_cmd_qprev() { - _arguments -s -S : $_hg_global_opts $_hg_qseries_opts -} - -_hg_cmd_qpush() { - _arguments -s -S : $_hg_global_opts \ - '(--all -a :)'{-a,--all}'[apply all patches]' \ - '(--list -l)'{-l,--list}'[list patch name in commit text]' \ - '(--merge -m)'{-m+,--merge=}'[merge from another queue]:' \ - '(--name -n)'{-n+,--name=}'[merge queue name]:' \ - '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \ - ':patch:_hg_qunapplied' -} - -_hg_cmd_qrefresh() { - _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \ - '(--git -g)'{-g,--git}'[use git extended diff format]' \ - '(--short -s)'{-s,--short}'[short refresh]' \ - '*:files:_hg_files' -} - -_hg_cmd_qrename() { - _arguments -s -S : $_hg_global_opts \ - ':patch:_hg_qseries' \ - ':destination:' -} - -_hg_cmd_qselect() { - _arguments -s -S : $_hg_global_opts \ - '(--none -n :)'{-n,--none}'[disable all guards]' \ - '(--series -s :)'{-s,--series}'[list all guards in series file]' \ - '--pop[pop to before first guarded applied patch]' \ - '--reapply[pop and reapply patches]' \ - '*:guards:_hg_qguards' -} - -_hg_cmd_qseries() { - _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \ - '(--missing -m)'{-m,--missing}'[print patches not in series]' -} - -_hg_cmd_qunapplied() { - _arguments -s -S : $_hg_global_opts $_hg_qseries_opts -} - -_hg_cmd_qtop() { - _arguments -s -S : $_hg_global_opts $_hg_qseries_opts -} - -_hg_cmd_strip() { - _arguments -s -S : $_hg_global_opts \ - '*'{-r+,--rev=}'[revision]:revision:_hg_tags' \ - '(--force -f)'{-f,--force}'[force removal of changesets, discard uncommitted changes (no backup)]' \ - '--no-backup[no backups]' \ - '(--keep -k)'{-k,--keep}'[do not modify working directory during strip]' \ - '*'{-B+,--bookmark=}'[remove revs only reachable from given bookmark]:bookmark:_hg_bookmarks_internal' \ - '*:revision:_hg_tags' -} - -_hg "$@" diff --git a/Completion/Unix/Command/_iconv b/Completion/Unix/Command/_iconv index d040be756..bf04acfe4 100644 --- a/Completion/Unix/Command/_iconv +++ b/Completion/Unix/Command/_iconv @@ -2,7 +2,7 @@ local expl curcontext="$curcontext" state line variant ret=1 -if _pick_variant -r variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC|Gentoo)' unix --version; then +if _pick_variant -r variant libiconv='GNU*libiconv' glibc='(Free Soft|GNU*libc|GLIBC|Gentoo)' unix --version; then local -a args local exargs="-l --list -? --help --usage --version -V" @@ -38,7 +38,7 @@ if _pick_variant -r variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC|Gent _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/_ifconfig b/Completion/Unix/Command/_ifconfig index c5b5af8d4..25ddd55bd 100644 --- a/Completion/Unix/Command/_ifconfig +++ b/Completion/Unix/Command/_ifconfig @@ -36,6 +36,9 @@ case $OSTYPE in {,-}wep {,-}nwkey add delete ether {,-}link{0,1,2} list wme wmm roam roam:rssi roam:rate roaming ) + ;| + dragonfly*) + args+=( '-n[disable auto-loading of kernel network interface driver]' ) ;; irix5*) opts=( $debug ) ;; irix6*) 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/_initctl b/Completion/Unix/Command/_initctl index 9d444c6d1..2d7c2494b 100644 --- a/Completion/Unix/Command/_initctl +++ b/Completion/Unix/Command/_initctl @@ -18,7 +18,7 @@ _initctl_fillarray_events_args () _initctl_events_list+=($match[1]) # this is a bit tricky, we take the string right of the matched event # and parse for \sUPPERCASE=\S (in perl-re syntax) substrings until there are no more matches - # since we can't do multiple matches, we concatenated the remaing strings and try again + # since we can't do multiple matches, we concatenated the remaining strings and try again local stml="$match[2]" while [[ "$stml" == (#b)(*)\ ([[:upper:]_]##\=)[^[:space:]](#b)(*) ]]; do _initctl_eventargs_list+=($match[2]) diff --git a/Completion/Unix/Command/_install b/Completion/Unix/Command/_install index 80a1b0c00..5ad84645e 100644 --- a/Completion/Unix/Command/_install +++ b/Completion/Unix/Command/_install @@ -25,7 +25,7 @@ if _pick_variant gnu='Free Soft' unix --version; then args+=( $common_args '(-b --backup)--backup=[create backup; optionally specify method]:: :->controls' - "${lx}--context=[like -Z, or specify SELinux security context to set]::SELinux security context" + "${lx}--context=-[like -Z, or specify SELinux security context to set]::SELinux security context:_selinux_contexts" '-D[create all leading destination path components]' '(: -)--help[display help information]' "${lx}--preserve-context[preserve SELinux security context]" @@ -64,14 +64,16 @@ else [[ $OSTYPE == (darwin|dragonfly)* ]] && args+=( '-M[disable use of mmap(2)]' ) + [[ $OSTYPE == (dragonfly|freebsd|netbsd)* ]] && args+=( + '(-C -c --compare)-l+[link files (rather than copy) using specified method]: :->linkflags' + '+N+[use user/group database files from specified directory]: :_directories' + '-U[indicate that install is unprivileged]' + ) [[ $OSTYPE == (freebsd|netbsd)* ]] && args+=( '-D+[specify destination directory used for metadata log]: :_directories' '-h+[store digest in metadata log using specified method]: :->digests' - '(-C -c --compare)-l+[link files (rather than copy) using specified method]: :->linkflags' '-M+[log mtree(8) metadata for installed files to specified file]:metadata log file:_files' - '+N+[use user/group database files from specified directory]: :_directories' '-T+[specify mtree(8) tags to store in metadata log]:mtree(8) tags' - '-U[indicate that install is unprivileged]' ) [[ $OSTYPE == netbsd* ]] || args+=( '-S[use temporary files to perform safe copy]' diff --git a/Completion/Unix/Command/_iostat b/Completion/Unix/Command/_iostat index 8909ae311..f5291a19b 100644 --- a/Completion/Unix/Command/_iostat +++ b/Completion/Unix/Command/_iostat @@ -4,42 +4,53 @@ local -a args parser parser=( -s -S -A '-*' ) case $OSTYPE:l in - *bsd*) + *bsd*|dragonfly*) args+=( - '-c[repeat the display N times]:count' + '-c+[repeat the display N times]:count' '-C[display CPU statistics]' '-d[display only device statistics]' '-I[display total statistics for a given period, rather than average]' - '-M[extract values of the name list from specified file]:core:_files' - '-N[extract the name list from the specified file]:system:_files' '-T[display TTY statistics]' - '-w[specify the duration of pauses between each display]:duration' + '-w+[specify the duration of pauses between each display]:duration' + '*: :_bsd_disks' ) ;| - freebsd*) + freebsd*|openbsd*|dragonfly*) + args+=( + '-M+[extract values of the name list from specified file]:core:_files' + '-N+[extract the name list from the specified file]:system:_files' + ) + ;| + freebsd*|dragonfly*) args+=( '-h[top mode]' '-K[display block count in kilobytes, not block size]' + '-n+[display up to the specified number fo devices]:number of disks' '-o[display old-style iostat device statistics]' - '-t[specify which type of device to display]: :->devicetype' + '*-t+[specify which type of device to display]: :_fbsd_device_types' + ) + ;| + freebsd*) + args+=( '-x[show extended disk statistics]' '-z[omit lines for devices with no activity]' - '-?[display a usage statement and exit]' - '*:drives:( ${${(M)${(f)"$(geom disk list)"}\:#Geom name\:*}#*\: } )' + '(* -)-?[display a usage statement and exit]' ) ;; - openbsd*) + dragonfly*) args+=( - '-D[display alternate disk statistics]' - '*:drives:( ${${(s.,.)"$(sysctl -n hw.disknames)"}%\:*} )' + '-D[display more details]' ) ;; - netbsd*) + openbsd*|netbsd*) args+=( '-D[display alternate disk statistics]' + ) + ;| + netbsd*) + args+=( '-x[show extended disk statistics]' '-y[report data on waiting and active requests]' - '*:drives:( $(sysctl -n hw.disknames) )' ) ;; aix*) @@ -97,16 +108,17 @@ case $OSTYPE:l in ;; darwin*) args=( + '(- *)-?[display usage statement and exit]' '-C[display CPU statistics]' - '-c[number of times to display statistics]' + '-c+[number of times to display statistics]:count' '-d[display only device statistics]' - '-l[total statistics for a given time period]' + '-I[display total statistics for a given period, rather than average]' '-K[display block count in kilobytes]' - '-n[limit the number of disks included in the report]:number of disks' + '-n+[limit the number of disks included in the report]:number of disks' '-o[display old-style iostat device statistics]' '-T[display TTY statistics]' '-U[display system load averages]' - '-w[specify the duration of pauses between each display]:duration' + '-w+[specify the duration of pauses between each display]:duration' '*::device:_files -W /dev -g "disk*"' ) ;; diff --git a/Completion/Unix/Command/_ip b/Completion/Unix/Command/_ip index 74101c646..9a7cbd821 100644 --- a/Completion/Unix/Command/_ip +++ b/Completion/Unix/Command/_ip @@ -542,6 +542,7 @@ _regex_words options "ip options" \ '-s*tatistics:output statistics' \ '-d*etails:output more detailed information' \ '-c*olor:color output' \ + '-br*ief:brief output' \ '-a*ll:executes specified command over all objects' \ '-f*amily:select protocol family:$subcmd_family' \ '-4:IPv4' \ diff --git a/Completion/Unix/Command/_java b/Completion/Unix/Command/_java index 30231c5ee..ee0441d97 100644 --- a/Completion/Unix/Command/_java +++ b/Completion/Unix/Command/_java @@ -111,7 +111,7 @@ javadoc) '-bottom[specify bottom text]:bottom text:' \ '-link[generate a link to external reference classes]:document URL:' \ '-linkoffline[generate a link for external reference class names]:document URL::package list URL:' \ - '-group[generate tables for each groupes]:group heading::package patterns:' \ + '-group[generate tables for each group]:group heading::package patterns:' \ '-nodeprecated[do not document deprecated API]' \ '-nodeprecatedlist[do not generate deprecated API list]' \ '-notree[do not generate class and interface hierarchy]' \ diff --git a/Completion/Unix/Command/_killall b/Completion/Unix/Command/_killall index 6fdb0f277..36accb2e0 100644 --- a/Completion/Unix/Command/_killall +++ b/Completion/Unix/Command/_killall @@ -32,7 +32,7 @@ if _pick_variant psmisc=PSmisc unix --version; then "*: :_process_names $opts" ) [[ $CURRENT = 2 || ( $CURRENT = 3 && $words[2] = (-Z|--context) ) ]] && \ - args+=( '(-Z --context)'{-Z+,--context=}'[specify SELinux security context]:regex pattern: ' ) + args+=( '(-Z --context)'{-Z+,--context=}'[specify SELinux security context]:regex pattern:_selinux_contexts' ) _arguments -s -S -C : $args && ret=0 diff --git a/Completion/Unix/Command/_ldconfig b/Completion/Unix/Command/_ldconfig index 3c3fca538..16ce3d680 100644 --- a/Completion/Unix/Command/_ldconfig +++ b/Completion/Unix/Command/_ldconfig @@ -62,7 +62,7 @@ case $OSTYPE in );| openbsd*) args+=( - '(-m)-U[unconfigure specified directories or inaccessable directories if none specified]' + '(-m)-U[unconfigure specified directories or inaccessible directories if none specified]' );| esac diff --git a/Completion/Unix/Command/_ldd b/Completion/Unix/Command/_ldd index 1de1659a5..3c7b088df 100644 --- a/Completion/Unix/Command/_ldd +++ b/Completion/Unix/Command/_ldd @@ -1,6 +1,6 @@ #compdef ldd -if _pick_variant gnu='(Free Soft|GNU|EGLIBC|Gentoo)' unix --version; then +if _pick_variant gnu='(Free Soft|GNU|GLIBC|Gentoo)' unix --version; then args=( '(- *)--version[display version information]' '(- *)--help[display help information]' diff --git a/Completion/Unix/Command/_less b/Completion/Unix/Command/_less index 7f01952d2..cb71314a6 100644 --- a/Completion/Unix/Command/_less +++ b/Completion/Unix/Command/_less @@ -41,7 +41,7 @@ _arguments -S -s -A "[-+]*" \ '(-d --dumb)'{-d,--dumb}'[suppress error message if terminal is dumb]' \ '(-e -E --quit-at-eof --QUIT-AT-EOF)'{-e,--quit-at-eof}'[exit the second time end-of-file is reached]' \ '(-e -E --quit-at-eof --QUIT-AT-EOF)'{-E,--QUIT-AT-EOF}'[exit when end-of-file is reached]' \ - '(-f --force)'{-f,--force}'[force opening of non-reqular files]' \ + '(-f --force)'{-f,--force}'[force opening of non-regular files]' \ '(-F --quit-if-one-screen)'{-F,--quit-if-one-screen}'[exit if entire file fits on first screen]' \ '(-G --HILITE-SEARCH -g --hilite-search)'{-g,--hilite-search}'[highlight only one match for searches]' \ '(-g --hilite-search -G --HILITE-SEARCH)'{-G,--HILITE-SEARCH}'[disable highlighting of search matches]' \ @@ -84,7 +84,12 @@ _arguments -S -s -A "[-+]*" \ '(-~ --tilde)'{-~,--tilde}"[don't display tildes after end of file]" \ '(-\# --shift)'{-\#+,--shift=}"[specify amount to move when scrolling horizontally]:number" \ '--follow-name[the F command changes file if the input file is renamed]' \ + '--mouse[enable mouse input]' \ + '--no-histdups[remove duplicates from command history]' \ + '--rscroll=[set the character used to mark truncated lines]:character [>]' \ + '--save-marks[retain marks across invocations of less]' \ '--use-backslash[subsequent options use backslash as escape char]' \ + '--wheel-lines=[specify lines to move for each click of the mouse wheel]:lines' \ "$files[@]" && ret=0 diff --git a/Completion/Unix/Command/_links b/Completion/Unix/Command/_links index 8bb9fee1c..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 @@ -108,10 +108,10 @@ _arguments -C \ '-html-target-in-new-window[allow opening new windows from html]' \ '-html-margin[specify margin]:margin (spaces)' \ '-html-user-font-size[specify font size in graphics mode]:size' \ - '-html-t-text-color[specify text color in text mode]:color (0..15)' \ - '-html-t-link-color[specify link color in text mode]:color (0..15)' \ - '-html-t-background-color[specify background color in text mode]:color (0..15)' \ - '-html-t-ignore-document-color[ignore colors from HTML in text mode]:ignore:(0 1)' \ + '-html-text-color[specify text color in text mode]:color (0..15)' \ + '-html-link-color[specify link color in text mode]:color (0..15)' \ + '-html-background-color[specify background color in text mode]:color (0..15)' \ + '-html-ignore-document-color[ignore colors from HTML in text mode]:ignore:(0 1)' \ '-html-g-text-color[specify text color in graphics mode]:color (0xRRGGBB)' \ '-html-g-link-color[specify link color in graphics mode]:color (0xRRGGBB)' \ '-html-g-background-color[specify background color in graphics mode]:color (0xRRGGBB)' \ diff --git a/Completion/Unix/Command/_ln b/Completion/Unix/Command/_ln index 3c1dcac76..9d5efcabb 100644 --- a/Completion/Unix/Command/_ln +++ b/Completion/Unix/Command/_ln @@ -1,77 +1,76 @@ #compdef ln gln zf_ln -local curcontext="$curcontext" state line ret=1 +local curcontext="$curcontext" state line ret=1 variant local -A opt_args -local -a args opts +local -a args opts=( -A '-*' ) args=( '(-i)-f[remove existing destination files]' '-s[create symbolic links instead of hard links]' ) -local variant -_pick_variant -r variant gnu=gnu unix --help -if [[ $variant == gnu ]]; then - opts=(-S) - args=( - '(-b --backup)-b[create a backup of each existing destination file]' \ - '(-b --backup)--backup=[create a backup of each existing destination file]::method:(( - none\:"never create backups" - off\:"never create backups" - numbered\:"create numbered backup" - t\:"create numbered backup" - existing\:"same as numbered if numbered backups exist, otherwise same as simple" - nil\:"same as numbered if numbered backups exist, otherwise same as simple" - simple\:"always create simple backups" - never\:"always create simple backups"))' - '(-d -F --directory)'{-d,-F,--directory}'[allow the superuser to attempt to hard link directories]' - '(-f --force)'{-f,--force}'[remove existing destination files]' - '(-i --interactive)'{-i,--interactive}'[prompt before removing destination files]' - '(-L --logical)'{-L,--logical}'[create hard links to symbolic link references]' - '(-n --no-dereference)'{-n,--no-dereference}'[treat destination symbolic link to a directory as if it were a normal file]' - '(-P --physical)'{-P,--physical}'[create hard links directly to symbolic links]' - '(-r --relative)'{-r,--relative}'[create symbolic links relative to link location]' - '(-s --symbolic)'{-s,--symbolic}'[create symbolic links instead of hard links]' - '(-S --suffix)'{-S,--suffix=}'[override default backup suffix]:suffix' - '(-t --target-directory)'{-t,--target-directory=}'[specify directory in which to create the links]: :_directories' - '(-T --no-target-directory)'{-T,--no-target-directory}'[treat destination as a normal file]' - '(-v --verbose)'{-v,--verbose}'[print name of each linked file]' - '--help[display usage information and exit]' - '--version[display version information and exit]') -elif (( ${+builtins[ln]} )); then - args+=( - '-d[attempt to hard link directories]' - {-h,-n}'[do not dereference destination]' - '(-f)-i[prompt before removing destination files]') -else - case $OSTYPE in - darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) - args+=( - {-h,-n}'[do not dereference destination]' - ) +_pick_variant -r variant -b zsh gnu=gnu $OSTYPE --help +case $variant; in + gnu) + opts=() + args=( + '(-b --backup)-b[create a backup of each existing destination file]' \ + '(-b --backup)--backup=[create a backup of each existing destination file]::method:(( + none\:"never create backups" + off\:"never create backups" + numbered\:"create numbered backup" + t\:"create numbered backup" + existing\:"same as numbered if numbered backups exist, otherwise same as simple" + nil\:"same as numbered if numbered backups exist, otherwise same as simple" + simple\:"always create simple backups" + never\:"always create simple backups"))' + '(-d -F --directory)'{-d,-F,--directory}'[allow the superuser to attempt to hard link directories]' + '(-f --force)'{-f,--force}'[remove existing destination files]' + '(-i --interactive)'{-i,--interactive}'[prompt before removing destination files]' + '(-L --logical)'{-L,--logical}'[create hard links to symbolic link references]' + '(-n --no-dereference)'{-n,--no-dereference}'[treat destination symbolic link to a directory as if it were a normal file]' + '(-P --physical)'{-P,--physical}'[create hard links directly to symbolic links]' + '(-r --relative)'{-r,--relative}'[create symbolic links relative to link location]' + '(-s --symbolic)'{-s,--symbolic}'[create symbolic links instead of hard links]' + '(-S --suffix)'{-S,--suffix=}'[override default backup suffix]:suffix' + '(-t --target-directory)'{-t,--target-directory=}'[specify directory in which to create the links]: :_directories' + '(-T --no-target-directory)'{-T,--no-target-directory}'[treat destination as a normal file]' + '(-v --verbose)'{-v,--verbose}'[print name of each linked file]' + '--help[display usage information and exit]' + '--version[display version information and exit]') + ;; + zsh) + args+=( + '-d[attempt to hard link directories]' + {-h,-n}'[do not dereference destination]' + '(-f)-i[prompt before removing destination files]') + ;; + darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + {-h,-n}'[do not dereference destination]' + ) ;| - darwin*|dragonfly*|freebsd*|netbsd*) - args+=( - '-F[remove existing destination directories]' - '(-f)-i[prompt before removing destination files]' - '-v[print name of each linked file]' - ) + darwin*|dragonfly*|freebsd*|netbsd*) + args+=( + '-F[remove existing destination directories]' + '(-f)-i[prompt before removing destination files]' + '-v[print name of each linked file]' + ) ;| - dragonfly*|freebsd*|netbsd*|openbsd*) - args+=( - '(-L)-P[create hard links directly to symbolic links]' - '(-P)-L[create hard links to symbolic link references]' - ) + dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + '(-L)-P[create hard links directly to symbolic links]' + '(-P)-L[create hard links to symbolic link references]' + ) ;| - dragonfly*|freebsd*) - args+=( - "-w[warn if source of a symbolic link doesn't currently exist]" - ) + dragonfly*|freebsd*|netbsd*) + args+=( + "-w[warn if source of a symbolic link doesn't currently exist]" + ) ;; - esac -fi +esac -_arguments -C -s $opts : \ +_arguments -C -s -S $opts : \ $args \ ':link target:_files' \ '*:: :->files' && ret=0 diff --git a/Completion/Unix/Command/_locale b/Completion/Unix/Command/_locale index 59e04a282..a7fd88f65 100644 --- a/Completion/Unix/Command/_locale +++ b/Completion/Unix/Command/_locale @@ -3,7 +3,7 @@ local curcontext="$curcontext" state state_descr line expl ret=1 typeset -A opt_args; local -a specs aopts -if _pick_variant gnu='(GNU|EGLIBC)' unix --version; then +if _pick_variant gnu='(Free Soft|GNU|GLIBC)' unix --version; then local exargs="-? --help --usage -V --version" diff --git a/Completion/Unix/Command/_localedef b/Completion/Unix/Command/_localedef index 4d4b4bbe3..57637e3ec 100644 --- a/Completion/Unix/Command/_localedef +++ b/Completion/Unix/Command/_localedef @@ -3,7 +3,7 @@ local curcontext="$curcontext" state line expl ret=1 typeset -A opt_args -if _pick_variant gnu='(GNU|EGLIBC)' unix --version; then +if _pick_variant gnu='(Free Soft|GNU|GLIBC)' unix --version; then local exargs="-? --help --usage -V --version" _arguments -A "-*" -C -S -s \ diff --git a/Completion/Unix/Command/_lp b/Completion/Unix/Command/_lp index 8c7ba7a8a..e84d9ad04 100644 --- a/Completion/Unix/Command/_lp +++ b/Completion/Unix/Command/_lp @@ -24,13 +24,14 @@ _lp_get_printer() _lp_job_options() { local expl printer - local -a lopts_with_args lopts_no_args + local -a lopts_with_args lopts_no_args desc_opts # Generic options (from lp manual page) - lopts_with_args=( media orientation-requested sides number-up scaling cpi lpi - page-{bottom,left,right,top} page-ranges ) + lopts_with_args=(collate job-{hold-until,priority,sheets} media + number-up{,-layout} orientation-requested outputorder page-border + page-ranges sides) - lopts_no_args=(fitplot fit-to-page landscape) + lopts_no_args=(fit-to-page mirror) if [[ $service == 'lpadmin' ]]; then # Extra options from lpadmin man page. @@ -51,7 +52,11 @@ _lp_job_options() compadd "$@" a4 letter legal ;; (orientation-requested) - compadd "$@" 4 + desc_opts=( + '4:rotated 90 degrees counter-clockwise' + '5:rotated 90 degrees clockwise' + '6:rotated 180 degrees') + _describe "orientation requested" desc_opts ;; (sides) compadd "$@" one-sided two-sided-{long,short}-edge @@ -60,8 +65,9 @@ _lp_job_options() _description -V option-o-1 expl "pages per sheet" compadd "$expl[@]" 2 4 6 9 16 ;; - (scaling|cpi|lpi|page-(bottom|left|right|top)) - return 0; # Don't complete anything + (number-up-layout) + _description -V option-o-1 expl "layout" + compadd "$expl[@]" btlr btrl lrbt lrtb rlbt rltb tblr tbrl ;; (cupsIPPSupplies|cupsSNMPSupplies|printer-is-shared) compadd "$@" true false @@ -69,6 +75,14 @@ _lp_job_options() (printer-error-policy) compadd "$@" abort-job retry-job retry-current-job stop-printer ;; + (Duplex|BRDuplex) + desc_opts=( + "DuplexTumble:flip short side" + "DuplexNoTumble:flip long side" + "None") + _describe "duplex options" desc_opts + ;; + (*) compadd "$@" \ $(_call_program list-printer-options lpoptions $printer -l | \ @@ -230,7 +244,7 @@ _lp() '-n[Copies]:copies (1--100):' \ '*-o:print job options:_lp_job_options' \ '-q[Job priority -- 1 (lowest) to 100 (highest)]:priority:' \ - '-s[Dont report resulting job IDs]' \ + "-s[Don't report resulting job IDs]" \ '-t[Sets the job name]:job name:' \ '-u[Job submission username]:username:_users' \ '-H[Time to print]:print time (or enter hh\:mm):(hold immediate restart resume)' \ diff --git a/Completion/Unix/Command/_ls b/Completion/Unix/Command/_ls index cedea1de9..1fd9383f5 100644 --- a/Completion/Unix/Command/_ls +++ b/Completion/Unix/Command/_ls @@ -81,10 +81,14 @@ if ! _pick_variant gnu=gnu unix --help; then if [[ $OSTYPE = (dragonfly*|freebsd*) ]]; then arguments+=( '(-A)-I[prevent -A from being automatically set for the super-user]' + '(-1 -C -m -x)-D+[specify format for date]:format: _date_formats' ) fi if [[ $OSTYPE = dragonfly* ]]; then - arguments+=( '-y[display FSMID in long listing]' ) + arguments+=( + '-_[use GMT based date and time output with nanotime timestamp]' + '-y[display FSMID in long listing]' + ) fi if [[ $OSTYPE = (freebsd*|darwin*) ]]; then arguments+=( '(-c -u)-U[file creation time]' ) @@ -92,9 +96,9 @@ if ! _pick_variant gnu=gnu unix --help; then if [[ $OSTYPE = freebsd* ]]; then arguments+=( '-,[print file sizes grouped and separated by thousands]' - '-D+[specify format for date]:format: _date_formats' '-y[with -t, sort filenames in the same order as the time]' '-Z[display MAC label]' + '--color=-[control use of color]:color:(never always auto)' ) fi if [[ $OSTYPE = darwin* ]]; then diff --git a/Completion/Unix/Command/_lsof b/Completion/Unix/Command/_lsof index 86115a4ef..754012e3b 100644 --- a/Completion/Unix/Command/_lsof +++ b/Completion/Unix/Command/_lsof @@ -1,9 +1,16 @@ #compdef lsof -local curcontext="$curcontext" state line expl fields args alts suf hsuf pref ret=1 +local curcontext="$curcontext" ret=1 +local -a state line expl args vals fields alts suf hsuf pref case $OSTYPE in - linux*) args=( '-X[skip reporting of info on network connections]' ) ;; + linux*) + args=( + '-E[display endpoint info for pipes, sockets and pseudoterminal files but not files of the endpoints]' + '+E[display endpoint info for pipes, sockets and pseudoterminal files including files of the endpoints]' + '-X[skip reporting of info on network connections]' + ) + ;; solaris*) args=( '-X[include deleted files]' @@ -24,8 +31,8 @@ _arguments -C -s -S $args \ '+D[recursively search from specified dir]:search directory:_files -/' \ '-D[direct use of device cache file]:function:((\?\:report\ device\ cache\ file\ paths b\:build\ the\ device\ cache\ file i\:ignore\ the\ device\ cache\ file r\:read\ the\ device\ cache\ file u\:read\ and\ update\ the\ device\ cache\ file))' \ '*-+e[exempt filesystem from blocking kernel calls]:file system:_directories' \ - '-f[inhibit listing of kernel file structure info]::info type or path:(c f g G n)' \ - '+f[enable listing of kernel file structure info]::info type:(c f g G n)' \ + '-f[inhibit listing of kernel file structure info]::info type:->file-structures' \ + '+f[enable listing of kernel file structure info]::info type:->file-structures' \ '-F[select output fields]:fields:->fields' \ '-g[select by process group id]::process group id' \ '(*)*-i[select internet files]::address:->addresses' \ @@ -93,6 +100,18 @@ case $state in _sequence -s , _wanted -x file-descriptors expl "file descriptor" compadd - \ cwd err jld ltz mem mmap pd rtd tr txt v86 && ret=0 ;; + file-structures) + vals=( + 'g[file flag abbreviations]' + 'G[file flags in hexadecimal]' + ) + [[ $OSTYPE != linux* ]] && vals+=( + 'c[file structure use count]' + 'f[file structure address]' + 'n[file structure node address]' + ) + _values 'kernel file structures' $vals && ret=0 + ;; states) if compset -P 1 '*:'; then _sequence _wanted states expl state compadd - -M 'm:{a-z}={A-Z}' \ diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks index 30bda1a9a..0915765dc 100644 --- a/Completion/Unix/Command/_luarocks +++ b/Completion/Unix/Command/_luarocks @@ -67,15 +67,8 @@ __luarocks_rock_version(){ fi ;; "installed") - # TODO: actually complete versions of installed rocks using the cache - # How does luarocks handles multiple versions of the same package? - # If anybody knows, please write something beautiful here tree="$2" - if [[ -z "${tree}" ]]; then - _message -e "version for installed rock ${words[$i]}" - else - _message -e "version for installed rock ${words[$i]} on tree ${tree}" - fi + __luarocks_installed_rocks "${tree}" "${words[$i]}" return ;; "new_version") @@ -142,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 @@ -180,16 +173,16 @@ ___luarocks_installed_rocks_cache_policy(){ local user_manifest_file="${configured_user_tree}/lib/luarocks/rocks-${configured_lua_version}/manifest" local system_manifest_file="${configured_system_tree}/lib/luarocks/rocks-${configured_lua_version}/manifest" - local cache_status=1 + local cache_status=0 if [[ -f ${cache_file} ]]; then if [[ -f ${user_manifest_file} ]]; then - if [[ ${user_manifest_file} -nt ${cache_file} ]]; then - cache_status=0 + if [[ ${cache_file} -nt ${user_manifest_file} ]]; then + cache_status=1 fi fi if [[ -f ${system_manifest_file} ]]; then - if [[ ${system_manifest_file} -nt ${cache_file} ]]; then - cache_status=0 + if [[ ${cache_file} -nt ${system_manifest_file} ]]; then + cache_status=1 fi fi fi @@ -197,12 +190,16 @@ ___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 # and ~/.luarocks + # + # The second argument (optional as well) is meant for telling the function to + # complete a version of a installed rock and not the rock itself from the list local tree="$1" + local complete_version_for_rock="$2" if [[ -z ${tree} ]]; then local update_policy zstyle -s ":completion:${curcontext}:" cache-policy update_policy @@ -240,7 +237,7 @@ __luarocks_installed_rocks(){ if _cache_invalid luarocks_installed_descriptions; then rocks_descriptions=() for i in {1.."${#rocks_names[@]}"}; do - name_version_description="$(luarocks show ${rocks_names[$i]} 2>/dev/null | head -2 | tail -1)" + name_version_description="$(luarocks show ${rocks_names[$i]} ${rocks_versions[$i]} 2>/dev/null | head -2 | tail -1)" total_length=${#name_version_description} garbage_length="$((${#rocks_names[$i]} + ${#rocks_versions[$i]} + 5))" description="${name_version_description[${garbage_length},${total_length}]}" @@ -253,7 +250,7 @@ __luarocks_installed_rocks(){ if _cache_invalid luarocks_installed_names_and_descriptions; then rocks_names_and_descriptions=() for i in {1.."${#rocks_names[@]}"}; do - name_and_description=${rocks_names[$i]}:${rocks_descriptions[$i]} + name_and_description=${rocks_names[$i]}:"${rocks_versions[$i]} "${rocks_descriptions[$i]} rocks_names_and_descriptions+=(${name_and_description}) done else @@ -275,7 +272,7 @@ __luarocks_installed_rocks(){ done rocks_descriptions=() for i in {1.."${#rocks_names[@]}"}; do - name_version_description="$(luarocks show ${rocks_names[$i]} 2> /dev/null | head -2 | tail -1)" + name_version_description="$(luarocks show ${rocks_names[$i]} ${rocks_versions[$i]} 2> /dev/null | head -2 | tail -1)" total_length=${#name_version_description} garbage_length="$((${#rocks_names[$i]} + ${#rocks_versions[$i]} + 5))" description="${name_version_description[${garbage_length},${total_length}]}" @@ -283,13 +280,32 @@ __luarocks_installed_rocks(){ done rocks_names_and_descriptions=() for i in {1.."${#rocks_names[@]}"}; do - name_and_description=${rocks_names[$i]}:${rocks_descriptions[$i]} + name_and_description=${rocks_names[$i]}:"${rocks_versions[$i]} "${rocks_descriptions[$i]} rocks_names_and_descriptions+=(${name_and_description}) done fi - _describe 'installed rocks' rocks_names_and_descriptions + if [[ -z "$complete_version_for_rock" ]]; then + _describe 'installed rock' rocks_names_and_descriptions + else + if [[ ! -z "${rocks_names[(r)${complete_version_for_rock}]}" ]]; then # checks if the requested rock exists in the list of rocks_names + local rock="${complete_version_for_rock}" + local first_match_index=${rocks_names[(i)${rock}]} + local last_match_index=${rocks_names[(I)${rock}]} + local versions=() + for i in {${first_match_index}..${last_match_index}}; do + versions+=("${rocks_versions[$i]}") + done + _values "rock's version" $versions + else + if [[ -z "${tree}" ]]; then + _message -r "no such rock installed" + else + _message -r "no such rock installed in tree ${tree}" + fi + fi + fi } -# Used to complete one or more of the followings: +# Used to complete one or more of the following: # - .rockspec file # - .src.rock file # - external rock @@ -386,7 +402,7 @@ local doc_command_options=( _luarocks_doc(){ _arguments \ "${doc_command_options[@]}" \ - '1: :{__luarocks_rock "installed" '"${opt_args[--tree]}"'}' + "1: :{__luarocks_rock installed ${opt_args[--tree]}}" } # arguments: # - must: external only rockspec @@ -508,8 +524,8 @@ local remove_command_options=( _luarocks_remove(){ _arguments -A "-*" \ "${remove_command_options[@]}" \ - '1: :{__luarocks_rock "installed" '"${opt_args[--tree]}"'}' \ - '2:: :{__luarocks_rock_version "installed" '"${opt_args[--tree]}"'}' + "1: :{__luarocks_rock installed ${opt_args[--tree]}}" \ + "2:: :{__luarocks_rock_version installed ${opt_args[--tree]}}" } # arguments: # - must: string as a search query @@ -542,7 +558,8 @@ local show_command_options=( _luarocks_show(){ _arguments \ "${show_command_options[@]}" \ - "1: :{__luarocks_rock 'installed' "${opt_args[--tree]}"}" + "1: :{__luarocks_rock installed "${opt_args[--tree]}"}" \ + "2:: :{__luarocks_rock_version installed ${opt_args[--tree]}}" } (( $+functions[_luarocks_test] )) || diff --git a/Completion/Unix/Command/_lz4 b/Completion/Unix/Command/_lz4 index d69091d00..2697c4d11 100644 --- a/Completion/Unix/Command/_lz4 +++ b/Completion/Unix/Command/_lz4 @@ -44,7 +44,7 @@ args=( + b # Benchmark-mode options "(C c d t)-b-[benchmark file using specified compression level]::compression level:(${(j< >)levels//-/})" "(C c d t)-e-[specify upper compression level limit (with -b)]:compression level:(${(j< >)levels//-/})" - '(C c d t)-i-[specifiy minimum evaluation time (with -b)]:evaluation time (seconds)' + '(C c d t)-i-[specify minimum evaluation time (with -b)]:evaluation time (seconds)' + c # Compress-mode options "(b d t ${(j< >)levels} -c0 -c1 -c2 -hc)"${^levels} '(B b d t -m -r --multiple)-l[compress using legacy (Linux kernel) format]' diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index e23906373..21ed56184 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -118,40 +118,14 @@ _make-parseMakefile () { done } -_make-findBasedir () { - local file index basedir - basedir=$PWD - for (( index=0; index < $#@; index++ )) - do - if [[ $@[index] == -C ]] - then - file=${~@[index+1]} 2>/dev/null - if [[ -z $file ]] - then - # make returns with an error if an empty arg is given - # even if the concatenated path is a valid directory - return - elif [[ $file == /* ]] - then - # Absolute path, replace base directory - basedir=$file - else - # Relative, concatenate path - basedir=$basedir/$file - fi - fi - done - print -- $basedir -} - _make() { - local prev="$words[CURRENT-1]" file expl tmp is_gnu incl match + local prev="$words[CURRENT-1]" file expl tmp is_gnu incl match basedir nul=$'\0' local context state state_descr line local -a option_specs local -A VARIABLES VAR_ARGS opt_args local -aU TARGETS keys - local ret=1 + local -i cdir=-1 ret=1 # VAR=VAL on the current command line for tmp in $words; do @@ -168,18 +142,18 @@ _make() { incl="(-|)include" option_specs=( '(-B --always-make)'{-B,--always-make}'[unconditionally make all targets]' - '*'{-C,--directory=}'[change directory first]:change to directory:->dir' + '*'{-C,--directory=}'[change directory first]:change to directory:->cdir' '-d[print lots of debug information]' '--debug=-[print various types of debug information]:debug options:->debug' '(-e --environment-overrides)'{-e,--environment-overrides}'[environment variables override makefiles]' - '--eval=-[evaluate STRING as a makefile statement]:STRING' - '(-f --file --makefile)'{-f,--file=,--makefile=}'[read FILE as a makefile]:makefile:->file' + \*{-E+,--eval=-}'[evaluate string as a makefile statement]:string' + '(-f --file --makefile)'{-f,--file=,--makefile=}'[read specified file as a makefile]:makefile:->file' '(- *)'{-h,--help}'[print help message and exit]' '(-i --ignore-errors)'{-i,--ignore-errors}'[ignore errors from recipes]' - '*'{-I,--include-dir=}'[search DIRECTORY for included makefiles]:search path for included makefile:->dir' - '(-j --jobs)'{-j+,--jobs=}'[allow N jobs at once; infinite jobs with no arg]:number of jobs' + '*'{-I,--include-dir=}'[search specified directory for included makefiles]:search path for included makefile:->dir' + '(-j --jobs)'{-j+,--jobs=}'[allow specified number of parallel jobs; unlimited jobs with no arg]:: : _guard "[0-9]#" "number of jobs"' '(-k --keep-going)'{-k,--keep-going}"[keep going when some targets can't be made]" - '(-l --load-average --max-load)'{-l,--load-average=,--max-load}"[don't start multiple jobs unless load is below N]:load" + '(-l --load-average --max-load)'{-l,--load-average=,--max-load}"[don't start multiple jobs unless load is below specified value]:load" '(-L --check-symlink-times)'{-L,--check-symlink-times}'[use the latest mtime between symlinks and target]' '(-n --just-print --dry-run --recon)'{-n,--just-print,--dry-run,--recon}"[don't actually run any recipe; just print them]" '*'{-o,--old-file=,--assume-old=}"[consider specified file to be old and don't remake it]:file not to remake:->file" @@ -189,12 +163,13 @@ _make() { '(-r --no-builtin-rules)'{-r,--no-builtin-rules}'[disable the built-in implicit rules]' '(-R --no-builtin-variables)'{-R,--no-builtin-variables}'[disable the built-in variable settings]' '(-s --silent --quiet)'{-s,--silent,--quiet}"[don't echo recipes]" + '--no-silent[echo recipes (disable --silent mode)]' '(-S --no-keep-going --stop)'{-S,--no-keep-going,--stop}'[turns off -k]' '(-t --touch)'{-t,--touch}'[touch targets instead of remaking them]' '(- *)'{-v,--version}'[print the version number of make and exit]' '(-w --print-directory)'{-w,--print-directory}'[print the current directory]' '--no-print-directory[turn off -w, even if it was turned on implicitly]' - '*'{-W,--what-if=,--new-file=,--assume-new=}'[consider FILE to be infinitely new]:file to treat as modified:->file' + '*'{-W,--what-if=,--new-file=,--assume-new=}'[consider specified file to be infinitely new]:file to treat as modified:->file' '--warn-undefined-variables[warn when an undefined variable is referenced]' '--warn-undefined-functions[warn when an undefined user function is called]' ) @@ -202,7 +177,7 @@ _make() { # Basic make options only. incl=.include option_specs=( - '-C[change directory first]:directory:->dir' + '-C[change directory first]:directory:->cdir' '-I[include directory for makefiles]:directory:->dir' '-f[specify makefile]:makefile:->file' '-o[specify file not to remake]:file not to remake:->file' @@ -213,15 +188,19 @@ _make() { _arguments -s $option_specs \ '*:make target:->target' && ret=0 + [[ $state = cdir ]] && cdir=-2 + basedir=${(j./.)${${~"${(@s.:.):-$PWD:${(Q)${opt_args[-C]:-$opt_args[--directory]}//\\:/$nul}}"}[(R)/*,cdir]}//$nul/:} + VAR_ARGS[CURDIR]="${basedir}" + case $state in - (dir) + (*dir) _description directories expl "$state_descr" - _files "$expl[@]" -W ${(q)$(_make-findBasedir ${words[1,CURRENT-1]})} -/ && ret=0 + _files "$expl[@]" -W $basedir -/ && ret=0 ;; (file) _description files expl "$state_descr" - _files "$expl[@]" -W ${(q)$(_make-findBasedir $words)} && ret=0 + _files "$expl[@]" -W $basedir && ret=0 ;; (debug) @@ -238,11 +217,9 @@ _make() { file=${(v)opt_args[(I)(-f|--file|--makefile)]} if [[ -n $file ]] then - [[ $file == [^/]* ]] && file=${(q)$(_make-findBasedir $words)}/$file + [[ $file == [^/]* ]] && file=$basedir/$file [[ -r $file ]] || file= else - local basedir - basedir=${$(_make-findBasedir $words)} if [[ $is_gnu == gnu && -r $basedir/GNUmakefile ]] then file=$basedir/GNUmakefile @@ -262,7 +239,7 @@ _make() { if [[ $is_gnu == gnu ]] then if zstyle -t ":completion:${curcontext}:targets" call-command; then - _make-parseMakefile < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" .PHONY 2> /dev/null) + _make-parseMakefile < <(_call_program targets "$words[1]" -nsp --no-print-directory -f "$file" --always-make 2> /dev/null) else _make-parseMakefile < $file fi @@ -286,7 +263,7 @@ _make() { _alternative \ 'targets:make target:compadd -Q -a TARGETS' \ 'variables:make variable:compadd -S = -F keys -k VARIABLES' \ - '*:file:_files' && ret=0 + '*:file:_files -W $basedir' && ret=0 fi esac diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 41ae85a1f..7d55201e3 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -381,7 +381,12 @@ _man() { (( $#sects )) || return 1 - _tags manuals.${^sects} + if [[ $PREFIX$SUFFIX == */* ]]; then + _tags manuals.${^sects} files + else + _tags manuals.${^sects} + fi + while _tags; do for sect_dirname in $sects; do d=$sect_dirname @@ -390,6 +395,8 @@ _man() { _requested manuals.$sect_dirname expl "manual page, section $d" _man_pages && ret=0 done + [[ $PREFIX$SUFFIX == */* ]] && + _requested files expl directory _files -/ && ret=0 (( ret )) || return 0 done ## To fall back to other sections' manpages when completing filenames, like diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir index e4308c304..4cd6bda32 100644 --- a/Completion/Unix/Command/_mkdir +++ b/Completion/Unix/Command/_mkdir @@ -1,29 +1,16 @@ #compdef mkdir gmkdir zf_mkdir -local curcontext="$curcontext" state line expl args variant ret=1 +local curcontext="$curcontext" variant ret=1 +local -a state line expl args aopts=( -A '-*' ) typeset -A opt_args args=( '(-m --mode)'{-m,--mode=}'[set permission mode]: :_file_modes' '(-p --parents)'{-p,--parents}'[make parent directories as needed]' - '(-)*: :->directories' + '*: :->directories' ) -# It can still happen that there is a precommand command or builtin in the line. -# In such cases, the variant has to be modified suitably, after further checking -# the variant of the _command_ mkdir. -# -# $precommands is defined in _main_complete -if (( ${+precommands[(r)command]} )); then - _mkdir_command () { command mkdir "$@" } - _pick_variant -c _mkdir_command -r variant gnu=gnu unix --help - unfunction _mkdir_command -elif (( ${+precommands[(r)builtin]} )) || (( ${+builtins[mkdir]} )) || [[ "$(type -w mkdir)" == "*: builtin" ]]; then - variant=zsh -else - _pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help -fi -# Now $variant is set. +_pick_variant -r variant -b zsh gnu=gnu $OSTYPE --help case $variant in gnu|freebsd*|dragonfly*|darwin*) @@ -32,9 +19,11 @@ case $variant in ) ;| gnu) + aopts=() if [[ $OSTYPE == linux* ]]; then args+=( - '(-Z --context)'{-Z,--context=}'[set SELinux context]:SELinux context' + '(--context)-Z[set SELinux context]' + '(-Z)--context=-[set SELinux context]::SELinux context:_selinux_contexts' ) fi args+=( @@ -47,12 +36,12 @@ case $variant in ;; esac -_arguments -C -s $args && ret=0 +_arguments -C -s -S $aopts $args && ret=0 case "$state" in directories) _wanted directories expl \ - 'parent directory (alternatively specify name of directory)' \ + 'parent directory or name of directory to create' \ _path_files -/ && ret=0 ;; esac diff --git a/Completion/Unix/Command/_mkfifo b/Completion/Unix/Command/_mkfifo index 4f1d8c87e..a055e4a1c 100644 --- a/Completion/Unix/Command/_mkfifo +++ b/Completion/Unix/Command/_mkfifo @@ -10,7 +10,7 @@ if _pick_variant gnu='Free Soft' unix --version; then ) [[ $OSTYPE == linux* ]] && args+=( '(--context)-Z[set SELinux security context to default]' - '(-Z)--context=-[like -Z, or specify SELinux security context]:SELinux security context' + '(-Z)--context=-[like -Z, or specify SELinux security context]::SELinux security context:_selinux_contexts' ) else aopts=( -A '-*' ) diff --git a/Completion/Unix/Command/_mknod b/Completion/Unix/Command/_mknod index 902f49b9f..8f07328db 100644 --- a/Completion/Unix/Command/_mknod +++ b/Completion/Unix/Command/_mknod @@ -22,7 +22,7 @@ if _pick_variant gnu='Free Soft' $OSTYPE --version; then ) [[ $OSTYPE == linux* ]] && args+=( '(--context)-Z[set SELinux security context to default]' - '(-Z)--context=-[like -Z, or specify SELinux security context]:SELinux security context' + '(-Z)--context=-[like -Z, or specify SELinux security context]::SELinux security context:_selinux_contexts' ) else aopts=( -A '-*' ) diff --git a/Completion/Unix/Command/_moosic b/Completion/Unix/Command/_moosic index f22fe16c5..54d768c8c 100644 --- a/Completion/Unix/Command/_moosic +++ b/Completion/Unix/Command/_moosic @@ -83,7 +83,7 @@ _moosic_add_cmds() { "noloop:turn loop mode off" "toggle-loop:toggle loop mode" "reconfigure:daemon reload configuration file" - "showconfig:show dameon filetype associations" + "showconfig:show daemon filetype associations" "start-server:starts new instance of daemon with given options" {quit,exit,die}":quit daemon" ) diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc index 0f292ab4c..7f7adc7b4 100644 --- a/Completion/Unix/Command/_mpc +++ b/Completion/Unix/Command/_mpc @@ -69,6 +69,7 @@ _mpc_command() { find:"search for a song, exact match" findadd:"find songs and add them to the current playlist" list:"list all tags of given type" + listneighbors:"list neighbors" seek:"seek to the position specified in percent" seekthrough:"seek by an amount of time within the song and playlist" shuffle:"shuffle the current playlist" diff --git a/Completion/Unix/Command/_mv b/Completion/Unix/Command/_mv index 3592efee6..84e43d47e 100644 --- a/Completion/Unix/Command/_mv +++ b/Completion/Unix/Command/_mv @@ -1,42 +1,55 @@ -#compdef mv gmv +#compdef mv gmv zf_mv -local args -if _pick_variant gnu=GNU unix --version; then - args=( - '(-b --backup -n --no-clobber)--backup=[make a backup of each existing destination file]: : _values "backup type" - {none,off}"[never make backups]" - {numbered,t}"[make numbered backups]" - {existing,nil}"[numbered backups, if they already exist]" - {simple,never}"[always make simple backups]"' - '(-b --backup -n --no-clobber)-b[make a backup of each existing destination file]' - '(-f --force -i --interactive -n --no-clobber)'{-f,--force}"[don't prompt before overwriting]" - '(-f --force -i --interactive -n --no-clobber)'{-i,--interactive}'[prompt before overwriting existing file]' - '--strip-trailing-slashes[remove any trailing slashes from each source argument]' - '(-S --suffix)'{-S+,--suffix=}'[specify the backup suffix]:backup suffix [~]' - '(-t --target-directory)'{-t+,--target-directory=}'[move all source arguments into specified directory]:directory:_directories' - '(-T --no-target-directory)'{-T,--no-target-directory}'[treat final argument as a normal file]' - '(-u --update)'{-u,--update}'[move only when destination file is older or missing]' - '(-v --verbose)'{-v,--verbose}'[show file names after they are moved]' - '(- *)--help[display usage information]' - '(- *)--version[display version information]' - ) - [[ $OSTYPE = linux* ]] && args+=( - '(-Z --context)'{-Z,--context}'[set SELinux security context of destination file to default type]' - ) -else - local pattern arg - args=( - "(-i -n)-f[don't prompt before overwriting]" - '(-f -n)-i[prompt before overwriting existing file]' - ) - for pattern arg in \ - '(darwin|dragonfly|freebsd)*' "(-f -i)-n[don't overwrite existing file]" \ - '(darwin|dragonfly|*bsd)*' '-v[show file names after they are moved]' \ - '(dragonfly|freebsd)*' "-h[if target is a symlink to a directory, don't follow it]" - do - [[ $OSTYPE = $~pattern ]] && args+=( $arg ) - done -fi +local args variant aopts=( -A '-*' ) -_arguments -s -S $args \ - '*:file:_files' +_pick_variant -r variant -b zsh gnu=GNU $OSTYPE --version +case $variant; in + gnu) + aopts=() + args=( + '(-b --backup -n --no-clobber)--backup=[make a backup of each existing destination file]: : _values "backup type" + {none,off}"[never make backups]" + {numbered,t}"[make numbered backups]" + {existing,nil}"[numbered backups, if they already exist]" + {simple,never}"[always make simple backups]"' + '(-b --backup -n --no-clobber)-b[make a backup of each existing destination file]' + '(-f --force -i --interactive -n --no-clobber)'{-f,--force}"[don't prompt before overwriting]" + '(-f --force -i --interactive -n --no-clobber)'{-i,--interactive}'[prompt before overwriting existing file]' + '--strip-trailing-slashes[remove any trailing slashes from each source argument]' + '(-S --suffix)'{-S+,--suffix=}'[specify the backup suffix]:backup suffix [~]' + '(-t --target-directory)'{-t+,--target-directory=}'[move all source arguments into specified directory]:directory:_directories' + '(-T --no-target-directory)'{-T,--no-target-directory}'[treat final argument as a normal file]' + '(-u --update)'{-u,--update}'[move only when destination file is older or missing]' + '(-v --verbose)'{-v,--verbose}'[show file names after they are moved]' + '(- *)--help[display usage information]' + '(- *)--version[display version information]' + ) + [[ $OSTYPE = linux* ]] && args+=( + '(-Z --context)'{-Z,--context}'[set SELinux security context of destination file to default type]' + ) + ;; + *) + args=( + "(-i -n)-f[don't prompt before overwriting]" + '(-f -n)-i[prompt before overwriting existing file]' + ) + ;| + darwin*|dragonfly*|freebsd*) + args+=( + "(-f -i)-n[don't overwrite existing file]" + ) + ;| + darwin*|dragonfly*|*bsd*) + args+=( + '-v[show file names after they are moved]' + ) + ;| + dragonfly*|freebsd*) + args+=( + "-h[if target is a symlink to a directory, don't follow it]" + ) + ;; +esac + +_arguments -s -S $aopts $args \ + '*: :_files' diff --git a/Completion/Unix/Command/_myrepos b/Completion/Unix/Command/_myrepos new file mode 100644 index 000000000..d26c1245b --- /dev/null +++ b/Completion/Unix/Command/_myrepos @@ -0,0 +1,126 @@ +#compdef mr + +# +# A zsh completion script for myrepos (http://myrepos.branchable.com/) +# + +# This script does not handle user defined alias nor user defined actions (lib, +# plugins) + + +local curcontext="$curcontext" state state_descr line ret=1 +local -a arguments +typeset -A opt_args +typeset -g mr_subcommands mr_alias + +arguments=( + '(-d --directory)'{-d,--directory}'[specify the topmost directory that mr should work in]:directory:_files -/' + '(-c --config)'{-c,--config}'[use the specified mrconfig file]:mrconfig:_files' + '(-f --force)'{-f,--force}'[force mr to act on repositories that would normally be skipped]' + '--force-env[force mr to execute even though potentially dangerous env variables]' + '(-v --verbose)'{-v,--verbose}'[be verbose]' + '(-m --minimal)'{-m,--minimal}'[minimise output]' + '(-q --quiet)'{-q,--quiet}"[suppress mr's usual output]" + '(-k --insecure)'{-k,--insecure}'[accept untrusted SSL certificates when bootstrapping]' + '(-s --stats)'{-s,--stats}'[expand the statistics line displayed at the end]' + '(-i --interactive)'{-i,--interactive}'[start a subshell if a repository fails to be processed]' + '(-n --no-recurse)'{-n,--no-recurse}'[specify the recursivity depth into repositories]::number' + '(-j --jobs)'{-j,--jobs}'[number of jobs run in parallel]::number' + '--cache[save the command result to ~/.mrcache/]' + '--cached[process cached commands]' + '--uncache[remove the cached output]' + '--top[cd to the top of the repo before running any commands]' + '(-t --trust-all)'{-t,--trust-all}'[trust all mrconfig files]' + \!{-p,--path} # this obsolete flag is ignored + ':mr commands:->subcommand' + '*::: := ->option-or-argument' +) + +_arguments -C $arguments && ret=0 + +case $state in + (subcommand) + + mr_subcommands=( + "checkout:check out any repositories that are not already checked out" + "update:update each repository" + "status:display a status report for each repository" + "clean:print/remove ignored or untracked files and other cruft" + "commit:commit changes to each repository" + "record:record changes to the local repository" + "fetch:fetch from each repository's remote repository" + "push:push committed local changes to remote repository" + "diff:show a diff of uncommitted changes" + "log:show the commit log" + "grep:search for a pattern in each repository" + "run:run the specified command in each repository" + "bootstrap:use a 'source' as .mrconfig file" + "list:list the repositories that mr will act on" + "register:register an existing repository in a mrconfig file" + "config:get and set value from a mrconfig file" + "offline:advise mr that it is in offline mode" + "online:advise mr that it is in online mode" + "remember:remember a command to be run later" + "help:display this help." + ) + + mr_alias=( + "co:check out any repositories that are not already checked out" + "ci:commit changes to each repository" + "ls:list the repositories that mr will act on" + ) + + _describe -t commands 'command' mr_subcommands -- mr_alias && ret=0 + + ;; + (option-or-argument) + curcontext=${curcontext%:*}-$line[1]: + case $line[1] in + (clean) + _arguments \ + '-f[allow removing the files]' \ + '*: :' && ret=0 + ;; + (commit|ci|record) + _arguments \ + '-m[allow specifying a commit message]' \ + '*: :' && ret=0 + ;; + (grep) + _message 'search pattern' + ;; + (run) + _message 'command to run' + ;; + (bootstrap) + if [[ $CURRENT -eq 2 ]]; then + _alternative \ + 'urls:URL:_urls' \ + 'local:local file or stdin:_files' + elif [[ $CURRENT -eq 3 ]]; then + _directories + fi + ;; + (register) + _directories + ;; + (config) + case $CURRENT in + (2) _message -e section 'section name';& + (3) _message -e setting '"setting" or "setting=value"';& + esac + ;; + (remember) + _describe -t commands 'command' mr_subcommands -- mr_alias && ret=0 + ;; + (checkout|co|update|status|fetch|push|diff|log|list|ls|offline|online|help) + _message 'no arguments' + ;; + (*) + _default && ret=0 + ;; + esac + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_netstat b/Completion/Unix/Command/_netstat index c03aae9a2..94aa1688d 100644 --- a/Completion/Unix/Command/_netstat +++ b/Completion/Unix/Command/_netstat @@ -174,8 +174,15 @@ case $OSTYPE in ;| solaris2.<11->) + sets+=( dcache '-[^-]#d*' ) + sel_dcache=( '-d[display the destination cache entry table]' ) + dcache=( $families ) args=( '-T+[specify time format]:time format:((u\:seconds\ since\ epoch d\:standard\ date\ format))' ) - sockets=( '-u[list user, pid and program that created network endpoint]' ) + sockets+=( + '-u[list user, pid and program that created network endpoint]' + '-k[show only sockets with kernel data path bypass enabled]' + '-L[only show state of sockets using SO_REUSEPORT load balancing]' + ) ;& solaris*) args=( -A '-*' $args ) @@ -269,6 +276,7 @@ case $OSTYPE in ) interfaces+=( '-c+[show specified number of updates, then exit]:count' + '-e[show only the number of errors on the interface]' '-q[only show interfaces that have seen packets]' '-t[show current value of the watchdog timer function]' ) diff --git a/Completion/Unix/Command/_nkf b/Completion/Unix/Command/_nkf index 04977e467..0c4f06fb5 100644 --- a/Completion/Unix/Command/_nkf +++ b/Completion/Unix/Command/_nkf @@ -33,7 +33,7 @@ _arguments -s \ '($inputs)-W16l[Input assumption is UTF-16 (Little Endian; BOM)]' \ '(-M)-m-[MIME decode]:mime decode:((B\:base64 Q\:quoted S\:strict N\:non-strict 0\:no-decode))' \ '(-m)-M-[MIME encode]:mime encode:((\:header B\:base64 Q\:quoted))' \ - '-h-[hirakana<->katakana]:hirakata:((1\:hirakana-\>katakana 2\:katakana-\>hirakana 3\:both))' \ + '-h-[hiragana<->katakana]:hirakata:((1\:hiragana-\>katakana 2\:katakana-\>hiragana 3\:both))' \ '-L-[line mode]:line mode:((u\:LF w\:CRLF m\:CR))' \ '-I[convert non ISO-2022-JP character to GETA]' \ '(--cap-input --url-input)'{--cap-input,--url-input}'[Convert hex after \: or \%]' \ diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm index 146a69e8a..423fd3223 100644 --- a/Completion/Unix/Command/_nm +++ b/Completion/Unix/Command/_nm @@ -59,8 +59,10 @@ if _pick_variant -r variant binutils=GNU elftoolchain=elftoolchain elfutils=elfu binutils) compset -P '@' && files='*:options file:_files' args+=( + '!(--no-recurse-limit)--recurse-limit' + '--no-recurse-limit[disable demangling recursion limit]' '(-f --format -P)-f+[specify output format]:format:(bsd sysv posix)' - '(-C --no-demangle)--demangle=-[decode symbol names]::style:(auto gnu lucid arm hp edg gnu-v3 java gnat)' + '(-C --no-demangle)--demangle=-[decode symbol names]::style:(auto gnu lucid arm hp edg gnu-v3 java gnat rust dlang)' '--plugin[load specified plugin]:plugin' '--special-syms[include special symbols in the output]' '--synthetic[display synthetic symbols as well]' diff --git a/Completion/Unix/Command/_notmuch b/Completion/Unix/Command/_notmuch deleted file mode 100644 index 6174d2c00..000000000 --- a/Completion/Unix/Command/_notmuch +++ /dev/null @@ -1,81 +0,0 @@ -#compdef notmuch - -_notmuch_commands() -{ - local -a notmuch_commands - notmuch_commands=( - 'setup:interactively set up notmuch for first use' - 'new:find and import any new message to the database' - 'insert:add a new message into the maildir and notmuch database' - 'search:search for messages matching the search terms, display matching threads as results' - 'address:get addresses from messages matching the given search terms' - 'reply:constructs a reply template for a set of messages' - 'show:show all messages matching the search terms' - 'tag:add or remove tags for all messages matching the search terms' - 'dump:creates a plain-text dump of the tags of each message' - 'restore:restores the tags from the given file' - 'compact:compact the notmuch database' - 'reindex:re-index all messages matching the search terms' - 'help:show details on a command' - 'compact:compact the notmuch database' - 'config:access the notmuch configuration file' - 'count:count messages matching the given search terms' - ) - - _describe -t command 'command' notmuch_commands -} - -_notmuch_dump() -{ - _files -} - -_notmuch_help_topics() -{ - local -a notmuch_help_topics - notmuch_help_topics=( - 'search-terms:common search-term syntax' - 'hooks:hooks that will be run before or after certain commands' - 'properties:message property conventions and documentation' - ) - _describe -t notmuch-help-topics 'topic' notmuch_help_topics -} - -_notmuch_help() -{ - _alternative \ - _notmuch_commands \ - _notmuch_help_topics -} - -_notmuch_restore() -{ - _files -} - -_notmuch_search() -{ - _arguments -s : \ - '--max-threads=[display only the first x threads from the search results]:number of threads to show: ' \ - '--first=[omit the first x threads from the search results]:number of threads to omit: ' \ - '--sort=[sort results]:sorting:((newest-first\:"reverse chronological order" oldest-first\:"chronological order"))' -} - -_notmuch() -{ - local ret=1 - if (( CURRENT > 2 )) ; then - local cmd=${words[2]} - curcontext="${curcontext%:*:*}:notmuch-$cmd" - (( CURRENT-- )) - shift words - if ! _call_function ret _notmuch_$cmd; then - _default && ret=0 - fi - return ret - else - _notmuch_commands - fi -} - -_notmuch "$@" diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump index ee2f3ea6f..989cd3f0b 100644 --- a/Completion/Unix/Command/_objdump +++ b/Completion/Unix/Command/_objdump @@ -1,123 +1,133 @@ #compdef objdump eu-objdump llvm-objdump -local opts args files variant curcontext=$context state state_descr line ret=1 +local curcontext="$curcontext" files variant ign ret=1 +local -a opts args state state_descr line typeset -A opt_args files='*:object file:_object_files' - +(( $#words > 2 )) && ign='!' _pick_variant -r variant binutils=GNU elfutils=elfutils llvm=LLVM unix --version -opts=( -s -S ) # options for _arguments +opts=( -s -S ) # options to _arguments itself args=( - "(-d --disassemble)"{-d,--disassemble}"[Display assembler code of executable sections]" - "(-r --reloc)"{-r,--reloc}"[Display relocation information]" - "(-s --full-contents)"{-s,--full-contents}"[Display the full contents of all sections requested]" - "*"{-j+,--section=}"[Only display information for section]:section:(.bss .data .dynamic .dynsym .got .interp .shstrtab .symtab .text)" + '(-d --disassemble)'{-d,--disassemble}'[display assembler code of executable sections]' + '(-r --reloc)'{-r,--reloc}'[display relocation information]' + '(-s --full-contents)'{-s,--full-contents}'[display the full contents of all sections requested]' + \*{-j+,--section=}'[only display information for section]:section:(.bss .data .dynamic .dynsym .got .interp .shstrtab .symtab .text)' ) case $variant in binutils) + compset -P '@' && files='*:options file:_files' args+=( - "(-a --archive-headers)"{-a,--archive-headers}"[Display archive header information]" - "(-f --file-headers)"{-f,--file-headers}"[Display the contents of the overall file header]" - "(-p --private-headers)"{-p,--private-headers}"[Display object format specific file header contents]" - "*"{-P,--private=}"[Display object format specific contents]:option" - "(-h --section-headers --headers)"{-h,--section-headers,--headers}"[Display the contents of the section headers]" - "(-x --all-headers)"{-x,--all-headers}"[Display the contents of all headers]" - "(-D --disassemble-all)"{-D,--disassemble-all}"[Display assembler contents of all sections]" - "(-S --source)"{-S,--source}"[Intermix source code with disassembly]" - "(-g --debugging)"{-g,--debugging}"[Display debug information in object file]" - "(-e --debugging-tags)"{-e,--debugging-tags}"[Display debug information using ctags style]" - "(-G --stabs)"{-G,--stabs}"[Display (in raw form) any STABS info in the file]" + '!(--no-recurse-limit)--recurse-limit' + '--no-recurse-limit[disable demangling recursion limit]' + '(-a --archive-headers)'{-a,--archive-headers}'[display archive header information]' + '(-f --file-headers)'{-f,--file-headers}'[display contents of the overall file header]' + '(-p --private-headers)'{-p,--private-headers}'[display object format specific file header contents]' + \*{-P+,--private=}'[display information specific to the object format]:option' + '(-h --section-headers --headers)'{-h,--section-headers,--headers}'[display contents of the section headers]' + '(-x --all-headers)'{-x,--all-headers}'[display the contents of all headers]' + '--disassemble=[display assembler contents for specified symbol]:symbol' + '(-D --disassemble-all)'{-D,--disassemble-all}'[display assembler contents of all sections]' + '(-S --source)'{-S,--source}'[intermix source code with disassembly]' + '--source-comment=-[prefix lines of source code with specified text]::text prefix [# ]' + '(-g --debugging)'{-g,--debugging}'[display debug information in object file]' + '(-e --debugging-tags)'{-e,--debugging-tags}'[display debug information using ctags style]' + '(-G --stabs)'{-G,--stabs}'[display (in raw form) any STABS info in the file]' + + '*-W-[display DWARF info in the file]::dwarf section:->short-dwarf-names' + '*--dwarf=-[display DWARF info in the file]::dwarf section:->dwarf-names' - "*-W-[Display DWARF info in the file]::dwarf section:->short_dwarf_names" - "*--dwarf=-[Display DWARF info in the file]::dwarf section:->dwarf_names" + '--ctf=[display compact C type format info for section]:section' + '(-t --syms)'{-t,--syms}'[display the contents of the symbol table(s)]' + '(-T --dynamic-syms)'{-T,--dynamic-syms}'[display the contents of the dynamic symbol table]' + '(-R --dynamic-reloc)'{-R,--dynamic-reloc}'[display the dynamic relocation entries in the file]' - "(-t --syms)"{-t,--syms}"[Display the contents of the symbol table(s)]" - "(-T --dynamic-syms)"{-T,--dynamic-syms}"[Display the contents of the dynamic symbol table]" - "(-R --dynamic-reloc)"{-R,--dynamic-reloc}"[Display the dynamic relocation entries in the file]" - #@<file> Read options from <file> + "${ign}(- *)"{-v,--version}"[display version information]" + "${ign}(- *)"{-i,--info}"[list supported object formats and architectures]" + "${ign}(- *)"{-H,--help}"[display usage information]" - "(- *)"{-v,--version}"[Display this program's version number]" - "(- *)"{-i,--info}"[List object formats and architectures supported]" - "(- *)"{-H,--help}"[Display this information]" - - "(-b --target)"{-b+,--target=}"[Specify the target object format]:bfdname:->bfdname" - "(-m --architecture)"{-m+,--architecture=}"[Specify the target architecture]:machine:->machine" - "*"{-M+,--disassembler-options=}"[Pass text OPT on to the disassembler]:opt:->disassembler_options" + '(-b --target)'{-b+,--target=}'[specify the target object format]:target:->bfdnames' + '(-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 -/" - "(-l --line-numbers)"{-l,--line-numbers}"[Include line numbers and filenames in output]" - "(-F --file-offsets)"{-F,--file-offsets}"[Include file offsets when displaying information]" - "(-C --demangle)-C[Decode mangled/processed symbol names]" - "(-C --demangle)--demangle=-[Decode mangled/processed symbol names]::style:(auto gnu lucid arm hp edg gnu-v3 java gnat)" - "(-w --wide)"{-w,--wide}"[Format output for more than 80 columns]" - "(-z --disassemble-zeroes)"{-z,--disassemble-zeroes}"[Do not skip blocks of zeroes 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 -/' + '(-l --line-numbers)'{-l,--line-numbers}'[include line numbers and filenames in output]' + '(-F --file-offsets)'{-F,--file-offsets}'[include file offsets when displaying information]' + '(-C --demangle)-C[decode mangled/processed symbol names]' + '(-C --demangle)--demangle=-[decode mangled/processed symbol names]::style:(auto gnu lucid arm hp edg gnu-v3 java gnat rust dlang)' + '!(--no-recurse-limit)--recurse-limit' + '--no-recurse-limit[disable demangling recursion limit]' + '(-w --wide)'{-w,--wide}'[format output for more than 80 columns]' + '(-z --disassemble-zeroes)'{-z,--disassemble-zeroes}"[don't skip blocks of zeroes when disassembling]" - "--start-address=[Only process data whose address is >= ADDR]:addr" - "--stop-address=[Only process data whose address is <= ADDR]:addr" - "--prefix-addresses[Print complete address alongside disassembly]" - "(--show-raw-insn --no-show-raw-insn)"--{,no-}show-raw-insn"[Display hex alongside symbolic disassembly]" - "--insn-width=[Display WIDTH bytes on a single line for -d]:width" - "--adjust-vma=[Add offset to all displayed section addresses]:offset" - "--special-syms[Include special symbols in symbol dumps]" - "--prefix=[Add prefix to absolute paths for -S]:prefix" - "--prefix-strip=[Strip initial directory names for -S]:level" - "--dwarf-depth=[Do not display DIEs at depth N or greater]:n" - "--dwarf-start=[Display DIEs starting with N, at the same depth or deeper]:n" - "--dwarf-check[Make additional dwarf internal consistency checks]" + '--start-address=[only process data whose address is >= ADDR]:address' + '--stop-address=[only process data whose address is <= ADDR]:address' + '--prefix-addresses[print complete address alongside disassembly]' + '(--show-raw-insn --no-show-raw-insn)'--{,no-}show-raw-insn'[display hex alongside symbolic disassembly]' + '--insn-width=[display specified number of bytes on a single line with -d]:width (bytes)' + '--adjust-vma=[add offset to all displayed section addresses]:offset' + '--special-syms[include special symbols in symbol dumps]' + '--inlines[print all inlines for source line (with -l)]' + '--prefix=[add prefix to absolute paths for -S]:prefix' + '--prefix-strip=[strip initial directory names for -S]:level' + "--dwarf-depth=[don't display DIEs at specified or greater depth]:depth" + '--dwarf-start=[display DIEs at specified or deeper depth]:depth' + '--dwarf-check[perform additional dwarf internal consistency checks]' + '--ctf-parent=[use specified section as the CTF parent]:section' ) ;; elfutils) args+=( - "--color=-[Colorize the output]::when:(always auto never)" - "(- *)"{-\?,--help}"[Display help]" - "(- *)--usage[Display usage]" - "(- *)"{-V,--version}"[Display program version]" + "--color=-[colorize the output]::when:(always auto never)" + "(- *)"{-\?,--help}"[display help]" + "(- *)--usage[display usage]" + "(- *)"{-V,--version}"[display program version]" ) ;; llvm) opts=( -S ) # no option stacking args=( # start over from an empty array - '-aarch64-neon-syntax=[chose style of NEON code (AArch64)]:style:(generic apple)' - '-arch=[w -macho: select arch from a fat binary]:arch:(i386 x86_64)' - '-arch-name=[specify target arch to disassemble for]:arch:->llvm_targets' - '-archive-headers[w -macho: print archive headers]' + '-aarch64-neon-syntax=[choose style of NEON code (AArch64)]:style:(generic apple)' + '-arch=[select arch from a fat binary (with -macho)]:architecture:(i386 x86_64)' + '-arch-name=[specify target arch to disassemble for]:architecture:->llvm_targets' + '-archive-headers[print archive headers (with -macho)]' '-archive-member-offsets[w -macho -archive-headers: print offset to each archive member]' '-bind[display Mach-O binding info]' - '-color[use colored syntax highlighting]' - '-data-in-code[w -macho: print data in code table]' - "-dis-symname=[w -macho: disassemble just the specfied symbol's instructions]" + '-color[use color syntax highlighting]' + '-data-in-code[print data in code table (with -macho)]' + "-dis-symname=[disassemble just the specified symbol's instructions (with -macho)]" '(-disassemble -d)'{-disassemble,-d}'[display assembler mnemonics for machine instructions]' '(-disassemble-all -D)'{-disassemble-all,-D}'[disassemble all instruction sections]' - '-dsym=[w -macho -g: use the specified .dSYM file for debug info]:dsym file:_files' + '-dsym=[use the specified .dSYM file for debug info (with -macho)]:dsym file:_files' '-dwarf=[dump of dwarf debug section]:section:(frames)' - "-dyld-id[w -macho: print the shared library's id for dylib Mach-O file]" - '-dylibs-used[w -macho: print the shared libraries used for linked Mach-O files]' + "-dyld-id[print the shared library's id for dylib Mach-O file (with -macho)]" + '-dylibs-used[print the shared libraries used for linked Mach-O files (with -macho)]' '-exports-trie[display Mach-O exported symbols]' '-fault-map-section[display contents of faultmap section]' '-filter-print-funcs=[only print IR for the specified functions]:function names' - '-full-leading-addr[w -macho: print full leading address]' - '-g[w -macho: print line information from debug info if available]' - '-indirect-symbols[w -macho: print indirect symbol table]' - '-info-plist[w -macho: print the info plist section]' + '-full-leading-addr[print full leading address (with -macho)]' + '-g[print line information from debug info if available (with -macho)]' + '-indirect-symbols[print indirect symbol table (with -macho)]' + '-info-plist[print the info plist section (with -macho)]' '-lazy-bind[display Mach-O lazy binding info]' '(-line-numbers -l)'{-line-numbers,-l}'[display source line numbers with disassembly]' - '-link-opt-hints[w -macho: print the linker optimization hints]' + '-link-opt-hints[print the linker optimization hints (with -macho)]' '(-macho -m)'{-macho,-m}'[use Mach-O specific object file parser]' '*-mattr=[target specific attributes]:attributes' '-mcpu=[specify target cpu type]:cpu type' - '-no-leading-addr[w -macho: print no leading address]' + '-no-leading-addr[print no leading address (with -macho)]' '-no-leading-headers[print no leading headers]' - '-no-show-raw-insn[do not print instruction bytes when disassembling]' - '-no-symbolic-operands[w -macho: do not print operands symbolically when disassembling]' - '-non-verbose[w -macho: print info in non-verbose form]' - '-objc-meta-data[w -macho: print Objective-C runtime meta data]' + "-no-show-raw-insn[don't print instruction bytes when disassembling]" + "-no-symbolic-operands[don't print operands symbolically when disassembling (with -macho)]" + '-non-verbose[print info in non-verbose form (with -macho)]' + '-objc-meta-data[print Objective-C runtime meta data (with -macho)]' '-print-after-all[print IR after each pass]' '-print-before-all[print IR before each pass]' '-print-imm-hex[use hex format for immediate values]' @@ -128,22 +138,22 @@ case $variant in '-rebase[display Mach-O rebasing info]' '-rng-seed=[seed for the random number generator]:seed' '-s[display contents of each section]' - '*'{-section=,-j}'[operate on the specified section only]:section' + \*{-section=,-j}'[operate on the specified section only]:section' '(-section-headers -h)'{-section-headers,-h}'[display summaries of the headers for each section]' '(-source -S)'{-source,-S}'[display source inlined with disassembly]' '-start-address=[start disassembly at the specified address]:address' '-stop-address=[stop disassembly at the specified address]:address' - '-t[display the symbol talbe]' + '-t[display the symbol table]' '-time-passes[time each pass, print elapsed time on exit]' '-triple=[target triple to disassemble for]:triple' - '-universal-headers[w -macho: print Mach-O universal headers]' + '-universal-headers[print Mach-O universal headers (with -macho)]' '-verify-dom-info[verify dominator info (time consuming)]' '-unwind-info[display unwind information]' '-weak-bind[display Mach-O weak binding info]' - '-x86-asm-syntax=[chose style of assembler code (x86)]:style:(att intel)' - '(- *)-help[display available options]' - '(- *)-help-list[display list of available options]' - '(- *)-version[display version of objdump]' + '-x86-asm-syntax=[choose style of assembler code (x86)]:style:(att intel)' + "${ign}(- *)-help[display available options]" + "${ign}(- *)-help-list[display list of available options]" + "${ign}(- *)-version[display version of objdump]" ) ;; esac @@ -151,24 +161,34 @@ esac _arguments $opts -C : "$args[@]" $files && ret=0 case "$state" in - short_dwarf_names) - _values -s "" "dwarf section" "l[rawline]" "L[decodedline]" "i[info]" "a[abbrev]" "p[pubnames]" "r[aranges]" "m[macro]" "f[frames]" "F[frames-interp]" "s[str]" "o[loc]" "R[Ranges]" "t[pubtypes]" "U[trace_info]" "u[trace_abbrev]" "g[gdb_index]" "T[trace_aranges]" "A[addr]" "c[cu_index]" "k[links]" "K[follow-links]" && ret=0 + short-dwarf-names) + _values -s "" "dwarf section" \ + "l[rawline]" "L[decodedline]" "i[info]" "a[abbrev]" "p[pubnames]" \ + "r[aranges]" "m[macro]" "f[frames]" "F[frames-interp]" "s[str]" \ + "o[loc]" "R[ranges]" "t[pubtypes]" "U[trace_info]" "u[trace_abbrev]" \ + "T[trace_aranges]" "g[gdb_index]" "A[addr]" "c[cu_index]" "k[links]" \ + "K[follow-links]" && ret=0 ;; - dwarf_names) - _values -s , "dwarf section" rawline decodedline info abbrev pubnames aranges macro frames frames-interp str loc Ranges pubtypes gdb_index trace_info trace_abbrev trace_aranges addr cu_index links follow-links && ret=0 + dwarf-names) + _sequence _wanted dwarf-sections expl "dwarf section" compadd - \ + rawline decodedline info abbrev pubnames aranges macro frames \ + frames-interp str loc Ranges pubtypes gdb_index trace_info \ + trace_abbrev trace_aranges addr cu_index links follow-links && ret=0 ;; - bfdname) - _values "object format" "${(z)${(@M)${(f)$(_call_program targets objdump --help)}##* supported targets:*}##*: }" && ret=0 + bfdnames) + _wanted targets expl target compadd - \ + ${=${(M)${(f)"$(_call_program targets objdump --help)"}##* supported targets:*}##*: } && ret=0 ;; - machine) - _values "machine architecture" "${(@)${(z)${(@M)${(f)$(_call_program targets objdump --help)}##* supported architectures:*}##*: }//:/\\:}" && ret=0 + architectures) + _wanted architectures expl architecture compadd - \ + ${=${(M)${(f)"$(_call_program targets objdump --help)"}##* supported architectures:*}##*: } && ret=0 ;; disassembler_options) _values -s , "disassembler options" "${(@)${(@)${(@M)${(f)${(ps.-M switch.)$(_call_program targets objdump --help)}[2]}:# [^ ]*}# }%% *}" && ret=0 ;; llvm_targets) _values "target architecture" "${(z)${(@)${(f)$(_call_program targets - ${~words[1]} -version)##*Registered Targets:}/ -*}}" + ${~words[1]} -version)##*Registered Targets:}/ -*}}" ;; esac 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 new file mode 100644 index 000000000..29d3724e0 --- /dev/null +++ b/Completion/Unix/Command/_pandoc @@ -0,0 +1,423 @@ +#compdef pandoc + +# {{{ helper: cache policy for available formats and other variables +(( $+functions[__pandoc_cache_policy] )) || +__pandoc_cache_policy(){ + local cache_file="$1" + if [[ -f "${commands[pandoc]}" && -f "${cache_file}" ]]; then + # if the manifest file is newer then the cache: + if [[ "${commands[pandoc]}" -nt "${cache_file}" ]]; then + return 0 + else + return 1 + fi + else + return 0 + fi +} +# }}} +# {{{ choose a format among supported output format +(( $+functions[_pandoc_output_format] )) || +_pandoc_output_format(){ + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __pandoc_cache_policy + fi + if _cache_invalid pandoc_output_formats_simple; then + output_formats_simple=($(pandoc --list-output-formats)) + _store_cache pandoc_output_formats_simple output_formats_simple + else + _retrieve_cache pandoc_output_formats_simple + fi + if _cache_invalid pandoc_output_formats_plus_extensible || _cache_invalid pandoc_output_formats_minus_extensible; then + for f in ${output_formats_simple[*]}; do + for e in $(pandoc --list-extensions=${f}); do + if [[ "${e}" =~ '^\+' ]]; then + output_formats_plus_extensible+=("${f}${e}") + elif [[ "${e}" =~ '^\-' ]]; then + output_formats_minus_extensible+=("${f}${e}") + fi + done + done + _store_cache pandoc_output_formats_minus_extensible output_formats_minus_extensible + _store_cache pandoc_output_formats_plus_extensible output_formats_plus_extensible + else + _retrieve_cache pandoc_output_formats_minus_extensible + _retrieve_cache pandoc_output_formats_plus_extensible + fi + _alternative \ + 'formats_plus:format:{_multi_parts "+" output_formats_plus_extensible}' \ + 'formats_minus:format:{_multi_parts -- "-" output_formats_minus_extensible}' +} +# }}} +# {{{ choose a format among supported input format +(( $+functions[_pandoc_input_format] )) || +_pandoc_input_format(){ + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __pandoc_cache_policy + fi + if _cache_invalid pandoc_input_formats_simple; then + input_formats_simple=($(pandoc --list-input-formats)) + _store_cache pandoc_input_formats_simple input_formats_simple + else + _retrieve_cache pandoc_input_formats_simple + fi + if _cache_invalid pandoc_input_formats_plus_extensible || _cache_invalid pandoc_input_formats_minus_extensible; then + for f in ${input_formats_simple[*]}; do + for e in $(pandoc --list-extensions=${f}); do + if [[ "${e}" =~ '^\+' ]]; then + input_formats_plus_extensible+=("${f}${e}") + elif [[ "${e}" =~ '^\-' ]]; then + input_formats_minus_extensible+=("${f}${e}") + fi + done + done + _store_cache pandoc_input_formats_minus_extensible input_formats_minus_extensible + _store_cache pandoc_input_formats_plus_extensible input_formats_plus_extensible + else + _retrieve_cache pandoc_input_formats_minus_extensible + _retrieve_cache pandoc_input_formats_plus_extensible + fi + _alternative \ + 'formats_plus:format:{_multi_parts "+" input_formats_plus_extensible}' \ + 'formats_minus:format:{_multi_parts -- "-" input_formats_minus_extensible}' +} +# }}} +# {{{ choose a format among all supported formats +(( $+functions[_pandoc_all_formats] )) || +_pandoc_all_formats(){ + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __pandoc_cache_policy + fi + if _cache_invalid pandoc_input_formats_simple; then + input_formats_simple=($(pandoc --list-input-formats)) + _store_cache pandoc_input_formats_simple input_formats_simple + else + _retrieve_cache pandoc_input_formats_simple + fi + if _cache_invalid pandoc_output_formats_simple; then + output_formats_simple=($(pandoc --list-output-formats)) + _store_cache pandoc_output_formats_simple output_formats_simple + else + _retrieve_cache pandoc_output_formats_simple + fi + if _cache_invalid pandoc_all_formats; then + all_formats=(${output_formats_simple} ${input_formats_simple}) + all_formats=($(sort -u <<<"${all_formats[*]}")) + _store_cache pandoc_all_formats all_formats + else + _retrieve_cache pandoc_all_formats + fi + _describe "format" all_formats +} +# }}} +# {{{ pdf engine choice +(( $+functions[_pandoc_pdf_engine] )) || +_pandoc_pdf_engine(){ + _alternative \ + 'engines:engine:{_values "engine" pdflatex lualatex xelatex wkhtmltopdf weasyprint prince context pdfroff}' \ + 'engine_files:engine:_files' +} +# }}} +# {{{ options to pass to --pdf-engine command +(( $+functions[_pandoc_pdf_engine_opts] )) || +_pandoc_pdf_engine_opts(){ + local pdf_engine=${opt_args[--pdf-engine]} + case ${pdf_engine} in + "pdflatex"|"lualatex"|"xelatex"|"xetex"|"latex"|"pdftex"|"tex"|"") + _tex + ;; + *) + type _${pdf_engine} > /dev/null + if [[ $? == 1 ]]; then + _message "Options for ${pdf_engine}" + fi + ;; + esac +} +# }}} +# {{{ choose data-dir +(( $+functions[_pandoc_data_dir] )) || +_pandoc_data_dir(){ + _files -/ +} +# }}} +# {{{ choose template from data-dir +(( $+functions[_pandoc_template] )) || +_pandoc_template(){ + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __pandoc_cache_policy + fi + if _cache_invalid pandoc_output_formats_simple; then + output_formats_simple=($(pandoc --list-output-formats)) + _store_cache pandoc_output_formats_simple output_formats_simple + else + _retrieve_cache pandoc_output_formats_simple + fi + local data_dir=${opt_args[--data-dir]} + if [[ -z $data_dir ]]; then + if _cache_invalid pandoc_default_data_dir; then + default_data_dir=$(pandoc --version | sed -ne 's/Default user data directory: \(.*\)/\1/p') + _store_cache pandoc_default_data_dir default_data_dir + else + _retrieve_cache pandoc_default_data_dir + fi + data_dir=${default_data_dir} + fi + _pandoc_template_find_args="-name '*.'${output_formats_simple[1]}" + for ((i = 2; i < ${#output_formats_simple[@]}; i++ )); do + _pandoc_template_find_args=$_pandoc_template_find_args" -or -name '*.'${output_formats_simple[$i]}" + done + templates=($(eval find -L ${data_dir}/templates ${_pandoc_template_find_args} 2>/dev/null | sed -e 's/.*\///' -e 's/\.[^.]*$//')) + if [[ -z "${templates}" ]]; then + templates=default + fi + _describe 'templates from default data-dir' templates +} +# }}} +# {{{ choose highlight-style +(( $+functions[_pandoc_highlight_style] )) || +_pandoc_highlight_style(){ + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __pandoc_cache_policy + fi + if _cache_invalid pandoc_highlighting_styles; then + highlighting_styles=($(pandoc --list-highlight-styles)) + _store_cache pandoc_highlighting_styles highlighting_styles + else + _retrieve_cache pandoc_highlighting_styles + fi + _alternative \ + 'styles:style:{_values "syntax builting style" ${highlighting_styles[*]}}' \ + 'style_files_here:style:{_files -g "*.theme"}' +} +# }}} +# {{{ choose filter from specified or default data-dir +(( $+functions[_pandoc_filter] )) || +_pandoc_filter(){ + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __pandoc_cache_policy + fi + local data_dir=${opt_args[--data-dir]} + if [[ -z $data_dir ]]; then + if _cache_invalid pandoc_default_data_dir; then + default_data_dir=$(pandoc --version | sed -ne 's/Default user data directory: \(.*\)/\1/p') + _store_cache pandoc_default_data_dir default_data_dir + else + _retrieve_cache pandoc_default_data_dir + fi + data_dir=${default_data_dir} + fi + local filters_dir=$data_dir"/filters" + _alternative \ + 'local_filter:filter:{_files -g "*.lua"}' \ + 'data_dir_filter:filter:{_files -W filters_dir -g "*.lua"}' +} +# }}} +# {{{ choose lua filter from specified or default data-dir +(( $+functions[_pandoc_lua_filter] )) || +_pandoc_lua_filter(){ + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy __pandoc_cache_policy + fi + local data_dir=${opt_args[--data-dir]} + if [[ -z $data_dir ]]; then + if _cache_invalid pandoc_default_data_dir; then + default_data_dir=$(pandoc --version | sed -ne 's/Default user data directory: \(.*\)/\1/p') + _store_cache pandoc_default_data_dir default_data_dir + else + _retrieve_cache pandoc_default_data_dir + fi + data_dir=${default_data_dir} + fi + local filters_dir=$data_dir"/filters" + _alternative \ + 'local_filter:filter:{_files -g "(#q*)(.)"}' \ + 'data_dir_filter:filter:{_files -W filters_dir -g "(#q*)(.)"}' + } +# }}} +# {{{ choose reference location +(( $+functions[_pandoc_reference_location] )) || +_pandoc_reference_location(){ + local -a policies + policies=( + 'block:place references at the end of the current (top-level) block' + 'section:place references at the end of the current (top-level) section' + 'document:place references at the end of the document' + ) + _describe 'location' policies +} +# }}} +# --base-header-level must be 1-5: https://github.com/jgm/pandoc/blob/34d8ffbcfc33b86766ff7229be4d8a0d1fbffb50/src/Text/Pandoc/App.hs#L867 +# {{{ choose top level division +(( $+functions[_pandoc_top_level_division] )) || +_pandoc_top_level_division(){ + _values 'top level division' default section chapter part +} +# }}} +# {{{ choose header levels +(( $+functions[_pandoc_header_levels] )) || +_pandoc_header_levels(){ + _values -s , "number" 1 2 3 4 5 6 +} +(( $+functions[_pandoc_header_level] )) || +_pandoc_header_level(){ + _values "number" 1 2 3 4 5 6 +} +# }}} +# {{{ choose email obfusication +(( $+functions[_pandoc_email_obfusication] )) || +_pandoc_email_obfusication(){ + local -a policies + policies=( + 'none:(default) leaves mailto: links as they are' + 'javascript:obfuscates them using JavaScript' + 'references:obfuscates them by printing their letters as decimal or hexadecimal character references' + ) + _describe 'obfusication' policies +} +# }}} +# {{{ choose wrapping policy +(( $+functions[_pandoc_wrap] )) || +_pandoc_wrap() { + local -a policies + policies=( + 'auto:(default) wrap lines to the column width specified by --columns (default 72)' + "none:don't wrap lines at all" + 'preserve:attempt to preserve the wrapping from the source document' + ) + _describe 'policy' policies +} +# }}} +# {{{ choose eol policy +(( $+functions[_pandoc_eol] )) || +_pandoc_eol() { + local -a policies + policies=( + 'native:line endings appropriate to the OS on which pandoc is being run' + 'crlf:windows' + 'lf:macOS/Linux/UNIX' + ) + _describe 'policy' policies +} +# }}} +# {{{ choose changes tracking policy +(( $+functions[_pandoc_track_changes] )) || +_pandoc_track_changes() { + local -a policies + policies=( + 'accept:(default) inserts all insertions, and ignores all deletions' + 'reject:inserts all deletions and ignores insertions' + 'all:puts in insertions, deletions, and comments, wrapped in spans with insertion, deletion, comment-start, and comment-end classes, respectively' + ) + _describe 'policy' policies +} +# }}} + +# The real thing +_arguments -C \ + {-f,-r,--from=,--read=}'[specify input format]:format:_pandoc_input_format' \ + {-t,-w,--to=,--write=}'[specify output format]:format:_pandoc_output_format' \ + {-o,--output=}'[write output to FILE instead of stdout]:file:_files' \ + '--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 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 built-in lua filtering system]:file:_pandoc_lua_filter' \ + {-p,--preserve-tabs}'[preserve tabs instead of converting them to spaces]: :' \ + '--tab-stop=[specify the number of spaces per tab (default is 4)]:number:{_message -r "choose a number equals to or greater then 1"}' \ + '--track-changes=[specifies what to do with insertions, deletions, and comments produced by the MS Word "Track Changes" feature]: :_pandoc_track_changes' \ + '--file-scope[parse each file individually before combining for multifile documents]: :' \ + '--extract-media=[extract images and other media contained in or linked from the source document to the path DIR]:dir:{_dir_list}' \ + {-s,--standalone}'[produce output with an appropriate header and footer]: :' \ + '--template=[use FILE as a custom template for the generated document. Implies --standalone]: :_pandoc_template' \ + {\*-M,\*--metadata=}'[set the metadata field KEY to the value VALUE]:key\:value: ' \ + {\*-V,\*--variable=}'[set the variable KEY to the value VALUE]:key\:value: ' \ + '(- :)'{-D,--print-default-template=}'[print the system default template for an output]:format:_pandoc_output_format' \ + '(- :)--print-default-data-file=[print a system default data file]:file: ' \ + '(- :)--print-highlight-style=[prints a JSON version of a highlighting style]:style|file: ' \ + '--dpi=[specify the dpi (dots per inch) value for conversion from pixels to inch/centimeters and vice versa]:number: ' \ + '--eol=[manually specify line endings (crlf|lf|native)]: :_pandoc_eol' \ + '--wrap=[determine how text is wrapped in the output (the source code, not the rendered version)]: :_pandoc_wrap ' \ + '--columns=[specify length of lines in characters (default 72)]:number: ' \ + '--strip-comments[strip out HTML comments in the Markdown or Textile source]: : ' \ + {--toc,--table-of-contents}'[include an automatically generated table of contents]: : ' \ + '--toc-depth=[specify the number of section levels to include in the table of contents]:number:{_message -r "choose a number equals to or greater then 1"}' \ + '--no-highlight[disables syntax highlighting for code blocks and inlines]: : ' \ + '--highlight-style=[specifies the coloring style to be used in highlighted source code]:style|file:_pandoc_highlight_style' \ + '--syntax-definition=[load a KDE XML syntax definition file]:file:{_files -g "*.xml"}' \ + {\*-H,\*--include-in-header=}'[include contents of FILE, verbatim, at the end of the header, implies --standalone]:file:_files' \ + {\*-B,\*--include-before-body=}'[include contents of FILE, verbatim, at the beginning of the document body, implies --standalone]:file:_files' \ + {\*-A,\*--include-end-body=}'[include contents of FILE, verbatim, at the end of the document body, implies --standalone]:file:_files' \ + '--resource-path=[list of paths to search for images and other resources]:searchpath:_dir_list' \ + '--request-header=[set the request header NAME to the value VAL when making HTTP requests]:name\:val: ' \ + '--self-contained[produce a standalone HTML file with no external dependencies, using data: URIs to incorporate the contents of linked scripts, stylesheets, images, and videos. Implies --standalone]: : ' \ + '--html-q-tags[use <q> tags for quotes in HTML]: : ' \ + '--ascii[use only ASCII characters in output, supported only for HTML and DocBook output]: : ' \ + '--reference-links[use reference-style links, rather than inline links]: : ' \ + '--reference-location=[specify where footnotes (and references, if reference-links is set) are placed (block|section|document)]: :_pandoc_reference_location' \ + '--atx-headers[use ATX-style headers in Markdown and AsciiDoc output]: : ' \ + '--top-level-division=[treat top-level headers as the given division type in LaTeX, ConTeXt, DocBook, and TEI output]: :_pandoc_top_level_division' \ + {-N,--number-sections}'[number section headings in LaTeX, ConTeXt, HTML, or EPUB output]: : ' \ + '--number-offset=[offset for section headings in HTML output (ignored in other output formats)]: :_pandoc_header_levels' \ + '--listings[use the listings package for LaTeX code blocks]: : ' \ + {-i,--incremental}'[make list items in slide shows display incrementally (one by one)]: : ' \ + '--slide-level=[specifies that headers with the specified level create slides (for beamer, s5, slidy, slideous, dzslides)]: :_pandoc_header_levels' \ + '--section-divs[wrap sections in <section> tags (or <div> tags for html4)Use the section-divs package for LaTeX code blocks]: : ' \ + '--email-obfusication=[treat top-level headers as the given division type in LaTeX, ConTeXt, DocBook, and TEI output (none|javascript|references)]: :_pandoc_email_obfusication' \ + '--default-image-extension=[specify a default extension to use when image paths/URLs have no extension]:extension: ' \ + '--id-prefix=[specify a prefix to be added to all identifiers and internal links in HTML and DocBook output]:string: ' \ + {-T,--title-prefix=}'[specify STRING as a prefix at the beginning of the title that appears in the HTML header]:string: ' \ + {\*-c,\*--css=}'[link to a CSS style sheet]:url: ' \ + '--reference-doc=[use the specified file as a style reference in producing a docx or ODT file]:file: ' \ + '--epub-subdirectory=[specify the subdirectory in the OCF container that is to hold the EPUB-specific contents]:dir:{_files -/}' \ + '--epub-cover-image=[use the specified image as the EPUB cover]:file:_files' \ + '--epub-metadata=[look in the specified XML file for metadata for the EPUB]:file:{_files -g "*.xml"}' \ + '*--epub-embed-font=[embed the specified font in the EPUB]:file:_files ' \ + '--epub-chapter-level=[specify the header level at which to split the EPUB into separate "chapter" files]:number:_pandoc_header_level' \ + '--pdf-engine=[use the specified engine when producing PDF output]:program:_pandoc_pdf_engine' \ + '*--pdf-engine-opt=[use the given string as a command-line argument to the pdf-engine]:string:_pandoc_pdf_engine_opts' \ + '*--bibliography=[set the bibliography field in the document'"'"'s metadata to FILE]:file:{_files -g "*.{bib,bibtex,copac,json,yaml,enl,xml,wos,medline,mods,ris}"}' \ + '--csl=[set the csl field in the document'"'"'s metadata to FILE]:file:{_files -g "*.csl"}' \ + '--citation-abbreviations=[set the citation-abbreviations field in the document'"'"'s metadata to FILE]:file:_files' \ + '--natbib[use natbib for citations in LaTeX output]' \ + '--biblatex[use biblatex for citations in LaTeX output]' \ + '--mathml[convert TeX math to MathML (in epub3, docbook4, docbook5, jats, html4 and html5)]' \ + '--webtex=[convert TeX formulas to <img> tags that link to an external script that converts formulas to images]::url: ' \ + '--mathjax=[use MathJax to display embedded TeX math in HTML output]::url: ' \ + '--katex=[use KaTeX to display embedded TeX math in HTML output]::url: ' \ + {-m,--latexmathml=,--asciimathml=}'[deprecated. Use the LaTeXMathML script to display embedded TeX math in HTML output]::url: ' \ + '--mimetex=[deprecated. Render TeX math using the mimeTeX CGI script, which generates an image for each TeX formula]::url: ' \ + '--jsmath=[deprecated. Use jsMath (the predecessor of MathJax) to display embedded TeX math in HTML output]::url: ' \ + '--gladtex[deprecated. Enclose TeX math in <eq> tags in HTML output]: : ' \ + '--abbreviations=[specifies a custom abbreviations file]:file:_files ' \ + '--trace[enable tracing]' \ + '--dump-args[print information about command-line arguments to stdout, then exit]' \ + '--ignore-args[ignore command-line arguments (for use in wrapper scripts)]' \ + '--verbose[give verbose debugging output]' \ + '--quiet[suppress warning messages]' \ + '--fail-if-warnings[exit with error status if there are any warnings]' \ + '--log=[write log messages in machine-readable JSON format to FILE]:file:_file' \ + '(- :)--bash-completion[generate a bash completion script]' \ + '(- :)--list-input-formats[list supported input formats, one per line]' \ + '(- :)--list-output-formats[list supported output formats, one per line]' \ + '(- :)--list-extensions=[list supported extensions, one per line, preceded by a + or - indicating whether it is enabled by default in FORMAT]:format:_pandoc_all_formats' \ + '(- :)--list-highlight-languages[list supported languages for syntax highlighting, one per line]' \ + '(- :)--list-highlight-styles[list supported styles for syntax highlighting, one per line]' \ + '(- :)'{-v,--version}'[print version]' \ + '(- :)'{-h,--help}'[print help]' \ + '*:file:_files' diff --git a/Completion/Unix/Command/_perforce b/Completion/Unix/Command/_perforce index 3cd99d519..0d007e3bc 100644 --- a/Completion/Unix/Command/_perforce +++ b/Completion/Unix/Command/_perforce @@ -2426,7 +2426,7 @@ _perforce_cmd_key() { _arguments -s : \ '(-i -m)-d[delete key]' \ '(-d -m)-i[increment key value by 1]' \ - '(-d -i)-m[allow mulitple operations]' \ + '(-d -i)-m[allow multiple operations]' \ $keyargs } diff --git a/Completion/Unix/Command/_picocom b/Completion/Unix/Command/_picocom index 4b8b3ea2e..9059b03e8 100644 --- a/Completion/Unix/Command/_picocom +++ b/Completion/Unix/Command/_picocom @@ -47,7 +47,7 @@ function _picocom () { '--omap[define output character map]:output character map:' '--emap[define local echo character map]:local echo character map:' '(--help -h)'{--help,-h}'[display help message]' - '*:device:_files -g "*(%c)"' ) + '*:device:_files -g "*(-%c)"' ) _arguments -C : "${args[@]}" } diff --git a/Completion/Unix/Command/_ping b/Completion/Unix/Command/_ping index 78fd33d92..274204264 100644 --- a/Completion/Unix/Command/_ping +++ b/Completion/Unix/Command/_ping @@ -11,6 +11,7 @@ case ${variant}:${${service#ping}:-4} in args+=( '-d[set SO_DEBUG on the socket]' '-n[show network addresses as numbers]' + '-M+[define mtu discovery]:mtu discovery:(do dont want)' '-v[verbose output]' ) ;| @@ -104,9 +105,11 @@ case ${variant}:${${service#ping}:-4} in '-z+[specify type of service]:type of service' ) ;| + (freebsd|openbsd|darwin)*:6) + args+=( '-D[disable IPv6 fragmentation]' ) + ;| (freebsd|darwin)*:6) args+=( - '-D[disable IPv6 fragmentation]' '-R[audible bell for no packet]' '-r[audible bell for each packet]' ) @@ -136,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' ) ;| @@ -149,16 +152,12 @@ case ${variant}:${${service#ping}:-4} in '--apple-time[prints the time a packet was received]' ) ;; - openbsd*:4) - args+=( - '-T+[change TOS value]:TOS value:(critical inetcontrol lowdelay netcontrol throughput reliability ef af cs)' - ) - ;| openbsd*) args+=( '-H[try reverse-lookups of addresses]' '-E[audible bell for no packet]' '-e[audible bell for each packet]' + '-T+[change TOS value]:TOS value:(critical inetcontrol lowdelay netcontrol throughput reliability ef af cs)' '-V+[specify routing table to be used]:routing table' ) ;; 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 new file mode 100644 index 000000000..595eb1cb4 --- /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 <param> => include only specified parameters +# -O <param> => 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 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' + '--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 "$@" diff --git a/Completion/Unix/Command/_prcs b/Completion/Unix/Command/_prcs deleted file mode 100644 index 46e441c34..000000000 --- a/Completion/Unix/Command/_prcs +++ /dev/null @@ -1,191 +0,0 @@ -#compdef prcs - -local curcontext="$curcontext" state line subcmds ret=1 -typeset -A opt_args - -# lookup project names in the repository -# (this does not handle subprojects) - -(( $+functions[_prcs_projects] )) || -_prcs_projects() { - local expl - - _wanted prcs-projects expl 'project name' compadd "$@" - \ - ${~opt_args[-R]:-${opt_args[--repository]:-${PRCS_REPOSITORY:-~/PRCS}}}/*(/:t) -} - -# standard options for all subcommands - -(( $+functions[_prcs_arguments] )) || -_prcs_arguments() { - _arguments -s \ - '(-f --force)'{-f,--force}'[resolve interactive queries in some fixed way]' \ - '(-h -H --help)'{-h,-H,--help}'[print out help]' \ - '(-j --jobs)'{-j,--jobs=}'[spawn many child processes at once]:number:' \ - '(-l -L --long-format --long-long-format)'{-l,--long-format}'[long format]' \ - '(-l -L --long-format --long-long-format)'{-L,--long-long-format}'[longer format]' \ - '(-n --no-action)--no-action[show what would happen but leave files unchanged]' \ - '(-q --quiet)'{-q,--quiet}'[suppress normal informational messages]' \ - "--plain-format[don't break lines at screen width]" \ - '(-R --repository)'{-R,--repository=}'[specify the repository directory]:directory:_files -/' \ - "$@" -} - -_arguments -C \ - '(* -)'{-h,-H,--help}'[print out help]' \ - '(* -)--version[display program version]' \ - '*:: :->subcmd' && ret=0 - -if (( CURRENT == 1 )); then - subcmds=( - 'admin:admin subcommand' - 'checkin:checkin project revision' - 'checkout:checkout project revision' - 'config:verify configuration' - 'delete:delete named revision of project' - 'depopulate:remove named files from project descriptor' - 'diff:show differences between two revisions' - 'execute:execute a command for each file in a project' - 'info:print information about versions of project' - 'merge:reconcile differences between working files and another revision' - 'package:package the project and all its revisions into packagefile' - 'populate:add named files to project descriptor' - 'rekey:set keywords in selected files' - 'unpackage:unpackage project in packagefile' - ) - - _describe -t commands 'prcs command' subcmds && ret=0 - return ret -fi - -curcontext="${curcontext%:*}-$words[1]:" - -case "$words[1]" in - admin) - if (( CURRENT == 2 )); then - subcmds=( - 'access:set the access permissions on the repository' - 'compress:instruct PRCS to save disk space for project' - 'init:create a repository entry' - 'pdelete:delete a repository entry' - 'pinfo:list all projects in the repository' - 'prename:rename a repository entry' - 'rebuild:reconstruct PRCS data files in the repository' - 'uncompress:instruct PRCS to save time in processing project' - ) - _describe -t commands 'admin subcommand' subcmds - else - shift words - (( --CURRENT )) - curcontext="${curcontext%:*}-$words[1]:" - case "$words[1]" in - access|compress|init|pdelete|prename|rebuild) - _prcs_arguments ':project name:_prcs_projects' - ;; - pinfo) - _prcs_arguments - ;; - uncompress) - _prcs_arguments \ - '-i[expand the entire project immediately]' \ - ':project name:_prcs_projects' - ;; - *) - _message "unknown prcs administrative subfunction: $words[1]" - ;; - esac - fi - ;; - checkin) - _prcs_arguments \ - '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ - '(-s --skilled-merge)'{-s,--skilled-merge}'[turn off most of the safety features of merge]' \ - ':project name:_prcs_projects' \ - '*:file or directory:_files' - ;; - checkout) - _prcs_arguments \ - '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ - '(-p --preserve)'{-p,--preserve}'[preserve permissions on files that are checked out]' \ - '(-u --unlink)'{-u,--unlink}"[don't overwrite symbolic link references]" \ - '(-P --exclude-project-file)'{-P,--exclude-project-file}"[don't checkout the project file]" \ - ':project name:_prcs_projects' \ - '*:file or directory:_files' - ;; - config) - _prcs_arguments - ;; - delete) - _prcs_arguments \ - '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ - ':project name:_prcs_projects' - ;; - depopulate) - _prcs_arguments \ - ':project name:_prcs_projects' \ - '*:file or directory:_files' - ;; - diff) - _prcs_arguments \ - '*'{-r+,--revision=}'[specify version of the project]:revision:' \ - '(-k --keywords)'{-k,--keywords}'[compare keywords too]' \ - '(-N --new)'{-N,--new}'[compare new files against empty files]' \ - '(-P --exclude-project-file)'{-P,--exclude-project-file}"[don't diff the project file]" \ - '--[introduce diff options]:*::diff options:= _diff_options ${PRCS_DIFF_COMMAND:-diff}' \ - ':project name:_prcs_projects' \ - '*:file or directory:_files' - ;; - execute) - _prcs_arguments \ - '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ - '--pre[list directories first]' \ - '(--pipe)--all[execute command once, with all files as arguments]' \ - '(--all)--pipe[supply file contents as the standard input]' \ - '--match[execute command on files matching a pattern]:pattern:' \ - '--not[execute command on files not matching a pattern]:pattern:' \ - '--:command: _command_names -e:*::arguments: _normal' \ - ':project name:_prcs_projects' \ - '*:file or directory:_files' - ;; - info) - _prcs_arguments \ - '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ - '--sort=[set sorting type]:sorting type:(version date)' \ - ':project name:_prcs_projects' \ - '*:file or directory:_files' - ;; - merge) - _prcs_arguments \ - '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ - '(-s --skilled-merge)'{-s,--skilled-merge}'[turn off most of the safety features of merge]' \ - '(-u --unlink)'{-u,--unlink}"[don't overwrite symbolic link references]" \ - ':project name:_prcs_projects' \ - '*:file or directory:_files' - ;; - package) - _prcs_arguments \ - '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ - '(-z --compress)'{-z,--compress=}'[compress the output]' \ - ':project name:_prcs_projects' \ - ':file:_files' - ;; - populate) - _prcs_arguments \ - '(-d --delete)'{-d,--delete=}'[perform optional deletions]' \ - ':project name:_prcs_projects' \ - '*:file or directory:_files' - ;; - rekey) - _prcs_arguments \ - '(-u --unlink)'{-u,--unlink}"[don't overwrite symbolic link references]" \ - ':project name:_prcs_projects' - ;; - unpackage) - _prcs_arguments \ - ':file:_files' \ - ':project name:_prcs_projects' - ;; - *) - _message "unknown prcs command: $words[1]" - ;; -esac diff --git a/Completion/Unix/Command/_pv b/Completion/Unix/Command/_pv new file mode 100644 index 000000000..68f8e8586 --- /dev/null +++ b/Completion/Unix/Command/_pv @@ -0,0 +1,87 @@ +#compdef pv + +local curcontext="$curcontext" ign Edesc ret=1 +local -a state state_descr line expl suf args fmts +local -A opt_args + +(( $#words > 2 )) && ign='!' +(( $+words[(r)-[^-]#E*] )) && Edesc=' and only report a read error once per file' +[[ $OSTYPE = linux* ]] && args=( + '(-d --watchfd)'{-d+,--watchfd=}'[watch file descriptor opened by process]:process\:fd:->pid-fds' \ +) + +_arguments -s -S $args \ + '(-p --progress -F --format)'{-p,--progress}'[show progress bar]' \ + '(-t --timer -F --format)'{-t,--timer}'[show elapsed time]' \ + '(-e --eta -F --format)'{-e,--eta}'[show estimated time of arrival]' \ + '(-I --fineta -F --format)'{-I,--fineta}'[show absolute estimated time of arrival]' \ + '(-r --rate -F --format)'{-r,--rate}'[show data transfer rate counter]' \ + '(-a --average-rate -F --format)'{-a,--average-rate}'[show data transfer average rate counter]' \ + '(-b --bytes -F --format)'{-b,--bytes}'[show number of bytes transferred]' \ + '(-T --buffer-percent -F --format)'{-T,--buffer-percent}'[show percentage of transfer buffer in use]' \ + '(-A --last-written -F --format)'{-A+,--last-written=}'[show number of bytes last written]:number (bytes)' \ + '(-F --format -p --progress -t --timer -e --eta -I --fineta -r --rate -a --average-rate -b --bytes -T --buffer-percent -A --last-written -F --format)'{-F+,--format=}'[set output format]:format:->formats' \ + '(-n --numeric -f --force)'{-n,--numeric}'[output percentages, not visual information]' \ + '(-q --quiet)'{-q,--quiet}"[don't output any transfer information at all, useful with -L]" \ + '(-W --wait)'{-W,--wait}'[display nothing until first byte transferred]' \ + '(-D --delay-start -R --remote)'{-D+,--delay-start=}'[display nothing until delay has passed]:delay (seconds)' \ + '(-s --size)'{-s+,--size=}'[set estimated data size]:size (bytes):->size-unit' \ + '(-l --line-mode -R --remote)'{-l,--line-mode}'[count lines instead of bytes]' \ + '(-0 --null -l --line-mode)'{-0,--null}'[lines are null-terminated]' \ + '(-i --interval)'{-i+,--interval=}'[update every after specified interval]:interval (seconds) [1]' \ + '(-w --width)'{-w+,--width}'[assume terminal is specified characters wide]:width' \ + '(-H --height)'{-H+,--height=}'[assume terminal is specified rows high]:height' \ + '(-N --name)'{-N+,--name=}'[prefix visual information with given name]:name' \ + '(-f --force -R --remote)'{-f,--force}'[output even if standard error is not a terminal]' \ + '(-c --cursor -R --remote)'{-c,--cursor}'[use cursor positioning escape sequences]' \ + '(-L --rate-limit)'{-L+,--rate-limit=}'[limit transfer rate]:rate (bytes per second):->size-unit' \ + '(-B --buffer-size)'{-B+,--buffer-size=}'[use a buffer size of given size]:size (bytes):->size-unit' \ + '(-C --no-splice)'{-C,--no-splice}'[never use splice(), always use read/write]' \ + '(-R --remote)*'{-E,--skip-errors}"[skip read errors in input${Edesc}]" \ + '(-S --stop-at-size -R --remote)'{-S,--stop-at-size}'[stop after --size bytes have been transferred]' \ + '(-R --remote -c --cursor -l --line-mode -f --force -D --delay-start -E --skip-errors -S --stop-at-size)'{-R+,--remote=}'[update settings of specified process]:process:_pids -m pv' \ + '(-P --pidfile)'{-P+,--pidfile=}'[save process id in a file]:file:_files' \ + "${ign}(- *)"{-h,--help}'[display usage information]' \ + "${ign}(- *)"{-V,--version}'[display version information]' \ + '*:file:_files' && ret=0 + +case $state in + formats) + compset -P '(%?|%<->A|[^%])#' + fmts=( + 'p:progress bar' + 't:elapsed time' + 'e:estimated time remaining' + 'I:estimated time of completion' + 'r:current data transfer rate' + 'a:average data transfer rate' + 'b:bytes transferred so far' + 'T:percentage of transfer buffer in use' + 'N:name prefix' + '%:literal %' + ) + _describe -t format-specifiers 'format specifier' fmts -p % -S '' + ;; + pid-fds) + if compset -P 1 '*:'; then + _message -e file-descriptors 'file descriptor' + else + compset -S ':*' || suf=( -qS : ) + _pids $suf && ret=0 + fi + ;; + size-unit) + if compset -P '<->'; then + _tags values units + else + _tags values + fi + while _tags; do + _requested values && _message -e values "$state_descr" && ret=0 + _requested units expl unit compadd -o nosort - K M G T && ret=0 + (( ret )) || break + done + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_python b/Completion/Unix/Command/_python index 2fb4a915b..f10106f9b 100644 --- a/Completion/Unix/Command/_python +++ b/Completion/Unix/Command/_python @@ -16,7 +16,7 @@ if _pick_variant python3=Python\ 3 python2 --version; then ) else args=( - '-R[use a pseudo-random salt to make hash values unpredeictable]' + '-R[use a pseudo-random salt to make hash values unpredictable]' '-Q+[division options]:division option:(old warn warnall new)' '(-tt)-t[issue warnings about inconsistent tab usage]' '(-t)-tt[issue errors about inconsistent tab usage]' diff --git a/Completion/Unix/Command/_raggle b/Completion/Unix/Command/_raggle deleted file mode 100644 index 4bda595be..000000000 --- a/Completion/Unix/Command/_raggle +++ /dev/null @@ -1,48 +0,0 @@ -#compdef raggle - -# Raggle v0.4.0 - -local curcontext="$curcontext" state line -typeset -A opt_args - -_arguments -C -s \ - '(-a --add)'{-a,--add}"[add a new feed (requires '--url')]" \ - '(-A --ascii)'{-A,--ascii}'[use ASCII characters instead of ANSI for window borders]' \ - '(-c --config)'{-c,--config}'[specify an alternate config file]:config file:_files -g "*.rb(-.)"' \ - '--default-config[print out the default configuration of Raggle in a format suitable for your config.rb file]' \ - '(-d --delete)'{-d,--delete}'[delete an existing feed]:feed ID:->feed' \ - '--diag[run raggle in diagnostics/debug mode]' \ - '(-e --edit)'{-e,--edit}'[edit an existing feed]:feed ID:->feed' \ - '(--import-opml)--export-opml[export feeds to OPML]:OPML file:_files -g "*.opml(-.)"' \ - '(-f --find)'{-f,--find}'[find feeds containing a string, via Syndic8]:search string:' \ - "--force[force behavior Raggle won't normally allow]" \ - '(-)'{-h,--help,--usage}'[display help information]' \ - '(--export-opml)--import-opml[import feeds from an OPML file]:OPML file:_files -g "*.opml(-.)"' \ - '(-i --invalidate)'{-i,--invalidate}'[invalidate a feed (force an update)]:feed ID:->feed' \ - '(-l --list)'{-l,--list}"[list existing feeds (use '--verbose' to show URLs as well)]" \ - "--lock-title[lock Title attribute of feed (for '--add' and '--edit')]" \ - "--max[set the maximum number of items for a feed (for '--add' and '--edit')]" \ - '(-p --priority)'{-p,--priority}"[feed sorting priority: 0 by default, higher values will sort feeds to the top (for '--add' and '--edit')]:sorting priority:" \ - '--purge[purge deleted feeds from feed cache]' \ - '(-r --refresh)'{-r,--refresh}"[refresh attribute of feed (for '--add' and '--edit')]:refresh time (minutes):" \ - "--save-items[save old items of feed (for '--add' and '--edit')]" \ - '--server[run Raggle in HTTP server mode]:port:_ports' \ - '(--sort --sort-feeds)'{--sort,--sort-feeds}'[sort feeds by priority then title (case-insensitive)]' \ - '(-t --title)'{-t,--title}"[title attribute of feed (for '--add' and '--edit')]:feed title:" \ - "--unlock-title[unlock Title attribute of feed (for '--add' and '--edit')]" \ - "--unsave-items[don't save old items of feed (for '--add' and '--edit')]" \ - "--update[update feed (or all feeds, if unspecified)]::feed ID:->feed" \ - '(-u --url)'{-u,--url}"[URL attribute of feed (for '--add' and '--edit')]:URL:_urls" \ - '--verbose[turn on verbose output]' \ - '(-)'{-v,--version}'[display version information]' && return 0 - -if [[ "$state" = feed ]]; then - local feeds - feeds=( - ${${(M)${${(f)"$(_call_program feeds $words[1] \ - --list)"}/(#s)[[:blank:]]/}:#[0-9]##,*}/, /:} - ) - _describe -t feeds "RSS feed" feeds && return 0 -fi - -return 1 diff --git a/Completion/Unix/Command/_rclone b/Completion/Unix/Command/_rclone new file mode 100644 index 000000000..40f06e0ba --- /dev/null +++ b/Completion/Unix/Command/_rclone @@ -0,0 +1,346 @@ +#compdef rclone + +local curcontext="$curcontext" ret=1 +local -A opt_args +local -a state line commands remotes + +commands=( + "about\:'get quota information from the remote'" + "authorize\:'remote authorization'" + "cachestats\:'print cache stats for a remote'" + "cat\:'concatenate any files and send them to stdout'" + "check\:'check files on the source and destination match'" + "cleanup\:'clean up the remote if possible'" + "config\:'enter an interactive configuration session'" + "copy\:'copy files from source to dest, skipping already copied'" + "copyto\:'copy files from source to dest, skipping already copied'" + "copyurl\:'copy url content to dest'" + "cryptcheck\:'check the integrity of a crypted remote'" + "cryptdecode\:'return unencrypted file names'" + "dbhashsum\:'produce a Dropbox hash file for all the objects in the path'" + "dedupe\:'interactively find duplicate files and delete/rename them'" + "delete\:'remove the contents of path'" + "deletefile\:'remove a single file from remote'" + "genautocomplete\:'output completion script for a given shell'" + "gendocs\:'output markdown docs for rclone to the directory supplied'" + "hashsum\:'produce an hashsum file for all the objects in the path'" + "help\:'show help for rclone commands, flags and backends'" + "link\:'generate public link to file/folder'" + "listremotes\:'list all the remotes in the config file'" + "ls\:'list the objects in the path with size and path'" + "lsd\:'list all directories/containers/buckets in the path'" + "lsf\:'list directories and objects on remote:path formatted for parsing'" + "lsjson\:'list directories and objects in the path in JSON format'" + "lsl\:'list the objects in path with modification time, size and path'" + "md5sum\:'produce an md5sum file for all the objects in the path'" + "mkdir\:'make the path if it does not already exist'" + "mount\:'mount the remote as file system on a mountpoint'" + "move\:'move files from source to dest'" + "moveto\:'move file or directory from source to dest'" + "ncdu\:'explore a remote with a text based user interface'" + "obscure\:'obscure password for use in the rclone.conf'" + "purge\:'remove the path and all of its contents'" + "rc\:'run a command against a running rclone'" + "rcat\:'copy standard input to file on remote'" + "rcd\:'run rclone listening to remote control commands only'" + "rmdir\:'remove the path if empty'" + "rmdirs\:'remove empty directories under the path'" + "serve\:'serve a remote over a protocol'" + "settier\:'change storage class/tier of objects on remote'" + "sha1sum\:'produce an sha1sum file for all the objects in the path'" + "size\:'print the total size and number of objects on remote:path'" + "sync\:'make source and dest identical, modifying destination only'" + "touch\:'create new file or change file modification time'" + "tree\:'list the contents of the remote in a tree like fashion'" + "version\:'show the version number'" +) + +_arguments -C \ + ":command:(($commands))" \ + '--ask-password[prompt for password for encrypted configuration]' \ + "--auto-confirm[don't request console confirmation]" \ + '--backup-dir[make backups into hierarchy based at specified directory]:directory:_directories' \ + '--bind[specify socal address to bind to for outgoing connections]:IPv4, IPv6 or name' \ + '--buffer-size[specify in memory buffer size when reading files for each --transfer]:size [16M]' \ + '--bwlimit[specify bandwidth limit]:BwTimetable (kBytes/s or b|k|M|G suffix)' \ + '--cache-dir[specify directory rclone will use for caching]:directory [~/.cache/rclone]:_directories' \ + '--checkers[specify number of checkers to run in parallel]:number [8]': \ + '(-c --checksum)'{-c,--checksum}'[skip based on checksum & size, not mod-time & size]' \ + '--config[specify config file]:file [~/.config/rclone/rclone.conf]:_files' \ + '--contimeout[specify connect timeout]:duration [1m0s]' \ + '--cpuprofile[write cpu profile to specified file]:file:_files' \ + '(--delete-before --delete-during)--delete-after[when synchronizing, delete files on destination after transferring (default)]' \ + '(--delete-after --delete-during)--delete-before[when synchronizing, delete files on destination before transferring]' \ + '(--delete-before --delete-after)--delete-during[when synchronizing, delete files during transfer]' \ + '--delete-excluded[delete files on dest excluded from sync]' \ + '--disable[disable a comma separated list of features]:feature' \ + '(-n --dry-run)'{-n,--dry-run}'[do a trial run with no permanent changes]' \ + '--dump[list of items to dump from]:string:_sequence compadd - headers bodies requests responses auth filters goroutines openfiles' \ + '--dump-bodies[dump HTTP headers and bodies - may contain sensitive info]' \ + '--dump-headers[dump HTTP headers - may contain sensitive info]' \ + '--exclude[exclude files matching pattern]:stringArray' \ + '--exclude-from[read exclude patterns from file]:files:_files' \ + '--exclude-if-present[exclude directories if filename is present]:string' \ + '--fast-list[use recursive list if available]' \ + '--files-from[read list of source-file names from file]:file:_files' \ + {-f,--filter}'[add a file-filtering rule]:stringArray' \ + '--filter-from[read filtering patterns from a file]:file:_files' \ + '--ignore-case[ignore case in filters (case insensitive)]' \ + '--ignore-case-sync[ignore case when synchronizing]' \ + '--ignore-checksum[skip post copy check of checksums]' \ + '--ignore-errors[delete even if there are I/O errors]' \ + '--ignore-existing[skip all files that exist on destination]' \ + '--ignore-size[ignore size when skipping use mod-time or checksum]' \ + '(-I --ignore-times)'{-I,--ignore-times}"[don't skip files that match on size and time - transfer all files]" \ + "--immutable[don't modify files, fail if existing files have been modified]" \ + '--include[include files matching pattern]:stringArray' \ + '--include-from[read include patterns from file]:file:_files' \ + '--log-file[log everything to this file]:file:_files' \ + '--log-format[specify comma separated list of log format options]:string ["date,time"]' \ + '--log-level[specify log level]:string [NOTICE]:(DEBUG INFO NOTICE ERROR)' \ + '--low-level-retries[number of low level retries to do]:int [10]' \ + '--max-age[only transfer files younger than this in s or suffix ms|s|m|h|d|w|M|y]:duration [default off]' \ + '--max-backlog[maximum number of objects in sync or check backlog]:int [10000]' \ + '--max-delete[when synchronizing, limit the number of deletes]:delete limit [-1]' \ + '--max-depth[limit the recursion depth]:depth [-1]' \ + '--max-size[only transfer files smaller than this in k or suffix b|k|M|G]:int [default off]' \ + '--max-transfer[maximum size of data to transfer]:int [default off]' \ + '--memprofile[write memory profile to file]:file:_files' \ + '--min-age[only transfer files older than this in s or suffix ms|s|m|h|d|w|M|y]:duration [default off]' \ + '--min-size[only transfer files bigger than this in k or suffix b|k|M|G]:int [default off]' \ + '--modify-window[specify max time delta to be considered the same]:duration [1ns]' \ + '--multi-thread-cutoff[use multi-threaded downloads for files above specified size]:size (250M)' \ + '--multi-thread-streams[specify max number of streams to use for multi-threaded downloads]:number (4)' \ + "--no-check-certificate[don't verify the server SSL certificate (insecure)]" \ + "--no-gzip-encoding[don't set Accept-Encoding: gzip]" \ + '!--no-traverse' \ + "--no-update-modtime[don't update destination mod-time if files are identical]" \ + '(-P --progress)'{-P,--progress}'[show progress during transfer]' \ + {-q,--quiet}'[print as little as possible]' \ + '--rc[enable the remote control server]' \ + '--rc-addr[IPaddress\:port or \:port to bind server to]:string [localhost\:5572]' \ + '--rc-cert[SSL PEM key (concatenation of certificate and CA certificate)]:string' \ + '--rc-client-ca[client certificate authority to verify clients with]:string' \ + '--rc-files[path to local files to serve on the HTTP server]:directory:_path_files -/' \ + '--rc-htpasswd[htpasswd file - if not provided no authentication is done]:file:_files' \ + '--rc-job-expire-duration[expire finished async jobs older than specified duration]:duration (1m0s)' \ + '--rc-job-expire-interval[specify interval to check for expired async jobs]:interval (10s)' \ + '--rc-key[SSL PEM Private key]:string' \ + '--rc-max-header-bytes[maximum size of request header]:int [4096]' \ + "--rc-no-auth[don't require auth for certain methods]" \ + '--rc-pass[password for authentication]:string' \ + '--rc-realm[realm for authentication]:string [rclone]' \ + '--rc-serve[enable the serving of remote objects]' \ + '--rc-server-read-timeout[timeout for server reading data]:duration [1h0m0s]' \ + '--rc-server-write-timeout[timeout for server writing data]:duration [1h0m0s]' \ + '--rc-user[user name for authentication]:string' \ + '--retries[retry operations this many times if they fail]:int [3]' \ + '--retries-sleep[interval between retrying operations if they fail, e.g 500ms, 60s, 5m. (0 to disable)]:interval' \ + '--size-only[skip based on size only, not mod-time or checksum]' \ + '--stats[interval between printing stats, e.g 500ms, 60s, 5m. (0 to disable)]:duration [1m0s]' \ + '--stats-file-name-length[max file name length in stats. 0 for no limit]:int [40]' \ + '--stats-log-level[log level to show --stats output]:string [INFO]:(DEBUG INFO NOTICE ERROR)' \ + '--stats-one-line[make the stats fit on one line]' \ + '--stats-one-line-date[enable --stats-one-line and add current date/time prefix]' \ + '--stats-one-line-date-format[enable --stats-one-line-date and use custom formatted date]:date format' \ + '--stats-unit[specify units for data rate in stats]:unit [bytes]:(bits bytes)' \ + '--streaming-upload-cutoff[specify size cutoff for switching to chunked upload]:size [100k]' \ + '--suffix[specify suffix for use with --backup-dir]:string' \ + '--syslog[use syslog for logging]' \ + '--syslog-facility[facility for syslog, eg KERN,USER,...]:string [DAEMON]' \ + '--timeout[specify IO idle timeout]:duration [5m0s]' \ + '--tpslimit[limit HTTP transactions per second to this]:float' \ + '--tpslimit-burst[max burst of transactions for --tpslimit]:int [1]' \ + '--track-renames[when synchronizing, track file renames and do a server side move if possible]' \ + '--transfers[number of file transfers to run in parallel]:int [4]' \ + {-u,--update}'[skip files that are newer on the destination]' \ + '--use-server-modtime[use server modified time instead of object metadata]' \ + '--user-agent[set the user-agent to the specified string]:user-agent [rclone/version]' \ + \*{-v,--verbose}'[print lots more stuff]:count' \ + '--acd-auth-url[auth server URL]:string' \ + '--acd-client-id[Amazon Application Client ID]:string' \ + '--acd-client-secret[Amazon Application Client Secret]:string' \ + '--acd-templink-threshold[files >= this size will be downloaded via their tempLink]:size [9G]' \ + '--acd-token-url[token server url]:string' \ + '--acd-upload-wait-per-gb[additional time per GB to wait after a failed complete upload to see if it appears]:Duration [3m0s]' \ + '--alias-remote[remote or path to alias]:string' \ + '--azureblob-access-tier[access tier of blob: hot, cool or archive]:string' \ + '--azureblob-account[specify storage account name]:string' \ + '--azureblob-chunk-size[upload chunk size (<= 100MB)]:size [4M]' \ + '--azureblob-endpoint[endpoint for the service]:string' \ + '--azureblob-key[storage account key (leave blank to use connection string or SAS URL)]:string' \ + '--azureblob-list-chunk[size of blob list]:int [5000]' \ + '--azureblob-sas-url[SAS URL for container level access only]:string' \ + '--azureblob-upload-cutoff[cutoff for switching to chunked upload (<= 256MB)]:size [256M]' \ + '--b2-account[account ID or application key ID]:string' \ + '--b2-chunk-size[specify upload chunk size]:size [96M]' \ + '--b2-endpoint[endpoint for the service]:string' \ + '--b2-hard-delete[permanently delete files on remote removal, otherwise hide files]' \ + '--b2-key[application key]:string' \ + '--b2-test-mode[a flag string for X-Bz-Test-Mode header for debugging]:string' \ + '--b2-upload-cutoff[cutoff for switching to chunked upload]:size [200M]' \ + '--b2-versions[include old versions in directory listings]' \ + '--box-client-id[specify Box app client Id]:client ID' \ + '--box-client-secret[specify Box app client secret]:secret' \ + '--box-commit-retries[max number of times to try committing a multipart file]:int [100]' \ + '--box-upload-cutoff[cutoff for switching to multipart upload (>= 50MB)]:size [50M]' \ + '--cache-chunk-clean-interval[how often should the cache perform cleanups of the chunk storage]:Duration [1m0s]' \ + '--cache-chunk-no-memory[disable the in-memory cache for storing chunks during streaming]' \ + '--cache-chunk-path[directory to cache chunk files]:directory [~/.cache/rclone/cache-backend]:_path_files -/' \ + '--cache-chunk-size[the size of a chunk (partial file data)]:size [5M]' \ + '--cache-chunk-total-size[the total size that the chunks can take up on the local disk]:size [10G]' \ + '--cache-db-path[directory to store file structure metadata DB]:directory [~/.cache/rclone/cache-backend]:_path_files -/' \ + '--cache-db-purge[clear all the cached data for this remote on start]' \ + '--cache-db-wait-time[how long to wait for the DB to be available - 0 is unlimited]:Duration [1s]' \ + '--cache-info-age[how long to cache file structure information (directory listings, file size, times etc)]:duration [6h0m0s]' \ + '--cache-plex-insecure[skip all certificate verifications when connecting to the Plex server]:string' \ + '--cache-plex-password[the password of the Plex user]:string' \ + '--cache-plex-url[the URL of the Plex server]:string' \ + '--cache-plex-username[the username of the Plex user]:string' \ + '--cache-read-retries[how many times to retry a read from a cache storage]:int [10]' \ + '--cache-remote[remote to cache]:string' \ + '--cache-rps[limits the number of requests per second to the source FS (-1 to disable)]:int [-1]' \ + '--cache-tmp-upload-path[directory to keep temporary files until they are uploaded]:directory:_path_files -/' \ + '--cache-tmp-wait-time[how long should files be stored in local cache before being uploaded]:Duration [15s]' \ + '--cache-workers[how many workers should run in parallel to download chunks]:int [4]' \ + '--cache-writes[cache file data on writes through the FS]' \ + {-L,--copy-links}'[follow symlinks and copy the pointed to item]' \ + '--crypt-directory-name-encryption[option to either encrypt directory names or leave them intact. (default true)]' \ + '--crypt-filename-encryption[specify how to encrypt the filenames]:string [standard]' \ + '--crypt-password[specify password or pass phrase for encryption]:string' \ + '--crypt-password2[specify password or pass phrase for salt]:string' \ + '--crypt-remote[remote to encrypt/decrypt]:string' \ + '--crypt-show-mapping[for all files listed show how the names encrypt]' \ + '--drive-acknowledge-abuse[set to allow files which return cannotDownloadAbusiveFile to be downloaded]' \ + '--drive-allow-import-name-change[allow the filetype to change when uploading Google docs (e.g. file.doc to file.docx)]' \ + '--drive-alternate-export[use alternate export URLs for google documents export.,]' \ + '--drive-auth-owner-only[only consider files owned by the authenticated user]' \ + '--drive-chunk-size[upload chunk size]:size [8M]' \ + '--drive-client-id[Google application client ID]:client ID' \ + '--drive-client-secret[Google application client secret]:secret' \ + '--drive-export-formats[list of preferred formats for downloading Google docs]:comma-separated format list [docx,xlsx,pptx,svg]' \ + '!--drive-formats:string' \ + '--drive-impersonate[impersonate specified user when using a service account]:user' \ + '--drive-import-formats[specify preferred formats for uploading Google docs]:formats' \ + '--drive-keep-revision-forever[keep new head revision of each file forever]' \ + '--drive-list-chunk[size of listing chunk 100-1000. 0 to disable]:int [1000]' \ + '--drive-root-folder-id[specify ID of the root folder]:string' \ + '--drive-scope[scope that rclone should use when requesting access from drive]:scope' \ + '--drive-server-side-across-configs[allow server side operations (eg copy) to work across different drive configs]' \ + '--drive-service-account-credentials[specify service account credentials JSON blob]:string' \ + '--drive-service-account-file[specify service account credentials JSON file path]:file:_files' \ + '--drive-shared-with-me[only show files that are shared with me]' \ + '--drive-size-as-quota[show storage quota usage for file size]' \ + '--drive-skip-gdocs[skip google documents in all listings]' \ + '--drive-team-drive[specify ID of the team drive]:ID' \ + '--drive-trashed-only[only show files that are in the trash]' \ + '--drive-upload-cutoff[cutoff for switching to chunked upload]:size [8M]' \ + '--drive-use-created-date[use file created date instead of modified date.,]' \ + '--drive-use-trash[send files to the trash instead of deleting permanently. (default true)]' \ + "--drive-v2-download-min-size[if object's are larger, use drive v2 API to download]:size [off]" \ + '--dropbox-chunk-size[specify upload chunk size]:size [48M]' \ + '--dropbox-client-id[specify Dropbox app client ID]:client ID' \ + '--dropbox-client-secret[specify Dropbox app client secret]:secret' \ + '--dropbox-impersonate[impersonate specified user]:user' \ + '--ftp-host[specify FTP host to connect to]:host:_hosts' \ + "--ftp-no-check-certificate[don't verify the TLS certificate of the server]" \ + '--ftp-pass[specify FTP password]:password' \ + '--ftp-port[specify FTP port]:port [21]:_ports' \ + '--ftp-tls[use FTP over TLS (implicit)]' \ + '--ftp-user[specify FTP username]::username' \ + '--gcs-bucket-acl[access control list for new buckets]:string' \ + '--gcs-client-id[Google application client id]:client id' \ + '--gcs-client-secret[Google application client secret]:secret' \ + '--gcs-location[specify location for the newly created buckets]:string' \ + '--gcs-object-acl[specify access control list for new objects]:string' \ + '--gcs-project-number[project number]:string' \ + '--gcs-service-account-file[service account credentials JSON file path]:file:_files' \ + '--gcs-storage-class[specify storage class to use when storing objects in Google cloud storage]:string' \ + '--http-url[URL of http host to connect to]:string' \ + '--hubic-chunk-size[above this size files will be chunked into a _segments container]:size [5G]' \ + '--hubic-client-id[Hubic client ID]:client ID' \ + '--hubic-client-secret[Hubic client secret]:secret' \ + '--jottacloud-hard-delete[delete files permanently rather than putting them into the trash]' \ + '--jottacloud-md5-memory-limit[files bigger than this will be cached on disk to calculate the MD5 if required]:size [10M]' \ + '--jottacloud-pass[password]:string' \ + '--jottacloud-unlink[remove existing public link to file/folder with link command rather than creating]' \ + '--jottacloud-user[user name]:string' \ + "--local-no-check-updated[don't check to see if the files change during upload]" \ + "--local-no-unicode-normalization[don't apply unicode normalization to paths and filenames (Deprecated)]" \ + '--local-nounc[disable UNC (long path names) conversion on windows]:string' \ + '(-x --one-file-system)'{-x,--one-file-system}"[don't cross filesystem boundaries (unix/macOS only)]" \ + '--onedrive-chunk-size[chunk size to upload files with - must be multiple of 320k]:size [10M]' \ + '--onedrive-client-id[specify Microsoft app client ID]:client ID' \ + '--onedrive-client-secret[specify Microsoft app client secret]:secret' \ + '--onedrive-drive-id[specify the ID of the drive to use]:string' \ + '--onedrive-drive-type[the type of the drive]:string:(personal business documentLibrary)' \ + '--onedrive-expose-onenote-files[set to make OneNote files show up in directory listings]' \ + '--opendrive-password[specify password]:string' \ + '--opendrive-username[specify username]:string' \ + '--pcloud-client-id[specify Pcloud app client ID]:client ID' \ + '--pcloud-client-secret[specify Pcloud app client secret]:secret' \ + '--s3-access-key-id[specify AWS access key ID]:string' \ + '--s3-acl[canned ACL used when creating buckets and storing or copying objects]:string' \ + '--s3-chunk-size[chunk size to use for uploading]:size [5M]' \ + "--s3-disable-checksum[don't store MD5 checksum with object metadata]" \ + '--s3-endpoint[endpoint for S3 API]:string' \ + '--s3-env-auth[get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars)]' \ + '--s3-force-path-style[if true use path style access if false use virtual hosted style. (default true)]' \ + '--s3-location-constraint[location constraint - must be set to match the region]:string' \ + '--s3-provider[choose your S3 provider]:string' \ + '--s3-region[region to connect to]:string' \ + '--s3-secret-access-key[AWS Secret access key (password)]:string' \ + '--s3-server-side-encryption[the server-side encryption algorithm used when storing this object in S3]:string' \ + '--s3-session-token[an AWS session token]:string' \ + '--s3-sse-kms-key-id[if using KMS ID you must provide the ARN of key]:string' \ + '--s3-storage-class[the storage class to use when storing new objects in S3]:string' \ + '--s3-upload-concurrency[concurrency for multipart uploads]:int [2]' \ + '--s3-v2-auth[if true use v2 authentication]' \ + '--s3-use-accelerate-endpoint[use the AWS S3 accelerated endpoint]' \ + '--sftp-ask-password[allow asking for SFTP password when needed]' \ + '--sftp-disable-hashcheck[disable the execution of SSH commands to determine if remote file hashing is available]' \ + '--sftp-host[SSH host to connect to]:string' \ + '--sftp-key-file[path to unencrypted PEM-encoded private key file, leave blank to use ssh-agent]:string' \ + '--sftp-pass[SSH password, leave blank to use ssh-agent]:string' \ + '--sftp-path-override[override path used by SSH connection]:string' \ + '--sftp-port[SSH port, leave blank to use default]:string [22]' \ + '--sftp-set-modtime[set the modified time on the remote if set. (default true)]' \ + '--sftp-use-insecure-cipher[enable the use of the aes128-cbc cipher]' \ + '--sftp-user[SSH username, leave blank for current username]:string' \ + "--skip-links[don't warn about skipped symlinks]" \ + '--swift-auth[authentication URL for server (OS_AUTH_URL)]:string' \ + '--swift-auth-token[aUTH token from alternate authentication - optional (OS_AUTH_TOKEN)]:string' \ + '--swift-auth-version[AuthVersion - optional - set to (1,2,3) if your auth URL has no version (ST_AUTH_VERSION)]:int' \ + '--swift-chunk-size[above this size files will be chunked into a _segments container]:size [5G]' \ + '--swift-domain[user domain - optional (v3 auth) (OS_USER_DOMAIN_NAME)]:string' \ + '--swift-endpoint-type[endpoint type to choose from the service catalogue (OS_ENDPOINT_TYPE)]:string [public]' \ + '--swift-env-auth[get swift credentials from environment variables in standard OpenStack form]' \ + '--swift-key[API key or password (OS_PASSWORD)]:string' \ + '--swift-region[region name - optional (OS_REGION_NAME)]:string' \ + '--swift-storage-policy[the storage policy to use when creating a new container]:string' \ + '--swift-storage-url[storage URL - optional (OS_STORAGE_URL)]:string' \ + '--swift-tenant[tenant name - optional for v1 auth, this or tenant_id required otherwise (OS_TENANT_NAME or OS_PROJECT_NAME)]:string' \ + '--swift-tenant-domain[tenant domain - optional (v3 auth) (OS_PROJECT_DOMAIN_NAME)]:string' \ + '--swift-tenant-id[tenant ID - optional for v1 auth, this or tenant required otherwise (OS_TENANT_ID)]:string' \ + '--swift-user[user name to log in (OS_USERNAME)]:string' \ + '--swift-user-id[user ID to log in - optional - most swift systems use user and leave this blank (v3 auth) (OS_USER_ID)]:string' \ + '--union-remotes[list of space separated remotes]:string' \ + '--webdav-bearer-token[bearer token instead of user/pass (eg a Macaroon)]:string' \ + '--webdav-pass[password]:string' \ + '--webdav-url[URL of http host to connect to]:string' \ + '--webdav-user[user name]:string' \ + '--webdav-vendor[name of the Webdav site/service/software you are using]:string' \ + '--yandex-client-id[Yandex client ID]:client ID' \ + '--yandex-client-secret[Yandex client secret]:secret' \ + '--yandex-unlink[remove existing public link to file/folder with link command rather than creating]' \ + "*: :->files_or_remotes" \ + && ret=0 + +if [[ $state == 'files_or_remotes' ]]; then + remotes=( $(_call_program rclone-remotes rclone listremotes) ) + _alternative \ + "remote:rclone-remotes:compadd -a remotes" \ + "file:files:_files" && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf index ce78baf27..42094742e 100644 --- a/Completion/Unix/Command/_readelf +++ b/Completion/Unix/Command/_readelf @@ -11,8 +11,6 @@ args=( '(-h --file-header)'{-h,--file-header}'[show file header]' '(-l --program-headers --segments)'{-l,--program-headers,--segments}'[show program headers]' '(-S --section-headers --sections)'{-S,--section-headers,--sections}'[show sections header]' - '(-s --syms --symbols)'{-s,--syms,--symbols}'[show symbol table]' - '(-n --notes)'{-n,--notes}'[show core notes (if present)]' '(-r --relocs)'{-r,--relocs}'[show relocations (if present)]' '(-d --dynamic)'{-d,--dynamic}'[show dynamic section (if present)]' '(-V --version-info)'{-V,--version-info}'[show version sections (if present)]' @@ -35,16 +33,25 @@ case $variant in '(-t --section-details)'{-t,--section-details}'[show section details]' '(-e --headers)'{-e,--headers}'[show file, program and sections headers]' '(-s --syms --symbols)'{-s,--syms,--symbols}'[show symbol table]' + '(-n --notes)'{-n,--notes}'[show core notes (if present)]' '(-u --unwind)'{-u,--unwind}'[show unwind info (if present)]' '(-D --use-dynamic)'{-D,--use-dynamic}'[use dynamic section info when showing symbols]' ) ;| - binutils) + elfutils|binutils) args+=( '--dyn-syms[show dynamic symbol table]' + ) + ;| + binutils) + args+=( \*{-R,--relocated-dump=}"[dump contents of specified section as relocated bytes]:section:($sections)" "--dwarf-depth=[don't show DIEs at greater than specified depth]:depth" '--dwarf-start=[show DIEs starting at specified depth or deeper]:depth' + '--ctf=[display compact C type format info from section]:section' + '--ctf-parent=[use specified section as the CTF parent]:section' + '--ctf-symbols=[use specified section as the CTF external symbol table]:section' + '--ctf-strings=[use specified section as the CTF external string table]:section' ) ;; elfutils) @@ -56,6 +63,8 @@ case $variant in '(-z --decompress)'{-z,--decompress}'[show compression information; decompress before dumping data]' '(--symbols)-s[show symbol table]' '(-s)--symbols=-[show symbol table]::section:(.dynsym .symtab)' + '(--notes)-n[show core notes (if present)]' + '(-n)--notes=-[show core notes (if present)]::section' ) ;; esac diff --git a/Completion/Unix/Command/_rm b/Completion/Unix/Command/_rm index aa24a3fd6..ea9190de2 100644 --- a/Completion/Unix/Command/_rm +++ b/Completion/Unix/Command/_rm @@ -1,58 +1,70 @@ #compdef rm grm zf_rm -declare -a opts args +local variant +declare -a args opts=( -A '-*' ) args=( '(-f --force)'{-f,--force}'[ignore nonexistent files, never prompt]' '(-I --interactive)-i[prompt before every removal]' '(-r -R --recursive)'{-r,-R,--recursive}'[remove directories and their contents recursively]' '*:: :->file' ) -if _pick_variant gnu=gnu unix --help; then - opts+=(-S) - args+=( - '(-i --interactive)-I[prompt when removing many files]' - '(-i -I)--interactive=-[prompt under given condition (defaulting to always)]::when:((once\:"prompt when removing many files" - always\:"prompt before every removal"))' - '--one-file-system[stay within filesystems of files given as arguments]' - '( --preserve-root)--no-preserve-root[do not treat / specially]' - '(--no-preserve-root )--preserve-root[do not remove / (default)]' - '(-d --dir)'{-d,--dir}'[remove directories as well]' - '(-v --verbose)'{-v,--verbose}'[explain what is being done]' - '(- *)--help[display help message and exit]' - '(- *)--version[output version information and exit]' - ) -else - args=(${args:#*)--*\[*}) - case $OSTYPE in - darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) - args+=( - '-d[remove directories as well]' - '-P[overwrite files before deleting them]' - '-v[explain what is being done]' - ) +_pick_variant -r variant -b zsh gnu=gnu $OSTYPE --help +case $variant; in + gnu) + opts=() + args+=( + '(-i --interactive)-I[prompt when removing many files]' + '(-i -I)--interactive=-[prompt under given condition (defaulting to always)]::when:((once\:"prompt when removing many files" + always\:"prompt before every removal"))' + '--one-file-system[stay within filesystems of files given as arguments]' + '( --preserve-root)--no-preserve-root[do not treat / specially]' + '(--no-preserve-root )--preserve-root[do not remove / (default)]' + '(-d --dir)'{-d,--dir}'[remove directories as well]' + '(-v --verbose)'{-v,--verbose}'[explain what is being done]' + '(- *)--help[display help message and exit]' + '(- *)--version[output version information and exit]' + ) + ;; + *) + args=(${args:#*)--*\[*}) + ;| + darwin*|dragonfly*|freebsd*|netbsd*|openbsd*|zsh) + args+=( + '-d[remove directories as well]' + ) ;| - darwin*|dragonfly*|freebsd*|netbsd*) - args+=( - '-W[attempt to undelete named files]' - ) + zsh) + args+=( + '-s[enable paranoid behavior]' + ) + ;; + darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + '-P[overwrite files before deleting them]' + '-v[explain what is being done]' + ) ;| - dragonfly*|freebsd*|netbsd*) - args+=( - "-x[don't cross file systems when removing a hierarchy]" - ) + darwin*|dragonfly*|freebsd*|netbsd*) + args+=( + '-W[attempt to undelete named files]' + ) ;| - dragonfly*|freebsd*) - args+=( - '(-i)-I[prompt when removing many files]' - ) + dragonfly*|freebsd*|netbsd*) + args+=( + "-x[don't cross file systems when removing a hierarchy]" + ) + ;| + dragonfly*|freebsd*) + args+=( + '(-i)-I[prompt when removing many files]' + ) ;; - esac -fi +esac local curcontext=$curcontext state line ret=1 declare -A opt_args -_arguments -C -s $opts \ +_arguments -C -s -S $opts \ $args && ret=0 case $state in diff --git a/Completion/Unix/Command/_rmdir b/Completion/Unix/Command/_rmdir index 0f5e16912..501ffb1cc 100644 --- a/Completion/Unix/Command/_rmdir +++ b/Completion/Unix/Command/_rmdir @@ -1,23 +1,32 @@ -#compdef rmdir grmdir +#compdef rmdir grmdir zf_rmdir -local -a args +local variant +local -a args aopts=( -A '-*' ) args=( '(-p --parents)'{-p,--parents}'[remove each component of the specified paths]' ) -if _pick_variant gnu=GNU unix --version; then - args+=( - '--ignore-fail-on-non-empty[ignore failure if directory is non-empty]' - '(-v --verbose)'{-v,--verbose}'[be verbose]' - ) -else - args=(${args:#*\)--*}) - if [[ $OSTYPE == (dragonfly|freebsd)* ]]; then +_pick_variant -r variant -b zsh gnu=GNU $OSTYPE --version +case $variant; in + gnu) + aopts=() + args+=( + '--ignore-fail-on-non-empty[ignore failure if directory is non-empty]' + '(-v --verbose)'{-v,--verbose}'[be verbose]' + ) + ;; + zsh) + args=() + ;; + *) + args=(${args:#*\)--*}) + ;| + dragonfly*|freebsd*) args+=('-v[be verbose]') - fi -fi + ;; +esac -_arguments -s -S -A '-*' \ +_arguments -s -S $aopts \ $args \ - '*:directories:_directories' + '*: :_directories' diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsync index c1404c908..56efd7b13 100644 --- a/Completion/Unix/Command/_rsync +++ b/Completion/Unix/Command/_rsync @@ -51,10 +51,11 @@ elif compset -P 1 '*::' || compset -P 1 'rsync://*/'; then fi remfiles=(${${(f)"$(_call_program files rsync $pat 2>/dev/null)"}:#([ ]|MOTD:)*}) + remfiles=( ${(M)remfiles:#*$'\t'*} ) remmodules=(${remfiles/[ ]##/:}) - _describe "remote modules" remmodules -S/ + _describe -V "remote modules" remmodules -S/ elif compset -P 'rsync://'; then _rsync_user_or_host / "$@" 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/_ruby b/Completion/Unix/Command/_ruby index d69c378fc..3ed25a3f0 100644 --- a/Completion/Unix/Command/_ruby +++ b/Completion/Unix/Command/_ruby @@ -36,15 +36,24 @@ opts=( '-s[enable some switch parsing for switches after script name]' '-S[look for the script using PATH environment variable]' '-T-[turn on tainting checks]::taint level [1]:((0\:strings\ from\ streams/environment/ARGV\ are\ tainted 1\:no\ dangerous\ operation\ by\ tainted\ value 2\:process/file\ operations\ prohibited 3\:all\ generated\ objects\ are\ tainted 4\:no\ global\ \(non-tainted\)\ variable\ modification/no\ direct\ output))' - '(-v --verbose)'{-v,--verbose}'[print version number, then turn on verbose mode]' + '(--verbose)-v[print version number, then turn on verbose mode]' + '(-v)--verbose[turn on verbose mode and disable script from stdin]' '-x-[strip off text before #!ruby line and perhaps cd to directory]:directory:_files -/' '(1 * -)--copyright[print the copyright]' - --{en,dis}'able=[enable or disable features]:feature:(gems did_you_mean rubyopt frozen_string_literal all)' + --{en,dis}'able=[enable or disable features]:feature:(gems did_you_mean rubyopt frozen_string_literal jit all)' \!--{en,dis}able-{gems,rubyopt,all} '--dump=[dump debug information]:information:_sequence compadd - insns yydebug parsetree parsetree_with_comment' --{external,internal}'-encoding=:charset:->charsets' '!'{-y,--yydebug} '!--dump=:target:(version copyright usage yydebug syntax parsetree parsetree_with_comment insns)' + '--jit[enable jit with default options]' + '--jit-warnings[enable printing JIT warnings]' + '--jit-debug[enable JIT debugging (very slow)]' + '--jit-wait[wait until JIT compilation is finished every time (for testing)]' + '--jit-save-temps[save JIT temporary files]' + '--jit-verbose=-[print JIT logs of level num or less to stderr]:maximum log level [0]' + '--jit-max-cache=-[specify max number of methods to be JIT-ed in a cache]:number [1000]' + '--jit-min-calls=-[specify number of calls to trigger JIT]:calls [5]' ) irb=( @@ -70,7 +79,6 @@ irb=( erb=( "-P[don't evaluate lines which start with %]" - '-S[specify safe level for running script]:level:(1 2 3 4)' '-T[specify trim mode]:mode [0]:((0\:EOL\ remains 1\:EOL\ removed\ if\ line\ ends\ with\ %\> 2\:EOL\ removed\ if\ line\ starts\ with\ \<%\ and\ ends\ with\ %\> -\:EOL\ is\ removed\ if\ line\ ends\ with\ -%\>,\ leading\ whitespace\ removed\ after\ \<%-))' '(-d --debug)'{-d,--debug}'[set debugging flags (set $DEBUG to true)]' '-n[used with -x, prepends line number to output]' diff --git a/Completion/Unix/Command/_sablotron b/Completion/Unix/Command/_sablotron deleted file mode 100644 index 53e0bec92..000000000 --- a/Completion/Unix/Command/_sablotron +++ /dev/null @@ -1,52 +0,0 @@ -#compdef sabcmd - -local curcontext="$curcontext" state mode line expl ret=1 -typeset -A opt_args -local mopts='(-c -x -s -? -v --chain-xsl --batch-xml --batch-xsl --help --version)' - -_arguments -C \ - '(-b --base)'{-b,--base=}'[specify base URI]:URI' \ - '(-)--debug-options[show help on debug options]' \ - '(- *)'{-\?,--help}'[show help information]' \ - '(-L --log-file)'{-L,--log-file=}'[specify log file, turn on logging]:log file:_files' \ - '(-m --measure)'{-m,--measure}'[measure the processing time]' \ - '(- *)'{-v,--version}'[display version information]' \ - '--debugger[run the xslt debugger]' \ - $mopts{-c,--chain-xsl}'[single input file, multiple chained stylesheets]' \ - $mopts{-x,--batch-xml}'[single input file, multiple stylesheets]' \ - $mopts{-s,--batch-xsl}'[multiple input files, single stylesheet]' \ - '*: :->arguments' && ret=0 - -if [[ -n "$state" ]]; then - mode="${opt_args[(i)-c|--chain-xsl]:+chain}${opt_args[(i)-x|--batch-xml]:+batch-x}${opt_args[(i)-s|--batch-xsl]:+batch-s}" - [[ $mode = (chain|batch-[xs]) ]] || mode=default - _tags files assignments - while _tags; do - if _requested files; then - case $mode:${#words[1,CURRENT-1]:#(-*|*=*)}; in - default:1|chain:<3->|batch-x:2|batch-s:1) - _description files expl stylesheet - _files "$expl[@]" -g "*.xsl(-.)" && ret=0 - ;; - default:2|chain:1|batch-x:1|batch-s:2) - _description files expl 'input file' - _files "$expl[@]" && ret=0 - ;; - default:3|chain:2|batch-x:<3->|batch-s:<3->) - _description files expl 'output file' - _files "$expl[@]" && ret=0 - ;; - esac - fi - if _requested assignments; then - if [[ -prefix *= ]]; then - _message -e value value - else - _message -e parameter 'parameter name' && ret=0 - fi - fi - (( ret )) || break - done -fi - -return ret diff --git a/Completion/Unix/Command/_script b/Completion/Unix/Command/_script index 436c9661b..ac3bf3973 100644 --- a/Completion/Unix/Command/_script +++ b/Completion/Unix/Command/_script @@ -34,10 +34,6 @@ case $OSTYPE in darwin*|dragonfly*|netbsd*|freebsd*) args=( '-q[be quiet: suppress display of starting and ending lines]' - ) - ;| - darwin*|netbsd*|freebsd*) - args+=( '(-a -r -k)-d[suppress sleeps when playing back a session]' '(-a -r -k -t)-p[play back a recorded session]' '(-d -p)-r[record a session with input, output and timing data]' @@ -58,13 +54,13 @@ case $OSTYPE in ;| darwin*|dragonfly*|freebsd*) args+=( + '-F[send output to specified named pipe]:fifo:_files -g "*(p)"' '-t+[specify interval of data flushing]:interval (seconds)' '-k[log keys sent to the program as well as output]' '*:::arguments: _normal' ) ;| darwin*|freebsd*) - args+=( '-F[send output to specified named pipe]:fifo:_files -g "*(p)"' ) ;| *) args+=( diff --git a/Completion/Unix/Command/_seafile b/Completion/Unix/Command/_seafile new file mode 100644 index 000000000..bd36c0ac8 --- /dev/null +++ b/Completion/Unix/Command/_seafile @@ -0,0 +1,33 @@ +#compdef seaf-cli + +local -a commands + +commands=( + "init\:'initialize config directory'" + "start\:'start seafile daemon'" + "stop\:'stop seafile daemon'" + "list\:'list local libraries'" + "list-remote\:'list remote libraries'" + "status\:'show syncing status'" + "download\:'download a library from seafile server'" + "download-by-name\:'download a library defined by name from seafile server'" + "sync\:'sync a library with an existing foler'" + "desync\:'desync a library with seafile server'" + "create\:'create a library'" + "config\:'configure seafile client'" +) + +_arguments \ + ":command:(($commands))" \ + {-h,--help}'[show help]' \ + {-c,--confdir}'[specify config directory]:config directory:_files -/' \ + {-d,--dir,--folder}'[directory]:directory:_directories' \ + {-s,--server}'[URL for seafile server]':server \ + {-u,--username}'[username]':username \ + {-p,--password}'[password]':password \ + {-a,--tfa}'[two-factor authentication]':tfa \ + {-l,--library}'[library id]':library \ + {-e,--libpasswd}'[library password]':libpasswd \ + {-k,--key}'[configuration key]':key \ + {-v,--value}'[configuration value]':value \ + "*: :_files" diff --git a/Completion/Unix/Command/_sed b/Completion/Unix/Command/_sed index f03278364..73227901e 100644 --- a/Completion/Unix/Command/_sed +++ b/Completion/Unix/Command/_sed @@ -38,7 +38,7 @@ cmds_end=( 'n:read the next line of input into pattern space' 'N:append the next line of input to the pattern space' 'p:print the current pattern space' - 'P:print upto the first newline of the current pattern space' + 'P:print up to the first newline of the current pattern space' 'x:exchange hold and pattern spaces' '}:end group' ) @@ -66,6 +66,7 @@ elif _pick_variant -r variant gnu=GNU unix --version; then aopts=( ) (( $#words > 2 )) && ign='!' args+=( + '--debug[annotate program execution]' '--follow-symlinks[follow symlinks when processing in place]' '(-i --in-place -s --separate)'{-i-,--in-place=-}$inplace '(-c --copy)'{-c,--copy}'[copy instead of rename when shuffling files in in-place mode]' diff --git a/Completion/Unix/Command/_smartmontools b/Completion/Unix/Command/_smartmontools index c60322ee0..fe6496664 100644 --- a/Completion/Unix/Command/_smartmontools +++ b/Completion/Unix/Command/_smartmontools @@ -4,7 +4,7 @@ local context state state_descr line _arguments -s -S \ '(H -i --info)'{-i,--info}'[show identity information for device]' \ - '(H)--identify=-[show words and bits from indentification data]: : _values -S "" "words and bits" + '(H)--identify=-[show words and bits from identification data]: : _values -S "" "words and bits" "(n v)b[print all bits]" "w[print all words]" "(b v)n[suppress printing bits]" diff --git a/Completion/Unix/Command/_sqlite b/Completion/Unix/Command/_sqlite index 4604fb40c..0f03c61c1 100644 --- a/Completion/Unix/Command/_sqlite +++ b/Completion/Unix/Command/_sqlite @@ -46,9 +46,12 @@ options+=( $^dashes'-append[append the database to the end of the file]' $^dashes'-bail[stop after hitting an error]' $^dashes'-cmd[run specified command before reading stdin]:sqlite meta-command' + $^dashes'-deserialize[open the database using sqlite3_deserialize()]' '(-*batch -*interactive)'$^dashes'-batch[force batch I/O]' '(-*batch -*interactive)'$^dashes'-interactive[force interactive I/O]' $^dashes'-lookaside[specify size and number of entries for lookaside memory]:size (bytes): :entries' + $^dashes'-maxsize[specify maximum size for a --deserialize database]:size' + $^dashes'-memtrace[trace all memory allocations and deallocations]' $^dashes'-mmap[set default mmap size]:size' $^dashes'-newline[set output row separator]:separator [\n]' $^dashes'-pagecache[specify size and number of slots for page cache memory]:size (bytes): :slots' @@ -69,6 +72,7 @@ if [[ -n $words[(r)-A*] ]]; then + '(commands)' \ '(-c --create)'{-c,--create}'[create a new archive]' '(-u --update)'{-u,--update}'[update or add files to an existing archive]' + '(-i --insert)'{-i,--insert}'[like -u but always add even if mtime unchanged]' '(-t --list)'{-t,--list}'[list contents of archive]' '(-x --extract)'{-x,--extract}'[extract files from archive]' ) diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index d1bd8f04b..0775590e6 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -3,13 +3,13 @@ # TODO: sshd, ssh-keysign _ssh () { - local curcontext="$curcontext" state line expl suf ret=1 - local args common common_transfer algopt tmp p1 file cmn cmds sdesc + local curcontext="$curcontext" state line expl suf arg ret=1 + local args sigargs common common_transfer algopt tmp p1 file cmn cmds sdesc tdesc typeset -A opt_args common=( - '(-6)-4[forces ssh to use IPv4 addresses only]' - '(-4)-6[forces ssh to use IPv6 addresses only]' + '(-6)-4[force ssh to use IPv4 addresses only]' + '(-4)-6[force ssh to use IPv6 addresses only]' '-C[compress data]' '-c+[select encryption cipher]:encryption cipher:->ciphers' '-F+[specify alternate config file]:config file:_files' @@ -17,6 +17,7 @@ _ssh () { '*-o+[specify extra options]:option string:->option' ) common_transfer=( + '-J+[connect via a jump host]: :->userhost' '-l+[limit used bandwidth]:bandwidth (Kbit/s)' '-P+[specify port on remote host]:port number on remote host' '-p[preserve modification times, access times and modes]' @@ -29,6 +30,7 @@ _ssh () { case "$service" in ssh) + (( $+words[(r)-[^-]#t*] )) && tdesc=' even if there is no controlling tty' _arguments -C -s \ '(-a)-A[enable forwarding of the authentication agent connection]' \ '(-A)-a[disable forwarding of authentication agent connection]' \ @@ -59,7 +61,7 @@ _ssh () { '-Q+[query parameters]:query option:((cipher\:"supported symmetric ciphers" cipher-auth\:"supported symmetric ciphers that support authenticated encryption" mac\:"supported message integrity codes" kex\:"key exchange algorithms" key\:"key types" key-cert\:"certificate key types" key-plain\:"non-certificate key types" protocol-version\:"supported SSH protocol versions" sig\:"supported signature algorithms" help\:"show supported queries"))' \ '-s[invoke subsystem]' \ '(-t)-T[disable pseudo-tty allocation]' \ - '(-T)-t[force pseudo-tty allocation]' \ + "(-T)*-t[force pseudo-tty allocation${tdesc}]" \ '-V[show version number]' \ '(-q)*-v[verbose mode (multiple increase verbosity, up to 3)]' \ '-W+[forward standard input and output to host]:stdinout forward:->hostport' \ @@ -75,6 +77,7 @@ _ssh () { _arguments -C -s \ '-3[copy through local host, not directly between the remote hosts]' \ '-B[batch mode (don'\''t ask for passphrases)]' \ + '-T[disable strict filename checking]' \ '*:file:->file' "$common[@]" "$common_transfer[@]" && ret=0 ;; ssh-add) @@ -95,6 +98,8 @@ _ssh () { '-M+[specify maximum number of signatures]:number' \ '-s+[add keys provided by the PKCS#11 shared library]:library:_files -g "*.(so|dylib)(|.<->)(-.)"' \ '-t+[set maximum lifetime for identity]:maximum lifetime (in seconds or time format):' \ + "-T[test usability of identity files' private keys]:*:public key file:_files -g '*.pub(-.)'" \ + '-v[verbose mode]' \ '-q[be quiet after a successful operation]' \ '-X[unlock the agent]' \ '-x[lock the agent with a password]' \ @@ -103,7 +108,7 @@ _ssh () { ;; ssh-agent) _arguments -s \ - '(-k)-a+[UNIX-domain socket to bind agent to]:UNIX-domain socket:_files' \ + '(-k)-a+[specify UNIX-domain socket to bind agent to]:UNIX-domain socket:_files' \ '(-k -s)-c[force csh-style shell]' \ '(-k)-d[debug mode]' \ '(-k)-D[foreground mode]' \ @@ -112,6 +117,7 @@ _ssh () { '(-k)-P[specify PKCS#11 shared library whitelist]:PKCS#11 library whitelist pattern' \ '(-k -c)-s[force sh-style shell]' \ '-t[set default maximum lifetime for identities]:maximum lifetime (in seconds or time format):' \ + '-v[verbose mode]' \ '*::command: _normal' return ;; @@ -120,53 +126,71 @@ _ssh () { (( CURRENT == 2 )) && p1='!' args=( '!-z:number' ) sdesc='certify keys with CA key' - (( $+words[(r)-s] )) && args=( '-z[specify serial number]:serial number' ) + (( $+words[(r)-I] )) && args=( '-z[specify serial number]:serial number' ) (( $+words[(r)-[ku]] )) && args=( '-z[specify version number]:version number' ) && sdesc='specify CA public key file' file=key - (( $+words[(r)-[HR]] )) && file=known_hosts + (( $+words[(r)-[FHR]] )) && file=known_hosts (( $+words[(r)-T] )) && file=input - if (( $+words[(r)-[kQ]] )); then + (( $+words[(r)-A] )) && file='prefix for host key' + if (( $+words[(r)-[kIQ]] )); then file=krl args+=( '*:file:_files' ) fi - cmds=( -p -i -e -y -c -l -B -D -H -R -r -G -T -s -L -A -k -Q ) # basic commands - cmn=( -b -P -N -C -m -v ) # options common to many basic commands (except -f which is common to most) - cms=( -E -q -t -g -M -S -a -J -j -K -W -I -h -n -O -V -u ) # options specific to one basic command + if (( arg = $words[(I)-Y*] )); then + [[ $words[arg] = -Y?* ]] || (( arg++ )) + case $words[arg] in + check*|verify) + sigargs+=( "$p1-s+[specify signature file]:signature file:-files" ) + ;| + sign) sigargs+=( '*:file:_files' ) ;; + verify) + args=() + sigargs+=( + '-I+[specify signer identity]:identity' + '-r+[specify revocation file]:revocation file:_files' + ) + ;; + esac + fi + cmds=( -p -i -e -y -c -l -B -D -F -H -R -r -G -T -s -L -A -k -Q -Y ) # basic commands + cmn=( -b -P -N -C -l -m -v ) # options common to many basic commands (except -f which is common to most) + cms=( -E -q -t -g -M -S -a -J -j -K -W -I -h -n -O -V -u -U ) # options specific to one basic command _arguments -s $args \ - "(${${(@)cmds:#-G}} -P -m ${${(@)cms:#-[MS]}})-b+[specify number of bits in key]:bits in key" \ - "$p1(${${(@)cmds:#-[pc]}} -b -C $cms)-P+[provide old passphrase]:old passphrase" \ - "(${${(@)cmds:#-p}} -m -v ${${(@)cms:#-[qt]}})-N+[provide new passphrase]:new passphrase" \ - "(${${(@)cmds:#-c}} -m -v $cms)-C+[provide new comment]:new comment" \ + "(${${(@)cmds:#-G}} -P ${${(@)cms:#-[MS]}})-b+[specify number of bits in key]:bits in key" \ + "$p1(${${(@)cmds:#-[pc]}} -b $cms)-P+[provide old passphrase]:old passphrase" \ + "(${${(@)cmds:#-p}} -v ${${(@)cms:#-[qt]}})-N+[provide new passphrase]:new passphrase" \ + "(${${(@)cmds:#-c}} -v $cms)-C+[provide new comment]:new comment" \ "(-D -G -M -S -I -h -n -O -V -A)-f+[$file file]:$file file:_files" \ - "$p1(${${(@)cmds:#-[ie]}})-m+[specify conversion format]:format:(PEM PKCS7 RFC4716)" \ + "$p1(${${(@)cmds:#-[FE]}} ${${(@)cmn:#-v}} ${${(@)cms:#-E}})-l[show fingerprint of key file]" \ + "$p1(${${(@)cmds:#-[iep]}} $cms)-m+[specify conversion format]:format [RFC4716]:(PEM PKCS8 RFC4716)" \ "(${${(@)cmds:#-[lGT]}} ${${(@)cmn:#-[bv]}} -f)*-v[verbose mode]" \ - '(commands)' \ - "(-b -P -C -v)-p[change passphrase of private key file]" \ - '(-b -P -N -C -v)-i[import key to OpenSSH format]' \ - '(-b -P -N -C -v)-e[export key to SECSH file format]' \ + "(-b -l -C -v)-p[change passphrase of private key file]" \ + '(-b -l -P -N -C -v)-i[import key to OpenSSH format]' \ + '(-b -l -P -N -C -v)-e[export key to SECSH file format]' \ "($cmn)-y[get public key from private key]" \ - '(-b -N -m -v)-c[change comment in private and public key files]' \ + '(-b -l -N -m -v)-c[change comment in private and public key files]' \ "($cmn)-B[show the bubblebabble digest of key]" \ "(-)-D+[download key stored in smartcard reader]:reader" \ + "(${${(@)cmn:#-[lv]}})-F+[search for host in known_hosts file]:host:_ssh_hosts" \ "($cmn)-H[hash names in known_hosts file]" \ "($cmn)-R+[remove host from known_hosts file]:host:_ssh_hosts" \ "($cmn)-L[print the contents of a certificate]" \ - "(-)-A[generate host keys for all key types]" \ + "($cmn -l)-A[generate host keys for all key types]" \ "($cmn)-Q[test whether keys have been revoked in a KRL]" \ - finger \ - "($cmn)-l[show fingerprint of key file]" \ "$p1($cmn)$algopt" \ - create \ - '(-P -m)-q[silence ssh-keygen]' \ - "(-P -m)-t+[specify the type of the key to create]:key type:(rsa dsa ecdsa ed25519)" \ + '(-P -l)-q[silence ssh-keygen]' \ + "(-P -l)-t+[specify the type of the key to create]:key type:(rsa dsa ecdsa ed25519)" \ - dns \ "($cmn)-r[print DNS resource record]:hostname:_hosts" \ "$p1($cmn)-g[use generic DNS format]" \ - primes \ - "(-P -N -C -m -f)-G[generate candidates for DH-GEX moduli]" \ - "$p1(-P -N -C -m -f)-M+[specify amount of memory to use for generating DH-GEX moduli]:memory (MB)" \ - "$p1(-P -N -C -m -f)-S+[specify start point]:start point (hex)" \ + "(-P -N -C -l -m -f)-G+[generate candidates for DH-GEX moduli]:output file:_files" \ + "$p1(-P -N -C -l -m -f)-M+[specify amount of memory to use for generating DH-GEX moduli]:memory (MB)" \ + "$p1(-P -N -C -l -m -f)-S+[specify start point]:start point (hex)" \ - screen \ "(${${(@)cmn:#-v}})-T+[screen candidates for DH-GEX moduli]:output file:_files" \ "${p1}(${${(@)cmn:#-v}})-a+[specify number of rounds]:rounds" \ @@ -176,26 +200,35 @@ _ssh () { "${p1}(${${(@)cmn:#-v}})-W[specify desired generator]:generator" \ - certify \ "($cmn)-s[$sdesc]:CA key:_files" \ - "$p1($cmn -f -u)-I+[specify key identifier to include in certificate]:key id" \ - "$p1($cmn -f -u)-h[generate host certificate instead of a user certificate]" \ - "$p1($cmn -f -u -D)-U[indicate that CA key is held by ssh-agent]" \ - "$p1($cmn -f -u -U)-D+[indicate the CA key is stored in a PKCS#11 token]:PKCS11 shared library:_files -g '*.(so|dylib)(|.<->)(-.)'" \ - "$p1($cmn -f -u)-n+[specify user/host principal names to include in certificate]:principals" \ - "$p1($cmn -f -u)*-O+[specify a certificate option]: : _values 'option' + "$p1($cmn -f -k -u)-I+[specify key identifier to include in certificate]:key id" \ + "$p1($cmn -f -k -u)-h[generate host certificate instead of a user certificate]" \ + "$p1($cmn -f -k -u -D)-U[indicate that CA key is held by ssh-agent]" \ + "$p1($cmn -f -k -u -U)-D+[indicate the CA key is stored in a PKCS#11 token]:PKCS11 shared library:_files -g '*.(so|dylib)(|.<->)(-.)'" \ + "$p1($cmn -f -k -u)-n+[specify user/host principal names to include in certificate]:principals" \ + "$p1($cmn -f -k -u)*-O+[specify a certificate option]: : _values 'option' clear critical\:name extension\:name force-command\:command\:_cmdstring no-agent-forwarding no-port-forwarding no-pty no-user-rc no-x11-forwarding permit-agent-forwarding permit-port-forwarding permit-pty permit-user-rc permit-x11-forwarding source-address\:source\ address" \ "$p1($cmn -f -u)-V+[specify certificate validity interval]:interval" \ - "($cmn -I -h -n -O -V)-k[generate a KRL file]" \ - "$p1($cmn -I -h -n -O -V)-u[update a KRL]" + "($cmn -I -h -n -D -O -U -V)-k[generate a KRL file]" \ + "$p1($cmn -I -h -n -D -O -U -V)-u[update a KRL]" \ + - signature \ + "($cmn)-Y+[signature action]:action:(( + sign\:sign\ a\ file\ using\ SSH\ key + verify\:verify\ a\ signature\ generated\ using\ the\ sign\ option + check-novalidate\:check\ signature\ structure + ))" \ + "$p1-n+[specify namespace]:namespace" \ + $sigargs return ;; ssh-keyscan) _arguments \ - '(-6)-4[forces ssh to use IPv4 addresses only]' \ - '(-4)-6[forces ssh to use IPv6 addresses only]' \ + '(-6)-4[force ssh to use IPv4 addresses only]' \ + '(-4)-6[force ssh to use IPv6 addresses only]' \ '-c[request certificates from target hosts instead of plain keys]' \ + '-D[print keys found as SSHFP DNS records]' \ '*-f+[read hosts from file, one per line]:file:_files' \ '-H[hash all hostnames and addresses in the output]' \ '-p+[specify port on remote host]:port number on remote host' \ @@ -212,7 +245,7 @@ _ssh () { '-D+[connect directly to a local sftp server]:sftp server path' \ '-f[request that files be flushed immediately after transfer]' \ '-R+[specify number of outstanding requests]:number of requests [64]' \ - '-s+[SSH2 subsystem or path to sftp server on the remote host]:subsystem/path' \ + '-s+[specify SSH2 subsystem or path to sftp server on the remote host]:subsystem/path' \ '1:file:->rfile' '*:file:->file' "$common[@]" "$common_transfer[@]" && ret=0 ;; ssh-copy-id) @@ -523,6 +556,7 @@ _ssh () { SendEnv \ ServerAliveCountMax \ ServerAliveInterval \ + SetEnv \ StreamLocalBindMask \ StreamLocalBindUnlink \ StrictHostKeyChecking \ diff --git a/Completion/Unix/Command/_stat b/Completion/Unix/Command/_stat index 2e84d6bf0..03b4552de 100644 --- a/Completion/Unix/Command/_stat +++ b/Completion/Unix/Command/_stat @@ -6,20 +6,14 @@ # Dragonfly by parsing the output of `lsof -N`, but it's not available by # default — is there another way? -local expl variant precmd ret=1 +local expl variant ret=1 local -a context line state state_descr args aopts=( -A '-*' ) local -A opt_args -if [[ $service == zstat ]] || [[ $precommands[-1] == builtin ]]; then - variant=zsh -else - [[ $precommands[-1] == command ]] && precmd=command - _pick_variant -c "${precmd:+$precmd }${words[1]}" -r variant \ - gnu='Free Soft' zsh='no files given' unix --version -fi +_pick_variant -r variant -b zsh gnu='Free Soft' $OSTYPE --version -case $OSTYPE-$variant in - *-zsh) +case $variant in + zsh) args=( "(-H)-A[assign the results to array, don't print]:array variable:_parameters -g '*array*'" - set1 @@ -43,7 +37,7 @@ case $OSTYPE-$variant in '-l[list stat types]' ) ;; - *-gnu) + gnu) aopts=( ) args=( '*: :_files' diff --git a/Completion/Unix/Command/_stdbuf b/Completion/Unix/Command/_stdbuf index e45b5a5cd..a18938ee1 100644 --- a/Completion/Unix/Command/_stdbuf +++ b/Completion/Unix/Command/_stdbuf @@ -4,7 +4,7 @@ local -a short long buf args local i opt gnu=0 short=( -e -i -o ) -long=( --error --output --input ) +long=( --error --input --output ) buf=( err in out ) opt='[set initial buffering for std${buf[i]}]:mode or size:((0\:unbuffered L\:line\ buffered' diff --git a/Completion/Unix/Command/_stow b/Completion/Unix/Command/_stow new file mode 100644 index 000000000..6a315fc57 --- /dev/null +++ b/Completion/Unix/Command/_stow @@ -0,0 +1,87 @@ +#compdef stow chkstow + +# +# A zsh completion script for GNU stow (https://www.gnu.org/software/stow/) +# + +(( $+functions[__stow_packages] )) || +__stow_packages() { + local stow_dir=${(Q)1} + local -a stow_pkg_list=( $stow_dir/*(-/N:t) ) + + if [[ ${#stow_pkg_list} -gt 0 ]]; then + _values -C "package from $stow_dir" ${${stow_pkg_list//\\/\\\\}//:/\\:} + else + _message "no package found in $stow_dir" + fi +} + +case $service in + stow) + local state line curcontext="$curcontext" ret=1 + typeset -A opt_args + # Others local variables + local stow_dir arguments + + arguments=( + '(- *)'{--help,-h}'[show help]' + '(- *)'{--version,-V}'[show version number]' + '(-d --dir)'{-d+,--dir=}'[set the stow dir (default is current dir)]:stow dir [$PWD]:_files -/' + '(-t --target)'{-t+,--target=}'[set the target dir (default is parent of stow dir)]:target dir [../$PWD]:_files -/' + # Several distinct actions can be specified in a single invocation + # of the stow command (stow/unstow/restow). However, neither the + # stow command nor this script will prevent you from using + # different actions on the same package. + '*'{-S,--stow}'[stow the package names that follow]: :->stow_package' + '*'{-D,--delete}'[unstow the package names that follow]: :->stow_package' + '*'{-R,--restow}'[restow (unstow and stow again) the package names that follow]: :->stow_package' + '--adopt[adopt already existing plain file]' + '--ignore=[ignore files ending with this perl regex]:regexp:' + "--defer=[don't stow files beginning with this perl regex]:regexp:" + '--override=[force stowing files beginning with this perl regex]:regexp:' + '--no-folding[disable any further tree folding or tree refolding]' + '--dotfiles[enable special handling for dotfiles]' + '(-p --compat)'{-p,--compat}'[use legacy algorithm for unstowing]' + '(-n -no --simulate)'{-n,--no,--simulate}'[do not actually make any filesystem changes]' + '*-v[increase verbosity]' + '*--verbose=-[increase verbosity]::level:(0 1 2 3 4 5)' + '*:stow package:->stow_package' + ) + + _arguments -s -C $arguments && ret=0 + + case $state in + (stow_package) + if (( $+opt_args[-d] )) ; then + stow_dir="$opt_args[-d]" + elif (( $+opt_args[--dir] )) ; then + stow_dir="$opt_args[--dir]" + elif [[ ${(t)STOW_DIR} == *export* ]] && [[ -n "$STOW_DIR" ]]; then + # if not provided from the command line, for the stow command, the stow + # directory is assumed to be the value of the "STOW_DIR" environment + # variable... + stow_dir="$STOW_DIR" + else + # ...if unset, the stow directory is assumed to be the current directory + stow_dir="$PWD" + fi + + __stow_packages "$stow_dir" && ret=0 + + ;; + esac + + return ret + ;; + chkstow) + local arguments + arguments=( + '(-t --target)'{-t+,--target=}'[set the target directory (default is /usr/local/)]:target dir:_files -/' + '(-b --badlinks)'{-b,--badlinks}'[report symlinks that point to non-existent files (default mode)]' + '(-a --aliens)'{-a,--aliens}'[report non-symlinks in the target directory]' + '(-l --list)'{-l,--list}'[list packages in the target directory]' + ) + _arguments $arguments + ;; +esac + diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index a066b0728..a1e9109de 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -11,11 +11,15 @@ _svn () { relative-url "the repository-relative URL" repos-root-url "the repository root URL" repos-uuid "the repository UUID" + repos-size "the size of TARGET in the repository (for files only)" revision "the revision of TARGET" last-changed-revision "the most recent revision in which TARGET was changed" last-changed-date "the date of the last-changed revision" last-changed-author "the author of the last-changed revision" wc-root "the working copy root path" + schedule "'normal', 'add', 'delete', 'replace'" + depth "'infinity', 'immediates', 'files', 'empty', 'exclude'" + changelist "the changelist this file was added to, if any" ) local update_policy @@ -30,11 +34,24 @@ _svn () { '1: :->cmds' \ '*:: :->args' && ret=0 + local _svn_help_takes_verbose + if _cache_invalid svn-help-takes-verbose || ! _retrieve_cache svn-help-takes-verbose; then + [[ $(_call_program svn-help-v svn help help) == *--verbose* ]] + _svn_help_takes_verbose=$(( ! $? )) + _store_cache svn-help-takes-verbose _svn_help_takes_verbose + fi + if (( _svn_help_takes_verbose )); then + readonly dash_v="-v" + else + readonly dash_v + fi + unset _svn_help_takes_verbose + if [[ -n $state ]] && (( ! $+_svn_cmds )); then typeset -gHA _svn_cmds if _cache_invalid svn-cmds || ! _retrieve_cache svn-cmds; then _svn_cmds=( - ${=${(f)${${"$(_call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z-]##)[[:space:]]#(\([a-z, ?-]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:} + ${=${(f)${${"$(_call_program commands svn help $dash_v)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z-]##)[[:space:]]#(\([a-z, ?-]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:} ) if (( $? == 0 )); then _store_cache svn-cmds _svn_cmds @@ -60,14 +77,14 @@ _svn () { if _cache_invalid svn-${cmd}-usage || \ ! _retrieve_cache svn-${cmd}-usage; then - usage=${${(M)${(f)"$(_call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] } + usage=${${(M)${(f)"$(_call_program options svn help $dash_v -- $cmd)"}:#usage:*}#usage:*$cmd] } _store_cache svn-${cmd}-usage usage fi if _cache_invalid svn-${cmd}-usage || \ ! _retrieve_cache svn-${cmd}-args; then args=( - ${=${${${(M)${(f)"$(_call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)(-##)([[:alpha:]]##) \[--([a-z-]##)\](:arg:)#/(--$match[3])$match[1]$match[2]$match[4] ($match[1]$match[2])--$match[3]$match[4]} + ${=${${${(M)${(f)"$(_call_program options svn help $dash_v -- $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)(-##)([[:alpha:]]##) \[--([a-z-]##)\](:arg:)#/(--$match[3])$match[1]$match[2]$match[4] ($match[1]$match[2])--$match[3]$match[4]} ) while (( idx=$args[(I)*--accept:arg:] )); do args[idx]=( --accept'=:automatic conflict resolution action:((working\:working base\:base recommended\:recommended '"`for i j in p postpone mc mine-conflict tc theirs-conflict mf mine-full tf theirs-full e edit l launch; do print -rn $i\\\\:$j $j\\\\:$j ""; done `"'))' ) @@ -106,7 +123,19 @@ _svn () { case $cmd in; (add) args+=( - '*:file:_files -g "*(^e:_svn_controlled:)"' + '*:file:_files -g "*(e:_svn_uncontrolled:)"' + ) + ;; + (auth) + args+=( + '*:auth pattern: ' + ) + ;; + (changelist) + args[(r)--remove]='(1)--remove' + args+=( + '(--remove)1:changelist name:_svn_changelists' + '*:file:_files -g "*(e:_svn_controlled:)"' ) ;; (commit) @@ -145,6 +174,12 @@ _svn () { (mergeinfo) args[(r)--show-revs=:arg:]=( '--show-revs=:revisions:(merged eligible)' ) ;; + (patch) + args+=( + '1:patch file:_files' + '2::working copy to patch:_files' + ) + ;; (propget|propedit|propdel) args+=( '1:property name:_svn_props' @@ -159,7 +194,7 @@ _svn () { '*:path or url: _alternative "files:file:_files" "urls:URL:_svn_urls"' ) ;; - (resolved) + (resolve|resolved) args+=( '*:file:_files -g "*(e:_svn_conflicts:)"' ) @@ -169,9 +204,9 @@ _svn () { '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"' ) ;; - (unshelve) - args+=( '1:shelf name:compadd - ${${(f)"$(_call_program shelves svn unshelve -q --list)"}%% *}' ) - ;; + (x-unshelve) + args+=( '1:shelf name:compadd - ${(f)"$(_call_program shelves svn x-shelves --quiet)"}' '2::shelf version' ) + ;; (*) case $usage in *(SRC|DST|TARGET|URL*PATH)*) @@ -310,12 +345,27 @@ _svnadmin () { (( $+functions[_svn_controlled] )) || _svn_controlled() { - [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]] + # For svn<=1.6, this was implemented as: + # [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]] + # However, because that implementation returns false for all files on svn>=1.7, and + # because 1.6 has been deprecated for 8 years and EOL for 6 years, we opt to DTRT + # for >=1.7. Therefore: + + # TODO: Reimplement this function and _svn_uncontrolled for svn>=1.7. + # (Use 'svn st' or 'svn info', not 'svn ls') + return 0 +} + + +(( $+functions[_svn_uncontrolled] )) || +_svn_uncontrolled() { + # TODO: See comments in _svn_controlled + return 0 } (( $+functions[_svn_conflicts] )) || _svn_conflicts() { - [ -n $REPLY.(mine|r<->)(N[1]) ] + () { (( $# > 0 )) } $REPLY.(mine|r<->)(NY1) } (( $+functions[_svn_deletedfiles] )) || diff --git a/Completion/Unix/Command/_sudo b/Completion/Unix/Command/_sudo index 10fa2e82e..41e32cbae 100644 --- a/Completion/Unix/Command/_sudo +++ b/Completion/Unix/Command/_sudo @@ -23,9 +23,9 @@ args=( \*{-l,--list}"[list user's privileges or check a specific command]" '(-n --non-interactive)'{-n,--non-interactive}'[non-interactive mode, no prompts are used]' '(-p --prompt)'{-p+,--prompt=}'[use the specified password prompt]:prompt' - '(-r --role)'{-r+,--role=}'[create SELinux security context with specified role]:role' + '(-r --role)'{-r+,--role=}'[create SELinux security context with specified role]: :_selinux_roles' '(-S --stdin)'{-S,--stdin}'[read password from standard input]' - '(-t --type)'{-t+,--type=}'[create SELinux security context with specified type]:type' + '(-t --type)'{-t+,--type=}'[create SELinux security context with specified type]: :_selinux_types' '(-T --command-timeout)'{-T+,--command-timeout=}'[terminate command after specified time limit]:timeout' '(-U --other-user)'{-U+,--other-user=}'[in list mode, display privileges for user]:user:_users' '(-u --user)'{-u+,--user=}'[run command (or edit file) as specified user]:user:_users' diff --git a/Completion/Unix/Command/_surfraw b/Completion/Unix/Command/_surfraw index d9df4170d..f945f1ca9 100644 --- a/Completion/Unix/Command/_surfraw +++ b/Completion/Unix/Command/_surfraw @@ -54,7 +54,7 @@ case $state in cddb) _arguments $args \ '-artists[search artists]' \ - '-albums[search albulms]' \ + '-albums[search albums]' \ '-songs[search songs]' \ '-all[search all artists, albums and songs]' && ret=0 ;; diff --git a/Completion/Unix/Command/_swaks b/Completion/Unix/Command/_swaks index a0ffb53ad..0e92221bd 100644 --- a/Completion/Unix/Command/_swaks +++ b/Completion/Unix/Command/_swaks @@ -1,5 +1,8 @@ #compdef swaks +local ign + +(( $#words > 2 )) && ign='!' _arguments \ '(-s --server -p --port)'{-s+,--server=}'[target host[:port\]]:host[\:port]:_hosts' \ '(-p --port)'{-p+,--port=}'[target port number]:port number:(25 465 587)' \ @@ -27,14 +30,27 @@ _arguments \ ESMTPS\:EHLO\ STARTTLS\ 25 ESMTPSA\:EHLO\ STARTTLS\ 25\ authenticated ))' \ - '-tls[TLS required]' \ - '(-tlsos --tls-optional-strict)'{-tlsos,--tls-optional-strict}'[TLS iff offered by target]' \ + '(-tls -tlsos --tls-optional-strict)-tls[TLS required]' \ + '(-tls -tlsos --tls-optional-strict)'{-tlsos,--tls-optional-strict}'[TLS iff offered by target]' \ '(-tlsc --tls-on-connect)'{-tlsc,--tls-on-connect}'[TLS on connect (port 465)]' \ '(-tlsp --tls-protocol)'{-tlsp,--tls-protocol=}':TLS protocol:(sslv2 sslv3 tlsv1 tlsv1_1 tlsv1_2)' \ '-tls-cipher:OpenSSL cipher string: ' \ '--tls-verify[verify TLS certificates]' \ '--tls-ca-path=:OpenSSL CAfile or CAdir:_files' \ '--tls-get-peer-cert=-:file to write (omit for STDOUT)' \ + '(-a --auth -ao --auth-optional -aos --auth-optional-strict)'{-a+,--auth=}'[use authentication, failing if no common auth-types found]::auth type:_sequence compadd - LOGIN PLAIN CRAM-MD5 DIGEST-MD5 CRAM-SHA1 NTLM SPA MSN' \ + '(-a --auth -ao --auth-optional -aos --auth-optional-strict)'{-ao,--auth-optional=}'[use authentication if common auth-types found]::auth type:_sequence compadd - LOGIN PLAIN CRAM-MD5 DIGEST-MD5 CRAM-SHA1 NTLM SPA MSN' \ + '(-a --auth -ao --auth-optional -aos --auth-optional-strict)'{-aos,--auth-optional-strict=}'[use authentication]::auth type:_sequence compadd - LOGIN PLAIN CRAM-MD5 DIGEST-MD5 CRAM-SHA1 NTLM SPA MSN' \ + '(-ap --auth-password)'{-ap,--auth-password=}'[provide the password to be used for authentication]::password' \ + \*{-ae,--auth-extra=}'[add extra information to authentication process]: :_values keywords + {realm,domain,dmd5-{serv-type,host,serv-name}}\:value' \ + \*{-am,--auth-map=}'[map alternate names for authentication types]:alias=type,...' \ + '(-apt --auth-plaintext)'{-apt,--auth-plaintext}'[show auth strings in plaintext when printing on screen]' \ + '(-ahp --auth-hide-password)'{-ahp,--auth-hide-password}'[replace passwords with dummy string when printing to terminal]' \ '(-d --data)'{-d+,--data=}'[specify DATA payload]:filename (or string with tokens):_files' \ '*'{-ah,--add-header=}'[add headers]:<Header>\: Value' \ - '*'{-h,--header=}'[replace headers]:<Header>\: Value' + '*'{-h,--header=}'[replace headers]:<Header>\: Value' \ + "${ign}(-)--support[display capabilities and exit]" \ + "--dump[display results of option processing but send no mail]" \ + "${ign}(-)--help[display usage information]" \ + "${ign}(-)--version[display version information]" diff --git a/Completion/Unix/Command/_sysctl b/Completion/Unix/Command/_sysctl index 2bdcc71f5..0416ca05e 100644 --- a/Completion/Unix/Command/_sysctl +++ b/Completion/Unix/Command/_sysctl @@ -85,7 +85,7 @@ case $OSTYPE in '(-A -a -M)-q[silently ignore nonexistent variables]' \ '(-M -x)-r[binary output]' \ '(-a -A -d -e -f -M -r)-w[write mode]' \ - '(-d -M -r)*-x[hex output. -xx for hexdupm-like output]' \ + '(-d -M -r)*-x[hex output. -xx for hexdump-like output]' \ '*:sysctl variable:_multi_parts ${words[(r)-w]:+-S=} -i . sysctlvars' ;; *) diff --git a/Completion/Unix/Command/_tac b/Completion/Unix/Command/_tac index 7a15bffff..083fce91f 100644 --- a/Completion/Unix/Command/_tac +++ b/Completion/Unix/Command/_tac @@ -1,11 +1,7 @@ #compdef tac gtac -local variant - -_pick_variant -r variant gnu='Free Soft' unix --version - # NetBSD (at least) has its own bare-bones version of this tool -[[ $variant == gnu ]] || { +_pick_variant gnu='Free Soft' unix --version || { _default return } diff --git a/Completion/Unix/Command/_tar b/Completion/Unix/Command/_tar index 727fbd6b5..f9901c0c9 100644 --- a/Completion/Unix/Command/_tar +++ b/Completion/Unix/Command/_tar @@ -99,7 +99,7 @@ if [[ "$PREFIX" = --* ]]; then # ...long options after `--'. - _arguments -- -l '--owner=*:user:_users' \ + _arguments '-f+:' '-C+:' '*: : true' -- -l '--owner=*:user:_users' \ '--group=*:group:_groups' \ '--atime-preserve*::method:(replace system)' \ '--*-script=NAME:script file:_files' \ diff --git a/Completion/Unix/Command/_tcpdump b/Completion/Unix/Command/_tcpdump index 4b9950fa5..9aad84d7b 100644 --- a/Completion/Unix/Command/_tcpdump +++ b/Completion/Unix/Command/_tcpdump @@ -134,6 +134,7 @@ if [[ $OSTYPE = openbsd* ]]; then - capture ${(R)args:#(|\*)(|\(*\))--*} # removes any long-options '(-n)-a[attempt to convert network and broadcast addresses to names]' + '-B+[specify drop action to be used when filter expression matches a packet]:drop action:(pass capture drop)' '-D[select packet flowing in specified direction]:direction:(in out)' '-I[print the interface on each dump line]' '-o[print a guess of the possible operating system(s)]' diff --git a/Completion/Unix/Command/_tiff b/Completion/Unix/Command/_tiff index 128aeb0c0..da55b541c 100644 --- a/Completion/Unix/Command/_tiff +++ b/Completion/Unix/Command/_tiff @@ -249,7 +249,7 @@ if [[ -n "$state" ]]; then _message -e values "compression quality (0-100), or \`r' (output RGB)" ret=0 ;; - lzw|lzma|zip) + lzw|lzma|zip|zstd|webp) _values 'LZW and deflate option' \ '1[without differencing]' \ '2[with differencing]' && ret=0 @@ -260,7 +260,7 @@ if [[ -n "$state" ]]; then while _tags; do while _next_label values expl 'compression scheme'; do compadd "$expl[@]" - none jbig g4 packbits sgilog && ret=0 - compadd "$expl[@]" -qS: - lzw zip lzma jpeg g3 && ret=0 + compadd "$expl[@]" -qS: - lzw zip lzma zstd webp jpeg g3 && ret=0 done (( ret )) || return 0 done diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index 0e8fe2223..b564c955d 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -43,7 +43,6 @@ # # TODO: # -# - Implement __tmux-format # - Implement __tmux-style (possibly using existing helpers like # __tmux-attributes and __tmux-colours) # - in _tmux-list-panes, use __tmux-windows or __tmux-sessions @@ -96,6 +95,7 @@ _tmux_aliasmap=( prevl previous-layout renamew rename-window resizep resize-pane + resizew resize-window respawnp respawn-pane respawnw respawn-window rotatew rotate-window @@ -187,7 +187,7 @@ _tmux-break-pane() { [[ -n ${tmux_describe} ]] && print "break a pane from an existing into a new window" && return _arguments -s \ "-d[don't make the new window become the active one]" \ - '-F+[specify output format]:format:__tmux-format' \ + '-F+[specify output format]:format:__tmux-formats' \ '-P[print information of new window after it has been created]' \ '-n+[specify window name]:name' \ '-s+[specify source pane]:pane:__tmux-panes' \ @@ -301,17 +301,20 @@ _tmux-detach-client() { _tmux-display-message() { [[ -n ${tmux_describe} ]] && print "display a message in the status line" && return - _arguments -s -S \ + _arguments -s -S -A "-*" \ + '(-p -F :)-a[list the format variables and their values]' \ '-c+[specify target client]:client:__tmux-clients' \ - '-p[print message to stdout]' \ + '(-a)-p[print message to stdout]' \ '-t+[specify target pane]:pane:__tmux-panes' \ - '-F+[specify output format]:format:__tmux-formats' \ + '(-a)-F+[specify output format]:format:__tmux-formats' \ + '(-a)-v[prints verbose logging as the format is parsed]' \ ':message' } _tmux-display-panes() { [[ -n ${tmux_describe} ]] && print "display an indicator for each visible pane" && return _arguments -S \ + "-b[don't block other commands until indicator is closed]" \ '-d+[time to show indicator for]:duration (ms)' \ '-t+[specify target client]:client:__tmux-clients' \ '*:::command:= _tmux' @@ -324,6 +327,7 @@ _tmux-find-window() { '-N[match window name]' \ '-T[match window title]' \ '-t+[specify target window]:window:__tmux-windows' \ + '-Z[zoom the pane]' \ ':window search pattern' } @@ -584,10 +588,17 @@ _tmux-previous-window() { _tmux-refresh-client() { [[ -n ${tmux_describe} ]] && print "refresh a client" && return - _arguments -s \ + _arguments -s -S -A "-*" \ + '-C+[set the width and height of a control client]:width,height' \ + '-c[reset so that the position follows the cursor]' \ + '-D[move visible portion of window down]' \ + '-L[move visible portion of window left]' \ + '-l[request clipboard from the client and store it in a new paste buf using xterm(1) escape sequence]' \ "-S[only update the client's status bar]" \ '-t+[specify target client]:client:__tmux-clients' \ - '-C+:size' + '-R[move visible portion of window right]' \ + '-U[move visible portion of window up]' \ + ': :_guard "[0-9]#" "adjustment"' } _tmux-rename-session() { @@ -616,7 +627,22 @@ _tmux-resize-pane() { '-x+[specify width]:width' \ '-y+[specify height]:height' \ '-Z[toggle zoom of pane]' \ - ':adjustment' + ': :_guard "[0-9]#" "adjustment"' +} + +_tmux-resize-window() { + [[ -n ${tmux_describe} ]] && print "resize a window" && return + _arguments -s -A "-*" -S : \ + '-A[set size of largest session containing the window]' \ + '-a[set size of smallest session containing the window]' \ + '-D[resize downward]' \ + '-L[resize to the left]' \ + '-R[resize to the right]' \ + '-U[resize upward]' \ + '-t+[specify target pane]:pane:__tmux-windows' \ + '-x+[specify width]:width' \ + '-y+[specify height]:height' \ + ': :_guard "[0-9]#" "adjustment"' } _tmux-respawn-pane() { @@ -1071,7 +1097,7 @@ function __tmux-environment-variables() { if _describe -t parameters $msg descriptions; then : elif [[ -n $hint ]]; then - _message $msg + _message -e $msg fi ;; (value) @@ -1079,10 +1105,10 @@ function __tmux-environment-variables() { # TODO: this if/else is because '_description -x' prints the "No matches" error in addition to the message. if [[ -n $var_and_val ]]; then local -a expl - _description -x parameter-values expl "Value for ${words[-2]}" + _description -x parameter-values expl "value for ${words[-2]}" compadd "$expl[@]" - ${var_and_val#*=} else - _message "Value for ${words[-2]}" + _message -e "value for ${words[-2]}" fi ;; (*) @@ -1092,7 +1118,180 @@ function __tmux-environment-variables() { } __tmux-formats() { - _message 'not implemented yet' + local hash='#' open='{' close='}' paren='(' quest='?' + local tmux_variables expl + compquote hash open close paren quest + compset -p ${#PREFIX%$hash*} + if compset -P "${(q)hash}${open}"; then + if compset -P "${(q)quest}"; then + close=, + elif ! compset -P "([bdt]|s/[^/]#/[^/]#/|=(-|)<->):"; then + _describe -t operators operator '( + \?:conditional + \=:length\ limit + )' -S '' -- '( + m:fnmatch\ comparison + t:convert\ time\ to\ string + b:basename + c:search\ for\ fnmatch\ pattern\ in\ pane\ content + d:dirname + \==:comparison + \!=:comparison + )' -S : -- '( + s:substitution + )' -S / -- '( + \|\|:either\ of\ two\ conditions + \&\&:both\ of\ two\ conditions + )' -S , + fi + tmux_variables=( + 'alternate_on:if pane is in alternate screen' + 'alternate_saved_x:saved cursor X in alternate screen' + 'alternate_saved_y:saved cursor Y in alternate screen' + 'buffer_created:time buffer created' + 'buffer_name:name of buffer' + 'buffer_sample:sample of start of buffer' + 'buffer_size:size of the specified buffer in bytes' + 'client_activity:time client last had activity' + 'client_created:time client created' + 'client_control_mode:1 if client is in control mode' + 'client_discarded:bytes discarded when client behind' + 'client_height:height of client' + 'client_key_table:current key table' + "client_last_session:name of the client's last session" + 'client_name:name of client' + 'client_pid:PID of client process' + 'client_prefix:1 if prefix key has been pressed' + 'client_readonly:1 if client is readonly' + "client_session:name of the client's session" + 'client_termname:terminal name of client' + 'client_termtype:terminal type of client' + 'client_tty:pseudo terminal of client' + 'client_utf8:1 if client supports utf8' + 'client_width:width of client' + 'client_written:bytes written to client' + 'command:name of command in use, if any' + 'command_list_name:command name if listing commands' + 'command_list_alias:command alias if listing commands' + 'command_list_usage:command usage if listing commands' + 'cursor_flag:pane cursor flag' + 'cursor_character:character at cursor in pane' + 'cursor_x:cursor X position in pane' + 'cursor_y:cursor Y position in pane' + 'history_bytes:number of bytes in window history' + 'history_limit:maximum window history lines' + 'history_size:size of history in lines' + 'hook:name of running hook, if any' + 'hook_pane:ID of pane where hook was run, if any' + 'hook_session:ID of session where hook was run, if any' + 'hook_session_name:name of session where hook was run, if any' + 'hook_window:ID of window where hook was run, if any' + 'hook_window_name:name of window where hook was run, if any' + 'host:hostname of local host' + 'host_short:hostname of local host (no domain name)' + 'insert_flag:pane insert flag' + 'keypad_cursor_flag:pane keypad cursor flag' + 'keypad_flag:pane keypad flag' + 'line:line number in the list' + 'mouse_any_flag:pane mouse any flag' + 'mouse_button_flag:pane mouse button flag' + 'mouse_standard_flag:pane mouse standard flag' + 'mouse_all_flag:pane mouse all flag' + 'pane_active:1 if active pane' + 'pane_at_bottom:1 if pane is at the bottom of window' + 'pane_at_left:1 if pane is at the left of window' + 'pane_at_right:1 if pane is at the right of window' + 'pane_at_top:1 if pane is at the top of window' + 'pane_bottom:bottom of pane' + 'pane_current_command:current command if available' + 'pane_dead:1 if pane is dead' + 'pane_dead_status:exit status of process in dead pane' + 'pane_format:1 if format is for a pane (not assuming the current)' + 'pane_height:height of pane' + 'pane_id:unique pane ID' + 'pane_in_mode:if pane is in a mode' + 'pane_input_off:if input to pane is disabled' + 'pane_index:index of pane' + 'pane_left:left of pane' + 'pane_mode:name of pane mode, if any.' + 'pane_pid:PID of first process in pane' + 'pane_pipe:1 if pane is being piped' + 'pane_right:right of pane' + 'pane_search_string:last search string in copy mode' + 'pane_start_command:command pane started with' + 'pane_synchronized:if pane is synchronized' + 'pane_tabs:pane tab positions' + 'pane_title:title of pane' + 'pane_top:top of pane' + 'pane_tty:pseudo terminal of pane' + 'pane_width:width of pane' + 'pid:server PID' + 'rectangle_toggle:1 if rectangle selection is activated' + 'scroll_region_lower:bottom of scroll region in pane' + 'scroll_region_upper:top of scroll region in pane' + 'scroll_position:scroll position in copy mode' + 'selection_present:1 if selection started in copy mode' + 'session_alerts:list of window indexes with alerts' + 'session_attached:number of clients session is attached to' + 'session_activity:time of session last activity' + 'session_created:time session created' + 'session_format:1 if format is for a session (not assuming the current)' + 'session_last_attached:time session last attached' + 'session_group:name of session group' + 'session_group_size:size of session group' + 'session_group_list:list of sessions in group' + 'session_grouped:1 if session in a group' + 'session_id:unique session ID' + 'session_many_attached:1 if multiple clients attached' + 'session_name:name of session' + 'session_stack:window indexes in most recent order' + 'session_width:width of session' + 'session_windows:number of windows in session' + 'socket_path:server socket path' + 'start_time:server start time' + 'version:server version' + 'window_activity:time of window last activity' + 'window_activity_flag:1 if window has activity' + 'window_active:1 if window active' + 'window_bell_flag:1 if window has bell' + 'window_flags:window flags' + 'window_format:1 if format is for a window (not assuming the current)' + 'window_height:height of window' + 'window_id:unique window ID' + 'window_index:index of window' + 'window_last_flag:1 if window is the last used' + 'window_layout:window layout description, ignoring zoomed window panes' + 'window_linked:1 if window is linked across sessions' + 'window_name:name of window' + 'window_offset_x:X offset into window if larger than client' + 'window_offset_y:Y offset into window if larger than client' + 'window_panes:number of panes in window' + 'window_silence_flag:1 if window has silence alert' + 'window_stack_index:index in session most recent stack' + 'window_visible_layout:window layout description, respecting zoomed window panes' + 'window_width:width of window' + 'window_zoomed_flag:1 if window is zoomed' + 'wrap_flag:pane wrap flag' + ) + _describe -t variables variable tmux_variables -S "$close" + elif compset -P "${(q)hash}${(q)paren}"; then + compset -S '(\\|)\)*' + _cmdstring + elif [[ $PREFIX = ${hash}* ]]; then + _describe -t variables variable '( + \#H:local\ hostname + \#h:short\ local\ hostname + \#D:pane\ id + \#P:pane\ index + \#T:pane\ title + \#S:session\ name + \#F:window\ flags + \#I:window\ index + \#W:window\ name + )' -S '' + else + _wanted format-specifiers expl 'format specifier' compadd -S '' \# + fi } function __tmux-colours() { @@ -1128,7 +1327,7 @@ function __tmux-get-optarg() { } __tmux-nothing-else() { - _message "no further arguments" + _message -e "no further arguments" } function __tmux-option-guard() { @@ -1140,12 +1339,13 @@ function __tmux-option-guard() { int_guard='_guard "[0-9]#" "'${opt}': numeric value"' if [[ ${mode} == 'session' ]]; then options=( + 'activity-action:DESC:any none current other' 'assume-paste-time:'${int_guard} 'base-index:'${int_guard} 'bell-action:DESC:any none current other' - 'bell-on-alert:DESC:on off' 'default-command:MSG:command string' 'default-shell:MSG:shell executable' + 'default-size:MSG:XxY' 'destroy-unattached:DESC:on off' 'detach-on-destroy:DESC:on off' 'display-panes-colour:__tmux-colours' @@ -1164,7 +1364,9 @@ function __tmux-option-guard() { 'repeat-time:'${int_guard} 'set-titles:DESC:on off' 'set-titles-string:MSG:title format string' + 'silence-action:DESC:any none current other' 'status:DESC:on off' + 'status-format:MSG:format string' 'status-interval:'${int_guard} 'status-justify:DESC:left centre right' 'status-keys:DESC:vi emacs' @@ -1177,6 +1379,7 @@ function __tmux-option-guard() { 'status-right-style:__tmux-style' 'status-style:__tmux-style' 'update-environment:MSG:string listing env. variables' + 'user-keys:MSG:key' 'visual-activity:DESC:on off' 'visual-bell:DESC:on off' 'visual-silence:DESC:on off' @@ -1185,13 +1388,14 @@ function __tmux-option-guard() { elif [[ ${mode} == 'server' ]]; then options=( 'buffer-limit:'${int_guard} + 'command-alias:MSG:alias' 'default-terminal:MSG:terminal string' 'escape-time:'${int_guard} + 'exit-empty:DESC:on off' 'exit-unattached:DESC:on off' 'focus-events:DESC:on off' 'history-file:_path-files -g "*(-.)"' 'message-limit:'${int_guard} - 'quiet:DESC:on off' 'set-clipboard:DESC:on off' 'terminal-overrides:MSG:overrides string' ) @@ -1204,13 +1408,12 @@ function __tmux-option-guard() { 'automatic-rename-format:DESC:__tmux-format' 'clock-mode-colour:__tmux-colours' 'clock-mode-style:DESC:12 24' - 'force-height:'${int_guard} - 'force-width:'${int_guard} 'main-pane-height:'${int_guard} 'main-pane-width:'${int_guard} 'mode-keys:DESC:vi emacs' 'mode-style:__tmux-style' 'monitor-activity:DESC:on off' + 'monitor-bell:DESC:on off' 'monitor-silence:DESC:on off' 'other-pane-height:'${int_guard} 'other-pane-width:'${int_guard} @@ -1230,6 +1433,7 @@ function __tmux-option-guard() { 'window-status-last-style:__tmux-style' 'window-status-separator:MSG:separator string' 'window-status-style:__tmux-style' + 'window-size:MSG:XxY' 'window-style:__tmux-style' 'wrap-search:DESC:on off' 'xterm-keys:DESC:on off' @@ -1241,12 +1445,11 @@ function __tmux-option-guard() { _message "unknown ${mode} option: ${opt}" return fi - _message "${mode} option value" guard=${guard#*:} case ${guard} in ('') ;; (MSG:*) - _message ${guard#*:} + _message -e ${guard#*:} ;; (DESC:*) eval "desc=( ${guard#*:} )" @@ -1261,12 +1464,13 @@ function __tmux-option-guard() { function __tmux-session-options() { local -a tmux_session_options tmux_session_options=( + 'activity-action:set action on window activity when monitor-activity is on' 'assume-paste-time:assume keys are pasted instead of typed if this fast' 'base-index:define where to start numbering' 'bell-action:set action on window bell' - 'bell-on-alert:ring the terminal bell when an alert occurs' 'default-command:default command for new windows' 'default-shell:default shell executable' + 'default-size:set the default size of windows when the size is not set' 'destroy-unattached:destroy session if no client is attached' 'detach-on-destroy:detach client if attached session is destroyed' 'display-panes-colour:colour used for display-panes' @@ -1286,7 +1490,9 @@ function __tmux-session-options() { 'repeat-time:time for multiple commands without prefix-key presses' 'set-titles:try to set xterm window titles' 'set-titles-string:format used by set-titles' + 'silence-action:set action on window silence when monitor-silence is on' 'status:show or hide the status bar' + 'status-format:specify the format to be used for each line of the status line' 'status-interval:interval (in seconds) for status bar updates' 'status-justify:position of the window list in status bar' 'status-keys:mode to use in status bar modes (vi/emacs)' @@ -1299,6 +1505,7 @@ function __tmux-session-options() { 'status-right-style:style of right part of status line' 'status-style:style status line' "update-environment:list of variables to be copied to a session's environment" + 'user-keys:set list of user-defined key escape sequences' 'visual-activity:display status line messages upon activity' 'visual-bell:use visual bell instead of audible' 'visual-silence:print a message if monitor-silence is on' @@ -1352,13 +1559,14 @@ function __tmux-server-options() { local -a tmux_server_options tmux_server_options=( 'buffer-limit:number of buffers kept per session' + 'command-alias:custom command aliases' 'default-terminal:default terminal definition string' 'escape-time:set timeout to detect single escape characters (in msecs)' 'exit-unattached:make server exit if it has no attached clients' + 'exit-empty:exit when there are no active sessions' 'focus-events:request focus events from terminal' 'history-file:tmux command history file name' 'message-limit:set size of message log per client' - 'quiet:enable/disable the display of various informational messages' 'set-clipboard:use esc sequences to set terminal clipboard' 'terminal-overrides:override terminal descriptions' ) @@ -1420,13 +1628,12 @@ function __tmux-window-options() { 'automatic-rename-format:format for automatic renames' 'clock-mode-colour:set clock colour' 'clock-mode-style:set clock hour format (12/24)' - 'force-height:force a windows to a certain height' - 'force-width:force a windows to a certain width' 'main-pane-height:set height for main-* layouts' 'main-pane-width:set width for main-* layouts' 'mode-keys:mode to use in copy and choice modes (vi/emacs)' 'mode-style:set window modes style' 'monitor-activity:monitor window activity' + 'monitor-bell:monitor for a bell in the window' 'monitor-silence:monitor window for inactivity' 'other-pane-height:height of other panes' 'other-pane-width:width of other panes' @@ -1446,6 +1653,7 @@ function __tmux-window-options() { 'window-status-last-style:style of last window in status bar' 'window-status-separator:separator drawn between windows in status line' 'window-status-style:general status bar style' + 'window-size:indicate how to automatically size windows' 'window-style:style of window' 'wrap-search:search wrap around at the end of a pane' 'xterm-keys:generate xterm-style function key sequences' diff --git a/Completion/Unix/Command/_top b/Completion/Unix/Command/_top index f9d2733fc..652432166 100644 --- a/Completion/Unix/Command/_top +++ b/Completion/Unix/Command/_top @@ -8,6 +8,7 @@ opts=( -s -w -C ) case $OSTYPE in *linux*) + # based on procps-ng-3.3.15 fields=( '%CPU:CPU usage' '%MEM:memory usage (res)' 'CGROUPS:control groups' 'CODE:code size' 'COMMAND:Command name/line' 'DATA:data + stack size' @@ -26,25 +27,33 @@ case $OSTYPE in 'nTH:number of threads' 'nsIPC:IPC namespace' 'nsMNT:MNT namespace' 'nsNET:NET namespace' 'nsPID:PID namespace' 'nsUSER:USER namespace' 'nsUTS:UTS namespace' 'vMj:major page fault count delta' - 'vMn:minor page fault count delta' + 'vMn:minor page fault count delta' 'LXC:lxc container name' + 'OOMa:out of memory adjustment factor' 'OOMs:out of memory source' + 'Rsan:resident anonymous memory size' + 'RSfd:resident file-backed memory size' 'RSlk:resident locked memory size' + 'RSsh:resident shared memory size' 'CGNAME:control group name' + 'NU:last known NUMA node' ) order=( '+:descending (default)' '-:ascending' ) + local -a units=( 'k:KiB' 'm:MiB' 'g:GiB' 't:TiB' 'p:PiB' 'e:EiB' ) specs=( '(-)-'{h,v}'[show version and usage]' '-b[batch mode]' '-c[command line/program name toggle]' '-d+[delay time interval]:interval' + '-E+[specify the memory scaling unit]: : _describe -V -t units unit units' '-H[threads mode operation]' '-i[idle process toggle]' '-n+[number of iterations]:number of iterations' '-o+[override sort field]:fieldname:->sortkey' '-O[output field names]' - '*-p+[monitor pids]: :_sequence -s , _pids' + '(-u -U)*-p+[monitor pids]: :_sequence -s , _pids' '-s[secure mode operation]' '-S[cumulative time toggle]' - '(-U)-u+[effective user filter mode]: :_users' - '(-u)-U+[user filter mode]: :_users' + '(-U -p)-u+[effective user filter mode]: :_users' + '(-u -p)-U+[user filter mode]: :_users' '-w+[output width override]::number' + '-1[single/separate cpu states toggle]' );; freebsd*|openbsd*) fields=( cpu size res time pri pid ) @@ -56,6 +65,7 @@ case $OSTYPE in '-i[interactive mode]' '-n[non-interactive mode (identical to batch mode)]' '-o+[sort process display by the specified field]:field:( $fields )' + '-p+[filter by the specified pid]: :_pids' '-q[renice top to -20]' '-S[show system processes]' '-s+[specify delay interval]:seconds:' @@ -63,7 +73,7 @@ case $OSTYPE in '1: :_guard "^-*" "number of processes to display"' );| freebsd*) - fields+=( threads total read write fault vcsw ivcsw jid ) + fields+=( threads total read write fault vcsw ivcsw jid swap ) specs+=( '-C[CPU display mode]' '-a[display command names via argv]' @@ -83,7 +93,6 @@ case $OSTYPE in '-1[combine CPU statistic into one line]' '-C[show command arguments as well as process name]' '-g+[filter processes by the specified string]:string' - '-p+[filter by the specified pid]: :_pids' '-U+[filter processes by the specified user]: :_users -M "L\:|-="' );; darwin*) @@ -127,6 +136,8 @@ case $OSTYPE in 'sysmach:total Mach syscalls' 'pageins:total pageins' 'boosts:number of boosts held by the process' + 'instrs:number of instructions retired by the process' + 'cycles:number of cycles spent in the process' ) order=( '-:descending (default)' '+:ascending' ) specs=( diff --git a/Completion/Unix/Command/_transmission b/Completion/Unix/Command/_transmission new file mode 100644 index 000000000..8a4bebec3 --- /dev/null +++ b/Completion/Unix/Command/_transmission @@ -0,0 +1,503 @@ +#compdef transmission-remote + +# arrays of options + +# `general_options`: *options* which can be used for any action +local exclusive_auth_options='(-n --auth -ne --authenv -N --netrc)' +local general_options=( + {-d,--debug}'[enable debugging mode]' + $exclusive_auth_options{-n-,--auth=}'[set the username and password for authentication]:username\:password: ' + $exclusive_auth_options{-ne,--authenv}'[set the authentication information from the TR_AUTH environment variable]' + $exclusive_auth_options{-N-,--netrc=}'[set the authentication information from a netrc file]:file:_files' + '--find[tell Transmission where to look for the current torrents'"'"' data]' +) +# `general_actions`: *actions* that can be specified when a specific set of torrents is either specified or either not +local general_actions=( + '(- :)'{-gsr,--global-seedratio}'[all torrents, unless overridden by a per-torrent setting, should seed until a specific ratio]:ratio:{_message "ratio in kB/sec"}' + '(- :)'{-GSR,--no-global-seedratio}'[all torrents, unless overridden by a per-torrent setting, should seed regardless of ratio]' + '(- :)'{-pr,--peers}'[set the maximum number of peers]:number: ' + '(- :)'{-d-,--downlimit=}'[limit the maximum download speed to limit kB/s]:limit:{_message "limit in kB/sec"}' + '(- :)'{-D,--no-downlimit}'[disable download speed limits]' +) +# `global_only_actions`: *actions* that can be specified only when no specific torrent is specified +local global_only_actions=( + '(- :)'{-as,--alt-speed}'[use the alternate Limits]' + '(- :)'{-AS,--not-alt-speed}'[don'"'"'t use the alternate Limits]' + '(- :)'{-asd,--alt-speed-downlimit}'[limit the alternate download speed to limit kilobytes per second]' + '(- :)'{-asu,--alt-speed-uplimit}'[limit the alternate upload speed to limit kilobytes per second]' + '(- :)'{-asc,--alt-speed-scheduler}'[use the scheduled on/off times]' + '(- :)'{-asc,--not-alt-speed-scheduler}'[don'"'"'t use the scheduled on/off times]' + '(- :)--alt-speed-time-begin[time to start using the alt speed limits]:hhmm:_transmission-remote_time' + '(- :)--alt-speed-time-end[time to stop using the alt speed limits]:hhmm:_transmission-remote_time' + '(- :)--alt-speed-days[set the number of days on which to enable the speed scheduler]:days:_transmission-remote_days' + '(- :)--torrent-done-script[specify a file to run each time a torrent finishes]:script:_files' + '(- :)--no-torrent-done-script[don'"'"'t run any script when a torrent finishes]' + '(- :)'{-e-,--cache=}'[set the session'"'"'s maximum memory cache size in MiB]:size (MiB):' + '(- :)'{-er,--encryption-required}'[encrypt all peer connections]' + '(- :)'{-ep,--encryption-preferred}'[prefer encrypted peer connections]' + '(- :)'{-et,--encryption-tolerated}'[prefer unencrypted peer connections]' + '(- :)'{-h,--help}'[print command-line option descriptions]' + '(- :)--exit[tell the Transmission to initiate a shutdown]' + '(- :)'{-V,--version}'[show version number and exit]' + {-t,--torrent=}'[set the current torrent(s) for use by subsequent options]:torrent:_transmission-remote_torrent' + '(- :)'{-si,--session-info}'[list session information from the server]' + '(- :)'{-st,--session-stats}'[list statistical information from the server]' + {-a-,--add=}'[add torrents to transmission]:filename\|url:_transmission-remote_add' + '(- :)'{-l,--list}'[list all torrents]' + '(- :)'{-p,--port}'[set the port for use when listening for incoming peer connections]:port:' + '(- :)--start-paused[start added torrents paused]' + '(- :)--no-start-paused[start added torrents unpaused]' + '(- :)'{-m,--portmap}'[enable portmapping via NAT-PMP or UPnP]' + '(- :)'{-M,--no-portmap}'[disable portmapping]' + '(- :)'{-o,--dht}'[enable distributed 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]' + '(- :)--no-utp[disable uTP for peer connections]' + '(- :)'{-x,--pex}'[enable peer exchange (PEX)]' + '(- :)'{-X,--no-pex}'[disable peer exchange (PEX)]' + '(- :)'{-y,--lss}'[enable local peer discovery (LPD)]' + '(- :)'{-Y,--no-lss}'[disable local peer discovery (LPD)]' + '(- :)'{-pi,--peer-info}"[list the current torrent's connected peers]" + "(- :)--blocklist-update[update blocklist from URL specified in remote client's settings with blocklist-url key]" + '*:host\:port:_hosts' +) +# `torrent_add_options`: *options* that can be used only when *adding* a torrent +local torrent_add_options=( + '(-C --no-incomplete-dir)'{-c-,--incomplete-dir=}'[when adding new torrents, store their contents in directory until the torrent is done]:dir:{_files -/}' + '(-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 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' + {-G,--no-get}'[mark file(s) for not downloading]:torrent_file:_transmission-remote_torrent_no_get' + {-i,--info}'[show details of the current torrent(s)]' + {-if,--info-files}'[list the specified torrent'"'"'s files]' + {-ip,--info-peers}'[list the specified torrent'"'"'s peers]' + {-ic,--info-pieces}'[list the specified torrent'"'"'s pieces]' + {-it,--info-trackers}'[list the specified torrent'"'"'s trackers]' + '--trash-torrent[delete torrents after adding]' + '--no-trash-torrent[do not delete torrents after adding]' + {-td-,--tracker-add=}'[add a tracker to a torrent]:tracker:_urls' + {-tr-,--tracker-remove=}'[remove a tracker from a torrent]:tracker_id:_transmission-remote_torrent_tracker_id' + {-s,--start}'[start the current torrent(s)]' + {-S,--stop}'[stop the current torrent(s) from downloading or seeding]' + {-r,--remove}'[remove the current torrent(s) without deleting the downloaded data]' + {-rad,--remove-and-delete}'[remove the current torrent(s) and delete the downloaded data]' + '--reannounce[reannounce the current torrent(s)]' + '--move[move the current torrents'"'"' data from their current locations to the specified directory]:{_files -/}' + {-sr-,--seedratio=}'[let the current torrent(s) seed until a specific ratio]:ratio:{_message "ratio in kB/sec"}' + {-SR,--no-seedratio}'[let the current torrent(s) use the global seedratio settings]' + {-hl,--honor-session}'[make the current torrent(s) honor the session limits]' + {-HL,--no-honor-session}'[make the current torrent(s) not honor the session limits]' + {-Bh,--bandwidth-high}'[give this torrent first chance at available bandwidth]' + {-Bn,--bandwidth-normal}'[give this torrent the bandwidth left over by high priority torrents]' + {-Bl,--bandwidth-low}'[give this torrent the bandwidth left over by high and normal priority torrents]' + {-ph,--priority-high}'[try to download the specified file(s) first]:torrent_file:_transmission-remote_torrent_priority_not_high' + {-pn,--priority-normal}'[try to download the specified files normally.]:torrent_file:_transmission-remote_torrent_priority_not_normal' + {-pl,--priority-low}'[try to download the specified files last]:torrent_file:_transmission-remote_torrent_priority_not_low' + {-v,--verify}'[verify the current torrent(s)]' +) + +# helper functions + +# complete argument specified after global only action: `--alt-speed-time-begin` +# completes time in HHMM format +(( $+functions[_transmission-remote_time] )) || +_transmission-remote_time(){ + _message "time in format HHMS" +} +# complete argument specified after global only action: `--alt-speed-days` +# completes days in a list such as "2,4-6". +(( $+functions[_transmission-remote_days] )) || +_transmission-remote_days(){ + _values -s , -S '-' days {1..7} +} +# complete argument specified after global only action: `--add` +(( $+functions[_transmission-remote_add] )) || +_transmission-remote_add(){ +_alternative \ + 'args:torrent:_files -g ".torrent"' \ + 'args:url:_urls' +} +# complete torrents +(( $+functions[_transmission-remote_torrent] )) || +_transmission-remote_torrent(){ + local authentication_args + for k in '--auth' '--netrc'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k"="${authentication_args}" + break + fi + done + if [[ -z "${authentication_args}" ]]; then + for k in '-n' '-N'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k""${authentication_args}" + break + fi + done + fi + if [[ -z "${authentication_args}" ]]; then + for k in '--authenv' '-ne' '--netrc' '-N'; do + if [[ ${+opt_args[$k]} == "1" ]]; then + authentication_args="$k" + break + fi + done + fi + local torrents_list_lines=(${(f)"$(transmission-remote "${authentication_args}" --list 2> /dev/null)"}) + local -a parts + local -a torrents_ids torrents_names + # 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]}) + torrents_ids+=("${parts[1]}") + torrents_names+=("${parts[10,${#parts[@]}]}") + done + _describe -t torrents torrent torrents_names torrents_ids +} +# complete action specified after *--torrent*: `--get` +(( $+functions[_transmission-remote_torrent_get] )) || +_transmission-remote_torrent_get(){ + local authentication_args + for k in '--auth' '--netrc'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k"="${authentication_args}" + break + fi + done + if [[ -z "${authentication_args}" ]]; then + for k in '-n' '-N'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k""${authentication_args}" + break + fi + done + fi + if [[ -z "${authentication_args}" ]]; then + for k in '--authenv' '-ne' '--netrc' '-N'; do + if [[ ${+opt_args[$k]} == "1" ]]; then + authentication_args="$k" + break + fi + done + fi + local selected_torrent + for k in '-t' '--torrent'; do + if [[ ! -z ${opt_args[$k]} ]]; then + selected_torrent="${opt_args[$k]}" + fi + done + if [[ -z "${selected_torrent}" ]]; then + _message -r "no torrent was selected on the command line enabling completion of files" + return + fi + local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"}) + local -a parts + local -a files + local torrent_name + for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do + parts=(${(@s. .)files_info_lines[$f]}) + torrent_name="${parts[7,${#parts[@]}]%/*}" + if [[ ${parts[4]} == "No" ]]; then + files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"]) + fi + done + if [[ -z "${files}" ]]; then + _message -r "No files are marked for not downloading in torrent ${torrent_name}" + return + fi + _values -s , -S '-' "files from ${torrent_name}" "${files[@]}" +} +# complete action specified after *--torrent*: `--no-get` +(( $+functions[_transmission-remote_torrent_no_get] )) || +_transmission-remote_torrent_no_get(){ + local authentication_args + for k in '--auth' '--netrc'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k"="${authentication_args}" + break + fi + done + if [[ -z "${authentication_args}" ]]; then + for k in '-n' '-N'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k""${authentication_args}" + break + fi + done + fi + if [[ -z "${authentication_args}" ]]; then + for k in '--authenv' '-ne' '--netrc' '-N'; do + if [[ ${+opt_args[$k]} == "1" ]]; then + authentication_args="$k" + break + fi + done + fi + local selected_torrent + for k in '-t' '--torrent'; do + if [[ ! -z ${opt_args[$k]} ]]; then + selected_torrent="${opt_args[$k]}" + fi + done + if [[ -z "${selected_torrent}" ]]; then + _message -r "no torrent was selected on the command line enabling completion of files" + return + fi + local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"}) + local -a parts + local -a files + local torrent_name + for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do + parts=(${(@s. .)files_info_lines[$f]}) + torrent_name="${parts[7,${#parts[@]}]%/*}" + if [[ ${parts[4]} == "Yes" ]]; then + files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"]) + fi + done + if [[ -z "${files}" ]]; then + _message -r "No files are marked for downloading in torrent ${torrent_name}" + return + fi + _values -s , -S '-' "files from ${torrent_name}" "${files[@]}" +} +# complete action specified after *--torrent*: `--priority-low` or `--priority-normal` +(( $+functions[_transmission-remote_torrent_priority_not_high] )) || +_transmission-remote_torrent_priority_not_high(){ + local authentication_args + for k in '--auth' '--netrc'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k"="${authentication_args}" + break + fi + done + if [[ -z "${authentication_args}" ]]; then + for k in '-n' '-N'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k""${authentication_args}" + break + fi + done + fi + if [[ -z "${authentication_args}" ]]; then + for k in '--authenv' '-ne' '--netrc' '-N'; do + if [[ ${+opt_args[$k]} == "1" ]]; then + authentication_args="$k" + break + fi + done + fi + local selected_torrent + for k in '-t' '--torrent'; do + if [[ ! -z ${opt_args[$k]} ]]; then + selected_torrent="${opt_args[$k]}" + fi + done + if [[ -z "${selected_torrent}" ]]; then + _message -r "no torrent was selected on the command line enabling completion of files" + return + fi + local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"}) + local -a parts + local -a files + local torrent_name + for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do + parts=(${(@s. .)files_info_lines[$f]}) + torrent_name="${parts[7,${#parts[@]}]%/*}" + if [[ ${parts[3]} != "High" ]]; then + files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"]) + fi + done + if [[ -z "${files}" ]]; then + _message -r "No files are marked with non-high priority in torrent ${torrent_name}" + return + fi + _values -s , -S '-' "files from ${torrent_name}" "${files[@]}" +} +# complete action specified after *--torrent*: `--priority-low` or `--priority-high` +(( $+functions[_transmission-remote_torrent_priority_not_normal] )) || +_transmission-remote_torrent_priority_not_normal(){ + local authentication_args + for k in '--auth' '--netrc'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k"="${authentication_args}" + break + fi + done + if [[ -z "${authentication_args}" ]]; then + for k in '-n' '-N'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k""${authentication_args}" + break + fi + done + fi + if [[ -z "${authentication_args}" ]]; then + for k in '--authenv' '-ne' '--netrc' '-N'; do + if [[ ${+opt_args[$k]} == "1" ]]; then + authentication_args="$k" + break + fi + done + fi + local selected_torrent + for k in '-t' '--torrent'; do + if [[ ! -z ${opt_args[$k]} ]]; then + selected_torrent="${opt_args[$k]}" + fi + done + if [[ -z "${selected_torrent}" ]]; then + _message -r "no torrent was selected on the command line enabling completion of files" + return + fi + local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"}) + local -a parts + local -a files + local torrent_name + for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do + parts=(${(@s. .)files_info_lines[$f]}) + torrent_name="${parts[7,${#parts[@]}]%/*}" + if [[ ${parts[3]} != "Normal" ]]; then + files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"]) + fi + done + if [[ -z "${files}" ]]; then + _message -r "No files are marked with non-high priority in torrent ${torrent_name}" + return + fi + _values -s , -S '-' "files from ${torrent_name}" "${files[@]}" +} +# complete action specified after *--torrent*: `--priority-normal` or `--priority-high` +(( $+functions[_transmission-remote_torrent_priority_not_low] )) || +_transmission-remote_torrent_priority_not_low(){ + local authentication_args + for k in '--auth' '--netrc'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k"="${authentication_args}" + break + fi + done + if [[ -z "${authentication_args}" ]]; then + for k in '-n' '-N'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k""${authentication_args}" + break + fi + done + fi + if [[ -z "${authentication_args}" ]]; then + for k in '--authenv' '-ne' '--netrc' '-N'; do + if [[ ${+opt_args[$k]} == "1" ]]; then + authentication_args="$k" + break + fi + done + fi + local selected_torrent + for k in '-t' '--torrent'; do + if [[ ! -z ${opt_args[$k]} ]]; then + selected_torrent="${opt_args[$k]}" + fi + done + if [[ -z "${selected_torrent}" ]]; then + _message -r "no torrent was selected on the command line enabling completion of files" + return + fi + local files_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent "${selected_torrent}" --info-files 2> /dev/null)"}) + local -a parts + local -a files + local torrent_name + for (( f = 3; f < ${#files_info_lines[@]}; ++f )); do + parts=(${(@s. .)files_info_lines[$f]}) + torrent_name="${parts[7,${#parts[@]}]%/*}" + if [[ ${parts[3]} != "Low" ]]; then + files+=("${parts[1]%:}""[""${parts[7,${#parts[@]}]#*/}"]) + fi + done + if [[ -z "${files}" ]]; then + _message -r "No files are marked with non-high priority in torrent ${torrent_name}" + return + fi + _values -s , -S '-' "files from ${torrent_name}" "${files[@]}" +} +# complete action specified after *--torrent*: `--tracker-remove` +(( $+functions[_transmission-remote_torrent_tracker_id] )) || +_transmission-remote_torrent_tracker_id(){ + local authentication_args + for k in '--auth' '--netrc'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k"="${authentication_args}" + break + fi + done + if [[ -z "${authentication_args}" ]]; then + for k in '-n' '-N'; do + authentication_args="${opt_args[${k}]}" + if ! [[ -z "${authentication_args}" ]]; then + authentication_args="$k""${authentication_args}" + break + fi + done + fi + if [[ -z "${authentication_args}" ]]; then + for k in '--authenv' '-ne' '--netrc' '-N'; do + if [[ ${+opt_args[$k]} == "1" ]]; then + authentication_args="$k" + break + fi + done + fi + local selected_torrent + for k in '-t' '--torrent'; do + if [[ ! -z ${opt_args[$k]} ]]; then + selected_torrent="${opt_args[$k]}" + fi + done + if [[ -z "${selected_torrent}" ]]; then + _message -r "no torrent was selected on the command line enabling completion of files" + return + fi + local trackers_info_lines=(${(f)"$(transmission-remote "${authentication_args}" --torrent $selected_torrent --info-trackers 2> /dev/null)"}) + local -a parts + local -a trackers_urls trackers_ids + for (( t = 1; t < ${#trackers_info_lines[@]}; ++t )); do + parts=(${(@s. .)trackers_info_lines[$t]}) + if [[ ( ${parts[1]} == "Tracker" && ${parts[2]} =~ "[0-9]+:" ) ]]; then + trackers_ids+=("${parts[2]%:}") + # descriptions passed to _describe need to have their ':' quoted. + trackers_urls+=("${parts[3]//:/\\:}") + fi + done + if [[ -z "${trackers_ids}" ]]; then + _message -r "Specified torrent has no trackers" + return + fi + _describe -t trackers-remove "tracker" trackers_urls trackers_ids +} + +# The real thing goes here +_arguments \ + "${general_options[@]}" \ + "${global_only_actions[@]}" \ + "${general_actions[@]}" \ + "${torrent_add_options[@]}" \ + "${torrent_action_only_actions[@]}" diff --git a/Completion/Unix/Command/_tree b/Completion/Unix/Command/_tree index 4fd9aed44..595249126 100644 --- a/Completion/Unix/Command/_tree +++ b/Completion/Unix/Command/_tree @@ -49,6 +49,7 @@ _arguments -s -S \ '(-n -C -X)-H[turn on HTML output]:base HREF' \ '(-n -C -X)-T[title for HTML output]:title' \ '(-n -C -X)--nolinks[turn off hyperlinks in HTML output]' \ + '--fromfile[read paths from specified files]' \ '(-)--version[version of tree]' \ '(-)--help[verbose usage listing]' \ '*:directory:_files -/' diff --git a/Completion/Unix/Command/_unison b/Completion/Unix/Command/_unison index 5725575c5..2a3333742 100644 --- a/Completion/Unix/Command/_unison +++ b/Completion/Unix/Command/_unison @@ -34,7 +34,7 @@ _arguments \ '-backups[keep backup copies of all files]' \ '-backupsuffix[a suffix to be added to names of backup files]:suffix:' \ '-confirmbigdel[ask about whole-replica (or path) deletes (default true)]' \ - '-confirmmerge[ask for confirmation before commiting results of a merge]' \ + '-confirmmerge[ask for confirmation before committing results of a merge]' \ '-contactquietly[suppress the "contacting server" message during startup]' \ '-copyprog[external program for copying large files]:program:_files -g "*(-x)"' \ '-copyprogrest[variant of copyprog for resuming partial transfers]:program:_files -g "*(-x)"' \ @@ -61,7 +61,7 @@ _arguments \ '-maxthreads[maximum number of simultaneous file transfers]:number:' \ '-merge[add a pattern to the merge list]:pattern:' \ '-mountpoint[abort if this path does not exist]:mountpoint:_files -/' \ - '-numericids[dont map uid/gid values by user/group names]' \ + "-numericids[don't map uid/gid values by user/group names]" \ '-preferpartial[add a pattern to the preferpartial list]:pattern:' \ '-pretendwin[use creation times for detecting updates]' \ '-repeat[synchronize repeatedly (text interface only)]:repeat:' \ diff --git a/Completion/Unix/Command/_user_admin b/Completion/Unix/Command/_user_admin index fe28c13f5..c7e1efc80 100644 --- a/Completion/Unix/Command/_user_admin +++ b/Completion/Unix/Command/_user_admin @@ -103,10 +103,10 @@ case ${service%???}:${(M)service%???}:$OSTYPE in user:mod:linux*) args+=( '(-a --append)'{-a,--append}'[add user to supplementary groups without removing from other groups]' - \*{-v,--add-sub-uids}'[add a range of subordinate uids]:uids (first-last)' - \*{-V,--del-sub-uids}'[remove a range of subordinate uids]:uids (first-last)' - \*{-w,--add-sub-gids}'[add a range of subordinate gids]:gids (first-last)' - \*{-W,--del-sub-gids}'[remove a range of subordinate gids]:gids (first-last)' + \*{-v,--add-subuids}'[add a range of subordinate uids]:uids (first-last)' + \*{-V,--del-subuids}'[remove a range of subordinate uids]:uids (first-last)' + \*{-w,--add-subgids}'[add a range of subordinate gids]:gids (first-last)' + \*{-W,--del-subgids}'[remove a range of subordinate gids]:gids (first-last)' ) ;| user:mod:*) diff --git a/Completion/Unix/Command/_uzbl b/Completion/Unix/Command/_uzbl deleted file mode 100644 index 570b20266..000000000 --- a/Completion/Unix/Command/_uzbl +++ /dev/null @@ -1,10 +0,0 @@ -#compdef uzbl uzbl-browser uzbl-tabbed - -_arguments \ - '(-u --uri)'{-u,--uri=}':uri to load:_urls' \ - '(-v --verbose)'{-v,--verbose}'[verbose]' \ - '(-n --name)'{-n,--name=}':instance name' \ - '(-c --config)'{-c,--config=}':config file:_files' \ - '--display=:X display:_x_display' \ - '--help[help]' - diff --git a/Completion/Unix/Command/_vim b/Completion/Unix/Command/_vim index 8853fac30..d9dc1a5b3 100644 --- a/Completion/Unix/Command/_vim +++ b/Completion/Unix/Command/_vim @@ -19,69 +19,86 @@ typeset -A opt_args local arguments arguments=( - '( -e -E -s -d -y)-v[vi mode]' - '(-v -E -d -y)-e[ex mode]' - '(-v -e -d -y)-E[improved ex mode]' - '(-v -e -E -s -d )-y[easy mode]' '-m[modifications (writing files) not allowed]' '-M[modifications in text not allowed]' '-b[binary mode]' '-l[lisp mode]' - '-C[start in compatible mode]' - '-N[start in incompatible mode]' - '(--nofork -f)'{--nofork,-f}'[do not detach the GUI version from the shell]' '-V-[verbosity level]::verbosity [10]:->verbosity' '-D[debugging mode]' '-n[no swap file (memory only)]' - '-nb[start as NetBean server]' {-r,-L}'[list swap files and exit or recover from a swap file]::swap file:_vim_files -g "*.sw?(-.)"' '( -H -F)-A[start in Arabic mode]' '(-A -F)-H[start in Hebrew mode]' '(-A -H )-F[start in Farsi mode]' - '-T[set terminal type]:::_terminals' - '--not-a-term[skip warning for input/output not being a terminal]' - '--ttyfail[exit if input or output is not a terminal]' '-u[use given vimrc file instead of default .vimrc]:config:->config' "--noplugin[don't load plugin scripts]" '-o-[number of windows to open (default: one for each file)]::window count: ' '-O-[number of windows to vertically split open (default is one for each file)]::window count: ' '-p-[number of tabs to open (default: one for each file)]::tab count: ' - '(* -t)-q-[quickfix file]:*:file:_vim_files' + '(* -t)-q+[quickfix file]::file:_files' '*--cmd[execute given command before loading any RC files]:command: ' '-c[execute given command after loading the first file]:command: ' - '-S[source a session file after loading the first file]:session file:_files' + '-S[source a session file after loading the first file]::session file:_files' '-s[read normal-mode commands from script file]:script file:_files' '-w[append all typed commands to given file]:output file:_files' '-W[write all typed commands to given file, overwriting existing file]:output file:_files' - '-x[edit encrypted files]' - '-X[do not connect to X server]' - '--remote[edit given files in a vim server if possible]:*:file:_vim_files' - '--remote-silent[as --remote but without complaining if not possible]:*:file:_vim_files' - '--remote-wait[as --remote but wait for files to have been edited]:*:file:_vim_files' - '--remote-wait-silent[as --remote-wait but without complaining if not possible]:*:file:_vim_files' - '--remote-send[send given keys to vim server if possible]:keys: ' - '--remote-tab[as --remote but open tab page for each file]:*:file:_vim_files' - '--remote-tab-silent[as --remote-silent but open tab page for each file]:*:file:_vim_files' - '--remote-tab-wait[as --remote-wait but open tab page for each file]:*:file:_vim_files' - '--remote-tab-wait-silent[as --remote-wait-silent but open tab page for each file]:*:file:_vim_files' - '--remote-expr[evaluate given expression in a vim server and print result]:expression: ' - '--literal[do not expand wildcards in arguments (this is useless with ZSH)]' - '(- *)--serverlist[list available vim servers and exit]' - '--servername[name of vim server to send to or name of server to become]:server name:->server' '--startuptime[write startup timing messages to given file]:log file:_files' - '--socketid[run GVIM in another window]' - '-i[use specified viminfo file]:viminfo file [~/.viminfo]:_files' '(- *)'{-h,--help}'[print help and exit]' '(- *)--version[print version information and exit]' - '(* -q)-t[edit file where tag is defined]:tag:_complete_tag' + '(* -q)-t+[edit file where tag is defined]:tag:_complete_tag' '(-t -q)*:file:_vim_files' - '--clean[start with defaults in non-compatible mode]' ) -[[ $service != *g* ]] && arguments+='-g[start with GUI]' +if [[ $service = nvim ]]; then + arguments+=( + '(-e -E -es -Es -s -d)-e[ex mode, read stdin as ex command]' + '(-e -E -es -Es -s -d)-E[ex mode, read stdin as text]' + '(-e -E -es -Es -s -d)-es[silent mode, read stdin as ex command]' + '(-e -E -es -Es -s -d)-Es[silent mode, read stdin as text]' + '-i[use the specified shada file]:shada file:_files' + '(- *)-v[print version information and exit]' + '(- *)--api-info[print msgpack-encoded api-metadata and exit]' + '--headless[do not start user interface]' + '--embed[use standard input and output as a msgpack-rpc channel]' + '--listen[start RPC server on the specified socket or named pipe]:address' + ) +else + arguments+=( + '(-v -E -d -y)-e[ex mode]' + '(-v -e -d -y)-E[improved ex mode]' + '( -e -E -s -d -y)-v[vi mode]' + '(-v -e -E -s -d )-y[easy mode]' + '-C[start in compatible mode]' + '-N[start in incompatible mode]' + '-nb[start as NetBean server]' + '-T[set terminal type]:::_terminals' + '--not-a-term[skip warning for input/output not being a terminal]' + '--ttyfail[exit if input or output is not a terminal]' + '-X[do not connect to X server]' + '-x[edit encrypted files]' + '--remote[edit given files in a vim server if possible]:*:file:_vim_files' + '--remote-silent[as --remote but without complaining if not possible]:*:file:_vim_files' + '--remote-wait[as --remote but wait for files to have been edited]:*:file:_vim_files' + '--remote-wait-silent[as --remote-wait but without complaining if not possible]:*:file:_vim_files' + '--remote-send[send given keys to vim server if possible]:keys: ' + '--remote-tab[as --remote but open tab page for each file]:*:file:_vim_files' + '--remote-tab-silent[as --remote-silent but open tab page for each file]:*:file:_vim_files' + '--remote-tab-wait[as --remote-wait but open tab page for each file]:*:file:_vim_files' + '--remote-tab-wait-silent[as --remote-wait-silent but open tab page for each file]:*:file:_vim_files' + '--remote-expr[evaluate given expression in a vim server and print result]:expression: ' + '--literal[do not expand wildcards in arguments (this is useless with ZSH)]' + '(- *)--serverlist[list available vim servers and exit]' + '--servername[name of vim server to send to or name of server to become]:server name:->server' + '--socketid[run GVIM in another window]' + '-i[use specified viminfo file]:viminfo file [~/.viminfo]:_files' + '--clean[start with defaults in non-compatible mode]' + ) +fi +[[ $service != *g* && $service != nvim ]] && arguments+='-g[start with GUI]' [[ $service != r* ]] && arguments+='-Z[restricted mode]' -[[ $service != *diff ]] && arguments+='(-v -e -E -s -y)-d[diff mode]' +[[ $service != *diff ]] && arguments+='(-v -e -E -es -Es -s -y)-d[diff mode]' [[ $service != *view ]] && arguments+='-R[readonly mode]' [[ $service = *g* ]] || (( ${words[(I)-g]} )) && arguments+=( + '(--nofork -f)'{--nofork,-f}'[do not detach the GUI version from the shell]' '-font:font:_xft_fonts' '-geometry:geometry:_x_geometry' '(-rv -reverse)'{-rv,-reverse}'[use reverse video]' diff --git a/Completion/Unix/Command/_vmstat b/Completion/Unix/Command/_vmstat index 7d3008592..f3ac1af14 100644 --- a/Completion/Unix/Command/_vmstat +++ b/Completion/Unix/Command/_vmstat @@ -21,15 +21,28 @@ case $OSTYPE in '(- :)'{-D,--disk-sum}'[summarize disk statistics]' ) ;; - *bsd*) + *bsd*|dragonfly*) specs=( '-c+[specify number of times to refresh the display]:count' - '-f[report on the number fork syscalls since boot and pages of virtual memory for each]' '-i[report the number of interrupts taken by devices since boot]' '-M+[specify core file to extract values associated with the name list from]:core:_files' '-N+[specify file to extract the name list from]:system:_files' '-w+[specify delay between each display]:delay (seconds)' - '*:disk:_files' + '*: :_bsd_disks' + ) + ;| + *bsd*) + specs+=( + '-f[report on the number fork syscalls since boot and pages of virtual memory for each]' + ) + ;| + freebsd*|dragonfly*) + specs+=( + '-m[report on the usage of kernel dynamic memory allocated using malloc(9) by type]' + '-n+[change the maximum number of disks to display]:number of disks to display [2]' + '*-p+[specify which types of devices to display]: :->devices' + '-s[display the contents of the SUM structure]' + '-z[report on memory used by the kernel zone allocator, uma(9), by zone]' ) ;| freebsd*) @@ -37,13 +50,8 @@ case $OSTYPE in '-a[include statistics about all interrupts]' '-h[human readable memory columns output]' '-H[scriptable memory columns output]' - '-m[report on the usage of kernel dynamic memory allocated using malloc(9) by type]' - '-n+[change the maximum number of disks to display]:number of disks to display' '-o[list virtual memory objects]' '-P[report per-cpu system/user/idle cpu statistics]' - '-p+[specify which types of devices to display]: :->devices' - '-s[display the contents of the SUM structure]' - '-z[report on memory used by the kernel zone allocator, uma(9), by zone]' ) ;| (net|open)bsd*) @@ -73,12 +81,14 @@ case $OSTYPE in '-W[print more information about kernel memory pools]' ) ;; - freebsd*|solaris*) + dragonfly*) specs+=( - '::disk:_files -W /dev -g "*(-%b)"' - ': :_guard "[0-9]#" "interval (seconds)"' ':count' + '-b[use brief format for formatted numbers]' + '-o[report usage of kernel object cache]' + '-u[output unformatted numeric values]' + '-v[include IRQ numbers and IRQ target CPU numbers before device names (with -i)]' ) - ;| + ;; solaris2.<11->) specs+=( '(-i -s)-T+[specify time format]:time format:((u\:seconds\ since\ epoch d\:standard\ date\ format))' ) ;& @@ -90,30 +100,20 @@ case $OSTYPE in '-p[report paging activity]' '(-T)-s[display the total number of system events since boot]' '-S[report on swapping rather than paging activity]' + '::disk:_files -W /dev -g "*(-%b)"' + ': :_guard "[0-9]#" "interval (seconds)"' '::count' ) ;; esac if (( $#specs )); then local curcontext=$curcontext state state_descr line ret=1 - typeset -A {opt,val}_args + typeset -A opt_args _arguments -C -s -w -A '-*' : "$specs[@]" && ret=0 if [[ $state == devices ]]; then - local -a types - types=( - 'da[direct access devices]' 'sa[sequential access devices]' - 'printer[printers]' 'proc[processor devices]' - 'worm[write once read multiple devices]' 'cd[CD devices]' - 'scanner[scanner devices]' 'optical[optical memory devices]' - 'changer[medium changer devices]' 'comm[communication devices]' - 'array[storage array devices]' 'enclosure[enclosure services devices]' - 'floppy[floppy devices]' 'IDE[Integrated Drive Electronics devices]' - 'SCSI[Small Computer System Interface devices]' - 'other[any other device interface]' 'pass[passthrough devices]' - ) - _values -s , 'device type' "$types[@]" && ret=0 + _fbsd_device_types && ret=0 elif [[ $state == hashes ]]; then local -a tables tables=( ${${${(f)"$(_call_program hashes $words[1] -L)"}[2,-1]#?}/ ##/:} ) diff --git a/Completion/Unix/Command/_vux b/Completion/Unix/Command/_vux deleted file mode 100644 index 1ed56dca6..000000000 --- a/Completion/Unix/Command/_vux +++ /dev/null @@ -1,63 +0,0 @@ -#compdef vux vuxctl - -local expl - -case "$service" in - (vux) - - _arguments -s -C \ - '-x:action:((play\:play\ music generate\:generate\ new\ scorelist - merge\:merge\ new\ songs - weed\:prune\ songs\ from\ scorelist - ratings\:show\ statistics force\:force-rate))' \ - '-s:file:_files' \ - '-a:file:_files' \ - '-z:file:_files' \ - '-y:file:_files' \ - '-p:file:_files' \ - '-w:ratings:(b t)' \ - '-W:repeats:(a c)' \ - '-G:age bypass method:(t s n)' \ - '-e:pattern' \ - '-O:device:_files' \ - '-M:minimum age val' \ - '-S[disable saving scorelist]' \ - '-A[disable saving agelist]' \ - '-Z[disable saving countlist]' \ - '-Y[disable missing log]' \ - '-c[disable rating check]' \ - '-d[disable rating updates on play]' \ - '-l[disable rating updates on skip]' \ - '-j[disable repeat check]' \ - '-b[disable repeat updates on play]' \ - '-k[disable repeat updates on skip]' \ - '-n[disable player]' \ - '-t:percent' \ - '-T:percent' \ - '-C:factor' \ - '-D:factor' \ - '-I:factor' \ - '-U:rating' \ - '-X:score' \ - '-N:count' \ - '-f:rating' \ - '-J[accelerate decreases]' \ - '-K[accelerate increases]' \ - '-u[check age before rating]' \ - '-R[show ratings after processing]' \ - '-V[verbose file manipulation]' \ - '-v[show version and exit]' \ - '-F[skip songs with -n and -xf]' \ - '-q[minimize vux output]' \ - '-P[always play new songs]' \ - '-g[print stats in xgraph format]' \ - '-h[show summary of options]' - ;; - - (vuxctl) - - _wanted vuxcmd expl 'vux control command' \ - compadd start clean double half up down next previous forward \ - replay pause resume stop reload save history help - ;; -esac diff --git a/Completion/Unix/Command/_wget b/Completion/Unix/Command/_wget index 2a4e722d8..49c8e8b01 100644 --- a/Completion/Unix/Command/_wget +++ b/Completion/Unix/Command/_wget @@ -16,6 +16,7 @@ _arguments -C -s \ '*-n+[turn off flags]:flags:->noflags' \ '--report-speed=:type:(bits)' \ '(--input-file -i)'{--input-file=,-i+}'[specify input file]:file containing URLs:_files' \ + '--input-metalink=[download files covered in local Metalink file]:file:_files' \ '(--force-html -F)'{--force-html,-F}'[treat input file as html]' \ '(--base -B)'{--base=,-B+}'[prepend URL to relative links]:base URL:_urls' \ '--config=[specify config file]:config file:_files' \ @@ -57,7 +58,11 @@ _arguments -C -s \ '--local-encoding=[specify local encoding for IRIs]:encoding' \ '--remote-encoding=[specify default remote encoding]:encoding' \ '--unlink[remove file before clobber]' \ - '--no-xattr[turn off storage of metadata in extended file attributes]' \ + '--keep-badhash[Keep files with checksum mismatch (append .badhash)]' \ + '--metalink-index=[metalink application/metalink4+xml metaurl ordinal]:number' \ + '--metalink-over-http[use Metalink metadata from HTTP response headers]' \ + '--preferred-location[preferred location for Metalink resources]' \ + '--xattr[turn on storage of metadata in extended file attributes]' \ '(-nd --no-directories)'{-nd,--no-directories}"[don't create directories]" \ '(--force-directories -x)'{--force-directories,-x}'[force creation of directories]' \ '(-nH --no-host-directories)'{-nH,--no-host-directories}"[don't create host directories]" \ @@ -102,7 +107,7 @@ _arguments -C -s \ "--ca-directory=[specify dir where hash list of CA's are stored]:directory:_directories" \ '--crl-file=[specify file with bundle of CRLs]:file:_files' \ '--pinnedpubkey=:file:_files' \ - '--random-file[specify file with random data for seeding generator]:file:_files' \ + '!--random-file=:file:_files' \ '--egd-file=[specify filename of EGD socket]:file:_files' \ '--ciphers=[set the priority string (GnuTLS) or cipher list string (OpenSSL) directly]:string' \ '--no-hsts[disable HSTS]' \ diff --git a/Completion/Unix/Command/_xargs b/Completion/Unix/Command/_xargs index 8b543341d..f21784ef1 100644 --- a/Completion/Unix/Command/_xargs +++ b/Completion/Unix/Command/_xargs @@ -47,6 +47,7 @@ case $variant in '(-0 --null -d --delimiter)'{-0,--null}'[expect NUL characters as input separators]' '(-d --delimiter -0 --null)'{-d+,--delimiter=}'[specify delimiter of input items]:delimiter' '(-l -L --max-lines -n --max-args -s --max-chars)--max-lines=-[call program for every number of lines]::number of input lines' + '(-o --open-tty)'{-o,--open-tty}'[reopen stdin as /dev/tty in the child process before executing the command]' '--process-slot-var=[set environment variable to unique value in child processes]:variable:_parameters -g "*export*"' '(-r --no-run-if-empty)'{-r,--no-run-if-empty}"[don't run command in absence of input]" '(- *)--help[show help information]' diff --git a/Completion/Unix/Command/_xmlsoft b/Completion/Unix/Command/_xmlsoft index 7b4b0b03d..487974fdb 100644 --- a/Completion/Unix/Command/_xmlsoft +++ b/Completion/Unix/Command/_xmlsoft @@ -53,7 +53,7 @@ case $service in '--catalogs[use SGML catalogs]' \ '--xinclude[do XInclude processing on document input]' \ '--xincludestyle[do XInclude processing on stylesheets]' \ - '--load-trace[print trace of all external entites loaded]' \ + '--load-trace[print trace of all external entities loaded]' \ {--profile,--norman}'[dump profiling information]' \ '1:stylesheet:_files -g "*.xslt#(-.)"' \ ':file:_files -g "*.xml(-.)"' && return @@ -71,7 +71,7 @@ case $service in '--noenc[ignore any encoding specified inside the document]' \ "(--output -o)--noout[don't output the result tree]" \ '--path[provide a set of paths for resources]:paths:_files -/' \ - '--load-trace[print trace of all external entites loaded]' \ + '--load-trace[print trace of all external entities loaded]' \ '--nonet[refuse to fetch DTDs or entities over network]' \ '--nocompact[do not generate compact text nodes]' \ '--htmlout[output results as HTML]' \ diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs index ce5df5877..814358bc7 100644 --- a/Completion/Unix/Command/_zfs +++ b/Completion/Unix/Command/_zfs @@ -145,7 +145,6 @@ _zfs() { # set the sorting for *size properties to false by default? rw_properties=( "aclinherit:value:(discard noallow restricted passthrough passthrough-x)" - "aclmode:value:(discard mask passthrough)" "atime:value:(on off)" "canmount:value:(on off noauto)" "checksum:value:(on off fletcher2 fletcher4 sha256 sha256+mac)" @@ -185,6 +184,15 @@ _zfs() { $share_rw_properties ) + if [[ "$OSTYPE" == "linux-gnu" ]]; then + rw_properties+=("acltype:value:(off noacl posixacl)") + elif [[ "$implementation" == "solaris" ]]; then + rw_properties+=("aclmode:value:(discard mask passthrough)") + else + rw_properties+=("aclmode:value:(discard groupmask passthrough restricted)") + fi + + create_properties=( $rw_properties "casesensitivity:value:(sensitive insensitive mixed)" diff --git a/Completion/Unix/Command/_zpool b/Completion/Unix/Command/_zpool index 4d4793eea..d9c2caa52 100644 --- a/Completion/Unix/Command/_zpool +++ b/Completion/Unix/Command/_zpool @@ -14,7 +14,7 @@ _zpool() { ) if [[ $implementation = openzfs ]] && [[ $OSTYPE != solaris* ]]; then - subcmds+=(labelclear) + subcmds+=( labelclear initialize ) fi versions=( @@ -158,6 +158,14 @@ _zpool() { '::pool name:_zfs_pool' ;; + (initialize) + _arguments -A "-*" \ + '(-c --cancel)'{-c,--cancel}'[cancel initializing on specified devices]' \ + '(-s --suspend)'{-s,--suspend}'[suspend initializing on specified devices]' \ + ':pool name:_zfs_pool' \ + '*:device:_files' + ;; + (iostat) _arguments -A "-*" \ '-l[Display configuration in /dev/chassis location form]' \ diff --git a/Completion/Unix/Type/_baudrates b/Completion/Unix/Type/_baudrates index add359d13..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. # @@ -72,7 +72,6 @@ if (( ${+opts[-f]} )); then done fi -# -1V removes dupes (which there shouldn't be) and otherwise leaves the -# order in the $rates array intact. -_description -1V baud-rates expl 'baud rate' -compadd "${(@)argv/#-J/-V}" "$expl[@]" -- "${rates[@]}" +# -1 removes dupes (which there shouldn't be) +_description -1 -o numeric baud-rates expl 'baud rate' +compadd "${argv[@]}" "$expl[@]" -- "${rates[@]}" diff --git a/Completion/Unix/Type/_canonical_paths b/Completion/Unix/Type/_canonical_paths index 6eab7b677..a8fbbb524 100644 --- a/Completion/Unix/Type/_canonical_paths +++ b/Completion/Unix/Type/_canonical_paths @@ -5,13 +5,14 @@ # (relative path when an absolute path is given, and vice versa; when ..'s are # present in the word to be completed, and some paths got from symlinks). -# Usage: _canonical_paths [-A var] [-N] [-MJV12nfX] tag desc [paths...] +# Usage: _canonical_paths [-A var] [-N] [-MJV12onfX] tag desc [paths...] # -A, if specified, takes the paths from the array variable specified. Paths # can also be specified on the command line as shown above. -N, if specified, # prevents canonicalizing the paths given before using them for completion, in # case they are already so. `tag' and `desc' arguments are well, obvious :) In -# addition, the options -M, -J, -V, -1, -2, -n, -F, -X are passed to compadd. +# addition, the options -M, -J, -V, -1, -2, -o, -n, -F, -x, -X are passed to +# compadd. _canonical_paths_add_paths () { # origpref = original prefix @@ -59,7 +60,7 @@ _canonical_paths() { local __index typeset -a __gopts __opts - zparseopts -D -a __gopts M: J: V: 1 2 n F: X: A:=__opts N=__opts + zparseopts -D -a __gopts M+: J+: V+: o+: 1 2 n F: x+: X+: A:=__opts N=__opts : ${1:=canonical-paths} ${2:=path} @@ -95,7 +96,7 @@ _canonical_paths() { # This style controls how many parent directory links (..) to chase searching # for possible completions. The default is 8. Note that this chasing is - # triggered only when the user enters atleast a .. and the path completed + # triggered only when the user enters at least a .. and the path completed # contains only . or .. components. A value of 0 turns off .. link chasing # altogether. diff --git a/Completion/Unix/Type/_dates b/Completion/Unix/Type/_dates index 0af10eb24..b75b3af0c 100644 --- a/Completion/Unix/Type/_dates +++ b/Completion/Unix/Type/_dates @@ -73,7 +73,7 @@ for ((;rows;rows--)); do (( spacing = COLUMNS - 32 * columns + 2 )) disp[-1]="${(l.spacing.)}" (( spacing < 2 )) && spacer=0 disp[-1]=() - expl[1+expl[(i)-V]]=dates-$rows + expl[1+expl[(i)-J]]=dates-$rows compadd -x "$mlabels" "$expl[@]" -d disp -E $(( $#disp )) for ((line=0;line<6;line++)); do diff --git a/Completion/Unix/Type/_diff_options b/Completion/Unix/Type/_diff_options index 4fd27442e..440913dff 100644 --- a/Completion/Unix/Type/_diff_options +++ b/Completion/Unix/Type/_diff_options @@ -92,6 +92,7 @@ if _pick_variant -r variant -c $cmd gnu=GNU unix -v || [[ $OSTYPE = freebsd<12-> '--ignore-file-name-case[ignore case when comparing file names]' \ '!(--ignore-file-name-case)--no-ignore-file-name-case' \ '(-b --ignore-space-change)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \ + '(-w --ignore-all-space)'{-w,--ignore-all-space}'[ignore all white space]' \ '(-B --ignore-blank-lines)'{-B,--ignore-blank-lines}'[ignore lines that are all blank]' \ '(-I --ignore-matching-lines)'{-I+,--ignore-matching-lines=}'[ignore lines that match regex]:line exclusion regex:' \ '--strip-trailing-cr[strip trailing carriage return on input]' \ diff --git a/Completion/Unix/Type/_directories b/Completion/Unix/Type/_directories index 438181eec..dc92e6c34 100644 --- a/Completion/Unix/Type/_directories +++ b/Completion/Unix/Type/_directories @@ -1,4 +1,4 @@ -#compdef zf_rmdir dircmp -P -value-,*path,-default- +#compdef dircmp -P -value-,*path,-default- local expl diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files index 467ed747c..6adaa8154 100644 --- a/Completion/Unix/Type/_files +++ b/Completion/Unix/Type/_files @@ -27,7 +27,7 @@ local opts tmp glob pat pats expl tag i def descr end ign tried local type sdef ignvars ignvar prepath oprefix rfiles rfile zparseopts -a opts \ - '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: X+: M+: F: J+: V+: + '/=tmp' 'f=tmp' 'g+:-=tmp' q n 1 2 P: S: r: R: W: x+: X+: M+: F: J+: V+: o+: type="${(@j::M)${(@)tmp#-}#?}" if (( $tmp[(I)-g*] )); then diff --git a/Completion/Unix/Type/_ld_debug b/Completion/Unix/Type/_ld_debug index 94593eff0..5c10faa02 100644 --- a/Completion/Unix/Type/_ld_debug +++ b/Completion/Unix/Type/_ld_debug @@ -31,6 +31,7 @@ case $OSTYPE in linux*) vals+=( 'all[combine all options]' + 'scopes[display scope information]' 'statistics[display relocation statistics]' ) ;; diff --git a/Completion/Unix/Type/_list_files b/Completion/Unix/Type/_list_files index 6c52bc1f4..0ea02a55a 100644 --- a/Completion/Unix/Type/_list_files +++ b/Completion/Unix/Type/_list_files @@ -64,6 +64,6 @@ for f in ${(PQ)1}; do ${(r:8:)stat[gid]} ${(l:8:)stat[size]} $stat[mtime] $f") done -(( ${#listfiles} )) && listopts=(-d listfiles -l -o) +(( ${#listfiles} )) && listopts=(-d listfiles -l -o match) return 0 diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files index 1021c34e6..06d9d8d51 100644 --- a/Completion/Unix/Type/_path_files +++ b/Completion/Unix/Type/_path_files @@ -59,7 +59,7 @@ exppaths=() zparseopts -a mopts \ 'P:=pfx' 'S:=pfxsfx' 'q=pfxsfx' 'r:=pfxsfx' 'R:=pfxsfx' \ 'W:=prepaths' 'F:=ignore' 'M+:=matcher' \ - J+: V+: X+: 1 2 n 'f=tmp1' '/=tmp1' 'g+:-=tmp1' + J+: V+: x+: X+: 1 2 o+: n 'f=tmp1' '/=tmp1' 'g+:-=tmp1' sopt="-${(@j::M)${(@)tmp1#-}#?}" (( $tmp1[(I)-[/g]*] )) && haspats=yes @@ -168,7 +168,7 @@ if zstyle -s ":completion:${curcontext}:" file-sort tmp1; then if [[ "$sort" = on ]]; then sort= else - mopts=( "${(@)mopts/#-J/-V}" ) + mopts=( -o nosort "${mopts[@]}" ) tmp2=() for tmp1 in "$pats[@]"; do @@ -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/Completion/Unix/Type/_pids b/Completion/Unix/Type/_pids index 8edb33529..d1523fc43 100644 --- a/Completion/Unix/Type/_pids +++ b/Completion/Unix/Type/_pids @@ -1,4 +1,4 @@ -#compdef pflags pcred pmap pldd psig pstack pfiles pwdx pstop prun pwait +#compdef pflags pcred pldd psig pstack pfiles pwdx pstop prun pwait # If given the `-m <pattern>' option, this tries to complete only pids # of processes whose command line match the `<pattern>'. diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files index 267715a51..3fa5779c8 100644 --- a/Completion/Unix/Type/_remote_files +++ b/Completion/Unix/Type/_remote_files @@ -59,7 +59,10 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then fi # remote filenames - remfiles=(${(M)${(f)"$(_call_program files $cmd $cmd_args $host ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) + remfiles=(${(M)${(f)"$( + _call_program files $cmd $cmd_args $host \ + command ls -d1FL -- "$rempat" 2>/dev/null + )"}%%[^/]#(|/)}) compset -P '*/' compset -S '/*' || (( ${args[(I)-/]} )) || suf='remote file' diff --git a/Completion/X/Command/_gv b/Completion/X/Command/_gv index d4dbed089..cde8a1c1a 100644 --- a/Completion/X/Command/_gv +++ b/Completion/X/Command/_gv @@ -22,7 +22,6 @@ _arguments \ '(--watch)--nowatch' \ '(--noresize)--resize' \ '(--resize)--noresize' \ - '(--grayscale --color)--monochrome' \ '(--monochrome --color)--grayscale' \ '(--grayscale --color)--monochrome' \ '(--landscape --seascape --upsidedown)--portrait' \ diff --git a/Completion/X/Command/_setxkbmap b/Completion/X/Command/_setxkbmap index 486268ed7..882a6f939 100644 --- a/Completion/X/Command/_setxkbmap +++ b/Completion/X/Command/_setxkbmap @@ -23,7 +23,7 @@ _setxkbmap() { local -a arguments arguments=( - '-compat[compability map]:compability:_setxkbmap_compat' + '-compat[compatibility map]:compatibility:_setxkbmap_compat' '-config[configuration file]:configuration:_files' '-display[display]:display:_x_display' '-geometry[geometry component]:geometry:_setxkbmap_geometry' diff --git a/Completion/X/Command/_vnc b/Completion/X/Command/_vnc index 70b897e47..d60616f21 100644 --- a/Completion/X/Command/_vnc +++ b/Completion/X/Command/_vnc @@ -33,7 +33,7 @@ case $service in '-ls[limit stack space to N Kb]:int:' \ '-nolock[disable the locking mechanism]' \ '-logo[enable logo in screen saver]' \ - '-nolisten[dont listen on protocol]:protocol:(tcp)' \ + "-nolisten[don't listen on protocol]:protocol:(tcp)" \ '-p[screen-saver pattern duration (minutes)]:time (minutes):' \ '-pn[accept failure to listen on all ports]' \ '-nopn[reject failure to listen on all ports]' \ @@ -61,7 +61,7 @@ case $service in '-udpinputport[UDP port for keyboard/pointer data]:port:' \ '-rfbport[TCP port for RFB protocol]:port:' \ '-rfbwait[max time in ms to wait for RFB client]:time:' \ - '-nocursor[dont put up a cursor]' \ + "-nocursor[don't put up a cursor]" \ '-rfbauth[use authentication on RFB protocol]:passwd-file:_files' \ '-httpd[serve files via HTTP from here]:dir:_files -/' \ '-httpport[port for HTTP]:port:' \ @@ -71,7 +71,7 @@ case $service in '-desktop[VNC desktop name (default x11)]:name:' \ '-alwaysshared[always treat new clients as shared]' \ '-nevershared[never treat new clients as shared]' \ - '-dontdisconnect[dont disconnect existing clients for new non-shared connections]' \ + "-dontdisconnect[don't disconnect existing clients for new non-shared connections]" \ '-viewonly[let clients only to view the desktop]' \ '-localhost[only allow connections from localhost]' \ '-interface[only bind to specified interface address]:ipaddr:' \ diff --git a/Completion/X/Command/_x_utils b/Completion/X/Command/_x_utils index 13c5572af..4b98ec48e 100644 --- a/Completion/X/Command/_x_utils +++ b/Completion/X/Command/_x_utils @@ -150,9 +150,10 @@ xon) ;; xsetroot) _x_arguments \ - -{help,def,gray,grey,rv} \ + -{help,version,def,default,gray,grey,rv,reverse} \ '-cursor:cursor file:_files -g \*.\(\#i\)\(xbm\|curs\(\|or\)\):mask file:_files -g \*.\(\#i\)\(xbm\|curs\(\|or\)\|mask\)\(-.\)' \ '-cursor_name:cursor name:_x_cursor' \ + '-xcf:cursor file:_files:size' \ '-bitmap:bitmap file:_files -g \*.\(\#i\)xbm\(-.\)' \ '-mod:x grid distance (1-16): :y grid distance (1-16)' \ '-fg:foreground color:_x_color' \ diff --git a/Completion/X/Command/_xrandr b/Completion/X/Command/_xrandr index 26d8cd082..67045b33d 100644 --- a/Completion/X/Command/_xrandr +++ b/Completion/X/Command/_xrandr @@ -46,6 +46,13 @@ _arguments -C \ '*--rmmode:Mode name:' \ "*--addmode:output:->outputs:name" \ "*--delmode:output:->outputs:name" \ + '--listproviders' \ + '--setprovideroutputsource:provider: :source' \ + '--setprovideroffloadsink:provider: :sink' \ + '--listmonitors' \ + '--listactivemonitors' \ + '--setmonitor:name' \ + '--delmonitor:name' \ && return 0 case $state in diff --git a/Completion/X/Command/_xterm b/Completion/X/Command/_xterm index 7619b280a..6d98985e7 100644 --- a/Completion/X/Command/_xterm +++ b/Completion/X/Command/_xterm @@ -1,12 +1,16 @@ #compdef xterm _xt_arguments \ - -+{ah,ai,aw,bc,bdc,cb,cm,cn,cu,dc,hf,ie,im,j,ls,mb,nul,pc,rw,s,sb,sf,si,sk,sp,t,u8,ulc,ut,vb,wc,wf,samename} \ - -{version,help,132,leftbar,rightbar,C} \ + -+{132,ah,ai,aw,bc,bdc,cb,cjk_width,cm,cn,cu,dc,fbb,fbx,fullscreen,hf,hm,hold,ie,im,itc,j,k8,l,lc,ls,maximized,mb,mesg,mk_width,nul,pc,pob,rvc,rw,s,samename,sb,sf,si,sk,sm,sp,t,u8,uc,ulc,ulit,ut,vb,wc,wf} \ + -{version,help,leftbar,rightbar,C} \ + '-report-'{charclass,colors,fonts} \ + '-T:title' \ '-b:inner border size:' \ + '-baudrate:rate [38400]' \ '-bcf:time text cursor is off when blinking (milliseconds):' \ '-bcn:time text cursor is on when blinking (milliseconds):' \ '-cc:character class:' \ + '-class:string' \ '-cr:text cursor color:_x_color' \ '-e:program: _command_names -e:*::program arguments: _normal' \ '-fa:font pattern:_xft_fonts' \ @@ -15,11 +19,14 @@ _xt_arguments \ '-hc:background color for highlighted text:_x_color' \ '-mc:multi-click threshold (milliseconds):' \ '-ms:pointer cursor color:_x_color' \ + '-n:icon name' \ '-nb:margin bell number:' \ + '-selbg:color:_x_color' \ + '-selfg:color:_x_color' \ + '-sh:scaling' \ '-sl:save lines:' \ '-ti:terminal ID:_terminals' \ '-tm:terminal setting:' \ '-tn:terminal type:' \ '-ziconbeep:iconbeep (percent):' \ - '-C' \ '-S-:pseudo-terminal and file descriptor:' diff --git a/Completion/X/Command/_zathura b/Completion/X/Command/_zathura deleted file mode 100644 index ebd229909..000000000 --- a/Completion/X/Command/_zathura +++ /dev/null @@ -1,47 +0,0 @@ -#compdef zathura - -(( $+functions[_zathura_files] )) || -_zathura_files(){ - local -a plugins_files - local plugins_dir - for plugins_dir in \ - ${(Qv)opt_args[(i)-p|--plugins-dir]}(#qN) \ - {/usr/local,/usr,}/lib/zathura(#qN) - do - plugins_files+=( $plugins_dir/*.so(N) ) - done - if [[ -z "${plugins_files}" ]]; then - _files -g "(#i)*.pdf(-.)" - return - fi - local -a supported_filetypes - local pf - for pf in "${plugins_files[@]}"; do - if [[ $pf =~ "mupdf" ]]; then - supported_filetypes+="pdf" - supported_filetypes+="epub" - supported_filetypes+="xps" - elif [[ $pf =~ "poppler" ]]; then - supported_filetypes+="pdf" - else - supported_filetypes+="${pf:t:r}" - fi - done - _files -g "(#i)*.(${(j.|.)${(@u)supported_filetypes}})(-.)" -} - -_arguments -s -S \ - {-e,--reparent=}'[specify xid of window to reparent to]:xid:_x_window' \ - {-c,--config-dir=}'[specify path to the config directory]:config directory:{_files -/}' \ - {-d,--data-dir=}'[specify path to the data directory]:data directory:{_files -/}' \ - {-p,--plugins-dir=}'[specify path to the directory containing plugins]:plugins directory:{_files -/}' \ - {-w,--password=}"[specify a password for the document]:password: " \ - {-P,--page=}'[open the document at the given page number]:page number: ' \ - {-l,--log-level=}'[set log level]:log level:(debug info warning error)' \ - {-x,--synctex-editor-command=}'[specify synctex editor command]:synctex editor command:_cmdstring' \ - '--synctex-forward=[jump to the given position]:synctex position: ' \ - '--synctex-pid=[specify pid of an instance having the correct file opened]:synctex pid:_pids' \ - '--fork[fork into background]' \ - '(- :)--version[display version string and exit]' \ - '(- :)--help[display help and exit]' \ - '*:file:_zathura_files' diff --git a/Completion/Zsh/Command/_builtin b/Completion/Zsh/Command/_builtin index 9fb6acf7b..ffb7b8c8d 100644 --- a/Completion/Zsh/Command/_builtin +++ b/Completion/Zsh/Command/_builtin @@ -3,7 +3,7 @@ if (( $CURRENT > 2 )); then shift words (( CURRENT -- )) - _normal + _normal -p $service else local expl diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command index 4e2858676..503f860a2 100644 --- a/Completion/Zsh/Command/_command +++ b/Completion/Zsh/Command/_command @@ -1,11 +1,7 @@ #compdef command -# indicate if this is a precommand modifier -[[ $service = command ]] && precommands+=(command) - _arguments \ '-v[indicate result of command search]:*:command:_path_commands' \ '-V[show result of command search in verbose form]:*:command:_path_commands' \ '(-)-p[use default PATH to find command]' \ - ':command:_path_commands' \ - '*::arguments: _normal' + '*:: : _normal -p $service' diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd index e709e400e..781fa2af8 100644 --- a/Completion/Zsh/Command/_compadd +++ b/Completion/Zsh/Command/_compadd @@ -14,9 +14,13 @@ _arguments -C -s -S -A "-*" \ '(-a)-k[matches are keys of specified associative arrays]' \ '-d+[specify display strings]:array:_parameters -g "*array*"' \ '-l[list display strings one per line, not in columns]' \ - '-o[order matches by match string not by display string]' \ - '(-1 -E)-J+[specify match group which will be sorted]:group' \ - '-V+[specify pre-ordered match group]:group' \ + '-o[specify order for matches by match string not by display string]:: : _values -s , order + "match[order by match not by display string]" + "nosort[matches are pre-ordered]" + "numeric[order numerically]" + "reverse[order backwards]"' \ + '(-1 -E)-J+[specify match group]:group' \ + '!-V+:group' \ '(-J -E)-1[remove only consecutive duplicates from group]' \ '-2[preserve all duplicates]' \ '(-x)-X[specify explanation]:explanation' \ @@ -45,7 +49,7 @@ if [[ -n $state ]]; then elif (( $+opt_args[-k] )); then _parameters -g "*assoc*" && ret=0 else - _message -e candidate candidates + _message -e candidates candidate fi fi diff --git a/Completion/Zsh/Command/_exec b/Completion/Zsh/Command/_exec index 8de341a02..2498b57c0 100644 --- a/Completion/Zsh/Command/_exec +++ b/Completion/Zsh/Command/_exec @@ -1,9 +1,7 @@ #compdef exec -[[ $service == exec ]] && precommands+=( exec ) - _arguments -s -S -A '-*' : \ '-a+[set argv\[0\] to specified string]:argv[0] string' \ '-c[clear environment]' \ '-l[simulate login shell (prepend - to argv\[0\])]' \ - '*:: : _normal' + '*:: : _normal -p $service' diff --git a/Completion/Zsh/Command/_precommand b/Completion/Zsh/Command/_precommand index c9eef78af..fd88074c0 100644 --- a/Completion/Zsh/Command/_precommand +++ b/Completion/Zsh/Command/_precommand @@ -1,9 +1,6 @@ #compdef - nohup eval time rusage noglob nocorrect catchsegv aoss hilite eatmydata -# precommands is made local in _main_complete -precommands+=($words[1]) - shift words (( CURRENT-- )) -_normal +_normal -p $service diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index fb7189c77..ae33ae539 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -61,6 +61,7 @@ case ${service} in '(-k -t -T -u -U -W -x -z -M +M +k +t +W +z)-+M[define mathematical function]' '(-k -m -t -T -u -U -W -x -z +M +k +t +W +z)-s[define mathematical function that takes a string argument]' '(-M)-x+[specify spaces to use for indentation]:spaces' + '(-* +*)-c[copy shell function to another name]:old name:_functions:new name:_functions' ) ;; integer) diff --git a/Completion/Zsh/Command/_zftp b/Completion/Zsh/Command/_zftp index 105533055..a41d72ce2 100644 --- a/Completion/Zsh/Command/_zftp +++ b/Completion/Zsh/Command/_zftp @@ -1,4 +1,4 @@ -#compdef -p zf* +#compdef -P zf* # Completion for zftp builtin and zf* functions. The functions # zfcd_match and zfget_match (also used for old-style completion) diff --git a/Completion/Zsh/Command/_zparseopts b/Completion/Zsh/Command/_zparseopts new file mode 100644 index 000000000..e13a91081 --- /dev/null +++ b/Completion/Zsh/Command/_zparseopts @@ -0,0 +1,37 @@ +#compdef zparseopts + +local ret=1 +local -a context line state state_descr alts opts +local -A opt_args + +_arguments -A '-*' : \ + '-a+[specify array in which to store parsed options]:array:_parameters -g "*array*~*readonly*"' \ + '-A+[specify association in which to store parsed options]:association:_parameters -g "*association*~*readonly*"' \ + '-D[remove parsed options from positional parameters]' \ + "-E[don't stop parsing at first parameter not described by specs]" \ + '-F[abort parsing and print error at first option-like parameter not described by specs]' \ + '-K[preserve contents of arrays/associations when specs are not matched]' \ + '-M[enable mapping among equivalent options with opt1=opt2 spec form]' \ + '(-)-[end zparseopts options; specs follow]' \ + '*: :->spec' \ +&& ret=0 + +[[ $state == spec ]] && +if compset -P '*='; then + alts=() + (( $+opt_args[-M] )) && { + opts=( $line ) + [[ $opts[1] == (-|--) ]] && shift opts + opts=( ${(@)opts%%(+|)(:|:-|::|)(=*|)} ) + opts=( ${(@)opts:#${words[CURRENT]%%=*}} ) + alts+=( "spec-opt-names:spec option name:(${(j< >)${(@q+)opts}})" ) + } + alts+=( 'parameters:array:_parameters -g "*array*~*readonly*"' ) + _alternative $alts && ret=0 +else + # Not great, but close enough for now + compset -S '=*' + _message -e spec-opts 'spec option (name[+][:|:-|::])' && ret=0 +fi + +return ret diff --git a/Completion/Zsh/Context/_brace_parameter b/Completion/Zsh/Context/_brace_parameter index a9ab44efd..6960cec9b 100644 --- a/Completion/Zsh/Context/_brace_parameter +++ b/Completion/Zsh/Context/_brace_parameter @@ -38,7 +38,7 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then case $char in (g) compset -P '*' - flags=('o:octal escapes' 'c:expand ^X etc.' 'e:expand \M-t etc.') + flags=('o:octal escapes' 'c:expand ^X etc.' 'e:expand \\M-t etc.') _describe -t format 'format option' flags -Q -S '' ;; @@ -177,7 +177,7 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then "s:split words on specified string" "Z:split words as if zsh command line (with options)" # "_:extended flags, for future expansion" - "S:search substrings in #, %, / expressions" + "S:match non-greedy in /, // or search substrings in % and # expressions" "I:search <argument>th match in #, %, / expressions" "B:include index of beginning of match in #, % expressions" "E:include index of one past end of match in #, % expressions" diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names index f8188774d..cd630b7a4 100644 --- a/Completion/Zsh/Type/_command_names +++ b/Completion/Zsh/Type/_command_names @@ -21,6 +21,8 @@ defs=( if [[ "$1" = -e ]]; then shift +elif (( ${#precommands:|builtin_precommands} )); then + # precommand excludes internal options below else [[ "$1" = - ]] && shift diff --git a/Completion/Zsh/Type/_file_descriptors b/Completion/Zsh/Type/_file_descriptors index 3e9f4968b..be96dd0e4 100644 --- a/Completion/Zsh/Type/_file_descriptors +++ b/Completion/Zsh/Type/_file_descriptors @@ -56,4 +56,4 @@ fi fds=( 0 1 2 $fds ) _description -V file-descriptors expl 'file descriptor' -compadd $disp "${@/-J/-V}" "$expl[@]" -a fds +compadd $disp -o nosort "$@" "$expl[@]" -a fds diff --git a/Completion/openSUSE/Command/_osc b/Completion/openSUSE/Command/_osc index 97263da7d..3c479aea8 100644 --- a/Completion/openSUSE/Command/_osc +++ b/Completion/openSUSE/Command/_osc @@ -119,7 +119,7 @@ _osc_cmd_do() { local -a cmdlist local tag=0 - # only start completion if theres some '-' on the line + # only start completion if there's some '-' on the line if ! [ "$words[2]" = "-" ]; then _complete return diff --git a/Config/version.mk b/Config/version.mk index 7d931f29b..2ddb92388 100644 --- a/Config/version.mk +++ b/Config/version.mk @@ -27,5 +27,5 @@ # This must also serve as a shell script, so do not add spaces around the # `=' signs. -VERSION=5.7.1 -VERSION_DATE='February 3, 2019' +VERSION=5.7.1-test-3 +VERSION_DATE='February 6, 2020' diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index cc9832379..ada69c99a 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -39,11 +39,11 @@ be familiar to most command line users. Typically, options are single letters preceded by a hyphen (tt(-)). Options that take an argument accept it either immediately following the -option letter or after white space, for example `tt(print -C3 *)' or -`tt(print -C 3 *)' are equivalent. Arguments to options are not the +option letter or after white space, for example `tt(print -C3 {1..9})' or +`tt(print -C 3 {1..9})' are equivalent. Arguments to options are not the same as arguments to the command; the documentation indicates which is which. Options that do not take an argument may be combined in a single -word, for example `tt(print -ca *)' and `tt(print -c -a *)' are +word, for example `tt(print -rca -- *)' and `tt(print -r -c -a -- *)' are equivalent. Some shell builtin commands also take options that begin with `tt(+)' @@ -54,14 +54,14 @@ Options (together with their individual arguments, if any) must appear in a group before any non-option arguments; once the first non-option argument has been found, option processing is terminated. -All builtin commands other than precommand modifiers, even those that -have no options, can be given the argument `tt(-)tt(-)' to terminate option -processing. This indicates that the following words are non-option -arguments, but is otherwise ignored. This is useful in cases where -arguments to the command may begin with `tt(-)'. For historical -reasons, most builtin commands also recognize a single `tt(-)' in a -separate word for this purpose; note that this is less standard and -use of `tt(-)tt(-)' is recommended. +All builtin commands other than `tt(echo)' and precommand modifiers, +even those that have no options, can be given the argument `tt(-)tt(-)' +to terminate option processing. This indicates that the following words +are non-option arguments, but is otherwise ignored. This is useful in +cases where arguments to the command may begin with `tt(-)'. For +historical reasons, most builtin commands (including `tt(echo)') also +recognize a single `tt(-)' in a separate word for this purpose; note +that this is less standard and use of `tt(-)tt(-)' is recommended. startitem() prefix(-) @@ -114,9 +114,9 @@ var(text) is any non-empty string, it is replaced by the text a literal string, not a pattern. A trailing space in var(value) is not special in this case. For example, -example(alias -s ps=gv) +example(alias -s ps='gv --') -will cause the command `tt(*.ps)' to be expanded to `tt(gv *.ps)'. As +will cause the command `tt(*.ps)' to be expanded to `tt(gv -- *.ps)'. As alias expansion is carried out earlier than globbing, the `tt(*.ps)' will then be expanded. Suffix aliases constitute a different name space from other aliases (so in the above example it is still possible @@ -290,6 +290,8 @@ of the list shown by the tt(dirs) command, starting with zero. An argument of the form `tt(-)var(n)' counts from the right. If the tt(PUSHD_MINUS) option is set, the meanings of `tt(PLUS())' and `tt(-)' in this context are swapped. +If the tt(POSIX_CD) option is set, this form of tt(cd) is not recognised +and will be interpreted as the first form. If the tt(-q) (quiet) option is specified, the hook function tt(chpwd) and the functions in the array tt(chpwd_functions) are not called. @@ -768,8 +770,8 @@ However, if the current event has added entries to the history with includes all new history entries since the current event began. When the tt(-l) flag is given, the resulting events are listed on -standard output. Otherwise the editor program var(ename) is invoked on a -file containing these history events. If var(ename) is not given, the +standard output. Otherwise the editor program specified by tt(-e) var(ename) +is invoked on a file containing these history events. If tt(-e) is not given, the value of the parameter tt(FCEDIT) is used; if that is not set the value of the parameter tt(EDITOR) is used; if that is not set a builtin default, usually `tt(vi)' is used. If var(ename) is `tt(-)', no editor is invoked. @@ -858,10 +860,11 @@ point numbers are not permitted. ) findex(functions) xitem(tt(functions) [ {tt(PLUS())|tt(-)}tt(UkmtTuWz) ] [ tt(-x) var(num) ] [ var(name) ... ]) +xitem(tt(functions -c) var(oldfn) var(newfn)) xitem(tt(functions -M) [tt(-s)] var(mathfn) [ var(min) [ var(max) [ var(shellfn) ] ] ]) xitem(tt(functions -M) [ tt(-m) var(pattern) ... ]) item(tt(functions +M) [ tt(-m) ] var(mathfn) ... )( -Equivalent to tt(typeset -f), with the exception of the tt(-x), +Equivalent to tt(typeset -f), with the exception of the tt(-c), tt(-x), tt(-M) and tt(-W) options. For tt(functions -u) and tt(functions -U), see tt(autoload), which provides additional options. @@ -875,6 +878,14 @@ function or functions only. The option is turned off at the start of nested functions (apart from anonoymous functions) unless the called function also has the tt(-W) attribute. +The tt(-c) option causes var(oldfn) to be copied to var(newfn). The +copy is efficiently handled internally by reference counting. If +var(oldfn) was marked for autoload it is first loaded and if this +fails the copy fails. Either function may subsequently be redefined +without affecting the other. A typical idiom is that var(oldfn) is the +name of a library shell function which is then redefined to call +tt(newfn), thereby installing a modified version of the function. + Use of the tt(-M) option may not be combined with any of the options handled by tt(typeset -f). @@ -988,6 +999,10 @@ The choice of hash table to work on is determined by the tt(-d) option; without the option the command hash table is used, and with the option the named directory hash table is used. +A command var(name) starting with a tt(/) is never hashed, whether by +explicit use of the tt(hash) command or otherwise. Such a command +is always found by direct look up in the file system. + Given no arguments, and neither the tt(-r) or tt(-f) options, the selected hash table will be listed in full. @@ -1243,7 +1258,10 @@ If given together with tt(-o) or tt(-O), sorting is performed case-independently. ) item(tt(-l))( -Print the arguments separated by newlines instead of spaces. +Print the arguments separated by newlines instead of spaces. Note: if +the list of arguments is empty, tt(print -l) will still output one empty +line. To print a possibly-empty list of arguments one per line, use +tt(print -C1), as in `tt(print -rC1 -- "$list[@]")'. ) item(tt(-m))( Take the first argument as a pattern (should be quoted), and remove @@ -1254,7 +1272,9 @@ item(tt(-n))( Do not add a newline to the output. ) item(tt(-N))( -Print the arguments separated and terminated by nulls. +Print the arguments separated and terminated by nulls. Again, +tt(print -rNC1 -- "$list[@]") is a canonical way to print an +arbitrary list as null-delimited records. ) item(tt(-o))( Print the arguments sorted in ascending order. diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index ba49fe298..c2d20ca40 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -1609,16 +1609,12 @@ item(tt(format))( If this is set for the tt(descriptions) tag, its value is used as a string to display above matches in completion lists. The sequence `tt(%d)' in this string will be replaced with a short description of -what these matches are. This string may also contain the following -sequences to specify output attributes -ifnzman((see noderef(Prompt Expansion)))\ -ifzman(as described in the section EXPANSION OF PROMPT SEQUENCES in -zmanref(zshmisc)): -`tt(%B)', `tt(%S)', `tt(%U)', `tt(%F)', `tt(%K)' and their lower case -counterparts, as well as `tt(%{)...tt(%})'. `tt(%F)', `tt(%K)' and -`tt(%{)...tt(%})' take arguments in the same form as prompt -expansion. Note that the sequence `tt(%G)' is not available; an argument -to `tt(%{)' should be used instead. +what these matches are. This string may also contain the output +attribute sequences understood by tt(compadd -X) +(see +ifzman(zmanref(zshcompwid))\ +ifnzman(noderef(Completion Widgets))\ +). The style is tested with each tag valid for the current completion before it is tested for the tt(descriptions) tag. Hence different format @@ -2064,6 +2060,9 @@ specification. The value should be in the form described in ifzman(the section `Completion Matching Control' in zmanref(zshcompwid))\ ifnzman(noderef(Completion Matching Control))\ . For examples of this, see the description of the tt(tag-order) style. + +For notes comparing the use of this and the tt(matcher-list) style, see +under the description of the tt(tag-order) style. ) kindex(matcher-list, completion style) item(tt(matcher-list))( @@ -2128,6 +2127,9 @@ If there is no current matcher or it is empty, and the option tt(NO_CASE_GLOB) is in effect, the matching for files is performed case-insensitively in any case. However, any matcher must explicitly specify case-insensitive matching if that is required. + +For notes comparing the use of this and the tt(matcher) style, see +under the description of the tt(tag-order) style. ) kindex(max-errors, completion style) item(tt(max-errors))( @@ -2534,20 +2536,20 @@ is started, making it easy to select either of them. ) kindex(sort, completion style) item(tt(sort))( -Many completion widgets call tt(_description) at some point which -decides whether the matches are added sorted or unsorted (often -indirectly via tt(_wanted) or tt(_requested)). This style can be set -explicitly to one of the usual `true' or `false' values as an override. -If it is not set for the context, the standard behaviour of the -calling widget is used. +This allows the standard ordering of matches to be overridden. + +If its value is `tt(true)' or `tt(false)', sorting is enabled or disabled. +Additionally the values associated with the `tt(-o)' option to tt(compadd) can +also be listed: tt(match), tt(nosort), tt(numeric), tt(reverse). If it is not +set for the context, the standard behaviour of the calling widget is used. The style is tested first against the full context including the tag, and if that fails to produce a value against the context without the tag. -If the calling widget explicitly requests unsorted matches, this is usually -honoured. However, the default (unsorted) behaviour of completion -for the command history may be overridden by setting the style to -`true'. +In many cases where a calling widget explicitly selects a particular ordering +in lieu of the default, a value of `tt(true)' is not honoured. An example of +where this is not the case is for command history where the default of sorting +matches chronologically may be overridden by setting the style to `true'. In the tt(_expand) completer, if it is set to `true', the expansions generated will always be sorted. If it is set @@ -4404,11 +4406,11 @@ convention is not enforced). The description for the corresponding set of matches is passed to the function in var(descr). The styles tested are: tt(format), tt(hidden), tt(matcher), -tt(ignored-patterns) and tt(group-name). The tt(format) style is first -tested for the given var(tag) and then for the tt(descriptions) tag if -no value was found, while the remainder are only tested for the tag -given as the first argument. The function also calls tt(_setup) -which tests some more styles. +tt(ignore-line), tt(ignored-patterns), tt(group-name) and tt(sort). +The tt(format) style is first tested for the given var(tag) and then for +the tt(descriptions) tag if no value was found, while the remainder are +only tested for the tag given as the first argument. The function also +calls tt(_setup) which tests some more styles. The string returned by the tt(format) style (if any) will be modified so that the sequence `tt(%d)' is replaced by the var(descr) given as the third @@ -4518,9 +4520,12 @@ New plugins will be picked up and run automatically. ) findex(_files) item(tt(_files))( -The function tt(_files) calls tt(_path_files) with all the arguments it -was passed except for tt(-g) and tt(-/). The use of these two options -depends on the setting of the tt(file-patterns) style. +The function tt(_files) is a wrapper around tt(_path_files). It supports +all of the same functionality, with some enhancements DASH()- notably, it +respects the tt(list-dirs-first) style, and it allows users to override +the behaviour of the tt(-g) and tt(-/) options with the tt(file-patterns) +style. tt(_files) should therefore be preferred over tt(_path_files) in +most cases. This function accepts the full set of options allowed by tt(_path_files), described below. @@ -4585,7 +4590,9 @@ not set with the former. If the tt(-r) option is given, no style is used; the var(descr) is taken literally as the string to display. This is most useful when the var(descr) comes from a pre-processed argument list -which already contains an expanded description. +which already contains an expanded description. Note that this +option does not disable the `tt(%)'-sequence parsing done by +tt(compadd). The tt(-12VJ) options and the var(group) are passed to tt(compadd) and hence determine the group the message string is added to. @@ -4658,7 +4665,7 @@ fi return ret) ) findex(_normal) -item(tt(_normal))( +item(tt(_normal) [ tt(-P) | tt(-p) var(precommand) ])( This is the standard function called to handle completion outside any special tt(-)var(context)tt(-). It is called both to complete the command word and also the arguments for a command. In the second case, @@ -4668,10 +4675,22 @@ there is none it uses the completion for the tt(-default-) context. A second use is to reexamine the command line specified by the tt($words) array and the tt($CURRENT) parameter after those have been modified. For example, the function tt(_precommand), which -completes after pre-command specifiers such as tt(nohup), removes the +completes after precommand specifiers such as tt(nohup), removes the first word from the tt(words) array, decrements the tt(CURRENT) parameter, -then calls tt(_normal) again. The effect is that `tt(nohup) var(cmd ...)' -is treated in the same way as `var(cmd ...)'. +then calls `tt(_normal -p $service)'. The effect is that +`tt(nohup) var(cmd ...)' is treated in the same way as `var(cmd ...)'. + +startitem() +item(tt(-P))( +Reset the list of precommands. This option should be used if completing +a command line which allows internal commands (e.g. builtins and +functions) regardless of prior precommands (e.g. `tt(zsh -c)'). +) +item(tt(-p) var(precommand))( +Append var(precommand) to the list of precommands. This option should be +used in nearly all cases in which tt(-P) is not applicable. +) +enditem() If the command name matches one of the patterns given by one of the options tt(-p) or tt(-P) to tt(compdef), the corresponding completion @@ -5135,7 +5154,7 @@ which values are already present on the command line and hence are not to be completed again. If the tt(-w) option is given, other arguments are examined as well. -The first non-option argument is used as a string to print as a +The first non-option argument, var(desc), is used as a string to print as a description before listing the values. All other arguments describe the possible values and their diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo index 1cc94bf95..0b98d07b2 100644 --- a/Doc/Zsh/compwid.yo +++ b/Doc/Zsh/compwid.yo @@ -446,12 +446,13 @@ startitem() findex(compadd) cindex(completion widgets, adding specified matches) redef(SPACES)(0)(tt(ifztexi(NOTRANS(@ @ @ @ @ @ @ @ ))ifnztexi( ))) -xitem(tt(compadd )[ tt(-akqQfenUlo12C) ] [ tt(-F) var(array) ]) +xitem(tt(compadd )[ tt(-akqQfenUl12C) ] [ tt(-F) var(array) ]) xitem(SPACES()[tt(-P) var(prefix) ] [ tt(-S) var(suffix) ]) xitem(SPACES()[tt(-p) var(hidden-prefix) ] [ tt(-s) var(hidden-suffix) ]) xitem(SPACES()[tt(-i) var(ignored-prefix) ] [ tt(-I) var(ignored-suffix) ]) xitem(SPACES()[tt(-W) var(file-prefix) ] [ tt(-d) var(array) ]) -xitem(SPACES()[tt(-J) var(name) ] [ tt(-V) var(name) ] [ tt(-X) var(explanation) ] [ tt(-x) var(message) ]) +xitem(SPACES()[tt(-J) var(group-name) ] [ tt(-X) var(explanation) ] [ tt(-x) var(message) ]) +xitem(SPACES()[tt(-V) var(group-name) ] [ tt(-o) [ var(order) ] ]) xitem(SPACES()[tt(-r) var(remove-chars) ] [ tt(-R) var(remove-func) ]) xitem(SPACES()[tt(-D) var(array) ] [ tt(-O) var(array) ] [ tt(-A) var(array) ]) xitem(SPACES()[tt(-E) var(number) ]) @@ -540,18 +541,40 @@ This option only has an effect if used together with the tt(-d) option. If it is given, the display strings are listed one per line, not arrayed in columns. ) -item(tt(-o))( -This option only has an effect if used together with the tt(-d) -option. If it is given, the order of the output is determined by the -match strings; otherwise it is determined by the display strings -(i.e. the strings given by the tt(-d) option). +item(tt(-o) [ var(order) ])( +This controls the order in which matches are sorted. var(order) is a +comma-separated list comprising the following possible values. These values +can be abbreviated to their initial two or three characters. Note that the +order forms part of the group name space so matches with different orderings +will not be in the same group. + +startitem() +item(tt(match))( +If given, the order of the output is determined by the match strings; +otherwise it is determined by the display strings (i.e. the strings given +by the tt(-d) option). This is the default if `tt(-o)' is specified but +the var(order) argument is omitted. +) +item(tt(nosort))( +This specifies that the matches are pre-sorted and their order should be +preserved. This value only makes sense alone and cannot be combined with any +others. +) +item(tt(numeric))( +If the matches include numbers, sort them numerically rather than +lexicographically. +) +item(tt(reverse))( +Arrange the matches backwards by reversing the sort ordering. ) -item(tt(-J) var(name))( +enditem() +) +item(tt(-J) var(group-name))( Gives the name of the group of matches the words should be stored in. ) -item(tt(-V) var(name))( -Like tt(-J) but naming an unsorted group. These are in a different name -space than groups created with the tt(-J) flag. +item(tt(-V) var(group-name))( +Like tt(-J) but naming an unsorted group. This option is identical to +the combination of tt(-J) and tt(-o nosort). ) item(tt(-1))( If given together with the tt(-V) option, makes @@ -567,6 +590,30 @@ different name spaces. item(tt(-X) var(explanation))( The var(explanation) string will be printed with the list of matches, above the group currently selected. + +Within the var(explanation), the following sequences may be used to +specify output attributes +ifnzman((see noderef(Prompt Expansion)))\ +ifzman(as described in the section EXPANSION OF PROMPT SEQUENCES in +zmanref(zshmisc)): +`tt(%B)', `tt(%S)', `tt(%U)', `tt(%F)', `tt(%K)' and their lower case +counterparts, as well as `tt(%{)...tt(%})'. `tt(%F)', `tt(%K)' and +`tt(%{)...tt(%})' take arguments in the same form as prompt +expansion. (Note that the sequence `tt(%G)' is not available; an +argument to `tt(%{)' should be used instead.) The sequence `tt(%%)' +produces a literal `tt(%)'. + +These sequences are most often employed by users when customising the +tt(format) style +(see +ifzman(zmanref(zshcompsys))\ +ifnzman(noderef(Completion System))\ +), +but they must also be taken into account when writing completion +functions, as passing descriptions with unescaped `tt(%)' characters +to utility functions such as tt(_arguments) and tt(_message) may +produce unexpected results. If arbitrary text is to be passed in a +description, it can be escaped using e.g. tt(${my_str//\%/%%}). ) item(tt(-x) var(message))( Like tt(-X), but the var(message) will be printed even if there are no @@ -728,8 +775,8 @@ The options are: startitem() item(tt(-p) var(number))( -If the contents of the tt(PREFIX) parameter is longer than var(number) -characters, the first var(number) characters are removed from it and +If the value of the tt(PREFIX) parameter is at least var(number) +characters long, the first var(number) characters are removed from it and appended to the contents of the tt(IPREFIX) parameter. ) item(tt(-P) [ var(number) ] var(pattern))( diff --git a/Doc/Zsh/cond.yo b/Doc/Zsh/cond.yo index 4ca132a26..000e576d0 100644 --- a/Doc/Zsh/cond.yo +++ b/Doc/Zsh/cond.yo @@ -138,7 +138,7 @@ tt(match) is set to the substrings that matched parenthesised subexpressions and the arrays tt(mbegin) and tt(mend) to the indices of the start and end positions, respectively, of the substrings within var(string). The arrays are not set if there were no parenthesised -subexpresssions. For example, if the string `tt(a short string)' is matched +subexpressions. For example, if the string `tt(a short string)' is matched against the regular expression `tt(s+LPAR()...RPAR()t)', then (assuming the option tt(KSH_ARRAYS) is not set) tt(MATCH), tt(MBEGIN) and tt(MEND) are `tt(short)', tt(3) and tt(7), respectively, while tt(match), diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index d32ba018d..c6bf745b7 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -677,7 +677,7 @@ As an example, ~[g:p:s] might specify: startitem() item(tt(g))( The top level directory for your git area. This first component -has to match, or the function will retrun indicating another +has to match, or the function will return indicating another directory name hook function should be tried. ) item(tt(p))( @@ -1343,11 +1343,11 @@ endsitem() In tt(patch-format) and tt(nopatch-format) these replacements are done: startsitem() -sitem(tt(%p))(The name of the top-most applied patch (tt(applied-string)).) -sitem(tt(%u))(The number of unapplied patches (tt(unapplied-string)).) +sitem(tt(%p))(The name of the top-most applied patch; may be overridden by the tt(applied-string) hook.) +sitem(tt(%u))(The number of unapplied patches; may be overridden by the tt(unapplied-string) hook.) sitem(tt(%n))(The number of applied patches.) sitem(tt(%c))(The number of unapplied patches.) -sitem(tt(%a))(The number of all patches.) +sitem(tt(%a))(The number of all patches (tt(%a = %n + %c)).) sitem(tt(%g))(The names of active tt(mq) guards (tt(hg) backend).) sitem(tt(%G))(The number of active tt(mq) guards (tt(hg) backend).) endsitem() @@ -2227,7 +2227,20 @@ is set in the context tt(:zle:*) to tt(true) if the word style is tt(bash) and tt(false) otherwise. It may be overridden by setting it in the more specific context tt(:zle:forward-word*). -Here are some examples of use of the styles, actually taken from the +It is possible to create widgets with specific behaviour by defining +a new widget implemented by the appropriate generic function, then +setting a style for the context of the specific widget. For example, +the following defines a widget tt(backward-kill-space-word) using +tt(backward-kill-word-match), the generic widget implementing +tt(backward-kill-word) behaviour, and ensures that the new widget +always implements space-delimited behaviour. + +example(zle -N backward-kill-space-word backward-kill-word-match +zstyle :zle:backward-kill-space-word word-style space) + +The widget tt(backward-kill-space-word) can now be bound to a key. + +Here are some further examples of use of the styles, actually taken from the simplified interface in tt(select-word-style): example(zstyle ':zle:*' word-style standard @@ -4284,9 +4297,10 @@ See also the tt(pager), tt(prompt) and tt(rprompt) styles below. findex(regexp-replace) item(tt(regexp-replace) var(var) var(regexp) var(replace))( Use regular expressions to perform a global search and replace operation -on a variable. If the option tt(RE_MATCH_PCRE) is not set, POSIX -extended regular expressions are used, else Perl-compatible regular -expressions (this requires the shell to be linked against the tt(pcre) +on a variable. POSIX extended regular expressions are used, +unless the option tt(RE_MATCH_PCRE) has been set, in which case +Perl-compatible regular expressions are used +(this requires the shell to be linked against the tt(pcre) library). var(var) is the name of the variable containing the string to be matched. @@ -4417,24 +4431,28 @@ the elements from the tt(input) list in each run. If no var(command) is provided, then no var(arg) list may be provided, and in that event the default command is `tt(print)' with arguments `tt(-r -)tt(-)'. -For example, to get a long tt(ls) listing of all plain files in the -current directory or its subdirectories: +For example, to get a long tt(ls) listing of all non-hidden plain files +in the current directory or its subdirectories: example(autoload -U zargs -zargs -- **/*(.) -- ls -l) +zargs -- **/*(.) -- ls -ld --) + +The first and third occurrences of `tt(-)tt(-)' are used to mark the end +of options for tt(zargs) and tt(ls) respectively to guard against +filenames starting with `tt(-)', while the second is used to separate the +list of files from the command to run (`tt(ls -ld --)'). + +The first `tt(-)tt(-)' would also be needed if there was a chance the +list might be empty as in: -Note that `tt(-)tt(-)' is used both to mark the end of the var(option) -list and to mark the end of the var(input) list, so it must appear twice -whenever the var(input) list may be empty. If there is guaranteed to be -at least one var(input) and the first var(input) does not begin with a -`tt(-)', then the first `tt(-)tt(-)' may be omitted. +example(zargs -r -- ./*.back+LPAR()#qN+RPAR() -- rm -f) In the event that the string `tt(-)tt(-)' is or may be an var(input), the tt(-e) option may be used to change the end-of-inputs marker. Note that this does em(not) change the end-of-options marker. For example, to use `tt(..)' as the marker: -example(zargs -e.. -- **/*(.) .. ls -l) +example(zargs -e.. -- **/*(.) .. ls -ld --) This is a good choice in that example because no plain file can be named `tt(..)', but the best end-marker depends on the circumstances. diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index a212d742d..c129b4228 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -260,9 +260,23 @@ see the definition of the filename extension in the description of the tt(r) modifier below. Note that according to that definition the result will be empty if the string ends with a `tt(.)'. ) -item(tt(h))( -Remove a trailing pathname component, leaving the head. This works -like `tt(dirname)'. +item(tt(h) [ var(digits) ])( +Remove a trailing pathname component, shortening the path by one +directory level: this is the `head' of the pathname. This works like +`tt(dirname)'. If the tt(h) is followed immediately (with no spaces or +other separator) by any number of decimal digits, and the value of the +resulting number is non-zero, that number of leading components is +preserved instead of the final component being removed. In an +absolute path the leading `tt(/)' is the first component, so, +for example, if tt(var=/my/path/to/something), then tt(${var:h3}) +substitutes tt(/my/path). Consecutive `/'s are treated the same as +a single `/'. In parameter substitution, digits may only be +used if the expression is in braces, so for example the short form +substitution tt($var:h2) is treated as tt(${var:h}2), not as +tt(${var:h2}). No restriction applies to the use of digits in history +substitution or globbing qualifiers. If more components are requested +than are present, the entire path is substituted (so this does not +trigger a `failed modifier' error in history expansion). ) item(tt(l))( Convert the words to all lowercase. @@ -316,9 +330,12 @@ immediately by a tt(g). In parameter expansion the tt(&) must appear inside braces, and in filename generation it must be quoted with a backslash. ) -item(tt(t))( -Remove all leading pathname components, leaving the tail. This works -like `tt(basename)'. +item(tt(t) [ var(digits) ])( +Remove all leading pathname components, leaving the final component (tail). +This works like `tt(basename)'. Any trailing slashes are first removed. +Decimal digits are handled as described above for (h), but in this +case that number of trailing components is preserved instead of +the default 1; 0 is treated the same as 1. ) item(tt(u))( Convert the words to all uppercase. @@ -383,7 +400,7 @@ backslashes. For example, the following piece of filename generation code with the tt(EXTENDED_GLOB) option: -example(print *.c+LPAR()#q:s/#%+LPAR()#b+RPAR()s+LPAR()*+RPAR().c/'S${match[1]}.C'/+RPAR()) +example(print -r -- *.c+LPAR()#q:s/#%+LPAR()#b+RPAR()s+LPAR()*+RPAR().c/'S${match[1]}.C'/+RPAR()) takes the expansion of tt(*.c) and applies the glob qualifiers in the tt(LPAR()#q)var(...)tt(RPAR()) expression, which consists of a substitution @@ -565,7 +582,25 @@ and subscript notation to access individual array elements. Note in particular the fact that words of unquoted parameters are not automatically split on whitespace unless the option tt(SH_WORD_SPLIT) is set; see references to this option below for more details. This is an -important difference from other shells. +important difference from other shells. However, as in other shells, +null words are elided from unquoted parameters' expansions. + +With default options, after the assignments: + +example(array=("first word" "" "third word") +scalar="only word") + +then tt($array) substitutes two words, `tt(first word)' and `tt(third +word)', and tt($scalar) substitutes a single word `tt(only word)'. Note +that second element of tt(array) was elided. Scalar parameters can +be elided too if their value is null (empty). To avoid elision, use quoting as +follows: tt("$scalar") for scalars and tt("${array[@]}") or tt("${(@)array}") +for arrays. (The last two forms are equivalent.) + +Parameter expansions can involve em(flags), as in `tt(${(@kv)aliases})', +and other operators, such as `tt(${PREFIX:-"/usr/local"})'. Parameter +expansions can also be nested. These topics will be introduced below. +The full rules are complicated and are noted at the end. In the expansions discussed below that require a pattern, the form of the pattern is the same as that used for filename generation; @@ -577,17 +612,8 @@ noderef(Modifiers) in noderef(History Expansion) can be applied: for example, tt(${i:s/foo/bar/}) performs string substitution on the expansion of parameter tt($i). -In the following descriptions, `word' refers to a single word +In the following descriptions, `var(word)' refers to a single word substituted on the command line, not necessarily a space delimited word. -With default options, after the assignments: - -example(array=("first word" "second word") -scalar="only word") - -then tt($array) substitutes two words, `tt(first word)' and `tt(second -word)', and tt($scalar) substitutes a single word `tt(only word)'. This -may be modified by explicit or implicit word-splitting, however. The -full rules are complicated and are noted at the end. startitem() item(tt(${)var(name)tt(}))( @@ -1122,7 +1148,7 @@ form of single quoting is used that only quotes the string if needed to protect special characters. Typically this form gives the most readable output. -If a tt(q+) is given, an extended form of minmal quoting is used that +If a tt(q+) is given, an extended form of minimal quoting is used that causes unprintable characters to be rendered using tt($')var(...)tt('). This quoting is similar to that used by the output of values by the tt(typeset) family of commands. @@ -1377,11 +1403,40 @@ used with the tt(${)...tt(/)...tt(}) forms. startitem() item(tt(S))( -Search substrings as well as beginnings or ends; with tt(#) start -from the beginning and with tt(%) start from the end of the string. +With tt(#) or tt(##), search for the match that starts closest to the start of +the string (a `substring match'). Of all matches at a particular position, +tt(#) selects the shortest and tt(##) the longest: + +example(% str="aXbXc" +% echo ${+LPAR()S+RPAR()str#X*} +abXc +% echo ${+LPAR()S+RPAR()str##X*} +a +% ) + +With tt(%) or tt(%%), search for the match that starts closest to the end of +the string: + +example(% str="aXbXc" +% echo ${+LPAR()S+RPAR()str%X*} +aXbc +% echo ${+LPAR()S+RPAR()str%%X*} +aXb +% ) + +(Note that tt(%) and tt(%%) don't search for the match that ends closest to the +end of the string, as one might expect.) + With substitution via tt(${)...tt(/)...tt(}) or tt(${)...tt(//)...tt(}), specifies non-greedy matching, i.e. that the -shortest instead of the longest match should be replaced. +shortest instead of the longest match should be replaced: + +example(% str="abab" +% echo ${str/*b/_} +_ +% echo ${+LPAR()S+RPAR()str/*b/_} +_ab +% ) ) item(tt(I:)var(expr)tt(:))( Search the var(expr)th match (where var(expr) evaluates to a number). @@ -2247,12 +2302,13 @@ parentheses can be referenced. For example, -example(foo="a string with a message" -if [[ $foo = (a|an)' '(#b)(*)' '* ]]; then +example(foo="a_string_with_a_message" +if [[ $foo = (a|an)_(#b)(*) ]]; then print ${foo[$mbegin[1],$mend[1]]} fi) -prints `tt(string with a)'. Note that the first parenthesis is before the +prints `tt(string_with_a_message)'. +Note that the first set of parentheses is before the tt((#b)) and does not create a backreference. Backreferences work with all forms of pattern matching other than filename @@ -2475,11 +2531,11 @@ therefore matches files in the current directory as well as subdirectories. Thus: -example(ls (*/)#bar) +example(ls -ld -- (*/)#bar) or -example(ls **/bar) +example(ls -ld -- **/bar) does a recursive directory search for files named `tt(bar)' (potentially including the file `tt(bar)' in the current directory). This form does not @@ -2494,11 +2550,11 @@ they are treated as if both a tt(/) plus a further tt(*) are present. Hence: example(setopt GLOBSTARSHORT -ls **.c) +ls -ld -- **.c) is equivalent to -example(ls **/*.c) +example(ls -ld -- **/*.c) subsect(Glob Qualifiers) cindex(globbing, qualifiers) cindex(qualifiers, globbing) @@ -2690,7 +2746,7 @@ appropriate test. For example, example(nt+LPAR()RPAR() { [[ $REPLY -nt $NTREF ]] } NTREF=reffile -ls -l *(+nt)) +ls -ld -- *(+nt)) lists all files in the directory that have been modified more recently than tt(reffile). @@ -2881,36 +2937,36 @@ is performed, although note that the presence of the parentheses causes the entire expression to be subjected to any global pattern matching options such as tt(NULL_GLOB). Thus: -example(ls *(-/)) +example(ls -ld -- *(-/)) lists all directories and symbolic links that point to directories, and -example(ls *(-@)) +example(ls -ld -- *(-@)) lists all broken symbolic links, and -example(ls *(%W)) +example(ls -ld -- *(%W)) lists all world-writable device files in the current directory, and -example(ls *(W,X)) +example(ls -ld -- *(W,X)) lists all files in the current directory that are world-writable or world-executable, and -example(echo /tmp/foo*(u0^@:t)) +example(print -rC1 /tmp/foo*(u0^@:t)) outputs the basename of all root-owned files beginning with the string `tt(foo)' in tt(/tmp), ignoring symlinks, and -example(ls *.*~(lex|parse).[ch](^D^l1)) +example(ls -ld -- *.*~(lex|parse).[ch](^D^l1)) lists all files having a link count of one whose names contain a dot (but not those starting with a dot, since tt(GLOB_DOTS) is explicitly switched off) except for tt(lex.c), tt(lex.h), tt(parse.c) and tt(parse.h). -example(print b*.pro+LPAR()#q:s/pro/shmo/+RPAR()(#q.:s/builtin/shmiltin/)) +example(print -rC1 b*.pro+LPAR()#q:s/pro/shmo/+RPAR()(#q.:s/builtin/shmiltin/)) demonstrates how colon modifiers and other qualifiers may be chained together. The ordinary qualifier `tt(.)' is applied first, then the colon diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo index d30c9d2d7..e028c8512 100644 --- a/Doc/Zsh/grammar.yo +++ b/Doc/Zsh/grammar.yo @@ -297,11 +297,11 @@ findex(always) cindex(always blocks) cindex(try blocks) item(tt({) var(try-list) tt(} always {) var(always-list) tt(}))( -First execute var(try-list). Regardless of errors, or tt(break), -tt(continue), or tt(return) commands encountered within var(try-list), +First execute var(try-list). Regardless of errors, or tt(break) or +tt(continue) commands encountered within var(try-list), execute var(always-list). Execution then continues from the result of the execution of var(try-list); in other words, any error, -or tt(break), tt(continue), or tt(return) command is treated in the +or tt(break) or tt(continue) command is treated in the normal way, as if var(always-list) were not present. The two chunks of code are referred to as the `try block' and the `always block'. @@ -313,23 +313,23 @@ An `error' in this context is a condition such as a syntax error which causes the shell to abort execution of the current function, script, or list. Syntax errors encountered while the shell is parsing the code do not cause the var(always-list) to be executed. For example, -an erroneously constructed tt(if) block in tt(try-list) would cause the -shell to abort during parsing, so that tt(always-list) would not be +an erroneously constructed tt(if) block in var(try-list) would cause the +shell to abort during parsing, so that var(always-list) would not be executed, while an erroneous substitution such as tt(${*foo*}) would -cause a run-time error, after which tt(always-list) would be executed. +cause a run-time error, after which var(always-list) would be executed. An error condition can be tested and reset with the special integer -variable tt(TRY_BLOCK_ERROR). Outside an tt(always-list) the value is -irrelevant, but it is initialised to tt(-1). Inside tt(always-list), the -value is 1 if an error occurred in the tt(try-list), else 0. If -tt(TRY_BLOCK_ERROR) is set to 0 during the tt(always-list), the error -condition caused by the tt(try-list) is reset, and shell execution -continues normally after the end of tt(always-list). Altering the value -during the tt(try-list) is not useful (unless this forms part of an +variable tt(TRY_BLOCK_ERROR). Outside an var(always-list) the value is +irrelevant, but it is initialised to tt(-1). Inside var(always-list), the +value is 1 if an error occurred in the var(try-list), else 0. If +tt(TRY_BLOCK_ERROR) is set to 0 during the var(always-list), the error +condition caused by the var(try-list) is reset, and shell execution +continues normally after the end of var(always-list). Altering the value +during the var(try-list) is not useful (unless this forms part of an enclosing tt(always) block). -Regardless of tt(TRY_BLOCK_ERROR), after the end of tt(always-list) the -normal shell status tt($?) is the value returned from tt(try-list). +Regardless of tt(TRY_BLOCK_ERROR), after the end of var(always-list) the +normal shell status tt($?) is the value returned from var(try-list). This will be non-zero if there was an error, even if tt(TRY_BLOCK_ERROR) was set to zero. @@ -345,10 +345,16 @@ example({ } # The error condition has been reset.) -An tt(exit) command (or a tt(return) command executed at the outermost -function level of a script) encountered in tt(try-list) does em(not) cause +When a tt(try) block occurs outside of any function, +a tt(return) or a tt(exit) encountered in var(try-list) does em(not) cause the execution of var(always-list). Instead, the shell exits immediately after any tt(EXIT) trap has been executed. +Otherwise, a tt(return) command encountered in var(try-list) will cause the +execution of var(always-list), just like tt(break) and tt(continue). + +COMMENT(The semantics of calling 'exit' in try-list inside a function are +deliberately left unspecified, because historically there was a mismatch between +the documented and implemented behaviours. Cf. 20076, 21734/21735, 45075.) ) findex(function) xitem(tt(function) var(word) ... [ tt(()) ] [ var(term) ] tt({) var(list) tt(})) diff --git a/Doc/Zsh/intro.yo b/Doc/Zsh/intro.yo index a7a2f3248..75d25ce27 100644 --- a/Doc/Zsh/intro.yo +++ b/Doc/Zsh/intro.yo @@ -15,6 +15,9 @@ startlist() ifzshone(\ list(em(zsh) Zsh overview (this section)) )\ +ifzshall(\ +list(em(zsh) Zsh overview) +)\ list(em(zshroadmap) Informal introduction to the manual) list(em(zshmisc) Anything not fitting into the other sections) list(em(zshexpn) Zsh command and parameter expansion) diff --git a/Doc/Zsh/mod_files.yo b/Doc/Zsh/mod_files.yo index 90e988474..9f9634c86 100644 --- a/Doc/Zsh/mod_files.yo +++ b/Doc/Zsh/mod_files.yo @@ -23,6 +23,26 @@ item(tt(chgrp) [ tt(-hRs) ] var(group) var(filename) ...)( Changes group of files specified. This is equivalent to tt(chown) with a var(user-spec) argument of `tt(:)var(group)'. ) +findex(chmod) +item(tt(chmod) [ tt(-Rs) ] var(mode) var(filename) ...)( +Changes mode of files specified. + +The specified var(mode) must be in octal. + +The tt(-R) option causes tt(chmod) to recursively descend into directories, +changing the mode of all files in the directory after +changing the mode of the directory itself. + +The tt(-s) option is a zsh extension to tt(chmod) functionality. It enables +paranoid behaviour, intended to avoid security problems involving +a tt(chmod) being tricked into affecting files other than the ones +intended. It will refuse to follow symbolic links, so that (for example) +``tt(chmod 600 /tmp/foo/passwd)'' can't accidentally chmod tt(/etc/passwd) +if tt(/tmp/foo) happens to be a link to tt(/etc). It will also check +where it is after leaving directories, so that a recursive chmod of +a deep directory tree can't end up recursively chmoding tt(/usr) as +a result of directories being moved up the tree. +) findex(chown) item(tt(chown) [ tt(-hRs) ] var(user-spec) var(filename) ...)( Changes ownership and group of files specified. @@ -124,15 +144,15 @@ fall back on copying and removing files; if this behaviour is desired, use tt(cp) and tt(rm) manually. This may change in a future version. ) findex(rm) -item(tt(rm) [ tt(-dfirs) ] var(filename) ...)( +item(tt(rm) [ tt(-dfiRrs) ] var(filename) ...)( Removes files and directories specified. -Normally, tt(rm) will not remove directories (except with the tt(-r) -option). The tt(-d) option causes tt(rm) to try removing directories +Normally, tt(rm) will not remove directories (except with the tt(-R) or tt(-r) +options). The tt(-d) option causes tt(rm) to try removing directories with tt(unlink) (see manref(unlink)(2)), the same method used for files. Typically only the super-user can actually succeed in unlinking directories in this way. -tt(-d) takes precedence over tt(-r). +tt(-d) takes precedence over tt(-R) and tt(-r). By default, the user will be queried before removing any file that the user cannot write to, but writable files will be silently @@ -142,9 +162,9 @@ any files. The tt(-f) option causes files to be silently deleted, without querying, and suppresses all error indications. tt(-f) takes precedence. -The tt(-r) option causes tt(rm) to recursively descend into directories, -deleting all files in the directory before removing the directory with -the tt(rmdir) system call (see manref(rmdir)(2)). +The tt(-R) and tt(-r) options cause tt(rm) to recursively descend into +directories, deleting all files in the directory before removing the directory +with the tt(rmdir) system call (see manref(rmdir)(2)). The tt(-s) option is a zsh extension to tt(rm) functionality. It enables paranoid behaviour, intended to avoid common security problems involving diff --git a/Doc/Zsh/mod_mapfile.yo b/Doc/Zsh/mod_mapfile.yo index 96e056816..640beeb12 100644 --- a/Doc/Zsh/mod_mapfile.yo +++ b/Doc/Zsh/mod_mapfile.yo @@ -18,7 +18,7 @@ editing the file `tt(myfile)'. When the array is accessed as a whole, the keys are the names of files in the current directory, and the values are empty (to save a huge overhead in -memory). Thus tt(${(k)mapfile}) has the same affect as the glob operator +memory). Thus tt(${(k)mapfile}) has the same effect as the glob operator tt(*(D)), since files beginning with a dot are not special. Care must be taken with expressions such as tt(rm ${(k)mapfile}), which will delete every file in the current directory without the usual `tt(rm *)' test. diff --git a/Doc/Zsh/mod_parameter.yo b/Doc/Zsh/mod_parameter.yo index 942e4c5b6..2e3011e44 100644 --- a/Doc/Zsh/mod_parameter.yo +++ b/Doc/Zsh/mod_parameter.yo @@ -55,7 +55,7 @@ For any other function, including any defined at an interactive prompt or an autoload function whose path has not yet been resolved, this is the empty string. However, the hash element is reported as defined just so long as the function is present: the keys to this hash are -the same as those to tt($funcions). +the same as those to tt($functions). ) vindex(dis_functions_source) item(tt(dis_functions_source))( diff --git a/Doc/Zsh/mod_socket.yo b/Doc/Zsh/mod_socket.yo index 867f6081f..78d9254e8 100644 --- a/Doc/Zsh/mod_socket.yo +++ b/Doc/Zsh/mod_socket.yo @@ -43,7 +43,8 @@ startitem() item(tt(zsocket) tt(-l) [ tt(-v) ] [ tt(-d) var(fd) ] var(filename))( tt(zsocket -l) will open a socket listening on var(filename). The shell parameter tt(REPLY) will be set to the file descriptor -associated with that listener. +associated with that listener. The file descriptor remains open in subshells +and forked external executables. If tt(-d) is specified, its argument will be taken as the target file descriptor for @@ -56,7 +57,8 @@ tt(zsocket -a) will accept an incoming connection to the socket associated with var(listenfd). The shell parameter tt(REPLY) will be set to the file descriptor associated with -the inbound connection. +the inbound connection. The file descriptor remains open in subshells +and forked external executables. If tt(-d) is specified, its argument will be taken as the target file descriptor for the diff --git a/Doc/Zsh/mod_system.yo b/Doc/Zsh/mod_system.yo index a27bab47f..6292af071 100644 --- a/Doc/Zsh/mod_system.yo +++ b/Doc/Zsh/mod_system.yo @@ -45,7 +45,9 @@ specified as a comma-separated list. The following is a list of possible options. Note that, depending on the system, some may not be available. startitem() item(tt(cloexec))( -mark file to be closed when other programs are executed +mark file to be closed when other programs are executed (else +the file descriptor remains open in subshells and forked external +executables) ) xitem(tt(create)) item(tt(creat))( @@ -177,8 +179,11 @@ locked by opening a file descriptor to the file and applying a lock to the file descriptor. The lock terminates when the shell process that created the lock exits; it is therefore often convenient to create file locks within subshells, since the lock is automatically released when -the subshell exits. Status 0 is returned if the lock succeeds, else -status 1. +the subshell exits. Note that use of the tt(print) builtin with the +tt(-u) option will, as a side effect, release the lock, as will redirection +to the file in the shell holding the lock. To work around this use a +subshell, e.g. `tt((print message) >> )var(file)'. Status 0 is +returned if the lock succeeds, else status 1. In the second form the file descriptor given by the arithmetic expression var(fd_expr) is closed, releasing a lock. The file descriptor diff --git a/Doc/Zsh/mod_zpty.yo b/Doc/Zsh/mod_zpty.yo index 6f20c4b75..3ca031c01 100644 --- a/Doc/Zsh/mod_zpty.yo +++ b/Doc/Zsh/mod_zpty.yo @@ -25,7 +25,7 @@ monitored with ZLE descriptor handlers (see ifzman(zmanref(zshzle))\ ifnzman(noderef(Zle Builtins))) or manipulated with tt(sysread) and tt(syswrite) (see ifzman(THE ZSH/SYSTEM MODULE in zmanref(zshmodules))\ ifnzman(noderef(The zsh/system Module))). em(Warning): Use of tt(sysread) -and tt(syswrite) is em(not) recommended, use tt(zpty -r) and tt(zpty -w) +and tt(syswrite) is em(not) recommended; use tt(zpty -r) and tt(zpty -w) unless you know exactly what you are doing. ) item(tt(zpty) tt(-d) [ var(name) ... ])( diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo index 15f6ed365..24aebdfaf 100644 --- a/Doc/Zsh/mod_zutil.yo +++ b/Doc/Zsh/mod_zutil.yo @@ -7,7 +7,7 @@ The tt(zsh/zutil) module only adds some builtins: startitem() findex(zstyle) -xitem(tt(zstyle) [ tt(-L) [ var(pattern) [ var(style) ] ] ]) +xitem(tt(zstyle) [ tt(-L) [ var(metapattern) [ var(style) ] ] ]) xitem(tt(zstyle) [ tt(-e) | tt(-) | tt(-)tt(-) ] var(pattern) var(style) var(string) ...) xitem(tt(zstyle -d) [ var(pattern) [ var(style) ... ] ]) xitem(tt(zstyle -g) var(name) [ var(pattern) [ var(style) ] ]) @@ -17,35 +17,56 @@ item(tt(zstyle -m) var(context) var(style) var(pattern))( This builtin command is used to define and lookup styles. Styles are pairs of names and values, where the values consist of any number of strings. They are stored together with patterns and lookup is done by -giving a string, called the `context', which is compared to the -patterns. The definition stored for the first matching pattern will be -returned. +giving a string, called the `em(context)', which is matched against the +patterns. The definition stored for the most specific pattern that matches +will be returned. -For ordering of comparisons, patterns are searched from most specific to -least specific, and patterns that are equally specific keep the order in -which they were defined. A pattern is considered to be more specific +A pattern is considered to be more specific than another if it contains more components (substrings separated by colons) or if the patterns for the components are more specific, where simple strings are considered to be more specific than patterns and complex patterns are considered to be more specific than the pattern -`tt(*)'. +`tt(*)'. A `tt(*)' in the pattern will match zero or more characters +in the context; colons are not treated specially in this regard. +If two patterns are equally specific, the tie is broken in favour of +the pattern that was defined first. -The first form (without arguments) lists the definitions. Styles +em(Example) + +For example, to define your preferred form of precipitation depending on which +city you're in, you might set the following in your tt(zshrc): + +example(zstyle ':weather:europe:*' preferred-precipitation rain +zstyle ':weather:europe:germany:* preferred-precipitation none +zstyle ':weather:europe:germany:*:munich' preferred-precipitation snow) + +Then, the fictional `tt(weather)' plugin might run under the hood a command +such as + +example(zstyle -s ":weather:${continent}:${country}:${county}:${city}" preferred-precipitation REPLY) + +in order to retrieve your preference into the scalar variable tt($REPLY). + +em(Usage) + +The forms that operate on patterns are the following. + +startitem() +item(tt(zstyle) [ tt(-L) [ var(metapattern) [ var(style) ] ] ])( +Without arguments, lists style definitions. Styles are shown in alphabetic order and patterns are shown in the order tt(zstyle) will test them. If the tt(-L) option is given, listing is done in the form of calls to -tt(zstyle). The optional first argument is a pattern which will be matched -against the string supplied as the pattern for the context; note that +tt(zstyle). The optional first argument, var(metapattern), is a pattern which +will be matched against the string supplied as var(pattern) when the style was +defined. Note: this means, for example, `tt(zstyle -L ":completion:*")' will match any supplied pattern beginning `tt(:completion:)', not -just tt(":completion:*"): use tt(":completion:\*") to match that. +just tt(":completion:*"): use tt(':completion:\*') to match that. The optional second argument limits the output to a specific var(style) (not a pattern). tt(-L) is not compatible with any other options. - -The other forms are the following: - -startitem() +) item(tt(zstyle) [ tt(-) | tt(-)tt(-) | tt(-e) ] var(pattern) var(style) var(string) ...)( vindex(reply, use of) Defines the given var(style) for the var(pattern) with the var(string)s as @@ -74,24 +95,30 @@ combination is returned. ) enditem() -The other forms can be used to look up or test patterns. +The other forms can be used to look up or test styles for a given context. startitem() item(tt(zstyle -s) var(context) var(style) var(name) [ var(sep) ])( The parameter var(name) is set to the value of the style interpreted as a string. If the value contains several strings they are concatenated with spaces (or with the var(sep) string if that is given) between them. + +Return tt(0) if the style is set, tt(1) otherwise. ) item(tt(zstyle -b) var(context) var(style) var(name))( The value is stored in var(name) as a boolean, i.e. as the string `tt(yes)' if the value has only one string and that string is equal to one of `tt(yes)', `tt(true)', `tt(on)', or `tt(1)'. If the value is any other string or has more than one string, the parameter is set to `tt(no)'. + +Return tt(0) if var(name) is set to `tt(yes)', tt(1) otherwise. ) item(tt(zstyle -a) var(context) var(style) var(name))( The value is stored in var(name) as an array. If var(name) is declared as an associative array, the first, third, etc. strings are used as the keys and the other strings are used as the values. + +Return tt(0) if the style is set, tt(1) otherwise. ) xitem(tt(zstyle -t) var(context) var(style) [ var(string) ... ]) item(tt(zstyle -T) var(context) var(style) [ var(string) ... ])( @@ -180,7 +207,7 @@ item(tt(zregexparse))( This implements some internals of the tt(_regex_arguments) function. ) findex(zparseopts) -item(tt(zparseopts) [ tt(-D) tt(-K) tt(-M) tt(-E) ] [ tt(-a) var(array) ] [ tt(-A) var(assoc) ] [ tt(-) ] var(spec) ...)( +item(tt(zparseopts) [ tt(-D) tt(-E) tt(-F) tt(-K) tt(-M) ] [ tt(-a) var(array) ] [ tt(-A) var(assoc) ] [ tt(-) ] var(spec) ...)( This builtin simplifies the parsing of options in positional parameters, i.e. the set of arguments given by tt($*). Each var(spec) describes one option and must be of the form `var(opt)[tt(=)var(array)]'. If an option @@ -195,7 +222,7 @@ Note that it is an error to give any var(spec) without an Unless the tt(-E) option is given, parsing stops at the first string that isn't described by one of the var(spec)s. Even with tt(-E), parsing always stops at a positional parameter equal to `tt(-)' or -`tt(-)tt(-)'. +`tt(-)tt(-)'. See also tt(-F). The var(opt) description must be one of the following. Any of the special characters can appear in the option name provided it is preceded by a @@ -234,9 +261,23 @@ first colon. ) enditem() +In all cases, option-arguments must appear either immediately following the +option in the same positional parameter or in the next one. Even an optional +argument may appear in the next parameter, unless it begins with a `tt(-)'. +There is no special handling of `tt(=)' as with GNU-style argument parsers; +given the var(spec) `tt(-foo:)', the positional parameter `tt(-)tt(-foo=bar)' +is parsed as `tt(-)tt(-foo)' with an argument of `tt(=bar)'. + +When the names of two options that take no arguments overlap, the longest one +wins, so that parsing for the var(spec)s `tt(-foo -foobar)' (for example) is +unambiguous. However, due to the aforementioned handling of option-arguments, +ambiguities may arise when at least one overlapping var(spec) takes an +argument, as in `tt(-foo: -foobar)'. In that case, the last matching +var(spec) wins. + The options of tt(zparseopts) itself cannot be stacked because, for example, the stack `tt(-DEK)' is indistinguishable from a var(spec) for -the GNU-style long option `tt(--DEK)'. The options of tt(zparseopts) +the GNU-style long option `tt(-)tt(-DEK)'. The options of tt(zparseopts) itself are: startitem() @@ -252,8 +293,29 @@ as the values. item(tt(-D))( If this option is given, all options found are removed from the positional parameters of the calling shell or shell function, up to but not including -any not described by the var(spec)s. This is similar to using the tt(shift) -builtin. +any not described by the var(spec)s. If the first such parameter is `tt(-)' +or `tt(-)tt(-)', it is removed as well. This is similar to using the +tt(shift) builtin. +) +item(tt(-E))( +This changes the parsing rules to em(not) stop at the first string +that isn't described by one of the var(spec)s. It can be used to test +for or (if used together with tt(-D)) extract options and their +arguments, ignoring all other options and arguments that may be in the +positional parameters. As indicated above, parsing still stops at the +first `tt(-)' or `tt(-)tt(-)' not described by a var(spec), but it is not +removed when used with tt(-D). +) +item(tt(-F))( +If this option is given, tt(zparseopts) immediately stops at the first +option-like parameter not described by one of the var(spec)s, prints an +error message, and returns status 1. Removal (tt(-D)) and extraction +(tt(-E)) are not performed, and option arrays are not updated. This +provides basic validation for the given options. + +Note that the appearance in the positional parameters of an option without +its required argument always aborts parsing and returns an error as described +above regardless of whether this option is used. ) item(tt(-K))( With this option, the arrays specified with the tt(-a) option and with the @@ -272,13 +334,6 @@ is found, the values are stored as usual. This changes only the way the values are stored, not the way tt($*) is parsed, so results may be unpredictable if the `var(name)tt(+)' specifier is used inconsistently. ) -item(tt(-E))( -This changes the parsing rules to em(not) stop at the first string -that isn't described by one of the var(spec)s. It can be used to test -for or (if used together with tt(-D)) extract options and their -arguments, ignoring all other options and arguments that may be in the -positional parameters. -) enditem() For example, diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index bc182eb7b..fdea51412 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -88,6 +88,21 @@ tt(AUTO_CD) option set) is not a directory, and does not begin with a slash, try to expand the expression as if it were preceded by a `tt(~)' (see noderef(Filename Expansion)). ) +pindex(CD_SILENT) +pindex(NO_CD_SILENT) +pindex(CDSILENT) +pindex(NOCDSILENT) +cindex(cd, silencing) +cindex(autocd, silencing) +item(tt(CD_SILENT))( +Never print the working directory after a tt(cd) (whether explicit or +implied with the tt(AUTO_CD) option set). tt(cd) normally prints the +working directory when the argument given to it was tt(-), a stack entry, or +the name of a directory found under tt(CDPATH). Note that this is distinct +from tt(pushd)'s stack-printing behaviour, which is controlled by +tt(PUSHD_SILENT). This option overrides the printing-related effects of +tt(POSIX_CD). +) pindex(CHASE_DOTS) pindex(NO_CHASE_DOTS) pindex(CHASEDOTS) @@ -133,7 +148,8 @@ ifzman(zmanref(zshbuiltins))\ ifnzman(noderef(Shell Builtin Commands)). If the option is set, the shell does not test for directories beneath the local directory (`tt(.)') until after all directories in tt(cdpath) -have been tested. +have been tested, and the tt(cd) and tt(chdir) commands do not recognise +arguments of the form `{tt(PLUS())|tt(-)}var(n)' as directory stack entries. Also, if the option is set, the conditions under which the shell prints the new directory after changing to it are modified. It is @@ -2318,7 +2334,9 @@ cindex(sh, field splitting style) item(tt(SH_WORD_SPLIT) (tt(-y)) <K> <S>)( Causes field splitting to be performed on unquoted parameter expansions. Note that this option has nothing to do with word splitting. -(See noderef(Parameter Expansion).) +(See +ifzman(zmanref(zshexpn))\ +ifnzman(noderef(Parameter Expansion)).) ) pindex(TRAPS_ASYNC) pindex(NO_TRAPS_ASYNC) diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 9ad228679..8daf33d5e 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -129,7 +129,7 @@ both var(key) and var(value) undergo all forms of expansion allowed for single word shell expansions (this does not include filename generation); these are as performed by the parameter expansion flag tt(LPAR()e+RPAR()) as described in -ifzman(zmanref(zshparam))\ +ifzman(zmanref(zshexpn))\ ifnzman(noderef(Parameter Expansion)). Nested parentheses may surround var(value) and are included as part of the value, which is joined into a plain string; this differs from ksh which @@ -629,7 +629,7 @@ startitem() vindex(!) item(tt(!) <S>)( The process ID of the last command started in the background with tt(&), -or put into the background with the tt(bg) builtin. +put into the background with the tt(bg) builtin, or spawned with tt(coproc). ) vindex(#) item(tt(#) <S>)( @@ -1674,7 +1674,7 @@ For example, with the tt(EXTENDED_GLOB) option set, the following: example(watch=('^(pws|barts)')) -causes reports for activity assoicated with any user other than tt(pws) +causes reports for activity associated with any user other than tt(pws) or tt(barts). ) vindex(WATCHFMT) diff --git a/Doc/Zsh/redirect.yo b/Doc/Zsh/redirect.yo index 7e38cd0c3..2b48974b4 100644 --- a/Doc/Zsh/redirect.yo +++ b/Doc/Zsh/redirect.yo @@ -42,18 +42,18 @@ otherwise, it is truncated to zero length. xitem(tt(>|) var(word)) item(tt(>!) var(word))( Same as tt(>), except that the file is truncated to zero length -if it exists, even if tt(CLOBBER) is unset. +if it exists, regardless of tt(CLOBBER). ) item(tt(>>) var(word))( Open file var(word) for writing in append mode as standard output. -If the file does not exist, and the tt(CLOBBER) -option is unset, this causes an error; +If the file does not exist, and the tt(CLOBBER) and tt(APPEND_CREATE) +options are both unset, this causes an error; otherwise, the file is created. ) xitem(tt(>>|) var(word)) item(tt(>>!) var(word))( Same as tt(>>), except that the file is created if it does not -exist, even if tt(CLOBBER) is unset. +exist, regardless of tt(CLOBBER) and tt(APPEND_CREATE). ) item(tt(<<)[tt(-)] var(word))( The shell input is read up to a line that is the same as @@ -182,7 +182,8 @@ indent(... tt({myfd}>&1)) This opens a new file descriptor that is a duplicate of file descriptor 1 and sets the parameter tt(myfd) to the number of the file descriptor, which will be at least 10. The new file descriptor can be written to using -the syntax tt(>&$myfd). +the syntax tt(>&$myfd). The file descriptor remains open in subshells +and forked external executables. The syntax tt({)var(varid)tt(}>&-), for example tt({myfd}>&-), may be used to close a file descriptor opened in this fashion. Note that the diff --git a/Doc/Zsh/restricted.yo b/Doc/Zsh/restricted.yo index 6cf9b36b5..33dfc96c6 100644 --- a/Doc/Zsh/restricted.yo +++ b/Doc/Zsh/restricted.yo @@ -37,3 +37,48 @@ Restricted mode can also be activated any time by setting the tt(RESTRICTED) option. This immediately enables all the restrictions described above even if the shell still has not processed all startup files. + +A shell em(Restricted Mode) is an outdated way to restrict what users may +do: modern systems have better, safer and more reliable ways to +confine user actions, such as em(chroot jails), em(containers) and +em(zones). + +A restricted shell is very difficult to implement safely. The feature +may be removed in a future version of zsh. + +It is important to realise that the restrictions only apply to the shell, +not to the commands it runs (except for some shell builtins). While a +restricted shell can only run the restricted list of commands accessible +via the predefined `tt(PATH)' variable, it does not prevent those +commands from running any other command. + +As an example, if `tt(env)' is among the list of em(allowed) commands, +then it allows the user to run any command as `tt(env)' is not a shell +builtin command and can run arbitrary executables. + +So when implementing a restricted shell framework it is important to be +fully aware of what actions each of the em(allowed) commands or features +(which may be regarded as em(modules)) can perform. + +Many commands can have their behaviour affected by environment +variables. Except for the few listed above, zsh does not restrict +the setting of environment variables. + +If a `tt(perl)', `tt(python)', `tt(bash)', or other general purpose +interpreted script it treated as a restricted +command, the user can work around the restriction by +setting specially crafted `tt(PERL5LIB)', `tt(PYTHONPATH)', +`tt(BASHENV)' (etc.) environment variables. On GNU systems, any +command can be made to run arbitrary code when performing character set +conversion (including zsh itself) by setting a `tt(GCONV_PATH)' +environment variable. Those are only a few examples. + +Bear in mind that, contrary to some other shells, `tt(readonly)' is not a +security feature in zsh as it can be undone and so cannot be used to +mitigate the above. + +A restricted shell only works if the allowed commands are few +and carefully written so as not to grant more access to users than +intended. It is also important to restrict what zsh module the user may +load as some of them, such as `tt(zsh/system)', `tt(zsh/mapfile)' and +`tt(zsh/files)', allow bypassing most of the restrictions. diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index c2b9f5430..c928b8ca2 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -2415,9 +2415,12 @@ directory, or changes to the value of variables referred to by the prompt). Otherwise, the prompt is only expanded each time zle starts, and -when the display as been interrupted by output from another part of the +when the display has been interrupted by output from another part of the shell (such as a job notification) which causes the command line to be reprinted. + +tt(reset-prompt) doesn't alter the special parameter tt(LASTWIDGET). + ) tindex(send-break) item(tt(send-break) (tt(^G ESC-^G)) (unbound) (unbound))( @@ -2726,10 +2729,10 @@ limited to 256 (i.e. the range 0 to 255). Some modern terminal emulators have support for 24-bit true colour (16 million colours). In this case, the hex triplet format can be used. This -consists of either a three or six digit hexadecimal number describing -the red, green and blue components of the colour. Hex triplets can also -be used with 88 and 256 colour terminals via the tt(zsh/nearcolor) -module (see ifzman(zmanref(zshmodules))\ +consists of a `tt(#)' followed by either a three or six digit hexadecimal +number describing the red, green and blue components of the colour. Hex +triplets can also be used with 88 and 256 colour terminals via the +tt(zsh/nearcolor) module (see ifzman(zmanref(zshmodules))\ ifnzman(noderef(The zsh/nearcolor Module))\ ). diff --git a/Doc/intro.ms b/Doc/intro.ms index fcca33dd8..4dd08f601 100644 --- a/Doc/intro.ms +++ b/Doc/intro.ms @@ -2146,7 +2146,7 @@ Of course, a hackish workaround is available in sh (and \fBzsh\fP): %\0ll\0'fuu\0bar' fuu\0bar\0not\0found .De -If you like the sh behaviour, \fBzsh\fP can accomodate you: +If you like the sh behaviour, \fBzsh\fP can accommodate you: .Ds %\0ls\0${=srcs} exec.c\0\0glob.c\0\0init.c @@ -2441,7 +2441,7 @@ and command line while leaving command output unhighlighted, try this: %\0POSTEDIT=`echotc\0se` %\0PROMPT='%S%%\0' .De -This trick is mostly superceded by the zle_highlight array parameter. +This trick is mostly superseded by the zle_highlight array parameter. .Sh "Login/logout watching" .PP You can specify login or logout events to monitor @@ -26,3 +26,8 @@ skipped when STTY=... is set for that command 41203 and others: Make it easier to maintain C modules out of tree. (May require defining a stable API for modules, see 41254) ------------------------------------------------------------------------ +44007 - Martijn - exit in trap executes rest of function +See test case in Test/C03traps.ztst. +------------------------------------------------------------------------ +45282: ${${:-foo}:P} where foo is a symlink that points to itself segfaults +------------------------------------------------------------------------ diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo index c4f65e97a..d1f8b7d83 100644 --- a/Etc/FAQ.yo +++ b/Etc/FAQ.yo @@ -128,6 +128,7 @@ Chapter 3: How to get various things to work 3.27. What are these `^' and `~' pattern characters, anyway? 3.28. How do I edit the input buffer in $EDITOR? 3.29. Why does `which' output for missing commands go to stdout? +3.30. Why doesn't the expansion mytt(*.{tex,aux,pdf}) do what I expect? Chapter 4: The mysteries of completion 4.1. What is completion? @@ -307,7 +308,7 @@ sect(On what machines will it run?) sect(What's the latest version?) - Zsh 5.7.1 is the latest production version. For details of all the + Zsh 5.8 is the latest production version. For details of all the changes, see the NEWS file in the source distribution. A beta of the next version is sometimes available. Development of zsh is @@ -1389,7 +1390,7 @@ sect(Why do my autoloaded functions not autoload [the first time]?) redefine the function when you called it. From version 3.1, there is an option tt(KSH_AUTOLOAD) to allow full ksh - compatiblity, i.e. the function myem(must) be in the second form + compatibility, i.e. the function myem(must) be in the second form above. If that is not set, zsh tries to guess which form you are using: if the file contains only a complete definition of the function in the second form, and nothing else apart from comments @@ -1935,7 +1936,7 @@ label(327) operator. As the mytt(**) operator cannot be grouped (inside parentheses it is treated as mytt(*)), this is one way to exclude some subdirectories from matching a mytt(**). Note that this can be quite - inefficent because the shell performs a complete search for + inefficient because the shell performs a complete search for mytt(**/foo) before it uses the pattern after the mytt(~) to exclude files from the match. The file is excluded if mytt(bar) occurs em(anywhere), in any directory segment or the final file name. @@ -1995,6 +1996,44 @@ sect(Why does `which' output for missing commands go to stdout?) the exit status does reflect the fact the command can't be found. +sect(Why doesn't the expansion mytt(*.{tex,aux,pdf}) do what I expect?) + + Based on the behaviour of some other shells, you might guess that the + following expression: + verb( + echo *.{tex,aux,pdf} + ) + would be the way to echo any files ending in mytt(.tex), mytt(.aux) or + mytt(.pdf) in the current directory. Depending on your settings for + matching (see link(2.1)(21), in particular tt(NO_NOMATCH)), you may + see something else, in particular an error about (say) mytt(*.aux) if + there were no files ending mytt(.aux). + + The reason for this is that the brace expansion isn't actually + a form of pattern matching. Instead, the line above is equivalent to + verb( + echo *.tex *.aux *.pdf + ) + giving you three separate patterns. With the default mytt(NOMATCH) + behaviour in effect, any pattern that fails to match is an error. + + However, there em(is) a way of doing exactly what you want, using + parentheses instead of braces: + verb( + echo *.(tex|aux|pdf) + ) + This is now a pattern matching expression, so is considered as a + single pattern. Now any file that exists will suppress the + mytt(NOMATCH) behaviour, but you'll still get all the files that do + match. + + This use of parentheses is special to zsh. Modern Bourne-like shells + have a syntax like this, too, but with an mytt(@) in front of the + parentheses: again, see link(2.1)(21), and search for mytt(@+LPAR()). + This is harder for the user to remember but easier for the shell to + parse! + + chapter(The mysteries of completion) @@ -2205,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 @@ -2224,22 +2263,21 @@ sect(How does zsh handle multibyte input and output?) cause all sorts of odd effects. (It was possible to edit in zsh using single-byte extensions of ASCII such as the ISO 8859 family, however.) - From version 4.3.4, multibyte input is handled in the line editor if zsh - has been compiled with the appropriate definitions, and is automatically - activated. This is indicated by the option tt(MULTIBYTE), which is - set by default on shells that support multibyte mode. Hence you - can test this with a standard option test: `tt([[ -o multibyte ]])'. + From version 4.3.4 (stable versions starting from 5.0), multibyte + input is handled in the line editor if zsh has been compiled with the + appropriate definitions, and is automatically activated. This is + indicated by the option tt(MULTIBYTE), which is set by default on + shells that support multibyte mode. Hence you can test this with a + standard option test: `tt([[ -o multibyte ]])'. The tt(MULTIBYTE) option affects the entire shell: parameter expansion, pattern matching, etc. count valid multibyte character strings as a single character. You can unset the option locally in a function to revert to single-byte operation. - Note that if the shell is emulating a Bourne shell the tt(MULTIBYTE) - option is unset by default. This allows various POSIX modes to - work normally (POSIX does not deal with multibyte characters). If - you use a "sh" or "ksh" emulation interactively you should probably - set the tt(MULTIBYTE) option. + As multibyte characters are nowadays standard across most utilities, + since 5.1 the tt(MULTBYTE) option has been turned on when emulating + other shells. The other option that affects multibyte support is tt(COMBINING_CHARS), new in version 4.3.9. When this is set, any zero-length punctuation @@ -2272,17 +2310,19 @@ sect(How do I ensure multibyte input and output work on my system?) itemization( it() The locale. This describes a whole series of features specific - to countries or regions of which the character set is one. Usually - it is controlled by the environment variable tt(LANG) (there are - others but this is the one to start with). You need to find a - locale whose name contains mytt(UTF-8). This will be a variant on - your usual locale, which typically indicates the language and - country; for example, mine is mytt(en_GB.UTF-8). Luckily, zsh can - complete locale names, so if you have the new completion system - loaded you can type mytt(export LANG=) and attempt to complete a - suitable locale. It's the locale that tells the shell to expect the - right form of multibyte input. (However, there's no guarantee that - the shell is actually going to get this input: for example, if you + to countries or regions of which the character set is one. + Usually it is controlled by the environment variable tt(LANG) + (there are others but this is the one to start with). If you have + a recent operating system, very likely it is already set + appropriately. Otherwise, you need to find a locale whose name + contains mytt(UTF-8). This will be a variant on your usual + locale, which typically indicates the language and country; for + example, mine is mytt(en_GB.UTF-8). Luckily, zsh can complete + locale names, so if you have the new completion system loaded you + can type mytt(export LANG=) and attempt to complete a suitable + locale. It's the locale that tells the shell to expect the right + form of multibyte input. (However, there's no guarantee that the + shell is actually going to get this input: for example, if you edit file names that have been created using a different character set it won't work properly.) it() The terminal emulator. Those that are supplied with a recent @@ -2443,7 +2483,7 @@ label(52) tt(unsubscribe) to unsubscribe. The mailing software (tt(ezlm)) has various bells and whistles: you can retrieve archived messages. Mail email(zsh-workers-help@zsh.org) for detailed information. - Adminstrative matters are best sent to + Administrative matters are best sent to email(zsh-workers-owner@zsh.org). real name is email(Geoff Wing <gcw@zsh.org>). diff --git a/Etc/completion-style-guide b/Etc/completion-style-guide index af7c46bfd..53d522764 100644 --- a/Etc/completion-style-guide +++ b/Etc/completion-style-guide @@ -69,12 +69,35 @@ for example, do not use: '--timeout[specify connection timeout in milliseconds]:timeout' but use: '--timeout[specify connection timeout]:timeout (ms)' - +To indicate a default value, use square brackets: + '--timeout[specify connection timeout]:timeout (ms) [5000]' +These two conventions can be used together or individually as appropriate. + Group descriptions should be singular because only one thing is being completed even though many may be listed. This applies even where you complete a list of the things. Tags, functions for completing types of things (such as _files), and states should have plural names. +Group descriptions can be omitted where they are handled by a helper/type +function. For example, the `file' description in the following line is +unnecessary, as `_files' provides it by default: + '--import=[import specified file]:file:_files' +In this case, the following syntax can be used instead: + '--import=[import specified file]: :_files' +Of course, it may make sense to add an explicit description which is +more specific than the default: + '--config=[use specified config file]:config file:_files' + +Similarly, group descriptions can and should be omitted where a `->state' +is involved, as the description in the argument spec is always ignored +in these cases. For example, instead of: + '--config=[use specified config file]:config file:->config-files' +use: + '--config=[use specified config file]: :->config-files' +Setting an explicit description here constitutes (a small amount of) +unnecessary noise, and may be misleading to other developers who update +the function. + In a function, allow any descriptions passed as an argument to override the default you define. For example: _wanted directories expl directory _files -/ "$@" - diff --git a/Etc/creating-a-release.txt b/Etc/creating-a-release.txt index dfde269ae..805ff2ce0 100644 --- a/Etc/creating-a-release.txt +++ b/Etc/creating-a-release.txt @@ -6,37 +6,58 @@ To create a zsh release: - Bump or update: Config/version.mk to today's date - Config/version.mk version number (sequence: 5.4.2, 5.4.2-dev-$((i++)), 5.4.2-test-$((++j)), 5.5) + Config/version.mk version number Etc/FAQ.yo README NEWS + The version-number sequence is as follows: + + 5.8, 5.8.0.1-dev, 5.8.0.2-test, 5.8.1, 5.8.1.1-dev, 5.8.1.2-test, 5.9 + + Please note: + + - All version numbers in this document are examples only and may not + reflect the actual version history of the shell. + - A slightly different ordering of version-number components was used + prior to zsh 5.8. All subsequent releases should use the scheme + described above. + - Usually there is only one -dev version (1-dev), but there may be more + if for example there is a wordcode compatibility break, in which case + the sequence would be something like 1-dev, 2-dev, 3-test, .... No + special release process is associated with a -dev version bump. + - Usually at least one -test version is released for public testing in + the lead-up to the final release of the next stable version. + README should document compatibility-breaking changes. Generally, NEWS should document new features and major bug fixes (but not routine fixes or changes to completion/contrib functions). + For -test releases, you may update the FAQ, README, etc., to refer to the + upcoming stable version number. + - Commit those changes with an "unposted" ChangeLog entry. - git commit -am "Test release: 5.5.1-test-1." && + git commit -am "Test release: 5.8.1.2-test." && zshdev-add-nnnnn-and-changelog unposted # (Everyone has a different way of getting the "unposted" magic string # into ChangeLog and the log message. This script is how I do it; YMMV; # see Etc/zsh-development-guide for alternative scripts.) -- Create signed git tag named "zsh-5.5.1-..." (not "5.5.1-...") +- Create signed git tag named "zsh-5.8.1..." (not "5.8.1...") - git tag --sign -m "Tag version zsh-5.5.1-test-1." zsh-5.5.1-test-1 + git tag --sign -m "Tag version zsh-5.8.1.2-test." zsh-5.8.1.2-test - If the tagged release is a stable release (as opposed to a test release): - vi Config/version.mk # bump to 5.6-dev-0 and tomorrow's date + vi Config/version.mk # bump to 5.9.0.1-dev and tomorrow's date git commit -am "Post-release version bump." && zshdev-add-nnnnn-and-changelog unposted # or local equivalent (see above) - Create tarball: - git checkout zsh-5.5.1-test-1 + git checkout zsh-5.8.1.2-test git diff HEAD # ensure no local mods rm -f Doc/help.txt Doc/help/[_a-zA-Z0-9]* # some devs have had issues with these Util/preconfig && ./configure ... @@ -45,16 +66,20 @@ To create a zsh release: make tarxz-doc tarxz-src for i in zsh*.tar.?z ; do gpg -ab -- $i ; done -- [one time step] Add your key to http://zsh.sf.net/Arc/source.html; see README in the 'web' repository for how to do this. Its URL is: +- [one time step] Add your key to http://zsh.sf.net/Arc/source.html; see README + in the 'web' repository for how to do this. Its URL is: git clone git://git.code.sf.net/p/zsh/web git clone ssh://git.code.sf.net/p/zsh/web -- Upload to sf.net +- Upload to sf.net: Test releases go to the "zsh-test" directory. Stable releases to zsh/ and zsh-doc/. - After uploading, select the tar.xz artifact, press the 🛈 button ("View Details") to its right, and press [Select All] next to "Default Download For:". This should cause sf.net to offer that artifact in the "Looking for the latest version?" line. + For stable releases only, after uploading, select the tar.xz artifact + under zsh/, press the 🛈 button ("View Details") to its right, and press + [Select All] next to "Default Download For:". This should cause sf.net + to offer that artifact in the "Looking for the latest version?" line. - If the new release is a stable release, update zsh.sf.net: @@ -94,8 +119,8 @@ To create a zsh release: # several minutes to appear afterwards rsync ... -- Upload the build artefacts to zsh.org/pub; you may need assistance from - another dev if you don't have access to do this. +- For stable releases, upload the build artefacts to zsh.org/pub; you may need + assistance from another dev if you don't have access to do this. - Post to -workers@ diff --git a/Etc/zsh-development-guide b/Etc/zsh-development-guide index ecbd3c081..cbada7de9 100644 --- a/Etc/zsh-development-guide +++ b/Etc/zsh-development-guide @@ -891,7 +891,7 @@ The wrapper function should be defined like: The first two arguments should only be used to pass them to `runshfunc()' which will execute the shell function. The last argument is the name of the function to be executed. The arguments passed to -the function can be accessed vie the global variable `pparams' (a +the function can be accessed via the global variable `pparams' (a NULL-terminated array of strings). The return value of the wrapper function should be zero if it calls diff --git a/Functions/Chpwd/zsh_directory_name_generic b/Functions/Chpwd/zsh_directory_name_generic index aa4bf9b84..df21af598 100644 --- a/Functions/Chpwd/zsh_directory_name_generic +++ b/Functions/Chpwd/zsh_directory_name_generic @@ -69,25 +69,32 @@ elif [[ $1 = d ]]; then local _zdn_rest=$_zdn_dir local -a _zdn_cpts local _zdn_pref _zdn_pref_raw _zdn_matched _zdn_cpt _zdn_name + local _zdn_pref_matched _zdn_rest_matched + integer _zdn_matchlen _zdn_len1 while [[ -n $_zdn_var && -n $_zdn_rest ]]; do + _zdn_matchlen=0 _zdn_assoc=(${(Pkv)_zdn_var}) - # Sorting in descending order will ensure prefixes - # come after longer strings with that perfix, so - # we match more specific directory names preferentially. _zdn_cpts=(${(Ov)_zdn_assoc}) _zdn_cpt='' for _zdn_pref_raw in $_zdn_cpts; do _zdn_pref=${_zdn_pref_raw%/:*} [[ -z $_zdn_pref ]] && continue if [[ $_zdn_rest = $_zdn_pref(#b)(/|)(*) ]]; then - _zdn_cpt=${(k)_zdn_assoc[(r)$_zdn_pref_raw]} - # if we matched a /, too, add it... - _zdn_matched+=$_zdn_pref$match[1] - _zdn_rest=$match[2] - break + _zdn_len1=${#_zdn_pref} + if (( _zdn_len1 > _zdn_matchlen )); then + _zdn_matchlen=$_zdn_len1 + _zdn_cpt=${(k)_zdn_assoc[(r)$_zdn_pref_raw]} + # if we matched a /, too, add it... + _zdn_pref_matched=$_zdn_pref$match[1] + _zdn_rest_matched=$match[2] + fi fi done + if (( _zdn_matchlen )); then + _zdn_matched+=$_zdn_pref_matched + _zdn_rest=$_zdn_rest_matched + fi if [[ -n $_zdn_cpt ]]; then _zdn_name+=${_zdn_name:+${_zdh_name}:}$_zdn_cpt if [[ ${_zdn_assoc[$_zdn_cpt]} = (#b)*/:([[:IDENT:]]##) ]]; then diff --git a/Functions/Newuser/zsh-newuser-install b/Functions/Newuser/zsh-newuser-install index e4028fd50..60ac16b13 100644 --- a/Functions/Newuser/zsh-newuser-install +++ b/Functions/Newuser/zsh-newuser-install @@ -899,7 +899,6 @@ __zni_options_config() { # The "no" prefix is used to indicate options on by default. __zni_apply_defaults -o autocd '' "Change directory given just path." \ extendedglob '' "Use additional pattern matching features." \ - appendhistory '' "Append new history lines instead of overwriting." \ '!nomatch' '' "Unmatched patterns cause an error." \ '!beep' '' "Beep on errors." \ notify '' "Immediately report changes in background job status." diff --git a/Functions/Prompts/prompt_oliver_setup b/Functions/Prompts/prompt_oliver_setup index 979411d4b..2df919950 100644 --- a/Functions/Prompts/prompt_oliver_setup +++ b/Functions/Prompts/prompt_oliver_setup @@ -5,7 +5,7 @@ prompt_oliver_help() { With this prompt theme, the prompt contains the current directory, history number, number of jobs (if non-zero) and the previous command's exit code (if non-zero) and a final character which -depends on priviledges. +depends on privileges. The colour of the prompt depends on two associative arrays - $pcolour and $tcolour. Each array is indexed by the name of the diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_git b/Functions/VCS_Info/Backends/VCS_INFO_detect_git index 61bc483e3..e4191f474 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_git @@ -6,8 +6,7 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && { print -l git-p4 git-svn; return 0 } -if VCS_INFO_check_com ${vcs_comm[cmd]} && ${vcs_comm[cmd]} rev-parse --is-inside-work-tree &> /dev/null ; then - vcs_comm[gitdir]="$(${vcs_comm[cmd]} rev-parse --git-dir 2> /dev/null)" || return 1 +if VCS_INFO_check_com ${vcs_comm[cmd]} && vcs_comm[gitdir]="$(${vcs_comm[cmd]} rev-parse --git-dir 2> /dev/null)" ; then if [[ -d ${vcs_comm[gitdir]}/svn ]] ; then vcs_comm[overwrite_name]='git-svn' elif [[ -d ${vcs_comm[gitdir]}/refs/remotes/p4 ]] ; then vcs_comm[overwrite_name]='git-p4' ; fi return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs index e9d172052..9b828bd11 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs @@ -5,11 +5,17 @@ setopt localoptions NO_shwordsplit local cvsbranch cvsbase +# Look for the most distant parent that still has a CVS subdirectory. +# VCS_INFO_detect_cvs ensured that ./CVS/Repository exists. cvsbase="." -while [[ -d "${cvsbase}/../CVS" ]]; do - cvsbase="${cvsbase}/.." -done cvsbase=${cvsbase:P} +while [[ -d "${cvsbase:h}/CVS" ]]; do + cvsbase="${cvsbase:h}" + if [[ $cvsbase == '/' ]]; then + break + fi +done + cvsbranch=$(< ./CVS/Repository) rrn=${cvsbase:t} cvsbranch=${cvsbranch##${rrn}/} diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn index c1547950f..21590addd 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn @@ -46,17 +46,19 @@ if (( ${+svninfo[Working_Copy_Root_Path]} )); then ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}" | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done else # svn 1.0-1.6 - while [[ -d "${svnbase}/../.svn" ]]; do + svnbase=${svnbase:P} + while [[ -d "${svnbase:h}/.svn" ]]; do parentinfo=() - ${vcs_comm[cmd]} info --non-interactive -- "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done + ${vcs_comm[cmd]} info --non-interactive -- "${svnbase:h}" | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done [[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break svninfo=(${(kv)parentinfo}) - svnbase="${svnbase}/.." + svnbase=${svnbase:h} + if [[ $svnbase == '/' ]]; then + break + fi done fi -svnbase=${svnbase:P} - rrn=${svnbase:t} zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r" hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" ) diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect index b20c05c9c..29b261413 100644 --- a/Functions/VCS_Info/VCS_INFO_bydir_detect +++ b/Functions/VCS_Info/VCS_INFO_bydir_detect @@ -2,6 +2,18 @@ ## Written by Frank Terbeck <ft@bewatermyfriend.org> ## Distributed under the same BSD-ish license as zsh itself. +# Helper function for VCS_INFO_detect_* +# +# Usage: +# vcs_comm[detect_need_file]=FILENAMES VCS_INFO_bydir_detect DIRNAME +# where DIRNAME is a directory name and FILENAMES is a space-separated list +# of filenames. +# +# If any parent directory of the current working directory, other than the root +# directory, contains a subdirectory named DIRNAME that contains a file whose name +# is in FILENAMES, set vcs_comm[basedir] to the path of that parent directory and +# return true. Otherwise, return false. + setopt localoptions NO_shwordsplit local dirname=$1 local basedir="." file diff --git a/Functions/VCS_Info/VCS_INFO_patch2subject b/Functions/VCS_Info/VCS_INFO_patch2subject index a48c16b04..a467edcdb 100644 --- a/Functions/VCS_Info/VCS_INFO_patch2subject +++ b/Functions/VCS_Info/VCS_INFO_patch2subject @@ -14,10 +14,7 @@ IFS= read -r "lines[$i]" if [[ -z ${lines[$i]} ]] || [[ ${lines[$i]} == (#b)(---[^-]|Index:)* ]]; then lines[$i]=() - # For 'svn log -r N --diff' output, read the first paragraph too. - if ! [[ $lines[i-1] =~ $svn_log_pattern ]]; then - break - fi + break fi done < "$1" @@ -55,9 +52,18 @@ fi } < "$1" REPLY=$needle - elif [[ $lines[2] =~ $svn_log_pattern ]]; then - REPLY=$lines[4] - if (( ${+lines[5]} )); then REPLY+='...'; fi + elif [[ $lines[1] =~ $svn_log_pattern ]] || [[ $lines[2] =~ $svn_log_pattern ]]; then + # Read up to the next blank line, and the first two lines after it. + integer multiline=0 + { + while read -r needle; [[ -n $needle ]]; do done + # Read the first line of the second paragraph, which is the first + # line of the log message. + read -r needle + read -r && [[ -n $REPLY ]] && multiline=1 + } < "$1" + REPLY=$needle + if (( multiline )); then REPLY+='...'; fi elif (( ${+lines[1]} )); then # The first line of the file is not part of the diff. REPLY=${lines[1]} diff --git a/Functions/VCS_Info/VCS_INFO_quilt b/Functions/VCS_Info/VCS_INFO_quilt index 1f20e895d..fef85964a 100644 --- a/Functions/VCS_Info/VCS_INFO_quilt +++ b/Functions/VCS_Info/VCS_INFO_quilt @@ -78,7 +78,7 @@ function VCS_INFO_quilt-dirfind() { VCS_INFO_bydir_detect ${dir} ret=$? vcs_comm[detect_need_file]=${oldfile} - printf '%s' ${vcs_comm[basedir]} + REPLY=${vcs_comm[basedir]} vcs_comm[basedir]="${olddir}" return ${ret} } @@ -113,8 +113,8 @@ function VCS_INFO_quilt-patch2subject() { ;; esac - pc="$(VCS_INFO_quilt-dirfind .pc .version)" - ret=$? + VCS_INFO_quilt-dirfind .pc .version + ret=$? pc=$REPLY if (( ret == 0 )); then [[ ${quiltmode} == 'standalone' ]] && root=${pc} pc=${pc}/.pc @@ -138,8 +138,8 @@ function VCS_INFO_quilt-patch2subject() { zstyle -s "${context}" quilt-patch-dir patches || patches="${QUILT_PATCHES}" if [[ "${patches}" != /* ]]; then tmp=${patches:-patches} - patches="$(VCS_INFO_quilt-dirfind "${tmp}")" - ret=$? + VCS_INFO_quilt-dirfind "${tmp}" + ret=$? patches=$REPLY (( ret )) && return ${ret} patches=${patches}/${tmp} else diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index d67ae6bf5..9f48bee75 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -59,6 +59,12 @@ vcs_info () { local -x LC_MESSAGES local -i maxexports local -a msgs + + # vcs_comm is used internally for passing values among VCS_INFO_* functions. + # It is not part of the public API. + # + # hook_com, backend_misc, and user_data are public API; see zshcontrib(1) + # and Misc/vcs_info-examples. local -A vcs_comm hook_com backend_misc user_data LC_MESSAGES=C 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/Functions/Zle/bracketed-paste-magic b/Functions/Zle/bracketed-paste-magic index 4baae823e..840091b44 100644 --- a/Functions/Zle/bracketed-paste-magic +++ b/Functions/Zle/bracketed-paste-magic @@ -162,7 +162,7 @@ bracketed-paste-magic() { # There are active widgets. Reprocess $PASTED as keystrokes. NUMERIC=1 - zle -U - $PASTED + zle -U - "$PASTED" # Just in case there are active undo widgets @@ -212,7 +212,7 @@ bracketed-paste-magic() { # Arrange to display highlighting if necessary if [[ -z $zle_highlight || -n ${(M)zle_highlight:#paste:*} ]]; then zle -R - zle .read-command && zle -U - $KEYS + zle .read-command && zle -U - "$KEYS" fi } diff --git a/Functions/Zle/insert-composed-char b/Functions/Zle/insert-composed-char index c0922e7d4..636895a89 100644 --- a/Functions/Zle/insert-composed-char +++ b/Functions/Zle/insert-composed-char @@ -27,7 +27,7 @@ # ' Acute # > Circumflex # ? Tilde -# - Macron. (A horizonal bar over the letter.) +# - Macron. (A horizontal bar over the letter.) # ( Breve. (A shallow dish shape over the letter.) # . Dot above, or no dot with lower case i, or dot in the middle of L or l. # : Diaeresis (Umlaut) @@ -43,7 +43,7 @@ # 9 Horn # Hence A! is upper case A with a grave, c, is lower case c with cedilla. # -# Some other composed charaters: +# Some other composed characters: # Various ligatures: # AE ae OE oe IJ ij # diff --git a/Functions/Zle/smart-insert-last-word b/Functions/Zle/smart-insert-last-word index cf8715dfe..05f23cba6 100644 --- a/Functions/Zle/smart-insert-last-word +++ b/Functions/Zle/smart-insert-last-word @@ -48,13 +48,14 @@ zle auto-suffix-retain # Not strictly necessary: # (($+_ilw_hist)) || integer -g _ilw_hist _ilw_count _ilw_cursor _ilw_lcursor _ilw_changeno +# (($+_ilw_result)) || typeset -g _ilw_result integer cursor=$CURSOR lcursor=$CURSOR local lastcmd pattern numeric=$NUMERIC # Save state for repeated calls if (( HISTNO == _ilw_hist && cursor == _ilw_cursor && - UNDO_CHANGE_NO == _ilw_changeno )) + UNDO_CHANGE_NO == _ilw_changeno )) && [[ $BUFFER == $_ilw_result ]] then NUMERIC=$[_ilw_count+1] lcursor=$_ilw_lcursor @@ -119,7 +120,7 @@ fi (( NUMERIC > $#lastcmd )) && return 1 LBUFFER[lcursor+1,cursor+1]=$lastcmd[-NUMERIC] -typeset -g _ilw_cursor=$CURSOR +typeset -g _ilw_cursor=$CURSOR _ilw_result=$BUFFER # This is necessary to update UNDO_CHANGE_NO immediately zle split-undo && typeset -g _ilw_changeno=$UNDO_CHANGE_NO @@ -251,6 +251,16 @@ source code in the directory that "configure" is in. For example, Note that this is mutually exclusive with using the source directories as make can become confused by build files created in the source directories. +Writing third-party autoloadable functions +------------------------------------------ + +Third-party autoloadable functions, including but not limited to completion +functions, should be installed into the share/zsh/site-functions/ directory +under the respective installation prefix. That would typically be written as +$(DESTDIR)$(PREFIX)/share/zsh/site-functions/ in a makefile. If the +third-party tool's $(PREFIX) is not the same as zsh's prefix, then that +directory should be added to $fpath in zsh's initialization files. + ================================ AUTOMATIC NEW USER CONFIGURATION @@ -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/Misc/vcs_info-examples b/Misc/vcs_info-examples index 58dd8cf98..456b3a85b 100644 --- a/Misc/vcs_info-examples +++ b/Misc/vcs_info-examples @@ -212,6 +212,41 @@ function +vi-git-remotebranch() { } +### Derive hook names dynamically +# With the following line: +zstyle -e ':vcs_info:git+set-message:*' hooks 'reply=( ${${(k)functions[(I)[+]vi-git-set-message*]}#+vi-} )' +# Any function named `+vi-git-set-message-<anything>' would be automatically +# registered as a hook. For example: ++vi-git-set-message-foo() {} ++vi-git-set-message-bar() {} +# Both of these functions would be called, even if they are defined after the zstyle is set. + + +## git: Display pertinent environment variables +# If environment variables such as $GIT_DIR, $GIT_WORK_TREE, etc are set in the +# environment, they'll be shown in the value of the %m expando. +# +# Note that the %m expando is not used by default. To see a change, either change +# `[misc]' to `[branch]', or set the `formats` style to a value that includes `%m'. +zstyle ':vcs_info:git+post-backend:*' hooks git-post-backend-envvars ++vi-git-post-backend-envvars() { + local param + # This uses the ${parameters} special variable (provided by the zsh/parameter + # module), in conjunction with the parameter expansion flags ${(k)foo} and + # ${(M)foo:#pattern} (documented in "Parameter Expansion" in zshexpn(1)) + # and the (R) subscript flag (documented in "Subscript Flags" in zshparam(1)), + # to iterate over the names of all environment variables named "GIT_*". Then + # it uses the ${(P)foo} parameter expansion flag to show the values of those + # parameters. + # + # The value of ${hook_com[misc]} is substituted for %m in the values of the + # 'formats' and 'actionformats' styles. + for param in ${(Mk)parameters[(R)*export*]:#GIT_*}; do + hook_com[misc]+=";%U${param//'%'/%%}%u=%F{white}${${(P)param}//'%'/%%}%f" + done +} + + ### hg: Show marker when the working directory is not on a branch head # This may indicate that running `hg up` will do something # NOTE: the branchheads.cache file is not updated with every Mercurial @@ -433,8 +468,16 @@ zstyle ':vcs_info:-quilt-.quilt-standalone:*:*' quilt-patch-dir debian/patches # and so we want addon mode to also use a $QUILT_PATCHES value of # `debian/patches' in some directories. In the other directories we never # want the default `patches' though but a dedicated place for them. -# Say `~/patches/<repository-name>'. Now we'll use some evaluated-style -# magic to achieve all that: +# Say `~/patches/<repository-name>'. +# +# First of all, even without any configuration, vcs_info will do the right +# thing most of the time. Whenever quilt has already run in a directory, +# vcs_info will figure out whether that directory uses `patches' or +# `debian/patches' by interrogating metadata in the `.pc/' subdirectory, +# which quilt creates. To make vcs_info find the patches dir correctly even +# when the `.pc/' directory doesn't exist, read on. +# +# We'll use some evaluated-style magic to achieve that: zstyle -e ':vcs_info:*.quilt-addon:*:*' quilt-patch-dir 'my-patches-func' # That runs something called `my-patches-func', and the value of $reply is @@ -451,19 +494,17 @@ function my-patches-func() { fi # Now the part about the dedicated directory is a little trickier. - # It requires some knowledge of vcs_info's internals. Not much though. - # Everything about this is described in the manual because this - # variable (plus a few others) may be of interest in hooks, where - # they are available, too. - # - # The variable in question here is `$rrn' which is an abbreviation - # of repository-root-name. if you're in + # The variable in question here is `$context', which is the zstyle + # context used for lookups. Its last component is the repository-root-name, + # or ${rrn} for short. If you're in # /usr/src/zsh/Functions # and the repository being # /usr/src/zsh - # then the value of `$rrn' is `zsh'. Now in case the variable is - # empty (it shouldn't at this point, but you never know), let's - # drop back to quilt's default "patches". + # then the value of `$rrn' would be `zsh'. + local rrn=${context##*:} + + # Now, in case the variable is empty (it shouldn't at this point, but you + # never know), let's drop back to quilt's default value, "patches". if [[ -z ${rrn} ]]; then reply=( patches ) return 0 @@ -4,9 +4,51 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH Note also the list of incompatibilities in the README file. -Changes since 5.6.2 +Changes since 5.7.1 ------------------- +The zsh/zutil module's zparseopts builtin learnt an -F option to abort +parsing when an unrecognised option-like parameter is encountered. + +The zsh/files module gained a chmod builtin. + +Several changes have been made to the way completion functions track +'precommands' (such as `command` and `env`) and determine whether the +command being completed for is a shell builtin. Developers of completion +functions may wish to familiarise themselves with `_normal -p` and +`_pick_variant -b`. + +The option CD_SILENT was added to suppress all output from cd (whether +explicit or implicit with AUTO_CD). It is disabled by default. + +The compadd builtin's -o option now takes an optional argument to +specify the order of completion matches. This affects the display +of candidate matches and the order in which they are selected when +cycling between them using menu completion. + +The :h and :t modifiers in parameter expansion (if braces are present), +glob qualifiers and history expansion may take following decimal digit +arguments in order to keep that many leading or trailing path components +instead of the defaults of all but one (:h) and one (:t). In an absolute +path the leading '/' counts as one component. + +The functions builtin gained a -c option to efficiently copy functions. + +The zshmisc(1) manual page incorrectly stated that when 'exit' is used +in a `try' block inside a function, the corresponding `always' block will +be executed. The manual page has been corrected. The shell's behaviour +has not changed, but code such as the following: +. + f() { { exit } always { echo Hello world } } +. +should be changed either to use 'return' instead of 'exit', or to have +the try/always block outside of any function. + +Changes from 5.6.2 to 5.7.1 +--------------------------- + +There are only minor changes between 5.7 and 5.7.1. + Support for 24-bit true color terminals has been added. Hex triplets can be used when specifying colours for prompts and line editor highlighting. On 88 and 256 colour terminals, a new zsh/nearcolor module @@ -515,7 +557,7 @@ Expansion (parameters, globbing, etc.) and redirection calculated by the (l) and (r) flags or the # operator should take account of the printing width of characters in multibyte mode, whether 0, 1 or more. (mm) causes printing characters to count as 1 and - non-printing chracters to count as 0. + non-printing characters to count as 0. - The parameter substitution flag (q-) picks the most minimal way of quoting the parameter words, to make the result as readable as possible. @@ -5,11 +5,11 @@ THE Z SHELL (ZSH) Version ------- -This is version 5.7.1 of the shell. This is a stable release. There are -a few visible improvements since 5.6 as well as many bugfixes. +This is version 5.8 of the shell. This is a stable release. There are +a few visible improvements since 5.7 as well as many bugfixes. Note in particular the changes highlighted under "Incompatibilities since -5.6.2" below. See NEWS for more information. +5.7.1" below. See NEWS for more information. Installing Zsh -------------- @@ -30,9 +30,35 @@ Zsh is a shell with lots of features. For a list of some of these, see the file FEATURES, and for the latest changes see NEWS. For more details, see the documentation. -Incompatibilities since 5.6.2 +Incompatibilities since 5.7.1 ----------------------------- +The history expansion !:1:t2 used to be interpreted such that the 2 +was a separate character added after the history expansion. Now +it is an argument to the :t modifier. + +For example + +% echo /my/interesting/path +% echo !:1:t2 + +used to echo "path2", but now echoes "interesting/path". + +The behaviour of :h has similarly changed. + +The behaviour has also changed in forms such as ${foo:t2) and *(:t2), +but in those cases the previous behaviour was not meaningful. + +The vcs_info function VCS_INFO_quilt-dirfind now returns a string value +by setting $REPLY. Previously it printed the value to standard output. +This only affects you if you override that function in your dotfiles. + +The cd and chdir builtins no longer interpret operands like -1 and +2 as +stack entries when POSIX_CD is enabled. + +Incompatibilities between 5.6.2 and 5.7.1 +----------------------------------------- + 1) vcs_info git: The gen-unapplied-string hook receives the patches in order (next to be applied first). This is consistent with the hg backend and with one of two contradictory claims in the documentation @@ -181,7 +207,7 @@ of this change is that variables that should have active ranges need [[ b = [${~cset}] ]] The "~" causes the "-" character to be active. In sh emulation the -"~" is unncessary in this example and double quotes must be used to +"~" is unnecessary in this example and double quotes must be used to suppress the range behaviour of the "-". 2) The first argument to 'repeat' is now evaluated as an arithmetic @@ -194,7 +220,7 @@ leading zeroes and the OCTAL_ZEROES option is set. 3) For some time the shell has had a POSIX_TRAPS option which determines whether the EXIT trap has POSIX behaviour (the trap is only run at shell exit) or traditional zsh behaviour (the trap is run once and discarded -when the enclosing fuction or shell exits, whichever happens first). +when the enclosing function or shell exits, whichever happens first). The use of this option has now been made "sticky" on the EXIT trap --- in other words, the setting of the option at the point where the trap is set now determines whether the trap has POSIX or traditional zsh @@ -321,7 +347,7 @@ can be used with both assoiative arrays and normal arrays. In the unlikely event that you wish to create an array with an entry matching a file whose name consists of one of a range of characters matched as a [...] expression, followed by an equal sign, followed -by arbitrary other charaters, it is now necessary to quote the equals +by arbitrary other characters, it is now necessary to quote the equals sign. Incompatibilites between 5.0.7 and 5.0.8 @@ -338,7 +364,7 @@ or both of the arguments were floating point. Now, the C math library fmod() operator is used to implement the operation where one of the arguments is floating point. For example: -Old behavour: +Old behaviour: % print $(( 5.5 % 2 )) 1 diff --git a/Src/Builtins/rlimits.awk b/Src/Builtins/rlimits.awk index fe2d0e931..e9c576c66 100644 --- a/Src/Builtins/rlimits.awk +++ b/Src/Builtins/rlimits.awk @@ -59,6 +59,7 @@ BEGIN {limidx = 0} if (limnam == "NPTS") { msg[limnum] = "Npseudoterminals" } if (limnam == "SWAP") { msg[limnum] = "Mswapsize" } if (limnam == "KQUEUES") { msg[limnum] = "Nkqueues" } + if (limnam == "UMTXP") { msg[limnum] = "Numtxp" } } } } diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c index 29f97b41d..6b552f3a9 100644 --- a/Src/Builtins/rlimits.c +++ b/Src/Builtins/rlimits.c @@ -413,6 +413,12 @@ printulimit(char *nam, int lim, int hard, int head) printf("-k: kqueues "); break; # endif /* HAVE_RLIMIT_KQUEUES */ +# ifdef HAVE_RLIMIT_UMTXP + case RLIMIT_UMTXP: + if (head) + printf("-o: umtx shared locks "); + break; +# endif /* HAVE_RLIMIT_UMTXP */ default: if (head) printf("-N %2d: ", lim); @@ -895,6 +901,11 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) res = RLIMIT_PTHREAD; break; # endif +# ifdef HAVE_RLIMIT_UMTXP + case 'o': + res = RLIMIT_UMTXP; + break; +# endif default: /* unrecognised limit */ zwarnnam(name, "bad option: -%c", *options); diff --git a/Src/Makefile.in b/Src/Makefile.in index 0577554f8..0fdbb73d2 100644 --- a/Src/Makefile.in +++ b/Src/Makefile.in @@ -94,7 +94,6 @@ zsh.res.o: $(sdir)/zsh.rc $(sdir)/zsh.ico stamp-modobjs: modobjs @if cmp -s stamp-modobjs.tmp stamp-modobjs; then \ rm -f stamp-modobjs.tmp; \ - echo "\`stamp-modobjs' is up to date."; \ else \ mv -f stamp-modobjs.tmp stamp-modobjs; \ echo "Updated \`stamp-modobjs'."; \ 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/files.c b/Src/Modules/files.c index 6f816bac0..6d20e38a8 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -613,12 +613,52 @@ bin_rm(char *nam, char **args, Options ops, UNUSED(int func)) rmm.opt_interact = OPT_ISSET(ops,'i') && !OPT_ISSET(ops,'f'); rmm.opt_unlinkdir = OPT_ISSET(ops,'d'); err = recursivecmd(nam, OPT_ISSET(ops,'f'), - OPT_ISSET(ops,'r') && !OPT_ISSET(ops,'d'), + !OPT_ISSET(ops,'d') && (OPT_ISSET(ops,'R') || + OPT_ISSET(ops,'r')), OPT_ISSET(ops,'s'), args, recurse_donothing, rm_dirpost, rm_leaf, &rmm); return OPT_ISSET(ops,'f') ? 0 : err; } +/* chmod builtin */ + +struct chmodmagic { + char *nam; + mode_t mode; +}; + +/**/ +static int +chmod_dochmod(char *arg, char *rp, UNUSED(struct stat const *sp), void *magic) +{ + struct chmodmagic *chm = magic; + + if(chmod(rp, chm->mode)) { + zwarnnam(chm->nam, "%s: %e", arg, errno); + return 1; + } + return 0; +} + +/**/ +static int +bin_chmod(char *nam, char **args, Options ops, int func) +{ + struct chmodmagic chm; + char *str = args[0], *ptr; + + chm.nam = nam; + + chm.mode = zstrtol(str, &ptr, 8); + if(!*str || *ptr) { + zwarnnam(nam, "invalid mode `%s'", str); + return 1; + } + + return recursivecmd(nam, 0, OPT_ISSET(ops,'R'), OPT_ISSET(ops,'s'), + args + 1, chmod_dochmod, recurse_donothing, chmod_dochmod, &chm); +} + /* chown builtin */ struct chownmagic { @@ -754,20 +794,22 @@ static struct builtin bintab[] = { /* The names which overlap commands without necessarily being * fully compatible. */ BUILTIN("chgrp", 0, bin_chown, 2, -1, BIN_CHGRP, "hRs", NULL), + BUILTIN("chmod", 0, bin_chmod, 2, -1, 0, "Rs", NULL), BUILTIN("chown", 0, bin_chown, 2, -1, BIN_CHOWN, "hRs", NULL), BUILTIN("ln", 0, bin_ln, 1, -1, BIN_LN, LN_OPTS, NULL), BUILTIN("mkdir", 0, bin_mkdir, 1, -1, 0, "pm:", NULL), BUILTIN("mv", 0, bin_ln, 2, -1, BIN_MV, "fi", NULL), - BUILTIN("rm", 0, bin_rm, 1, -1, 0, "dfirs", NULL), + BUILTIN("rm", 0, bin_rm, 1, -1, 0, "dfiRrs", NULL), BUILTIN("rmdir", 0, bin_rmdir, 1, -1, 0, NULL, NULL), BUILTIN("sync", 0, bin_sync, 0, 0, 0, NULL, NULL), /* The "safe" zsh-only names */ BUILTIN("zf_chgrp", 0, bin_chown, 2, -1, BIN_CHGRP, "hRs", NULL), + BUILTIN("zf_chmod", 0, bin_chmod, 2, -1, 0, "Rs", NULL), BUILTIN("zf_chown", 0, bin_chown, 2, -1, BIN_CHOWN, "hRs", NULL), BUILTIN("zf_ln", 0, bin_ln, 1, -1, BIN_LN, LN_OPTS, NULL), BUILTIN("zf_mkdir", 0, bin_mkdir, 1, -1, 0, "pm:", NULL), BUILTIN("zf_mv", 0, bin_ln, 2, -1, BIN_MV, "fi", NULL), - BUILTIN("zf_rm", 0, bin_rm, 1, -1, 0, "dfirs", NULL), + BUILTIN("zf_rm", 0, bin_rm, 1, -1, 0, "dfiRrs", NULL), BUILTIN("zf_rmdir", 0, bin_rmdir, 1, -1, 0, NULL, NULL), BUILTIN("zf_sync", 0, bin_sync, 0, 0, 0, NULL, NULL), 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/Modules/system.c b/Src/Modules/system.c index 7a4f4ee13..fb3d80773 100644 --- a/Src/Modules/system.c +++ b/Src/Modules/system.c @@ -174,7 +174,7 @@ bin_sysread(char *nam, char **args, Options ops, UNUSED(int func)) } while ((ret = select(infd+1, (SELECT_ARG_2_T) &fds, - NULL, NULL,&select_tv)) < 1) { + NULL, NULL,&select_tv)) < 0) { if (errno != EINTR || errflag || retflag || breaks || contflag) break; } @@ -316,7 +316,7 @@ bin_sysopen(char *nam, char **args, Options ops, UNUSED(int func)) int o, fd, moved_fd, explicit = -1; mode_t perms = 0666; #if defined(FD_CLOEXEC) && !defined(O_CLOEXEC) - int fdflags; + int fdflags = 0; #endif if (!OPT_ISSET(ops, 'u')) { @@ -396,8 +396,8 @@ bin_sysopen(char *nam, char **args, Options ops, UNUSED(int func)) #endif /* O_CLOEXEC */ fcntl(moved_fd, F_SETFD, FD_CLOEXEC); #endif /* FD_CLOEXEC */ + fdtable[moved_fd] = FDT_EXTERNAL; if (explicit == -1) { - fdtable[moved_fd] = FDT_EXTERNAL; setiparam(fdvar, moved_fd); /* if setting the variable failed, close moved_fd to avoid leak */ if (errflag) diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index 4aaa1f072..e8e239e76 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -237,7 +237,7 @@ enum { /* * We keep an fd open for communication between the main shell * and forked off bits and pieces. This allows us to know - * if something happend in a subshell: mode changed, type changed, + * if something happened in a subshell: mode changed, type changed, * connection was closed. If something too substantial happened * in a subshell --- connection opened, ZFTP_USER and ZFTP_PWD changed * --- we don't try to track it because it's too complicated. @@ -1257,14 +1257,8 @@ zfstats(char *fnam, int remote, off_t *retsize, char **retmdtm, int fd) if (retmdtm) { /* use gmtime() rather than localtime() for consistency */ tm = gmtime(&statbuf.st_mtime); - /* - * FTP format for data is YYYYMMDDHHMMSS - * Using tm directly is easier than worrying about - * incompatible strftime()'s. - */ - sprintf(tmbuf, "%04d%02d%02d%02d%02d%02d", - tm->tm_year + 1900, tm->tm_mon+1, tm->tm_mday, - tm->tm_hour, tm->tm_min, tm->tm_sec); + /* FTP format for date is YYYYMMDDHHMMSS */ + ztrftime(tmbuf, sizeof(tmbuf), "%Y%m%d%H%M%S", tm, 0L); mt = ztrdup(tmbuf); } } @@ -2518,7 +2512,8 @@ zftp_local(UNUSED(char *name), char **args, int flags) #ifdef OFF_T_IS_64_BIT printf("%s %s\n", output64(sz), mt); #else - DPUTS(sizeof(sz) > 4, "Shell compiled with wrong off_t size"); + DPUTS(sizeof(sz) > sizeof(long), + "Shell compiled with wrong off_t size"); printf("%ld %s\n", (long)sz, mt); #endif zsfree(mt); diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 2f83f7ce6..45fd15ee0 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -426,7 +426,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) execode(prog, 1, 0, "zpty"); stopmsg = 2; mypid = 0; /* trick to ensure we _exit() */ - zexit(lastval, 0); + zexit(lastval, ZEXIT_NORMAL); } master = movefd(master); if (master == -1) { diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index 19a8306b5..24659cb16 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -88,7 +88,8 @@ typedef struct style *Style; struct style { struct hashnode node; - Stypat pats; /* patterns */ + Stypat pats; /* patterns, sorted by weight descending, then + by order of definition, newest first. */ }; struct stypat { @@ -337,7 +338,19 @@ setstypat(Style s, char *pat, Patprog prog, char **vals, int eval) p->eval = eprog; p->next = NULL; - /* Calculate the weight. */ + /* Calculate the weight. + * + * The weight of a pattern is scored as follows: + * + * - The pattern is split to colon-separated components. + * - A component equal to '*' (with nothing else) scores 0 points. + * - A component that's a pattern, otherwise, scores 1 point. + * - A component that's a literal string scores 2 points. + * - The score of a pattern is the sum of the score of its components. + * + * This corresponds to the notion of 'more specific' in the zshmodules(1) + * documentation of zstyle. + */ for (weight = 0, tmp = 2, first = 1, str = pat; *str; str++) { if (first && *str == '*' && (!str[1] || str[1] == ':')) { @@ -362,9 +375,9 @@ setstypat(Style s, char *pat, Patprog prog, char **vals, int eval) } p->weight = (weight += tmp); + /* Insert 'q' to 's->pats', using 'qq' as a temporary. */ for (qq = NULL, q = s->pats; q && q->weight >= weight; qq = q, q = q->next); - p->next = q; if (qq) qq->next = p; @@ -1644,7 +1657,7 @@ static int bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) { char *o, *p, *n, **pp, **aval, **ap, *assoc = NULL, **cp, **np; - int del = 0, flags = 0, extract = 0, keep = 0; + int del = 0, flags = 0, extract = 0, fail = 0, keep = 0; Zoptdesc sopts[256], d; Zoptarr a, defarr = NULL; Zoptval v; @@ -1681,6 +1694,14 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) } extract = 1; break; + case 'F': + if (o[2]) { + args--; + o = NULL; + break; + } + fail = 1; + break; case 'K': if (o[2]) { args--; @@ -1843,6 +1864,10 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) if (!(d = lookup_opt(o + 1))) { while (*++o) { if (!(d = sopts[STOUC(*o)])) { + if (fail) { + zwarnnam(nam, "bad option: %c", *o); + return 1; + } o = NULL; break; } diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h index 3e9834560..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 */ @@ -90,6 +90,9 @@ struct cmgroup { #define CGF_PACKED 32 /* LIST_PACKED for this group */ #define CGF_ROWS 64 /* LIST_ROWS_FIRST for this group */ #define CGF_FILES 128 /* contains file names */ +#define CGF_MATSORT 256 /* sort by match rather than by display string */ +#define CGF_NUMSORT 512 /* sort numerically */ +#define CGF_REVSORT 1024 /* sort in reverse */ /* This is the struct used to hold matches. */ @@ -123,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 */ @@ -300,6 +303,9 @@ struct menuinfo { #define CAF_ARRAYS 32 /* compadd -a or -k: array/assoc parameter names */ #define CAF_KEYS 64 /* compadd -k: assoc parameter names */ #define CAF_ALL 128 /* compadd -C: _all_matches */ +#define CAF_MATSORT 256 /* compadd -o match: sort by match rather than by display string */ +#define CAF_NUMSORT 512 /* compadd -o numeric: sort numerically */ +#define CAF_REVSORT 1024 /* compadd -o numeric: sort in reverse */ /* Data for compadd and addmatches() */ diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 0a454ad5f..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. @@ -2080,6 +2080,9 @@ addmatches(Cadata dat, char **argv) /* Select the group in which to store the matches. */ gflags = (((dat->aflags & CAF_NOSORT ) ? CGF_NOSORT : 0) | + ((dat->aflags & CAF_MATSORT) ? CGF_MATSORT : 0) | + ((dat->aflags & CAF_NUMSORT) ? CGF_NUMSORT : 0) | + ((dat->aflags & CAF_REVSORT) ? CGF_REVSORT : 0) | ((dat->aflags & CAF_UNIQALL) ? CGF_UNIQALL : 0) | ((dat->aflags & CAF_UNIQCON) ? CGF_UNIQCON : 0)); if (dat->group) { @@ -3034,8 +3037,9 @@ begcmgroup(char *n, int flags) HEAP_ERROR(p->heap_id); } #endif - if (p->name && - flags == (p->flags & (CGF_NOSORT|CGF_UNIQALL|CGF_UNIQCON)) && + if (p->name && flags == + (p->flags & (CGF_NOSORT|CGF_UNIQALL|CGF_UNIQCON| + CGF_MATSORT|CGF_NUMSORT|CGF_REVSORT)) && !strcmp(n, p->name)) { mgroup = p; @@ -3118,32 +3122,35 @@ addexpl(int always) /* The comparison function for matches (used for sorting). */ +static int matchorder; + /**/ static int matchcmp(Cmatch *a, Cmatch *b) { - if ((*a)->disp && !((*a)->flags & CMF_MORDER)) { - if ((*b)->disp) { - if ((*a)->flags & CMF_DISPLINE) { - if ((*b)->flags & CMF_DISPLINE) - return strcmp((*a)->disp, (*b)->disp); - else - return -1; - } else { - if ((*b)->flags & CMF_DISPLINE) - return 1; - else - return strcmp((*a)->disp, (*b)->disp); - } - } - return -1; + const char *as, *bs; + int cmp = !!(*b)->disp - !!(*a)->disp; + int sortdir = (matchorder & CGF_REVSORT) ? -1 : 1; + + /* if match sorting selected or we have no display strings */ + if ((matchorder & CGF_MATSORT) || (!cmp && !(*a)->disp)) { + as = (*a)->str; + bs = (*b)->str; + } else { + if (cmp) /* matches with display strings come first */ + return cmp; + + cmp = ((*b)->flags & CMF_DISPLINE) - ((*a)->flags & CMF_DISPLINE); + if (cmp) /* sort one-per-line display strings first */ + return cmp; + + as = (*a)->disp; + bs = (*b)->disp; } - if ((*b)->disp && !((*b)->flags & CMF_MORDER)) - return 1; - return zstrcmp((*a)->str, (*b)->str, (SORTIT_IGNORING_BACKSLASHES| - (isset(NUMERICGLOBSORT) ? - SORTIT_NUMERICALLY : 0))); + return sortdir * zstrcmp(as, bs, SORTIT_IGNORING_BACKSLASHES| + ((isset(NUMERICGLOBSORT) || + matchorder & CGF_NUMSORT) ? SORTIT_NUMERICALLY : 0)); } /* This tests whether two matches are equal (would produce the same @@ -3205,6 +3212,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp) } else { if (!(flags & CGF_NOSORT)) { /* Now sort the array (it contains matches). */ + matchorder = flags; qsort((void *) rp, n, sizeof(Cmatch), (int (*) _((const void *, const void *)))matchcmp); diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c index fe87409cb..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. */ @@ -2511,7 +2511,7 @@ makecomplistcmd(char *os, int incmd, int flags) else if (!(cmdstr && (((ccp = (Compctlp) compctltab->getnode(compctltab, cmdstr)) && (cc = ccp->cc)) || - ((s = dupstring(cmdstr)) && remlpaths(&s) && + ((s = dupstring(cmdstr)) && remlpaths(&s, 1) && (ccp = (Compctlp) compctltab->getnode(compctltab, s)) && (cc = ccp->cc))))) { if (flags & CFN_DEFAULT) @@ -3178,7 +3178,27 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) /* Compute line prefix/suffix. */ lpl = offs; lpre = zhalloc(lpl + 1); - memcpy(lpre, s, lpl); + if (comppatmatch) + { + int ccount; + char *psrc, *pdst; + for (ccount = 0, psrc = s, pdst = lpre; + ccount < lpl; + ++ccount, ++psrc, ++pdst) + { + if (*psrc == Meta) + { + ccount++; + *pdst++ = *psrc++; + *pdst = *psrc; + } else if (*psrc == Dash) + *pdst = '-'; + else + *pdst = *psrc; + } + } + else + memcpy(lpre, s, lpl); lpre[lpl] = '\0'; qlpre = quotename(lpre); lsuf = dupstring(s + offs); @@ -3331,13 +3351,11 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) zlemetaline[end] = save; if (brend) { Brinfo bp; - char *p; - int bl; for (bp = brend; bp; bp = bp->next) { - p = lpsuf + (we - zlemetacs) - bp->qpos - - (bl = strlen(bp->str)); - strcpy(p, p + bl); + char *p2 = lpsuf + (we - zlemetacs) - bp->qpos; + char *p1 = p2 - strlen(bp->str); + memmove(p1, p2, strlen(p2) + 1); } } if (!(lpsuf = strchr(lpsuf, '/')) && sf2) diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c index 1dc2b01c2..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. @@ -558,12 +558,53 @@ parse_class(Cpattern p, char *iptr) return iptr; } +static struct { char *name; int abbrev; int oflag; } orderopts[] = { + { "nosort", 2, CAF_NOSORT }, + { "match", 3, CAF_MATSORT }, + { "numeric", 3, CAF_NUMSORT }, + { "reverse", 3, CAF_REVSORT } +}; + +/* Parse the option to compadd -o, if flags is non-NULL set it + * returns -1 if the argument isn't a valid ordering, 0 otherwise */ + +/**/ +static int +parse_ordering(const char *arg, int *flags) +{ + int o, fl = 0; + const char *next, *opt = arg; + do { + int found = 0; + next = strchr(opt, ','); + if (!next) + next = opt + strlen(opt); + + for (o = sizeof(orderopts)/sizeof(*orderopts) - 1; o >= 0 && + !found; --o) + { + if ((found = next - opt >= orderopts[o].abbrev && + !strncmp(orderopts[o].name, opt, next - opt))) + fl |= orderopts[o].oflag; + } + if (!found) { + if (flags) /* default to "match" */ + *flags = CAF_MATSORT; + return -1; + } + } while (*next && ((opt = next + 1))); + if (flags) + *flags |= fl; + return 0; +} + /**/ static int bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) { struct cadata dat; char *mstr = NULL; /* argument of -M options, accumulated */ + char *oarg = NULL; /* argument of -o option */ int added; /* return value */ Cmatcher match = NULL; @@ -572,7 +613,7 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) return 1; } dat.ipre = dat.isuf = dat.ppre = dat.psuf = dat.prpre = dat.mesg = - dat.pre = dat.suf = dat.group = dat.rems = dat.remf = dat.disp = + dat.pre = dat.suf = dat.group = dat.rems = dat.remf = dat.disp = dat.ign = dat.exp = dat.apar = dat.opar = dat.dpar = NULL; dat.match = NULL; dat.flags = 0; @@ -587,6 +628,7 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) } for (p = *argv + 1; *p; p++) { char *m = NULL; /* argument of -M option (this one only) */ + int order = 0; /* if -o found (argument to which is optional) */ char **sp = NULL; /* the argument to an option should be copied to *sp. */ const char *e; /* error message */ @@ -710,7 +752,11 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) dat.flags |= CMF_DISPLINE; break; case 'o': - dat.flags |= CMF_MORDER; + /* we honour just the first -o option but need to skip + * over a valid argument to subsequent -o options */ + order = oarg ? -1 : 1; + sp = &oarg; + /* no error string because argument is optional */ break; case 'E': if (p[1]) { @@ -741,15 +787,18 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) if (sp) { if (p[1]) { /* Pasted argument: -Xfoo. */ - if (!*sp) + if (!*sp) /* take first option only */ *sp = p + 1; - p += strlen(p+1); + if (!order || !parse_ordering(oarg, order == 1 ? &dat.aflags : NULL)) + p += strlen(p+1); } else if (argv[1]) { /* Argument in a separate word: -X foo. */ argv++; if (!*sp) *sp = *argv; - } else { + if (order && parse_ordering(oarg, order == 1 ? &dat.aflags : NULL)) + --argv; + } else if (!order) { /* Missing argument: argv[N] == "-X", argv[N+1] == NULL. */ zwarnnam(name, e, *p); zsfree(mstr); @@ -962,7 +1011,7 @@ do_comp_vars(int test, int na, char *sa, int nb, char *sb, int mod) } } else #endif - if ((int)strlen(test == CVT_PRENUM ? compprefix : compsuffix) >= na) + if ((int)strlen(test == CVT_PRENUM ? compprefix : compsuffix) < na) return 0; if (test == CVT_PRENUM) ignore_prefix(na); diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index 1cdbb8a48..cc4c3eca9 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -1399,7 +1399,7 @@ pattern_match_restrict(Cpattern p, Cpattern wp, convchar_t *wsc, int wsclen, if (prestrict->tp == CPAT_CHAR) { /* * Easy case: restricted to an exact character on - * the line. Procede as normal. + * the line. Proceed as normal. */ c = prestrict->u.chr; } else { 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/iwidgets.list b/Src/Zle/iwidgets.list index 58310cd74..c95c7a491 100644 --- a/Src/Zle/iwidgets.list +++ b/Src/Zle/iwidgets.list @@ -99,7 +99,7 @@ "recursive-edit", recursiveedit, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "redisplay", redisplay, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "redo", redo, ZLE_KEEPSUFFIX -"reset-prompt", resetprompt, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL +"reset-prompt", resetprompt, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL | ZLE_NOTCOMMAND | ZLE_NOLAST "reverse-menu-complete", reversemenucomplete, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_ISCOMP "run-help", processcmd, ZLE_MENUCMP | ZLE_KEEPSUFFIX | ZLE_LASTCOL "select-a-word", selectword, ZLE_KEEPSUFFIX diff --git a/Src/Zle/zle.h b/Src/Zle/zle.h index f06c56483..609493f8c 100644 --- a/Src/Zle/zle.h +++ b/Src/Zle/zle.h @@ -217,6 +217,7 @@ struct widget { #define ZLE_ISCOMP (1<<11) /* usable for new style completion */ #define WIDGET_INUSE (1<<12) /* widget is in use */ #define WIDGET_FREE (1<<13) /* request to free when no longer in use */ +#define ZLE_NOLAST (1<<14) /* widget should not alter lbindk */ /* thingies */ 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 3487b5d9f..be68f4722 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -632,7 +632,11 @@ raw_getbyte(long do_keytmout, char *cptr, int full) * with all fds, then try unsetting the special ones. */ if (selret < 0 && !errtry) { - errtry = 1; + /* Continue after irrelevant interrupt */ + if (errno != EINTR) { + /* Don't trust special FDs */ + errtry = 1; + } continue; } if (selret == 0) { @@ -704,7 +708,7 @@ raw_getbyte(long do_keytmout, char *cptr, int full) */ if ( # ifdef HAVE_POLL - (fds[0].revents & POLLIN) + (fds[0].revents & (POLLIN|POLLERR|POLLHUP|POLLNVAL)) # else FD_ISSET(SHTTY, &foofd) # endif @@ -889,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 @@ -901,7 +905,7 @@ getbyte(long do_keytmout, int *timeout, int full) if ((zlereadflags & ZLRF_IGNOREEOF) && icnt++ < 20) continue; stopmsg = 1; - zexit(1, 0); + zexit(1, ZEXIT_NORMAL); } icnt = 0; if (errno == EINTR) { @@ -924,7 +928,7 @@ getbyte(long do_keytmout, int *timeout, int full) } else if (errno != 0) { zerr("error on TTY read: %e", errno); stopmsg = 1; - zexit(1, 0); + zexit(1, ZEXIT_NORMAL); } } if (cc == '\r') /* undo the exchange of \n and \r determined by */ @@ -1073,7 +1077,7 @@ redrawhook(void) * temporarily reset state for special variable handling etc. */ incompfunc = 0; - execzlefunc(initthingy, args, 1); + execzlefunc(initthingy, args, 1, 0); incompfunc = old_incompfunc; /* Restore errflag and retflag as zlecallhook() does */ @@ -1136,7 +1140,7 @@ zlecore(void) eofsent = 1; break; } - if (execzlefunc(bindk, zlenoargs, 0)) { + if (execzlefunc(bindk, zlenoargs, 0, 0)) { handlefeep(zlenoargs); if (eofsent) break; @@ -1256,7 +1260,6 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish) resetneeded = 0; fetchttyinfo = 0; trashedzle = 0; - clearflag = 0; raw_lp = lp; lpromptbuf = promptexpand(lp ? *lp : NULL, 1, NULL, NULL, &pmpt_attr); raw_rp = rp; @@ -1387,7 +1390,7 @@ execimmortal(Thingy func, char **args) { Thingy immortal = rthingy_nocreate(dyncat(".", func->nam)); if (immortal) - return execzlefunc(immortal, args, 0); + return execzlefunc(immortal, args, 0, 0); return 1; } @@ -1399,13 +1402,14 @@ execimmortal(Thingy func, char **args) /**/ int -execzlefunc(Thingy func, char **args, int set_bindk) +execzlefunc(Thingy func, char **args, int set_bindk, int set_lbindk) { int r = 0, ret = 0, remetafy = 0; int nestedvichg = vichgflag; int isrepeat = (viinrepeat == 3); Widget w; Thingy save_bindk = bindk; + Thingy save_lbindk = lbindk; if (set_bindk) bindk = func; @@ -1413,6 +1417,8 @@ execzlefunc(Thingy func, char **args, int set_bindk) unmetafy_line(); remetafy = 1; } + if (set_lbindk) + refthingy(save_lbindk); if (isrepeat) viinrepeat = 2; @@ -1536,7 +1542,10 @@ execzlefunc(Thingy func, char **args, int set_bindk) redup(osi, 0); } } - if (r) { + if (set_lbindk) { + unrefthingy(lbindk); + lbindk = save_lbindk; + } else if (r) { unrefthingy(lbindk); refthingy(func); lbindk = func; @@ -1869,13 +1878,17 @@ describekeybriefly(UNUSED(char **args)) { char *seq, *str, *msg, *is; Thingy func; + Keymap km; if (statusline) return 1; clearlist = 1; statusline = "Describe key briefly: _"; zrefresh(); + if (invicmdmode() && region_active && (km = openkeymap("visual"))) + selectlocalmap(km); seq = getkeymapcmd(curkeymap, &func, &str); + selectlocalmap(NULL); statusline = NULL; if(!*seq) return 1; diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index 1f293845f..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. @@ -834,7 +834,7 @@ nextline(Rparams rpms, int wrapped) if (rpms->nvln != -1 && rpms->nvln != winh - 1 && (numscrolls != onumscrolls - 1 || rpms->nvln <= winh / 2)) - return 1; + return 1; numscrolls++; rpms->canscroll = winh / 2; } @@ -1151,20 +1151,20 @@ zrefresh(void) resetneeded = 0; /* unset */ oput_rpmpt = 0; /* no right-prompt currently on screen */ - if (!clearflag) { - if (tccan(TCCLEAREOD)) - tcoutclear(TCCLEAREOD); - else - cleareol = 1; /* request: clear to end of line */ + if (!clearflag) { + if (tccan(TCCLEAREOD)) + tcoutclear(TCCLEAREOD); + else + cleareol = 1; /* request: clear to end of line */ if (listshown > 0) listshown = 0; } - if (t0 > -1) - olnct = (t0 < winh) ? t0 : winh; - if (termflags & TERM_SHORT) - vcs = 0; + if (t0 > -1) + olnct = (t0 < winh) ? t0 : winh; + if (termflags & TERM_SHORT) + vcs = 0; else if (!clearflag && lpromptbuf[0]) { - zputs(lpromptbuf, shout); + zputs(lpromptbuf, shout); if (lpromptwof == winw) zputs("\n", shout); /* works with both hasam and !hasam */ } else { @@ -1678,7 +1678,12 @@ zrefresh(void) moveto(0, winw - rprompt_off - rpromptw); zputs(rpromptbuf, shout); - vcs = winw - rprompt_off; + if (rprompt_off) { + vcs = winw - rprompt_off; + } else { + zputc(&zr_cr); + vcs = 0; + } /* reset character attributes to that set by the main prompt */ txtchange = pmpt_attr; /* @@ -1885,7 +1890,7 @@ refreshline(int ln) if (hasam && vcs == winw) { if (nbuf[vln] && nbuf[vln][vcs + 1].chr == ZWC('\n')) { vln++, vcs = 1; - if (nbuf[vln] && nbuf[vln]->chr) { + if (nbuf[vln] && nbuf[vln]->chr) { zputc(nbuf[vln]); } else zputc(&zr_sp); /* I don't think this should happen */ @@ -1954,11 +1959,11 @@ refreshline(int ln) if (!nl->chr) { if (ccs == winw && hasam && char_ins > 0 && ins_last && vcs != winw) { - nl--; /* we can assume we can go back here */ + nl--; /* we can assume we can go back here */ moveto(ln, winw - 1); zputc(nl); vcs++; - return; /* write last character in line */ + return; /* write last character in line */ } if ((char_ins <= 0) || (ccs >= winw)) /* written everything */ return; @@ -2159,24 +2164,19 @@ moveto(int ln, int cl) const REFRESH_ELEMENT *rep; if (vcs == winw) { - if (rprompt_indent == 0 && tccan(TCLEFT)) { - tc_leftcurs(1); - vcs--; + vln++, vcs = 0; + if (!hasam) { + zputc(&zr_cr); + zputc(&zr_nl); } else { - vln++, vcs = 0; - if (!hasam) { - zputc(&zr_cr); - zputc(&zr_nl); - } else { - if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr) - rep = nbuf[vln]; - else - rep = &zr_sp; - zputc(rep); - zputc(&zr_cr); - if ((vln < olnct) && obuf[vln] && obuf[vln]->chr) - *obuf[vln] = *rep; - } + if ((vln < nlnct) && nbuf[vln] && nbuf[vln]->chr) + rep = nbuf[vln]; + else + rep = &zr_sp; + zputc(rep); + zputc(&zr_cr); + if ((vln < olnct) && obuf[vln] && obuf[vln]->chr) + *obuf[vln] = *rep; } } @@ -2212,7 +2212,7 @@ moveto(int ln, int cl) } if (cl != vcs) - singmoveto(cl); + singmoveto(cl); } /**/ @@ -2292,7 +2292,7 @@ tc_rightcurs(int ct) /* it is cheaper to send TCRIGHT than reprint the whole prompt */ for (ct = lpromptw - i; ct--; ) tcout(TCRIGHT); - else { + else { if (i != 0) zputc(&zr_cr); tc_upcurs(lprompth - 1); diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c index 6b892b822..ce61db27b 100644 --- a/Src/Zle/zle_thingy.c +++ b/Src/Zle/zle_thingy.c @@ -703,7 +703,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) { Thingy t; struct modifier modsave = zmod; - int ret, saveflag = 0, setbindk = 0, remetafy; + int ret, saveflag = 0, setbindk = 0, setlbindk, remetafy; char *wname = *args++, *keymap_restore = NULL, *keymap_tmp; if (!wname) @@ -787,7 +787,8 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) * a vi range to detect a repeated key */ setbindk = setbindk || (t->widget && (t->widget->flags & (WIDGET_INT | ZLE_VIOPER)) == WIDGET_INT); - ret = execzlefunc(t, args, setbindk); + setlbindk = t->widget && (t->widget->flags & ZLE_NOLAST) == ZLE_NOLAST; + ret = execzlefunc(t, args, setbindk, setlbindk); unrefthingy(t); if (saveflag) zmod = modsave; diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 2b25d6b2e..fdd168763 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -1236,8 +1236,10 @@ get_comp_string(void) else if (tok == OUTPAR) { if (parct) parct--; - else + else if (linarr) { linarr = 0; + incmdpos = 1; + } } if (inredir && IS_REDIROP(tok)) { rdstr = rdstrbuf; diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index c6df3d89c..2b306fdcd 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1607,7 +1607,11 @@ static int unapplychange(struct change *ch) { if(ch->hist != histline) { - zle_setline(quietgethist(ch->hist)); + Histent he = quietgethist(ch->hist); + DPUTS(he == NULL, "quietgethist(ch->hist) returned NULL"); + if(he == NULL) + return 1; + zle_setline(he); zlecs = ch->new_cs; return 0; } @@ -1647,7 +1651,11 @@ static int applychange(struct change *ch) { if(ch->hist != histline) { - zle_setline(quietgethist(ch->hist)); + Histent he = quietgethist(ch->hist); + DPUTS(he == NULL, "quietgethist(ch->hist) returned NULL"); + if(he == NULL) + return 1; + zle_setline(he); zlecs = ch->old_cs; return 0; } @@ -1733,7 +1741,7 @@ zlecallhook(char *name, char *arg) args[0] = arg; args[1] = NULL; - execzlefunc(thingy, args, 1); + execzlefunc(thingy, args, 1, 0); unrefthingy(thingy); /* Retain any user interrupt error status */ diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c index a5ff9200c..0f198d0e8 100644 --- a/Src/Zle/zle_vi.c +++ b/Src/Zle/zle_vi.c @@ -216,7 +216,7 @@ getvirange(int wf) * a number of lines is used. If the function used * returns 1, we fail. */ - if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs, 1)) + if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs, 1, 0)) ret = -1; if (viinrepeat) zmult = mult1; diff --git a/Src/builtin.c b/Src/builtin.c index 8dcdcc024..aa5767cf1 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -74,7 +74,7 @@ static struct builtin builtins[] = BUILTIN("fc", 0, bin_fc, 0, -1, BIN_FC, "aAdDe:EfiIlLmnpPrRt:W", NULL), BUILTIN("fg", 0, bin_fg, 0, -1, BIN_FG, NULL, NULL), BUILTIN("float", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "E:%F:%HL:%R:%Z:%ghlp:%rtux", "E"), - BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "kmMstTuUWx:z", NULL), + BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "ckmMstTuUWx:z", NULL), BUILTIN("getln", 0, bin_read, 0, -1, 0, "ecnAlE", "zr"), BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, NULL, NULL), BUILTIN("hash", BINF_MAGICEQUALS, bin_hash, 0, -1, 0, "Ldfmrv", NULL), @@ -720,7 +720,7 @@ bin_set(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) /**** directory-handling builtins ****/ /**/ -int doprintdir = 0; /* set in exec.c (for autocd) */ +int doprintdir = 0; /* set in exec.c (for autocd, cdpath, etc.) */ /* pwd: display the name of the current directory */ @@ -912,7 +912,7 @@ cd_get_dest(char *nam, char **argv, int hard, int func) char *end; doprintdir++; - if (argv[0][1] && (argv[0][0] == '+' || argv[0][0] == '-') + if (!isset(POSIXCD) && argv[0][1] && (argv[0][0] == '+' || argv[0][0] == '-') && strspn(argv[0]+1, "0123456789") == strlen(argv[0]+1)) { dd = zstrtol(argv[0] + 1, &end, 10); if (*end == '\0') { @@ -1251,7 +1251,7 @@ cd_new_pwd(int func, LinkNode dir, int quiet) if (func != BIN_CD && isset(INTERACTIVE)) { if (unset(PUSHDSILENT) && !quiet) printdirstack(); - } else if (doprintdir) { + } else if (unset(CDSILENT) && doprintdir) { fprintdir(pwd, stdout); putchar('\n'); } @@ -1718,7 +1718,7 @@ fcsubs(char **sp, struct asgment *sub) newstr = sub->value.scalar; sub = (Asgment)sub->node.next; oldpos = s; - /* loop over occurences of oldstr in s, replacing them with newstr */ + /* loop over occurrences of oldstr in s, replacing them with newstr */ while ((newpos = (char *)strstr(oldpos, oldstr))) { newmem = (char *) zhalloc(1 + (newpos - s) + strlen(newstr) + strlen(newpos + strlen(oldstr))); @@ -2171,7 +2171,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), !ASG_VALUEP(asg)) on |= PM_UNSET; else if (usepm && (pm->node.flags & PM_READONLY) && - !(on & PM_READONLY)) { + !(on & PM_READONLY) && func != BIN_EXPORT) { zerr("read-only variable: %s", pm->node.nam); return NULL; } @@ -2526,7 +2526,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), * Attempt to assign a scalar value to an array. * This can happen if the array is special. * We'll be lenient and guess what the user meant. - * This is how normal assigment works. + * This is how normal assignment works. */ if (*asg->value.scalar) { /* Array with one value */ @@ -2582,9 +2582,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), } } pm->node.flags |= (on & PM_READONLY); - - if (OPT_ISSET(ops,'p')) - paramtab->printnode(&pm->node, PRINT_TYPESET); + DPUTS(OPT_ISSET(ops,'p'), "BUG: -p not handled"); return pm; } @@ -2714,7 +2712,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func) (!isset(GLOBALEXPORT) && !OPT_ISSET(ops,'g'))) on |= PM_LOCAL; - if (on & PM_TIED) { + if ((on & PM_TIED) && !OPT_ISSET(ops, 'p')) { Param apm; struct asgment asg0, asg2; char *oldval = NULL, *joinstr; @@ -3031,7 +3029,7 @@ eval_autoload(Shfunc shf, char *name, Options ops, int func) } if (OPT_MINUS(ops,'X')) { char *fargv[3]; - fargv[0] = name; + fargv[0] = quotestring(name, QT_SINGLE_OPTIONAL); fargv[1] = "\"$@\""; fargv[2] = 0; shf->funcdef = mkautofn(shf); @@ -3250,11 +3248,50 @@ bin_functions(char *name, char **argv, Options ops, int func) if ((off & PM_UNDEFINED) || (OPT_ISSET(ops,'k') && OPT_ISSET(ops,'z')) || (OPT_ISSET(ops,'x') && !OPT_HASARG(ops,'x')) || - (OPT_MINUS(ops,'X') && (OPT_ISSET(ops,'m') || !scriptname))) { + (OPT_MINUS(ops,'X') && (OPT_ISSET(ops,'m') || !scriptname)) || + (OPT_ISSET(ops,'c') && (OPT_ISSET(ops,'x') || OPT_ISSET(ops,'X') || + OPT_ISSET(ops,'m')))) { zwarnnam(name, "invalid option(s)"); return 1; } + if (OPT_ISSET(ops,'c')) { + Shfunc newsh; + if (!*argv || !argv[1] || argv[2]) { + zwarnnam(name, "-c: requires two arguments"); + return 1; + } + shf = (Shfunc) shfunctab->getnode(shfunctab, *argv); + if (!shf) { + zwarnnam(name, "no such function: %s", *argv); + return 1; + } + if (shf->node.flags & PM_UNDEFINED) { + if (shf->funcdef) { + freeeprog(shf->funcdef); + shf->funcdef = &dummy_eprog; + } + shf = loadautofn(shf, 1, 0, 0); + if (!shf) + return 1; + } + newsh = zalloc(sizeof(*newsh)); + memcpy(newsh, shf, sizeof(*newsh)); + if (newsh->node.flags & PM_LOADDIR) { + /* Expand original location of autoloaded file */ + newsh->node.flags &= ~PM_LOADDIR; + newsh->filename = tricat(shf->filename, "/", shf->node.nam); + } else + newsh->filename = ztrdup(shf->filename); + newsh->funcdef->nref++; + if (newsh->redir) + newsh->redir->nref++; + if (shf->sticky) + newsh->sticky = sticky_emulation_dup(sticky, 0); + shfunctab->addnode(shfunctab, ztrdup(argv[1]), &newsh->node); + return 0; + } + if (OPT_ISSET(ops,'x')) { char *eptr; expand = (int)zstrtol(OPT_ARG(ops,'x'), &eptr, 10); @@ -4993,8 +5030,7 @@ bin_print(char *name, char **args, Options ops, int func) narg = strtoul(c, &endptr, 0); if (*endptr == '$') { c = endptr + 1; - DPUTS(narg <= 0, "specified zero or negative arg"); - if (narg > argc) { + if (narg <= 0 || narg > argc) { zwarnnam(name, "%d: argument specifier out of range", narg); if (fout != stdout) @@ -5514,14 +5550,12 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun /* check for legality */ if(opch == ':' || !(p = memchr(optstr, opch, lenoptstr))) { p = "?"; - err: zsfree(zoptarg); setsparam(var, ztrdup(p)); if(quiet) { zoptarg = metafy(optbuf, lenoptbuf, META_DUP); } else { - zwarn(*p == '?' ? "bad option: %c%c" : - "argument expected after %c%c option", + zwarn("bad option: %c%c", "?-+"[lenoptbuf], opch); zoptarg=ztrdup(""); } @@ -5532,8 +5566,17 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun if(p[1] == ':') { if(optcind == lenstr) { if(!args[zoptind]) { - p = ":"; - goto err; + zsfree(zoptarg); + if(quiet) { + setsparam(var, ztrdup(":")); + zoptarg = metafy(optbuf, lenoptbuf, META_DUP); + } else { + setsparam(var, ztrdup("?")); + zoptarg = ztrdup(""); + zwarn("argument expected after %c%c option", + "?-+"[lenoptbuf], opch); + } + return 0; } p = ztrdup(args[zoptind++]); } else @@ -5558,7 +5601,11 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun return 0; } -/* Flag that we should exit the shell as soon as all functions return. */ +/* Boolean flag that we should exit the shell as soon as all functions return. + * + * Set by the 'exit' builtin. + */ + /**/ mod_export int exit_pending; @@ -5622,7 +5669,7 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func) } return lastval; } - zexit(num, 0); /* else treat return as logout/exit */ + zexit(num, ZEXIT_NORMAL); /* else treat return as logout/exit */ break; case BIN_LOGOUT: if (unset(LOGINSHELL)) { @@ -5644,7 +5691,7 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func) * If we are already exiting... give this all up as * a bad job. */ - if (stopmsg || (zexit(0,2), !stopmsg)) { + if (stopmsg || (zexit(0, ZEXIT_DEFERRED), !stopmsg)) { retflag = 1; breaks = loops; exit_pending = 1; @@ -5652,7 +5699,7 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func) exit_val = num; } } else - zexit(num, 0); + zexit(num, ZEXIT_NORMAL); break; } return 0; @@ -5737,14 +5784,15 @@ _realexit(void) /* exit the shell. val is the return value of the shell. * * from_where is - * 1 if zexit is called because of a signal - * 2 if we can't actually exit yet (e.g. functions need - * terminating) but should perform the usual interactive tests. + * ZEXIT_SIGNAL if zexit is called because of a signal + * ZEXIT_DEFERRED if we can't actually exit yet (e.g., functions need + * terminating) but should perform the usual interactive + * tests. */ /**/ mod_export void -zexit(int val, int from_where) +zexit(int val, enum zexit_t from_where) { /* * Don't do anything recursively: see below. @@ -5755,7 +5803,7 @@ zexit(int val, int from_where) if (shell_exiting == -1) return; - if (isset(MONITOR) && !stopmsg && from_where != 1) { + if (isset(MONITOR) && !stopmsg && from_where != ZEXIT_SIGNAL) { scanjobs(); /* check if jobs need printing */ if (isset(CHECKJOBS)) checkjobs(); /* check if any jobs are running/stopped */ @@ -5764,8 +5812,9 @@ zexit(int val, int from_where) return; } } - /* Positive in_exit means we have been here before */ - if (from_where == 2 || (shell_exiting++ && from_where)) + /* Positive shell_exiting means we have been here before */ + if (from_where == ZEXIT_DEFERRED || + (shell_exiting++ && from_where != ZEXIT_NORMAL)) return; /* @@ -5781,12 +5830,12 @@ zexit(int val, int from_where) if (isset(MONITOR)) { /* send SIGHUP to any jobs left running */ - killrunjobs(from_where == 1); + killrunjobs(from_where == ZEXIT_SIGNAL); } if (isset(RCS) && interact) { if (!nohistsave) { int writeflags = HFILE_USE_OPTIONS; - if (from_where == 1) + if (from_where == ZEXIT_SIGNAL) writeflags |= HFILE_NO_REWRITE; saveandpophiststack(1, writeflags); savehistfile(NULL, 1, writeflags); @@ -7238,8 +7287,11 @@ bin_umask(char *nam, char **args, Options ops, UNUSED(int func)) char *s = *args; /* Get the current umask. */ - um = umask(0); + queue_signals(); + um = umask(0777); umask(um); + unqueue_signals(); + /* No arguments means to display the current setting. */ if (!s) { if (OPT_ISSET(ops,'S')) { diff --git a/Src/compat.c b/Src/compat.c index 7b5c4411c..8ab335aa1 100644 --- a/Src/compat.c +++ b/Src/compat.c @@ -30,8 +30,8 @@ #include "zsh.mdh" #include "compat.pro" -/* Return pointer to first occurence of string t * - * in string s. Return NULL if not present. */ +/* Return pointer to first occurrence of string t * + * in string s. Return NULL if not present. */ /**/ #ifndef HAVE_STRSTR @@ -361,8 +361,18 @@ zgetdir(struct dirsav *d) pino = sbuf.st_ino; pdev = sbuf.st_dev; - /* If they're the same, we've reached the root directory. */ + /* If they're the same, we've reached the root directory... */ if (ino == pino && dev == pdev) { + /* + * ...well, probably. If this was an orphaned . after + * an unmount, or something such, we could be in trouble... + */ + if (stat("/", &sbuf) < 0 || + sbuf.st_ino != ino || + sbuf.st_dev != dev) { + zerr("Failed to get current directory: path invalid"); + return NULL; + } if (!buf[pos]) buf[--pos] = '/'; if (d) { @@ -509,7 +519,7 @@ zgetcwd(void) #endif /* HAVE_GETCWD */ if (!ret) ret = unmeta(pwd); - if (!ret) + if (!ret || *ret == '\0') ret = dupstring("."); return ret; } diff --git a/Src/exec.c b/Src/exec.c index 042ba065a..50027654a 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -940,6 +940,8 @@ hashcmd(char *arg0, char **pp) char *s, buf[PATH_MAX+1]; char **pq; + if (*arg0 == '/') + return NULL; for (; *pp; pp++) if (**pp == '/') { s = buf; @@ -969,6 +971,10 @@ hashcmd(char *arg0, char **pp) return cn; } +/* The value that 'locallevel' had when we forked. When we get back to this + * level, the current process (which is a subshell) will terminate. + */ + /**/ int forklevel; @@ -1688,7 +1694,8 @@ execpline(Estate state, wordcode slcode, int how, int last1) lastwj = thisjob = newjob; - if (list_pipe || (pline_level && !(how & Z_TIMED))) + if (list_pipe || (pline_level && !(how & Z_TIMED) && + !(jn->stat & STAT_NOSTTY))) jn->stat |= STAT_NOPRINT; if (nowait) { @@ -2533,7 +2540,7 @@ setunderscore(char *str) { queue_signals(); if (str && *str) { - int l = strlen(str) + 1, nl = (l + 31) & ~31; + size_t l = strlen(str) + 1, nl = (l + 31) & ~31; if (nl > underscorelen || (underscorelen - nl) > 64) { zfree(zunderscore, underscorelen); @@ -2762,9 +2769,12 @@ execcmd_fork(Estate state, int how, int type, Wordcode varspc, sigtrapped[SIGEXIT] = 0; #ifdef HAVE_NICE /* Check if we should run background jobs at a lower priority. */ - if ((how & Z_ASYNC) && isset(BGNICE)) - if (nice(5) < 0) + if ((how & Z_ASYNC) && isset(BGNICE)) { + errno = 0; + nice(5); + if (errno) zwarn("nice(5) failed: %e", errno); + } #endif /* HAVE_NICE */ return 0; @@ -4293,7 +4303,7 @@ save_params(Estate state, Wordcode pc, LinkList *restore_p, LinkList *remove_p) (unset(RESTRICTED) || !(pm->node.flags & PM_RESTRICTED))) { /* * In this case we're just saving parts of - * the parameter in a tempory, so use heap allocation + * the parameter in a temporary, so use heap allocation * and don't bother copying every detail. */ tpm = (Param) hcalloc(sizeof *tpm); @@ -4405,8 +4415,10 @@ closem(int how, int all) /* * Process substitution needs to be visible to user; * fd's are explicitly cleaned up by filelist handling. + * External FDs are managed directly by the user. */ - (all || fdtable[i] != FDT_PROC_SUBST) && + (all || (fdtable[i] != FDT_PROC_SUBST && + fdtable[i] != FDT_EXTERNAL)) && (how == FDT_UNUSED || (fdtable[i] & FDT_TYPE_MASK) == how)) { if (i == SHTTY) SHTTY = -1; @@ -4638,19 +4650,25 @@ getoutput(char *cmd, int qt) return NULL; } -/* read output of command substitution */ +/* read output of command substitution + * + * The file descriptor "in" is closed by the function. + * + * "qt" indicates if the substitution was in double quotes. + * + * "readerror", if not NULL, is used to return any error that + * occurred during the read. + */ /**/ mod_export LinkList readoutput(int in, int qt, int *readerror) { LinkList ret; - char *buf, *ptr; - int bsiz, c, cnt = 0; - FILE *fin; + char *buf, *bufptr, *ptr, inbuf[64]; + int bsiz, c, cnt = 0, readret; int q = queue_signal_level(); - fin = fdopen(in, "r"); ret = newlinklist(); ptr = buf = (char *) hcalloc(bsiz = 64); /* @@ -4662,33 +4680,38 @@ readoutput(int in, int qt, int *readerror) */ dont_queue_signals(); child_unblock(); - while ((c = fgetc(fin)) != EOF || errno == EINTR) { - if (c == EOF) { - errno = 0; - clearerr(fin); - continue; - } - if (imeta(c)) { - *ptr++ = Meta; - c ^= 32; - cnt++; + for (;;) { + readret = read(in, inbuf, 64); + if (readret <= 0) { + if (readret < 0 && errno == EINTR) + continue; + else + break; } - if (++cnt >= bsiz) { - char *pp; - queue_signals(); - pp = (char *) hcalloc(bsiz *= 2); - dont_queue_signals(); + for (bufptr = inbuf; bufptr < inbuf + readret; bufptr++) { + c = *bufptr; + if (imeta(c)) { + *ptr++ = Meta; + c ^= 32; + cnt++; + } + if (++cnt >= bsiz) { + char *pp; + queue_signals(); + pp = (char *) hcalloc(bsiz *= 2); + dont_queue_signals(); - memcpy(pp, buf, cnt - 1); - ptr = (buf = pp) + cnt - 1; + memcpy(pp, buf, cnt - 1); + ptr = (buf = pp) + cnt - 1; + } + *ptr++ = c; } - *ptr++ = c; } child_block(); restore_queue_signals(q); if (readerror) - *readerror = ferror(fin) ? errno : 0; - fclose(fin); + *readerror = readret < 0 ? errno : 0; + close(in); while (cnt && ptr[-1] == '\n') ptr--, cnt--; *ptr = '\0'; @@ -4821,6 +4844,7 @@ getoutputfile(char *cmd, char **eptr) } /* pid == 0 */ + closem(FDT_UNUSED, 0); redup(fd, 1); entersubsh(ESUB_PGRP|ESUB_NOMONITOR, NULL); cmdpush(CS_CMDSUBST); @@ -4982,7 +5006,7 @@ getpipe(char *cmd, int nullexec) procsubstpid = pid; return pipes[!out]; } - entersubsh(ESUB_PGRP, NULL); + entersubsh(ESUB_ASYNC|ESUB_PGRP, NULL); redup(pipes[out], out); closem(FDT_UNUSED, 0); /* this closes pipes[!out] as well */ cmdpush(CS_CMDSUBST); @@ -5929,7 +5953,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) * exit command was handled. */ stopmsg = 1; - zexit(exit_val, 0); + zexit(exit_val, ZEXIT_NORMAL); } } diff --git a/Src/glob.c b/Src/glob.c index ed2c90bd8..f67a376b9 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -274,7 +274,7 @@ addpath(char *s, int l) } /* stat the filename s appended to pathbuf. l should be true for lstat, * - * false for stat. If st is NULL, the file is only checked for existance. * + * false for stat. If st is NULL, the file is only checked for existence. * * s == "" is treated as s == ".". This is necessary since on most systems * * foo/ can be used to reference a non-directory foo. Returns nonzero if * * the file does not exists. */ @@ -400,7 +400,7 @@ insert(char *s, int checked) if (colonmod) { /* Handle the remainder of the qualifier: e.g. (:r:s/foo/bar/). */ char *mod = colonmod; - modify(&news, &mod); + modify(&news, &mod, 1); } if (!statted && (gf_sorts & GS_NORMAL)) { statfullpath(s, &buf, 1); @@ -566,7 +566,7 @@ scanner(Complist q, int shortcircuit) continue; errsfound = errssofar; if (pattry(p, fn)) { - /* if this name matchs the pattern... */ + /* if this name matches the pattern... */ if (pbcwdsav == pathbufcwd && strlen(fn) + pathpos - pathbufcwd >= PATH_MAX) { int err; @@ -2909,6 +2909,12 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr, */ mb_charinit(); tmatch = NULL; + set_pat_start(p, l); + if (pattrylen(p, send, 0, 0, &patstralloc, umltot) && + !--n) { + *sp = get_match_ret(&imd, umltot, umltot); + return 1; + } for (ioff = 0, t = s, umlen = umltot; t < send; ioff++) { set_pat_start(p, t-s); if (pattrylen(p, t, umlen, 0, &patstralloc, ioff)) @@ -3053,7 +3059,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr, case (SUB_END|SUB_SUBSTR): case (SUB_END|SUB_LONG|SUB_SUBSTR): /* Longest/shortest at end, matching substrings. */ - if (!(fl & SUB_LONG)) { + { set_pat_start(p, l); if (pattrylen(p, send, 0, 0, &patstralloc, umltot) && !--n) { @@ -3391,7 +3397,7 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr, case (SUB_END|SUB_SUBSTR): case (SUB_END|SUB_LONG|SUB_SUBSTR): /* Longest/shortest at end, matching substrings. */ - if (!(fl & SUB_LONG)) { + { set_pat_start(p, l); if (pattrylen(p, send, 0, 0, &patstralloc, uml) && !--n) { *sp = get_match_ret(&imd, uml, uml); diff --git a/Src/hashtable.c b/Src/hashtable.c index b7baa3142..e210ddeca 100644 --- a/Src/hashtable.c +++ b/Src/hashtable.c @@ -996,7 +996,7 @@ printshfuncnode(HashNode hn, int printflags) * expansion of leading tabs. * expand = 0 is standard: use hard tabs. * expand > 0 uses that many spaces. - * expand < 0 uses no identation. + * expand < 0 uses no indentation. * * Note this function and the following two are called with * interrupts queued, so saving and restoring text_expand_tabs diff --git a/Src/hist.c b/Src/hist.c index dbdc1e4e5..5281e8718 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -181,7 +181,7 @@ mod_export char *chline; * To avoid having to modify this every time we modify chline, * we set it when we push the stack, and unset it when we pop * the appropriate value off the stack. As it's never modified - * on the stack this is the only maintainance we ever do on it. + * on the stack this is the only maintenance we ever do on it. * In return, ZLE has to check both zle_chline and (if that's * NULL) chline to get the current value. */ @@ -216,6 +216,7 @@ static struct histfile_stats { char *text; time_t stim, mtim; off_t fpos, fsiz; + int interrupted; zlong next_write_ev; } lasthist; @@ -475,7 +476,7 @@ herrflush(void) * * Note that this is a side effect --- this is not the usual reason * for testing lex_add_raw which is to add the text to a different - * buffer used when we are actually parsing the command substituion + * buffer used when we are actually parsing the command substitution * (nothing to do with ZLE). Sorry. */ while (inbufct && (!strin || lex_add_raw)) { @@ -554,6 +555,27 @@ substfailed(void) return -1; } +/* + * Return a count given by decimal digits after a modifier. + */ +static int +digitcount(void) +{ + int c = ingetc(), count; + + if (idigit(c)) { + count = 0; + do { + count = 10 * count + (c - '0'); + c = ingetc(); + } while (idigit(c)); + } + else + count = 0; + inungetc(c); + return count; +} + /* Perform history substitution, returning the next character afterwards. */ /**/ @@ -834,7 +856,7 @@ histsubchar(int c) } break; case 'h': - if (!remtpath(&sline)) { + if (!remtpath(&sline, digitcount())) { herrflush(); zerr("modifier failed: h"); return -1; @@ -855,7 +877,7 @@ histsubchar(int c) } break; case 't': - if (!remlpaths(&sline)) { + if (!remlpaths(&sline, digitcount())) { herrflush(); zerr("modifier failed: t"); return -1; @@ -898,6 +920,16 @@ histsubchar(int c) case 'u': sline = casemodify(sline, CASMOD_UPPER); break; + case 'P': + if (*sline != '/') { + char *here = zgetcwd(); + if (here[strlen(here)-1] != '/') + sline = zhtricat(metafy(here, -1, META_HEAPDUP), "/", sline); + else + sline = dyncat(here, sline); + } + sline = xsymlink(sline, 1); + break; default: herrflush(); zerr("illegal modifier: %c", c); @@ -1197,8 +1229,9 @@ histreduceblanks(void) chline[pos] = '\0'; } else { ptr = chline + pos; - while ((*ptr++ = *lastptr++)) - ; + if (ptr < lastptr) + while ((*ptr++ = *lastptr++)) + ; } } @@ -1972,16 +2005,18 @@ chrealpath(char **junkptr) /**/ int -remtpath(char **junkptr) +remtpath(char **junkptr, int count) { char *str = strend(*junkptr); /* ignore trailing slashes */ while (str >= *junkptr && IS_DIRSEP(*str)) --str; - /* skip filename */ - while (str >= *junkptr && !IS_DIRSEP(*str)) - --str; + if (!count) { + /* skip filename */ + while (str >= *junkptr && !IS_DIRSEP(*str)) + --str; + } if (str < *junkptr) { if (IS_DIRSEP(**junkptr)) *junkptr = dupstring ("/"); @@ -1990,6 +2025,34 @@ remtpath(char **junkptr) return 0; } + + if (count) + { + /* + * Return this many components, so start from the front. + * Leading slash counts as one component, consistent with + * behaviour of repeated applications of :h. + */ + char *strp = *junkptr; + while (strp < str) { + if (IS_DIRSEP(*strp)) { + if (--count <= 0) { + if (strp == *junkptr) + ++strp; + *strp = '\0'; + return 1; + } + /* Count consecutive separators as one */ + while (IS_DIRSEP(strp[1])) + ++strp; + } + ++strp; + } + + /* Full string needed */ + return 1; + } + /* repeated slashes are considered like a single slash */ while (str > *junkptr && IS_DIRSEP(str[-1])) --str; @@ -2038,7 +2101,7 @@ rembutext(char **junkptr) /**/ mod_export int -remlpaths(char **junkptr) +remlpaths(char **junkptr, int count) { char *str = strend(*junkptr); @@ -2048,12 +2111,29 @@ remlpaths(char **junkptr) --str; str[1] = '\0'; } - for (; str >= *junkptr; --str) - if (IS_DIRSEP(*str)) { - *str = '\0'; - *junkptr = dupstring(str + 1); - return 1; + for (;;) { + for (; str >= *junkptr; --str) { + if (IS_DIRSEP(*str)) { + if (--count > 0) { + if (str > *junkptr) { + --str; + break; + } else { + /* Whole string needed */ + return 1; + } + } + *str = '\0'; + *junkptr = dupstring(str + 1); + return 1; + } } + /* Count consecutive separators as 1 */ + while (str >= *junkptr && IS_DIRSEP(*str)) + --str; + if (str <= *junkptr) + break; + } return 0; } @@ -2544,11 +2624,13 @@ readhistfile(char *fn, int err, int readflags) sb.st_size == 0) return; if (readflags & HFILE_FAST) { - if ((lasthist.fsiz == sb.st_size && lasthist.mtim == sb.st_mtime) - || lockhistfile(fn, 0)) + if (!lasthist.interrupted && + ((lasthist.fsiz == sb.st_size && lasthist.mtim == sb.st_mtime) + || lockhistfile(fn, 0))) return; lasthist.fsiz = sb.st_size; lasthist.mtim = sb.st_mtime; + lasthist.interrupted = 0; } else if ((ret = lockhistfile(fn, 1))) { if (ret == 2) { zwarn("locking failed for %s: %e: reading anyway", fn, errno); @@ -2694,8 +2776,11 @@ readhistfile(char *fn, int err, int readflags) */ if (uselex || remeta) freeheap(); - if (errflag & ERRFLAG_INT) + if (errflag & ERRFLAG_INT) { + /* Can't assume fast read next time if interrupted. */ + lasthist.interrupted = 1; break; + } } if (start && readflags & HFILE_USE_OPTIONS) { zsfree(lasthist.text); @@ -3236,6 +3321,7 @@ bufferwords(LinkList list, char *buf, int *index, int flags) int owb = wb, owe = we, oadx = addedx, onc = nocomments; int ona = noaliases, ocs = zlemetacs, oll = zlemetall; int forloop = 0, rcquotes = opts[RCQUOTES]; + int envarray = 0; char *p, *addedspaceptr; if (!list) @@ -3319,6 +3405,14 @@ bufferwords(LinkList list, char *buf, int *index, int flags) ctxtlex(); if (tok == ENDINPUT || tok == LEXERR) break; + /* + * After an array assignment, return to the initial + * start-of-command state. There could be a second ENVARRAY. + */ + if (tok == OUTPAR && envarray) { + incmdpos = 1; + envarray = 0; + } if (tok == FOR) { /* * The way for (( expr1 ; expr2; expr3 )) is parsed is: @@ -3356,6 +3450,7 @@ bufferwords(LinkList list, char *buf, int *index, int flags) switch (tok) { case ENVARRAY: p = dyncat(tokstr, "=("); + envarray = 1; break; case DINPAR: diff --git a/Src/init.c b/Src/init.c index e7e62e2f7..04a5856ff 100644 --- a/Src/init.c +++ b/Src/init.c @@ -45,7 +45,10 @@ int noexitct = 0; char *zunderscore; /**/ -int underscorelen, underscoreused; +size_t underscorelen; + +/**/ +int underscoreused; /* what level of sourcing we are at */ @@ -134,7 +137,7 @@ loop(int toplevel, int justonce) else stophist = hstop; /* - * Reset all errors, including user interupts. + * Reset all errors, including user interrupts. * This is what allows ^C in an interactive shell * to return us to the command line. */ @@ -158,7 +161,7 @@ loop(int toplevel, int justonce) * Handle that now. */ stopmsg = 1; - zexit(exit_val, 0); + zexit(exit_val, ZEXIT_NORMAL); } if (tok == LEXERR && !lastval) lastval = 1; @@ -200,7 +203,7 @@ loop(int toplevel, int justonce) * that would be inconsistent with the case where * we didn't execute a preexec function. This is * an implementation detail that an interrupting user - * does't care about. + * doesn't care about. */ errflag &= ~ERRFLAG_ERROR; } @@ -359,7 +362,7 @@ static void parseopts_setemulate(char *nam, int flags) * Parse shell options. * * If (flags & PARSEARGS_TOPLEVEL): - * - we are doing shell initilisation + * - we are doing shell initialisation * - nam is the name under which the shell was started * - set up emulation and standard options based on that. * Otherwise: @@ -879,7 +882,7 @@ setupvals(char *cmd, char *runscript, char *zsh_name) char *ptr; int i, j; #if defined(SITEFPATH_DIR) || defined(FPATH_DIR) || defined (ADDITIONAL_FPATH) || defined(FIXED_FPATH_DIR) -#define FPATH_NEEDS_INIT 1 +# define FPATH_NEEDS_INIT 1 char **fpathptr; # if defined(FPATH_DIR) && defined(FPATH_SUBDIRS) char *fpath_subdirs[] = FPATH_SUBDIRS; @@ -991,18 +994,29 @@ setupvals(char *cmd, char *runscript, char *zsh_name) # endif /* ADDITONAL_FPATH */ fpath = fpathptr = (char **)zalloc((fpathlen+1)*sizeof(char *)); # ifdef FIXED_FPATH_DIR + /* Zeroth: /usr/local/share/zsh/site-functions */ *fpathptr++ = ztrdup(FIXED_FPATH_DIR); fpathlen--; # endif # ifdef SITEFPATH_DIR + /* First: the directory from --enable-site-fndir + * + * default: /usr/local/share/zsh/site-functions + * (but changeable by passing --prefix or --datadir to configure) */ *fpathptr++ = ztrdup(SITEFPATH_DIR); fpathlen--; # endif /* SITEFPATH_DIR */ # if defined(ADDITIONAL_FPATH) + /* Second: the directories from --enable-additional-fpath + * + * default: empty list */ for (j = 0; j < more_fndirs_len; j++) *fpathptr++ = ztrdup(more_fndirs[j]); # endif # ifdef FPATH_DIR + /* Third: The directory from --enable-fndir + * + * default: /usr/local/share/zsh/${ZSH_VERSION}/functions */ # ifdef FPATH_SUBDIRS # ifdef ADDITIONAL_FPATH for (j = more_fndirs_len; j < fpathlen; j++) @@ -1010,7 +1024,7 @@ setupvals(char *cmd, char *runscript, char *zsh_name) # else for (j = 0; j < fpathlen; j++) *fpathptr++ = tricat(FPATH_DIR, "/", fpath_subdirs[j]); -#endif +# endif # else *fpathptr++ = ztrdup(FPATH_DIR); # endif @@ -1234,6 +1248,15 @@ init_signals(void) intr(); +#ifdef POSIX_SIGNALS + { + struct sigaction act; + if (!sigaction(SIGQUIT, NULL, &act) && + act.sa_handler == SIG_IGN) + sigtrapped[SIGQUIT] = ZSIG_IGNORED; + } +#endif + #ifndef QDEBUG signal_ignore(SIGQUIT); #endif @@ -1359,7 +1382,7 @@ init_misc(char *cmd, char *zsh_name) bshin = fdopen(SHIN, "r"); execstring(cmd, 0, 1, "cmdarg"); stopmsg = 1; - zexit((exit_pending || shell_exiting) ? exit_val : lastval, 0); + zexit((exit_pending || shell_exiting) ? exit_val : lastval, ZEXIT_NORMAL); } if (interact && isset(RCS)) @@ -1766,20 +1789,20 @@ zsh_main(UNUSED(int argc), char **argv) if (!lastval) lastval = 1; stopmsg = 1; - zexit(lastval, 0); + zexit(lastval, ZEXIT_NORMAL); } if (!(isset(IGNOREEOF) && interact)) { #if 0 if (interact) fputs(islogin ? "logout\n" : "exit\n", shout); #endif - zexit(lastval, 0); + zexit(lastval, ZEXIT_NORMAL); continue; } noexitct++; if (noexitct >= 10) { stopmsg = 1; - zexit(lastval, 0); + zexit(lastval, ZEXIT_NORMAL); } /* * Don't print the message if it was already handled by diff --git a/Src/jobs.c b/Src/jobs.c index 73d7f26da..e7438251e 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -1085,7 +1085,7 @@ printjob(Job jn, int lng, int synch) { /* * A subjob still has process, which must finish before - * further excution of the superjob, which the user wants to + * further execution of the superjob, which the user wants to * know about. So report the status of the subjob as if it * were the user-visible superjob. */ @@ -1932,7 +1932,7 @@ getjob(const char *s, const char *prog) /* a digit here means we have a job number */ if (idigit(*s)) { jobnum = atoi(s); - if (jobnum && jobnum <= mymaxjob && myjobtab[jobnum].stat && + if (jobnum > 0 && jobnum <= mymaxjob && myjobtab[jobnum].stat && !(myjobtab[jobnum].stat & STAT_SUBJOB) && /* * If running jobs in a subshell, we are allowed to @@ -2933,6 +2933,7 @@ acquire_pgrp(void) sigaddset(&blockset, SIGTTOU); sigaddset(&blockset, SIGTSTP); oldset = signal_block(blockset); + int loop_count = 0; while ((ttpgrp = gettygrp()) != -1 && ttpgrp != mypgrp) { mypgrp = GETPGRP(); if (mypgrp == mypid) { @@ -2948,8 +2949,21 @@ acquire_pgrp(void) if (read(0, NULL, 0) != 0) {} /* Might generate SIGT* */ signal_block(blockset); mypgrp = GETPGRP(); - if (mypgrp == lastpgrp && !interact) - break; /* Unlikely that pgrp will ever change */ + if (mypgrp == lastpgrp) { + if (!interact) + break; /* Unlikely that pgrp will ever change */ + if (++loop_count == 100) + { + /* + * It's time to give up. The count is arbitrary; + * this is just to fix up unusual cases, so it's + * left large in an attempt not to break normal + * cases where there's some delay in the system + * setting up the terminal. + */ + break; + } + } lastpgrp = mypgrp; } if (mypgrp != mypid) { @@ -2109,7 +2109,7 @@ skipcomm(void) hist_in_word(1); } else { /* - * Set up for nested command subsitution, however + * Set up for nested command substitution, however * we don't actually need the string until we get * back to the top level and recover the lot. * The $() body just appears empty. diff --git a/Src/loop.c b/Src/loop.c index 1013aeb50..01abc6cc9 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -425,7 +425,7 @@ execwhile(Estate state, UNUSED(int do_exec)) breaks--; simple_pline = old_simple_pline; - } else + } else { for (;;) { state->pc = loop; noerrexit = NOERREXIT_EXIT | NOERREXIT_RETURN; @@ -445,8 +445,11 @@ execwhile(Estate state, UNUSED(int do_exec)) lastval = oldval; break; } - if (retflag) + if (retflag) { + if (breaks) + breaks--; break; + } /* In case the loop body is also a functional no-op, * make sure signal handlers recognize ^C as above. */ @@ -470,6 +473,7 @@ execwhile(Estate state, UNUSED(int do_exec)) freeheap(); oldval = lastval; } + } cmdpop(); popheap(); loops--; @@ -566,7 +570,7 @@ execif(Estate state, int do_exec) if (run) { /* we need to ignore lastval until we reach execcmd() */ - if (olderrexit) + if (olderrexit || run == 2) noerrexit = olderrexit; else if (lastval) noerrexit |= NOERREXIT_EXIT | NOERREXIT_RETURN | NOERREXIT_UNTIL_EXEC; @@ -728,7 +732,7 @@ exectry(Estate state, int do_exec) Wordcode end, always; int endval; int save_retflag, save_breaks, save_contflag; - zlong save_try_errflag, save_try_tryflag, save_try_interrupt; + zlong save_try_errflag, save_try_interrupt; end = state->pc + WC_TRY_SKIP(state->pc[-1]); always = state->pc + 1 + WC_TRY_SKIP(*state->pc); @@ -737,12 +741,9 @@ exectry(Estate state, int do_exec) cmdpush(CS_CURSH); /* The :try clause */ - save_try_tryflag = try_tryflag; - try_tryflag = 1; - + ++try_tryflag; execlist(state, 1, do_exec); - - try_tryflag = save_try_tryflag; + --try_tryflag; /* Don't record errflag here, may be reset. However, */ /* endval should show failure when there is an error. */ diff --git a/Src/main.c b/Src/main.c index 30eef5a25..bad698ee7 100644 --- a/Src/main.c +++ b/Src/main.c @@ -34,7 +34,7 @@ * Support for Cygwin binary/text mode filesystems. * Peter A. Castro <doctor@fruitbat.org> * - * This deserves some explaination, because it uses Cygwin specific + * This deserves some explanation, because it uses Cygwin specific * runtime functions. * * Cygwin supports the notion of binary or text mode access to files @@ -43,7 +43,7 @@ * and all. If it's on a text mounted filesystem, Cygwin will strip out * the CRs. This presents a problem because zsh code doesn't allow for * CRLF's as line terminators. So, we must force all open files to be - * in text mode reguardless of the underlying filesystem attributes. + * in text mode regardless of the underlying filesystem attributes. * However, we only want to do this for reading, not writing as we still * want to write files in the mode of the filesystem. To do this, * we have two options: augment all {f}open() calls to have O_TEXT added to diff --git a/Src/makepro.awk b/Src/makepro.awk index 0498c1545..226d3f96b 100644 --- a/Src/makepro.awk +++ b/Src/makepro.awk @@ -121,7 +121,7 @@ BEGIN { # initialiser. dcltor = substr(line, 1, RLENGTH-1) line = substr(line, RLENGTH+1) - sub(/\=.*$/, "", dcltor) + sub(/=.*$/, "", dcltor) match(dcltor, /^([^_0-9A-Za-z]| const )*/) dcltor = substr(dcltor, 1, RLENGTH) "@+" substr(dcltor, RLENGTH+1) match(dcltor, /^.*@\+[_0-9A-Za-z]+/) diff --git a/Src/math.c b/Src/math.c index a38770073..905b910ec 100644 --- a/Src/math.c +++ b/Src/math.c @@ -1133,8 +1133,7 @@ notzero(mnumber a) /* macro to pop three values off the value stack */ -/**/ -void +static void op(int what) { mnumber a, b, c, *spval; @@ -1569,14 +1568,19 @@ mathparse(int pc) if (errflag) return; + queue_signals(); mtok = zzlex(); /* Handle empty input */ - if (pc == TOPPREC && mtok == EOI) + if (pc == TOPPREC && mtok == EOI) { + unqueue_signals(); return; + } checkunary(mtok, optr); while (prec[mtok] <= pc) { - if (errflag) + if (errflag) { + unqueue_signals(); return; + } switch (mtok) { case NUM: push(yyval, NULL, 0); @@ -1595,6 +1599,7 @@ mathparse(int pc) if (mtok != M_OUTPAR) { if (!errflag) zerr("bad math expression: ')' expected"); + unqueue_signals(); return; } break; @@ -1613,6 +1618,7 @@ mathparse(int pc) if (mtok != COLON) { if (!errflag) zerr("bad math expression: ':' expected"); + unqueue_signals(); return; } if (q) @@ -1636,4 +1642,5 @@ mathparse(int pc) mtok = zzlex(); checkunary(mtok, optr); } + unqueue_signals(); } @@ -1120,7 +1120,7 @@ struct m_hdr { /* length of memory header, length of first field of memory header and minimal size of a block left free (if we allocate memory and take a block from the free list that is larger than needed, it must have at - least M_MIN extra bytes to be splitted; if it has, the rest is put on + least M_MIN extra bytes to be split; if it has, the rest is put on the free list) */ #define M_HSIZE (sizeof(struct m_hdr)) diff --git a/Src/module.c b/Src/module.c index 33d75ebbd..f41b82f25 100644 --- a/Src/module.c +++ b/Src/module.c @@ -442,7 +442,7 @@ add_autobin(const char *module, const char *bnam, int flags) } /* Remove the builtin added previously by addbuiltin(). Returns * - * zero on succes and -1 if there is no builtin with that name. */ + * zero on success and -1 if there is no builtin with that name. */ /**/ int diff --git a/Src/options.c b/Src/options.c index 600b649e4..48c14c179 100644 --- a/Src/options.c +++ b/Src/options.c @@ -108,6 +108,7 @@ static struct optname optns[] = { {{NULL, "cbases", 0}, CBASES}, {{NULL, "cprecedences", OPT_EMULATE|OPT_NONZSH}, CPRECEDENCES}, {{NULL, "cdablevars", OPT_EMULATE}, CDABLEVARS}, +{{NULL, "cdsilent", 0}, CDSILENT}, {{NULL, "chasedots", OPT_EMULATE}, CHASEDOTS}, {{NULL, "chaselinks", OPT_EMULATE}, CHASELINKS}, {{NULL, "checkjobs", OPT_EMULATE|OPT_ZSH}, CHECKJOBS}, diff --git a/Src/params.c b/Src/params.c index 089a958ae..863b32600 100644 --- a/Src/params.c +++ b/Src/params.c @@ -44,7 +44,11 @@ #endif #endif -/* what level of localness we are at */ +/* What level of localness we are at. + * + * Hand-wavingly, this is incremented at every function call and decremented + * at every function return. See startparamscope(). + */ /**/ mod_export int locallevel; @@ -474,7 +478,13 @@ static initparam argvparam_pm = IPDEF9("", &pparams, NULL, \ static Param argvparam; -/* hash table containing the parameters */ +/* "parameter table" - hash table containing the parameters + * + * realparamtab always points to the shell's global table. paramtab is sometimes + * temporarily changed to point at another table, while dealing with the keys + * of an associative array (for example, see makecompparams() which initializes + * the associative array ${compstate}). + */ /**/ mod_export HashTable paramtab, realparamtab; @@ -1124,8 +1134,10 @@ copyparam(Param tpm, Param pm, int fakecopy) tpm->base = pm->base; tpm->width = pm->width; tpm->level = pm->level; - if (!fakecopy) + if (!fakecopy) { + tpm->old = pm->old; tpm->node.flags &= ~PM_SPECIAL; + } switch (PM_TYPE(pm->node.flags)) { case PM_SCALAR: tpm->u.str = ztrdup(pm->gsu.s->getfn(pm)); @@ -2201,10 +2213,10 @@ getstrvalue(Value v) if (v->flags & VALFLAG_SUBST) { if (v->pm->node.flags & (PM_LEFT|PM_RIGHT_B|PM_RIGHT_Z)) { - unsigned int fwidth = v->pm->width ? v->pm->width : MB_METASTRLEN(s); + size_t fwidth = v->pm->width ? (unsigned int)v->pm->width : MB_METASTRLEN(s); switch (v->pm->node.flags & (PM_LEFT | PM_RIGHT_B | PM_RIGHT_Z)) { char *t, *tend; - unsigned int t0; + size_t t0; case PM_LEFT: case PM_LEFT | PM_RIGHT_Z: @@ -2585,7 +2597,7 @@ assignstrvalue(Value v, char *val, int flags) Param pm = v->pm; /* Size doesn't change, can limit actions to only * overwriting bytes in already allocated string */ - strncpy(z + v->start, val, vlen); + memcpy(z + v->start, val, vlen); /* Implement remainder of strsetfn */ if (!(pm->node.flags & PM_HASHELEM) && ((pm->node.flags & PM_NAMEDDIR) || @@ -3546,7 +3558,7 @@ setiparam(char *s, zlong val) /* * Set an integer parameter without forcing creation of an integer type. - * This is useful if the integer is going to be set to a parmaeter which + * This is useful if the integer is going to be set to a parameter which * would usually be scalar but may not exist. */ @@ -3617,10 +3629,18 @@ unsetparam_pm(Param pm, int altflag, int exp) altpm = (Param) paramtab->getnode(paramtab, altremove); /* tied parameters are at the same local level as each other */ oldpm = NULL; - while (altpm && altpm->level > pm->level) { - /* param under alternate name hidden by a local */ - oldpm = altpm; - altpm = altpm->old; + /* + * Look for param under alternate name hidden by a local. + * If this parameter is special, however, the visible + * parameter is the special and the hidden one is keeping + * an old value --- we just mark the visible one as unset. + */ + if (altpm && !(altpm->node.flags & PM_SPECIAL)) + { + while (altpm && altpm->level > pm->level) { + oldpm = altpm; + altpm = altpm->old; + } } if (altpm) { if (oldpm && !altpm->level) { @@ -5858,7 +5878,7 @@ printparamnode(HashNode hn, int printflags) doneminus = 0; } if ((pmptr->flags & PMTF_USE_WIDTH) && p->width) { - printf("%d ", p->width); + printf("%u ", p->width); doneminus = 0; } } diff --git a/Src/parse.c b/Src/parse.c index 83383f10c..de1b27967 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -414,10 +414,10 @@ ecstrcode(char *s) return c; } else { Eccstr p, *pp; - int cmp; + long cmp; for (pp = &ecstrs; (p = *pp); ) { - if (!(cmp = p->nfunc - ecnfunc) && !(cmp = (((signed)p->hashval) - ((signed)val))) && !(cmp = strcmp(p->str, s))) { + if (!(cmp = p->nfunc - ecnfunc) && !(cmp = (((long)p->hashval) - ((long)val))) && !(cmp = strcmp(p->str, s))) { return p->offs; } pp = (cmp < 0 ? &(p->left) : &(p->right)); @@ -1811,7 +1811,7 @@ par_simple(int *cmplx, int nr) for (ptr = str; *ptr; ptr++) { /* * We can't treat this as "simple" if it contains - * expansions that require process subsitution, since then + * expansions that require process substitution, since then * we need process handling. */ if (ptr[1] == Inpar && @@ -1899,6 +1899,14 @@ par_simple(int *cmplx, int nr) p += nrediradd; sr += nrediradd; } + else if (postassigns) + { + /* C.f. normal case below */ + postassigns++; + ecadd(WCB_ASSIGN(WC_ASSIGN_SCALAR, WC_ASSIGN_INC, 0)); + ecstr(toksave); + ecstr(""); /* TBD can possibly optimise out */ + } else { ecstr(toksave); @@ -2271,7 +2279,8 @@ par_redir(int *rp, char *idstring) void setheredoc(int pc, int type, char *str, char *termstr, char *munged_termstr) { - ecbuf[pc] = WCB_REDIR(type | REDIR_FROM_HEREDOC_MASK); + int varid = WC_REDIR_VARID(ecbuf[pc]) ? REDIR_VARID_MASK : 0; + ecbuf[pc] = WCB_REDIR(type | REDIR_FROM_HEREDOC_MASK | varid); ecbuf[pc + 2] = ecstrcode(str); ecbuf[pc + 3] = ecstrcode(termstr); ecbuf[pc + 4] = ecstrcode(munged_termstr); diff --git a/Src/pattern.c b/Src/pattern.c index 737f5cdcb..c7c2c8bea 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -156,7 +156,7 @@ typedef union upat *Upat; * P_BRANCH, but applies to the immediately preceding branch. The code in * the corresponding branch is followed by a P_EXCSYNC, which simply * acts as a marker that a P_EXCLUDE comes next. The P_EXCLUDE - * has a pointer to char embeded in it, which works + * has a pointer to char embedded in it, which works * like P_WBRANCH: if we get to the P_EXCSYNC, and we already matched * up to the same position, fail. Thus we are forced to backtrack * on closures in the P_BRANCH if the first attempt was excluded. @@ -502,7 +502,7 @@ patcompcharsset(void) } } -/* Called before parsing a set of file matchs to initialize flags */ +/* Called before parsing a set of file matches to initialize flags */ /**/ void @@ -2030,6 +2030,16 @@ int errsfound; /* Total error count so far */ /**/ int forceerrs; /* Forced maximum error count */ +/* + * exactpos is used to remember how far down an exact string we have + * matched, if we are doing approximation and can therefore redo from + * the same point; we never need to otherwise. + * + * exactend is a pointer to the end of the string, which isn't + * null-terminated. + */ +static char *exactpos, *exactend; + /**/ void pattrystart(void) @@ -2072,7 +2082,7 @@ patmungestring(char **string, int *stringlen, int *unmetalenin) } /* - * Allocate memeory for pattern match. Note this is specific to use + * Allocate memory for pattern match. Note this is specific to use * of pattern *and* trial string. * * Unmetafy a trial string for use in pattern matching, if needed. @@ -2093,7 +2103,7 @@ patmungestring(char **string, int *stringlen, int *unmetalenin) * In patstralloc (supplied by caller, must last until last pattry is done) * unmetalen is the unmetafied length of the string; it will be * calculated if the input value is negative. - * unmetalenp is the umetafied length of a path segment preceeding + * unmetalenp is the umetafied length of a path segment preceding * the trial string needed for file mananagement; it is calculated as * needed so does not need to be initialised. * alloced is the memory allocated on the heap --- same as return value from @@ -2227,7 +2237,7 @@ pattrylen(Patprog prog, char *string, int len, int unmetalen, * depends on both prog *and* the trial string). This should only be * done if there is no path prefix (pathpos == 0) as otherwise the path * buffer and unmetafied string may not match. To do this, - * patallocstr() is callled (use force = 1 to ensure it is alway + * patallocstr() is called (use force = 1 to ensure it is always * unmetafied); paststralloc points to existing storage. Memory is * on the heap. * @@ -2321,7 +2331,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, if (patstralloc->alloced) { /* - * Unmetafied; we need pattern sring that's also unmetafied. + * Unmetafied; we need pattern string that's also unmetafied. * We'll cache it in the patstralloc structure. * Note it's on the heap. */ @@ -2379,7 +2389,7 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, /* * Remember the length in case used for ${..#..} etc. * In this case, we didn't unmetafy the pattern string - * In the orignal structure, but it might be unmetafied + * in the original structure, but it might be unmetafied * for use with an unmetafied test string. */ patinlen = pstrlen; @@ -2463,6 +2473,8 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, patinput = patinstart; + exactpos = exactend = NULL; + /* The only external call to patmatch --- all others are recursive */ if (patmatch((Upat)progstr)) { /* * we were lazy and didn't save the globflags if an exclusion @@ -2480,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) { @@ -2607,10 +2619,10 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalenin, } /* - * Return length of previous succesful match. This is + * Return length of previous successful match. This is * in metafied bytes, i.e. includes a count of Meta characters, * unless the match was done on an unmetafied string using - * a patstralloc stuct, in which case it, too is unmetafed. + * a patstralloc struct, in which case it too is unmetafied. * Unusual and futile attempt at modular encapsulation. */ @@ -2653,16 +2665,6 @@ patmatchlen(void) (charmatch_cache = (expr), CHARMATCH(charmatch_cache, chpa)) /* - * exactpos is used to remember how far down an exact string we have - * matched, if we are doing approximation and can therefore redo from - * the same point; we never need to otherwise. - * - * exactend is a pointer to the end of the string, which isn't - * null-terminated. - */ -static char *exactpos, *exactend; - -/* * Main matching routine. * * Testing the tail end of a match is usually done by recursion, but diff --git a/Src/prompt.c b/Src/prompt.c index f2b3f161e..b65bfb86b 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -163,7 +163,7 @@ promptpath(char *p, int npath, int tilde) * * txtchangep gives an integer controlling the attributes of * the prompt. This is for use in zle to maintain the attributes - * consistenly. Other parts of the shell should not need to use it. + * consistently. Other parts of the shell should not need to use it. */ /**/ @@ -1075,10 +1075,9 @@ putstr(int d) mod_export void countprompt(char *str, int *wp, int *hp, int overf) { - int w = 0, h = 1; + int w = 0, h = 1, multi = 0, wcw = 0; int s = 1; #ifdef MULTIBYTE_SUPPORT - int wcw, multi = 0; char inchar; mbstate_t mbs; wchar_t wc; @@ -1087,10 +1086,28 @@ countprompt(char *str, int *wp, int *hp, int overf) #endif for (; *str; str++) { - if (w > zterm_columns && overf >= 0) { - w = 0; + /* + * Avoid double-incrementing the height when there's a newline in the + * prompt and the line it terminates takes up exactly the width of the + * terminal + */ + while (w > zterm_columns && overf >= 0 && !multi) { h++; + if (wcw) { + /* + * Wide characters don't get split off. They move to the + * next line if there is not enough space. + */ + w = wcw; + break; + } else { + /* + * Tabs overflow to the next line as if they were made of spaces. + */ + w -= zterm_columns; + } } + wcw = 0; /* * Input string should be metafied, so tokens in it should * be real tokens, even if there are multibyte characters. @@ -1171,12 +1188,19 @@ countprompt(char *str, int *wp, int *hp, int overf) * This isn't easy to handle generally; just assume there's no * output. */ - if(w >= zterm_columns && overf >= 0) { - if (!overf || w > zterm_columns) { - w = 0; - h++; + while (w > zterm_columns && overf >= 0) { + h++; + if (wcw) { + w = wcw; + break; + } else { + w -= zterm_columns; } } + if (w == zterm_columns && overf == 0) { + w = 0; + h++; + } if(wp) *wp = w; if(hp) diff --git a/Src/signals.c b/Src/signals.c index f294049c2..96ff9e9b3 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -654,7 +654,7 @@ zhandler(int sig) _exit(SIGPIPE); else if (!isatty(SHTTY)) { stopmsg = 1; - zexit(SIGPIPE, 1); + zexit(SIGPIPE, ZEXIT_SIGNAL); } } break; @@ -662,7 +662,7 @@ zhandler(int sig) case SIGHUP: if (!handletrap(SIGHUP)) { stopmsg = 1; - zexit(SIGHUP, 1); + zexit(SIGHUP, ZEXIT_SIGNAL); } break; @@ -670,7 +670,7 @@ zhandler(int sig) if (!handletrap(SIGINT)) { if ((isset(PRIVILEGED) || isset(RESTRICTED)) && isset(INTERACTIVE) && (noerrexit & NOERREXIT_SIGNAL)) - zexit(SIGINT, 1); + zexit(SIGINT, ZEXIT_SIGNAL); if (list_pipe || chline || simple_pline) { breaks = loops; errflag |= ERRFLAG_INT; @@ -703,7 +703,7 @@ zhandler(int sig) errflag = noerrs = 0; zwarn("timeout"); stopmsg = 1; - zexit(SIGALRM, 1); + zexit(SIGALRM, ZEXIT_SIGNAL); } } break; @@ -1011,10 +1011,6 @@ removetrap(int sig) (!trapped || locallevel > (sigtrapped[sig] >> ZSIG_SHIFT))) dosavetrap(sig, locallevel); - if (!trapped) { - unqueue_signals(); - return NULL; - } if (sigtrapped[sig] & ZSIG_TRAPPED) nsigtrapped--; sigtrapped[sig] = 0; diff --git a/Src/sort.c b/Src/sort.c index 92ee1c0d4..8faf9349c 100644 --- a/Src/sort.c +++ b/Src/sort.c @@ -33,6 +33,9 @@ /* Flag for direction of sort: 1 forwards, -1 reverse */ static int sortdir; +/* Flag that sort ignores backslashes */ +static int sortnobslash; + /* Flag that sort is numeric */ static int sortnumeric; @@ -113,9 +116,24 @@ eltpcmp(const void *a, const void *b) bs += (laststarta - as); as += (laststarta - as); } + + if (sortnobslash) { + while (*as && *bs) { + if (*as == '\\') + as++; + if (*bs == '\\') + bs++; + if (*as != *bs || !*as) + break; + as++; + bs++; + } + } + #ifdef HAVE_STRCOLL cmp = strcoll(as, bs); #endif + if (sortnumeric) { for (; *as == *bs && *as; as++, bs++); #ifndef HAVE_STRCOLL @@ -162,7 +180,10 @@ mod_export int zstrcmp(const char *as, const char *bs, int sortflags) { struct sortelt ae, be, *aeptr, *beptr; - int oldsortdir = sortdir, oldsortnumeric = sortnumeric, ret; + int oldsortdir = sortdir; + int oldsortnobslash = sortnobslash; + int oldsortnumeric = sortnumeric; + int ret; ae.cmp = as; be.cmp = bs; @@ -173,11 +194,13 @@ zstrcmp(const char *as, const char *bs, int sortflags) beptr = &be; sortdir = 1; + sortnobslash = (sortflags & SORTIT_IGNORING_BACKSLASHES) ? 1 : 0; sortnumeric = (sortflags & SORTIT_NUMERICALLY) ? 1 : 0; ret = eltpcmp(&aeptr, &beptr); /* Paranoia: I don't think we ever need to restore these. */ + sortnobslash = oldsortnobslash; sortnumeric = oldsortnumeric; sortdir = oldsortdir; @@ -227,7 +250,7 @@ strmetasort(char **array, int sortwhat, int *unmetalenp) if (unmetalenp) { /* * Already unmetafied. We just need to check for - * embededded nulls. + * embedded nulls. */ int count = unmetalenp[arrptr-array]; /* Remember this length for sorted array */ diff --git a/Src/subst.c b/Src/subst.c index 60eb33390..79efc9ad2 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -91,7 +91,7 @@ keyvalpairelement(LinkList list, LinkNode node) * "flag"s contains PREFORK_* flags, defined in zsh.h. * * "ret_flags" is used to return PREFORK_* values from nested parameter - * substitions. It may be NULL in which case PREFORK_SUBEXP must not + * substitutions. It may be NULL in which case PREFORK_SUBEXP must not * appear in flags; any return value from below will be discarded. */ @@ -1548,7 +1548,7 @@ untok_and_escape(char *s, int escapes, int tok_arg) /* * See if an argument str looks like a subscript or length following * a colon and parse it. It must be followed by a ':' or nothing. - * If this succeeds, expand and return the evaulated expression if + * If this succeeds, expand and return the evaluated expression if * found, else return NULL. * * We assume this is what is meant if the first character is not @@ -1682,7 +1682,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, */ int wantt = 0; /* - * Indicates spliting a string into an array. There aren't + * Indicates splitting a string into an array. There aren't * actually that many special cases for this --- which may * be why it doesn't work properly; we split in some cases * where we shouldn't, in particular on the multsubs for @@ -1732,7 +1732,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, int mods = 0; /* * The (z) flag, nothing to do with SH_WORD_SPLIT which is tied - * spbreak, see above; fairly straighforward in use but c.f. + * spbreak, see above; fairly straightforward in use but cf. * the comment for mods. * * This gets set to one of the LEXFLAGS_* values. @@ -2725,7 +2725,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, * substitution is in quotes) always good enough? Potentially * we may be OK by now --- all potential `@'s and subexpressions * have been handled, including any [@] index which comes up - * by virture of v->isarr being set to SCANPM_ISVAR_AT which + * by virtue of v->isarr being set to SCANPM_ISVAR_AT which * is now in isarr. * * However, if we are replacing multsub() with something that @@ -3044,7 +3044,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, * shouldn't be any if not interactive. */ stopmsg = 1; - zexit(1, 0); + zexit(1, ZEXIT_NORMAL); } else _exit(1); } @@ -3110,7 +3110,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, /* * Either loop over an array doing replacements or - * do the replacment on a string. + * do the replacement on a string. * * We need an untokenized value for matching. */ @@ -3438,7 +3438,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, s--; if (unset(KSHARRAYS) || inbrace) { if (!isarr) - modify(&val, &s); + modify(&val, &s, inbrace); else { char *ss; char **ap = aval; @@ -3447,12 +3447,12 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, while ((*pp = *ap++)) { ss = s; - modify(pp++, &ss); + modify(pp++, &ss, inbrace); } if (pp == aval) { char *t = ""; ss = s; - modify(&t, &ss); + modify(&t, &ss, inbrace); } s = ss; } @@ -4182,6 +4182,12 @@ arithsubst(char *a, char **bptr, char *rest) * PTR is an in/out parameter. On entry it contains the string of colon * modifiers. On return it points past the last recognised modifier. * + * INBRACE is non-zero if we are in some form of a bracketed or + * parenthesised expression; it is zero for modifiers ocurring + * in an an unbracketed variable substitution. This means that + * $foo:t222 is treated ias ${foo:t}222 rather than ${foo:t222} + * for backward compatibility. + * * Example: * ENTRY: *str is "." *ptr is ":AN" * RETURN: *str is "/home/foobar" (equal to $PWD) *ptr points to the "N" @@ -4189,7 +4195,7 @@ arithsubst(char *a, char **bptr, char *rest) /**/ void -modify(char **str, char **ptr) +modify(char **str, char **ptr, int inbrace) { char *ptr1, *ptr2, *ptr3, *lptr, c, *test, *sep, *t, *tt, tc, *e; char *copy, *all, *tmp, sav, sav1, *ptr1end; @@ -4202,6 +4208,8 @@ modify(char **str, char **ptr) *str = dupstring(*str); while (**ptr == ':') { + int count = 0; + lptr = *ptr; (*ptr)++; wall = gbal = 0; @@ -4214,10 +4222,8 @@ modify(char **str, char **ptr) case 'a': case 'A': case 'c': - case 'h': case 'r': case 'e': - case 't': case 'l': case 'u': case 'q': @@ -4226,6 +4232,17 @@ modify(char **str, char **ptr) c = **ptr; break; + case 'h': + case 't': + c = **ptr; + if (inbrace && idigit((*ptr)[1])) { + do { + count = 10 * count + ((*ptr)[1] - '0'); + ++(*ptr); + } while (idigit((*ptr)[1])); + } + break; + case 's': c = **ptr; (*ptr)++; @@ -4392,7 +4409,7 @@ modify(char **str, char **ptr) break; } case 'h': - remtpath(©); + remtpath(©, count); break; case 'r': remtext(©); @@ -4401,7 +4418,7 @@ modify(char **str, char **ptr) rembutext(©); break; case 't': - remlpaths(©); + remlpaths(©, count); break; case 'l': copy = casemodify(tt, CASMOD_LOWER); @@ -4478,7 +4495,7 @@ modify(char **str, char **ptr) break; } case 'h': - remtpath(str); + remtpath(str, count); break; case 'r': remtext(str); @@ -4487,7 +4504,7 @@ modify(char **str, char **ptr) rembutext(str); break; case 't': - remlpaths(str); + remlpaths(str, count); break; case 'l': *str = casemodify(*str, CASMOD_LOWER); diff --git a/Src/text.c b/Src/text.c index 3658b1bc6..69530ae79 100644 --- a/Src/text.c +++ b/Src/text.c @@ -470,8 +470,13 @@ gettext2(Estate state) " || " : " && "); s->code = *state->pc++; s->pop = (WC_SUBLIST_TYPE(s->code) == WC_SUBLIST_END); - if (WC_SUBLIST_FLAGS(s->code) & WC_SUBLIST_NOT) - taddstr("! "); + if (WC_SUBLIST_FLAGS(s->code) & WC_SUBLIST_NOT) { + if (WC_SUBLIST_SKIP(s->code) == 0) + stack = 1; + taddstr((stack || (!(WC_SUBLIST_FLAGS(s->code) & + WC_SUBLIST_SIMPLE) && wc_code(*state->pc) != + WC_PIPE)) ? "!" : "! "); + } if (WC_SUBLIST_FLAGS(s->code) & WC_SUBLIST_COPROC) taddstr("coproc "); } @@ -579,7 +584,7 @@ gettext2(Estate state) state->pc = end; if (!nargs) { /* - * Unnamed fucntion. + * Unnamed function. * We're not going to pull any arguments off * later, so skip them now... */ diff --git a/Src/utils.c b/Src/utils.c index 32f600858..f5667f389 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -287,9 +287,7 @@ zerrmsg(FILE *file, const char *fmt, va_list ap) { const char *str; int num; -#ifdef DEBUG long lnum; -#endif #ifdef HAVE_STRERROR_R #define ERRBUFSIZE (80) int olderrno; @@ -325,12 +323,10 @@ zerrmsg(FILE *file, const char *fmt, va_list ap) nicezputs(s, file); break; } -#ifdef DEBUG case 'L': lnum = va_arg(ap, long); fprintf(file, "%ld", lnum); break; -#endif case 'd': num = va_arg(ap, int); fprintf(file, "%d", num); @@ -2201,6 +2197,31 @@ gettempname(const char *prefix, int use_heap) #ifdef HAVE__MKTEMP /* Zsh uses mktemp() safely, so silence the warnings */ ret = (char *) _mktemp(ret); +#elif HAVE_MKSTEMP && defined(DEBUG) + { + /* zsh uses mktemp() safely (all callers use O_EXCL, and one of them + * uses mkfifo()/mknod(), as opposed to open()), but some compilers + * warn about this anyway and give no way to disable the warning. To + * appease them, use mkstemp() and then close the fd and unlink the + * filename, to match callers' expectations. + * + * But do this in debug builds only, because we don't want to suffer + * x3 the disk access (touch, unlink, touch again) in production. + */ + int fd; + errno = 0; + fd = mkstemp(ret); + if (fd < 0) + zwarn("can't get a temporary filename: %e", errno); + else { + close(fd); + ret = ztrdup(ret); + + errno = 0; + if (unlink(ret) < 0) + zwarn("unlinking a temporary filename failed: %e", errno); + } + } #else ret = (char *) mktemp(ret); #endif @@ -3159,6 +3180,8 @@ spckword(char **s, int hist, int cmd, int ask) scanhashtable(cmdnamtab, 1, 0, 0, spscan, 0); if (autocd) { char **pp; + if (cd_able_vars(unmeta(guess))) + return; for (pp = cdpath; *pp; pp++) { char bestcd[PATH_MAX + 1]; int thisdist; @@ -3336,7 +3359,7 @@ morefmt: case '.': { long fnsec = nsec; - if (digs > 9) + if (digs < 0 || digs > 9) digs = 9; if (ztrftimebuf(&bufsize, digs)) return -1; diff --git a/Src/watch.c b/Src/watch.c index cd7dc643d..93b3cb134 100644 --- a/Src/watch.c +++ b/Src/watch.c @@ -98,7 +98,7 @@ /* * In utmpx, the ut_name field is replaced by ut_user. - * Howver, on some systems ut_name may already be defined this + * However, on some systems ut_name may already be defined this * way for the purposes of utmp. */ # ifndef ut_name @@ -455,7 +455,7 @@ enum { */ #define FDT_FLOCK_EXEC 6 /* - * Entry used by a process substition. + * Entry used by a process substitution. * This marker is not tested internally as we associated the file * descriptor with a job for closing. * @@ -1254,8 +1254,8 @@ enum { /* * Assignment has value? - * If the assignment is an arrray, then it certainly has a value --- we - * can only tell if there's an expicit assignment. + * If the assignment is an array, then it certainly has a value --- we + * can only tell if there's an explicit assignment. */ #define ASG_VALUEP(asg) (ASG_ARRAYP(asg) || \ @@ -1444,8 +1444,8 @@ struct builtin { */ #define BINF_HANDLES_OPTS (1<<18) /* - * Handles the assignement interface. The argv list actually contains - * two nested litsts, the first of normal arguments, and the second of + * Handles the assignment interface. The argv list actually contains + * two nested lists, the first of normal arguments, and the second of * assignment structures. */ #define BINF_ASSIGN (1<<19) @@ -2006,7 +2006,7 @@ enum { enum { /* * Set if the string had whitespace at the start - * that should cause word splitting against any preceeding string. + * that should cause word splitting against any preceding string. */ MULTSUB_WS_AT_START = 1, /* @@ -2272,9 +2272,9 @@ struct histent { */ #define LEXFLAGS_NEWLINE 0x0010 -/******************************************/ -/* Definitions for programable completion */ -/******************************************/ +/*******************************************/ +/* Definitions for programmable completion */ +/*******************************************/ /* Nothing special. */ #define IN_NOTHING 0 @@ -2348,6 +2348,7 @@ enum { CASEMATCH, CBASES, CDABLEVARS, + CDSILENT, CHASEDOTS, CHASELINKS, CHECKJOBS, @@ -2998,7 +2999,7 @@ struct sortelt { int origlen; /* * The length of the string, if needed, else -1. - * The length is only needed if there are embededded nulls. + * The length is only needed if there are embedded nulls. */ int len; }; @@ -3221,6 +3222,14 @@ enum { /* Hooks in core. */ /***************************************/ +/* The type of zexit()'s second parameter, which see. */ +enum zexit_t { + /* This isn't a bitfield. The values are here just for explicitness. */ + ZEXIT_NORMAL = 0, + ZEXIT_SIGNAL = 1, + ZEXIT_DEFERRED = 2 +}; + #define EXITHOOK (zshhooks + 0) #define BEFORETRAPHOOK (zshhooks + 1) #define AFTERTRAPHOOK (zshhooks + 2) diff --git a/Src/zsh_system.h b/Src/zsh_system.h index e7d529b6e..85e198f2e 100644 --- a/Src/zsh_system.h +++ b/Src/zsh_system.h @@ -522,7 +522,7 @@ struct timespec { # define RLIMIT_VMEM RLIMIT_AS #endif -#ifdef HAVE_SYS_CAPABILITY_H +#if defined(HAVE_SYS_CAPABILITY_H) && defined(HAVE_CAP_GET_PROC) # include <sys/capability.h> #endif 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/A01grammar.ztst b/Test/A01grammar.ztst index 339ce7494..1e0e9a04e 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -76,6 +76,39 @@ 0:Basic current shell list with error >false + fn() { : && ! ; : } + functions -x3 fn + fn +0:End of sublist containing ! with no command +>fn () { +> : && ! +> : +>} + + if [[ m -eq y ]]; then + : && ! + : + fi +0:! followed by no further commands + + fn() { ! {!} && ! (!) || ! {!} } + functions -x2 fn + fn +0:exclamation marks without following commands +>fn () { +> ! { +> ! +> } && ! ( +> ! +> ) || ! { +> ! +> } +>} + + ! | true +1:! followed by no command but by a pipe +?(eval):1: parse error near `|' + # # Tests for `Precommand Modifiers' # @@ -433,14 +466,6 @@ >Status after always block is 1. ?(eval):3: bad substitution - fn() { { return } always { echo always 1 }; echo not executed } - fn - fn() { { echo try 2 } always { return }; echo not executed } - fn -0:Always block interaction with return ->always 1 ->try 2 - # Outputting of structures from the wordcode is distinctly non-trivial, # we probably ought to have more like the following... fn1() { { echo foo; } } @@ -640,6 +665,16 @@ >1 >0 + echo 'echo dot + until return 42; do + : + done' >until_dot + . ./until_dot + echo After dot +0:return in positive until test in dot file does not cause excess breaks +>dot +>After dot + echo 'echo $?' >dot_status false . ./dot_status @@ -677,6 +712,14 @@ >read it >read it + fn() { { return } always { echo always 1 }; echo not executed } + fn + fn() { { echo try 2 } always { return }; echo not executed } + fn +0:Always block interaction with return +>always 1 +>try 2 + ( mywrap() { echo BEGIN; true; echo END } mytest() { { exit 3 } always { mywrap }; print Exited before this } @@ -686,6 +729,7 @@ 3:Exit and always block with functions: simple >BEGIN >END +F:Note that the behaviour of 'exit' inside try-list inside a function is unspecified. ( mytrue() { echo mytrue; return 0 } @@ -698,6 +742,7 @@ >BEGIN >mytrue >END +F:Note that the behaviour of 'exit' inside try-list inside a function is unspecified. (emulate sh -c ' fn() { @@ -883,3 +928,7 @@ >PIPE >and true >or false + + $ZTST_testdir/../Src/zsh -fc '{ ( ) } always { echo foo }' +-f:exec last command optimization inhibited for try/always +>foo diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst index 99f7aae26..ca415fa39 100644 --- a/Test/A02alias.ztst +++ b/Test/A02alias.ztst @@ -129,7 +129,7 @@ setopt ALIAS_FUNC_DEF eval 'goodalias() { print does now work; }' isafunc) -0:ALIAS_FUNC_DEF causes the icky behaviour to be avaliable +0:ALIAS_FUNC_DEF causes the icky behaviour to be available >does now work (alias thisisokthough='thisworks() { print That worked; }' diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst index 1e17dddd4..d60519064 100644 --- a/Test/A04redirect.ztst +++ b/Test/A04redirect.ztst @@ -692,11 +692,19 @@ >b >d - umask 0777 + (umask 0777 cat <<' HERE' look ma, no permissions HERE cat <<<"it's a miracle" + ) 0:Here-{string,document}s succeed with restrictive umask > look ma, no permissions >it's a miracle + + exec {testfd}<<' HERE' + This is, in some sense, a here document. + HERE + cat <&$testfd +0:Regression test for here document with fd declarator +> This is, in some sense, a here document. diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst index 8d4f0955c..d903b7462 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. # @@ -70,11 +70,13 @@ # the expected status returned by the code when run, or - if it is # irrelevant. An optional set of single-letter flags follows the status # or -. The following are understood: -# . d Don't diff stdout against the expected stdout. +# . d Don't diff stdout against the expected stdout. # D Don't diff stderr against the expected stderr. # q All redirection lines given in the test script (not the lines # actually produced by the test) are subject to ordinary quoted shell # expansion (i.e. not globbing). +# f Test is expected to fail. If the test's exit code, stdout, and stderr +# match, report a problem; otherwise, carry on to the next test case. # This can be followed by a `:' and a message describing the # test, which will be printed if the test fails, along with a # description of the failure that occurred. The `:' and message are @@ -105,6 +107,8 @@ # is to be skipped. # ZTST_skip: Set this in any test case if that single test case is to be # skipped. Testing resumes at the next test case in the same file. +# +# Syntax highlighting for Vim is available, see Util/ztst-*.vim. cd cdtst.tmp/sub/fake && pwd && print $PWD @@ -141,6 +145,10 @@ F:something is broken. But you already knew that. 1:Implicit cd with unset HOME. ?zsh:cd:1: HOME not set + $ZTST_testdir/../Src/zsh -fc 'cd -P ////dev && pwd' +-f:(workers/45367) cd -P squashes multiple leading slashes +>/dev + %clean # This optional section cleans up after the test, if necessary, # e.g. killing processes etc. This is in addition to the removal of *.tmp diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index ac86e0ad1..e7bf93794 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -1101,3 +1101,10 @@ >export zsh_exported_readonly_scalar=1 >readonly zsh_exported_readonly_array=( 2 ) >readonly zsh_exported_readonly_scalar=1 + + # The second case was buggy as it needs special handling in postassigns + (typeset {X}) + (typeset Q= {X}) +1:Regression test for {...} parsing in typeset +?(eval):typeset:2: not valid in this context: {X} +?(eval):typeset:3: not valid in this context: {X} diff --git a/Test/B10getopts.ztst b/Test/B10getopts.ztst index 7eba5a4b1..72c9e209e 100644 --- a/Test/B10getopts.ztst +++ b/Test/B10getopts.ztst @@ -79,3 +79,20 @@ test_getopts +x 1:one illegal option, + variant >test_getopts:3: bad option: +x + + set -- -x + OPTIND=1 + while getopts x: opt; do + echo "$opt,${OPTARG:-Empty}" + done +0:missing option-argument (error message mode) +>?,Empty +?(eval):3: argument expected after -x option + + set -- -x + OPTIND=1 + while getopts :x: opt; do + echo "$opt,${OPTARG:-Empty}" + done +0:missing option-argument (quiet mode) +>:,x diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst index 9dfc065c8..419f45292 100644 --- a/Test/C01arith.ztst +++ b/Test/C01arith.ztst @@ -386,7 +386,7 @@ esac) print after case in subshell) ' -0:Non-arithmetic subst with command subsitution parse from hell +0:Non-arithmetic subst with command substitution parse from hell >yes, this one after case in subshell print "a$((echo one subst) diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst index 4ffb07dd4..4b1ec02f0 100644 --- a/Test/C02cond.ztst +++ b/Test/C02cond.ztst @@ -388,7 +388,7 @@ F:Failures in these cases do not indicate a problem in the shell. eval test $w print $? done -0:test compatability weirdness: treat ! as a string sometimes +0:test compatibility weirdness: treat ! as a string sometimes >0 >0 >1 diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index 4aebd92b7..6f84e5db2 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -500,6 +500,15 @@ >Succeed 2 >Succeed 3 + (set -e + if false; then + else + a=$(false) + print This should not appear + fi + ) +1:ERREXIT is triggered in an else block after a cmd subst returning false + fn() { emulate -L zsh setopt errreturn @@ -881,6 +890,23 @@ F:Must be tested with a top-level script rather than source or function $ZTST_testdir/../Src/zsh -f <<<'fn() { exit 0; }; trap fn EXIT; false' 0:Explicit exit status overrides implicit: script-like code path + $ZTST_testdir/../Src/zsh -f <<<$' + trap \'echo $1; exit; echo $2\' USR1 + fn() { + echo fn1 + kill -s USR1 $$ + echo fn2 + } + echo out1 + fn trap1 trap2 + echo out2 + ' +-f:(workers/44007) function execution continues after 'exit' in trap +>out1 +>fn1 +>trap1 +# As of 5.7.1-test-2, the output was "out1 fn1 trap1 fn2" (on separate lines). + %clean rm -f TRAPEXIT diff --git a/Test/C04funcdef.ztst b/Test/C04funcdef.ztst index 3aaf7fb4a..407fc471f 100644 --- a/Test/C04funcdef.ztst +++ b/Test/C04funcdef.ztst @@ -503,7 +503,7 @@ not_trashed() { print This function was not trashed; } autoload -Uz /foo/bar/not_trashed not_trashed -0:autoload with absolute path doesn't trash loaded function +0:autoload with absolute path does not trash loaded function >This function was not trashed # keep spec from getting loaded in parent shell for simplicity @@ -542,6 +542,73 @@ 0:autoload containing dash >this should run automatically + tbc() { + print This function is called $0. + } + tbc + functions -c tbc newcopy + newcopy + unfunction tbc + newcopy +0:functions -c +>This function is called tbc. +>This function is called newcopy. +>This function is called newcopy. + + ( + fpath=(.) + print >tbc_auto 'print This autoloaded function is called $0.' + autoload -Uz tbc_auto + functions -c tbc_auto newcopy_auto + newcopy_auto + tbc_auto + ) +0:functions -c with autoload +>This autoloaded function is called newcopy_auto. +>This autoloaded function is called tbc_auto. + + ( + fpath=(.) + print >tbc_redef "print This is the core of the old function." + autoload -Uz tbc_redef + functions -c tbc_redef tbc_original + tbc_redef() { + print About to call the original. + tbc_original + print Stopped calling the original because once is enough. + } + tbc_redef + ) +0:function -c with redefinition +>About to call the original. +>This is the core of the old function. +>Stopped calling the original because once is enough. + + ( + fpath=(.) + print >line_info '\nprint -P "%1x:%I is where we are."' + autoload -Uz line_info + functions -c line_info preserve_file + preserve_file + ) +0:functions -c preserves file information +>line_info:2 is where we are. + + ( + fpath=(.) + print >func_info '\nprint -P "%N:%i is where we are."' + autoload -Uz func_info + functions -c func_info change_output + change_output + ) +0:functions -c updates non-file function information +>change_output:2 is where we are. + + autoload -Uz cant_autoload_for_copying + functions -c cant_autoload_for_copying not_copied +1:functions -c gracefully rejects failed autoload +?(eval):2: cant_autoload_for_copying: function definition file not found + %clean rm -f file.in file.out diff --git a/Test/D02glob.ztst b/Test/D02glob.ztst index 08b71dc8e..b0650c8c8 100644 --- a/Test/D02glob.ztst +++ b/Test/D02glob.ztst @@ -700,3 +700,53 @@ print ${value//[${foo}b-z]/x} 0:handling of - range in complicated pattern context >xx + + pathtotest=glob.tmp/my/test/dir/that/does/not/exist + mkdir -p $pathtotest + print $pathtotest(:h) + print $pathtotest(:h0) + print $pathtotest(:h10) + print $pathtotest(:h3) + print $pathtotest(:h2) + print $pathtotest(:h1) + print $pathtotest(:t) + print $pathtotest(:t0) + print $pathtotest(:t10) + print $pathtotest(:t3) + print $pathtotest(:t2) + print $pathtotest(:t1) +0:modifiers :h and :t with numbers (main test is in D04parameter.ztst) +>glob.tmp/my/test/dir/that/does/not +>glob.tmp/my/test/dir/that/does/not +>glob.tmp/my/test/dir/that/does/not/exist +>glob.tmp/my/test +>glob.tmp/my +>glob.tmp +>exist +>exist +>glob.tmp/my/test/dir/that/does/not/exist +>does/not/exist +>not/exist +>exist + + mkdir -m 000 glob.tmp/secret-d000 + mkdir -m 111 glob.tmp/secret-d111 + mkdir -m 444 glob.tmp/secret-d444 + for 1 in 000 111 444 ; do ln -s secret-d$1 glob.tmp/secret-s$1; done + print -rC 2 -- glob.tmp/secret-*/ glob.tmp/secret-*(-/) +-f:unreadable directories can be globbed (users/24619, users/24626) +>glob.tmp/secret-d000/ glob.tmp/secret-d000 +>glob.tmp/secret-d111/ glob.tmp/secret-d111 +>glob.tmp/secret-d444/ glob.tmp/secret-d444 +>glob.tmp/secret-s000/ glob.tmp/secret-s000 +>glob.tmp/secret-s111/ glob.tmp/secret-s111 +>glob.tmp/secret-s444/ glob.tmp/secret-s444 + + () { echo $1:P } ////dev +-f:(workers/45367) modifier ':P' squashes multiple slashes +>/dev + +%clean + + # Fix unreadable-directory permissions so ztst can clean up properly + chmod +rwx glob.tmp/secret-*(N) 2> /dev/null diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst index 1ef55821b..8cf4e2a7f 100644 --- a/Test/D03procsubst.ztst +++ b/Test/D03procsubst.ztst @@ -26,7 +26,7 @@ >SEcond ViErtE diff =(cat FILE1) =(cat FILE2) -1:=(...) substituion +1:=(...) substitution >1c1 >< First Second Third Fourth >--- diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 1ec650352..76f3e77a1 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -640,6 +640,74 @@ >echo >$(|||) bar + argv=( + $'a=() b=()' + $'a=(foo) b=(bar)' + $'a=(foo) b=() c=() d=(bar) e=(baz) f=() g=()' + $'a=(foo) b=() c=() d=(bar)\ne=(baz) f=() g=()' + $'a=(foo) b=() d=(bar)' + ) + for 1; print -rl -- ${(z)1} && print +0:${(z)} regression test: multiple array assignments +>a=( +>) +>b=( +>) +> +>a=( +>foo +>) +>b=( +>bar +>) +> +>a=( +>foo +>) +>b=( +>) +>c=( +>) +>d=( +>bar +>) +>e=( +>baz +>) +>f=( +>) +>g=( +>) +> +>a=( +>foo +>) +>b=( +>) +>c=( +>) +>d=( +>bar +>) +>; +>e=( +>baz +>) +>f=( +>) +>g=( +>) +> +>a=( +>foo +>) +>b=( +>) +>d=( +>bar +>) +> + foo=$'\x06ZUI\x1f text-field example: \x1azuitfieldtfield1_1\x1a\'\'\x1a\'\'\x1a1\x1aZUI\\[my_tfield1_width\\]\x1aZUI\\[my_tfield1_start\\]\x1aZUI\\[my_tfield1_data\\]\x1c' print "${#${(z@)foo}}" 0:Test real-world data that once seemed to fail @@ -2444,4 +2512,141 @@ 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 + eval "print \$testpath:t$i" + eval "print \${testpath:t$i}" + done +0:t with trailing digits +>four0 +>four +>four1 +>four +>four2 +>three/four +>four3 +>two/three/four +>four4 +>one/two/three/four +>four5 +>/one/two/three/four +>four6 +>/one/two/three/four + + testpath=/one/two/three/four + for (( i = 0; i <= 6; ++i )); do + eval "print \$testpath:h$i" + eval "print \${testpath:h$i}" + done +0:h with trailing digits +>/one/two/three0 +>/one/two/three +>/one/two/three1 +>/ +>/one/two/three2 +>/one +>/one/two/three3 +>/one/two +>/one/two/three4 +>/one/two/three +>/one/two/three5 +>/one/two/three/four +>/one/two/three6 +>/one/two/three/four + + testpath=/a/quite/long/path/to/do/messy/stuff/with + print $testpath:h2:t3:h5:t16:h2n2 + print ${testpath:t5:h2} + print ${testpath:t5:h2:t} + print ${testpath:h6:t4:h3:t2:h} + print ${testpath:h10:t10:t6:h3} + print ${testpath:t9:h} + print ${testpath:t9:h:t} +0:Combinations of :h and :t with and without trailing digits +>/a/quite/long/path/to/do/messy/stuff2:t3:h5:t16:h2n2 +>to/do +>do +>long +>path/to/do +>a/quite/long/path/to/do/messy/stuff +>stuff + + testpath=///this//has////lots//and////lots//of////slashes + print ${testpath:h3} + print ${testpath:t4} +0:Multiple slashes are treated as one in :h and :t but are not removed +>///this//has +>and////lots//of////slashes + + testpath=trailing/slashes/are/removed/// + print ${testpath:h} + print ${testpath:h2} + print ${testpath:t} + print ${testpath:t2} +0:Modifiers :h and :t remove trailing slashes before examining path +>trailing/slashes/are +>trailing/slashes +>removed +>are/removed + + foo=global-value + fn() { + local foo=function-value + foo=export-value true + print $foo + } + fn + print $foo +0:Global variables are not trashed by "foo=bar builtin" (regression test) +>function-value +>global-value + + foo=pws + print ${foo%*} +0:Smallest match at end can match zero-length string +>pws + + foo=pws + print ${foo%?} +0:Smallest match at end with a character always matches one +>pw + + setopt extendedglob + foo=pws + print ${foo%s#} + print ${foo%%s#} +0:Smallest / largest match with non-trivial closure +>pws +>pw + + foo=pws + print ${foo%%*} +0:Largest match at end matches entire string +> + + foo=pws + print 1: ${(S)foo#*} + print 2: ${(S)foo##*} + print 3: ${(S)foo#?} + print 4: ${(S)foo##?} +0:(S) with zero-length matches at start +>1: pws +>2: +>3: ws +>4: ws + + foo=pws + print 2: ${(S)foo%%*} +0:(S) with zero-length matches at end, part 1 (workers/45164) +>2: pws + + foo=pws + print 1: ${(S)foo%*} + print 3: ${(S)foo%?} + print 4: ${(S)foo%%?} +0:(S) with zero-length matches at end, part 2 +>1: pws +>3: pw +>4: pw diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst index 3ea7fb7e4..c1a8d79cf 100644 --- a/Test/D06subscript.ztst +++ b/Test/D06subscript.ztst @@ -190,7 +190,7 @@ typeset -ga empty echo X${${empty##*}[-1]}X -0:Negative index applied to substition result from empty array +0:Negative index applied to substitution result from empty array >XX print $empty[(i)] $empty[(I)] @@ -221,7 +221,7 @@ >fimble two three four print X$array[(R)notfound]X -0:(R) yuckily returns the first element on failure withe KSH_ZERO_SUBSCRIPT +0:(R) yuckily returns the first element on failure with KSH_ZERO_SUBSCRIPT >XfimbleX unsetopt KSH_ZERO_SUBSCRIPT diff --git a/Test/D08cmdsubst.ztst b/Test/D08cmdsubst.ztst index 4e0759e35..04bf698aa 100644 --- a/Test/D08cmdsubst.ztst +++ b/Test/D08cmdsubst.ztst @@ -174,6 +174,6 @@ eval '{ OPEN print hi; CLOSE } var=$({ OPEN print bye; CLOSE}) && print $var' ) -0:Alias expansion needed in parsing substituions +0:Alias expansion needed in parsing substitutions >hi >bye diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 0f6bb3455..c4b101bdb 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -850,7 +850,7 @@ # With non-special command: original value restored # With special builtin: new value kept - # With special builtin preceeded by "command": original value restored. + # With special builtin preceded by "command": original value restored. (setopt posixbuiltins FOO=val0 FOO=val1 true; echo $FOO diff --git a/Test/Makefile.in b/Test/Makefile.in index 083df4942..09f37bf53 100644 --- a/Test/Makefile.in +++ b/Test/Makefile.in @@ -40,16 +40,21 @@ INSTALL = @INSTALL@ # ========== DEPENDENCIES FOR TESTING ========== +# If ZTST_handler is not empty, run that instead of runtests.zsh. +# It's assumed to be found in the source directory. check test: if test -n "$(DLLD)"; then \ cd $(dir_top) && DESTDIR= \ $(MAKE) MODDIR=`pwd`/$(subdir)/Modules install.modules > /dev/null; \ fi + if test -z "$$ZTST_handler"; then \ + ZTST_handler=runtests.zsh; \ + fi; \ if ZTST_testlist="`for f in $(sdir)/$(TESTNUM)*.ztst; \ do echo $$f; done`" \ ZTST_srcdir="$(sdir)" \ ZTST_exe=$(dir_top)/Src/zsh@EXEEXT@ \ - $(dir_top)/Src/zsh@EXEEXT@ +Z -f $(sdir)/runtests.zsh; then \ + $(dir_top)/Src/zsh@EXEEXT@ +Z -f $(sdir)/$$ZTST_handler; then \ stat=0; \ else \ stat=1; \ diff --git a/Test/V05styles.ztst b/Test/V05styles.ztst index ca95b6348..c221d9db8 100644 --- a/Test/V05styles.ztst +++ b/Test/V05styles.ztst @@ -141,3 +141,13 @@ >scalar-style > :ztst:context:* second-scalar-value + (zstyle 'ctx?' foo one + zstyle 'ctx*' foo two + zstyle -s 'ctx1' foo bar && print $bar) + (zstyle 'ctx*' foo two + zstyle 'ctx?' foo one + zstyle -s 'ctx1' foo bar && print $bar) +0:patterns of equal weight are used in order of definition +>one +>two + diff --git a/Test/V10private.ztst b/Test/V10private.ztst index 880784e12..a3a63867b 100644 --- a/Test/V10private.ztst +++ b/Test/V10private.ztst @@ -104,7 +104,7 @@ private -h path print X$path } -0:privates may hide tied paramters +0:privates may hide tied parameters >X # Deliberate type mismatch here diff --git a/Test/V12zparseopts.ztst b/Test/V12zparseopts.ztst new file mode 100644 index 000000000..d7fc33f72 --- /dev/null +++ b/Test/V12zparseopts.ztst @@ -0,0 +1,172 @@ +# Test zparseopts from the zsh/zutil module + +%prep + + if zmodload zsh/zutil 2> /dev/null; then + # Produce a string representing an associative array ordered by its keys + order_assoc() { + local -a _arr + for 2 in "${(@kP)1}"; do + _arr+=( "${(q-)2} ${(q-)${(P)1}[$2]}" ) + done + print -r - ${(j< >)${(@o)_arr}} + } + else + ZTST_unimplemented="can't load the zsh/zutil module for testing" + fi + +%test + + () { + local -a optv + zparseopts -a optv - a b: c:- z + print -r - ret: $?, optv: $optv, argv: $argv + } -ab1 -c -d -e -z +0:zparseopts -a +>ret: 0, optv: -a -b 1 -c-d, argv: -ab1 -c -d -e -z + + () { + local -A opts + zparseopts -A opts - a b: c:- z + print -r - ret: $?, opts: "$( order_assoc opts )", argv: $argv + } -ab1 -c -d -e -z +0:zparseopts -A +>ret: 0, opts: -a '' -b 1 -c -d, argv: -ab1 -c -d -e -z + + () { + local -a optv + zparseopts -D -a optv - a b: c:- z + print -r - ret: $?, optv: $optv, argv: $argv + } -ab1 -c -d -e -z +0:zparseopts -D +>ret: 0, optv: -a -b 1 -c-d, argv: -e -z + + () { + local -a optv + zparseopts -E -a optv - a b: c:- z + print -r - ret: $?, optv: $optv, argv: $argv + } -ab1 -c -d -e -z +0:zparseopts -E +>ret: 0, optv: -a -b 1 -c-d -z, argv: -ab1 -c -d -e -z + + () { + local -a optv + zparseopts -D -E -a optv - a b: c:- z + print -r - ret: $?, optv: $optv, argv: $argv + } -ab1 -c -d -e -z +0:zparseopts -D -E +>ret: 0, optv: -a -b 1 -c-d -z, argv: -e + + for 1 in '-a -x -z' '-ax -z' '-a --x -z'; do + () { + local -a optv + zparseopts -D -E -F -a optv - a b: c:- z + print -r - ret: $?, optv: $optv, argv: $argv + } $=1 + done +0:zparseopts -F +?(anon):zparseopts:2: bad option: x +>ret: 1, optv: , argv: -a -x -z +?(anon):zparseopts:2: bad option: x +>ret: 1, optv: , argv: -ax -z +?(anon):zparseopts:2: bad option: - +>ret: 1, optv: , argv: -a --x -z + + for 1 in '-a 1 2 3' '1 2 3'; do + () { + local -a optv=( -x -y -z ) + zparseopts -D -K -a optv - a b: c:- z + print -r - ret: $?, optv: $optv, argv: $argv + } $=1 + done +0:zparseopts -K -a +>ret: 0, optv: -a, argv: 1 2 3 +>ret: 0, optv: -x -y -z, argv: 1 2 3 + + for 1 in '-a 1 2 3' '1 2 3'; do + () { + local -A opts=( -b 1 -z '' ) + zparseopts -D -K -A opts - a b: c:- z + print -r - ret: $?, opts: "$( order_assoc opts )", argv: $argv + } $=1 + done +0:zparseopts -K -A +>ret: 0, opts: -a '' -b 1 -z '', argv: 1 2 3 +>ret: 0, opts: -b 1 -z '', argv: 1 2 3 + + () { + local -a optv + local -A opts + zparseopts -D -M -a optv -A opts - a:=-aaa -aaa: + print -r - ret: $?, optv: $optv, opts: "$( order_assoc opts )", argv: $argv + } --aaa foo -a bar 1 2 3 +0:zparseopts -M +>ret: 0, optv: --aaa bar, opts: --aaa bar, argv: 1 2 3 + + () { + local -a optv aa ab + zparseopts -a optv - a=aa b:=ab c:- z + print -r - ret: $?, optv: $optv, aa: $aa, ab: $ab, argv: $argv + } -ab1 -c -d +0:multiple arrays +>ret: 0, optv: -c-d, aa: -a, ab: -b 1, argv: -ab1 -c -d + + for 1 in '-a - -b - - -b' '-a -- -b -- -- -b' '-a 1 -b - - -b'; do + # -D alone strips - out + () { + local -a optv + zparseopts -D -F -a optv - a b: c:- z + print -r - '(-D )' ret: $?, optv: $optv, argv: $argv + } $=1 + # -D -E leaves - in + () { + local -a optv + zparseopts -D -E -F -a optv - a b: c:- z + print -r - '(-D -E)' ret: $?, optv: $optv, argv: $argv + } $=1 + done +0:-/-- handling +>(-D ) ret: 0, optv: -a, argv: -b - - -b +>(-D -E) ret: 0, optv: -a, argv: - -b - - -b +>(-D ) ret: 0, optv: -a, argv: -b -- -- -b +>(-D -E) ret: 0, optv: -a, argv: -- -b -- -- -b +>(-D ) ret: 0, optv: -a, argv: 1 -b - - -b +>(-D -E) ret: 0, optv: -a -b -, argv: 1 - -b + + # Escaping should always work, but it's optional on the first character + for specs in '\+ \: \= \\' '+ : = \'; do + () { + local -a optv + zparseopts -D -a optv - $=specs + print -r - ret: $?, optv: $optv, argv: $argv + } -+:=\\ 1 2 3 + done + () { + local -a optv + zparseopts -D -a optv - '-\:\:\::' + print -r - ret: $?, optv: $optv, argv: $argv + } --:::foo 1 2 3 +0:special characters in option names +>ret: 0, optv: -+ -: -= -\, argv: 1 2 3 +>ret: 0, optv: -+ -: -= -\, argv: 1 2 3 +>ret: 0, optv: --::: foo, argv: 1 2 3 + + for specs in '-foo: -foobar' '-foobar -foo:'; do + () { + local -a optv + zparseopts -a optv - $=specs + print -r - ret: $?, optv: $optv, argv: $argv + } --foobar 1 2 3 + done +0:overlapping option specs (scan order) +>ret: 0, optv: --foobar, argv: --foobar 1 2 3 +>ret: 0, optv: --foo bar, argv: --foobar 1 2 3 + + () { + local -a optv + zparseopts -a optv - a b: c:- z + print -r - ret: $?, optv: $optv, argv: $argv + } -ab1 -c +0:missing optarg +?(anon):zparseopts:2: missing argument for option: c +>ret: 1, optv: , argv: -ab1 -c diff --git a/Test/W01history.ztst b/Test/W01history.ztst index 6ef9b11cc..0b2f60d1e 100644 --- a/Test/W01history.ztst +++ b/Test/W01history.ztst @@ -58,3 +58,33 @@ *?* F:Check that a history bug introduced by workers/34160 is working again. # Discarded line of error output consumes prompts printed by "zsh -i". + + $ZTST_testdir/../Src/zsh -fis <<<' + echo /my/path/for/testing + echo !1:1:h10 + echo !1:1:h3 + echo !1:1:h2 + echo !1:1:h1 + echo !1:1:t10 + echo !1:1:t3 + echo !1:1:t2 + echo !1:1:t1 + echo !1:1:t3:h2' 2>/dev/null +0:Modifiers :h and :t with arguments +>/my/path/for/testing +>/my/path/for/testing +>/my/path +>/my +>/ +>/my/path/for/testing +>path/for/testing +>for/testing +>testing +>path/for + + $ZTST_testdir/../Src/zsh -fis <<<' + echo /my/path/for/testing + echo !1:1:P' 2>/dev/null +0:Modifier :P +>/my/path/for/testing +>/my/path/for/testing diff --git a/Test/X04zlehighlight.ztst b/Test/X04zlehighlight.ztst index 000949698..475a2e309 100644 --- a/Test/X04zlehighlight.ztst +++ b/Test/X04zlehighlight.ztst @@ -157,5 +157,3 @@ %clean zmodload -ui zsh/zpty - -# vim:ft=zsh diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst index b1c0e40e5..51f604bcf 100644 --- a/Test/Y01completion.ztst +++ b/Test/Y01completion.ztst @@ -1,6 +1,16 @@ # Tests for completion system. %prep + unset -m LC_\* + ZSH_TEST_LANG= + langs=(en_{US,GB}.{UTF-,utf}8 en.UTF-8 + $(locale -a 2>/dev/null | egrep 'utf8|UTF-8')) + for LANG in $langs; do + if [[ é = ? ]]; then + ZSH_TEST_LANG=$LANG + break; + fi + done if [[ $OSTYPE = cygwin ]]; then ZTST_unimplemented="the zsh/zpty module does not work on Cygwin" elif ( zmodload zsh/zpty 2>/dev/null ); then @@ -99,6 +109,7 @@ F:regression test workers/31611 comptesteval 'cd "A(B)/C"' comptest $'cd ../\t' } always { + comptesteval 'cd -' # Reset CWD rmdir 'A(B)/C' 'A(B)' } 0:directory name is not a glob qualifier @@ -106,6 +117,34 @@ F:regression test workers/31611 >line: {cd "A(B)/C/}{} >line: {cd ../C/}{} + comptesteval '_tst() { compset -p 1; _message "${(qq)IPREFIX} ${(qq)PREFIX}" }' + comptest $'tst .\t' +0:remove exact number of characters from a prefix +>line: {tst .}{} +>MESSAGE:{'.' ''} + + comptesteval '_tst() { compset -s 3; _message "${(qq)SUFFIX} ${(qq)ISUFFIX}" }' + comptest $'tst 123\eb\t' +0:remove exact number of characters from a suffix +>line: {tst }{123} +>MESSAGE:{'' '123'} + + comptesteval '_tst() { compset -p 2; compset -p 3;compset -s 2;compset -s 3; _message "${(qq)PREFIX} ${(qq)SUFFIX}" }' + comptest $'tst 12345678\e4\C-b\t' +0:try to remove excess characters from prefix and suffix +>line: {tst 1234}{5678} +>MESSAGE:{'34' '56'} + + if [[ -z $ZSH_TEST_LANG ]]; then + ZTST_skip="no UTF-8 locale for multibyte completion test" + else + comptesteval '_tst() { compset -p 1; _message "${(qq)IPREFIX} ${(qq)PREFIX}" }' + comptest $'tst €100\t' + fi +0:remove multibyte character from a prefix +>line: {tst €100}{} +>MESSAGE:{'€' '100'} + comptesteval "_tst() { compadd -U -s : -S / -I . word; compstate[to_end]= }" comptest $'tst .\C-b\t' 0:allow for suffixes when moving cursor to end of match (with ignored suffix) @@ -116,6 +155,76 @@ F:regression test workers/31611 0:allow for suffixes when moving cursor to end of match (without ignored suffix) >line: {tst word:/}{} +# Test for regression introduced by workers/41242, raised in workers/43842 + { + mkdir sortnobslash + touch sortnobslash/{'!foo','#foo','\foo','|foo','~foo',Afoo,bfoo} + comptesteval 'old_LC_ALL=$LC_ALL; LC_ALL=C' + comptest $': sortnobslash/\t' + } always { + comptesteval 'LC_ALL=$old_LC_ALL' + rm -rf sortnobslash + } +0:ignore backslashes when sorting completion matches +>line: {: sortnobslash/}{} +>DESCRIPTION:{file} +>FI:{\!foo} +>FI:{\#foo} +>FI:{Afoo} +>FI:{\\foo} +>FI:{bfoo} +>FI:{\|foo} +>FI:{\~foo} + + comptesteval "_tst() { compadd -onum,rev -J versions r1.10 r1.1 r1.2 r2.3 r2.34 }" + comptest $'tst r\t' +0:reverse numeric sorting of matches +>line: {tst r}{} +>NO:{r2.34} +>NO:{r2.3} +>NO:{r1.10} +>NO:{r1.2} +>NO:{r1.1} + + comptesteval "_tst() { local expl; _wanted times expl time compadd -o match r1.10 r1.2 r2.3 r2.34 }" + comptesteval "zstyle ':completion:*:tst:*' sort reverse numeric" + comptest $'tst r\t' +0:reverse numeric sorting of matches via a style +>line: {tst r}{} +>DESCRIPTION:{time} +>NO:{r2.34} +>NO:{r2.3} +>NO:{r1.10} +>NO:{r1.2} + + comptesteval "_tst() { local disp=(a b c); compadd -o -J letters -d disp 3 2 1 }" + comptest $'tst \t' +0:sort in match rather than display name order +>line: {tst }{} +>NO:{c} +>NO:{b} +>NO:{a} + + comptesteval "_tst() { local expl; _wanted times expl time compadd 3am 12pm 3pm 10pm }" + comptesteval "zstyle ':completion:*:tst:*' sort false" + comptest $'tst \t' +0:sorting disabled via the sort style +>line: {tst }{} +>DESCRIPTION:{time} +>NO:{3am} +>NO:{12pm} +>NO:{3pm} +>NO:{10pm} + + comptest $'a=() b=(\t' +0:multiple envarrays +>line: {a=() b=(}{} +>DESCRIPTION:{file} +>DI:{dir1} +>DI:{dir2} +>FI:{file1} +>FI:{file2} + %clean zmodload -ui zsh/zpty diff --git a/Test/list-XFails b/Test/list-XFails new file mode 100755 index 000000000..8d94a3d04 --- /dev/null +++ b/Test/list-XFails @@ -0,0 +1,5 @@ +#!/bin/sh +# This script lists tests that are currently expected to fail. (I.e., tests +# for bugs that haven't been fixed yet.) + +grep --color -E -n '^[-0-9.dDqf]*f[-0-9.dDqf]*:' -- "$(dirname -- "$0")"/*.ztst diff --git a/Test/ztst.zsh b/Test/ztst.zsh index d835e0edb..375efd16c 100755 --- a/Test/ztst.zsh +++ b/Test/ztst.zsh @@ -322,7 +322,7 @@ ZTST_diff() { diff_lines2=("${(f@)$(<$argv[-1])}") if (( ${#diff_lines1} != ${#diff_lines2} )); then failed=1 - print -r "Pattern match filead, line mismatch (${#diff_lines1}/${#diff_lines2}):" + print -r "Pattern match failed, line mismatch (${#diff_lines1}/${#diff_lines2}):" else for (( i = 1; i <= ${#diff_lines1}; i++ )); do if [[ ${diff_lines2[i]} != ${~diff_lines1[i]} ]]; then @@ -366,6 +366,7 @@ ZTST_test() { local last match mbegin mend found substlines local diff_out diff_err local ZTST_skip + integer expected_to_fail while true; do rm -f $ZTST_in $ZTST_out $ZTST_err @@ -460,8 +461,21 @@ $ZTST_curline" fi fi + if [[ $ZTST_flags = *f* ]]; then + expected_to_fail=1 + ZTST_xfail_diff() { ZTST_diff "$@" > /dev/null } + ZTST_diff=ZTST_xfail_diff + else + expected_to_fail=0 + ZTST_diff=ZTST_diff + fi + # First check we got the right status, if specified. if [[ $ZTST_xstatus != - && $ZTST_xstatus != $ZTST_status ]]; then + if (( expected_to_fail )); then + ZTST_verbose 1 "Test failed, as expected." + continue + fi ZTST_testfailed "bad status $ZTST_status, expected $ZTST_xstatus from: $ZTST_code${$(<$ZTST_terr):+ Error output: @@ -480,7 +494,11 @@ $(<$ZTST_terr)" rm -rf $ZTST_out print -r -- "${(e)substlines}" >$ZTST_out fi - if [[ $ZTST_flags != *d* ]] && ! ZTST_diff $diff_out -u $ZTST_out $ZTST_tout; then + if [[ $ZTST_flags != *d* ]] && ! $ZTST_diff $diff_out -u $ZTST_out $ZTST_tout; then + if (( expected_to_fail )); then + ZTST_verbose 1 "Test failed, as expected." + continue + fi ZTST_testfailed "output differs from expected as shown above for: $ZTST_code${$(<$ZTST_terr):+ Error output: @@ -492,11 +510,19 @@ $(<$ZTST_terr)}" rm -rf $ZTST_err print -r -- "${(e)substlines}" >$ZTST_err fi - if [[ $ZTST_flags != *D* ]] && ! ZTST_diff $diff_err -u $ZTST_err $ZTST_terr; then + if [[ $ZTST_flags != *D* ]] && ! $ZTST_diff $diff_err -u $ZTST_err $ZTST_terr; then + if (( expected_to_fail )); then + ZTST_verbose 1 "Test failed, as expected." + continue + fi ZTST_testfailed "error output differs from expected as shown above for: $ZTST_code" return 1 fi + if (( expected_to_fail )); then + ZTST_testfailed "test was expected to fail, but passed." + return 1 + fi fi ZTST_verbose 1 "Test successful." [[ -n $last ]] && break diff --git a/Util/ztst-ftplugin.vim b/Util/ztst-ftplugin.vim new file mode 100644 index 000000000..60f2b526f --- /dev/null +++ b/Util/ztst-ftplugin.vim @@ -0,0 +1,29 @@ +" ztst filetype plugin + +" Only do this when not done yet for this buffer +if exists("b:did_ftplugin") + finish +endif + +let s:cpo_save = &cpo +set cpo&vim + +" Inherit zsh.vim +runtime! ftplugin/zsh.vim + +let b:undo_ftplugin .= "| setl fo< comments< commentstring<" + +" Set 'formatoptions' to break comment lines but not other lines, +" and insert the comment leader when hitting <CR> or using "o". +setlocal fo-=t fo+=croql + +" Set 'comments' to format expected output/errput lines +setlocal comments+=:*>,:>,:*?,:?,:F: + +" Format comments to be up to 78 characters long +if &textwidth == 0 + setlocal textwidth=78 +endif + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/Util/ztst-syntax.vim b/Util/ztst-syntax.vim new file mode 100644 index 000000000..a39fe3fbb --- /dev/null +++ b/Util/ztst-syntax.vim @@ -0,0 +1,101 @@ +"" A Vim syntax highlighting file for Test/*.ztst +" +" See ../Util/zyodl.vim for installation instructions. +" Also, it's recommended to 'setlocal conceallevel=3 concealcursor=nc'. +" +" See B01cd.ztst for cases we cover + +" TODO: Some zsh syntax isn't highlighted, e.g., «{ cd $0 }» doesn't highlight either 'cd' or '$0' +" Apparently because the $VIMRUNTIME/syntax/zsh.vim zshBrackets group is defined as 'contains=TOP'? +" https://bugs.debian.org/947120 +" TODO: ZTST_unimplemented ZTST_skip aren't recognized everywhere +" I haven't found yet a legitimate use where they aren't highlighted, but +" they aren't highlighted in theoretical cases such as (( ++ZTST_skip )). +" (This example is theoretical because those variables are string-typed.) + +"" Boilerplate: +if exists("b:current_syntax") + finish +endif +let s:cpo_save = &cpo +set cpo&vim + +"" Syntax groups: +syn clear + +syn include @zsh syntax/zsh.vim + +" Note that we don't do /^\s\zs.*/ here. If we did that, lines that start +" with " #" (a space and a hash sign) would not be highlighted as comments, +" because zshComment's patterns won't match unless the '#' is preceded by +" a space or start-of-line. See: +" +" https://github.com/chrisbra/vim-zsh/issues/21#issuecomment-577738791 +syn match ztstPayload /^\s.*/ contains=@zsh + +syn match ztstExitCode /^\d\+\|^-/ nextgroup=ztstFlags +syn match ztstFlags /[.dDqf]*:/ contained nextgroup=ztstTestName contains=ztstColon +syn match ztstColon /:/ contained +syn region ztstTestName start=// end=/$/ contained + +syn match ztstInputMarker /^</ nextgroup=ztstInput +syn region ztstInput start=// end=/$/ contained + +syn match ztstOutputPattern /^[*]>/ nextgroup=ztstOutput contains=ztstOutputPatternSigil,ztstOutputPatternMarker +syn match ztstOutputPatternSigil /[*]/ contained +syn match ztstOutputPatternMarker /[>]/ contained conceal +syn match ztstOutputLiteral /^>/ nextgroup=ztstOutput +syn region ztstOutput start=// end=/$/ contained + +syn match ztstErrputPattern /^[*][?]/ nextgroup=ztstErrput contains=ztstErrputPatternSigil,ztstErrputPatternMarker +syn match ztstErrputPatternSigil /[*]/ contained +syn match ztstErrputPatternMarker /[?]/ contained conceal +syn match ztstErrputLiteral /^[?]/ nextgroup=ztstErrput +syn region ztstErrput start=// end=/$/ contained + +syn match ztstFrequentExplanationMarker /^F:/ nextgroup=ztstFrequentExplanation +syn region ztstFrequentExplanation start=// end=/$/ contained + +syn match ztstDirective /^%.*/ + +syn match ztstComment /^#.*/ + +" Highlight those variables which are /de jure/ or /de facto/ APIs of the test +" harness to the test files. +syn keyword ztstSpecialVariable ZTST_unimplemented ZTST_skip ZTST_testdir ZTST_fd ZTST_srcdir containedin=@zsh + +"" Sync +" The following is sufficient for our modest line-based format, and helps +" sidestep problems resulting from test cases that use syntax constructs +" that confuse us and/or syntax/zsh.vim. If we outgrow it, we should sync +" on empty lines instead. +" +" If you run into syntax highlighting issues, just scroll the line that throws +" the syntax highlighting off off the top of the screen. +syn sync maxlines=1 + +"" Highlight groups: +hi def link ztstExitCode Number +hi def link ztstFlags Normal +hi def link ztstColon Ignore +hi def link ztstTestName Title +hi def link ztstInput Normal +hi def link ztstInputMarker Ignore +hi def link ztstOutput String +hi def link ztstOutputPatternSigil Type +hi def link ztstOutputPatternMarker Ignore +hi def link ztstOutputLiteral Ignore +hi def link ztstErrput Identifier +hi def link ztstErrputPatternSigil Type +hi def link ztstErrputPatternMarker Ignore +hi def link ztstErrputLiteral Ignore +hi def link ztstDirective Statement +hi def link ztstComment Comment +hi def link ztstFrequentExplanation PreProc +hi def link ztstFrequentExplanationMarker Ignore +hi def link ztstSpecialVariable Underlined + +"" Boilerplate: +let b:current_syntax = "ztst" +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/Util/zyodl.vim b/Util/zyodl.vim index d0d3cf54f..7acd1dfaf 100644 --- a/Util/zyodl.vim +++ b/Util/zyodl.vim @@ -21,7 +21,10 @@ " xitem(foo) " item(foo)(foo) " sitem(foo)(foo foo) +" COMMENT(foo var(foo) foo) +" comment(foo) " example(print *.c+LPAR()#q:s/#%+LPAR()#b+RPAR()s+LPAR()*+RPAR().c/'S${match[1]}.C'/+RPAR()) +" example(zargs -- **/*(.) -- ls -l) " ifzman(zmanref(zshmisc))ifnzman(noderef(Redirection)) " LPAR()foo 42 foo+RPAR() " chapter(foo (foo) foo) @@ -35,6 +38,8 @@ if exists("b:current_syntax") finish endif +let s:cpo_save = &cpo +set cpo&vim "" Syntax groups: syn clear @@ -48,7 +53,10 @@ syn match zyodlSpecial "+\?\<\(LPAR\|RPAR\|PLUS\)()" syn match zyodlNumber "\d\+" syn region zyodlItem start="\<xitem(" end=")" contains=zyodlSpecial,@zyodlInline syn region zyodlItem start="\<item(" end=")" contains=zyodlSpecial,@zyodlInline -syn region zyodlExample start="\<example(" end=")" contains=zyodlSpecial +syn region zyodlExample start="\<example(" end=")" contains=zyodlSpecial,zyodlParenthetical +syn region zyodlComment start="\<COMMENT(" end=")" contains=zyodlSpecial,@zyodlInline,zyodlParenthetical +" comment that gets output in generated texinfo/roff source +syn region zyodlComment start="\<comment(" end=")" syn region zyodlTitle start="\<\(chapter\|subsect\|sect\)(" end=")" contains=zyodlSpecial,@zyodlInline,zyodlParenthetical syn match zyodlTitle "^texinode(.*$" syn region zyodlParenthetical start="\w\@<!(" end=")" transparent contained contains=zyodlParenthetical @@ -68,11 +76,12 @@ hi def link zyodlVar Identifier " Not ':hi def link zyodlBold Bold' since there's no such group. hi def zyodlBold gui=bold cterm=bold hi def link zyodlEmph Type -hi def link zyodlIndex Comment +hi def link zyodlIndex PreProc hi def link zyodlSpecial Special hi def link zyodlNumber Number hi def link zyodlItem Keyword hi def link zyodlExample String +hi def link zyodlComment Comment hi def link zyodlTitle Title hi def link zyodlCond Conditional hi def link zyodlRef Include @@ -80,4 +89,5 @@ hi def link zyodlSItemArg1 Macro hi def link zyodlSItemArg2 Underlined let b:current_syntax = "zyodl" - +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/config.guess b/config.guess index 883a6713b..ae713942d 100755 --- a/config.guess +++ b/config.guess @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2018-05-19' +timestamp='2019-05-28' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -50,7 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright 1992-2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -84,8 +84,6 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -96,34 +94,38 @@ trap 'exit 1' 1 2 15 # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; -: ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || - { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || - { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || - { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; -dummy=$tmp/dummy ; -tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in - ,,) echo "int x;" > "$dummy.c" ; - for c in cc gcc c89 c99 ; do - if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } + dummy=$tmp/dummy + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi @@ -138,7 +140,7 @@ Linux|GNU|GNU/*) # We could probably try harder. LIBC=gnu - eval "$set_cc_for_build" + set_cc_for_build cat <<-EOF > "$dummy.c" #include <features.h> #if defined(__UCLIBC__) @@ -199,7 +201,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval "$set_cc_for_build" + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -389,7 +391,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval "$set_cc_for_build" + set_cc_for_build SUN_ARCH=i386 # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. @@ -482,7 +484,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include <stdio.h> /* for printf() prototype */ @@ -579,7 +581,7 @@ EOF exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> @@ -660,7 +662,7 @@ EOF esac fi if [ "$HP_ARCH" = "" ]; then - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE @@ -700,7 +702,7 @@ EOF esac if [ "$HP_ARCH" = hppa2.0w ] then - eval "$set_cc_for_build" + set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -726,7 +728,7 @@ EOF echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include <unistd.h> int @@ -840,6 +842,17 @@ EOF *:BSD/OS:*:*) echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=`uname -p` + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf + fi + exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case "$UNAME_PROCESSOR" in @@ -881,7 +894,7 @@ EOF echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin + echo x86_64-pc-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" @@ -894,8 +907,8 @@ EOF # other systems with GNU libc and userland echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; - i*86:Minix:*:*) - echo "$UNAME_MACHINE"-pc-minix + *:Minix:*:*) + echo "$UNAME_MACHINE"-unknown-minix exit ;; aarch64:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" @@ -922,7 +935,7 @@ EOF echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval "$set_cc_for_build" + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then @@ -971,23 +984,51 @@ EOF echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval "$set_cc_for_build" + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #endif #endif EOF - eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" - test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" @@ -1100,7 +1141,7 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then @@ -1284,38 +1325,39 @@ EOF echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - eval "$set_cc_for_build" - if test "$UNAME_PROCESSOR" = unknown ; then - UNAME_PROCESSOR=powerpc + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build fi - if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - case $UNAME_PROCESSOR in - i386) UNAME_PROCESSOR=x86_64 ;; - powerpc) UNAME_PROCESSOR=powerpc64 ;; - esac - fi - # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc - if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_PPC >/dev/null - then - UNAME_PROCESSOR=powerpc - fi + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc fi elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; @@ -1358,6 +1400,7 @@ EOF # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. + # shellcheck disable=SC2154 if test "$cputype" = 386; then UNAME_MACHINE=i386 else @@ -1414,8 +1457,148 @@ EOF amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" + exit ;; esac +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" <<EOF +#ifdef _SEQUENT_ +#include <sys/types.h> +#include <sys/utsname.h> +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include <signal.h> +#if defined(_SIZE_T_) || defined(SIGLOST) +#include <sys/utsname.h> +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include <sys/param.h> + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include <sys/param.h> +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + echo "$0: unable to guess system type" >&2 case "$UNAME_MACHINE:$UNAME_SYSTEM" in diff --git a/config.sub b/config.sub index d1f5b5490..5b158ac41 100755 --- a/config.sub +++ b/config.sub @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright 1992-2019 Free Software Foundation, Inc. -timestamp='2018-05-24' +timestamp='2019-05-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -67,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright 1992-2019 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -89,7 +89,7 @@ while test $# -gt 0 ; do - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) @@ -111,7 +111,8 @@ case $# in esac # Split fields of configuration type -IFS="-" read -r field1 field2 field3 field4 <<EOF +# shellcheck disable=SC2162 +IFS="-" read field1 field2 field3 field4 <<EOF $1 EOF @@ -149,29 +150,39 @@ case $1 in esac ;; *-*) - # Second component is usually, but not always the OS - case $field2 in - # Prevent following clause from handling this valid os - sun*os*) - basic_machine=$field1 - os=$field2 - ;; - # Manufacturers - dec* | mips* | sequent* | encore* | pc532* | sgi* | sony* \ - | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ - | unicom* | ibm* | next | hp | isi* | apollo | altos* \ - | convergent* | ncr* | news | 32* | 3600* | 3100* | hitachi* \ - | c[123]* | convex* | sun | crds | omron* | dg | ultra | tti* \ - | harris | dolphin | highlevel | gould | cbm | ns | masscomp \ - | apple | axis | knuth | cray | microblaze* \ - | sim | cisco | oki | wec | wrs | winbond) - basic_machine=$field1-$field2 + # A lone config we happen to match not fitting any pattern + case $field1-$field2 in + decstation-3100) + basic_machine=mips-dec os= ;; - *) - basic_machine=$field1 - os=$field2 - ;; + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* \ + | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \ + | ultra | tti* | harris | dolphin | highlevel | gould \ + | cbm | ns | masscomp | apple | axis | knuth | cray \ + | microblaze* | sim | cisco \ + | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + os= + ;; + *) + basic_machine=$field1 + os=$field2 + ;; + esac + ;; esac ;; *) @@ -190,6 +201,14 @@ case $1 in basic_machine=m68010-adobe os=scout ;; + alliant) + basic_machine=fx80-alliant + os= + ;; + altos | altos3068) + basic_machine=m68k-altos + os= + ;; am29k) basic_machine=a29k-none os=bsd @@ -198,6 +217,10 @@ case $1 in basic_machine=580-amdahl os=sysv ;; + amiga) + basic_machine=m68k-unknown + os= + ;; amigaos | amigados) basic_machine=m68k-unknown os=amigaos @@ -234,13 +257,41 @@ case $1 in basic_machine=arm-unknown os=cegcc ;; + convex-c1) + basic_machine=c1-convex + os=bsd + ;; + convex-c2) + basic_machine=c2-convex + os=bsd + ;; + convex-c32) + basic_machine=c32-convex + os=bsd + ;; + convex-c34) + basic_machine=c34-convex + os=bsd + ;; + convex-c38) + basic_machine=c38-convex + os=bsd + ;; cray) basic_machine=j90-cray os=unicos ;; - craynv) - basic_machine=craynv-cray - os=unicosmp + crds | unos) + basic_machine=m68k-crds + os= + ;; + da30) + basic_machine=m68k-da30 + os= + ;; + decstation | pmax | pmin | dec3100 | decstatn) + basic_machine=mips-dec + os= ;; delta88) basic_machine=m88k-motorola @@ -286,6 +337,9 @@ case $1 in basic_machine=m88k-harris os=sysv3 ;; + hp300) + basic_machine=m68k-hp + ;; hp300bsd) basic_machine=m68k-hp os=bsd @@ -307,7 +361,7 @@ case $1 in os=mach ;; vsta) - basic_machine=i386-unknown + basic_machine=i386-pc os=vsta ;; isi68 | isi) @@ -371,7 +425,7 @@ case $1 in os=sysv4 ;; netbsd386) - basic_machine=i386-unknown + basic_machine=i386-pc os=netbsd ;; netwinder) @@ -454,14 +508,26 @@ case $1 in basic_machine=mips-sei os=seiux ;; + sequent) + basic_machine=i386-sequent + os= + ;; sps7) basic_machine=m68k-bull os=sysv2 ;; + st2000) + basic_machine=m68k-tandem + os= + ;; stratus) basic_machine=i860-stratus os=sysv4 ;; + sun2) + basic_machine=m68000-sun + os= + ;; sun2os3) basic_machine=m68000-sun os=sunos3 @@ -470,6 +536,10 @@ case $1 in basic_machine=m68000-sun os=sunos4 ;; + sun3) + basic_machine=m68k-sun + os= + ;; sun3os3) basic_machine=m68k-sun os=sunos3 @@ -478,6 +548,10 @@ case $1 in basic_machine=m68k-sun os=sunos4 ;; + sun4) + basic_machine=sparc-sun + os= + ;; sun4os3) basic_machine=sparc-sun os=sunos3 @@ -490,6 +564,10 @@ case $1 in basic_machine=sparc-sun os=solaris2 ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + os= + ;; sv1) basic_machine=sv1-cray os=unicos @@ -562,417 +640,162 @@ case $1 in ;; esac -# Decode aliases for certain CPU-COMPANY combinations. +# Decode 1-component or ad-hoc basic machines case $basic_machine in - # Recognize the basic CPU types without company name. - # Some are omitted here because they have special meanings below. - 1750a | 580 \ - | a29k \ - | aarch64 | aarch64_be \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ - | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ - | bfin \ - | c4x | c8051 | clipper | csky \ - | d10v | d30v | dlx | dsp16xx \ - | e2k | epiphany \ - | fido | fr30 | frv | ft32 \ - | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | hexagon \ - | i370 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ - | k1om \ - | le32 | le64 \ - | lm32 \ - | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ - | mips | mipsbe | mipseb | mipsel | mipsle \ - | mips16 \ - | mips64 | mips64el \ - | mips64octeon | mips64octeonel \ - | mips64orion | mips64orionel \ - | mips64r5900 | mips64r5900el \ - | mips64vr | mips64vrel \ - | mips64vr4100 | mips64vr4100el \ - | mips64vr4300 | mips64vr4300el \ - | mips64vr5000 | mips64vr5000el \ - | mips64vr5900 | mips64vr5900el \ - | mipsisa32 | mipsisa32el \ - | mipsisa32r2 | mipsisa32r2el \ - | mipsisa32r6 | mipsisa32r6el \ - | mipsisa64 | mipsisa64el \ - | mipsisa64r2 | mipsisa64r2el \ - | mipsisa64r6 | mipsisa64r6el \ - | mipsisa64sb1 | mipsisa64sb1el \ - | mipsisa64sr71k | mipsisa64sr71kel \ - | mipsr5900 | mipsr5900el \ - | mipstx39 | mipstx39el \ - | mn10200 | mn10300 \ - | moxie \ - | mt \ - | msp430 \ - | nds32 | nds32le | nds32be \ - | nfp \ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 | or1k | or1knd | or32 \ - | pdp10 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pru \ - | pyramid \ - | riscv32 | riscv64 \ - | rl78 | rx \ - | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ - | sh64 | sh64le \ - | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu \ - | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ - | ubicom32 \ - | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ - | visium \ - | wasm32 \ - | x86 | xc16x | xstormy16 | xtensa \ - | z8k | z80) - basic_machine=$basic_machine-unknown - ;; - c54x) - basic_machine=tic54x-unknown - ;; - c55x) - basic_machine=tic55x-unknown - ;; - c6x) - basic_machine=tic6x-unknown - ;; - leon|leon[3-9]) - basic_machine=sparc-$basic_machine - ;; - m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) - basic_machine=$basic_machine-unknown - os=${os:-none} - ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) + # Here we handle the default manufacturer of certain CPU types. It is in + # some cases the only manufacturer, in others, it is the most popular. + w89k) + cpu=hppa1.1 + vendor=winbond ;; - m9s12z | m68hcs12z | hcs12z | s12z) - basic_machine=s12z-unknown - os=${os:-none} + op50n) + cpu=hppa1.1 + vendor=oki ;; - ms1) - basic_machine=mt-unknown + op60c) + cpu=hppa1.1 + vendor=oki ;; - strongarm | thumb | xscale) - basic_machine=arm-unknown + ibm*) + cpu=i370 + vendor=ibm ;; - xgate) - basic_machine=$basic_machine-unknown - os=${os:-none} + orion105) + cpu=clipper + vendor=highlevel ;; - xscaleeb) - basic_machine=armeb-unknown + mac | mpw | mac-mpw) + cpu=m68k + vendor=apple ;; - - xscaleel) - basic_machine=armel-unknown + pmac | pmac-mpw) + cpu=powerpc + vendor=apple ;; - # We use `pc' rather than `unknown' - # because (1) that's what they normally are, and - # (2) the word "unknown" tends to confuse beginning users. - i*86 | x86_64) - basic_machine=$basic_machine-pc - ;; - # Recognize the basic CPU types with company name. - 580-* \ - | a29k-* \ - | aarch64-* | aarch64_be-* \ - | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ - | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ - | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* | avr32-* \ - | ba-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | e2k-* | elxsi-* \ - | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ - | h8300-* | h8500-* \ - | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | hexagon-* \ - | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ - | ip2k-* | iq2000-* \ - | k1om-* \ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ - | mips16-* \ - | mips64-* | mips64el-* \ - | mips64octeon-* | mips64octeonel-* \ - | mips64orion-* | mips64orionel-* \ - | mips64r5900-* | mips64r5900el-* \ - | mips64vr-* | mips64vrel-* \ - | mips64vr4100-* | mips64vr4100el-* \ - | mips64vr4300-* | mips64vr4300el-* \ - | mips64vr5000-* | mips64vr5000el-* \ - | mips64vr5900-* | mips64vr5900el-* \ - | mipsisa32-* | mipsisa32el-* \ - | mipsisa32r2-* | mipsisa32r2el-* \ - | mipsisa32r6-* | mipsisa32r6el-* \ - | mipsisa64-* | mipsisa64el-* \ - | mipsisa64r2-* | mipsisa64r2el-* \ - | mipsisa64r6-* | mipsisa64r6el-* \ - | mipsisa64sb1-* | mipsisa64sb1el-* \ - | mipsisa64sr71k-* | mipsisa64sr71kel-* \ - | mipsr5900-* | mipsr5900el-* \ - | mipstx39-* | mipstx39el-* \ - | mmix-* \ - | mt-* \ - | msp430-* \ - | nds32-* | nds32le-* | nds32be-* \ - | nfp-* \ - | nios-* | nios2-* | nios2eb-* | nios2el-* \ - | none-* | np1-* | ns16k-* | ns32k-* \ - | open8-* \ - | or1k*-* \ - | orion-* \ - | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ - | pru-* \ - | pyramid-* \ - | riscv32-* | riscv64-* \ - | rl78-* | romp-* | rs6000-* | rx-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ - | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ - | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ - | tahoe-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ - | tile*-* \ - | tron-* \ - | ubicom32-* \ - | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ - | vax-* \ - | visium-* \ - | wasm32-* \ - | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* \ - | xstormy16-* | xtensa*-* \ - | ymp-* \ - | z8k-* | z80-*) - ;; - # Recognize the basic CPU types without company name, with glob match. - xtensa*) - basic_machine=$basic_machine-unknown - ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) - basic_machine=m68000-att + cpu=m68000 + vendor=att ;; 3b*) - basic_machine=we32k-att - ;; - abacus) - basic_machine=abacus-unknown - ;; - alliant | fx80) - basic_machine=fx80-alliant - ;; - altos | altos3068) - basic_machine=m68k-altos - ;; - amd64) - basic_machine=x86_64-pc - ;; - amd64-*) - basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - amiga | amiga-*) - basic_machine=m68k-unknown - ;; - asmjs) - basic_machine=asmjs-unknown - ;; - blackfin-*) - basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=linux + cpu=we32k + vendor=att ;; bluegene*) - basic_machine=powerpc-ibm + cpu=powerpc + vendor=ibm os=cnk ;; - c54x-*) - basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c55x-*) - basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c6x-*) - basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` - ;; - c90) - basic_machine=c90-cray - os=${os:-unicos} - ;; - convex-c1) - basic_machine=c1-convex - os=bsd - ;; - convex-c2) - basic_machine=c2-convex - os=bsd - ;; - convex-c32) - basic_machine=c32-convex - os=bsd - ;; - convex-c34) - basic_machine=c34-convex - os=bsd - ;; - convex-c38) - basic_machine=c38-convex - os=bsd - ;; - cr16 | cr16-*) - basic_machine=cr16-unknown - os=${os:-elf} - ;; - crds | unos) - basic_machine=m68k-crds - ;; - crisv32 | crisv32-* | etraxfs*) - basic_machine=crisv32-axis - ;; - cris | cris-* | etrax*) - basic_machine=cris-axis - ;; - crx) - basic_machine=crx-unknown - os=${os:-elf} - ;; - da30 | da30-*) - basic_machine=m68k-da30 - ;; - decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) - basic_machine=mips-dec - ;; decsystem10* | dec10*) - basic_machine=pdp10-dec + cpu=pdp10 + vendor=dec os=tops10 ;; decsystem20* | dec20*) - basic_machine=pdp10-dec + cpu=pdp10 + vendor=dec os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) - basic_machine=m68k-motorola - ;; - dpx20 | dpx20-*) - basic_machine=rs6000-bull - os=${os:-bosx} + cpu=m68k + vendor=motorola ;; dpx2*) - basic_machine=m68k-bull + cpu=m68k + vendor=bull os=sysv3 ;; - e500v[12]) - basic_machine=powerpc-unknown - os=$os"spe" - ;; - e500v[12]-*) - basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=$os"spe" - ;; encore | umax | mmax) - basic_machine=ns32k-encore + cpu=ns32k + vendor=encore ;; elxsi) - basic_machine=elxsi-elxsi + cpu=elxsi + vendor=elxsi os=${os:-bsd} ;; fx2800) - basic_machine=i860-alliant + cpu=i860 + vendor=alliant ;; genix) - basic_machine=ns32k-ns + cpu=ns32k + vendor=ns ;; h3050r* | hiux*) - basic_machine=hppa1.1-hitachi + cpu=hppa1.1 + vendor=hitachi os=hiuxwe2 ;; - hp300-*) - basic_machine=m68k-hp - ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) - basic_machine=m68000-hp + cpu=m68000 + vendor=hp ;; hp9k3[2-9][0-9]) - basic_machine=m68k-hp + cpu=m68k + vendor=hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) - basic_machine=hppa1.0-hp + cpu=hppa1.0 + vendor=hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) - basic_machine=hppa1.1-hp + cpu=hppa1.1 + vendor=hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) - basic_machine=hppa1.0-hp - ;; - i370-ibm* | ibm*) - basic_machine=i370-ibm + cpu=hppa1.0 + vendor=hp ;; i*86v32) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc os=sysv32 ;; i*86v4*) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc os=sysv4 ;; i*86v) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc os=sysv ;; i*86sol2) - basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + cpu=`echo "$1" | sed -e 's/86.*/86/'` + vendor=pc os=solaris2 ;; j90 | j90-cray) - basic_machine=j90-cray + cpu=j90 + vendor=cray os=${os:-unicos} ;; iris | iris4d) - basic_machine=mips-sgi + cpu=mips + vendor=sgi case $os in irix*) ;; @@ -981,40 +804,27 @@ case $basic_machine in ;; esac ;; - leon-*|leon[3-9]-*) - basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` - ;; - m68knommu-*) - basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=linux - ;; - microblaze*) - basic_machine=microblaze-xilinx - ;; miniframe) - basic_machine=m68000-convergent + cpu=m68000 + vendor=convergent ;; *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) - basic_machine=m68k-atari + cpu=m68k + vendor=atari os=mint ;; - mips3*-*) - basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` - ;; - mips3*) - basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown - ;; - ms1-*) - basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` - ;; news-3600 | risc-news) - basic_machine=mips-sony + cpu=mips + vendor=sony os=newsos ;; next | m*-next) - basic_machine=m68k-next + cpu=m68k + vendor=next case $os in - nextstep* ) + openstep*) + ;; + nextstep*) ;; ns2*) os=nextstep2 @@ -1025,260 +835,442 @@ case $basic_machine in esac ;; np1) - basic_machine=np1-gould + cpu=np1 + vendor=gould ;; - neo-tandem) - basic_machine=neo-tandem + op50n-* | op60c-*) + cpu=hppa1.1 + vendor=oki + os=proelf ;; - nse-tandem) - basic_machine=nse-tandem + pa-hitachi) + cpu=hppa1.1 + vendor=hitachi + os=hiuxwe2 ;; - nsr-tandem) - basic_machine=nsr-tandem + pbd) + cpu=sparc + vendor=tti ;; - nsv-tandem) - basic_machine=nsv-tandem + pbb) + cpu=m68k + vendor=tti ;; - nsx-tandem) - basic_machine=nsx-tandem + pc532) + cpu=ns32k + vendor=pc532 ;; - op50n-* | op60c-*) - basic_machine=hppa1.1-oki - os=proelf + pn) + cpu=pn + vendor=gould ;; - openrisc | openrisc-*) - basic_machine=or32-unknown + power) + cpu=power + vendor=ibm ;; - pa-hitachi) - basic_machine=hppa1.1-hitachi - os=hiuxwe2 + ps2) + cpu=i386 + vendor=ibm ;; - parisc-*) - basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` - os=linux + rm[46]00) + cpu=mips + vendor=siemens ;; - pbd) - basic_machine=sparc-tti + rtpc | rtpc-*) + cpu=romp + vendor=ibm ;; - pbb) - basic_machine=m68k-tti + sde) + cpu=mipsisa32 + vendor=sde + os=${os:-elf} ;; - pc532 | pc532-*) - basic_machine=ns32k-pc532 + simso-wrs) + cpu=sparclite + vendor=wrs + os=vxworks ;; - pc98) - basic_machine=i386-pc + tower | tower-32) + cpu=m68k + vendor=ncr ;; - pc98-*) - basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` + vpp*|vx|vx-*) + cpu=f301 + vendor=fujitsu + ;; + w65) + cpu=w65 + vendor=wdc + ;; + w89k-*) + cpu=hppa1.1 + vendor=winbond + os=proelf ;; - pentium | p5 | k5 | k6 | nexgen | viac3) - basic_machine=i586-pc + none) + cpu=none + vendor=none ;; - pentiumpro | p6 | 6x86 | athlon | athlon_*) - basic_machine=i686-pc + leon|leon[3-9]) + cpu=sparc + vendor=$basic_machine ;; - pentiumii | pentium2 | pentiumiii | pentium3) - basic_machine=i686-pc + leon-*|leon[3-9]-*) + cpu=sparc + vendor=`echo "$basic_machine" | sed 's/-.*//'` ;; - pentium4) - basic_machine=i786-pc + + *-*) + # shellcheck disable=SC2162 + IFS="-" read cpu vendor <<EOF +$basic_machine +EOF ;; - pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + cpu=$basic_machine + vendor=pc ;; - pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + # These rules are duplicated from below for sake of the special case above; + # i.e. things that normalized to x86 arches should also default to "pc" + pc98) + cpu=i386 + vendor=pc ;; - pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` + x64 | amd64) + cpu=x86_64 + vendor=pc ;; - pentium4-*) - basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` + # Recognize the basic CPU types without company name. + *) + cpu=$basic_machine + vendor=unknown ;; - pn) - basic_machine=pn-gould +esac + +unset -v basic_machine + +# Decode basic machines in the full and proper CPU-Company form. +case $cpu-$vendor in + # Here we handle the default manufacturer of certain CPU types in canonical form. It is in + # some cases the only manufacturer, in others, it is the most popular. + craynv-unknown) + vendor=cray + os=${os:-unicosmp} + ;; + c90-unknown | c90-cray) + vendor=cray + os=${os:-unicos} ;; - power) basic_machine=power-ibm + fx80-unknown) + vendor=alliant ;; - ppc | ppcbe) basic_machine=powerpc-unknown + romp-unknown) + vendor=ibm ;; - ppc-* | ppcbe-*) - basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + mmix-unknown) + vendor=knuth ;; - ppcle | powerpclittle) - basic_machine=powerpcle-unknown + microblaze-unknown | microblazeel-unknown) + vendor=xilinx ;; - ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` + rs6000-unknown) + vendor=ibm ;; - ppc64) basic_machine=powerpc64-unknown + vax-unknown) + vendor=dec ;; - ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` + pdp11-unknown) + vendor=dec ;; - ppc64le | powerpc64little) - basic_machine=powerpc64le-unknown + we32k-unknown) + vendor=att ;; - ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` + cydra-unknown) + vendor=cydrome ;; - ps2) - basic_machine=i386-ibm + i370-ibm*) + vendor=ibm ;; - rm[46]00) - basic_machine=mips-siemens + orion-unknown) + vendor=highlevel ;; - rtpc | rtpc-*) - basic_machine=romp-ibm + xps-unknown | xps100-unknown) + cpu=xps100 + vendor=honeywell + ;; + + # Here we normalize CPU types with a missing or matching vendor + dpx20-unknown | dpx20-bull) + cpu=rs6000 + vendor=bull + os=${os:-bosx} ;; - s390 | s390-*) - basic_machine=s390-ibm + + # Here we normalize CPU types irrespective of the vendor + amd64-*) + cpu=x86_64 ;; - s390x | s390x-*) - basic_machine=s390x-ibm + blackfin-*) + cpu=bfin + os=linux ;; - sb1) - basic_machine=mipsisa64sb1-unknown + c54x-*) + cpu=tic54x ;; - sb1el) - basic_machine=mipsisa64sb1el-unknown + c55x-*) + cpu=tic55x ;; - sde) - basic_machine=mipsisa32-sde - os=${os:-elf} + c6x-*) + cpu=tic6x ;; - sequent) - basic_machine=i386-sequent + e500v[12]-*) + cpu=powerpc + os=$os"spe" ;; - sh5el) - basic_machine=sh5le-unknown + mips3*-*) + cpu=mips64 ;; - simso-wrs) - basic_machine=sparclite-wrs - os=vxworks + ms1-*) + cpu=mt ;; - spur) - basic_machine=spur-unknown + m68knommu-*) + cpu=m68k + os=linux ;; - st2000) - basic_machine=m68k-tandem + m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) + cpu=s12z ;; - strongarm-* | thumb-*) - basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` + openrisc-*) + cpu=or32 ;; - sun2) - basic_machine=m68000-sun + parisc-*) + cpu=hppa + os=linux ;; - sun3 | sun3-*) - basic_machine=m68k-sun + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + cpu=i586 ;; - sun4) - basic_machine=sparc-sun + pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + cpu=i686 ;; - sun386 | sun386i | roadrunner) - basic_machine=i386-sun + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + cpu=i686 ;; - tile*) - basic_machine=$basic_machine-unknown - os=linux-gnu + pentium4-*) + cpu=i786 ;; - tx39) - basic_machine=mipstx39-unknown + pc98-*) + cpu=i386 ;; - tx39el) - basic_machine=mipstx39el-unknown + ppc-* | ppcbe-*) + cpu=powerpc ;; - tower | tower-32) - basic_machine=m68k-ncr + ppcle-* | powerpclittle-*) + cpu=powerpcle ;; - vpp*|vx|vx-*) - basic_machine=f301-fujitsu + ppc64-*) + cpu=powerpc64 ;; - w65*) - basic_machine=w65-wdc - os=none + ppc64le-* | powerpc64little-*) + cpu=powerpc64le ;; - w89k-*) - basic_machine=hppa1.1-winbond - os=proelf + sb1-*) + cpu=mipsisa64sb1 ;; - x64) - basic_machine=x86_64-pc + sb1el-*) + cpu=mipsisa64sb1el ;; - xps | xps100) - basic_machine=xps100-honeywell + sh5e[lb]-*) + cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'` ;; - xscale-* | xscalee[bl]-*) - basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` + spur-*) + cpu=spur ;; - none) - basic_machine=none-none - os=${os:-none} + strongarm-* | thumb-*) + cpu=arm ;; - -# Here we handle the default manufacturer of certain CPU types. It is in -# some cases the only manufacturer, in others, it is the most popular. - w89k) - basic_machine=hppa1.1-winbond + tx39-*) + cpu=mipstx39 ;; - op50n) - basic_machine=hppa1.1-oki + tx39el-*) + cpu=mipstx39el ;; - op60c) - basic_machine=hppa1.1-oki + x64-*) + cpu=x86_64 ;; - romp) - basic_machine=romp-ibm + xscale-* | xscalee[bl]-*) + cpu=`echo "$cpu" | sed 's/^xscale/arm/'` ;; - mmix) - basic_machine=mmix-knuth + + # Recognize the canonical CPU Types that limit and/or modify the + # company names they are paired with. + cr16-*) + os=${os:-elf} ;; - rs6000) - basic_machine=rs6000-ibm + crisv32-* | etraxfs*-*) + cpu=crisv32 + vendor=axis ;; - vax) - basic_machine=vax-dec + cris-* | etrax*-*) + cpu=cris + vendor=axis ;; - pdp11) - basic_machine=pdp11-dec + crx-*) + os=${os:-elf} ;; - we32k) - basic_machine=we32k-att + neo-tandem) + cpu=neo + vendor=tandem ;; - sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) - basic_machine=sh-unknown + nse-tandem) + cpu=nse + vendor=tandem ;; - cydra) - basic_machine=cydra-cydrome + nsr-tandem) + cpu=nsr + vendor=tandem ;; - orion) - basic_machine=orion-highlevel + nsv-tandem) + cpu=nsv + vendor=tandem ;; - orion105) - basic_machine=clipper-highlevel + nsx-tandem) + cpu=nsx + vendor=tandem ;; - mac | mpw | mac-mpw) - basic_machine=m68k-apple + s390-*) + cpu=s390 + vendor=ibm ;; - pmac | pmac-mpw) - basic_machine=powerpc-apple + s390x-*) + cpu=s390x + vendor=ibm ;; - *-unknown) - # Make sure to match an already-canonicalized machine name. + tile*-*) + os=${os:-linux-gnu} ;; + *) - echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv64 \ + | rl78 | romp | rs6000 | rx \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1356,7 +1348,7 @@ case $os in | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ | aos* | aros* | cloudabi* | sortix* \ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ - | clix* | riscos* | uniplus* | iris* | rtu* | xenix* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ | knetbsd* | mirbsd* | netbsd* \ | bitrig* | openbsd* | solidbsd* | libertybsd* \ | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ @@ -1376,12 +1368,12 @@ case $os in | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ | skyos* | haiku* | rdos* | toppers* | drops* | es* \ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd*) + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi*) # Remember, each alternative MUST END IN *, to match a version number. ;; qnx*) - case $basic_machine in - x86-* | i*86-*) + case $cpu in + x86 | i*86) ;; *) os=nto-$os @@ -1507,7 +1499,7 @@ case $os in # Until real need of OS specific support for # particular features comes up, bare metal # configurations are quite functional. - case $basic_machine in + case $cpu in arm*) os=eabi ;; @@ -1541,7 +1533,7 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +case $cpu-$vendor in score-*) os=elf ;; @@ -1722,9 +1714,8 @@ fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) +case $vendor in + unknown) case $os in riscix*) vendor=acorn @@ -1793,11 +1784,10 @@ case $basic_machine in vendor=stratus ;; esac - basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo "$basic_machine-$os" +echo "$cpu-$vendor-$os" exit # Local variables: diff --git a/configure.ac b/configure.ac index 5513e25f1..c8885cac5 100644 --- a/configure.ac +++ b/configure.ac @@ -774,7 +774,7 @@ AS_HELP_STRING([--with-term-lib=LIBS],[search space-separated LIBS for terminal termcap_curses_order="$withval" AC_SEARCH_LIBS(tigetstr, [$termcap_curses_order]) else - termcap_curses_order="$ncursesw_test tinfo termcap $ncurses_test curses" + termcap_curses_order="$ncursesw_test $ncurses_test tinfow tinfo termcap curses" fi], [case "$host_os" in solaris*) @@ -783,7 +783,7 @@ fi], DL_EXT="${DL_EXT=sl}" termcap_curses_order="Hcurses $ncursesw_test $ncurses_test curses termcap" ;; *) - termcap_curses_order="$ncursesw_test tinfo termcap $ncurses_test curses" ;; + termcap_curses_order="$ncursesw_test $ncurses_test tinfow tinfo termcap curses" ;; esac])dnl AH_TEMPLATE([ZSH_NO_XOPEN], @@ -807,6 +807,8 @@ dnl That's so that on systems where termcap and [n]curses are dnl both available and both contain termcap functions, while dnl only [n]curses contains terminfo functions, we only link against dnl [n]curses. +LIBS_save_pre_term="$LIBS" +AC_SEARCH_LIBS(tigetstr, [$termcap_curses_order]) AC_SEARCH_LIBS(tigetflag, [$termcap_curses_order]) AC_SEARCH_LIBS(tgetent, [$termcap_curses_order], true, @@ -831,7 +833,56 @@ AC_CACHE_CHECK(if we need to ignore ncurses, zsh_cv_ignore_ncurses, zsh_cv_ignore_ncurses=no ;; *) - zsh_cv_ignore_ncurses=yes + dnl The lack of -lncurses in the $LIBS might be the result of passing + dnl --with-term-lib=^ncurses option. To address this, a test for the tgetent + dnl and other functions is ran here, possibly for the second time, just to + dnl ensure that the ncurses library doesn't have them. + LIBS_save="$LIBS" + dnl Remember (the values are used later, around line 3005) and remove the cache + ac_cv_search_tigetstr_SAVE="$ac_cv_search_tigetstr" + ac_cv_search_tigetnum_SAVE="$ac_cv_search_tigetnum" + ac_cv_search_tigetflag_SAVE="$ac_cv_search_tigetflag" + ac_cv_search_tgetent_SAVE="$ac_cv_search_tgetent" + unset ac_cv_search_tigetstr ac_cv_search_tigetnum ac_cv_search_tigetflag ac_cv_search_tgetent + LIBS="$LIBS_save_pre_term" + + dnl Run the checks for all four used terminal functions + AC_SEARCH_LIBS(tigetstr, [ncursesw ncurses curses]) + AC_SEARCH_LIBS(tigetnum, [ncursesw ncurses curses]) + AC_SEARCH_LIBS(tigetflag, [ncursesw ncurses curses]) + AC_SEARCH_LIBS(tgetent, [ncursesw ncurses curses]) + LIBS_result="$LIBS" + + LIBS="$LIBS_save" + dnl Restore the cache + ac_cv_search_tigetstr="$ac_cv_search_tigetstr_SAVE" + ac_cv_search_tigetnum="$ac_cv_search_tigetnum_SAVE" + ac_cv_search_tigetflag="$ac_cv_search_tigetflag_SAVE" + ac_cv_search_tgetent="$ac_cv_search_tgetent_SAVE" + + case $LIBS_result in + *-lncurses*|*-lcurses*) + dnl Yes we need to ignore ncurses, its tgetent or tigetflag might + dnl conflict with the one from the selected terminal library + zsh_cv_ignore_ncurses=yes + ;; + *) + dnl If the tgetent nor tigetflag weren't found in the libncurses*.so, then + dnl there will be no conflict with the other terminal library selected (e.g. + dnl libtinfo) and it's possible to link ncurses provided that it is working + dnl - it is here verified that it has initscr() function to check that + AC_SEARCH_LIBS(initscr, [ncursesw ncurses curses]) + case $LIBS in + *-lncurses*|*-lcurses*) + dnl No need to ignore curses - it is working and it doesn't + dnl have tgetent nor tigetflag + zsh_cv_ignore_ncurses=no + ;; + *) + zsh_cv_ignore_ncurses=yes + ;; + esac + esac ;; esac]) @@ -1880,6 +1931,7 @@ zsh_LIMIT_PRESENT(RLIMIT_POSIXLOCKS) zsh_LIMIT_PRESENT(RLIMIT_NPTS) zsh_LIMIT_PRESENT(RLIMIT_SWAP) zsh_LIMIT_PRESENT(RLIMIT_KQUEUES) +zsh_LIMIT_PRESENT(RLIMIT_UMTXP) AH_TEMPLATE([RLIMIT_VMEM_IS_RSS], [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.]) @@ -2007,17 +2059,9 @@ dnl be good enough. AH_TEMPLATE([PATH_DEV_FD], [Define to the path of the /dev/fd filesystem.]) AC_CACHE_CHECK(for /dev/fd filesystem, zsh_cv_sys_path_dev_fd, -[if test "$host_os" = cygwin; then -dnl In current (2008/12/01) versions of Cygwin these are present but don't -dnl seem to work smoothly for process substitution; no great surprise -dnl since getting processes to work at all on Cygwin is a big challenge. -dnl We'll rely on FIFOs, since they do what we need. -zsh_cv_sys_path_dev_fd=no -else [for zsh_cv_sys_path_dev_fd in /proc/self/fd /dev/fd no; do test x`echo ok|(exec 3<&0; cat $zsh_cv_sys_path_dev_fd/3 2>/dev/null;)` = xok && break - done] -fi]) + done]) if test x$zsh_cv_sys_path_dev_fd != xno; then AC_DEFINE_UNQUOTED(PATH_DEV_FD, "$zsh_cv_sys_path_dev_fd") fi @@ -2087,6 +2131,10 @@ AC_CACHE_CHECK(for NIS, zsh_cv_sys_nis, zsh_cv_sys_nis=yes || zsh_cv_sys_nis=no]) if test x$zsh_cv_sys_nis = xyes; then AC_DEFINE(HAVE_NIS) +dnl RPC is removed from glibc-2.26 and replaced by libtirpc + AC_CHECK_HEADER(rpc/rpc.h, [], + [test -f /usr/include/tirpc/rpc/rpc.h && \ + CPPFLAGS="$CPPFLAGS -I/usr/include/tirpc"]) dnl Some systems (Solaris 2.x, Linux Redhat 5.x) require dnl libnsl (Network Services Library) to find yp_all AC_SEARCH_LIBS(yp_all, nsl) @@ -2204,14 +2252,9 @@ dnl ----------- dnl named FIFOs dnl ----------- dnl -dnl Named FIFOs work well enough on recent versions of Cygwin -dnl to provide what we want. Simply enable them. AC_CACHE_CHECK(if named FIFOs work, zsh_cv_sys_fifo, -[if test "$host_os" = cygwin; then -zsh_cv_sys_fifo=yes -else -AC_RUN_IFELSE([AC_LANG_SOURCE([[ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <fcntl.h> #include <signal.h> main() @@ -2239,7 +2282,7 @@ main() exit(ret); } ]])],[zsh_cv_sys_fifo=yes],[zsh_cv_sys_fifo=no],[zsh_cv_sys_fifo=yes]) -fi]) +]) AH_TEMPLATE([HAVE_FIFOS], [Define to 1 if system has working FIFOs.]) if test x$zsh_cv_sys_fifo = xyes; then |