diff options
326 files changed, 10259 insertions, 7081 deletions
diff --git a/.cvsignore b/.cvsignore deleted file mode 100644 index 95cdc587b..000000000 --- a/.cvsignore +++ /dev/null @@ -1,16 +0,0 @@ -Makefile -META-FAQ -config.cache -config.h -config.h.in -config.log -config.modules -config.modules.sh -config.status -configure -cscope.out -stamp-h -stamp-h.in -autom4te.cache -*.swp -.git diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000..7a4bb5650 --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1,28 @@ +# commits to be ignored by git blame. use as follows: +# +# git config blame.ignoreRevsFile .git-blame-ignore-revs +# +# .git-blame-ignore-revs is the conventional file name for this purpose, so you +# may prefer to use it globally instead. this is possible in git 2.53+: +# +# git config --global blame.ignoreRevsFile ':(optional).git-blame-ignore-revs' +# +# in general, only trivial, non-functionality-affecting commits (e.g. typo and +# white-space fixes) should be added to this list +# +# please add in ascending chronological order + +# unposted: Fix inconsistent white space in change log +92b0e885d6273315602668eb50f25310020fee13 +# unposted: fix indentation (whitespace-only change) +6c6200520afa0409c5c310cd421f33353c44c61d +# 45101: Adjust white space +1a8c69e26fc7e64e1b5e2837d7754a910b6a0c26 +# Clean up error-message white space +4ce66857b71b40a0661df3780ff557f2b0f4cb13 +# 46139: _git: Remove hanging whitespaces +d839833e4e00ee320a353846eaa235ab952181f0 +# 49435: Remove trailing whitespaces in expn.yo +02f75cf38699b99340c1d2c8f5a9d9aaf81432e7 +# 54806: reformat interactive tests for readability (whitespace only) +4d1193772b093e23c533e86cb11448d36f38c8c2 diff --git a/.gitignore b/.gitignore index ec2f56642..b8922ef6f 100644 --- a/.gitignore +++ b/.gitignore @@ -155,3 +155,4 @@ Src/Zle/zle_widget.h Test/*.tmp /.project +.DS_Store @@ -1,3 +1,800 @@ +2026-08-14 Mikael Magnusson <mikachu@gmail.com> + + * 55082: Src/Zle/zle_move.c: fix zlecs bounds checks in + vimatchbracket and alignmultiwordleft + +2026-08-13 Mikael Magnusson <mikachu@gmail.com> + + * 55076: Src/exec.c: _exit in zexecve when the interpreter + doesn't work + + * 55065: Src/jobs.c: fix null deref in havefiles + +2026-08-05 Mikael Magnusson <mikachu@gmail.com> + + * 55055: Src/builtin.c, Test/A07control.ztst: break: more + completely enumerate loop types we are not in + +2026-07-25 Mikael Magnusson <mikachu@gmail.com> + + * 54994: Src/Modules/db_gdbm.c, configure.ac: use gdbm_fd_open + so we can move the fd to >9 + + * 54993: configure.ac: fail at configure time if a feature is + requested and we couldn't find it + + * 54986: Src/Modules/socket.c, Src/Modules/tcp.c, + Src/Modules/zftp.c, Src/exec.c, Src/params.c, Src/utils.c, + Src/zsh.h: actually prevent FDT_MODULE fds from being closed + by user + +2026-07-21 Mikael Magnusson <mikachu@gmail.com> + + * 54985: Src/Zle/zle_main.c, Src/hist.c, Src/zsh.h: fix crash + with bracketed-paste-magic and undo + +2026-07-19 Bart Schaefer <schaefer@zsh.org> + + * 54996: Doc/Zsh/mod_ksh93.yo: Remove obsolete doc reference to + subscript namerefs + + * Philippe: 54943: Src/params.c: Do not export named references + even when ALLEXPORT is enabled + + * Philippe: 54809: Src/Zle/compctl.c, Src/Zle/complete.c, + Src/Zle/compresult.c, Src/Zle/zle_main.c, Src/Zle/zle_params.c, + Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c: ZLE specials are + always in realparamtab and can't be namerefs + + * Philippe: 54988: Test/K01nameref.ztst: Add comment clarifying + test from workers/54792 + +2026-07-15 dana <dana@dana.is> + + * Philippe Altherr: 54941: Src/exec.c, Test/A06assign.ztst: Fix + saving and restoring of subscripted inline assignments + + * Shohei YOSHIDA: 54974: Completion/Unix/Command/_vim: Add + '--log' option + + * Shohei YOSHIDA: 54933: Completion/Darwin/Command/_nettop: + Correct interface type name in nettop + + * 54956: Src/init.c, Test/D04parameter.ztst: init: don't reset + ZLE_RPROMPT_INDENT on term init + + * 54950: Doc/Zsh/compsys.yo: clarify $line contents + +2026-07-12 dana <dana@dana.is> + + * 54939: Completion/Unix/Command/_sudo: fix handling of envvar + assignments + +2026-07-12 Mikael Magnusson <mikachu@gmail.com> + + * 54927: Src/Modules/zpty.c, Src/zsh_system.h: checkptycmd: + remove select()+FIONREAD variant, re-enable poll on osx + + * 54928: Test/W02jobs.ztst: W02: really close all the fds + for sleep + +2026-07-11 dana <dana@dana.is> + + * 54930: Src/builtin.c: zexit: don't write history in sub-shells + + * 54926: Completion/Base/Core/_main_complete: mark some + parameters as global + +2026-07-10 dana <dana@dana.is> + + * unposted: Completion/X/Command/_firefox, + Completion/Zsh/Type/_command_names: fix some wrongly ordered + globquals + +2026-07-09 dana <dana@dana.is> + + * 54919: Test/D04parameter.ztst: fix hang in D04 + zsh_eval_context test + + * unposted: Completion/Unix/Command/_grep: fix freebsd grep + variant pattern + + * unposted (see 54915): + Completion/Darwin/Type/_mac_files_for_application: remove + _mac_files_for_application + +2026-07-08 dana <dana@dana.is> + + * unposted: Test/runtests.zsh: runtests: colourise signal fail + message + + * unposted: NEWS, README: mention various changes + + * unposted: Completion/Unix/Type/_urls: make parameter local + + * 54915 (tweaked): Completion/Darwin/Command/_open, + Completion/Darwin/Type/_retrieve_mac_apps: complete --args, etc + + * 54914: Completion/Unix/Command/_webbrowser, + Completion/X/Command/_chromium, Completion/X/Command/_firefox, + Completion/X/Command/_mozilla: add _firefox, _chromium, etc + + * 54913: Completion/Base/Core/_message, + Test/Y01completion.ztst: improve option parsing + + * 54913: Completion/Base/Utility/_numbers: pass -r and -R to + compadd + + * 54913: Test/comptest: prefer $TMPDIR for temp files + + * 54912: Completion/Base/Utility/_call_program, + Doc/Zsh/compsys.yo, Test/Y07call_program.ztst: add -qQ options, + etc + + * unposted: Test/D04parameter.ztst: add regression test for + w/54909 + +2026-07-08 Mikael Magnusson <mikachu@gmail.com> + + * 54909: Src/subst.c: Untokenize before quoting unquoted literal + values + +2026-07-06 dana <dana@dana.is> + + * 54894 (tweaked): Completion/compdump: improve performance + +2026-07-04 Mikael Magnusson <mikachu@gmail.com> + + * 54783: Src/Modules/zpty.c, Test/V08zpty.ztst: improve + checkptycmd + +2026-07-03 Oliver Kiddle <opk@zsh.org> + + * unposted: Completion/X/Command/_mplayer, Completion/X/Command/_xv: + complete more media file types + + * unposted (c.f. 54878): Completion/Unix/Command/_age: import + ZSH-licenced age completion from zsh-completions (by Hydrargyrum) + + * 54899: Completion/Linux/Command/_namei: new completion + +2026-07-03 dana <dana@dana.is> + + * 54891: Completion/Solaris/Command/_pkgadd, + Completion/Solaris/Command/_pkginfo, + Completion/Solaris/Command/_pkgrm, + Completion/Solaris/Type/_pkg_instances: move/rename + _pkg_instance -> _pkg_instances + + * 54891: Completion/Linux/Command/_ip, + Completion/Linux/Command/_kbd, Completion/Linux/Command/_kmod, + Completion/Linux/Command/_ladspa, + Completion/Solaris/Command/_pkgadd, + Completion/Solaris/Command/_pkginfo, + Completion/Solaris/Command/_pkgrm, + Completion/Unix/Command/_htop: move/rename several functions + + * 54891: Completion/BSD/Command/_csup, + Completion/BSD/Command/_portaudit, + Completion/Base/Utility/_arg_compile, + Completion/Debian/Command/_auto-apt, + Completion/Debian/Command/_git-buildpackage, + Completion/Linux/Command/_mondo, + Completion/Mandriva/Command/_rebootin, + Completion/Unix/Command/_aap, Completion/Unix/Command/_baz, + Completion/Unix/Command/_bittorrent, + Completion/Unix/Command/_clay, Completion/Unix/Command/_cplay, + Completion/Unix/Command/_fsh, Completion/Unix/Command/_initctl, + Completion/Unix/Command/_monotone, + Completion/Unix/Command/_moosic, Completion/Unix/Command/_pump, + Completion/Unix/Command/_tla, Completion/Unix/Command/_totd, + Completion/Unix/Command/_twidge, + Completion/Unix/Type/_arch_archives, + Completion/Unix/Type/_arch_namespace, + Completion/X/Command/_acroread, Completion/X/Command/_dcop, + Completion/X/Command/_netscape, + Completion/openSUSE/Command/_SUSEconfig: remove obsolete + functions + + * 54889: Src/Zle/computil.c, Test/Y03arguments.ztst: + comparguments: always parse optargs as optargs + + * 54876: Src/Zle/computil.c, Test/Y03arguments.ztst: + comparguments: search more thoroughly for foreign-set options + + * unposted: Completion/Unix/Command/_ping: revert previous + _arguments fix + + * unposted: Completion/BSD/Command/_pfctl, + Completion/Debian/Command/_module-assistant, + Completion/Unix/Command/_ping, Completion/Unix/Command/_tiff, + Completion/Unix/Command/_zfs: fix ambiguous arg specs + + * unposted: Completion/Unix/Command/_pip: remove -b + +2026-07-02 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 54893: Functions/Misc/is-at-least, Test/Z01is-at-least.ztst: + fix/simplify is-at-least + +2026-07-01 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * unposted: Completion/Unix/Command/_attr: $list was removed + in 54528 + +2026-07-01 dana <dana@dana.is> + + * unposted: Completion/Zsh/Command/_zformat: add _zformat + + * unposted: README: document ::= changes + + * unposted: .git-blame-ignore-revs: add 4d1193772b (54806) to + ignore-revs + + * unposted: Completion/X/Command/_sioyek: remove _sioyek + + * Štěpán Němec: 54871: Doc/Zsh/compwid.yo: add index markup for + the Completion Condition Codes + + * Štěpán Němec: 54870: Doc/Zsh/builtins.yo, Doc/Zsh/compsys.yo, + Doc/Zsh/options.yo, Doc/intro.ms, Etc/CONTRIBUTORS: Fix some + doc typos + + * Štěpán Němec: 54869: Doc/Zsh/compsys.yo: move 'expl' index + annotation to (more) proper place(s) + + * Štěpán Němec: 54868: Completion/Unix/Command/_perl: fix -c + option description + +2026-07-01 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 54648: Test/K01nameref.ztst: set $module_path in child zsh + + * 54847 + 54849: Test/V15nearcolor.ztst: skip only 88 or 256 + color tests if corresponding terminal is not available + +2026-06-30 dana <dana@dana.is> + + * unposted: Completion/Unix/Command/_nano: fix syntaxes tag + +2026-06-29 dana <dana@dana.is> + + * 54863: Completion/Unix/Command/_configure, + Completion/Unix/Command/_ffmpeg, Completion/Unix/Command/_git, + Completion/Unix/Command/_php, + Completion/Unix/Command/_postgresql: compadd -q -> -r + +2026-06-28 dana <dana@dana.is> + + * unposted: Completion/Base/Utility/_numbers: fix compadd -q + spec + + * unposted: Completion/Unix/Command/_configure: auto-remove = + after variable name + +2026-06-23 dana <dana@dana.is> + + * 54830 (tweaked): Completion/Unix/Command/_ffmpeg: improve + _ffmpeg + + * 54831: Src/Zle/computil.c, Test/Y03arguments.ztst: + comparguments: treat empty description as if missing + + * 54818: Doc/Zsh/compsys.yo: clarify _arguments {...} action + behaviour + + * 54823: Doc/Zsh/expn.yo: clarify ::= behaviour + +2026-06-23 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 54838: Test/D04parameter.ztst: avoid hang up if FIFO is used + for process substitution + +2026-06-22 Bart Schaefer <schaefer@zsh.org> + + * Philippe: 54805: Test/comptest: capture any DPUTS output during + completion tests + + * Philippe: 54806: Test/A02alias.ztst, Test/B06fc.ztst, + Test/D04parameter.ztst, Test/K01nameref.ztst, + Test/W01history.ztst: Null prompts in interactive tests to avoid + unnecessary stderr; reformat for readability + + * Philippe: 54792: Src/params.c, Test/K01nameref.ztst: prevent + named references from being entered as named directories + +2026-06-23 Oliver Kiddle <opk@zsh.org> + + * Felipe Contreras: 47546: Src/builtin.c: trivial cleanup + + * 54844: Completion/Unix/Command/_configure, + Completion/Unix/Command/_gcc: complete variable assignments + with configure + + * 54828: Completion/Unix/Command/_shutdown: handle time arguments + +2026-06-21 Mikael Magnusson <mikachu@gmail.com> + + * 54822: Src/subst.c, Test/D04parameter.ztst: the ::= fix in + 54674 was incomplete + +2026-06-20 dana <dana@dana.is> + + * Nuke: 54790 (tweaked): Completion/Unix/Command/_ffmpeg: + update for modern ffmpeg + + * Holger Hoffstätte: github #174: Completion/Unix/Command/_gcc: + _gcc: coroutines-ts was merged in 2020 + + * 54808: .git-blame-ignore-revs: add .git-blame-ignore-revs + + * 54773: Src/params.c, Test/D06subscript.ztst: make out-of-range + (w) subscript index work like others + + * 54768: Completion/Base/Core/_description, + Completion/Base/Core/_main_complete, + Completion/Base/Core/_message, + Completion/Base/Utility/_numbers, + Completion/Debian/Command/_git-buildpackage, + Completion/Linux/Command/_valgrind, + Completion/Unix/Command/_csplit, + Completion/Unix/Command/_gcore, Completion/Unix/Command/_mpc, + Completion/Unix/Command/_nano, + Completion/Unix/Command/_opustools, + Completion/Unix/Type/_date_formats, Test/Y01completion.ztst, + Test/Y03arguments.ztst, Test/Y05describe.ztst, + Test/Y06values.ztst: use `zformat -q` for formatting + + * 54767: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c, + Test/V13zformat.ztst: zformat: replace -qn by spec quoting + indicator syntax + + * 54763: Completion/Unix/Command/_sh: support more shells + + options + +2026-06-19 Oliver Kiddle <opk@zsh.org> + + * 54800, 54807: Completion/...: completion options update + +2026-06-18 Mikael Magnusson <mikachu@gmail.com> + + * 54801: Src/Zle/compctl.c, Src/Zle/complete.c: fix two more + warnings from 54710 + +2026-06-16 Mikael Magnusson <mikachu@gmail.com> + + * 54788: Completion/Unix/Command/_shutdown: fix shutdown + completion when not using systemd + + * 54784: configure.ac: cache the last few checks in configure.ac + + * 54776: Src/Modules/system.c, Src/Modules/zftp.c, + Src/Zle/complete.c, Src/exec.c, Src/glob.c: fix warnings from + 54710 + + * 54771: Src/Zle/compcore.c, Test/Y01completion.ztst: fix a bug + in nosort deduplication + +2026-06-15 dana <dana@dana.is> + + * unposted: Completion/Unix/Command/_ansible: remove duplicate + option + + * 54764: Src/utils.c: zerrmsg: handle null pointers with %s/%l + +2026-06-14 Mikael Magnusson <mikachu@gmail.com> + + * unposted: Completion/Unix/Command/_zip: fix return code in _zip + +2026-06-14 Oliver Kiddle <opk@zsh.org> + + * unposted: config.guess, config.sub: update to 2026-05-17 + + * unposted: Completion/Unix/Command/_tcpdump: remove dead code + + * unposted: Completion/Unix/Command/_cdrecord: use _tilde_files + + * 54665: Doc/Zsh/compsys.yo, Completion/Base/Utility/_phony, + Completion/Darwin/Command/_fink, Completion/Solaris/Command/_ipadm, + Completion/Unix/Command/_abcde, Completion/Unix/Command/_postfix, + Completion/Unix/Command/_shutdown, Completion/Unix/Command/_sleep, + Completion/Unix/Command/_ssh, Completion/Unix/Command/_zfs: + new utility function for mixing in extra values + +2026-06-14 Mikael Magnusson <mikachu@gmail.com> + + * 54762: Src/jobs.c, Test/W02jobs.ztst: make curjob and prevjob + work better + + * unposted: Doc/Zsh/mod_zpty.yo: add some usage notes to zpty + -d and -t + + * 54753: Src/Modules/zpty.c, Test/W02jobs.ztst: zpty: register + pty fd as FDT_MODULE so it isn't closed when forking + + * 54751: Test/W02jobs.ztst: make the W02 test not take a full + minute on linux + + * 54721: Doc/Zsh/expn.yo, Doc/intro.ms, Functions/Misc/zmv, + Src/Modules/zpty.c, Src/Modules/zutil.c, Src/Zle/compctl.c, + Src/Zle/computil.c, Src/Zle/zle_main.c, Src/Zle/zle_refresh.c, + Src/builtin.c, Src/glob.c, Src/hist.c, Src/jobs.c, + Src/math.c, Src/module.c, Src/parse.c, Test/B02typeset.ztst, + Test/B10getopts.ztst, Test/B11kill.ztst, Test/D04parameter.ztst, + Test/K01nameref.ztst, Test/V13zformat.ztst: illegal -> invalid, + invalid option -> bad option + + * 54715: Src/Zle/compctl.c: compctl: print multibyte errors + correctly (phew) + + * 54714: Src/Modules/zutil.c, Src/glob.c, Src/utils.c, Src/zsh.h: + add MB_NICECHAR and use it + + * 54713: Src/Modules/zutil.c: fix multibyte error reporting + in zparseopts + + * 54712: Src/subst.c: handle the Pound token in error message + + * 54711: Src/builtin.c: print invalid option to getopts correctly + + * 54710: Src/Builtins/rlimits.c, Src/Builtins/sched.c, + Src/Modules/stat.c, Src/Modules/system.c, Src/Modules/zftp.c, + Src/Zle/complete.c, Src/Zle/zle_thingy.c, Src/builtin.c, + Src/exec.c, Src/glob.c, Src/math.c, Src/options.c, + Test/B12limit.ztst: handle multibyte arguments in error messages + +2026-06-10 dana <dana@dana.is> + + * 54677: Test/runtests.zsh, Test/ztst.zsh: improve readability + + * unposted: Src/jobs.c, Test/B11kill.ztst: kill: fix -l + argument error, add tests + +2026-06-09 Bart Schaefer <schaefer@zsh.org> + + * Philippe: 54731: Src/Modules/db_gdbm.c, Test/V11db_gdbm.ztst: + Adapt gdbm code to named references + + * Philippe: 54727: Src/params.c, Test/K01nameref.ztst: Implement + references to positional parameters + + * Philippe: 54722: Src/builtin.c, Src/params.c, Src/params.c: Fix + nameref issues in builtin "unset" + +2026-06-10 Mikael Magnusson <mikachu@gmail.com> + + * Stephane Chazelas: 54695: Doc/Zsh/contrib.yo, + Functions/Misc/regexp-replace: regexp-replace and ^, word boundary + or look-behind operators (and more). + + * 54707: Src/builtin.c: fix autoload +X nonexist leaving funcdef + at dummy + + * 54705: Src/Modules/ksh93.c: ksh93: fix use after free of + .sh.edchar + + * 54704 + 54728: Src/Modules/ksh93.c: remove obsolete workaround + in ksh93 module + + * 54696: Src/glob.c: unset REPLY before e:: and oe:: so things + don't break if it had acquired a weird type + + * 54693: Src/exec.c: show ARGV0 and - precommand more clearly + in xtrace output + + * 54692: Src/subst.c: untokenize string sent to matheval for + (#) flag + + * 54691: Src/subst.c, Test/D04parameter.ztst: fix :W and :w + duplicating input + + * 54688: Src/pattern.c, Test/D07multibyte.ztst: handle Stéphane + correctly + + * 54687: Src/Zle/compcore.c, Src/Zle/compctl.c, + Src/Zle/compmatch.c, Src/Zle/compresult.c, Src/Zle/zle_tricky.c: + fix brace completion + + * 54686: Src/Zle/zle_utils.c: count lines in showmsg more + correctly + + * 54683: Src/Zle/zle_refresh.c: fix for ctrl-r with combining + characters or nonprintable wide chars + + * 54674: Src/subst.c, Test/D04parameter.ztst: ::= didn't respect + parameter flags + +2026-06-08 dana <dana@dana.is> + + * unposted: NEWS: document COLUMNS+LINES change from w/54676 + + * 54676: Doc/Zsh/params.yo, Src/init.c, Src/params.c, + Src/utils.c, Test/D04parameter.ztst: preserve COLUMNS + LINES + from the environment + + * unposted: NEWS: fix 5.9 changes header + + * 54659: Completion/Zsh/Command/_alias, + Completion/Zsh/Command/_bindkey, + Completion/Zsh/Command/_command, + Completion/Zsh/Command/_compadd, Completion/Zsh/Command/_dirs, + Completion/Zsh/Command/_disable, + Completion/Zsh/Command/_emulate, + Completion/Zsh/Command/_enable, Completion/Zsh/Command/_exec, + Completion/Zsh/Command/_fc, Completion/Zsh/Command/_hash, + Completion/Zsh/Command/_jobs_builtin, + Completion/Zsh/Command/_kill, Completion/Zsh/Command/_print, + Completion/Zsh/Command/_prompt, Completion/Zsh/Command/_read, + Completion/Zsh/Command/_set, Completion/Zsh/Command/_strftime, + Completion/Zsh/Command/_tcpsys, + Completion/Zsh/Command/_typeset, + Completion/Zsh/Command/_unhash, Completion/Zsh/Command/_vared, + Completion/Zsh/Command/_which, Completion/Zsh/Command/_zattr, + Completion/Zsh/Command/_zcompile, Completion/Zsh/Command/_zed, + Completion/Zsh/Command/_zle, Completion/Zsh/Command/_zmodload, + Completion/Zsh/Command/_zmv, + Completion/Zsh/Command/_zparseopts, + Completion/Zsh/Command/_zpty, Completion/Zsh/Command/_zsocket, + Completion/Zsh/Function/__arguments, Doc/Zsh/compsys.yo, + Src/Zle/computil.c, Test/Y03arguments.ztst: comparguments: + support zsh-style '-' terminator with -S -S + + * unposted: Functions/Misc/zgetopt: try funcstack for function + name + +2026-06-08 Bart Schaefer <schaefer@zsh.org> + + * Philippe Altherr: 54718: Src/builtin.c, Src/params.c, Src/zsh.h + Test/K01nameref.ztst: Remove support for named references to + subscripted variables + + * Philippe Altherr: 54475: Src/Modules/watch.c, Src/Modules/zftp.c, + Src/builtin.c, Src/init.c, Src/module.c, Src/params.c, Src/utils.c: + Don't perform dereferencing when looking up certain special parameters + + * Philippe Altherr: 54700: Src/params.c, Test/A06assign.ztst: + Refine string and array slice assignments (no user-visible change) + + * Mikel Ward: 54294: Src/jobs.c, Test/A05execution.ztst, + Test/W02jobs.ztst: Fix %- (prevjob) picking wrong job after resuming + + * Philippe Altherr: 54278: Src/params.c, Test/K01nameref.ztst: + Detect invalid variable names in reference initializers + + * Philippe Altherr: 54277: Src/params.c: reference loops are detected + at create time, remove loop tagging + +2026-06-08 Mikael Magnusson <mikachu@gmail.com> + + * unposted: Src/Modules/ksh93.c: fix NULL termination in ksh93 + +2026-06-07 Mikael Magnusson <mikachu@gmail.com> + + * unposted: Completion/Zsh/Type/_history_modifiers: add :S from + 51816 to completion + + * 54672: Src/Zle/zle_tricky.c: use bangchar instead of this + hardcoded ! + + * 54671: Src/glob.c, Test/D04parameter.ztst: fix anchored pattern + with --disable-multibyte + + * 54670: configure.ac: don't cache the user saying + --disable-multibyte as meaning multibyte support was detected + broken + + * 54668: aczsh.m4, configure.ac: various configure.ac cleanups + + * 54669: Src/Modules/cap.c, Src/Modules/cap.mdd, + Src/Modules/db_gdbm.c, Src/Modules/db_gdbm.mdd, + Src/Modules/pcre.mdd, Src/mkmakemod.sh, configure.ac: add + --disable-link-all-libs configure option + +2026-06-06 dana <dana@dana.is> + + * unposted: NEWS: better document hlgroups, termquery, etc + + * unposted: Doc/Zsh/mod_watch.yo: mention support for %H in + WATCHFMT (w/52646) + +2026-06-04 dana <dana@dana.is> + + * 54660: Completion/compinit: improve argument parsing + + * unposted: Completion/compdump: guard arguments to mv + + * unposted: README, Test/E01options.ztst: add regression test, + update README for w/54328 + + * Philippe Altherr: 54328: Doc/Zsh/options.yo, Src/params.c, + Src/utils.c: Only ever turn global parameters into named + directories + + * unposted: Test/A06assign.ztst: add regression test for w/54340 + + * Philippe Altherr: 54340: Src/params.c: Remove partial + duplication of strsetfn and arrsetfn + +2026-06-04 Mikael Magnusson <mikachu@gmail.com> + + * Moritz Bunkus: 49676: Completion/Unix/Command/_ansible: + re-read cached hosts & groups on directory change + + * Roman Perepelitsa: 44874: Src/Zle/zle_refresh.c: fix a memory + leak and potential heap corruption when rotating lines + + * 54624: Src/Zle/complete.c: parse_class would underallocate if + posix character classes are used + + * 54620: Src/exec.c: fix check for when to hash commands + + * 54617: Src/Modules/parameter.c, Src/zsh.h, + Test/V06parameter.ztst: fix lookup in $commands array when + hashlistall is unset + +2026-06-04 Oliver Kiddle <opk@zsh.org> + + * unposted: Src/zsh.h: remove further remnant of restricted mode + + * Shohei YOSHIDA: 54663: Completion/Unix/Command/_ruby: + update JIT flags + +2026-06-01 dana <dana@dana.is> + + * 54644: Src/init.c, Src/zsh.mdd, Test/E01options.ztst: init: + add patchlevel to --version output + + * Wesley Schwengle: 49374: Src/init.c: Show patchlevel in + version string + + * 54645: Test/A01grammar.ztst, Test/D03procsubst.ztst, + Test/V09datetime.ztst: fix some failures with + alpine/busybox/musl + +2026-05-30 dana <dana@dana.is> + + * unposted: Completion/Unix/Command/_imagemagick: support .heic + extension + + * unposted: Completion/Unix/Type/_diff_options: assume diff + under netbsd is gnu-like + +2026-05-29 dana <dana@dana.is> + + * 54625: .cvsignore, Completion/.cvsignore, Config/.cvsignore, + Doc/.cvsignore, Doc/Zsh/.cvsignore, Doc/help/.cvsignore, + Etc/.cvsignore, Functions/.cvsignore, Src/.cvsignore, + Src/Builtins/.cvsignore, Src/Modules/.cvsignore, + Src/Zle/.cvsignore, Test/.cvsignore: remove .cvsignore + +2026-05-27 dana <dana@dana.is> + + * 54603 (tweaked): Doc/Zsh/params.yo, Src/exec.c, Src/math.c, + Test/D04parameter.ztst: zsh_eval_context: add math context + + * unposted: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c, + Test/V13zformat.ztst: zformat: pass through %) with -q + + * 54602: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c, + Test/V13zformat.ztst: zformat: add -qQ options to auto-escape %s + + * unposted: Config/version.mk: bump to 5.9.999.3-test + + * unposted: Etc/creating-a-release.txt: document new version + sequence + + * unposted: NEWS: mention _as_if (w/53174) + +2026-05-26 Mikael Magnusson <mikachu@gmail.com> + + * 54613: configure.ac: restrict mdd search to Src/ since that's + where they are + +2026-05-26 Oliver Kiddle <opk@zsh.org> + + * 54589: Src/Modules/socket.c, Src/Modules/zftp.c, + Src/Modules/zpty.c, Src/Zle/compcore.c, Src/Zle/compctl.c, + Src/Zle/complist.c, Src/Zle/compmatch.c, Src/Zle/compresult.c, + Src/Zle/computil.c, Src/Zle/zle_keymap.c, Src/Zle/zle_tricky.c, + Src/builtin.c, Src/exec.c, Src/glob.c, Src/init.c, Src/params.c, + Src/prompt.c, Src/sort.c, Src/subst.c: remove dead code + identified by scan-build + +2026-05-25 dana <dana@dana.is> + + * Josh Triplett: unposted: Completion/Debian/Command/_dak, + Completion/Debian/Command/_debfoster: completion/debian: Update + for new programming language sections + +2026-05-26 Mikael Magnusson <mikachu@gmail.com> + + * 54615: Src/exec.c: fix ambiguous dangling from 54595 + +2026-05-25 Mikael Magnusson <mikachu@gmail.com> + + * 54609: Src/Zle/compresult.c: fix accept-and-hold completion + for words with leading quotes + + * 54609 + 54606: Src/Zle/complist.c: additional fixes for + interactive menu selection + + * 54601: Src/Zle/complist.c: fix complist interactive mode + overwriting buffer + + * 54600: Src/builtin.c: fix metafy stuff in add_autoload_function + + * 54599: Src/exec.c: use correct buf size in cancd + + * 54598: Src/exec.c: fix getfpfunc metafication + + * 54597: Src/exec.c: hashcmd could reject valid paths to hash + if they had metafied characters + + * 54596: Src/utils.c: pathprog used a signed char as a buffer size + + * 54595: Src/exec.c: overflow check in isreallycom + + * 54594: Src/exec.c: fix two very similar coverity issues + + * 54593: Src/Zle/compmatch.c: fix two edge cases in join_strs + + * 54592: Src/Zle/computil.c, Src/module.c: fix two dead + assignments reported 15 years ago by clang + +2026-05-23 dana <dana@dana.is> + + * unposted: Src/builtin.c, Test/B08shift.ztst: shift: improve + count error message + + * 54591: Src/Modules/termcap.c, Src/Modules/terminfo.c, + Src/jobs.c: fix new compiler warnings + + * unposted: NEWS, README: update for w/54580, w/54584, w/54585 + + * unposted: Completion/Zsh/Type/_jobs_fg: complete disown -a + + * 54585: Doc/Zsh/builtins.yo, Src/builtin.c, Src/jobs.c, + Test/W02jobs.ztst: disown: add -a option + + * 54584: Src/jobs.c, Test/W02jobs.ztst, + Test/W03jobparameters.ztst: jobs: update curjob in sub-shells + +2026-05-22 dana <dana@dana.is> + + * unposted: NEWS: update for w/52326 and w/52594 + +2026-05-22 Mikael Magnusson <mikachu@gmail.com> + + * unposted: Src/Modules/curses.c: fix missing return keyword + in 54552 + +2026-05-21 dana <dana@dana.is> + + * unposted: Src/parse.c, Test/A09zwc.ztst, Test/B14zwc.ztst: + add error message and improve tests for w/54571 + + * Michael Ridgway: 54571: Src/parse.c, Test/B14zwc.ztst: bound + h->npats in .zwc loader + + * unposted: Test/D07multibyte.ztst: add regression test for + w/54583 + + * LY: 54583: Src/loop.c: loop.c: stop destructive unmetafy in + selectlist() + + * 54580: Src/Modules/zutil.c, Test/V13zformat.ztst: zformat: + better handle literal % in format string + + * 54579: Doc/Zsh/mod_zutil.yo: clarify zformat -F ternary + behaviour + + * 54574: Completion/Base/Utility/_numbers: align descriptions + +2026-05-18 dana <dana@dana.is> + + * Michael Kuhn: github #160 (tweaked): + Completion/X/Command/_papers: New Papers completion + 2026-05-18 Oliver Kiddle <opk@zsh.org> * github #172: gi1242: Completion/X/Command/_sioyek: Completion diff --git a/Completion/.cvsignore b/Completion/.cvsignore deleted file mode 100644 index 89ff7b089..000000000 --- a/Completion/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -*.swp diff --git a/Completion/BSD/Command/_bectl b/Completion/BSD/Command/_bectl index 484fa0159..8bbcdf628 100644 --- a/Completion/BSD/Command/_bectl +++ b/Completion/BSD/Command/_bectl @@ -43,6 +43,7 @@ if [[ $state = args ]]; then args+=( '-r[create recursive boot environment]' '-e+[clone specified boot environment]: :->boot-environs' + '-E[create new empty boot environment]' ) ;; destroy) diff --git a/Completion/BSD/Command/_csup b/Completion/BSD/Command/_csup deleted file mode 100644 index 69e13f3d1..000000000 --- a/Completion/BSD/Command/_csup +++ /dev/null @@ -1,26 +0,0 @@ -#compdef csup - -_arguments -s \ - '-1[disable automatic retries]' \ - '-4[force usage of IPv4 addresses]' \ - '-6[force usage of IPv6 addresses]' \ - '-A[local address to bind to when connecting to the server]:local address:_hosts' \ - '-b[base directory]:base directory:_files -/' \ - '-c[subdirectory of base for information about collections]:collections directory:_files -/' \ - '-d[maximum number of deleted files]:maximum number of deleted files:' \ - '-h[server host]:server host:_hosts' \ - '-i[include only files and directories matching]:file pattern:' \ - '-k[keep temporary copies of failed updates]' \ - '-l[lock file]:lock file:_files' \ - '-L[verbosity level]:verbosity level:(0 1 2)' \ - '-L0[verbosity level 0]' \ - '-L1[verbosity level 1]' \ - '-L2[verbosity level 2]' \ - '-p[server port]:port:_ports' \ - '-r[maximum number of retries]:maximum number of retries:' \ - '-s[suppress status checks]' \ - '-v[print version information]' \ - '(-Z)-z[enable compression]' \ - '(-z)-Z[disable compression]' \ - ':csup file:_files' \ - ':destination directory:_files -/' diff --git a/Completion/BSD/Command/_freebsd-update b/Completion/BSD/Command/_freebsd-update index af37641e4..0d1f008ac 100644 --- a/Completion/BSD/Command/_freebsd-update +++ b/Completion/BSD/Command/_freebsd-update @@ -22,5 +22,6 @@ _arguments \ '-r[specify the new release]:new release' \ '-s[fetch files from the specified server or server pool]:server:_hosts' \ '-t[mail output of cron command, if any, to address]:address' \ + '-v[set output verbosity]:level [stats]:(stats nostats debug)' \ '--currently-running[assume specified release as current]:release' \ '*:command:_values -S " " -w "commands" $flags[@]' diff --git a/Completion/BSD/Command/_pfctl b/Completion/BSD/Command/_pfctl index 7756239d8..a664b6dd7 100644 --- a/Completion/BSD/Command/_pfctl +++ b/Completion/BSD/Command/_pfctl @@ -99,7 +99,7 @@ case $OSTYPE in ;; esac -_arguments -s $args \ +_arguments -s : $args \ '-a[apply flags -f, -F, and -s only to the rules in the specified anchor]:anchor' \ '-F+[flush the filter parameters specified by modifier]:modifier:(($pfctl_flush_modifiers))' \ '-D+[define macro to be set to value]:macro' \ diff --git a/Completion/BSD/Command/_portaudit b/Completion/BSD/Command/_portaudit deleted file mode 100644 index 788248d7f..000000000 --- a/Completion/BSD/Command/_portaudit +++ /dev/null @@ -1,14 +0,0 @@ -#compdef portaudit - -_arguments -s \ - '-a[vulnerability report for all installed packages]' \ - '-C[vulnerability report for the port in the current working directory]' \ - '-d[print creation date of the database]' \ - '-F[fetch the current database]' \ - '-q[quiet mode]' \ - '-V[show portaudit version number]' \ - '-v[verbose mode]' \ - '-X[download a fresh database from least days old]:days:' \ - '-f[check the packages listed in file]:file:_files' \ - '-r[restrict listed vulnerabilities with eregex pattern]:eregex:' \ - ':pkg-name:' diff --git a/Completion/Base/Core/_description b/Completion/Base/Core/_description index 368b41ee2..586b1590d 100644 --- a/Completion/Base/Core/_description +++ b/Completion/Base/Core/_description @@ -86,7 +86,7 @@ elif [[ -n "$format" ]]; then [[ -n $match[3] ]] && argv+=( o:$match[3] ) fi - zformat -F format "$format" "d:$1" "${(@)argv[2,-1]}" + zformat -Fq format "$format" "d:$1" "${(@)argv[2,-1]}" fi if [[ -n "$gname" ]]; then diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index 408a66ee3..b0c2db5b7 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -305,7 +305,7 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then elif [[ -n "$_menu_style[(r)select=long*]" ]]; then if [[ tmp -gt LINES ]]; then zmodload -i zsh/complist - MENUSELECT=00 + typeset -g MENUSELECT=00 fi fi if [[ "$MENUSELECT" != 00 ]]; then @@ -328,19 +328,19 @@ if [[ $compstate[old_list] = keep || nm -gt 1 ]]; then done zmodload -i zsh/complist - MENUSELECT="$min" + typeset -g MENUSELECT="$min" else unset MENUSELECT fi fi if [[ -n "$MENUSELECT" ]]; then if [[ -n "$_menu_style[(r)interactive*]" ]]; then - MENUMODE=interactive + typeset -g MENUMODE=interactive elif [[ -n "$_menu_style[(r)search*]" ]]; then if [[ -n "$_menu_style[(r)*backward*]" ]]; then - MENUMODE=search-backward + typeset -g MENUMODE=search-backward else - MENUMODE=search-forward + typeset -g MENUMODE=search-forward fi else unset MENUMODE @@ -366,7 +366,7 @@ elif [[ nm -eq 0 && -z "$_comp_mesg" && esac _setup warnings - zformat -f mesg "$format" "d:$str" "D:${(F)${(@)_lastdescr:#}}" + zformat -fq mesg "$format" "d:$str" "D:${(F)${(@)_lastdescr:#}}" compadd -x "$mesg" fi @@ -385,12 +385,12 @@ fi # Stuff we always do to clean up. if [[ "$compstate[old_list]" = keep ]]; then if [[ $_saved_colors_set = 1 ]]; then - ZLS_COLORS="$_saved_colors" + typeset -g ZLS_COLORS="$_saved_colors" else unset ZLS_COLORS fi elif (( $#_comp_colors )); then - ZLS_COLORS="${(j.:.)_comp_colors}" + typeset -g ZLS_COLORS="${(j.:.)_comp_colors}" else unset ZLS_COLORS fi diff --git a/Completion/Base/Core/_message b/Completion/Base/Core/_message index dbeed4a88..8c3f351f6 100644 --- a/Completion/Base/Core/_message +++ b/Completion/Base/Core/_message @@ -1,19 +1,26 @@ #autoload -local format raw gopt +local format raw +local -a gopt +local -A opth -if [[ "$1" = -e ]]; then +zparseopts -A opth -D -F - \ + {1+,2+,V+:,J+:}=gopt F: M: n o: q s: S: x: X: \ + e r \ +|| return + +if (( $+opth[-e] )); then local expl ret=1 tag _comp_mesg=yes - if (( $# > 2 )); then - tag="$2" + if (( $# > 1 )); then + tag=$1 shift else tag="$curtag" fi - _tags "$tag" && while _next_label "$tag" expl "$2"; do + _tags "$tag" && while _next_label "$tag" expl "$1"; do compadd ${expl:/-X/-x} ret=0 done @@ -24,22 +31,17 @@ if [[ "$1" = -e ]]; then return ret fi -gopt=() -zparseopts -D -a gopt 1 2 V J - _tags messages || return 1 -if [[ "$1" = -r ]]; then - raw=yes - shift - format="$1" +if (( $+opth[-r] )); then + raw=yes format=$1 else zstyle -s ":completion:${curcontext}:messages" format format || zstyle -s ":completion:${curcontext}:descriptions" format format fi if [[ -n "$format$raw" ]]; then - [[ -z "$raw" ]] && zformat -F format "$format" "d:$1" "${(@)argv[2,-1]}" + [[ -z "$raw" ]] && zformat -Fq format "$format" "d:$1" "${(@)argv[2,-1]}" builtin compadd "$gopt[@]" -x "$format" _comp_mesg=yes fi diff --git a/Completion/Base/Utility/_arg_compile b/Completion/Base/Utility/_arg_compile deleted file mode 100644 index e37c869ee..000000000 --- a/Completion/Base/Utility/_arg_compile +++ /dev/null @@ -1,199 +0,0 @@ -#autoload - -# A simple compiler for _arguments descriptions. The first argument of -# _arg_compile is the name of an array parameter in which the parse is -# returned. The remaining arguments form a series of `phrases'. Each -# `phrase' begins with one of the keywords "argument", "option", or "help" -# and consists of a series of keywords and/or values. The syntax is as -# free-form as possible, but "argument" phrases generally must appear in -# the same relative position as the corresponding argument on the command -# line to be completed, and there are some restrictions on ordering of -# keywords and values within each phrase. -# -# Anything appearing before the first phrase or after the last is passed -# through verbatim. (See TODO.) If more detailed mixing of compiled and -# uncompiled fragments is necessary, use two or more calls, either with -# different array names or by passing the output of each previous call -# through the next. -# -# In the documentation below, brackets [ ] indicate optional elements and -# braces { } indicate elements that may be repeated zero or more times. -# Except as noted, bracketed or braced elements may appear in any order -# relative to each other, but tokens within each element are ordered. -# -# argument [POS] [means MSG] [action ACT] -# -# POS may be an integer N for the Nth argument or "*" for all, and -# must appear first if it appears at all. -# MSG is a string to be displayed above the matches in a listing. -# ACT is (currently) as described in the compsys manual. -# -# option OPT [follow HOW] [explain STR] {unless XOR} \ -# {[means MSG] [action ACT]} [through PAT [means MSG] [action ACT]] -# -# OPT is the option, prefixed with "*" if it may appear more than once. -# HOW refers to a following argument, and may be one of: -# "close" must appear in the same word (synonyms "join" or "-") -# "next" the argument must appear in the next word (aka "split") -# "loose" the argument may appear in the same or the next word ("+") -# "assign" as loose, but must follow an "=" in the same word ("=") -# HOW should be suffixed with a colon if the following argument is -# _not_ required to appear. -# STR is to be displayed based on style `description' -# XOR is another option in combination with which OPT may not appear. -# It may be ":" to disable non-option completions when OPT is present. -# MSG is a string to be displayed above the matches in a listing. -# ACT is (currently) as described in the compsys manual. -# PAT is either "*" for "all remaining words on the line" or a pattern -# that, if matched, marks the end of the arguments of this option. -# The "through PAT ..." description must be the last. -# PAT may be suffixed with one colon to narrow the $words array to -# the remainder of the command line, or with two colons to narrow -# to the words before (not including) the next that matches PAT. -# -# help PAT [means MSG] action ACT -# -# ACT is applied to any option output by --help that matches PAT. -# Do not use "help" with commands that do not support --help. -# PAT may be suffixed with a colon if the following argument is -# _not_ required to appear (this is usually inferred from --help). -# MSG is a string to be displayed above the matches in a listing. - -# EXAMPLE: -# This is from _gprof in the standard distribution. Note that because of -# the brace expansion trick used in the "function name" case, no attempt -# is made to use `phrase' form; that part gets passed through unchanged. -# It could simply be moved to the _arguments call ahead of "$args[@]". -# -# _arg_compile args -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \ -# -{A,C,e,E,f,F,J,n,N,O,p,P,q,Q,Z}:'function name:->funcs' \ -# option -I means directory action _dir_list \ -# option -d follow close means "debug level" \ -# option -k means "function names" action '->pair' \ -# option -m means "minimum execution count" \ -# argument means executable action '_files -g \*\(-\*\)' \ -# argument means "profile file" action '_files -g gmon.\*' \ -# help '*=name*' means "function name" action '->funcs' \ -# help '*=dirs*' means "directory" action _dir_list -# _arguments "$args[@]" - -# TODO: -# Verbose forms of various actions, e.g. (but not exactly) -# "state foo" becomes "->foo" -# "completion X explain Y ..." becomes "((X\:Y ...))" -# etc. -# Represent leading "*" in OPT some other way. -# Represent trailing colons in HOW and PAT some other way. -# Stricter syntax checking on HOW, sanity checks on XOR. -# Something less obscure than "unless :" would be nice. -# Warning or other syntax check for stuff after the last phrase. - -emulate -L zsh -local -h argspec dspec helpspec prelude xor -local -h -A amap dmap safe - -[[ -n "$1" ]] || return 1 -[[ ${(tP)${1}} = *-local ]] && { print -R NAME CONFLICT: $1 1>&2; return 1 } -safe[reply]="$1"; shift - -# First consume and save anything before the argument phrases - -helpspec=() -prelude=() - -while (($#)) -do - case $1 in - (argument|help|option) break;; - (*) prelude=("$prelude[@]" "$1"); shift;; - esac -done - -# Consume all the argument phrases and build the argspec array - -while (($#)) -do - amap=() - dspec=() - case $1 in - - # argument [POS] [means MSG] [action ACT] - (argument) - shift - while (($#)) - do - case $1 in - (<1->|\*) amap[position]="$1"; shift;; - (means|action) amap[$1]="$2"; shift 2;; - (argument|option|help) break;; - (*) print -R SYNTAX ERROR at "$@" 1>&2; return 1;; - esac - done - if (( $#amap )) - then - argspec=("$argspec[@]" "${amap[position]}:${amap[means]}:${amap[action]}") - fi;; - - # option OPT [follow HOW] [explain STR] {unless XOR} \ - # {[through PAT] [means MSG] [action ACT]} - (option) - amap[option]="$2"; shift 2 - dmap=() - xor=() - while (( $# )) - do - (( ${+amap[$1]} || ${+dmap[through]} )) && break; - case $1 in - (follow) - amap[follow]="${2:s/join/-/:s/close/-/:s/next//:s/split//:s/loose/+/:s/assign/=/:s/none//}" - shift 2;; - (explain) amap[explain]="[$2]" ; shift 2;; - (unless) xor=("$xor[@]" "${(@)=2}"); shift 2;; - (through|means|action) - while (( $# )) - do - (( ${+dmap[$1]} )) && break 2 - case $1 in - (through|means|action) dmap[$1]=":${2}"; shift 2;; - (argument|option|help|follow|explain|unless) break;; - (*) print -R SYNTAX ERROR at "$@" 1>&2; return 1;; - esac - done;; - (argument|option|help) break;; - (*) print -R SYNTAX ERROR at "$@" 1>&2; return 1;; - esac - if (( $#dmap )) - then - dspec=("$dspec[@]" "${dmap[through]}${dmap[means]:-:}${dmap[action]:-:}") - fi - done - if (( $#amap )) - then - argspec=("$argspec[@]" "${xor:+($xor)}${amap[option]}${amap[follow]}${amap[explain]}${dspec}") - fi;; - - # help PAT [means MSG] action ACT - (help) - amap[pattern]="$2"; shift 2 - while (($#)) - do - (( ${+amap[$1]} )) && break; - case $1 in - (means|action) amap[$1]="$2"; shift 2;; - (argument|option|help) break;; - (*) print -R SYNTAX ERROR at "$@" 1>&2; return 1;; - esac - done - if (( $#amap )) - then - helpspec=("$helpspec[@]" "${amap[pattern]}:${amap[means]}:${amap[action]}") - fi;; - (*) break;; - esac -done - -eval $safe[reply]'=( "${prelude[@]}" "${argspec[@]}" ${helpspec:+"-- ${helpspec[@]}"} "$@" )' - -# print -R _arguments "${prelude[@]:q}" "${argspec[@]:q}" ${helpspec:+"-- ${helpspec[@]:q}"} "$@:q" - -return 0 diff --git a/Completion/Base/Utility/_call_program b/Completion/Base/Utility/_call_program index 55712b04b..38bcede0b 100644 --- a/Completion/Base/Utility/_call_program +++ b/Completion/Base/Utility/_call_program @@ -1,19 +1,30 @@ #autoload +X local -xi COLUMNS=999 -local curcontext="${curcontext}" tmp err_fd=-1 clocale='_comp_locale;' -local -a prefix +local curcontext="${curcontext}" tmp ssb sse err_fd=-1 clocale='_comp_locale;' +local -a prefix args +local -A opth -if [[ "$1" = -p ]]; then - shift - if (( $#_comp_priv_prefix )); then - curcontext="${curcontext%:*}/${${(@M)_comp_priv_prefix:#^*[^\\]=*}[1]}:" - zstyle -t ":completion:${curcontext}:${1}" gain-privileges && - prefix=( $_comp_priv_prefix ) - fi -elif [[ "$1" = -l ]]; then - shift - clocale='' +zparseopts -A opth -D -F - l p q Q || return + +(( $+opth[-l] )) && clocale= + +# function authors might be tempted to run this in ${ ... }. but doing so will +# wreck the user's locale. force a sub-shell if necessary to avoid this +(( $+opth[-l] || ZSH_SUBSHELL )) || ssb='(' sse=')' + +(( $+opth[-p] && $#_comp_priv_prefix )) && { + curcontext="${curcontext%:*}/${${(@M)_comp_priv_prefix:#^*[^\\]=*}[1]}:" + zstyle -t ":completion:${curcontext}:${1}" gain-privileges && + prefix=( $_comp_priv_prefix ) +} + +if (( $+opth[-q] )); then + args=( "${(@q+)argv[2,-1]}" ) +elif (( $+opth[-Q] )); then + args=( "$2" "${(@q+)argv[3,-1]}" ) +else + args=( "${(@)argv[2,-1]}" ) fi if (( ${debug_fd:--1} > 2 )) || [[ ! -t 2 ]] @@ -25,12 +36,12 @@ fi if zstyle -s ":completion:${curcontext}:${1}" command tmp; then if [[ "$tmp" = -* ]]; then - eval $clocale "$tmp[2,-1]" "$argv[2,-1]" + eval $ssb $clocale "$tmp[2,-1]" "${(@)args}" $sse else - eval $clocale $prefix "$tmp" + eval $ssb $clocale $prefix "$tmp" $sse fi else - eval $clocale $prefix "$argv[2,-1]" + eval $ssb $clocale $prefix "${(@)args}" $sse fi 2>&$err_fd } always { diff --git a/Completion/Base/Utility/_numbers b/Completion/Base/Utility/_numbers index 9148fea13..8fd2e1d7e 100644 --- a/Completion/Base/Utility/_numbers +++ b/Completion/Base/Utility/_numbers @@ -37,13 +37,15 @@ # _description is called with the x token set to make the completed # list of suffixes available to the normal format style -local desc tag range suffixes suffix suffixfmt pat='<->' partial='' +local MATCH MBEGIN MEND +local desc tag range suffixes suffix suffixfmt pad pat='<->' partial='' local -a expl formats local -a default max min keep tags units local -i i local -A opts -zparseopts -K -D -A opts M+:=keep q:=keep s+:=keep S+:=keep J+: V+: 1 2 o+: n F: x+: X+: \ +zparseopts -K -D -A opts \ + {M+:,q+,r+:,R+:,s+:,S+:}=keep J+: V+: 1 2 o+: n F: x+: X+: \ t:=tags u:=units l:=min m:=max d:=default f=type e=type N=type desc="${1:-number}" tag="${tags[2]:-numbers}" @@ -56,7 +58,9 @@ desc="${1:-number}" tag="${tags[2]:-numbers}" if (( $#argv )) && compset -P "$pat"; then zstyle -s ":completion:${curcontext}:units" list-separator sep || sep=-- _description -V units expl unit - disp=( ${${argv#:}/:/ $sep } ) + pad=${#${(O)${${argv%%:*}//?/.}}[1]} # length of longest suffix + disp=( ${${argv#:}/(#m)[^:]##/${(pr<$pad>< >)MATCH}} ) # pad suffixes + disp=( ${disp/:/ $sep } ) compadd -M 'r:|/=* r:|=*' -d disp "$keep[@]" "$expl[@]" - ${${argv#:}%%:*} return elif [[ -prefix $~pat || $PREFIX = $~partial ]]; then @@ -70,12 +74,13 @@ elif [[ -prefix $~pat || $PREFIX = $~partial ]]; then zstyle -s ":completion:${curcontext}:unit-suffixes" format suffixfmt || \ suffixfmt='%(d.%U.)%x%(d.%u.)%(r..|)' for ((i=0;i<$#;i++)); do - zformat -f suffix "$suffixfmt" "x:${${${argv[i+1]#:}%%:*}//\%/%%}" \ - "X:${${${argv[i+1]#:}#*:}//\%/%%}" "d:${#${argv[i+1]}[1]#:}" \ + zformat -fq suffix "$suffixfmt" "x:${${argv[i+1]#:}%%:*}" \ + "X:${${argv[i+1]#:}#*:}" "d:${#${argv[i+1]}[1]#:}" \ i:i r:$(( $# - i - 1)) suffixes+=$suffix done - [[ -n $suffixes ]] && formats+=( x:$suffixes ) + # don't quote %x so we can pass formatting through + [[ -n $suffixes ]] && formats+=( %%x:$suffixes ) _comp_mesg=yes _description -x $tag expl "$desc" $formats diff --git a/Completion/Base/Utility/_phony b/Completion/Base/Utility/_phony new file mode 100644 index 000000000..1d53a2ecf --- /dev/null +++ b/Completion/Base/Utility/_phony @@ -0,0 +1,51 @@ +#autoload + +# Mix literal matches in with those produced by another function. +# This is useful where certain phony values, like "all", "any" or +# "none" are permitted alongside the real matches. + +# _phony [compadd options] [word] [words... --] [ _function [args] ] +# -a, -k, -l and -d options are the same as for compadd but are not +# passed on to the child function +# -E is only used once (last) +# -A and -O results merged as if compadd was used once only + +local curcontext="$curcontext" minus +local -i minus strip nm skip ret=1 +local -a phony opts cont amerge omerge phony_amat phony_omat last + +zparseopts -D -a opts a=phony k=phony d:=phony l=phony \ + n F: p: i: P: I: e f s: S: q r: R: M+: J+: V+: 1 2 o+: X+: x+: D: \ + A+:=amerge O+:=omerge \ + E:=last + +if (( $argv[(I)--] )); then + (( strip = $argv[(i)--] )) + phony+=( "${(@)argv[1,strip-1]}" ) + shift $strip +else + phony+=( "$argv[1]" ) + shift +fi + +if (( ! $# )); then # no function passed + opts=( ${opts:/-X/-x} ) + skip=1 +else + (( minus = argv[(ib:2:)-] )) + (( minus > $# )) && minus=2 && argv[1]+=( - ) + argv[minus]=( "$opts[@]" ${=amerge:+-A phony_amat} ${=omerge:+-O phony_omat} "$last[@]" ) +fi + +compadd "$opts[@]" "$amerge[@]" "$omerge[@]" "$phony[@]" && ret=0 +nm=$compstate[nmatches] +if (( skip )) || "$@" || [[ -n "$_comp_mesg" ]]; then + [[ ret -eq 0 && compstate[nmatches] -eq nm && -z "$PREFIX$SUFFIX" ]] && + compstate[insert]='' + ret=0 +fi + +(( $+amerge[2] )) && set -A ${amerge[2]} "${(@P)amerge[2]}" "$phony_amat[@]" +(( $+omerge[2] )) && set -A ${omerge[2]} "${(@P)omerge[2]}" "$phony_omat[@]" + +return ret diff --git a/Completion/Darwin/Command/_fink b/Completion/Darwin/Command/_fink index 04a067ec1..258e4ecee 100644 --- a/Completion/Darwin/Command/_fink +++ b/Completion/Darwin/Command/_fink @@ -123,7 +123,7 @@ _fink(){ '(-s --section)'{-s=,--section=}'[sections]:section name' \ '(-m --maintainer)'{-m=,--maintainer=}'[maintainer]:maintainer name' \ --tree='[tree]:tree name' \ - '(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \ + '(-w --width)'{-w=,--width=}'[width of display]:number:_phony auto' \ '(1 : -)'{-h,--help}'[display help text]' \ '1: :->pkgs' && return 0 @@ -134,7 +134,7 @@ _fink(){ apropos) _arguments \ '(-t --tab)'{-t,--tab}'[output the list with tabs as field delimiter]' \ - '(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \ + '(-w --width)'{-w=,--width=}'[width of display]:number:_phony auto' \ '(1 : -)'{-h,--help}'[display help text]' \ '1: :->pkgs' && return diff --git a/Completion/Darwin/Command/_nettop b/Completion/Darwin/Command/_nettop index 128b102e4..379afffe6 100644 --- a/Completion/Darwin/Command/_nettop +++ b/Completion/Darwin/Command/_nettop @@ -6,7 +6,7 @@ typeset -A opt_args local msg='number of samples (0=infinite)' local specs=( '-m+[specify the mode]:mode:(tcp udp route)' - '*-t+[specify interface type]:interface type:(wifi wired loopback owdl expensive undefined external)' + '*-t+[specify interface type]:interface type:(wifi wired loopback awdl expensive undefined external)' '-n[disable address to name resolution]' '-c[less intensive use of the CPU]' '-d[delta mode]' diff --git a/Completion/Darwin/Command/_open b/Completion/Darwin/Command/_open index 1c693dfb8..079dd2987 100644 --- a/Completion/Darwin/Command/_open +++ b/Completion/Darwin/Command/_open @@ -4,8 +4,6 @@ # - open(1) says that -f opens the result in the default text editor. This is # not true; the result is always opened in TextEdit unless another option is # supplied to override it -# - We no longer try to restrict files to those associated with the specified -# app; this was a nice idea, but it's unreliable _open_absolute_application_path() { local expl curcontext @@ -17,28 +15,31 @@ _open_absolute_application_path() { _open() { local curcontext=$curcontext ret=1 local -a context expl line state state_descr tmp - local -A opt_args val_args + local -A opt_args # No +, and no -S (--args covers that) - _arguments -s -C : \ + _arguments -0 -s -C : \ '(-a -b -e -f -R -t)-a+[specify application name]: :->applications' \ - '(: * -)--args[pass remaining arguments to application]:*:::argument' \ + '--arch[open with specified CPU architecture/subtype]:architecture (or type/subtype):( + any arm arm64 arm64e arm64_32 x86_64 x86_64h i386 + )' \ + '(: * -)--args[pass remaining arguments to application]:*::: :->arguments' \ '(-a -b -e -f -R -t)-b+[specify application bundle identifier]: :->bundle-ids' \ '(-a -b -e -f -R -t)-e[open with TextEdit]' \ - '*--env[add the environment variable of the launched application]:env_var=value:_parameters -g "*export*" -qS=' \ + '*--env[export specified environment variable]:name=value:_parameters -g "*export*" -qS=' \ '(-h)-f[open standard input with TextEdit or specified application]' \ '(-R)-F[open application with fresh state]' \ '(-j)-g[do not bring application to foreground]' \ '(-f)-h[open library header file]' \ - '(-g)-j[launch the app hidden]' \ + '(-g)-j[open application hidden]' \ '(-R)-n[always open new instance of application]' \ '(-a -b -e -f -F -n -s -t -W --args)-R[reveal in Finder]' \ - '(-R)-s+[specify SDK name/version]: :->sdks' \ - '--stdin[launch the application with stdin connected to the given file]:file:_files' \ - '--stdout[launch the application with stdout connected to the given file]:file:_files' \ - '--stderr[launch the application with stderr connected to the given file]:file:_files' \ + '(-R)-s+[specify SDK name/version (with -h)]: :->sdks' \ + '--stdin[open application with stdin connected to specified file]:stdin file:_files' \ + '--stdout[open application with stdout connected to specified file]:stdout file:_files' \ + '--stderr[open application with stderr connected to specified file]:stderr file:_files' \ '(-a -b -e -f -R -t)-t[open with default text editor]' \ - '-u[open URL with whatever application claims the url scheme]:url:_urls' \ + '-u+[open specified URL]: :_urls' \ '(-R)-W[wait for application to exit]' \ '(-f)*: :->files' \ && ret=0 @@ -53,20 +54,73 @@ _open() { bundle-ids) autoload -Uz zargs _retrieve_mac_apps - tmp=( ${(@)_mac_apps:#/System/Library/(Private|)Frameworks/*} ) + tmp=( $_mac_apps ) tmp=( ${(0)"$( _call_program bundle-ids \ zargs -n300 -P2 -- ${(@q)tmp} -- mdls -rn kMDItemCFBundleIdentifier )"} ) - tmp=( ${(@)tmp:#\(null\)} ) - _values 'bundle identifier' $tmp com.apple.TextEdit && ret=0 + tmp=( ${(@)tmp:#\(null\)} com.apple.TextEdit ) + _describe -t bundle-identifier 'bundle identifier' tmp && ret=0 + ;; + arguments) + local app exe + + _retrieve_mac_apps + + # resolve bundle id or app name to path + if (( $+opt_args[-b] )); then + app=$( + # 'c' suffix means case-insensitive + _call_program -q bundle-identifier-app \ + mdfind "kMDItemCFBundleIdentifier == ${(qq)${(Q)opt_args[-b]}}c" + ) + elif [[ ${(Q)opt_args[-a]} == */* ]]; then + app=${(Q)opt_args[-a]} + elif (( $+opt_args[-a] )); then + tmp=( ${(M)_mac_apps:#*/${(Q)opt_args[-a]%.app}.app} ) + (( $#tmp )) || tmp=( ${(M)_mac_apps:#*/${(Q)opt_args[-a]}} ) + app=$tmp[1] + fi + + # find actual executable for app + [[ -n $app ]] && { + # plutil prints errors to stdout, so we need to check the return status + exe=$( + _call_program -q bundle-executable \ + plutil -extract CFBundleExecutable raw -- $app/Contents/Info.plist + ) || exe= + [[ ${exe:-/} == /* ]] || exe=$app/Contents/MacOS/$exe + } + + if [[ -n $exe ]]; then + # many applications use the same name for their executable as for the + # app itself (including capitalisation and spaces). this usually isn't + # compdef'd. but sometimes there is a linux equivalent that is -- e.g. + # instead of 'Google Chrome' we might have 'google-chrome'. try to find + # one of these + for 1 in ${exe:t} ${${(L)exe:t}// /-} ${(L)exe:t} ${${exe:t}// /-}; do + (( $+_comps[$1] )) || continue + exe=${exe:h}/$1 && break + done + # if we still didn't find something, try the kebab-case form anyway, + # maybe it will match a -P pattern + (( $+_comps[${exe:t}] )) || exe=${exe:h}/${${(L)exe:t}// /-} + words=( $exe "${(@)words}" ) + (( CURRENT++ )) + _normal && ret=0 + else + _default && ret=0 + fi ;; files) if (( $+opt_args[-h] )); then tmp=( - /System/Library/Frameworks/*/Headers/*.h(#q-.N:t) - /usr/local/include/**/*.h(#q-.N:t) + # found via `strings =open | rg -C2 /` + ~/Library/(|Private)Frameworks/*/(|Private)Headers/*.h(#q-.N:t) + /Library/(|Private)Frameworks/*/(|Private)Headers/*.h(#q-.N:t) + /System/Library/(|Private)Frameworks/*/(|Private)Headers/*.h(#q-.N:t) /usr/include/**/*.h(#q-.N:t) + /usr/local/include/**/*.h(#q-.N:t) ) _describe -t headers 'header file' tmp && ret=0 else @@ -75,11 +129,7 @@ _open() { ;; sdks) tmp=( /Library/Developer/CommandLineTools/SDKs/*.*.sdk(#qN:t:r) ) - if (( $#tmp )); then - _describe -t sdks 'SDK name/version' tmp && ret=0 - else - _message -e sdks 'SDK name/version' && ret=0 - fi + _describe -t sdks 'SDK name/version' tmp && ret=0 ;; esac diff --git a/Completion/Darwin/Type/_mac_files_for_application b/Completion/Darwin/Type/_mac_files_for_application deleted file mode 100644 index 885b064fe..000000000 --- a/Completion/Darwin/Type/_mac_files_for_application +++ /dev/null @@ -1,74 +0,0 @@ -#autoload - -_mac_rsrc_check() { - [[ ! -s "$REPLY/..namedfork/rsrc" ]] && return 1 - if [[ -x /Developer/Tools/GetFileInfo ]]; then - local ftype="$(command /Developer/Tools/GetFileInfo -t $REPLY)" - ftype="${ftype//\"/}" - [[ -n "$types[(r)$ftype]" ]] - else - grep --quiet "\(${(j/\|/)types}\)" "$REPLY/..namedfork/rsrc" - fi -} - -_mac_parse_info_plist() { - # For now, awk is used because builtin function "read" was too slow. - # '<' is used for the delimiter because some Info.plist files use CR as - # newline but read doesn't treat them as so - local s=' - BEGIN { RS="<" } - /^key>/ { sub(/key>/, ""); reading_key=$0 } - /^string>/ { - sub(/string>/, "") - if (reading_key == "CFBundleTypeExtensions") exts=exts " \"" $0 "\"" - if (reading_key == "CFBundleTypeOSTypes") types=types " \"" $0 "\"" - } - END { - print "exts=(" exts ")\ntypes=(" types ")" - } - ' - command awk $s "$app_path/Contents/Info.plist" | while read; do - eval "$REPLY" - done -} - -# Try to complete files for the specified application. -_mac_files_for_application() { - local -a opts - 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 - app_path="${_mac_apps[(r)*/$1(|.app)]:-$1}" - - local -a glob_patterns - glob_patterns=() - - # 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 - - if [[ -n "$exts[(r)\*]" ]]; then - glob_patterns=( "*" ) - else - if (( #exts != 0 )); then - glob_patterns+=( "*.(${(j/|/)exts})(N)" ) - fi - - if (( #types != 0 )); then - glob_patterns+=( "^*.[[:alnum:]]##(.Ne:_mac_rsrc_check:)" ) - fi - fi - else - glob_patterns=( "*" ) - fi - - case ${#glob_patterns} in - 0) return 1 ;; - 1) _files "$opts[@]" -g "$glob_patterns[1]" ;; - *) _files "$opts[@]" -g "{${(j/,/)glob_patterns}}" ;; - esac -} - -_mac_files_for_application "$@" diff --git a/Completion/Darwin/Type/_retrieve_mac_apps b/Completion/Darwin/Type/_retrieve_mac_apps index 655170d3a..8cfc3810e 100644 --- a/Completion/Darwin/Type/_retrieve_mac_apps +++ b/Completion/Darwin/Type/_retrieve_mac_apps @@ -17,7 +17,7 @@ _mac_apps_caching_policy () { # Paths to applications are stored in _mac_apps. _mac_apps_spotlight_retrieve () { - typeset mdfind_query="kMDItemContentType == 'com.apple.application-*'" + typeset mdfind_query="kMDItemContentType == 'com.apple.application-bundle'" for i in ${app_dir_root}; do _mac_apps+=(${(f)"$(_call_program command \ @@ -102,6 +102,19 @@ _retrieve_mac_apps() { typeset -g -Ua _mac_apps $retrieve + # filter out some false positives + local -a ign_pats=( + '/Library/Apple/System/Library/(|Private)Frameworks/*' + '/Library/Developer/CommandLineTools/*' + '/Library/Image Capture/*' + '/Library/PrivilegedHelperTools/*' + '/System/Library/(|Private)Frameworks/*' + # firefox garbage + '/Users/*/Library/Application Support/*/Profiles/*/storage/*' + '/Users/*/Library/HTTPStorages/*' + ) + _mac_apps=( ${_mac_apps:#(${(j<|>)~ign_pats})} ) + _store_cache Mac_applications _mac_apps fi } diff --git a/Completion/Debian/Command/_apt b/Completion/Debian/Command/_apt index ac3095a4d..01d8282d1 100644 --- a/Completion/Debian/Command/_apt +++ b/Completion/Debian/Command/_apt @@ -492,12 +492,15 @@ _apt-get () { -d,--download-only:bool \ -f,--fix-broken:bool \ -h,--help:bool \ + --assume-no:bool \ + -a,--host-architecture:bool \ + -P,--build-profiles:bool \ -m,--ignore-missing,--fix-missing:bool \ -o,--option:arbitem \ -q,--quiet,--silent:intlevel \ -s,--simulate,--just-print,--dry-run,--recon,--no-act:bool \ -t,--target-release,--default-release:release \ - -u,--show-upgraded:bool \ + --no-show-upgraded:bool \ -v,--version:bool \ -y,--yes,--assume-yes:bool \ --allow-change-held-packages:bool \ @@ -515,6 +518,7 @@ _apt-get () { --no-download:bool \ --no-install-recommends:bool \ --no-remove:bool \ + --install-suggests:bool \ --no-upgrade:bool \ --only-source:bool \ --only-upgrade:bool \ diff --git a/Completion/Debian/Command/_auto-apt b/Completion/Debian/Command/_auto-apt deleted file mode 100644 index 2e6dccbc1..000000000 --- a/Completion/Debian/Command/_auto-apt +++ /dev/null @@ -1,31 +0,0 @@ -#compdef auto-apt - -local expl prev="$words[CURRENT-1]" - -# if there is a command in arguments ? -if [[ -n $words[(r)(run|update|update-local|merge|del|check|list|search|debuilt|status)] ]] ; then - - # yes, add completion for command arguments and command options - if [[ -n $words[(r)(update|update-local|merge)] && "$words[CURRENT]" = -* ]] ; then - _wanted option expl 'option' compadd - "-a" && return; - fi - - if [[ -n $words[(r)(check|list|search)] && "$words[CURRENT]" = -* ]] ; then - _wanted option expl 'option' compadd - "-v" "-f" && return; - fi - - case $prev in - run) _wanted command expl 'command' _files -g '*(/,*)' && return ;; - del) _wanted package expl 'package' _deb_packages avail && return ;; - esac -else - _arguments \ - '-a:distribution:_values -s , distribution main contrib non-free non-US none' \ - '-p:hook:_values -s , hook exec open access stat none' \ - '-D:dbfile:_files' \ - '-F:filedb:_files' \ - -h -s -y -q -i -X -x -L \ - '*:command:(run update update-local merge del check list search debuild status)' && return -fi - -return 1 diff --git a/Completion/Debian/Command/_dak b/Completion/Debian/Command/_dak index 9976c7371..0c1d82f84 100644 --- a/Completion/Debian/Command/_dak +++ b/Completion/Debian/Command/_dak @@ -37,7 +37,7 @@ case $cmd in '(-n --no-action)'{-n,--no-action}'[do not do anything]' '(-s --suite)'{-s,--suite=}':suite:_values -s , "suite list" oldstable stable testing unstable experimental' ':package:_deb_packages avail' - ':section:(admin base comm contrib/admin contrib/comm contrib/devel contrib/doc contrib/games contrib/graphics contrib/interpreters contrib/kde contrib/libdevel contrib/libs contrib/mail contrib/math contrib/misc contrib/net contrib/otherosfs contrib/perl contrib/python contrib/science contrib/sound contrib/tex contrib/text contrib/utils contrib/web contrib/x11 devel doc editors electronics embedded games gnome graphics hamradio interpreters kde libdevel libs mail math misc net news non-free/admin non-free/base non-free/comm non-free/devel non-free/doc non-free/editors non-free/electronics non-free/games non-free/graphics non-free/hamradio non-free/libdevel non-free/libs non-free/mail non-free/math non-free/misc non-free/net non-free/news non-free/otherosfs non-free/python non-free/science non-free/sound non-free/tex non-free/text non-free/utils non-free/web non-free/x11 oldlibs otherosfs perl python science shells sound tex text utils web x11)' + ':section:({,contrib/,non-free/}{admin,cli-mono,comm,database,debug,devel,doc,editors,education,electronics,embedded,fonts,games,gnome,gnu-r,gnustep,graphics,hamradio,haskell,httpd,interpreters,introspection,java,javascript,kde,kernel,libdevel,libs,lisp,localization,mail,math,metapackages,misc,net,news,ocaml,oldlibs,otherosfs,perl,php,python,ruby,rust,science,shells,sound,tex,text,utils,vcs,video,web,x11,xfce,zope})' ':priority:(extra important optional required standard)' ) ;; diff --git a/Completion/Debian/Command/_debfoster b/Completion/Debian/Command/_debfoster index 08a1078e2..3e2231d73 100644 --- a/Completion/Debian/Command/_debfoster +++ b/Completion/Debian/Command/_debfoster @@ -44,10 +44,13 @@ if [[ -n "$state" ]]; then ;; *(#i)(no|)keepsections*) _wanted values expl 'section' compadd \ - x11 web utils text tex sound shells science \ - otherosfs oldlibs news net misc math mail libs \ - interpreters hamradio graphics games electronics \ - editors doc devel comm base admin && ret=0 + zope xfce x11 web video vcs utils text tex sound shells \ + science rust ruby python php perl otherosfs oldlibs ocaml \ + news net misc metapackages math mail localization lisp libs \ + libdevel kernel kde javascript java introspection \ + interpreters httpd haskell hamradio graphics gnustep gnu-r \ + gnome games fonts embedded electronics education editors doc \ + devel debug database comm cli-mono admin && ret=0 ;; *(#i)guessdepends*) _wanted values expl 'name extension' \ diff --git a/Completion/Debian/Command/_dpkg_source b/Completion/Debian/Command/_dpkg_source index eabe8bc33..379ad39a7 100644 --- a/Completion/Debian/Command/_dpkg_source +++ b/Completion/Debian/Command/_dpkg_source @@ -1,16 +1,32 @@ #compdef dpkg-source _arguments \ - '-x[specify source file]:Debian source file:_files -g "*.dsc(-.)"' \ - '-b[specify source directory]:Debian source directory:_files -/' \ + '(-x --extract)'{-x,--extract}'[specify source file]:Debian source file:_files -g "*.dsc(-.)"::output directory:_directories' \ + '(-b --build)'{-b,--build}'[specify source directory]:Debian source directory:_files -/' \ + '--print-format[print the format to be used for the source package]: :_directories' \ + '--before-build[run the corresponding source package format hook]: :_directories' \ + '--after-build[run the corresponding source package format hook]: :_directories' \ + '--commit[store upstream changes in a new patch]: :_directories::patch name' \ '-c-[control file]:control file:_files' \ '-l-[changelog file]:changelog file:_files' \ '-F-[changelog format]:changelog format:' \ + '--format=[set the format to be used for the source package]:format' \ '-V-[set substitutions variable]:expression:' \ '-T-[alternate variable file]:varlistfile:' \ '-D-[override dsc field]:expression:' \ '-U-[remove a field]:field:' \ - '-i-[ignore files in diff]:filter:' \ + '(-i --diff-ignore)'{-i-,--diff-ignore=}'[filter out files to ignore diffs of]:regex' \ + '--extend-diff-ignore=:regex' \ + '(-I --tar-ignore)'{-I-,--tar-ignore=}'[filter out files when building tarballs]:regex' \ + '(-Z --compression)'{-Z-,--compression=}'[select compression to use]:compression [xz]:(bzip2 gzip lzma xz)' \ + '(-z --compression-level)'{-z-,--compression-level=}'[compression level to use]:level [9]' \ + "--no-copy[don't copy .orig tarballs]" \ + "--no-check[don't check signature and checksums before unpacking]" \ + "--no-overwrite-dir[don't overwrite directory on extraction]" \ + "--require-valid-signature[abort if the package doesn't have a valid signature]" \ + '--require-strong-checksums[abort if the package contains no strong checksums]' \ + '--ignore-bad-version[allow bad source package versions]' \ + '--threads-max=[set maximum number of threads for compressors]:threads' \ '-sa[autoselect orig source]' \ '-sk[use packaged orig source - unpack and keep]' \ '-sp[use packaged orig source - unpack and remove]' \ @@ -19,10 +35,14 @@ _arguments \ '-ss[trust packed and unpacked source are the same]' \ '-sn[no diff, do main tarfile only]' \ '-sA[autoselect orig source with overwrite]' \ + '--abort-on-upstream-changes' \ '-sK[use packaged orig source - unpack and keep with overwrite]' \ '-sP[use packaged orig source - unpack and remove with overwrite]' \ '-sU[use unpackaged orig source - unpack and keep with overwrite]' \ '-sR[use unpackaged orig source - unpack and remove with overwrite]' \ '-sp[leave original source packed in cwd]' \ '-su[unpack original source tree too]' \ - '-h[help]' + "--skip-debianization[don't apply debian diff to upstream sources]" \ + '(-)'{-\?,--help}'[display help information]' \ + '-q[quiet mode]' \ + '--version[display version information]' diff --git a/Completion/Debian/Command/_git-buildpackage b/Completion/Debian/Command/_git-buildpackage deleted file mode 100644 index 81bf7dac9..000000000 --- a/Completion/Debian/Command/_git-buildpackage +++ /dev/null @@ -1,43 +0,0 @@ -#compdef git-buildpackage -#description build Debian packages from a git repository - -_arguments \ - '--version[show program version number and exit]' \ - '--help[show help message and exit]' \ - '--git-ignore-new[build with uncommitted changes in the source tree]' \ - '--git-no-ignore-new[negates --git-ignore-new]' \ - '--git-verbose[verbose command execution]' \ - '--git-tag[create a tag after a successful build]' \ - '--git-tag-only[do not build, only tag and run the posttag hook]' \ - '--git-retag[do not fail if the tag already exists]' \ - '--git-sign-tags[sign tags]' \ - '--git-no-sign-tags[negates --git-sign-tags]' \ - '--git-keyid=-[GPG keyid to sign tags with]:GPG key:' \ - '--git-debian-tag=-[format string for debian tags]:format string [debian/%%(version)s]' \ - '--git-upstream-tag=-[format string for upstream tags]:format string [upstream/%%(version)s]' \ - '--git-pristine-tar[use pristine-tar to create .orig.tar.gz]' \ - '--git-no-pristine-tar[negates --git-pristine-tar]' \ - '--git-force-create[force creation of orig.tar.gz]' \ - '--git-no-create-orig[do not create orig.tar.gz]' \ - '--git-tarball-dir=-[location to look for external tarballs]:tarball directory:_files -/' \ - '--git-compression=-[compression type]:compression type [auto]:(auto gzip bzip2 lzma xz)' \ - '--git-compression-level=-[set compression level]:level:(1 2 3 4 5 6 7 8 9)' \ - '--git-upstream-branch=-[upstream branch]::' \ - '--git-debian-branch=-[branch the Debian package is being developed on]::' \ - '--git-ignore-branch[build although debian-branch != current branch]' \ - '--git-no-ignore-branch[negates --git-ignore-branch]' \ - '--git-builder=-[command to build the Debian package]:command:' \ - '--git-cleaner=-[command to clean the working copy]:command:' \ - '--git-prebuild=-[command to run before a build]:command:' \ - '--git-postbuild=-[hook run after a successful build]:command:' \ - '--git-posttag=-[hook run after a successful tag operation]:command:' \ - '--git-pbuilder[invoke git-pbuilder for building]' \ - '--git-no-pbuilder[negates --git-pbuilder]' \ - '--git-dist=-[build for this distribution when using git-pbuilder]:distribution:' \ - '--git-arch=-[build for this architecture when using git-pbuilder]:architecture:' \ - '--git-export-dir=-[before building the package export the source into this directory]:directory:_files -/' \ - '--git-export=-[export treeish object instead of HEAD]:treeish:' \ - '--git-dont-purge[retain exported package build directory]' \ - '--git-overlay[extract orig tarball when using export-dir option]' \ - '--git-no-overlay[negates --git-overlay]' \ - '*:other options:_dpkg-buildpackage' diff --git a/Completion/Debian/Command/_invoke-rc.d b/Completion/Debian/Command/_invoke-rc.d index cd8df28c1..74ee1e828 100644 --- a/Completion/Debian/Command/_invoke-rc.d +++ b/Completion/Debian/Command/_invoke-rc.d @@ -1,11 +1,13 @@ #compdef invoke-rc.d _arguments \ + '(- 1 2)--help[display help information]' \ '--quiet[quiet mode, no error messages are generated]' \ '--force[run the initscript regardless of policy and subsystem]' \ '--try-anyway[run the initscript even if a non-fatal error is found]' \ '--disclose-deny[return 101 instead of 0 if action is denied]' \ '--query[return one of status codes 100-106, does not run the script]' \ '--no-fallback[ignore any fallback action requests by the policy layer]' \ + '--skip-systemd-native[exit before doing anything if a systemd environment is detected]' \ '1:service:_services' \ - '2:command:(start stop force-stop restart reload force-reload status)' + '2:command:(start stop force-stop restart try-restart reload force-reload status)' diff --git a/Completion/Debian/Command/_module-assistant b/Completion/Debian/Command/_module-assistant index b2c1e56ee..27c06bc5b 100644 --- a/Completion/Debian/Command/_module-assistant +++ b/Completion/Debian/Command/_module-assistant @@ -20,7 +20,7 @@ _module_assistant_commands=( 'purge[clear cache and remove all binary packages of source package]' ) -_arguments -A \ +_arguments -s -S : \ '(-h --help)'{-h,--help}'[print help screen]' \ '(-v --verbose)'{-v,--verbose}'[be verbose, show full paths, etc.]' \ '(-q --quiet)'{-q,--quiet}'[the opposite of verbose]' \ @@ -34,4 +34,3 @@ _arguments -A \ '(-t --text-mode)'{-t,--text-mode}'[no progress bars]' \ '1:list of commands:_values -s , subcommands "${_module_assistant_commands[@]}"' \ '*:package: compadd /usr/src/modass/var_cache_modass/*.avail_version(N:t:r) /var/cache/modass/*.avail_version(N:t:r)' - diff --git a/Completion/Debian/Command/_update-alternatives b/Completion/Debian/Command/_update-alternatives index 31128dd82..0ddb8748d 100644 --- a/Completion/Debian/Command/_update-alternatives +++ b/Completion/Debian/Command/_update-alternatives @@ -14,8 +14,10 @@ _arguments -C \ '--test' \ '--help' \ '--version' \ - '--altdir:altdir:_files -/' \ - '--admindir:admindir:_files -/' \ + '--altdir:alternatives directory [/etc/alternatives]:_files -/' \ + "--admindir:administrative directory [$alterdir]:_files -/" \ + '--instdir:installation directory:_files -/' \ + '--root:root directory:_files -/' \ '--log:log file:_files -/' \ '--force' \ '--skip-auto' \ diff --git a/Completion/Debian/Command/_update-rc.d b/Completion/Debian/Command/_update-rc.d index 68b81dc72..d1941a384 100644 --- a/Completion/Debian/Command/_update-rc.d +++ b/Completion/Debian/Command/_update-rc.d @@ -3,26 +3,18 @@ local curcontext="$curcontext" state line expl _arguments -C \ - '-n[show actions without performing them]' \ '-f[force removal of symlinks]' \ '1:service:_services' \ - '2:command:(remove defaults start stop)' \ + '2:command:(remove defaults defaults-disabled disable enable)' \ '*::args:->args' && return case $words[2] in - defaults) - _message -e number 'sequence number' + disable|enable) + _wanted runlevels expl runlevel S 2 3 4 5 && return ;; - remove) + *) _message 'no more arguments' ;; - st*) - case ${words[CURRENT-1]} in - .) _wanted commands expl commands compadd start stop && return ;; - start|stop) _message -e number 'sequence number' ;; - *) _message -e runlevels run\ level ;; - esac - ;; esac return 1 diff --git a/Completion/Linux/Command/_blkid b/Completion/Linux/Command/_blkid index e31250d37..29392c4e5 100644 --- a/Completion/Linux/Command/_blkid +++ b/Completion/Linux/Command/_blkid @@ -19,10 +19,10 @@ _arguments \ '(-l --list-one)'{-l,--list-one}'[look up only first device with token specified by -t]' \ '(-n --match-types)'{-n+,--match-types=}'[filter by filesystem type]: :_sequence _file_systems' \ '(-O --offset)'{-O+,--offset=}'[probe at the given offset]: :_numbers -M "m\:{a-zA-Z}={A-Za-z}" offset {K,M,G,T,P,E,Z,Y}{,B,iB}' \ - '(-o --output)'{-o+,--output=}'[specify output format]:format [full]:(full value list device udev export)' \ + '(-o --output)'{-o+,--output=}'[specify output format]:format [full]:(full value list device udev export json)' \ '(-p --probe)'{-p,--probe}'[probe low-level superblocks]' \ \*{-s+,--match-tag=}'[show specified tag(s)]:tag:(none LABEL UUID UUID_SUB TYPE PARTLABEL PARTUUID SEC_TYPE PTUUID PTTYPE ALIGNMENT_OFFSET MINIMUM_IO_SIZE OPTIMAL_IO_SIZE PHYSICAL_SECTOR_SIZE LOGICAL_SECTOR_SIZE)' \ - '(-S --size)'{-S+,--size=}'[overwrite device size]: :_numbers -M "m\:{a-zA-Z}={A-Za-z}" size {K,M,G,T,P,E,Z,Y}{,B,iB}' \ + '(-S --size)'{-S+,--size=}'[override device size]: :_numbers -M "m\:{a-zA-Z}={A-Za-z}" size {K,M,G,T,P,E,Z,Y}{,B,iB}' \ '(-t --match-token)'{-t+,--match-token=}'[find device with a specific token]:token' \ '(-u --usages)'{-u+,--usages=}'[filter by usage]:usage:_sequence compadd - {no,}{filesystem,raid,crypto,other}' \ '*:device:_files -g "*(-%)"' diff --git a/Completion/Linux/Command/_chrt b/Completion/Linux/Command/_chrt index 5431b0799..3e550bf60 100644 --- a/Completion/Linux/Command/_chrt +++ b/Completion/Linux/Command/_chrt @@ -8,21 +8,22 @@ _arguments -C -s -S -A "-*" \ '(H -a --all-tasks)'{-a,--all-tasks}'[operate on all tasks (threads) for a given pid]' \ '(H)'{-v,--verbose}'[display status information]' \ '(H)'{-p,--pid}'[interpret args as process ID]' \ - '(H -R --reset-on-fork -b --batch -d --deadline -i --idle -o --other)'{-R,--reset-on-fork}'[set SCHED_RESET_ON_FORK for FIFO or RR]' \ + '(H -R --reset-on-fork -b --batch -d --deadline -e --ext -i --idle -o --other)'{-R,--reset-on-fork}'[set SCHED_RESET_ON_FORK for FIFO or RR]' \ + '(H -T --sched-runtime -f --fifo -e --ext -i --idle -r --rr)'{-T,--sched-runtime}'[runtime parameter for DEADLINE]' \ '(H)*::command or priority:->cmd_or_prio' \ + 'H' \ '(* -)'{-m,--max}'[show minimum and maximum valid priorities, then exit]' \ '(* -)'{-h,--help}'[display usage information]' \ '(* -)'{-V,--version}'[output version information]' \ + 'dline' \ - '(H -T --sched-runtime -b --batch -f --fifo -i --idle -o --other -r --rr)'{-T,--sched-runtime}'[runtime parameter for DEADLINE]' \ - '(H -P --sched-period -b --batch -f --fifo -i --idle -o --other -r --rr)'{-P,--sched-period}'[period parameter for DEADLINE]' \ - '(H -D --sched-deadline -b --batch -f --fifo -i --idle -o --other -r --rr)'{-D,--sched-deadline}'[deadline parameter for DEADLINE]' \ + '(H -P --sched-period -b --batch -f --fifo -e --ext -i --idle -o --other -r --rr)'{-P,--sched-period}'[period parameter for DEADLINE]' \ + '(H -D --sched-deadline -b --batch -f --fifo -e --ext -i --idle -o --other -r --rr)'{-D,--sched-deadline}'[deadline parameter for DEADLINE]' \ + '(policy)' \ '(H dline -R --reset-on-fork)'{-b,--batch}'[set scheduling policy to SCHED_BATCH]' \ '(H -R --reset-on-fork)'{-d,--deadline}'[set scheduling policy to SCHED_DEADLINE]' \ - '(H dline)'{-f,--fifo}'[set scheduling policy to SCHED_FIFO]' \ - '(H dline -R --reset-on-fork)'{-i,--idle}'[set scheduling policy to SCHED_IDLE]' \ + '(H dline -T --sched-runtime)'{-e,--ext}'[set scheduling policy to SCHED_EXT (BPF program-defined scheduling)]' \ + '(H dline -T --sched-runtime)'{-f,--fifo}'[set scheduling policy to SCHED_FIFO]' \ + '(H dline -R --reset-on-fork -T --sched-runtime)'{-i,--idle}'[set scheduling policy to SCHED_IDLE]' \ '(H dline -R --reset-on-fork)'{-o,--other}'[set scheduling policy to SCHED_OTHER]' \ '(H dline)'{-r,--rr}'[set scheduling policy to SCHED_RR (default)]' && ret=0 diff --git a/Completion/Linux/Command/_cryptsetup b/Completion/Linux/Command/_cryptsetup index 897eb94f9..2654ca844 100644 --- a/Completion/Linux/Command/_cryptsetup +++ b/Completion/Linux/Command/_cryptsetup @@ -45,6 +45,7 @@ _arguments -s \ '--dump-volume-key[dump volume key instead of keyslots info]' \ '--external-tokens-path=[specify path to directory with external token handlers (plugins)]:path:_directories' \ '--force-offline-reencrypt[force offline LUKS2 reencryption and bypass active device detection]' \ + '--force-no-keyslots[force dangerous reencryption operation erasing all remaining keyslots]' \ '--header=[device or file with separated LUKS header]:file:_files' \ '--hw-opal[use HW OPAL encryption together with SW encryption]' \ '--hw-opal-factory-reset[wipe WHOLE OPAL disk on luksErase]' \ @@ -52,8 +53,12 @@ _arguments -s \ '--keep-key[do not change volume key]' \ '--link-vk-to-keyring=[set keyring where to link volume key]:string' \ '--new-keyfile=[read the key for a new slot from a file]:file:_files' \ + '--new-key-description=[specify keyring new key description]:description' \ + '--new-key-size=[specify size of the new encryption key]:size (bits)' \ '--new-key-slot=[specify slot number for new key]:slot [first free]' \ '--new-token-id=[token number]:number [any]' \ + '--new-volume-key-file=[use new volume key from file]: :_files' \ + '--new-volume-key-keyring=[use specified keyring key as new volume key]:key' \ '--progress-json[print progress data in json format]' \ "--test-args[don't run action, just validate all command line parameters]" \ '--volume-key-file=[use the volume key from file]:file:_files' \ @@ -76,6 +81,7 @@ _arguments -s \ '--force-password[disable password quality check (if enabled)]' \ '--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]' \ + '--perf-high_priority[set dm-crypt workqueues and writer thread to high priority]' \ '--perf-no_read_workqueue[bypass dm-crypt workqueue and process read requests synchronously]' \ '--perf-no_write_workqueue[bypass dm-crypt workqueue and process write requests synchronously]' \ '--deferred[device removal is deferred until the last user closes it]' \ @@ -88,12 +94,14 @@ _arguments -s \ '--disable-locks[disable locking of on-disk metadata]' \ '--disable-keyring[disable loading volume keys via kernel keyring]' \ '(-I --integrity)'{-I+,--integrity=}'[specify data integrity algorithm (LUKS2 only)]:algorithm' \ + '--integrity-inline[use inline mode (use HW integrity field)]' \ + '--integrity-key-size=[specify size of the data integrity key]:size (bits)' \ '--integrity-no-journal[disable journal for integrity device]' \ "--integrity-no-wipe[don't wipe device after format]" \ '--integrity-legacy-padding[use inefficient legacy padding (old kernels)]' \ "--token-only[don't ask for passphrase if activation by token fails]" \ '--token-id=[specify token number]:number [any]' \ - '--key-description=[specify key description]:description' \ + '--key-description=[specify keyring key description]:description' \ '--sector-size=[specify encryption sector size]:size [512 bytes]' \ '--iv-large-sectors[use IV counted in sector size (not in 512 bytes)]' \ '--persistent[set activation flags persistent for device]' \ diff --git a/Completion/Linux/Command/_ethtool b/Completion/Linux/Command/_ethtool index 8cff24e96..f1f67a357 100644 --- a/Completion/Linux/Command/_ethtool +++ b/Completion/Linux/Command/_ethtool @@ -6,14 +6,24 @@ local -A opt_args _arguments -C -A "-*" \ '--debug[turn on debugging messages]:mask:((1\:parser\ information))' \ - '--json[output results in JSON]' \ + '(-j --json)'{-j,--json}'[output results in JSON]' \ '(-I --include-statistics)'{-I,--include-statistics}'[include command-related statistics in the output]' \ - '(cmds)'{-Q,--per-queue}'[apply per-queue command]: :(queue_mask):queue mask' \ + '(cmds cmdp)'{-Q,--per-queue}'[apply per-queue command]: :(queue_mask):queue mask' \ + '(cmds cmdc)--phy=[target a PHY within the interface]:phy' \ "1:interface:_net_interfaces" \ '*:: :->args' \ + '(cmdc)' \ - '(cmds)'{-c,--show-coalesce}'[query the specified ethernet device for coalescing information]' \ - '(cmds)'{-C,--coalesce}'[change the coalescing settings of the specified ethernet device]' \ + '(cmdp cmds)'{-c,--show-coalesce}'[query the specified ethernet device for coalescing information]' \ + '(cmdp cmds)'{-C,--coalesce}'[change the coalescing settings of the specified ethernet device]' \ + + '(cmdp)' \ + '(cmds cmdc)--cable-test[perform cable test and report the results]' \ + '(cmds cmdc)--cable-test-tdr[perform cable test and report Time Domain Reflectometer data]' \ + '(cmds cmdc)--get-plca-cfg[get PLCA configuration]' \ + '(cmds cmdc)--set-plca-cfg[set PLCA configuration]' \ + '(cmds cmdc)--get-plca-status[get PLCA status information]' \ + '(cmds cmdc)--show-pse[show settings for power sourcing equipment]' \ + '(cmds cmdc)--set-pse[set power sourcing equipment settings]' \ + '(cmds cmdc)--show-mse[show Mean Square Error (MSE) diagnostics]' \ + '(cmds)' \ '(1)'{-h,--help}'[display help information]' \ '(1)--version[display version information]' \ @@ -36,6 +46,8 @@ _arguments -C -A "-*" \ {-n,--show-nfc,-u,--show-ntuple}'[retrieve receive network flow classification options or rules]' \ {-N,--config-nfc,-U,--config-ntuple}'[configure receive network flow classification options or rules]' \ {-T,--show-time-stamping}"[show device's time stamping capabilities]" \ + '--get-hwtimestamp-cfg[get selected hardware time stamping]' \ + '--set-hwtimestamp-cfg[select hardware time stamping]' \ {-x,--show-rxfh-indir,--show-rxfh}'[show Rx flow hash indirection table and/or RSS hash key]' \ {-X,--set-rxfh-indir,--rxfh}'[set Rx flow hash indirection table and/or RSS hash key]' \ {-f,--flash}'[flash firmware image from the specified file]' \ @@ -56,24 +68,20 @@ _arguments -C -A "-*" \ '--reset[reset hardware components]' \ '--show-fec[query device for forward error correction support]' \ '--set-fec[configure forward error correction for device]' \ - '--cable-test[perform cable test and report the results]' \ - '--cable-test-tdr[perform cable test and report Time Domain Reflectometer data]' \ '--show-tunnels[show tunnel-related device capabilities and state]' \ '--show-module[show transceiver module settings]' \ '--set-module[set transceiver module settings]' \ - '--get-plca-cfg[get PLCA configuration]' \ - '--set-plca-cfg[set PLCA configuration]' \ - '--get-plca-status[get PLCA status information]' \ '--show-mm[show MAC merge layer state]' \ '--set-mm[set MAC merge layer parameters]' \ - '--show-pse[show settings for power sourcing equipment]' \ - '--set-pse[set power sourcing equipment settings]' \ + '--flash-module-firmware[flash transceiver module firmware]' \ + '--show-phys[list PHYs]' \ '--monitor[listen to netlink notifications and displays them]::command:( --all -s --change -k --show-features --show-offload -K --features --offload --show-priv-flags --set-priv-flags -g --show-ring -G --set-ring -l --show-channels -L --set-channels -c --show-coalesce -C --coalesce -a --show-pause -A --pause --show-eee --set-eee --cable-test --cable-test-tdr --show-module --set-module + --get-plca-cfg --set-plca-cfg --pse-event )' && return if [[ -n $state ]]; then @@ -97,17 +105,18 @@ if [[ -n $state ]]; then rx-frames-low|tx-usecs-low|tx-frames-low|pkt-rate-high|rx-usecs-high) ;& rx-frames-high|tx-usecs-high|tx-frames-high|sample-interval|dmac) ;& tx-aggr-max-bytes|tx-aggr-max-frame|tx-aggr-time-usec) ;& - rx-mini|rx-jumbo|rx-buf-len|cqe-size|tx-push-buf-len) ;& + rx-mini|rx-jumbo|rx-buf-len|cqe-size|tx-push-buf-len|hds-thresh) ;& offset|length|magic|value|phyad|proto|tos|tclass|l4proto|src-port) ;& dst-port|spi|l4data|vlan-etype|vlan|user-def|action|vf|queue|loc) ;& + index) ;& page|bank|i2c|first|last|step|pair|lanes) ;& rx-copybreak|tx-copybreak|tx-buf-size|pfc-prevention-tout) ;& other|combined|tx-timer|count|msecs) ;& node-id|node-cnt|to-tmr|burst-cnt|burst-tmr) ;& - tx-min-frag-size) + tx-min-frag-size|c33-pse-avail-pw-limit|prio) _message -e numbers 'number' ;; - podl-pse-admin-control) + (podl-pse|c33-pse)-admin-control) _wanted values expl 'value' compadd enable disable ;; speed) @@ -168,6 +177,12 @@ if [[ -n $state ]]; then src|src-ip|dst|dst-ip|dst-mac) _message -e addresses address ;; + qualifier) + _wanted qualifiers expl qualifier compadd precise approx + ;; + rx-filter) + _message -e values value + ;; m) _message -e masks mask ;; @@ -178,7 +193,7 @@ if [[ -n $state ]]; then _message -e functions 'hash function' ;; xfrm) - _wanted transformations expl transformation compadd symmetric-xor none + _wanted transformations expl transformation compadd symmetric-xor symmetric-or-xor none ;; flags) _message -e masks mask @@ -192,6 +207,9 @@ if [[ -n $state ]]; then tcp-data-split) _wanted states expl state compadd auto on off ;; + pass) + _message -e passwords password + ;; *) case ${${(Mk)opt_args:#cmd?*}[1]#cmd?-} in -a|--show-pause) @@ -215,7 +233,8 @@ if [[ -n $state ]]; then 'rx-mini[change number of ring entries for the RX Mini ring]' \ 'rx-jumbo[change number of ring entries for the RX Jumbo ring]' \ 'tx[change number of ring entries for the TX ring]' \ - rx-buf-len tcp-data-split cqe-size tx-push rx-push tx-push-buf-len + rx-buf-len tcp-data-split cqe-size tx-push rx-push tx-push-buf-len \ + hds-thresh ;; -d|--register-dump) _values -S ' ' -w 'option' \ @@ -303,6 +322,12 @@ if [[ -n $state ]]; then queue context loc fi ;; + -T|--show-time-stamping) + _wanted options expl option compadd index qualifier + ;; + --set-hwtimestamp-cfg) + _wanted options expl option compadd index qualifier tx rx-filter + ;; -x|--show-rxfh-indir|--show-rxfh) _wanted options expl option compadd -F line - context ;; @@ -381,6 +406,17 @@ if [[ -n $state ]]; then _wanted options expl tunable compadd enable node-id node-cnt \ to-tmr burst-cnt burst-tmr ;; + --set-mm) + _wanted options expl option compadd verify-enabled verify-time \ + tx-enabled pmac-enabled tx-min-frag-size + ;; + --set-pse) + _wanted options expl option compadd {podl-pse,c33-pse}-admin-control \ + c33-pse-avail-pw-limit prio + ;; + --flash-module-firmware) + _wanted options expl option compadd file pass + ;; esac ;; esac diff --git a/Completion/Linux/Command/_findmnt b/Completion/Linux/Command/_findmnt index 6155d4dc1..b9cb04dc7 100644 --- a/Completion/Linux/Command/_findmnt +++ b/Completion/Linux/Command/_findmnt @@ -19,6 +19,7 @@ _arguments -s -C \ '(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)--hyperlink=-[print paths as hyperlinks]::when:(always never auto)' \ '(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]' \ @@ -52,7 +53,8 @@ _arguments -s -C \ '(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)-k[search in /proc/self/mountinfo (default)]' \ + '(H)--kernel=-[search in /proc/self/mountinfo (default)]::method:(mountinfo listmount)' \ '(H)'{-m,--mtab}'[search in /etc/mtab]' \ '(H)'{-N+,--task=}'[search /proc/<pid>/mountinfo]: :_pids' \ '(H)'{-s,--fstab}'[search in /etc/fstab]' \ diff --git a/Completion/Linux/Command/_gpasswd b/Completion/Linux/Command/_gpasswd index d5d16ebba..24fe361b0 100644 --- a/Completion/Linux/Command/_gpasswd +++ b/Completion/Linux/Command/_gpasswd @@ -5,7 +5,7 @@ _arguments -s \ '(-d --delete -a --add)'{-d,--delete}'[remove user from group]: : _users' \ '(-)'{-h,--help}'[display help]' \ '(-Q --root)'{-Q,--root}'[specify directory to chroot into]: : _files -/' \ - '(-r --delete-password)'{-r,--delete-password}'[remove the group password]' \ + '(-r --remove-password)'{-r,--remove-password}'[remove the group password]' \ '(-R --restrict)'{-R,--restrict}'[restrict access to GROUP to its members]' \ '(-M --members -A --administrators)'{-M,--members}'[set the list of members of GROUP]: :_sequence _users' \ '(-A --administrators -M --members)'{-A,--administrators}'[set the list of admins for GROUP]: :_sequence _users' \ diff --git a/Completion/Unix/Command/_ip b/Completion/Linux/Command/_ip index d63ddedab..d63ddedab 100644 --- a/Completion/Unix/Command/_ip +++ b/Completion/Linux/Command/_ip diff --git a/Completion/Unix/Command/_loadkeys b/Completion/Linux/Command/_kbd index d0a87b6f6..d0a87b6f6 100644 --- a/Completion/Unix/Command/_loadkeys +++ b/Completion/Linux/Command/_kbd diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_kmod index f19784dff..4e87c4767 100644 --- a/Completion/Linux/Command/_modutils +++ b/Completion/Linux/Command/_kmod @@ -38,11 +38,15 @@ _modutils() { ) case "$service" in - lsmod) _arguments -s "$args[@]" && return ;; + lsmod) + _arguments -s "$args[@]" \ + '(-s --syslog)'{-s,--syslog}'[report via syslog instead of stderr]' \ + '(-v --verbose)'{-v,--verbose}'[enable more messages]' && return + ;; modinfo) _arguments -s -C "$args[@]" \ - '(-)'{-k+,--set-version=}'[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \ + '(-)'{-k+,--set-version=}'[use modules from a different kernel version]:kernel_version:compadd $modules_dir/*(/\:t)' \ {-b+,--basedir=}'[use specified directory as filesystem root]:path:_directories' \ '1:module file:->all-modules' \ + '(field)' \ @@ -59,13 +63,14 @@ _modutils() { 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]' \ + '!--remove-dependencies' \ + '--remove-holders[also remove module holders]' \ + '(-w --wait)'{-w+,--wait=}"[wait for module's refcount to become 0 so it can be removed (with -r)]:delay (msecs)" \ '(* -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]'} \ @@ -76,8 +81,8 @@ _modutils() { '(-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)))' \ + '(-d --dirname)'{-d+,--dirname=}'[use specified directory as filesystem root]:path:_directories' \ + '(-S --set-version)'{-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" \ @@ -87,17 +92,20 @@ _modutils() { ;; rmmod) - _arguments -s -C "$args[@]" \ + _arguments -s "$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 + '*:loaded module:->loaded-modules' && return ;; insmod) - _arguments "$args[@]" \ - '1:module file:_files' \ - '*:module parameters' && ret=0 + _arguments -s "$args[@]" \ + '(-f --force)'{-f,--force}'[forces a module load (dangerous)]' \ + '(-s --syslog)'{-s,--syslog}'[report via syslog instead of stderr]' \ + '(-v --verbose)'{-v,--verbose}'[enable more messages]' \ + '1:module file:_files -g "*.ko(|.gz|.xz|.zst)(-.)"' \ + '*:module option' && return ;; esac diff --git a/Completion/Linux/Command/_analyseplugin b/Completion/Linux/Command/_ladspa index f7f36db50..f7f36db50 100644 --- a/Completion/Linux/Command/_analyseplugin +++ b/Completion/Linux/Command/_ladspa diff --git a/Completion/Linux/Command/_losetup b/Completion/Linux/Command/_losetup index affbc58f3..aab9adbcd 100644 --- a/Completion/Linux/Command/_losetup +++ b/Completion/Linux/Command/_losetup @@ -8,7 +8,7 @@ fi local device offset -device='1:device:_files -g "/dev/loop<->"' +device=':device:_files -g "/dev/loop<->"' offset=( {-o,--offset}'+[specify data start is offset]:offset (bytes)' ) _arguments -s -S \ @@ -28,7 +28,8 @@ _arguments -s -S \ {-c,--set-capacity}'[reread the size of the file associated with the loop device]' \ - 'detach' \ '(-)'{--detach,-d}'[detach from specified loop device]' \ - "$device" \ + '(-)--remove[remove one or more devices]:device' \ + "*$device" \ - '(detach-all)' \ {-D,--detach-all}'[detach all associated loop devices]' \ - 'create' \ diff --git a/Completion/Linux/Command/_lsblk b/Completion/Linux/Command/_lsblk index c8b30eb5e..c2c67c9a6 100644 --- a/Completion/Linux/Command/_lsblk +++ b/Completion/Linux/Command/_lsblk @@ -13,16 +13,18 @@ _arguments -C -s -S \ '(H)*--ct-filter=[restrict the next counter]:expression' \ '(H)*--ct=[define a custom counter]:name\:param\:func' \ '(H -a --all)'{-a,--all}'[print all devices]' \ - '(H -b --bytes)'{-b,--bytes}'[print size in bytes rather than in human readable format]' \ + '(H -b --bytes)'{-b,--bytes}'[print size in bytes instead of a human readable format]' \ '(H -d --nodeps)'{-d,--nodeps}"[don't print slaves or holders]" \ '(H -I --include)*'{-e,--exclude}'[exclude devices by major number]:major device number:->majorlist' \ '(H -e --exclude)*'{-I+,--include=}'[show only devices with specified major numbers]:major device number:->majorlist' \ + '(H)--hyperlink=-[print paths as hyperlinks]::when:(always never auto)' \ '(H -n --noheadings -y --shell)'{-n,--noheadings}"[don't print headings]" \ '(H -p --paths)'{-p,--paths}'[print complete device path]' \ '(H -s --inverse)'{-s,--inverse}'[reverse dependency order]' \ '(H -w --width)'{-w+,--width=}'[specify output width]:width' \ '(H -x --sort)'{-x+,--sort=}'[sort output by specified column]:column:->columns' \ '(H -y --shell -n --noheadings)'{-y,--shell}'[use column names usable as shell variable identifiers]' \ + '--properties-by=[specify methods used to gather data]:method [file,udev,blkid]:_sequence compadd - udev blkid file none' \ '(H)--sysroot=[use specified directory as system root]:directory:_directories' \ '*:device:_files -g "*(-%b)" -P / -W /' \ + fields \ diff --git a/Completion/Linux/Command/_mondo b/Completion/Linux/Command/_mondo deleted file mode 100644 index 047a04129..000000000 --- a/Completion/Linux/Command/_mondo +++ /dev/null @@ -1,54 +0,0 @@ -#compdef mondoarchive - -local curcontext="$curcontext" state line expl ret=1 -typeset -A opt_args - -_arguments -C \ - '(-V)-O[create backup]' \ - '(-O)-V[verify backup]' \ - '(-c -C -i -n -w)-c[use CD-R as backup media]:CD-R burn speed' \ - '(-c -C -i -n -w)-C[use CD-R as streaming device (experimental)]:CD-R burn speed' \ - '(-c -C -i -n -w)-i[use ISO image as backup media]' \ - '(-c -C -i -n -w)-n[use NFS mountpoint as backup media]:NFS mountpoint' \ - '(-c -C -i -n -w)-w[use CD-RW as backup media]:CD-RW burn speed' \ - '-D[differential backup]' \ - '-E[exclude path(s) from backup]:paths to exclude from backup:->quoted_path' \ - '-I[path(s) to backup]:paths to include in backup:->quoted_path' \ - '-d[backup device]:backup device' \ - '-g[run in fullscreen mode]' \ - '-k[path to kernel]:path to kernel:->kernel_or_magic' \ - '-m[manual eject]' \ - '-s[media size]:media size]' \ - '-x[non-linux partition]:non-linux partition:_files -g "*(%b)"' \ - '(-1 -2 -3 -4 -5 -6 -7 -8 -9)-'{1,2,3,4,5,6,7,8,9}'[compression level]' \ - '-A[post ISO-creation command]:pre ISO-creation command' \ - '-B[pre iSO-creation command]:post ISO-creation command' \ - '-F[do not create floppy]' \ - '-H[create autorestore image]' \ - '-L[use lzo instead of bzip2]' \ - '-P[post-nuke tarball]:post-nuke tarball:_files -g "*.(#i)(tar.gz|tgz)(-.)"' \ - '-S[scratch directory]:scratch directory:_files -/' \ - '-T[temporary directory]:temporary directory:_files -/' \ - '-f[device with MBR]:device with MBR:_files -g "*(%b)"' \ - '-l[bootloader type]:bootloader type:(GRUB LILO)' && ret=0 - -case $state in - quoted_path) - local suf="/ \t\n" - [[ -n $compstate[quote] ]] && { suf="$compstate[quote]$suf"; compset -q; } - _files -r $suf && ret=0 - ;; - kernel_or_magic) - _tags kernel magic - while _tags; do - _requested magic expl "keyword" \ - compadd -- FAILSAFE && ret=0 - _requested kernel expl "path to kernel image" \ - _files && ret=0 - - (( ret )) || break - done - ;; -esac - -return ret diff --git a/Completion/Linux/Command/_namei b/Completion/Linux/Command/_namei new file mode 100644 index 000000000..6f3533eec --- /dev/null +++ b/Completion/Linux/Command/_namei @@ -0,0 +1,15 @@ +#compdef namei + +local ign + +(( $#words > 2 )) && ign='!(* -)' +_arguments -s -S \ + '(-x --mountpoints)'{-x,--mountpoints}"[mark mount point directories with a 'D']" \ + '(-m --modes -l --long)'{-m,--modes}'[show the permission bits of each file]' \ + '(-o --owners -l --long)'{-o,--owners}'[show owner and group of each file]' \ + '(-l --long -m --modes -o --owners -v --vertical)'{-l,--long}'[use long listing format (-m -o -v)]' \ + '(-n --nosymlinks)'{-n,--nosymlinks}"[don't follow symlinks]" \ + '(-v --vertical -l --long)'{-v,--vertical}'[align modes and owners vertically]' \ + "$ign"{-h,--help}'[display usage information]' \ + "$ign"{-V,--version}'[display version information]' \ + '*: :_files' diff --git a/Completion/Linux/Command/_ss b/Completion/Linux/Command/_ss index 2a1cfcb78..ac21c3bcb 100644 --- a/Completion/Linux/Command/_ss +++ b/Completion/Linux/Command/_ss @@ -13,23 +13,29 @@ _arguments -C -s \ "($info -r --resolve)"{-r,--resolve}'[resolve host addresses]' \ "($info -a --all -l --listening)"{-a,--all}'[display all sockets]' \ "($info -l --listening -a --all)"{-l,--listening}'[display listening sockets]' \ + "($info -B --bound-inactive)"{-B,--bound-inactive}'[display TCP bound but inactive sockets]' \ "($info -o --options -e --extended)"{-o,--options}'[show timer information]' \ "($info -e --extended -o --options)"{-e,--extended}'[show detailed information]' \ "($info -m --memory)"{-m,--memory}'[show socket memory usage]' \ "($info -p --processes)"{-p,--processes}'[show process using each socket]' \ + "($info -T --threads)"{-T,--threads}'[show thread using socket]' \ "($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)--cgroup[show cgroup information]" \ "($info -b --bpf)"{-b,--bpf}'[show bpf filter socket information]' \ + "($info)--bpf-maps[show all BPF socket-local storage maps]" \ + "($info)--bpf-map-id=[show a BPF socket-local storage map]:map ID" \ "($info -E --events)"{-E,--events}'[continually display sockets as they are destroyed]' \ - "($info -Z --context)"{-Z,--context}'[display process SELinux security contexts]' \ - "($info -z --contexts)"{-z,--contexts}'[display process and socket SELinux security contexts]' \ + "($info -Z --context)"{-Z,--context}'[display task SELinux security contexts]' \ + "($info -z --contexts)"{-z,--contexts}'[display task and socket SELinux security contexts]' \ "($info -N --net)"{-N,--net}'[switch to specified network namespace]:network namespace' \ "($info -4 --ipv4 -6 --ipv6)"{-4,--ipv4}'[display only IP version 4 sockets]' \ "($info -4 --ipv4 -6 --ipv6)"{-6,--ipv6}'[display only IP version 6 sockets]' \ "($info -0 --packet)"{-0,--packet}'[display PACKET sockets]' \ "($info -t --tcp)"{-t,--tcp}'[display TCP sockets]' \ + "($info -M --mptcp)"{-M,--mptcp}'[display only MPTCP sockets]' \ "($info -S --sctp)"{-S,--sctp}'[display SCTP sockets]' \ "($info -u --udp)"{-u,--udp}'[display UDP sockets]' \ "($info -d --dccp)"{-d,--dccp}'[display DCCP sockets]' \ @@ -41,7 +47,9 @@ _arguments -C -s \ "($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 -Q --no-queues)"{-Q,--no-queues}'[suppress sending and receiving queue columns]' \ "($info -O --oneline)"{-O,--oneline}"[print socket's data on a single line]" \ + "($info)--inet-sockopt[show various inet socket options]" \ "($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/_strace b/Completion/Linux/Command/_strace index 6f42c4ae0..149a1dddb 100644 --- a/Completion/Linux/Command/_strace +++ b/Completion/Linux/Command/_strace @@ -23,11 +23,13 @@ _arguments -C -s \ '(-z -Z --successful-only --failed-only)'{-z,--successful-only}'[trace only system calls that return success]' \ '(-z -Z --successful-only --failed-only)'{-Z,--failed-only}'[trace only system calls that return an error]' \ '(-a --columns)'{-a+,--columns=}'[align return values in a specific column]:column number [40]' \ + '--color=[control use of color]:color [auto]:(never always auto)' \ '(-i --instruction-pointer -c --summary-only)'{-i,--instruction-pointer}'[print instruction pointer at time of syscall]' \ '(-c --summary-only)*-k[obtain stack trace between each syscall]' \ '(-c --summary-only -k)--stack-trace=-[obtain stack trace between each syscall]::symbol' \ '(-c --summary-only)--stack-trace-frame-limit=[specify limit on stack trace frames to print]:frames [256]' \ '(-n --syscall-number)'{-n,--syscall-number}'[print syscall number]' \ + '(-N --arg-names)'{-N,--arg-names}'[print syscall argument names]' \ '(-o --output)'{-o+,--output=}'[send trace output to the specified file]:output file:->file-pipe' \ '(-A --output-append-mode)'{-A,--output-append-mode}'[open the file provided with the -o option in append mode]' \ '--output-separately[output to separate files for child processes (by appending pid to file names)]' \ @@ -95,6 +97,7 @@ case $state in 'status[trace system calls with given return status]:status:->status' \ 'quiet[suppress various information messages]:message [none]:_sequence compadd - none attach exit path-resolution personality thread-execve superseded' \ 'kvm[print the exit reason of kvm vcpu]: :(vcpu)' \ + 'namespace=new[print namespace IDs that the tracee enters]' \ 'decode-fds[print information associated with file descriptors]:information [none]:_sequence compadd - none all path socket dev eventfd pidfd signalfd' \ 'secontext' \ 'decode-pids[print information associated with process IDs]:information [none]:_sequence compadd - none comm pidns' && ret=0 diff --git a/Completion/Linux/Command/_tracepath b/Completion/Linux/Command/_tracepath index f0f777d96..68a3d6ee6 100644 --- a/Completion/Linux/Command/_tracepath +++ b/Completion/Linux/Command/_tracepath @@ -1,9 +1,12 @@ #compdef tracepath tracepath6 _arguments -s -S \ + '(-6)-4[use IPv4]' \ + '(-4)-6[use IPv6]' \ '-n[print IP addresses numerically]' \ '-b[print both host names and IP addresses]' \ '-l+[set the initial packet length]:length (bytes)' \ '-m+[set maximum hops]:maximum [30]' \ '-p+[set initial destination port to use]:port:_ports' \ + '-V[display version information]' \ ':destination:_hosts' diff --git a/Completion/Linux/Command/_valgrind b/Completion/Linux/Command/_valgrind index 47fced1fd..638b29cf5 100644 --- a/Completion/Linux/Command/_valgrind +++ b/Completion/Linux/Command/_valgrind @@ -20,7 +20,7 @@ common_own_malloc=( '--alignment=-[set minimum alignment of heap allocations]:number [16]' '--redzone-size=-[set minimum size of redzones added before/after heap blocks]:size (bytes) [16]' '--xtree-memory=-[profile heap memory in an xtree [none]:(none allocs full)' - '--xtree-memory-file=-[specify xtree memory report file]:file [xtmemory.kcg.%%p]:_files' + '--xtree-memory-file=-[specify xtree memory report file]:file [xtmemory.kcg.%p]:_files' ) common_read_varinfo=( @@ -67,7 +67,7 @@ args_addrcheck=( '(--show-leak-kinds)--show-reachable=-[show reachable blocks in leak check]:enable:(yes no)' '(--show-leak-kinds)--show-possibly-lost=-:enable:(yes no)' '--xtree-leak=-[output leak result in xtree format]:enable [no]:(yes no)' - '--xtree-leak-file=-[specify xtree leak report file]:file [xtleak.kcg.%%p]:_files' + '--xtree-leak-file=-[specify xtree leak report file]:file [xtleak.kcg.%p]:_files' '--undef-value-errors=-[check for undefined value errors]:enable [yes]:(yes no)' '--track-origins=-[show origins of undefined values]:enable [no]:(yes no)' $common_partial @@ -124,11 +124,11 @@ args_cachegrind=( '--LL=-[set LL cache manually]:size,assoc,line_size' '--cache-sim=-[collect cache stats]:enable [yes]:(yes no)' '--branch-sim=-[collect branch prediction stats]:enable [no]:(yes no)' - '--cachegrind-out-file=-[specify output file name]:file name [cachegrind.out.%%p]:_files' + '--cachegrind-out-file=-[specify output file name]:file name [cachegrind.out.%p]:_files' ) args_callgrind=( - '--callgrind-out-file=-[specify output file name]:file name [callgrind.out.%%p]:_files' + '--callgrind-out-file=-[specify output file name]:file name [callgrind.out.%p]:_files' '--dump-line=-[perform event counting at source line granularity]:enable [yes]:(yes no)' '--dump-instr=-[perform event counting at instruction granularity]:enable [no]:(yes no)' '--compress-strings=-[identify file and function names by numbers]:enable [yes]:(yes no)' @@ -202,7 +202,7 @@ args_massif=( ))" '--detailed-freq=-[every Nth snapshot should be detailed]:snapshot interval [10]' '--max-snapshots=-[specofy maximum number of snapshots recorded]:maximum [100]' - '--massif-out-file=-[specify output file name]:filename [massif.out.%%p]:_files' + '--massif-out-file=-[specify output file name]:filename [massif.out.%p]:_files' ) args_exp_bbv=( diff --git a/Completion/Mandriva/Command/_rebootin b/Completion/Mandriva/Command/_rebootin deleted file mode 100644 index 284ff08f1..000000000 --- a/Completion/Mandriva/Command/_rebootin +++ /dev/null @@ -1,29 +0,0 @@ -#compdef rebootin - -local context state line expl -typeset -A opt_args -local loader=${$(_call_program -p entries detectloader -q):-GRUB} - -_arguments -s \ - '-n[no immediate reboot just set the flags for next reboot]' \ - '-f[create a /fastboot file to reboot in fastboot mode]' \ - '*::arguments:->loader_entry' - -case $state in - loader_entry) - case $loader in - GRUB) - if [ -r /boot/grub/menu.lst ]; then - _wanted -C $context entries expl entry \ - compadd ${${(M)${(f)"$(</boot/grub/menu.lst)"}##title *}#title } - fi - ;; - LILO) - if [ -r /etc/lilo.conf ]; then - _wanted -C $context entries expl entry \ - compadd $(awk -F= '{ if ($0 ~ /label=/) print $2 }' /etc/lilo.conf) - fi - ;; - esac - ;; -esac diff --git a/Completion/Solaris/Command/_ipadm b/Completion/Solaris/Command/_ipadm index c59fc8108..c3ddd26ec 100644 --- a/Completion/Solaris/Command/_ipadm +++ b/Completion/Solaris/Command/_ipadm @@ -274,7 +274,7 @@ _ipadm() { ("dhcp:"*) _arguments -A "-*" \ - '(-w --wait)'{-w,--wait}'[Seconds to wait for completion]:number or "forever":{if [[ -prefix [0-9]## ]]; then _message -e "number of seconds"; else _wanted forever expl "number or \"forever\"" compadd forever; fi}' \ + '(-w --wait)'{-w,--wait}'[time to wait for completion]:time (seconds):_phony forever' \ '-h[Request a specific hostname]:hostname:' \ ':address object name:_ipadm_addrobjs_or_ifs' ;; diff --git a/Completion/Unix/Command/_pkgadd b/Completion/Solaris/Command/_pkgadd index 7adc18a2a..09e6a06d0 100644 --- a/Completion/Unix/Command/_pkgadd +++ b/Completion/Solaris/Command/_pkgadd @@ -23,10 +23,10 @@ _pkgadd() { '-R[root path]:root path:_files -/' \ '-r[response file]:response file:_files' \ '-V[alternate vfstab file]:vfstab file:_files' \ - '*:package instance:_pkg_instance --_opts uninstalled:-d' \ + '*:package instance:_pkg_instances --_opts uninstalled:-d' \ - set2 \ '-s[spool package]:spool directory:_files -/' \ - '*:package instance:_pkg_instance --_opts uninstalled:-d' + '*:package instance:_pkg_instances --_opts uninstalled:-d' } _pkgadd "$@" diff --git a/Completion/Unix/Command/_pkginfo b/Completion/Solaris/Command/_pkginfo index eca9e057e..26a5a866b 100644 --- a/Completion/Unix/Command/_pkginfo +++ b/Completion/Solaris/Command/_pkginfo @@ -12,7 +12,7 @@ _arguments -s \ '(-p)-i[select completely installed packages]' \ '(-i)-p[select partially installed packages]' \ '-R[root path]:root path:_files -/' \ - '*:package instance:_pkg_instance --_opts installed:set1--R' \ + '*:package instance:_pkg_instances --_opts installed:set1--R' \ - set2 \ '-d[device]:device file:_files' \ - '*:package instance:_pkg_instance --_opts uninstalled:set2--d' + '*:package instance:_pkg_instances --_opts uninstalled:set2--d' diff --git a/Completion/Unix/Command/_pkgrm b/Completion/Solaris/Command/_pkgrm index 1191a2d1f..19fbc4409 100644 --- a/Completion/Unix/Command/_pkgrm +++ b/Completion/Solaris/Command/_pkgrm @@ -10,7 +10,7 @@ _arguments -s \ "-M[don't use vfstab file]" \ '-R[root path]:root path:_files -/' \ '-V[alternate vfstab file]:vfstab file:_files' \ - '*:package instance:_pkg_instance --_opts installed:set1--R' \ + '*:package instance:_pkg_instances --_opts installed:set1--R' \ - set2 \ '-s[spool package]:spool directory:_files -/' \ - '*:package instance:_pkg_instance --_opts spooled:set2--s' + '*:package instance:_pkg_instances --_opts spooled:set2--s' diff --git a/Completion/Unix/Command/_pkg_instance b/Completion/Solaris/Type/_pkg_instances index 3f4c49219..3f4c49219 100644 --- a/Completion/Unix/Command/_pkg_instance +++ b/Completion/Solaris/Type/_pkg_instances diff --git a/Completion/Unix/Command/_aap b/Completion/Unix/Command/_aap deleted file mode 100644 index 38e50f1fc..000000000 --- a/Completion/Unix/Command/_aap +++ /dev/null @@ -1,50 +0,0 @@ -#compdef aap - -# A-A-P recipe executive version 1.076; released 2005 May 30 12:47:03 GMT - -local curcontext="$curcontext" state line ret=1 -typeset -A opt_args - -_arguments -C -s -S \ - '(- *)'{-V,--version}'[print version information and exit]' \ - '(- *)'{-h,--help}'[print help information and exit]' \ - '(-s --silent -v --verbose)'{-v,--verbose}'[print more information]' \ - '(-v --verbose -s --silent)'{-s,--silent}'[print less information]' \ - '(-d --debug)'{-d,--debug=}'[debug the specified items]:flags:' \ - '--profile=[profile A-A-P execution and write results in specified file]:output file:_files' \ - '(-n --nobuild)'{-n,--nobuild}'[print the build commands but do not execute them]' \ - '--changed=[consider specified file changed]:changed file:_files' \ - '(-t --touch)'{-t,--touch}'[update target signatures, do not build]' \ - '(-F --force)'{-F,--force}'[force rebuilding]' \ - '(-C --contents)'{-C,--contents}'[only build when file contents changed]' \ - \*{-c,--command=}'[execute a command after reading the recipe]:aap command:' \ - '(-k --continue)'{-k,--continue}'[continue building after an error]' \ - '(-S --stop)'{-S,--stop}'[stop building at first error (default)]' \ - '(-N --nofetch-recipe -R --fetch-recipe)'{-R,--fetch-recipe}'[fetch recipe file and child recipes]' \ - '(-R --fetch-recipe -N --nofetch-recipe)'{-N,--nofetch-recipe}'[do not fetch recipes for "fetch" target]' \ - '(-a --nocache)'{-a,--nocache}"[always download files, don't use the cache]" \ - '(-l --local)'{-l,--local}'[do not recurse into subdirectories]' \ - '(-j --jobs)'{-j,--jobs=}'[maximum number of parallel jobs]:number of jobs:' \ - '(-f --recipe -u --search-up --up)'{-u,--search-up,--up}'[search directory tree upwards for main.aap recipe]' \ - \*{-I,--include=}'[directory to search for included recipes]:include directory:_files -/' \ - '(-u --search-up --up -f --recipe)'{-f,--recipe=}'[recipe file to be executed]:recipe file:_files -g \*.aap\(-.\)' \ - '--install=[install specified package]:package name:' \ - '--[end of options, targets and assignments follow]' \ - '*:aap target:->target' && ret=0 - -if [[ "$state" = target ]]; then - local targets recipe - if [[ -n $opt_args[(I)(-u|--search-up|--up)] ]]; then - recipe=( (../)#main.aap(N[-1]) ) - else - recipe=${(v)opt_args[(I)(-f|--recipe)]:-main.aap} - fi - if [[ -f $recipe ]]; then - targets=( ${${(f)"$(_call_program targets $words[1] -f $recipe comment 2>/dev/null)"}/(#b)target (*):[[:blank:]]##(*)/$match[1]:${match[2]:l}} comment ) - _describe -t targets 'aap target' targets && ret=0 - else - _message -e targets 'aap target' - fi -fi - -return ret diff --git a/Completion/Unix/Command/_abcde b/Completion/Unix/Command/_abcde index 6b09d87b5..be18d7f05 100644 --- a/Completion/Unix/Command/_abcde +++ b/Completion/Unix/Command/_abcde @@ -34,7 +34,7 @@ _arguments -s -S -A "-*" \ '(- :)-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:_command_names -e' \ + '-X+[use an alternative "cue2discid" implementation]:cue2discid:_phony builtin _command_names -e' \ '-w+[add a comment to the tracks ripped from the CD]:comment' \ "-W+[concatenate CD's]:cd-number" \ '-z[debug mode]' \ diff --git a/Completion/Unix/Command/_age b/Completion/Unix/Command/_age new file mode 100644 index 000000000..487933d92 --- /dev/null +++ b/Completion/Unix/Command/_age @@ -0,0 +1,24 @@ +#compdef age age-keygen + +case $service in + age) + _arguments -S -A '-?*' \ + '(- :)'{-h,--help}'[display usage information]' \ + '!(-d --decrypt)'{-e,--encrypt} \ + '(-e --encrypt -d --decrypt -a --armor -p --passphrase -r --recipient -R --recipients-file)'{-d,--decrypt}'[decrypt the input to the output]' \ + '(-o --output)'{-o,--output=}'[write result to given file]:output file:_files' \ + '(-a --armor -d --decrypt)'{-a,--armor}'[encrypt to PEM encoded format]' \ + '(-p --passphrase -d --decrypt)'{-p,--passphrase}'[encrypt with passphrase]' \ + '(-d --decrypt)'\*{-r,--recipient=}'[encrypt to specified recipient]:recipient' \ + '(-d --decrypt)'\*{-R,--recipients-file=}'[encrypt to recipients listed in specified file]:recipients file:_files' \ + \*{-i,--identity=}'[use given identify file]:identity:_files' \ + ':input:_files' + ;; + age-keygen) + _arguments -S -A '-?*' \ + '-pq[generate post-quantum hybrid ML-KEM-768 + X25519 key pair]' \ + '(-o --output)'{-o,--output}'[write the result to the given file]:file:_files' \ + '-y[convert an identity file to a recipients file]' \ + ':input:_files' + ;; +esac diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index 554e61c49..d87bf49c2 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -143,7 +143,6 @@ case $service in ;; ansible-playbook) args+=( - '--flush-cache[clear the fact cache for every host in inventory]' '--force-handlers[run handlers even if a task fails]' '--list-tags[list all available tags]' '--list-tasks[list all tasks that would be executed]' @@ -208,10 +207,15 @@ case $state in else local -a inventory typeset -ga _ansible_hosts _ansible_groups + typeset -g _ansible_inventory_last_cwd + if [[ $PWD != $_ansible_inventory_last_cwd ]]; then + unset _ansible_hosts _ansible_groups + fi if (( !$#_ansible_hosts || !$#_ansible_groups )); then inventory=( ${(f)"$(_call_program groups ansible-inventory --graph)"} ) _ansible_hosts=( ${${(M)inventory%--[^:]#}#--} ) _ansible_groups=( ${${${(M)inventory%@*:}%:}#@} ) + _ansible_inventory_last_cwd=$PWD fi if [[ $state = hosts ]]; then suf=( -qS: ) diff --git a/Completion/Unix/Command/_attr b/Completion/Unix/Command/_attr index 58fd8837e..208c46db6 100644 --- a/Completion/Unix/Command/_attr +++ b/Completion/Unix/Command/_attr @@ -2,7 +2,7 @@ case $service in attr) - _arguments -s -S "$list[@]" \ + _arguments -s -S \ '(-l -r -s -V)-g[get extended attribute for file]:attribute name' \ '(-g -s -r -V)-l[list extended attributes associated with file]' \ '(-l -g -s -q -V)-r[remove given attribute from file]:attribute name' \ diff --git a/Completion/Unix/Command/_baz b/Completion/Unix/Command/_baz deleted file mode 100644 index 0acdc4639..000000000 --- a/Completion/Unix/Command/_baz +++ /dev/null @@ -1,585 +0,0 @@ -#compdef baz - -autoload -z is-at-least -local BAZ=$words[1] -local baz_version -local hide_short - -# ask the user which version of baz this is -if ! zstyle -s ":completion:${curcontext}:" baz-version baz_version; then - # ask baz instead - baz_version="${${$($BAZ --version)#baz Bazaar version }%% \(thelove@canonical.com*}" -fi - -# test whether to hide short options from completion -if zstyle -s ":completion:${curcontext}:" hide-shortopts hide_short; then - case $hide_short in - true|yes|on|1) hide_short='!' ;; - *) hide_short='' ;; - esac -fi - -# completion functions -(( $+functions[_baz_archives] )) || -_baz_archives () { _arch_archives baz "$@" } - -(( $+functions[_baz_categories] )) || -_baz_categories () { _arch_namespace baz 1 "$argv[@]" } - -(( $+functions[_baz_branches] )) || -_baz_branches () { _arch_namespace baz 2 "$argv[@]" } - -(( $+functions[_baz_versions] )) || -_baz_versions () { _arch_namespace baz 3 "$argv[@]" } - -(( $+functions[_baz_revisions] )) || -_baz_revisions () { _arch_namespace baz 4 "$argv[@]" } - -(( $+functions[_baz_local_revisions] )) || -_baz_local_revisions () { - local expl1 expl2 tree_version=`$BAZ tree-version` - _description -V applied-patches expl1 "patch from this version" - _description -V other-patches expl2 "patch from other versions" - compadd "$expl1[@]" `$BAZ logs` - compadd "$expl2[@]" `$BAZ logs --full $($BAZ log-versions | grep -v $tree_version)` - # This is incredibly slow. - # Should complete based on -A, -R, -d -} - -(( $+functions[_baz_config] )) || -_baz_config () { - local configdir root ret=1 n expl - - n=$opt_args[(i)(-d|--dir)] - [[ -n "$n" ]] && configdir=$opt_args[$n] - root="$(_call_program baz $BAZ tree-root ${configdir} 2>&1)" - if (( $? )); then - if [[ -d "configs" ]]; then - root=. - else - _message -e messages "Error: $root" - return $ret - fi - fi - - if [[ -d "$root/configs" ]]; then - configdir=("$root/configs") - _description files expl 'config file' - _files -W configdir "$expl[@]" && ret=0 - else - _message -e messages "No configs/ directory in tree whose root is $root" - fi - return $ret -} - -(( $+functions[_baz_limit] )) || -_baz_limit () { #presently only does push-mirror style limits - [[ $words[$CURRENT] == *@* ]] && return 1 - - local expl archive - archive=${words[(r)*@*]:-$($BAZ my-default-archive 2> /dev/null)} - if [ $archive ]; then - - if [[ $PREFIX != *--* ]]; then - _description -V categories expl "categories in $archive" - compadd -q -S -- "$expl[@]" `$BAZ category $archive` - else - _baz_namespace_branches 3 - fi - fi -} - -(( $+functions[_baz_tree_or_rev] )) || -_baz_tree_or_rev () { - _alternative 'trees:tree:_files -/' 'revisions:revision:_baz_revisions' -} - -(( $+functions[_baz_libraries] )) || -_baz_libraries () { - local libraries expl - libraries=($(_call_program baz $BAZ my-revision-library)) - _description -V libraries expl "revision library" - compadd "$expl[@]" -a libraries -} - -(( $+functions[_baz_my_revision_library] )) || -_baz_my_revision_library () { - if [[ -n $words[(r)-d] ]] || [[ -n $words[(r)--delete] ]]; then - _baz_libraries - else - _files -/ - fi -} - -(( $+functions[_baz_log_versions] )) || -_baz_log_versions () { - local logs expl - logs=($(_call_program baz $BAZ log-versions)) - _description -V versions expl "log version" - compadd "$expl[@]" -a logs -} - -# command argument definitions -# commands with different versions - -local cmd_register_archive cmd_archives cmd_ls_archives cmd_redo -local cmd_redo_changes cmd_what_changed cmd_categories -local cmd_branches cmd_versions cmd_cacherev cmd_logs cmd_log_versions -local cmd_log_ls cmd_update cmd_join_branch cmd_replay cmd_deltapatch -local cmd_delta_patch cmd_apply_delta cmd_sync_tree cmd_make_sync_tree -local cmd_delta cmd_revdelta cmd_library_categories cmd_library_branches -local cmd_library_versions cmd_library_revisions -local cmd_status cmd_diff - -cmd_log_ls=('*:version:_baz_log_versions') -cmd_log_versions=() -# the options should only complete items that are in the tree - -cmd_register_archive=('::archive:_baz_archives' ':location:_files -/') -cmd_archives=('::regex:') -cmd_redo=('::changeset:_files -/') -cmd_status=('::dir:_files -/') -cmd_diff=('::revision:_baz_revisions' - # ':separator:(--)' '*::limit:_files' - #don't understand the limit usage -) -cmd_categories=('::archive:_baz_archives') -cmd_branches=('::category:_baz_categories') -cmd_versions=('::branch:_baz_branches') -cmd_cacherev=('::revision:_baz_revisions') -#should only complete non-cached revisions - -cmd_logs=($cmd_log_ls) -cmd_update=('::revision:_baz_revisions') -cmd_join_branch=(':revision:_baz_revisions') -#should only complete continuation revisions - -cmd_replay=('*::revision:_baz_revisions') -cmd_deltapatch=(':FROM:_baz_tree_or_rev' ':TO:_baz_tree_or_rev') -cmd_sync_tree=(':revision:_baz_revisions') -cmd_delta=(':FROM:_baz_tree_or_rev' ':TO:_baz_tree_or_rev' '::DEST:_files -/') -cmd_library_categories=('::archive:_baz_archives --library') -cmd_library_branches=('::category:_baz_categories --library') -cmd_library_versions=('::branch:_baz_branches --library') -cmd_library_revisions=('::version:_baz_versions --library') - -cmd_ls_archives=($cmd_archives) -cmd_redo_changes=($cmd_redo) -cmd_what_changed=($cmd_changes) -cmd_delta_patch=($cmd_deltapatch) -cmd_apply_delta=($cmd_deltapatch) -cmd_make_sync_tree=($cmd_sync_tree) -cmd_revdelta=($cmd_delta) - -# commands the same in all versions - -local cmd_help -cmd_help=() - -local cmd_my_id -cmd_my_id=('::id-string:') - -local cmd_my_default_archive -cmd_my_default_archive=('::archive:_baz_archives') - -local cmd_whereis_archive -cmd_whereis_archive=(':archive:_baz_archives') - -local cmd_init_tree -cmd_init_tree=('::version:_baz_versions') - -local cmd_tree_id -cmd_tree_id=('::directory:_files -/') - -local cmd_tree_root -cmd_tree_root=('::directory:_files -/') - -local cmd_tree_version -cmd_tree_version=(':version:_baz_versions') - -local cmd_build_config cmd_buildcfg -cmd_build_config=(':config:_baz_config') -cmd_buildcfg=($cmd_build_config) - -local cmd_cat_config cmd_catcfg cmd_cfgcat -cmd_cat_config=(':config:_baz_config') -cmd_catcfg=($cmd_cat_config) -cmd_cfgcat=($cmd_cat_config) - -local cmd_undo cmd_undo_changes -cmd_undo=('::revision:_baz_revisions') -cmd_undo_changes=($cmd_undo) - -local cmd_file_diffs -cmd_file_diffs=(':file:_files' '::revision:_baz_revisions') - -local cmd_file_find -cmd_file_find=(':file:_files' '::revision:_baz_revisions') - -local cmd_inventory cmd_srcfind -cmd_inventory=('::separator:(--)' '*:directory:_files -/') -cmd_srcfind=($cmd_inventory) - -local cmd_lint -cmd_lint=('::directory:_files -/') - -local cmd_id cmd_invtag -cmd_id=('*:file:_files') -cmd_invtag=($cmd_id) - -local cmd_id_tagging_method cmd_tagging_method methods -cmd_id_tagging_method=('::tagging method:(($methods))') -methods=( - 'names:use naming conventions only' - 'implicit:use naming conventions but permit for inventory tags' - 'tagline:use naming conventions but permit for inventory tags' - 'explicit:require explicit designation of source' -) -cmd_tagging_method=($cmd_id_tagging_method) - -local cmd_add cmd_add_id cmd_add_tag -cmd_add=('*:file to add:_files') -cmd_add_id=($cmd_add) -cmd_add_tag=($cmd_add) - -local cmd_delete cmd_delete_id cmd_delete_tag -cmd_delete=('*:file to delete:_files') -cmd_delete_id=($cmd_delete) -cmd_delete_tag=($cmd_delete) - -local cmd_move cmd_move_id cmd_move_tag -cmd_move_id=(':old name:_files' ':new name:_files') -cmd_move_id=($cmd_move) -cmd_move_tag=($cmd_move) -#would be nice not to offer dirs for newname if oldname is a file, and -#vice versa - -local cmd_mv -cmd_mv=('*:file:_files') -# not really right, but close enough - -local cmd_default_id cmd_explicit_default cmd_default_tag -cmd_default_id=('::TAG-PREFIX:') -cmd_explicit_default=($cmd_default_id) -cmd_default_tag=($cmd_default_id) - -local cmd_tagging_defaults cmd_id_tagging_defaults -cmd_tagging_defaults=() -cmd_id_tagging_defaults=($cmd_tagging_defaults) - -local cmd_changeset cmd_mkpatch -cmd_changeset=( - ':ORIG:_files -/' - ':MOD:_files -/' - ':DEST:_files -/' - '*:file:_files' -) -cmd_mkpatch=("$cmd_changeset[@]") - -local cmd_dopatch cmd_do_changeset cmd_apply_changeset -cmd_dopatch=(':changeset:_files -/' ':target:_files -/') -cmd_do_changeset=($cmd_dopatch) -cmd_apply_changeset=($cmd_dopatch) - -local cmd_show_changeset -cmd_show_changeset=('::changeset:_files -/') - -local cmd_make_archive -cmd_make_archive=('::name:' ':location:_files -/') - -local cmd_archive_setup -cmd_archive_setup=('*:version:_baz_branches --trailing-dashes') - -local cmd_make_category -cmd_make_category=(':category:_baz_archives -S /') - -local cmd_make_branch -cmd_make_branch=(':branch:_baz_categories --trailing-dashes') - -local cmd_make_version -cmd_make_version=(':version:_baz_branches --trailing-dashes') - -local cmd_import cmd_imprev -cmd_import=('::version:_baz_versions') -cmd_imprev=($cmd_import) - -local cmd_commit cmd_cmtrev -cmd_commit=('*:file:_files') -cmd_cmtrev=($cmd_commit) - -local cmd_get cmd_getrev -cmd_get=(':revision:_baz_revisions' '::directory:_files -/') -cmd_getrev=($cmd_get) - -local cmd_get_patch cmd_get_changeset -cmd_get_patch=(':revision:_baz_revisions' '::dir:_files -/') -cmd_get_changeset=($cmd_get_patch) - -local cmd_lock_revision -cmd_lock_revision=(':revision:_baz_revisions') - -local cmd_push_mirror cmd_archive_mirror -cmd_push_mirror=( - '::FROM or MINE:_baz_archives' - '::TO:_baz_archives' - '::LIMIT:_baz_limit' -) -cmd_archive_mirror=($cmd_push_mirror) - -local cmd_revisions -cmd_revisions=('::version:_baz_versions') - -local cmd_ancestry -cmd_ancestry=('::revision:_baz_revisions') - -local cmd_ancestry_graph -cmd_ancestry_graph=('::revision:_baz_revisions') - -local cmd_cat_archive_log -cmd_cat_archive_log=(':revision:_baz_revisions') - -local cmd_cachedrevs -cmd_cachedrevs=(':version:_baz_versions') - -local cmd_uncacherev -cmd_uncacherev=(':revision:_baz_revisions' '::dir:_files -/') - -local cmd_archive_meta_info -cmd_archive_meta_info=(':item-name:((name\:foo mirror\:bar))') - -local cmd_archive_snapshot -cmd_archive_snapshot=(':dir:_files -/' '::limit:_baz_revisions') - -local cmd_archive_version -cmd_archive_version=() - -local cmd_archive_fixup -cmd_archive_fixup=() - -local cmd_make_log -cmd_make_log=('::version:_baz_versions') - -local cmd_add_log cmd_add_log_version -cmd_add_log=(':version:_baz_versions') -cmd_add_log_version=($cmd_add_log) - -local cmd_remove_log cmd_remove_log_version -cmd_remove_log=(':version:_baz_log_versions') -cmd_remove_log_version=($cmd_remove_log) - -local cmd_abrowse -cmd_abrowse=('::LIMIT:_baz_revisions') - -local cmd_cat_log -cmd_cat_log=(':revision-spec:_baz_local_revisions') - -local cmd_changelog -cmd_changelog=('::version:_baz_versions') - -local cmd_log_for_merge -cmd_log_for_merge=('::version:_baz_versions') - -local cmd_merges -cmd_merges=(':INTO:_baz_revisions' '::FROM:_baz_revisions') - -local cmd_new_merges -cmd_new_merges=('::version:_baz_versions') - -local cmd_branch -cmd_branch=(':SOURCE-REVISION:_baz_revisions' ':TAG-VERSION:_baz_versions') - -local cmd_merge -cmd_merge=(':FROM:_baz_revisions') - -local cmd_missing cmd_whats_missing -cmd_missing=('::revision:_baz_revisions') -cmd_whats_missing=($cmd_missing) - -local cmd_pristines cmd_ls_pristines -cmd_pristines=('::limit:_baz_revisions') -cmd_ls_pristines=($cmd_pristines) - -local cmd_lock_pristine -cmd_lock_pristine=(':revision:_baz_revisions') - -local cmd_add_pristine -cmd_add_pristine=(':revision:_baz_revisions') - -local cmd_find_pristine -cmd_find_pristine=(':revision:_baz_revisions') - -local cmd_my_revision_library -cmd_my_revision_library=(':library:_baz_my_revision_library') - -local cmd_library_find -cmd_library_find=(':revision:_baz_revisions --library') - -local cmd_library_add -cmd_library_add=(':revision:_baz_revisions --exclude-library-revisions') - -local cmd_library_remove -cmd_library_remove=(':revision:_baz_revisions --library') - -local cmd_library_archives -cmd_library_archives=() - -local cmd_library_log -cmd_library_log=(':revision:_baz_revisions --library') - -local cmd_library_file -cmd_library_file=(':file:_files' ':revision:_baz_revisions --library') - -local cmd_grab -cmd_grab=(':location:_files') - -local cmd_parse_package_name -cmd_parse_package_name=(':name:') - -local cmd_valid_package_name -cmd_valid_package_name=(':name:') - -local cmd_library_config -cmd_library_config=(':library:_baz_libraries') - -local cmd_rbrowse -cmd_rbrowse=('::regular expression:') - -local cmd_rm -cmd_rm=('*:file:_files') - -local cmd_escape -cmd_escape=(':string:') - -local cmd_switch -cmd_switch=(':revision:_baz_revisions') - -#mutually exclusive options - -local -A excludes -excludes=( -# This first line means that if --output was given, don't complete -# --no-output or --keep. The converse is not true. ---output '--no-output --keep' ---no-output --output - ---silent ' --quiet --report --verbose --debug' ---quiet '--silent --report --verbose --debug' ---report '--silent --quiet --verbose --debug' ---verbose '--silent --quiet --report --debug' ---debug '--silent --quiet --report --verbose ' - ---sparse --non-sparse ---non-sparse --sparse - ---files ' --directories --both' ---directories '--files --both' ---both '--files --directories ' - ---mirror --mirror-from ---mirror-from --mirror - ---no-cached --cached-tags ---cached-tags --no-cached - ---non-greedy --greedy ---greedy --non-greedy -) - -_baz_main () { - typeset -A opt_args - local arguments - if (( CURRENT > 2 )); then - local cmd=${words[2]} - local var_cmd=cmd_${cmd//-/_} - curcontext="${curcontext%:*:*}:baz-$cmd:" - (( CURRENT-- )) - shift words - - arguments=() - local input - input=(${${(M)${(f)"$($BAZ $cmd -h)"}:# *}# }) - - local i j=1 - local short long arg desc action - short=() - long=() - arg=() - desc=() - action=() - for (( i=1 ; i <= ${#input} ; i++ )); do - [[ "$input[i]" != *[^\ ]* ]] && continue # stupid blank lines - short[j]="${${${input[i]}[1,2]}#--}" - long[j]="${${input[i]#-?, }%% *}" - - arg[j]="${${${input[i]%% *}##* }##-*}" - [[ $long[j] == --archive ]] && arg[j]=ARCHIVE # baz doesn't mention this - - desc[j]="${input[i]##* }" - if [[ "$input[i+1]" == \ *[^\ ]* ]]; then # description continues - (( i++ )) - desc[j]="$desc[j] ${input[i]##* }" - fi - [[ "$short[j]" == -[hHV] ]] && continue - desc[j]="${${desc[j]//\[/\\[}//\]/\\]}" # escape brackets - - case $arg[j] in - DIR|PATCH-DIR|DEST|OUTPUT|PATH) - action[j]='_files -/' ;; - FILES|FILE|SNAP-FILE) - action[j]='_files' ;; - MASTER|MASTER-SOURCE|ARCHIVE) - action[j]='_baz_archives' ;; - CATEGORY) - action[j]='_baz_categories' ;; - BRANCH) - action[j]='_baz_branches' ;; - VERSION) - action[j]='_baz_versions' ;; - CFG) - action[j]='_baz_configs' ;; - LIB) - action[j]='_baz_libraries' ;; -# PATCH,FILE) # not sure how to complete this -# action[j]='_baz_patch_file' ;; - *) - action[j]='' ;; - esac - - (( j++ )) - - done - - local excluded k - for (( i = 1 ; i < j ; i++ )); do - excluded=($short[i] $long[i]) - foreach opt (${=excludes[$long[i]]}) - k=$long[(i)$opt] - excluded=($excluded $short[k] $long[k]) - #excludes matching short options too :-) - end - - - # generate arguments to _arguments ;-) - # make long and short options mutually exclusive - [ $short[i] ] && arguments=("$arguments[@]" - "${hide_short}(${excluded})${short[i]}[${desc[i]}]${arg[i]:+:$arg[i]:$action[i]}") - [ $long[i] ] && arguments=("$arguments[@]" - "(${excluded})${long[i]}[${desc[i]}]${arg[i]:+:$arg[i]:$action[i]}") - done - - arguments=("$arguments[@]" "${(@P)var_cmd-*:FILE:_files}") - else - local help - local -U cmds - help=(${(f)"$($BAZ help)"}) - cmds=(${${${${(M)help:#* :*}/ #: #/:}%% ##}## #}) - arguments=(':command:(($cmds))') - fi - _arguments -S -A '-*' \ - {"${hide_short}(: -)-V",'(: -)--version'}'[display version]' \ - {"${hide_short}(: -)-h",'(: -)--help'}'[display help]' \ - '(: -)-H[display verbose help]' \ - "$arguments[@]" -} - -_baz_main "$@" diff --git a/Completion/Unix/Command/_bittorrent b/Completion/Unix/Command/_bittorrent deleted file mode 100644 index 1fbab35ef..000000000 --- a/Completion/Unix/Command/_bittorrent +++ /dev/null @@ -1,100 +0,0 @@ -#compdef btdownloadcurses btdownloadheadless btdownloadgui btlaunchmany btlaunchmanycurses bttrack btshowmetainfo btreannounce btmakemetafile btrename - -# Bittorrent completion commands. Originally written by Jussi -# Pakkanen, 2004. Most of the command descriptions are from the Debian -# project's man pages. - -# Modified by R.Ramkumar, 2006 to conform to zsh completion standards and -# enhance completion for certain options. - -case $service in - -# Start with the clients. - - btdownloadcurses) - ;& - btdownloadheadless) - ;& - btdownloadgui) - ;& - btlaunchmany) - ;& - btlaunchmanycurses) - _arguments -s -S \ - '(--responsefile)--responsefile+[specify file for server response]:file:_files'\ - "--url+[specify URL of torrent file]:URL:_urls"\ - '(-i --ip)'{-i+,--ip+}'[specify ip address to report as]:ip address'\ - "--bind+[specify ip to bind to instead of default]:ip:_bind_addresses"\ - "--minport+[specify minimum port to listen to]:port:"\ - "--maxport+[specify maximum port to listen to]:port:"\ - "--saveas+[specify file to save to]:file:_files -/"\ - "--max_uploads+[specify maximum amount of uploads]:uploads:"\ - "--max_upload_rate+[specify maximum upload rate]:rate (kb):"\ - "--keepalive_interval+[specify pause between keepalives]:time (s):"\ - "--download_slice_size+[specify bytes to query per request]:size (b):"\ - "--request_backlog+[specify number of requests to keep in a single pipe]:requests:"\ - "--max_message_length+[specify maximum length of prefix encoding]:size (b):"\ - "--timeout+[specify timeout before closing sockets on receiving nothing]:timeout (s):"\ - "--timeout_check_interval+[specify interval to check for connection time]:time interval (s):"\ - "--max_slice_length+[specify maximum size of requests accepted from peers]:size (b):"\ - "--max_rate_recalculate_interval+[specify length of pauses leading to reduced rate]:time (s):"\ - "--max_rate_period+[specify maximum time taken to guess the current rate estimate]:time (s):"\ - "--upload_rate_fudge+[specify time equivalent of writing to kernel TCP buffer]:time (s):"\ - "--display_interval+[specify time between updates to displayed information]:time (s):"\ - "--rerequest_interval+[specify time between requests for more peers]:time (s)"\ - "--min_peers+[specify peers needed before stopping or delaying requests for peers]:peers:"\ - "--http_timeout+[specify timeout for http connections]:timeout (s):"\ - "--snub_time+[specify timeout to decide that connection is semi-permanently choked]:timeout (s):"\ - "--spew+[display diagnostic info to stdout]:enable:(0 1)"\ - "--check_hashes+[check hashes on disk]:enable:(0 1)"\ - "--max_initiate+[specify peers needed before stopping initiating new connections]:peers:"\ - "--report_hash_failures+[report hash failures to user]:enable:(0 1)"\ - "--rarest_first_priority_cutoff+[specify peers which need to have a piece before other partials take priority over rarest first]:peers:"\ - ':torrent file:_files -g "*.torrent(-.)"' - return - ;; - -# Next up are the torrent file manipulation programs. - - btshowmetainfo) - _files -g "*.torrent(-.)" && return - ;; - - btrename) - _files -g '*.torrent(-.)' && return - ;; - - btmakemetafile) - _arguments -s -S \ - '--piece_size_pow2+[specify power of 2 to set the piece size to]:power:' \ - "--comment+[specify human-readable comment to put in .torrent]:comment:"\ - "--target+[specify target file for the torrent]:file:_files"\ - ':file:_files' - return - ;; - - btreannounce) - _files -g '*.torrent(-.)' && return - ;; - -# Lastly the tracker. - - bttrack) - _arguments -s -S \ - "--port+[specify port to listen on]:port number:" \ - "--dfile+[specify file to store recent downloader info]:file:_files" \ - "--bind+[specify ip to bind to]:bind address:_bind_addresses" \ - "--socket_timeout+[specify timeout for closing connections]:timeout (s):"\ - "--save_dfile_interval+[specify interval between saving dfile]:time (s):"\ - "--timeout_downloaders_interval+[timeout for expiring downloaders]:time (s):" \ - "--reannounce_interval+[specify interval downloaders should wait between reannouncements]:time (s):" \ - "--response_size+[specify peers to send in an info message]:peers:" \ - "--timeout_check_interval+[specify connection timeout]:timeout (s):"\ - "--nat_check=[check back and ban downloaders behind NAT]:enable:(0 1)" \ - "--min_time_between_log_flushes+[specify minimum time between log flushes]:time (s):" \ - "--allowed_dir+[specify directory having downloadable torrents]:directory:_files -/" \ - "--parse_allowed_interval+[specify interval between reloading allowed_dir]:time (min):" \ - "--show_names+[display names from allowed dir]:enable:(0 1)" - return - ;; -esac diff --git a/Completion/Unix/Command/_cat b/Completion/Unix/Command/_cat index 78c35653c..d15c5f93c 100644 --- a/Completion/Unix/Command/_cat +++ b/Completion/Unix/Command/_cat @@ -1,65 +1,73 @@ #compdef cat gcat +local ign local -a args if _pick_variant gnu='(GNU|uutils)' unix --version; then + (( $#words > 2 )) && ign='!(- : *)' args=( '(-A --show-all)'{-A,--show-all}'[equivalent to -vET]' '(-b --number-nonblank -n --number)'{-b,--number-nonblank}'[number nonempty output lines, overrides -n]' '-e[equivalent to -vE]' - '(-E --show-ends)'{-E,--show-ends}'[display $ at end of each line]' + '(-E --show-ends)'{-E,--show-ends}'[display $ or ^M$ at end of each line]' '(-n --number)'{-n,--number}'[number all output lines]' '(-s --squeeze-blank)'{-s,--squeeze-blank}'[suppress repeated empty output lines]' '-t[equivalent to -vT]' '(-T --show-tabs)'{-T,--show-tabs}'[display TAB characters as ^I]' '-u[ignored]' '(-v --show-nonprinting)'{-v,--show-nonprinting}'[use ^ and M- notation, except for LFD and TAB]' - '(- : *)--help[display help and exit]' - '(- : *)--version[output version information and exit]' + "$ign--help[display help and exit]" + "$ign--version[display version information]" '*: :_files' ) - -elif [[ "$OSTYPE" == (*bsd|dragonfly|darwin)* ]]; then - args=( - -A "-*" +else + # POSIX requires just '-u' + args=( -A "-?*" '(-n)-b[number non-blank output lines]' '(-v)-e[display $ at the end of each line (implies -v)]' - '-n[number all output lines]' - '-s[squeeze multiple blank lines into one]' - '(-v)-t[display tab as ^I (implies -v)]' - '-u[do not buffer output]' '-v[display non-printing chars as ^X or M-a]' - '*: :_files' - ) - [[ $OSTYPE = (free|net)bsd* ]] && args+=( - '-l[set a lock on the stdout file descriptor]' - ) - [[ $OSTYPE = netbsd* ]] && args+=( - '-B+[read with buffer of specified size]:size (bytes)' - '-f[only attempt to display regular files]' - ) - [[ $OSTYPE = darwin* ]] && args+=( - '-l[set an exclusive advisory lock on standard output]' - ) -elif [[ $OSTYPE = solaris* ]]; then - args=( - -A "-*" - '(-b)-n[number all output lines]' - '(-n)-b[number non-blank output lines]' - "-u[don't buffer output]" - '-s[be silent about non-existent files]' - '-v[display non-printing chars as ^X or M-a]' - '-e[display $ at the end of each line (requires -v)]' - '-t[display tab as ^I and formfeeds and ^L (requires -v)]' - '*: :_files' - ) -else - # POSIX requires '-u', and most OSes may support '-n' - args=( '-n[number all output lines]' - '-u[do not buffer output]' + "-u[don't buffer output]" '*: :_files' ) + case $OSTYPE in + (*bsd|dragonfly|darwin)*) + args+=( + '-s[squeeze multiple blank lines into one]' + '(-v)-t[display tab as ^I (implies -v)]' + ) + ;| + (free|net)bsd*) + args+=( + '-l[set a lock on the stdout file descriptor]' + ) + ;| + aix*|solaris*) + args+=( + '(-q)-s[be silent about non-existent files]' + '-t[display tab as ^I and formfeeds and ^L (requires -v)]' + ) + ;| + + aix*) + args+=( + '(-s)-q[be silent about non-existent files]' + '(-r -S)'{-r,-S}'[condense consecutive blank lines to one line]' + '-Z[dump encrypted files in encrypted format]' + ) + ;; + netbsd*) + args+=( + '-B+[read with buffer of specified size]:size (bytes)' + '-f[only attempt to display regular files]' + ) + ;; + darwin*) + args+=( + '-l[set an exclusive advisory lock on standard output]' + ) + ;; + esac fi _arguments -s -S $args diff --git a/Completion/Unix/Command/_cdrecord b/Completion/Unix/Command/_cdrecord index 602cd5e8e..e429d7bfa 100644 --- a/Completion/Unix/Command/_cdrecord +++ b/Completion/Unix/Command/_cdrecord @@ -80,8 +80,8 @@ if [[ -n $state ]]; then 'mcn[set media catalog number for this CD]:text' \ 'isrc[set isrc number for the next track]:text' \ 'index[set the index list for the next track]:list' \ - 'textfile[set the file with CD-Text data]:name:_files -g "*.inf(-.)"' \ - 'cuefile[set the file with CDRWIN CUE data]:name:_files -g "*.cue(-.)"' && ret=0 + 'textfile[set the file with CD-Text data]:name:_tilde_files -g "*.inf(-.)"' \ + 'cuefile[set the file with CDRWIN CUE data]:name:_tilde_files -g "*.cue(-.)"' && ret=0 fi _requested files expl track _files && ret=0 (( ret )) || break diff --git a/Completion/Unix/Command/_clay b/Completion/Unix/Command/_clay deleted file mode 100644 index 581338b8b..000000000 --- a/Completion/Unix/Command/_clay +++ /dev/null @@ -1,42 +0,0 @@ -#compdef clay - -# Completion for the Clay Programming Language -# http://claylabs.com/clay/ - -_arguments -C \ - "-o:specify output file:_files" \ - "-target:set target platform for code generation" \ - "-shared[create a dynamically linkable library]" \ - "-emit-llvm[emit llvm code]" \ - "-S[emit assembler code]" \ - "-c[emit object code]" \ - "-D-:set flag value" \ - "-O-:set optimization level:(0 1 2 3)" \ - "-g[keep debug symbol information]" \ - "-exceptions[enable exception handling]" \ - "-no-exceptions[disable exception handling]" \ - "-inline[inline procedures marked 'forceinline']" \ - "-no-inline[ignore 'inline' and 'forceinline' keyword]" \ - "-import-externals[include externals from imported modules]" \ - "-no-import-externals[don't include externals from imported modules]" \ - "-pic[generate position independent code]" \ - "-abort[abort on error (to get stacktrace in gdb)]" \ - "-run[execute the program without writing to disk]" \ - "-timing[show timing information]" \ - "-full-match-errors[show universal patterns in match failure errors]" \ - "-log-match:log overload matching behavior for calls" \ - "-arch:build for Darwin architecture <arch>" \ - "-F-:add <dir> to framework search path:_files -/" \ - "-framework:link with framework <name>" \ - "-L:add <dir> to library search path:_files -/" \ - "-Wl,-:pass flags to linker" \ - "-l-:link with library <lib>" \ - "-I+:add <path> to clay module search path:_files -/" \ - "-deps[keep track of the dependencies of the currently]" \ - "-no-deps[don't generate dependencies file]" \ - "-o-deps:write the dependencies to this file" \ - "-e:compile and run <source> (implies -run)" \ - "-M-:import <module>.*; for -e" \ - "-v[display version info]" \ - ":program file:_files -g '*.clay(-.)'" - diff --git a/Completion/Unix/Command/_column b/Completion/Unix/Command/_column index 737bb4561..d9f397f23 100644 --- a/Completion/Unix/Command/_column +++ b/Completion/Unix/Command/_column @@ -32,10 +32,11 @@ case $variant in + fill '(info table text json -x --fillrows)'{-x,--fillrows}'[print across before down]' + table - '(info fill -t --table)'{-t,--table}'[create a table]' + '(info fill -t --table -S --use-spaces)'{-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 -s --input-separator --separator)'{-s+,--input-separator=,--separator=}'[specify column delimiters in input data]:delimiters' '(info fill -O --table-order)'{-O+,--table-order=}'[specify order of output columns]: :->columns' + '(info)--table-colorscheme=[specify color scheme name]:name [column]' '(info fill -N --table-columns)*'{-C+,--table-column=}'[specify column properties]: :_values -s, -S= property "name[column name]\:name" "trunc[truncate text in the columns when necessary]" @@ -54,13 +55,16 @@ case $variant in '(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-header-repeat)'{-e,--table-header-repeat}'[repeat header for each page]' + '(info fill json -K --table-header-as-columns)'{-K,--table-header-as-columns}'[use first row as table header]' '(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)--wrap-separator=[wrap at specified separator]:string' '(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' + '(info table json -S --use-spaces)'{-S+,--use-spaces=}'[minimal whitespace between columns (no tabs)]:spaces' + 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]' diff --git a/Completion/Unix/Command/_configure b/Completion/Unix/Command/_configure index 3b22b53db..9911b78ec 100644 --- a/Completion/Unix/Command/_configure +++ b/Completion/Unix/Command/_configure @@ -1,6 +1,11 @@ #compdef configure config.status -_arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \ +local ret=1 +local -a expl suf + +[[ -prefix - ]] || + ! zstyle -T ":completion:${curcontext}:options" prefix-needed && + _arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \ -s '((#s)--disable- --enable- (#s)--enable- --disable- (#s)--with- --without- @@ -8,4 +13,19 @@ _arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \ '*=(E|)PREFIX*:prefix directory:_files -/' \ '*=PROGRAM*:program:_command_names -e' \ '*=NAME*executable*:program:_command_names -e' \ - '*=NAME*:file:_files' + '*=NAME*:file:_files' && ret=0 + +if [[ ! -prefix - ]]; then + if [[ "$PREFIX" = *\=* ]]; then + compstate[parameter]="${PREFIX%%\=*}" + compset -P 1 '*=' + _value && ret=0 + else + compset -S '=*' || suf=( -r = -S = ) + _wanted -x variables expl variable compadd $suf \ + CC CFLAGS CPP CPPFLAGS CXX CXXFLAGS DEFS ERLCFLAGS FCFLAGS \ + FFLAGS GOFLAGS LDFLAGS LIBS OBJCFLAGS OBJCXXFLAGS && ret=0 + fi +fi + +return ret diff --git a/Completion/Unix/Command/_cplay b/Completion/Unix/Command/_cplay deleted file mode 100644 index f1755c1a1..000000000 --- a/Completion/Unix/Command/_cplay +++ /dev/null @@ -1,8 +0,0 @@ -#compdef cplay - -_arguments -s \ - '-n[enable restricted mode]' \ - '-r[toggle playlist repeat mode]' \ - '-R[toggle playlist random mode]' \ - '-v[toggle PCM and MASTER volume control]' \ - '*:playlist or directory or audio file:_files -g "*.(mp3|mp2|ogg|669|amf|ams|dsm|far|it|med|mod|mt2|mtm|okt|s3m|stm|ult|gdm|xm|m3u|pls|spx|wav|au)(-.)"' diff --git a/Completion/Unix/Command/_csplit b/Completion/Unix/Command/_csplit index b0ba1d7f4..eb354bd83 100644 --- a/Completion/Unix/Command/_csplit +++ b/Completion/Unix/Command/_csplit @@ -17,7 +17,7 @@ specs=( if _pick_variant gnu='(GNU|uutils)' unix --version; then # GNU coreutils 8.32 specs+=( - '(hv -b --suffix-format -n --digits)'{-b+,--suffix-format=}'[specify format for numbers in output file names]:format [%%02d]: ' + '(hv -b --suffix-format -n --digits)'{-b+,--suffix-format=}'[specify format for numbers in output file names]:format [%02d]: ' '(hv)--suppress-matched[suppress the lines matching the pattern]' '(hv -z --elide-empty)'{-z,--elide-empty-files}'[remove empty output files]' + hv @@ -44,7 +44,7 @@ case $state in elif compset -P '[0-9]*'; then _message 'line number' && ret=0 elif [[ ${words[CURRENT]} != -* ]] then - _message "line_number, '/regex/[offset]', '%%regex%%[offset]', or '{count}'" && ret=0 + _message "line_number, '/regex/[offset]', '%regex%[offset]', or '{count}'" && ret=0 fi esac diff --git a/Completion/Unix/Command/_drill b/Completion/Unix/Command/_drill index 68fa7917b..6ce634874 100644 --- a/Completion/Unix/Command/_drill +++ b/Completion/Unix/Command/_drill @@ -20,7 +20,7 @@ _arguments -s -S -C \ '(-4)-6[stay on ipv6]' \ '-a[fallback to EDNS0 and TCP if the answer is truncated]' \ '-b+[specify buffer size (defaults to 512 b)]:size (bytes) [512]' \ - '-c+[use specified file for rescursive nameserver configuration]:file [/etc/resolv.conf]:_files' \ + '-c+[use specified file for recursive nameserver configuration]:file [/etc/resolv.conf]:_files' \ '-k+[specify a file that contains a trusted DNSSEC key]:file:_files' \ '*-o+[set/unset header bits]:mnemonic (uppercase sets, lower unsets):_sequence compadd - QR qr AA aa TC tc RD rd CD cd RA ra AD ad' \ '-p+[use specified remote port number]:port:_ports' \ diff --git a/Completion/Unix/Command/_du b/Completion/Unix/Command/_du index 038811eb8..be2cbdfce 100644 --- a/Completion/Unix/Command/_du +++ b/Completion/Unix/Command/_du @@ -5,7 +5,7 @@ if _pick_variant gnu='(Free Soft|uutils)' unix --version /dummy/no-such-file; th _arguments -s \ '(-a --all -s --summarize)'{-a,--all}'[write counts for all files]' \ - '--apparent-size[print apparent sizes rather than disc usage]' \ + '(-A --apparent-size)'{-A,--apparent-size}'[print apparent sizes rather than disc usage]' \ '(-B --block-size -k)'{-B+,--block-size=}'[specify block size]:size (bytes)' \ '(-B --block-size -k --apparent-size -b --bytes)'{-b,--bytes}'[equivalent to --apparent-size --block-size=1]' \ '(-c --total)'{-c,--total}'[produce a grand total]' \ @@ -56,22 +56,22 @@ else local xdev='[skip directories on different filesystems]' for pattern arg in \ '(freebsd|darwin)*' '-A[apparent size instead of usage]' \ - '(darwin*|*bsd*|dragonfly*|solaris2.<10->)' '(-H -L -P)-H[follow symlinks on the command line]' \ + '(aix*|darwin*|*bsd*|dragonfly*|solaris2.<10->)' '(-H -L -P)-H[follow symlinks on the command line]' \ '(darwin|*bsd|dragonfly)*' '(-H -L -P)-P[do not follow symlinks (default)]' \ '(darwin|dragonfly|freebsd)*' '*-I+[ignore files/directories matching specified mask]:mask' \ '(darwin|*bsd|dragonfly)*' '(-a -s -d)-d+[display entry for directories up to specified depth]:depth' \ '(darwin*|*bsd*|dragonfly*|solaris2.<10->)' '(-k -m -g -B)-h[human readable output]' \ 'netbsd*' '-i[output inode usage instead of blocks]' \ - '(darwin*|freebsd*|netbsd*|solaris2.<11->)' '(-h -k -g -B)-m[use block size of 1M-byte]' \ - '(darwin|freebsd<8->.|netbsd)*' '(-h -k -m -B)-g[use block size of 1G-byte]' \ + '(aix*|darwin*|freebsd*|netbsd*|solaris2.<11->)' '(-h -k -g -B)-m[use block size of 1M-byte]' \ + '(aix|darwin|freebsd<8->.|netbsd)*' '(-h -k -m -B)-g[use block size of 1G-byte]' \ '(freebsd|darwin)*' '(-h -k -m -g)-B+[block size]:block size (bytes)' \ '(darwin|*bsd|dragonfly)*' '-c[display grand total]' \ - '(freebsd|darwin)*' '-l[count sizes many times if hard linked]' \ + '(aix|freebsd|darwin)*' '-l[count sizes many times if hard linked]' \ '(freebsd|netbsd)*' '-n[ignore files and directories with nodump flag set]' \ 'solaris*' "(-a)-o[don't add child directories' usage to parent's total]" \ '(freebsd|darwin)*' '-t+[report only entries for which size exceeds threshold]:threshold' \ 'solaris*' "-d$xdev" \ - '(darwin|*bsd|dragonfly|solaris)*' "-x$xdev" + '(aix|darwin|*bsd|dragonfly|solaris)*' "-x$xdev" do [[ $OSTYPE = $~pattern ]] && args+=( $arg ) done diff --git a/Completion/Unix/Command/_entr b/Completion/Unix/Command/_entr index 4fb984af2..ebd66ab72 100644 --- a/Completion/Unix/Command/_entr +++ b/Completion/Unix/Command/_entr @@ -13,6 +13,7 @@ _arguments -s -S \ '(*)-s[evaluate the first argument using interpreter specified by $SHELL]' \ '*-x[format custom exit status messages using a persistent awk(1) process]' \ '-z[exit after the utility completes]' \ + '(- *)-h[display usage information]' \ '(-): :->command' \ '*::arguments:_normal' && ret=0 diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg index 9c91fe386..33eb9c5f6 100644 --- a/Completion/Unix/Command/_ffmpeg +++ b/Completion/Unix/Command/_ffmpeg @@ -1,200 +1,1525 @@ #compdef ffmpeg -local curcontext="$curcontext" state line expl -typeset -A opt_args +# notes: +# - stream/file options modify the input/output file argument that follows, so +# ideally their arguments would be limited accordingly (e.g. -c would only +# show encoders before an output file). but it seemed like being too 'smart' +# about this could be very confusing/annoying. so we don't do that -(( $+functions[_ffmpeg_presets] )) || _ffmpeg_presets() { - local presets - presets=(~/.ffmpeg/*.ffpreset(:t:r) "$FFMPEG_DATADIR"/*.ffpreset(:t:r)) - _wanted ffmpeg-presets expl 'preset' compadd -a presets +# complete numeric argument +(( $+functions[_ffmpeg_numbers] )) || +_ffmpeg_numbers() { + # most numeric args support these suffixes, even when it's nonsensical, e.g. + # -framerate 1KiB specifies 8192 fps. and most options that only accept + # integer args nonetheless need -f here because of this + _numbers -f "$@" {K,M,G}{,i}{,B} } -(( $+functions[_ffmpeg_acodecs] )) || _ffmpeg_acodecs() { - local acodecs - acodecs=(copy ${${(M)${(f)"$(_call_program audio-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]A[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]}) - _wanted ffmpeg-audio-codecs expl 'force audio codec (''copy'' to copy stream)' compadd -a acodecs +# `compadd -R` helper for _ffmpeg_flags +(( $+functions[_ffmpeg_flags_remf] )) || +_ffmpeg_flags_remf() { + [[ $1 == 0 ]] || return + # swallow last char of inserted match if it was typed again + [[ $LBUFFER[-1] == $KEYS ]] && LBUFFER=${LBUFFER%?} } -(( $+functions[_ffmpeg_vcodecs] )) || _ffmpeg_vcodecs() { - local vcodecs - vcodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]V[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]}) - _wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a vcodecs +# complete flag argument (flag1+flag2-flag3) +# $1 ... => flag +(( $+functions[_ffmpeg_flags] )) || +_ffmpeg_flags() { + local ret=1 tag=${curtag:-flags} + local -a expl ca_opts ca_x_opts flags + local -A opth + + zparseopts -A opth -D -F - \ + M+:=ca_opts {x+:,X+:}=ca_x_opts 1 2 F: J: n o: q r: R: s: S: V: \ + || return + + flags=( ${@:#${PREFIX//:/\\:}(|:*)} ) + + compset -S '[+-]*' + compset -P '*[+-]' + + _describe -t $tag flag flags "${(@)ca_opts}" "${(@)ca_x_opts}" -S '' && ret=0 + + [[ $IPREFIX$PREFIX == *[+-] ]] || { + compset -P '*' + _wanted operators expl operator \ + compadd "${(@)ca_opts}" -R _ffmpeg_flags_remf -S '' - + - && ret=0 + } + + return ret } -(( $+functions[_ffmpeg_scodecs] )) || _ffmpeg_scodecs() { - local scodecs - scodecs=(copy ${${(M)${(f)"$(_call_program subtitle-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]S[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]}) - _wanted ffmpeg-subtitle-codecs expl 'force subtitle codec (''copy'' to copy stream)' compadd -a scodecs +# helper to get stream type char from stream specifier in previous word. this +# isn't quite accurate, but probably fine for most purposes +# $1 => param to assign to +(( $+functions[_ffmpeg_prev_ss_type] )) || +_ffmpeg_prev_ss_type() { + [[ $1 == (-|--) ]] && shift + case ${9::=${(Q)words[CURRENT-1]}} in + -[adsv]codec|-[av]f) + : ${(P)1::=${(U)9[2]}} + ;; + -(c|codec):(|*:*:)[adstvV](|:*)) ;& + -filter:(|*:*:)[avV](|:*)) + 8=${(M)9##*:[adstvV](:|)} + 8=${${8%:}##*:} + : ${(P)1::=${(U)8}} + ;; + *) return 1 ;; + esac } -(( $+functions[_ffmpeg_formats] )) || _ffmpeg_formats() { - local formats - formats=(${(ou)${=${(s:,:)${${(M)${(f)"$(_call_program formats $words[1] -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}}) - _wanted ffmpeg-formats expl 'force format' compadd -a formats +# complete stream specifier, usually after a colon-option like -c: +(( $+functions[_ffmpeg_stream_specs] )) || +_ffmpeg_stream_specs() { + # does it make sense to allow e.g. -c:a:a:... ? + if compset -P '([adstvV]|g:([^i:]*|i:*)|(p|disp):*):'; then + _ffmpeg_stream_specs + elif compset -P 'g:(\#|\\\#|i:)'; then + _message 'group ID' + elif compset -P g:; then + _message 'group specifier' + elif compset -P p:; then + _message 'program ID' + elif compset -P '(\#|\\\#|i:)'; then + _message 'stream ID' + elif compset -P m:; then + _message 'metadata tag key[:value]' + elif compset -P disp:; then + _sequence -s+ _ffmpeg_dispositions -I + else + local ret=1 + local -a ca_opts + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:}=ca_opts J: V: x: X: \ + || return + + _describe -t stream-specifier-types 'stream-type specifier' '( + a:"audio" + d:"data" + s:"subtitle" + t:"attachment" + v:"video (all)" + V:"video (not images)" + )' -qS: "${(@)ca_opts}" && ret=0 + _describe -t stream-specifier-others 'other stream specifier' \ + '( + g:"group index or ID" + i:"stream ID" + p:"program ID" + m:"metadata tag" + disp:"dispositions" + )' -r: -S: "${(@)ca_opts}" \ + -- \ + '( + u:"usable configuration" + )' "${(@)ca_opts}" && ret=0 + + return ret + fi } -(( $+functions[_ffmpeg_pix_fmts] )) || _ffmpeg_pix_fmts() { - local pix_fmts - _wanted ffmpeg-pix-fmts expl 'pixel format' compadd "$@" - \ - ${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *} +# complete metadata specifier +(( $+functions[_ffmpeg_metadata_specs] )) || +_ffmpeg_metadata_specs() { + if compset -P s:; then + _ffmpeg_stream_specs + elif compset -P c:; then + _message 'chapter index' + elif compset -P p:; then + _message 'program index' + else + _describe -t metadata-specs 'metadata specifier' \ + '( + c:"per-chapter metadata" + p:"per-program metadata" + s:"per-stream metadata" + )' -r: -S: \ + -- \ + '( + g:"global metadata" + )' + fi } -(( $+functions[_ffmpeg_bsfs] )) || _ffmpeg_bsfs() { - local bsfs - bsfs=(${${(f)"$(_call_program bsfs $words[1] -bsfs 2>/dev/null)"}:#*:}) - _wanted ffmpeg-bsfs expl 'set bitstream filter' compadd -a bsfs +# complete preset name +(( $+functions[_ffmpeg_presets] )) || +_ffmpeg_presets() { + local -a presets=( + ~/.ffmpeg + $FFMPEG_DATADIR + ${${${${(Q)words[1]}:c}%/bin/*}:-/usr}/share/ffmpeg + ) + presets=( $^presets/*.ffpreset(N:t:r) ) + _wanted presets expl preset compadd "$@" -a presets } -typeset -A _ffmpeg_flags +# complete codec or encoder/decoder (-codec et al accept either) +# -D => decoders, -E => encoders, -T => type (audio, video, etc) +(( $+functions[_ffmpeg_codecs] )) || +_ffmpeg_codecs() { + local ret=1 de=DE de_desc=encoder/decoder type=ADSTV type_desc + local -a ca_opts codecs encdecs + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,x+:,X+:}=ca_opts J: V: \ + D E T: \ + || return + + case ${(L)opth[-T]} in + a|aud*) type=A ;; + d|dat*) type=D ;; + s|sub*) type=S ;; + t|att*) type=T ;; + v|vid*) type=V ;; + *) _ffmpeg_prev_ss_type type ;; + esac + case $type in + A) type_desc=audio ;; + D) type_desc=data ;; + S) type_desc=subtitle ;; + T) type_desc=attachment ;; + V) type_desc=video ;; + esac + + if (( ${+opth[-D]} )); then + de=D de_desc=decoder + elif (( ${+opth[-E]} )); then + de=E de_desc=encoder + fi + + codecs=( ${(f)"$( _call_program codecs $words[1] -codecs )"} ) + codecs=( ${(M)codecs:# [ADILSTV. ](#c6) [^=]* *} ) + [[ $de == *D* ]] || codecs=( ${codecs:# D?*} ) + [[ $de == *E* ]] || codecs=( ${codecs:# ?E*} ) + codecs=( ${(M)codecs:# ??[$type]??? *} ) + codecs=( ${codecs# ?????? } ) + + # -decoders and -encoders don't include data/attachment + [[ $type == *[ASV]* ]] && { + [[ $de == *D* ]] && + encdecs+=( ${(f)"$( _call_program decoders $words[1] -decoders )"} ) + [[ $de == *E* ]] && + encdecs+=( ${(f)"$( _call_program encoders $words[1] -encoders )"} ) + + encdecs=( ${(M)encdecs:# [$type][ABDFSVX. ](#c5) [^=]* *} ) + encdecs=( ${encdecs# ?????? } ) + } + + if zstyle -t ":completion:$curcontext:$tag" verbose; then + codecs=( ${codecs%%[[:space:]]##\((decoders#|encoders#):*} ) + codecs=( ${${(@)codecs//:/\\:}/[[:space:]]##/:} ) + # _describe doesn't remove duplicates when there are descriptions + encdecs=( ${(u)encdecs} ) + encdecs=( ${${(@)encdecs//:/\\:}/[[:space:]]##/:} ) + else + codecs=( ${codecs%%[[:space:]]*} ) + encdecs=( ${encdecs%%[[:space:]]*} ) + fi -(( $+functions[_ffmpeg_flag_options] )) || _ffmpeg_flag_options() { - local expl - _wanted options expl 'flag' compadd -S '' -- {-,+}${^flag_options} + _describe -t codecs "${type_desc:+$type_desc }codec" \ + codecs "${(@)ca_opts}" && ret=0 + _describe -t encoders-decoders "${type_desc:+$type_desc }$de_desc" \ + encdecs "${(@)ca_opts}" && ret=0 + [[ $de == *E* && ${(Q)words[CURRENT-1]} == -(c|[adsv]#codec)(|:*) ]] && + _describe -t codecs-special 'copy option' '( copy:"copy stream" )' && ret=0 + + return ret } -(( $+functions[_ffmpeg_more_flag_options] )) || _ffmpeg_more_flag_options() { - compset -p $1 && _ffmpeg_flag_options +# complete format/muxer/demuxer/device +# -D => demuxer, -E => muxer, -v => device +(( $+functions[_ffmpeg_formats] )) || +_ffmpeg_formats() { + local dde=dDE tag=formats desc=format + local -a ca_opts tmp formats + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \ + D E v \ + || return + + if (( ${+opth[-D]} )); then + dde=D tag=demuxers desc=demuxer + elif (( ${+opth[-E]} )); then + dde=E tag=muxers desc=muxer + elif (( ${+opth[-v]} )); then + dde=d tag=devices desc=device + fi + + tmp=( ${(f)"$( _call_program formats $words[1] -formats )"} ) + tmp=( ${(M)tmp:# [dDE. ](#c3) [^=]* *} ) + [[ $dde == *D* ]] && formats+=( ${(M)tmp:# D?? *} ) + [[ $dde == *E* ]] && formats+=( ${(M)tmp:# ?E? *} ) + [[ $dde == *d* ]] && formats+=( ${(M)tmp:# ??d *} ) + formats=( ${formats# ??? } ) + + # some formats have multiple descriptions, e.g. 'matroska:Matroska' and + # 'matroska:Matroska / WebM'. ideally we would merge these together somehow + if zstyle -t ":completion:$curcontext:$tag" verbose; then + local f d + tmp=( ${${(@)formats//:/\\:}/[[:space:]]##/:} ) + formats=( ) + for f in $tmp; do + d=${f#*:} f=${f%%:*} + formats+=( ${^${(@s<,>)f}}:$d ) + done + formats=( ${(u)formats} ) + + else + formats=( ${(@s<,>)${(@)formats%%[[:space:]]*}} ) + fi + + _describe -t $tag $desc formats "${(@)ca_opts}" } -(( $+functions[_ffmpeg_new_flag_options] )) || _ffmpeg_new_flag_options() { - compset -P '*' && _ffmpeg_flag_options +# complete bitstream filter +# -I => single bsf +(( $+functions[_ffmpeg_bsfs] )) || +_ffmpeg_bsfs() { + local tag=bsfs desc='bitstream filter' + local -a ca_opts expl bsfs + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \ + I \ + || return + + bsfs=( ${(f)"$( _call_program $tag $words[1] -bsfs )"} ) + bsfs=( ${bsfs##[[:space:]]##} ) + bsfs=( ${bsfs:#*:} ) + + if (( ${+opth[-I]} )); then + _describe -t $tag $desc bsfs "${(@)ca_opts}" + else + _wanted $tag expl '' _values -s, -S= $desc \ + $^bsfs':bsf option (opt1=val1\:opt2=val2\:...):' + fi } -(( $+functions[_ffmpeg_flags] )) || _ffmpeg_flags() { - local -a flag_options - eval "flag_options=(\${=_ffmpeg_flags[$1]})" +# complete pixel format / hwaccel output format +# -H => hwaccel formats only +(( $+functions[_ffmpeg_pix_fmts] )) || +_ffmpeg_pix_fmts() { + local tag=pixel-formats desc='pixel format' + local -a ca_opts pixfmts + local -A opth - local match mbegin mend - integer ret=1 + zparseopts -A opth -D -F - \ + {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \ + H \ + || return - if [[ $PREFIX = (#b)(*)[-+]([^-+]#) ]]; then - if [[ -n ${flag_options[(R)$match[2]]} ]]; then - _ffmpeg_new_flag_options && ret=0 - fi - if [[ -n ${flag_options[(R)$match[2]?*]} ]]; then - _ffmpeg_more_flag_options ${#match[1]} && ret=0 - fi - else - _ffmpeg_flag_options && ret=0 - fi + pixfmts=( ${(f)"$( _call_program $tag $words[1] -pix_fmts )"} ) + pixfmts=( ${(M)pixfmts:#[BHIOP. ](#c5) [^=]* *} ) - return ret + (( ${+opth[-H]} )) && { + tag=hwaccel-formats desc='output format' + pixfmts=( ${(M)pixfmts:#??H?? *} ) + } + + pixfmts=( ${pixfmts#????? *} ) + pixfmts=( ${pixfmts%%[[:space:]]*} ) + + (( ${+opth[-H]} )) || { + compset -P + || pixfmts+=( + ) + } + + _describe -t $tag $desc pixfmts "${(@)ca_opts}" } -(( $+functions[_ffmpeg_register_lastopt_values] )) || _ffmpeg_register_lastopt_values() { - if (( lastopt_takesargs )); then - lastopt+=":$lastopt_description:" - if (( $#lastopt_values )); then - if [[ $lastopt_type == flags ]]; then - lastopt="*$lastopt" - flagtype=${${lastopt%%:*}#-} - lastopt+="->$flagtype" - _ffmpeg_flags[$flagtype]="${lastopt_values[*]}" - else - lastopt+="(${lastopt_values[*]})" - fi - fi - fi - _ffmpeg_argspecs+=$lastopt +# complete filter +(( $+functions[_ffmpeg_filters] )) || +_ffmpeg_filters() { + local MATCH MBEGIN MEND x y z tag=filters desc=filter type=AV + local -a ca_opts tmp filters + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \ + T: \ + || return + + case ${(L)opth[-T]} in + a|aud*) type=A ;; + v|vid*) type=V ;; + *) _ffmpeg_prev_ss_type type ;; + esac + case $type in + A) tag=audio-$tag desc="audio $desc" ;; + V) tag=video-$tag desc="video $desc" ;; + esac + + tmp=( ${(f)"$( _call_program filters $words[1] -filters )"} ) + tmp=( ${(M)tmp:#*-\>*} ) + tmp=( ${tmp# ?? } ) + tmp=( ${tmp/[ ]##/$'\t'} ) + tmp=( ${tmp/[ ]##/$'\t'} ) + + for x y z in "${(@ps<\t>)tmp}"; do + [[ ${y//[N$type]/} == $y ]] || + filters+=( $x:${z//:/\\:} ) + done + + if zstyle -t ":completion:$curcontext:$tag" verbose; then + # undo sentence case/punctuation + filters=( ${filters%.} ) + filters=( ${filters/(#m):[A-Z][a-z]/${(L)MATCH}} ) + else + filters=( ${filters%%:*} ) + fi + + _describe -t $tag $desc filters "${(@)ca_opts}" +} + +# complete filtergraph spec +(( $+functions[_ffmpeg_filtergraphs] )) || +_ffmpeg_filtergraphs() { + # [link][link] fltr@id=val:key=val:val, fltr@id [link]; fltr=val; ... + compset -P '*[];,]' + compset -P '[[:space:]]##' + compset -S '[;,[]*' + compset -S '[[:space:]]##' + + if compset -P '*\['; then + _message 'link label' + elif compset -P '*='; then + _message 'filter arguments ([key=]val:[key=]val:...)' + elif compset -P '*@'; then + _message 'filter ID' + else + _ffmpeg_filters -r$'@=,[; \t\n\-' -S, + fi +} + +# complete protocol +(( $+functions[_ffmpeg_protocols] )) || +_ffmpeg_protocols() { + local tag=protocols desc=protocol + local -a protocols + + protocols=( ${(f)"$( _call_program $tag $words[1] -protocols )"} ) + protocols=( ${protocols:#*:*} ) + protocols=( ${protocols##[[:space:]]##} ) + + _describe -t $tag $desc protocols "$@" +} + +# complete standard or custom channel layout +(( $+functions[_ffmpeg_layouts] )) || +_ffmpeg_layouts() { + local ret=1 + local -a tmp names layouts + + tmp=( ${(f)"$( _call_program layouts $words[1] -layouts )"} ) + tmp=( ${tmp##[[:space:]]##} ) + + names=( ${tmp[1,(R)*(#i)layouts*:*]} ) + names=( ${names:#(#i)*(NAME[[:space:]]##D|(channel|layout)*:)*} ) + names=( ${^${names/[[:space:]]##/\[}}\] ) + names=( $^names':custom name' ) + + layouts=( ${tmp[(R)*(#i)layouts*:*,-1]} ) + layouts=( ${layouts:#(#i)*(NAME[[:space:]]##D|layouts*:)*} ) + layouts=( ${layouts//:/\\:} ) + layouts=( ${layouts/[[:space:]]##/:} ) + + [[ $PREFIX == *[@+]* ]] || { + _describe -t channel-layouts 'standard channel layout' layouts && ret=0 + } + _values -s+ -S@ 'channel name' $names && ret=0 + + return ret } -local -a _ffmpeg_argspecs -{ - local lastopt REPLY - local lastopt_description - local lastopt_takesargs - local lastopt_type - local -a lastopt_values +# complete sample format +(( $+functions[_ffmpeg_sample_fmts] )) || +_ffmpeg_sample_fmts() { + local tag=sample-formats desc='sample format' + local -a sample_fmts + + sample_fmts=( ${(f)"$( _call_program $tag $words[1] -sample_fmts )"} ) + sample_fmts=( ${sample_fmts:#*(:|name[[:space:]]##desc)*} ) + sample_fmts=( ${sample_fmts##[[:space:]]##} ) + sample_fmts=( ${sample_fmts%%[[:space:]]*} ) + + _describe -t $tag $desc sample_fmts "$@" +} + +# complete hardware acceleration method +# -T => types only +(( $+functions[_ffmpeg_hwaccels] )) || +_ffmpeg_hwaccels() { + local tag=hwaccels desc='hardware acceleration method' + local -a ca_opts hwaccels + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \ + T \ + || return + + hwaccels=( ${(f)"$( _call_program $tag $words[1] -hwaccels )"} ) + hwaccels=( ${hwaccels##[[:space:]]##} ) + hwaccels=( ${hwaccels:#*:*} ) + + (( ${+opth[-T]} )) || hwaccels+=( none auto ) + + _describe -t $tag $desc hwaccels "${(@)ca_opts}" +} + +# complete hardware devices +(( $+functions[_ffmpeg_hw_devices] )) || +_ffmpeg_hw_devices() { + local i tag=hardware-devices desc='hardware device' + local -a ca_opts devices + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,x+:,X+:}=ca_opts J: V: \ + || return + + for (( i = 2; i <= CURRENT; i++ )); do + [[ ${(Q)words[i]} == -init_hw_device ]] || continue + devices+=( ${${${(Q)words[i+1]}#*=}%@*} ) + (( i++ )) + done + + # exclude name in current arg + [[ ${(Q)words[CURRENT-1]} == -init_hw_device ]] && + [[ ${i::=$IPREFIX$PREFIX} == *=* ]] && + devices=( ${devices:#${${i%%[@:,]*}#*=}} ) - _call_program options $words[1] -h 2>/dev/null | while IFS=$'\n' read -r; do - if [[ $REPLY == -* ]]; then - [[ -n $lastopt ]] && _ffmpeg_register_lastopt_values - lastopt=${REPLY%%[[:space:]]*} - lastopt_description=${REPLY##-[^[:space:]]##[[:space:]]##} - if [[ $lastopt_description == (#b)'<'(?##)'>'* ]]; then - lastopt_type=$match[1] - lastopt_description=${lastopt_description##<[^[:space:]]##>[[:space:]]##[^[:space:]]##[[:space:]]#} - if [[ -z $lastopt_description ]]; then - lastopt_description=$lastopt - fi - lastopt_description=${lastopt_description//:/\\:} - elif [[ $lastopt_description == [^[:space:]]##[[:space:]][[:space:]]* ]]; then - local example=${lastopt_description%% *} - example=${example//:/\\:} - lastopt_description=${lastopt_description##[^[:space:]]##[[:space:]]##} - lastopt_description=${lastopt_description//:/\\:} - if [[ $example == filename ]]; then - lastopt_takesargs=0 - lastopt+=":${lastopt_description}:_files" - elif [[ $lastopt == -[asv]pre ]]; then - lastopt_takesargs=0 - lastopt="*$lastopt" - lastopt+=": :_ffmpeg_presets" - elif [[ $lastopt == -acodec ]]; then - lastopt_takesargs=0 - lastopt+=": :_ffmpeg_acodecs" - elif [[ $lastopt == -vcodec ]]; then - lastopt_takesargs=0 - lastopt+=": :_ffmpeg_vcodecs" - elif [[ $lastopt == -scodec ]]; then - lastopt_takesargs=0 - lastopt+=": :_ffmpeg_scodecs" - elif [[ $lastopt == -f ]]; then - lastopt_takesargs=0 - lastopt="*$lastopt" - lastopt+=": :_ffmpeg_formats" - elif [[ $lastopt == -pix_fmt ]]; then - lastopt_takesargs=0 - lastopt="*$lastopt" - lastopt+=":set pixel format:_ffmpeg_pix_fmts" - elif [[ $example == bitstream_filter ]]; then - lastopt_takesargs=0 - lastopt+=": :_ffmpeg_bsfs" - else - lastopt_takesargs=1 - lastopt_description+=" ($example)" - fi - else - lastopt_takesargs=0 - if [[ $lastopt == -vfilters ]]; then - lastopt+=": :->vfilters" - fi - fi - lastopt_values=() - elif [[ $REPLY == ' '* ]]; then - REPLY=${REPLY##[[:space:]]##} - REPLY=${REPLY%%[[:space:]]##*} - lastopt_takesargs=1 - lastopt_values+=$REPLY - fi + _alternative -O ca_opts \ + "$tag:$desc:( ${(j< >)${(@q+)devices}} )" \ + "$tag:$desc:_ffmpeg_hwaccels -T" +} + +# complete hardware devices init spec +(( $+functions[_ffmpeg_hw_device_inits] )) || +_ffmpeg_hw_device_inits() { + local -a expl + if compset -P '*,*=' && [[ $PREFIX != *,* ]]; then + _wanted values expl 'device parameter value' _files -qS, + elif compset -P '*,'; then + _message 'device parameter (key=val)' + elif compset -P '*@'; then + _ffmpeg_hw_devices + elif compset -P '*:'; then + _wanted devices expl device _files -qS, + elif compset -P '*='; then + _message 'hardware device name' + else + _ffmpeg_hwaccels -T -qS= + fi +} + +# complete input/output devices +(( $+functions[_ffmpeg_devices] )) || +_ffmpeg_devices() { + local de=DE tag=devices desc=device + local -a ca_opts tmp devices + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \ + D E \ + || return + + if (( ${+opth[-D]} )); then + de=D tag=input-$tag desc="input $desc" + elif (( ${+opth[-E]} )); then + de=E tag=output-$tag desc="output $desc" + fi + + tmp=( ${(f)"$( _call_program devices $words[1] -devices )"} ) + tmp=( ${(M)tmp:# [DE. ](#c2) [^=]* *} ) + + [[ $de == *D* ]] && devices+=( ${(M)tmp:# D? *} ) + [[ $de == *E* ]] && devices+=( ${(M)tmp:# ?E *} ) + devices=( ${devices# ?? } ) + + if zstyle -t ":completion:$curcontext:$tag" verbose; then + local f d + tmp=( ${${(@)devices//:/\\:}/[[:space:]]##/:} ) + devices=( ) + for f in $tmp; do + d=${f#*:} f=${f%%:*} + devices+=( ${^${(@s<,>)f}}:$d ) done - [[ -n $lastopt ]] && _ffmpeg_register_lastopt_values + devices=( ${(u)devices} ) + + else + devices=( ${(@s<,>)${(@)devices%%[[:space:]]*}} ) + fi + + _describe -t $tag $desc devices "${(@)ca_opts}" +} + +# complete disposition flags +# -I => single disposition +(( $+functions[_ffmpeg_dispositions] )) || +_ffmpeg_dispositions() { + local tag=dispositions desc='disposition flag' + local -a ca_opts expl dispositions + local -A opth + + zparseopts -A opth -D -F - \ + {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \ + I \ + || return + + dispositions=( ${(f)"$( _call_program $tag $words[1] -dispositions )"} ) + dispositions=( ${dispositions:#*:*} ) + dispositions=( ${dispositions##[[:space:]]##} ) + + if (( ${+opth[-I]} )); then + _describe -t $tag $desc dispositions "${(@)ca_opts}" + else + _wanted $tag expl $desc _ffmpeg_flags "${(@)ca_opts}" - $dispositions + fi +} + +# complete stats format spec +(( $+functions[_ffmpeg_stats_fmt_specs] )) || +_ffmpeg_stats_fmt_specs() { + local bs + + compset -S '[{[[:space:]]*' + compset -P '*[}[[:space:]]' + + [[ -n $compstate[quote] ]] || bs=\\ + + argv=( -r'}\-' -S"$bs}" "$@" ) + compset -P '*{' || argv=( -P"$bs{" "$@" ) + + _describe -t stats-format-spec-directives 'stats format spec directive' '( + fidx:"index of output file" + sidx:"index of output stream in file" + n:"frame number" + ni:"input frame number" + tb:"time base for time stamps of frame/packet" + tbi:"timebase for ptsi" + pts:"presentation time stamp of frame/packet" + ptsi:"presentation time stamp of input frame (ni)" + t:"presentation time of frame/packet" + ti:"presentation time of input frame (ni)" + dts:"decoding time stamp of packet" + dt:"decoding time of frame/packet (dts*tb)" + sn:"number of audio samples sent to encoder" + samp:"number of audio samples in frame" + size:"size of packet (bytes)" + br:"current bit rate (bps)" + abr:"average bit rate of whole stream (bps)" + key:"K if packet contains key frame, N otherwise" + )' "$@" +} + +# complete vsync method / frame-rate mode +(( $+functions[_ffmpeg_fps_modes] )) || +_ffmpeg_fps_modes() { + _describe -t fps-modes 'frame-rate mode [auto]' '( + passthrough:"pass through frames unmodified" + cfr:"duplicate or drop frames to achieve constant frame rate" + vfr:"pass through or drop frames to achieve variable frame rate" + auto:"choose cfr or vfr based on muxer capabilities" + )' "$@" +} + +# complete video-size abbreviation +(( $+functions[_ffmpeg_video_sizes] )) || +_ffmpeg_video_sizes() { + _describe -t video-sizes 'video size abbreviation (or WxH)' '( + ntsc:720x480 pal:720x576 qntsc:352x240 qpal:352x288 + sntsc:640x480 spal:768x576 film:352x240 ntsc-film:352x240 + sqcif:128x96 qcif:176x144 cif:352x288 4cif:704x576 + 16cif:1408x1152 qqvga:160x120 qvga:320x240 vga:640x480 + svga:800x600 xga:1024x768 uxga:1600x1200 qxga:2048x1536 + sxga:1280x1024 qsxga:2560x2048 hsxga:5120x4096 wvga:852x480 + wxga:1366x768 wsxga:1600x1024 wuxga:1920x1200 woxga:2560x1600 + wqsxga:3200x2048 wquxga:3840x2400 whsxga:6400x4096 + whuxga:7680x4800 cga:320x200 ega:640x350 hd480:852x480 + hd720:1280x720 hd1080:1920x1080 2k:2048x1080 2kflat:1998x1080 + 2kscope:2048x858 4k:4096x2160 4kflat:3996x2160 + 4kscope:4096x1716 nhd:640x360 hqvga:240x160 wqvga:400x240 + fwqvga:432x240 hvga:480x320 qhd:960x540 2kdci:2048x1080 + 4kdci:4096x2160 uhd2160:3840x2160 uhd4320:7680x4320 + )' "$@" } -_arguments -C -S \ - "${_ffmpeg_argspecs[@]}" \ - '*:output file:_files' \ - && return +# complete map data source +(( $+functions[_ffmpeg_map_sources] )) || +_ffmpeg_map_sources() { + compset -P - + + if compset -P '*:view:'; then + _message 'view ID' + elif compset -P '*:vidx:'; then + _message 'view index' + elif compset -P '*:vpos:'; then + _describe -t view-positions 'view position' '(left right)' + elif compset -P 1 '*:'; then + local ret=1 + # this isn't quite right + compset -P '<->:' || + compset -P '[astvV](:(?|[\\#]##[^:]##))#:' || + compset -P 'g:(i:|)[\\#]#[^:]##:' || + compset -P 'p:[^:]##(|:(?|[\\#]##[^:]##))#:' || + compset -P '([\\#]##|i:)[^:]##:' || + compset -P 'm:[^:]##:' || # how can this have a value here? + compset -P 'disp:[^:]##:' || + compset -P u: + _ffmpeg_stream_specs -qS: && ret=0 + _describe -t view-specifiers 'view specifier' '( + view:"view ID" + vidx:"view index" + vpos:"view position" + )' -qS: && ret=0 + return ret + else + _message \ + 'map source ([-]input_file_id[:stream_specifier][:view_specifier][:?])' + fi +} + +# complete program spec +(( $+functions[_ffmpeg_program_specs] )) || +_ffmpeg_program_specs() { + local x + local -a kvs keys=( + 'title:program title' + 'program_num:program number' + 'st:stream index' + ) + for x in $keys; do + kvs+=( "${x%%:*}[${${x#*:}%%:*}]:${x#*:}" ) + done + + # it doesn't seem like these need to be given in order + compset -P '*:' + _values -s: -S= 'program specifier (key=val:key=val:...)' $kvs +} + +# complete stream-group spec +(( $+functions[_ffmpeg_stream_group_specs] )) || +_ffmpeg_stream_group_specs() { + local x + local -a kvs keys=( + 'map:input-group mapping' + 'type:stream-group type:( iamf_audio_element iamf_mix_presentation )' + 'st:stream index' + 'stg:stream group' + 'id:stream-group ID' + ) + for x in $keys; do + kvs+=( "${x%%:*}[${${x#*:}%%:*}]:${x#*:}" ) + done + + # @todo we should complete these. it's annoying because some use ':' for their + # own values + compset -P '*,' && { + _message 'type option' + return + } + + # it doesn't seem like these need to be given in order. except maybe the type + # options? + compset -P '*:' + _values -s: -S= 'stream-group specifier (key=val:key=val:...)' $kvs +} + +# complete key-frame force condition +(( $+functions[_ffmpeg_kf_force_conds] )) || +_ffmpeg_kf_force_conds() { + if compset -P expr:; then + _message expression + elif compset -P '*[0-9,]*'; then + _message 'time stamps (time[,time...])' + else + _describe -t kf-force-conditions 'when to force key frame (or time stamps)' \ + '( + source:"when source frame is marked as key frame" + scd_metadata:"when frame has metadata entry lavfi.scd.time" + )' \ + -- \ + '( expr:"when evaluated expression is non-zero" )' -r: -S: + fi +} + +# complete log-level flag +(( $+functions[_ffmpeg_loglevels] )) || +_ffmpeg_loglevels() { + local -a levels=( + quiet panic fatal error warning info verbose debug trace + ) + compset -P "(|*+)(${(j<|>)${(@b)levels}})" && return + _alternative \ + "levels:logging level:_ffmpeg_flags - ${(j< >)${(@q+)levels}}" \ + 'flags: :_ffmpeg_flags - repeat level time datetime' +} + +# complete date spec +(( $+functions[_ffmpeg_dates] )) || +_ffmpeg_dates() { + _message -e dates \ + 'date ([(YYYY-MM-DD|YYYYMMDD)[T|t| ]]((HH:MM:SS[.m]]])|(HHMMSS[.m]]]))[Z]) (or now)' +} + +# complete duration spec +(( $+functions[_ffmpeg_durations] )) || +_ffmpeg_durations() { + _message -e durations 'duration ([-][HH:]MM:SS[.m] or [-]S+[.m][s|ms|us])' +} + +# complete compare functions +(( $+functions[_ffmpeg_cmp_functions] )) || +_ffmpeg_cmp_functions() { + _describe -t compare-functions 'compare function' '( + sad sse satd dct psnr bit rd zero vsad vsse nsse w53 w97 dctmax + chroma msad + )' "$@" +} + +# complete frame discard methods +(( $+functions[_ffmpeg_discard_methods] )) || +_ffmpeg_discard_methods() { + _describe -t discard-methods 'frame discard method' '( + none:"no frames" + default:"useless frames" + noref:"non-reference frames" + bidir:"bi-directional frames" + nointra:"all except I frames" + nokey:"all except key frames" + all:"all frames" + )' "$@" +} + +# complete -help topic +(( $+functions[_ffmpeg_help_topics] )) || +_ffmpeg_help_topics() { + if compset -P decoder=; then + _ffmpeg_codecs -D + elif compset -P encoder=; then + _ffmpeg_codecs -E + elif compset -P demuxer=; then + _ffmpeg_formats -D + elif compset -P muxer=; then + _ffmpeg_formats -E + elif compset -P filter=; then + _ffmpeg_filters + elif compset -P bsf=; then + _ffmpeg_bsfs -I + elif compset -P protocol=; then + _ffmpeg_protocols + else + _describe -t help-topics 'help topic' \ + '( + long:"basic and advanced tool options" + full:"all options" + )' \ + -- \ + '( + decoder:"specified decoder" + encoder:"specified encoder" + demuxer:"specified demuxer" + muxer:"specified muxer" + filter:"specified filter" + bsf:"specified bitstream filter" + protocol:"specified protocol" + )' -r= -S= + fi +} + +local MATCH MBEGIN MEND x y z no +local -a ss_opts ms_opts basic_opts expert_opts gen_avo_opts opts tmp + +# names of options that support optional :stream_specifier form +ss_opts=( + ac apad apply_cropping ar aspect autorotate autoscale b + bits_per_raw_sample bsf c canvas_size ch_layout channel_layout + chroma_intra_matrix codec copyinkf copypriorss discard + display_hflip display_rotation display_vflip disposition + drop_changed dump_attachment enc_time_base filter filter_script + fix_sub_duration fix_sub_duration_heartbeat force_fps + force_key_frames fps_mode fpsmax frames guess_layout_max hwaccel + hwaccel_device hwaccel_output_format inter_matrix intra_matrix + itsscale max_muxing_queue_size muxing_queue_data_threshold pass + passlogfile pix_fmt pre q qscale r rc_override reinit_filter s + sample_fmt stats_enc_post stats_enc_post_fmt stats_enc_pre + stats_enc_pre_fmt stats_mux_pre stats_mux_pre_fmt tag threads + time_base top +) + +# names of options that support optional :metadata_specifier form +ms_opts=( metadata map_metadata ) + +# option specs are grouped and ordered per `ffmpeg -help full` output. the +# separate arrays probably aren't necessary, but i was keeping track of it +# anyway, and maybe it'll be useful in the future + +# note: in order for the replacements below to work reliably, all specs must +# have descriptions ('-o[desc]'), and colons must not be omitted after optarg +# descriptions: '-o[desc]:argdesc:', NOT '-o[desc]:argdesc' + +# basic information/capability options +basic_opts+=( + '(- : *)'{-L,-license}'[display licence information]' + '(- : *)'{-h,-help,--help}'[display help information]:: :_ffmpeg_help_topics' + '!(- : *)-?[]:: :_ffmpeg_help_topics' # annoying + '(- : *)-version[display version information]' + '(- : *)-muxers[display available muxers]' + '(- : *)-demuxers[display available demuxers]' + '(- : *)-devices[display available devices]' + '(- : *)-decoders[display available decoders]' + '(- : *)-encoders[display available encoders]' + '(- : *)-filters[display available filters]' + '(- : *)-pix_fmts[display available pixel formats]' + '(- : *)-layouts[display channel names and standard channel layouts]' + '(- : *)-sample_fmts[display available sample formats]' +) +# advanced information/capability options +expert_opts+=( + '(- : *)-buildconf[display build configuration]' + '(- : *)-formats[display available formats]' + '(- : *)-codecs[display available codecs]' + '(- : *)-bsfs[display available bitstream filters]' + '(- : *)-protocols[display available protocols]' + '(- : *)-dispositions[display stream dispositions]' + '(- : *)-colors[display recognised colours]' + '(- : *)-sources[display input sources (specify device)]:: :{ + compset -S ",*" + if compset -P "*,"; then + _message "input device option (opt1=val1,opt2=val2,...)" + else + _ffmpeg_devices -D -qS, + fi + }' + '(- : *)-sinks[display output sinks (specify device)]:: :{ + compset -S ",*" + if compset -P "*,"; then + _message "output device option (opt1=val1,opt2=val2,...)" + else + _ffmpeg_devices -E -qS, + fi + }' + '(- : *)-hwaccels[display available hardware-acceleration methods]' +) +# basic global options +basic_opts+=( + '(-v -loglevel)'{-v,-loglevel}'[set logging level]: :_ffmpeg_loglevels' + '(-n)-y[overwrite output files without asking]' + '(-y)-n[never overwrite output files]' + '-print_graphs[print execution graph data to stderr]' + '-print_graphs_file[write execution graph data to specified file]:execution graph file:_files' + '-print_graphs_format[specify execution graph format]:execution graph format:( + default compact csv flat ini json xml mermaid mermaidhtml + )' + '-stats[print encoding progress and statistics]' +) +# advanced global options +expert_opts+=( + '-report[generate report]' + '-max_alloc[specify heap allocation size limit]: :\ + _ffmpeg_numbers -u bytes "max heap allocation block size" + ' + # we could check these against $MACHTYPE but i don't think it matters + '-cpuflags[specify CPU flags]:CPU flag:_ffmpeg_flags - \ + mmx mmxext \ + sse sse2 sse2slow sse3 sse3slow ssse3 sse4.1 sse4.2 \ + atom \ + avx avx2 \ + xop \ + fma3 fma4 \ + 3dnow 3dnowext \ + bmi1 bmi2 \ + cmov \ + pentium2 pentium3 pentium4 k6 k62 athlon athlonxp k8 \ + armv5te armv6 armv6t2 vfp vfpv3 neon setend \ + armv8 vfp neon \ + altivec + ' + '-cpucount[specify CPU count]: :_ffmpeg_numbers "CPU count"' + '-hide_banner[suppress banner]' + '(-copy_unknown)-ignore_unknown[ignore unknown stream types]' + '(-ignore_unknown)-copy_unknown[copy unknown stream types]' + '-recast_media[allow forcing decoder of different media type]' + '-benchmark[show benchmark information at end of encode]' + '-benchmark_all[show benchmark information during encode]' + '-progress[write progress information to specified URL]: :{ + if compset -P pipe\:; then + _describe "file descriptor" "(0 1 2)" + else + _alternative "urls\: \:_urls" "files\: \:_files" + fi + }' + '-stdin[enable interaction on standard input]' + '-timelimit[specify max run time]: :\ + _ffmpeg_numbers -u seconds "max CPU user time" + ' + '-dump[dump each input packet to stderr]' + '-hex[also dump payload (with -dump)]' + '-frame_drop_threshold[specify frame-drop threshold]: :\ + _ffmpeg_numbers -u frames -N -d-1.1 "frame-drop threshold" + ' + '-copyts[copy timestamps]' + '-start_at_zero[shift input timestamps to start at 0 (with -copyts)]' + '-copytb[specify how to set encoder time base when copying stream]:mode:(( + -1\:"decide automatically" + 0\:"use decoder time base" + 1\:"use demuxer time base" + ))' + '-dts_delta_threshold[specify timestamp discontinuity delta threshold]: :\ + _ffmpeg_numbers -u seconds -d10 "timestamp discontinuity delta threshold" + ' + '-dts_error_threshold[specify timestamp error delta threshold]: :\ + _ffmpeg_numbers -u seconds -d108000 "timestamp error delta threshold" + ' + '-xerror[exit on error]' + '-abort_on[abort on specified condition flags]:condition flag:\ + _ffmpeg_flags - empty_output empty_output_stream + ' + '-filter_threads[specify number of threads used for each filter pipeline]: :\ + _ffmpeg_numbers threads + ' + '-filter_buffered_frames[specify max buffered frames in a filtergraph]: :\ + _ffmpeg_numbers -d0 "max buffered frames" + ' + '*'{-filter_complex,-lavfi}'[define specified complex filtergraph]: :_ffmpeg_filtergraphs' + '-filter_complex_threads[specify number of threads used for each complex filtergraph]: :\ + _ffmpeg_numbers threads + ' + '!*-filter_complex_script[]:-filter_complex script:_files' # deprecated + '-auto_conversion_filters[enable automatic conversion filters globally]' + '-stats_period[specify progress/statistics update interval]: :\ + _ffmpeg_numbers -u seconds -d0.5 "update interval" + ' + '-debug_ts[print timestamp/latency information]' + '-max_error_rate[specify max decoding error ratio]: :\ + _ffmpeg_numbers -l0 -m1 -d0.67 "max decoding error ratio" + ' + '-sdp_file[write sdp information to specified file]:sdp file:_files' + '*-init_hw_device[initialise specified hardware device]: :_ffmpeg_hw_device_inits' + '-filter_hw_device[specify hardware device for filtering]: :_ffmpeg_hw_devices' + '!-adrift_threshold[]:threshold:' # deprecated + '!-qphist[]' # deprecated + # deprecated in favour of -fps_mode, but still used in documentation, so no ! + '-vsync[specify video sync method globally]: :_ffmpeg_fps_modes' +) +# basic per-file options (input and output) +basic_opts+=( + '*-f[force specified container format]: :_ffmpeg_formats' + '*-t[stop after specified duration]: :_ffmpeg_durations' + '*-to[stop at specified time]: :_ffmpeg_durations' + '*-ss[start at specified time]: :_ffmpeg_durations' +) +# advanced per-file options (input and output) +expert_opts+=( + '*-bitexact[enable bitexact mode]' + '*-thread_queue_size[specified max queued packets for demuxer]: :\ + _ffmpeg_numbers "max queued packets" + ' +) +# advanced per-file options (input only) +expert_opts+=( + '*-sseof[start at specified time relative to EOF]: :_ffmpeg_durations' + '*-seek_timestamp[seek by timestamp (with -ss/-sseof)]' + '*-accurate_seek[enable accurate seeking (with -ss/-sseof)]' + '*-isync[specify input index for sync reference]: :\ + _ffmpeg_numbers -N -d-1 "input index" + ' + '*-itsoffset[specify input time offset]: :_ffmpeg_durations' + '*-re[read input at native frame rate (like -readrate 1)]' + '*-readrate[specify input read speed limit]: :\ + _ffmpeg_numbers -u seconds -l0 -d0 "max input read duration per 1s of wall time" + ' + '*-readrate_initial_burst[specify initial read burst time (with -readrate)]: :\ + _ffmpeg_numbers -u seconds "initial read burst time" + ' + '*-readrate_catchup[specify catch-up read speed limit if blocked (with -readrate)]: :\ + _ffmpeg_numbers -u seconds "max input read duration per 1s of wall time" + ' + '*-dump_attachment[extract matching attachment into specified file]:attachment output file:_files' + '*-stream_loop[specify number of times to loop input stream]: :\ + _ffmpeg_numbers -N -d0 "input-stream loops" + ' + '*-find_stream_info[decode streams to fill missing info with heuristics]' +) +# basic per-file options (output only) +basic_opts+=( + '*-metadata[add specified metadata to output]:metadata key=value:' +) +# advanced per-file options (output only) +expert_opts+=( + '*-map[specify stream mapping from input to output]: :_ffmpeg_map_sources' + '*-map_metadata[set metadata mapping from input to output]: :{ + if compset -P 1 "*\:"; then + _ffmpeg_metadata_specs + else + _message "input file index[\:metadata specifier]" + fi + }' + '*-map_chapters[specify chapter mapping from input to output]: :\ + _ffmpeg_numbers -N "input index" + ' + '*-fs[specify output file size limit]: :\ + _ffmpeg_numbers -u bytes "output file size limit" + ' + '*-timestamp[specify recording timestamp]: :_ffmpeg_dates' + '*-program[add program with specified streams]: :_ffmpeg_program_specs' + '*-stream_group[add stream group with specified streams]: :_ffmpeg_stream_group_specs' + '*-dframes[specify max data frames to output (-like -frames\:d)]: :\ + _ffmpeg_numbers "max data frames" + ' + '*-target[specify target file type]:file type:( + {film-,ntsc-,pal-,}{vcd,svcd,dvd,dv,dv50} + )' + '*-shortest[finish encoding when shortest output stream ends]' + '*-shortest_buf_duration[specify buffer duration for -shortest]: :\ + _ffmpeg_numbers -u seconds -d10 "max duration of buffered frames" + ' + '*'{-q,-qscale}'[specify VBR quality]: :\ + _ffmpeg_numbers "quality scale value" + ' + # this is codec-specific, but here are some we know about + '*-profile[specify codec profile]:codec profile:( + # avcodeccontext + unknown main10 + # dnxhd + dnxhd dnxhr_444 dnxhr_hqx dnxhr_hq dnxhr_sq dnxhr_lb + # prores + auto proxy lt standard hq 4444 4444xq + # x264 + baseline main high high10 high422 high444 + # h264 videotoolbox + baseline constrained_baseline main high constrained_high extended + # hevc videotoolbox + main main10 main42210 rext + # prores videotoolbox + auto proxy lt standard hq 4444 xq + )' + '*-attach[add attachment]:file to attach:_files' + '*-muxdelay[specify max demux-decode delay]: :\ + _ffmpeg_numbers -u seconds "max demux-decode delay" + ' + '*-muxpreload[specify initial demux-decode delay]: :\ + _ffmpeg_numbers -u seconds "demux-decode delay" + ' + '*-fpre[set options from specified preset file]:preset file:_files' \ +) +# basic per-stream options +basic_opts+=( + '*'{-c,-codec}'[specify encoder or decoder]: :_ffmpeg_codecs' + '*-filter[apply specified filtergraph]: :_ffmpeg_filtergraphs' +) +# advanced per-stream options +expert_opts+=( + '*-pre[specify preset]: :_ffmpeg_presets' + '*-itsscale[specify input timestamp scale]: :_ffmpeg_numbers scale' + '*-copyinkf[copy initial non-key frames]' + '*-copypriorss[copy or discard frames before start time]' + '*-frames[specify max frames to output]: :\ + _ffmpeg_numbers "max frames" + ' + # there are hundreds of these so i'm not sure it makes sense to complete them + '*-tag[force specified codec tag/fourcc]:codec fourcc:' + '!*-filter_script[]:-filter script:_files' # deprecated + '*-reinit_filter[specify whether to re-initialise filtergraph on input parameter change]:re-initialise mode:(( + 0\:disabled + 1\:enabled + ))' + '*-drop_changed[specify whether to drop frame on input parameter change]:drop mode:(( + 0\:disabled + 1\:enabled + ))' + '*-discard[specify frames to discard]: :_ffmpeg_discard_methods' + '*-disposition[specify disposition flags]: :_ffmpeg_dispositions' + '*-bits_per_raw_sample[specify bits per raw sample]: :\ + _ffmpeg_numbers "bits per raw sample" + ' + '*-stats_enc_pre[write pre-encoding frame stats to specified file]:stats file:_files' + '*-stats_enc_post[write post-encoding frame stats to specified file]:stats file:_files' + '*-stats_mux_pre[write pre-muxing frame stats to specified file]:stats file:_files' + '*-stats_enc_pre_fmt[specify format for -stats_enc_pre]: :_ffmpeg_stats_fmt_specs' + '*-stats_enc_post_fmt[specify format for -stats_enc_post]: :_ffmpeg_stats_fmt_specs' + '*-stats_mux_pre_fmt[specify format for -stats_mux_pre]: :_ffmpeg_stats_fmt_specs' + '*-time_base[specify time base for output stream]:time base (num\:den or float):' + '*-enc_time_base[specify time base for encoder]:encoder time base (or num\:den or float):(( + 0\:"assign default value according to media type" + demux\:"use time base from demuxer" + filter\:"use time base from filtergraph" + ))' + '*-bsf[specify bitstream filters]: :_ffmpeg_bsfs' + '*-max_muxing_queue_size[specify max packets in muxing queue]: :\ + _ffmpeg_numbers "max packets in muxing queue" + ' + '*-muxing_queue_data_threshold[specify minimum threshold for -max_muxing_queue_size]: :\ + _ffmpeg_numbers -u bytes -d50M "minimum threshold for muxing queue size" + ' +) +# basic video options +basic_opts+=( + '*-r[specify frame rate]: :\ + _ffmpeg_numbers -u "Hz, fraction, or abbreviation" "frame rate" + ' + '*-aspect[specify aspect ratio]: :\ + _ffmpeg_numbers -u "float or num:den" "aspect ratio" + ' + '*-vn[disable video]' + '*-vcodec[force specified video codec (like -c\:v)]: :_ffmpeg_codecs -Tv' + '*-vf[apply specified filtergraph to video (like -filter\:v)]: :_ffmpeg_filtergraphs' + # this is actually not a video option, it has to be used like -b:a or -b:v. + # but this is where it's listed in the help output + '*-b[specify bit rate]: :_ffmpeg_numbers -u bps "bit rate"' + # this isn't in the help output for some reason + '*-s[specify video frame size]: :_ffmpeg_video_sizes' +) +# advanced video options +expert_opts+=( + '*-vframes[specify max video frames to output (like -frames\:v)]: :\ + _ffmpeg_numbers "max video frames" + ' + '*-fpsmax[specify max video frame rate]: :\ + _ffmpeg_numbers -u "Hz, fraction, or abbreviation" "frame rate" + ' + '*-pix_fmt[specify pixel format]: :_ffmpeg_pix_fmts' + '*-display_rotation[specify video rotation]: :\ + _ffmpeg_numbers -u degrees "anti-clockwise video rotation" + ' + '*-display_hflip[flip video horizontally]' + '*-display_vflip[flip video vertically]' + '*-rc_override[specify rate-control override]:rate control (beg,end,quant):' + '*-timecode[specify timecode]:timecode (hh\:mm\:ss[\:;.]ff)' + '*-pass[specify pass number for two-pass video encoding]:pass:(1 2)' + '*-passlogfile[specify two-pass log-file prefix]:log-file prefix [ffmpeg2pass]:' + '*-intra_matrix[specify intra quantisation matrix]:intra quantisation matrix:' + '*-inter_matrix[specify inter quantisation matrix]:inter quantisation matrix:' + '*-chroma_intra_matrix[specify chroma intra quantisation matrix]:intra quantisation matrix:' + '*-vtag[force specified video codec tag/fourcc (like -tag\:v)]:video codec fourcc:' + '*-fps_mode[specify frame-rate mode]: :_ffmpeg_fps_modes' + '*-force_fps[force selected frame rate]' + '*-streamid[specify stream identifier]:output-stream-index\:new-value:' + '*-force_key_frames[force key frames at specified timestamps]: :_ffmpeg_kf_force_conds' + '*-hwaccel[specify hardware acceleration for decoding]: :_ffmpeg_hwaccels' + '*-hwaccel_device[specify hardware-acceleration device (with -hwaccel)]: :_ffmpeg_hw_devices' + '*-hwaccel_output_format[specify hardware-acceleration output format (with -hwaccel)]: :_ffmpeg_pix_fmts -H' + '*-autorotate[automatically rotate video]' + '*-autoscale[automatically scale video]' + '*-apply_cropping[automatically crop video using specified method]:crop method [all]:(( + none\:"don'\''t apply cropping" + all\:"apply codec- and container-level cropping" + codec\:"apply codec-level cropping" + container\:"apply container-level cropping" + ))' + '*-fix_sub_duration_heartbeat[set stream as heartbeat stream (with -fix_sub_duration)]' + '*-vpre[specify video preset]: :_ffmpeg_presets' + '!*-top[]:top:' # deprecated +) +# basic audio options +basic_opts+=( + '*-aq[specify audio VBR quality (like -q\:a)]: :\ + _ffmpeg_numbers "quality scale value" + ' + '*-ar[specify audio sampling rate]: :\ + _ffmpeg_numbers -u Hz "audio sampling rate" + ' + '*-ac[specify number of audio channels]: :\ + _ffmpeg_numbers "audio channels" + ' + '*-an[disable audio]' + '*-acodec[force specified audio codec (like -c\:a)]: :_ffmpeg_codecs -Ta' + '*-ab[specify audio bit rate]: :_ffmpeg_numbers -u bps "audio bit rate"' + '*-af[apply specified filtergraph to audio (like -filter\:a)]: :_ffmpeg_filtergraphs' +) +# advanced audio options +expert_opts+=( + '*-aframes[specify max audio frames to output (like -frames\:a)]: :\ + _ffmpeg_numbers "max audio frames" + ' + '*-apad[pad audio stream with specified parameters (like -af apad) (with -shortest)]:apad filter parameters ([key=]val\:[key=]val\:...):' + '*-atag[force specified audio codec tag/fourcc (like -tag\:a)]:audio codec fourcc:' + '*-sample_fmt[specify audio sample format]: :_ffmpeg_sample_fmts' + '*'{-channel_layout,-ch_layout}'[specify audio channel layout]: :_ffmpeg_layouts' + '*-guess_layout_max[specify max channels for guessing channel layout]: :\ + _ffmpeg_numbers "max audio channels" + ' + '*-apre[specify audio preset]: :_ffmpeg_presets' +) +# basic subtitle options +basic_opts+=( + '*-sn[disable subtitles]' + '*-scodec[force specified subtitle codec (like -c\:s)]: :_ffmpeg_codecs -Ts' +) +# advanced subtitle options +expert_opts+=( + '*-stag[force specified subtitle codec tag/fourcc (like -tag\:s)]:subtitle codec fourcc:' + '*-fix_sub_duration[fix subtitle durations]' + '*-canvas_size[specify size of canvas for rendering subtitles]: :_ffmpeg_video_sizes' + '*-spre[specify subtitle preset]: :_ffmpeg_presets' +) +# basic data-stream options +basic_opts+=( + '*-dcodec[force specified data codec (like -c\:d)]: :_ffmpeg_codecs -Td' + '*-dn[disable data]' +) +# generic codec AVOptions. my assumption is that these are rarely used, so i +# haven't put much effort into them +gen_avo_opts+=( + '!*-bt[]: :_ffmpeg_numbers -u bps "bit-rate tolerance"' + '!*-flags[]: :_ffmpeg_flags - \ + unaligned mv4qpel loop gray psnr ildct low_delay global_header \ + bitexact aic ilme cgop output_corrupt + ' + '!*-flags2[]: :_ffmpeg_flags - \ + fast noout ignorecrop local_header chunks showall export_mvs \ + skip_manual ass_ro_flush_noop icc_profiles + ' + '!*-export_side_data[]: :_ffmpeg_flags - \ + mvs prft venc_params film_grain enhancements + ' + '*-g[specify GOP (group of pictures) length]: :\ + _ffmpeg_numbers -u frames "GOP length" + ' + '*-cutoff[specify audio cut-off frequency]: :\ + _ffmpeg_numbers -u Hz "cut-off frequency" + ' + '*-frame_size[specify audio frame size]: :\ + _ffmpeg_numbers -u samples/channel "frame size" + ' + '!*-qcomp[]:float:' + '!*-qblur[]:float:' + '!*-qmin[]:int:' + '!*-qmax[]:int:' + '!*-qdiff[]:int:' + '!*-bf[]:int:' + '!*-b_qfactor[]:float:' + '!*-bug[]: :_ffmpeg_flags - \ + autodetect xvid_ilace ump4 no_padding amv qpel_chroma std_qpel \ + qpel_chroma2 direct_blocksize edge hpel_chroma dc_clip ms trunc \ + iedge + ' + '*-strict[specify how strictly to follow standards]:strictness level:( + very strict normal unofficial experimental + )' + '!*-b_qoffset[]:float:' + '!*-err_detect[]: :_ffmpeg_flags - \ + crccheck bitstream buffer explode ignore_err careful compliant + aggressive + ' + '!*-maxrate[]:int64:' + '!*-minrate[]:int64:' + '!*-bufsize[]:int:' + '!*-i_qfactor[]:float:' + '!*-i_qoffset[]:float:' + '!*-lumi_mask[]:float:' + '!*-tcplx_mask[]:float:' + '!*-scplx_mask[]:float:' + '!*-p_mask[]:float:' + '!*-dark_mask[]:float:' + '!*-dct[]:algorithm:(auto fastint int mmx altivec faan neon)' + '!*-idct[]:algorithm:( + auto int simple simplemmx arm altivec simplearm simplearmv5te + simplearmv6 simpleneon xvid xvidmmx faani simpleauto + )' + '!*-ec[]: :_ffmpeg_flags - guess_mvs deblock favor_inter' + '!*-sar[]:rational:' + '!*-debug[]: :_ffmpeg_flags - \ + pict rc bitstream mb_type qp dct_coeff green_metadata skip \ + startcode er mmco bugs buffers thread_ops nomc + ' + '!*-dia_size[]:int:' + '!*-last_pred[]:int:' + '!*-pre_dia_size[]:int:' + '!*-subq[]:int:' + '!*-me_range[]:int:' + '!*-global_quality[]:int:' + '!*-mdb[]:macroblock decision algorithm [simple]:(simple bits rd)' + '!*-rc_init_occupancy[]:int:' + '*-threads[specify number of threads to use]: :\ + _ffmpeg_numbers -d1 "threads (or auto)" + ' + '!*-dc[]:int:' + '!*-nssew[]:int:' + '!*-skip_top[]:int:' + '!*-skip_bottom[]:int:' + '!*-level[]:int:' + '!*-lowres[]:int:' + '!*-cmp[]: :_ffmpeg_cmp_functions' + '!*-subcmp[]: :_ffmpeg_cmp_functions' + '!*-mbcmp[]: :_ffmpeg_cmp_functions' + '!*-ildctcmp[]: :_ffmpeg_cmp_functions' + '!*-precmp[]: :_ffmpeg_cmp_functions' + '!*-mblmin[]:int:' + '!*-mblmax[]:int:' + '!*-skip_loop_filter[]: :_ffmpeg_discard_methods' + '!*-skip_idct[]: :_ffmpeg_discard_methods' + '!*-skip_frame[]: :_ffmpeg_discard_methods' + '!*-bidir_refine[]:int:' + '!*-keyint_min[]:int:' + '!*-refs[]:int:' + '!*-trellis[]:int:' + '!*-mv0_threshold[]:int:' + '!*-compression_level[]:int:' + '!*-rc_max_vbv_use[]:float:' + '!*-rc_min_vbv_use[]:float:' + '!*-color_primaries[]:colour primary [unknown]:( + bt709 unknown bt470m bt470bg smpte170m smpte240m film bt2020 + smpte428 smpte428_1 smpte431 smpte432 jedec-p22 ebu3213 + unspecified + )' + '!*-color_trc[]:colour transfer characteristic [unknown]:( + bt709 unknown gamma22 gamma28 smpte170m smpte240m linear log100 + log316 iec61966-2-4 bt1361e iec61966-2-1 bt2020-10 bt2020-12 + smpte2084 smpte428 arib-std-b67 unspecified log log_sqrt + iec61966_2_4 bt1361 iec61966_2_1 bt2020_10bit bt2020_12bit + smpte428_1 + )' + '!*-colorspace[]:colour space [unknown]:( + rgb bt709 unknown fcc bt470bg smpte170m smpte240m ycgco bt2020nc + bt2020c smpte2085 chroma-derived-nc chroma-derived-c ictcp ipt-c2 + unspecified ycocg ycgco-re ycgco-ro bt2020_ncl bt2020_cl + )' + '!*-color_range[]:colour range [unknown]:( + unknown tv pc unspecified mpeg jpeg limited full + )' + '!*-chroma_sample_location[]:sample location [unknown]:( + unknown left center topleft top bottomleft bottom unspecified + )' + '!*-alpha_mode[]:alpha mode [unknown]:( + unknown unspecified premultiplied straight + )' + '!*-slices[]:int:' + '!*-thread_type[]:thread-type flag [slice+frame]:_ffmpeg_flags - slice frame' + '!*-audio_service_type[]:audio service type [ma]:(ma ef vi hi di co em vo ka)' + '!*-request_sample_fmt[]: :_ffmpeg_sample_fmts' + '!*-sub_charenc[specify subtitle character encoding]:subtitle character encoding:' + '!*-sub_charenc_mode[]:subtitle character encoding mode flag [0]:\ + _ffmpeg_flags - do_nothing auto pre_decoder ignore + ' + '!*-skip_alpha[]' + '!*-field_order[]:field order [0]:(progressive tt bb tb bt)' + '!*-dump_separator[specify information dump field separator]:field separator:' + '!*-codec_whitelist[]: :_sequence -s, _ffmpeg_codecs -D' + '!*-max_pixels[]:int64:' + '!*-max_samples[]:int64:' + '!*-hwaccel_flags[]:hardware-acceleration flag [ignore_level]:\ + _ffmpeg_flags - \ + ignore_level allow_high_depth allow_profile_mismatch \ + unsafe_output + ' + '!*-extra_hw_frames[]:int:' + '!*-discard_damaged_percentage[]:int:' + '!*-side_data_prefer_packet[]: : _values -s, "side data type" \ + replaygain displaymatrix spherical stereo3d audio_service_type \ + mastering_display_metadata content_light_level icc_profile exif + ' +) +# generic format AVOptions. see above +gen_avo_opts+=( + '!*-avioflags[]: :_ffmpeg_flags - direct' + '!*-probesize[]:int64:' + '!*-formatprobesize[]:int:' + '!*-packetsize[]:int:' + '!*-fflags[]: :_ffmpeg_flags - \ + flush_packets ignidx genpts nofillin noparse igndts \ + discardcorrupt sortdts fastseek nobuffer bitexact autobsf + ' + '!*-seek2any[]' + '!*-analyzeduration[]:int64:' + '!*-cryptokey[]:binary:' + '!*-indexmem[]:int:' + '!*-rtbufsize[]:int:' + '!*-fdebug[]: :_ffmpeg_flags - ts' + '!*-max_delay[]:int:' + '!*-start_time_realtime[]:int64:' + '!*-fsprobesize[]:int:' + '!*-audio_preload[]:int:' + '!*-chunk_duration[]:int:' + '!*-chunk_size[]:int:' + '!*'{-f_err_detect,-err_detect}'[]: :_ffmpeg_flags - \ + crccheck bitstream buffer explode ignore_err careful compliant \ + aggressive + ' # -f_err_detect is deprecated + '!*-use_wallclock_as_timestamps[]' + '!*-skip_initial_bytes[]:int64:' + '!*-correct_ts_overflow[]' + '!*-flush_packets[]:int:' + '!*-metadata_header_padding[]:int:' + '!*-output_ts_offset[]: :_ffmpeg_durations' + '!*-max_interleave_delta[]:int64:' + # deprecated. see -strict + '!*-f_strict[]:strictness level:(very strict normal unofficial experimental)' + '!*-max_ts_probe[]:int:' + '!*-avoid_negative_ts[]:time-stamp shift method:( + auto disabled make_non_negative make_zero + )' + '!*-format_whitelist[]: :_sequence -s, _ffmpeg_formats -D' + '!*-protocol_whitelist[]: :_sequence -s, _ffmpeg_protocols' + '!*-protocol_blacklist[]: :_sequence -s, _ffmpeg_protocols' + '!*-max_streams[]:int:' + '!*-skip_estimate_duration_from_pts[]' + '!*-max_probe_packets[]:int:' + '!*-duration_probesize[]:int64:' +) +# and... this +basic_opts+=( + '*-i[input file or URL]:input file:_files' +) + +# previous iterations of this function only completed basic options. not sure if +# that's specifically desirable, but we can support it +opts=( $basic_opts ) +if zstyle -t ":completion:$curcontext:$curtag" basic; then + opts+=( ${expert_opts/#(#m)[^!]/!$MATCH} ${gen_avo_opts/#(#m)[^!]/!$MATCH} ) +else + opts+=( $expert_opts $gen_avo_opts ) +fi + +# --help looks annoying in the list +[[ -n $words[(r)--*] ]] || opts=( ${opts:#(|\(*\))\*#--*} ) + +# support -no variants of boolean options +[[ $PREFIX == -no* ]] && +for x in ${opts:#*\]:*}; do + [[ $x == \([' *:-']##\)* ]] && continue # skip -version etc + # skip some others that are stupid + [[ $x == (|\(*\))-(hide_banner|n|y)\[* ]] && continue + # turn '-foo[do bar]' into "-nofoo[don't do bar]" + [[ $x == \(* ]] && x=${x/\)-/\)-no} || x=${x/-/-no} + x=${x/\[/\[don\'t } + opts+=( $x ) +done -[[ "$state" == "vfilters" ]] && - _values -s , -S = 'video filter' \ - 'aspect:set aspect ratio (rational number X\:Y or decimal number):' \ - 'crop:crop input video (x\:y\:width\:height):' \ - 'format: :_sequence -s : _ffmpeg_pix_fmts' \ - 'noformat: :_sequence -s : _ffmpeg_pix_fmts' \ - 'null' \ - 'pad:add pads to the input image (width\:height\:x\:y\:color_string):' \ - 'pixelaspect:set pixel aspect ratio (rational number X\:Y or decimal number):' \ - 'scale:scale input video (width\:height):' \ - 'slicify:output slice height ("random" or a number of pixels):' \ - 'unsharp:luma_x\:luma_y\:luma_amount\:chroma_x\:chroma_y\:chroma_amount:' \ - 'vflip' \ - 'buffer' \ - 'nullsrc' \ - 'nullsink' \ - && return +# support optional stream/metadata spec, e.g. -codec:a or -metadata:s:a +[[ $words[CURRENT] == -/#*:* || $words[CURRENT-1] == -/#*:* ]] && +for x y in ss_opts _ffmpeg_stream_specs ms_opts _ffmpeg_metadata_specs; do + for z in ${(P)x}; do + [[ $words[CURRENT] == -/#$z:* || $words[CURRENT-1] == -/#$z:* ]] || continue + tmp=( ${(M)opts:#(|\(*\))\*#-$z\[*} ) + opts=( ${opts:#$tmp} ) + # turn '-c:x:y' into '-c\:-: :_ffmpeg_stream_specs:x:y' + tmp=( ${tmp/\[/\\:-\[} ) + tmp=( ${tmp/%(#m):([^:]|\\:)##(|:([^:]|\\:)#)/: :$y$MATCH} ) + opts+=( $tmp ) + break + done +done -[[ -n $state && -n $_ffmpeg_flags[$state] ]] && - _ffmpeg_flags $state && return +# support -/ variant (-/filter:v filter.script) of options with args +[[ $words[CURRENT] == -/* || $words[CURRENT-1] == -/?* ]] && +for (( x = 1; x <= $#opts; x++ )); do + [[ $opts[x] == *\]:* ]] || continue + [[ $opts[x] == \([' *:-']##\)* ]] && continue # skip -help etc + y=${${${${opts[x]#\!}#\(*\)}#\*}%%(\\:|)(-|)\[*} # option name for desc + # turn '-c:x:y' into '-/c:...:_files' + [[ $opts[x] == \(* ]] && opts[x]=${opts[x]/\)-/\)-/} || opts[x]=${opts[x]/-/-/} + opts[x]=${opts[x]/%:([^:]|\\:)##(|:([^:]|\\:)#)/:$y argument value file:_files} +done -return 1 +_arguments -S : $opts '*:output file:_files' diff --git a/Completion/Unix/Command/_find b/Completion/Unix/Command/_find index 8628ad43e..2afb46e34 100644 --- a/Completion/Unix/Command/_find +++ b/Completion/Unix/Command/_find @@ -12,17 +12,21 @@ case $variant in '*-local' ) ;| - solaris*|darwin*) + solaris*|darwin*|freebsd<15->.*) args+=( '*-xattr' ) ;| solaris2.<10->|freebsd*|darwin*) args+=( '*-acl' ) ;| - solaris2.<11->|freebsd*|dragonfly*|darwin*|openbsd*|gnu) + aix*|solaris2.<11->|freebsd*|dragonfly*|darwin*|openbsd*|gnu) args+=( '*-amin:access time (minutes)' '*-cmin:inode change time (minutes)' '*-mmin:modification time (minutes)' + ) + ;| + solaris2.<11->|freebsd*|dragonfly*|darwin*|openbsd*|gnu) + args+=( '*-iname:name pattern to match (case insensitive)' '*-print0' ) @@ -36,7 +40,7 @@ case $variant in darwin*|freebsd*|gnu) args+=( '*-Bmin:birth time (minutes)' - '*-Bnewer:file to compare (birth time):_files' + '!*-Bnewer:reference file:_files' '*-newer'{a,B,c,m}{a,B,c,m}'[if [aBcm\]time is newer than [aBcm\]time of given file]:reference file:_files' '*-newerat[if access time is newer than given timestamp]:timestamp: ' '*-newerBt[if birth time is newer than given timestamp]:timestamp: ' @@ -98,7 +102,7 @@ case $variant in ) ;| freebsd*|dragonfly*) args+=( '*-sparse' ) ;| - darwin*) args+=( '*-xattrname:name' ) ;| + darwin*|freebsd<15->.*) args+=( '*-xattrname:name' ) ;| gnu) args+=( '(- *)-help' '(-)--help' diff --git a/Completion/Unix/Command/_flac b/Completion/Unix/Command/_flac index 0197aaf92..d7f3e801c 100644 --- a/Completion/Unix/Command/_flac +++ b/Completion/Unix/Command/_flac @@ -67,7 +67,6 @@ case $service in - 'H' \ '(-)'{-v,--version}'[display version information]' \ '(-)'{-h,--help}'[display help information]' \ - '(-)'{-H,--explain}'[display detailed explanation of usage and options]' \ - encode \ '(-V --verify)'{-V,--verify}'[verify a correct encoding]' \ --lax --ignore-chunk-sizes '!--sector-align' --replay-gain \ @@ -88,6 +87,7 @@ case $service in '(-p --qlp-coeff-precision-search -q --qlp-coeff-precision)'{-q,--qlp-coeff-precision=}'[specify precision]:precision (bits)' \ '(-r --rice-partition-order)'{-r,--rice-partition-order=}'[set min/max residual partition order]:order' \ "--limit-min-bitrate[don't allow frames consisting of only constant subframes]" \ + '(-j --threads)'{-j+,--threads=}'[set number of encoding threads]:threads' \ '--endian=:byte order:(big little)' \ '--channels=:channels' \ '--bps=:bits per sample' \ @@ -102,6 +102,7 @@ case $service in '(-F --decode-through-errors)'{-F,--decode-through-errors}'[continue decoding through stream errors]' \ '--apply-replaygain-which-is-not-lossless=:specification' \ '--cue=[set the beginning and ending cuepoints to decode]:cue point' \ + '--decode-chained-stream[decode all links in a chained Ogg stream, not just the first one]' \ '(--force-raw-format --force-rf64-format --force-wave64-format --force-legacy-wave-format --force-extensible-wave-format --force-aiff-c-none-format --force-aiff-c-sowt-format)--force-aiff-format' \ '(--force-raw-format --force-aiff-format --force-wave64-format --force-legacy-wave-format --force-extensible-wave-format --force-aiff-c-none-format --force-aiff-c-sowt-format)--force-rf64-format' \ '(--force-raw-format --force-aiff-format --force-rf64-format --force-legacy-wave-format --force-extensible-wave-format --force-aiff-c-none-format --force-aiff-c-sowt-format)--force-wave64-format' \ @@ -112,6 +113,7 @@ case $service in ;; metaflac) _arguments -S $shared \ + '(-o --output-name)'{-o+,--output-name=}'[write changes to a new file]:file:_files' \ '(--no-filename)--with-filename[prefix output with filename]' \ '(--with-filename)--no-filename' \ '--dont-use-padding[always rewrite the file]' \ diff --git a/Completion/Unix/Command/_fsh b/Completion/Unix/Command/_fsh deleted file mode 100644 index c39373117..000000000 --- a/Completion/Unix/Command/_fsh +++ /dev/null @@ -1,22 +0,0 @@ -#compdef fsh - -local curcontext="$curcontext" state line ret=1 -local -a _comp_priv_prefix - -_arguments -C \ - '(- : *)'{-h,--help}'[display help information]' \ - '(- : *)'{-V,--version}'[display version information]' \ - '-r[specify method]:method:(rsh ssh)' \ - '-l[specify login id]:login:_users' \ - '(-T --timeout)'{-T,--timeout}':idle timeout:' \ - ':remote host name:_hosts' \ - '(-):command: _command_names -e' \ - '*::args:->command' && ret=0 - -if [[ -n "$state" ]]; then - shift 1 words - (( CURRENT-- )) - _normal && ret=0 -fi - -return ret diff --git a/Completion/Unix/Command/_fuser b/Completion/Unix/Command/_fuser index 05de1c529..90124ea30 100644 --- a/Completion/Unix/Command/_fuser +++ b/Completion/Unix/Command/_fuser @@ -69,9 +69,12 @@ case $variant in args+=( '-n[list only processes with non-blocking mandatory locks]' ) - ;; + ;| solaris2.<10->) args+=( '-d[report device usage for all minor nodes bound to same device]' ) + ;| + solaris2.<11->) + args+=( "-l[don't resolve symlinks to target file]" ) ;; sysv4 ) (( $+words[(r)-k] )) && argf=( ':name: _alternative signals\:signal\:_signals\ -p files:file:_files' ) diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc index 03c3eb2f2..cf1cf7efa 100644 --- a/Completion/Unix/Command/_gcc +++ b/Completion/Unix/Command/_gcc @@ -1,10 +1,18 @@ -#compdef gcc g++ cc c++ llvm-gcc llvm-g++ clang clang++ -value-,LDFLAGS,-default- -value-,CFLAGS,-default- -value-,CXXFLAGS,-default- -value-,CPPFLAGS,-default- -P gcc-* -P g++-* -P c++-* +#compdef gcc g++ cc c++ llvm-gcc llvm-g++ clang clang++ -value-,LDFLAGS,-default- -value-,CFLAGS,-default- -value-,CXXFLAGS,-default- -value-,CPPFLAGS,-default- -value-,CC,-default- -value-,CXX,-default- -P gcc-* -P g++-* -P c++-* local curcontext="$curcontext" state line ret=1 expl i local -a args args2 warnings arch typeset -A opt_args -if [[ "$service" = -value-* ]]; then +if [[ "$service" = -value-,CC,* ]]; then + _description compilers expl compiler + compadd "$expl[@]" -M 'r:|-=* r:|=*' -k 'commands[(I)(clang|([ig]|sun|open)cc(|<->|-devel)|icx)]' + return +elif [[ "$service" = -value-,CXX,* ]]; then + _description compilers expl compiler + compadd "$expl[@]" -M 'r:|-=* r:|=*' -k 'commands[(I)((clang|g)++(|<->|-devel)|(sun|open|)CC|icpx)]' + return +elif [[ "$service" = -value-* ]]; then compset -q words=( fake "$words[@]" ) (( CURRENT++ )) @@ -337,7 +345,7 @@ i[3456]86|x86_64) '-mstack-arg-probe[enable stack probing]' '-mstack-protector-guard=-[use given stack-protector guard]:guard:(global tls)' '-mstackrealign[realign stack in prologue]' - '-mstringop-strategy=-[chose strategy to generate stringop using]:stringop strategy:(byte_loop libcall loop rep_4byte rep_8byte rep_byte unrolled_loop)' + '-mstringop-strategy=-[choose strategy to generate stringop using]:stringop strategy:(byte_loop libcall loop rep_4byte rep_8byte rep_byte unrolled_loop)' '-mstv[disable Scalar to Vector optimization pass transforming 64-bit integer computations into a vector ones]' '-mtbm[support TBM built-in functions and code generation]' '-mthreads[support thread-safe exception handling on MinGW]' @@ -616,7 +624,6 @@ if [[ "$service" = clang* ]]; then '-fconstexpr-steps=[constexpr steps]:arg' '-fconvergent-functions[assume functions may be convergent]' '-fconvert=[convert]:arg' - '-fcoroutines-ts[enable support for the C++ Coroutines TS]' '-fcoverage-compilation-dir=[the compilation directory to embed in the coverage mapping]:arg' '-fcoverage-mapping[generate coverage mapping to enable code coverage analysis]' '-fcoverage-prefix-map=[remap file source paths in coverage mapping]:arg' @@ -1695,6 +1702,7 @@ args+=( '-fcompare-elim[perform comparison elimination after register allocation has finished]' '-fcond-mismatch[allow the arguments of the ? operator to have different types]' '-fconserve-stack[do not perform optimizations increasing noticeably stack usage]' + '-fcoroutines[enable support for C++ Coroutines]' '-fcprop-registers[perform a register copy-propagation optimization pass]' '-fcrossjumping[perform cross-jumping optimization]' '-fcse-follow-jumps[when running CSE, follow jumps to their targets]' @@ -1837,6 +1845,8 @@ args+=( '-fno-stack-limit[do not limit the size of the stack]' '-fno-threadsafe-statics[do not generate thread-safe code for initializing local statics]' '-fnothrow-opt[treat a throw() exception specification as noexcept to improve code size]' + '-foffload=[specify offloading targets]:target list' + '-foffload-options=:option list' '-fomit-frame-pointer[when possible do not generate stack frames]' '-fopenacc[enable OpenACC]' '-fopenmp[enable OpenMP (implies -frecursive in Fortran)]' diff --git a/Completion/Unix/Command/_gcore b/Completion/Unix/Command/_gcore index ef3afd919..4e5041f3b 100644 --- a/Completion/Unix/Command/_gcore +++ b/Completion/Unix/Command/_gcore @@ -56,7 +56,7 @@ case $OSTYPE in '-v[report progress on the dump as it proceeds]' \ '-b+[specify maximum size of core file]:size (MiB): ' \ '(-c)-o+[write core file to specified file]:file:_files' \ - '(-o)-c+[specify format of core file name]:format (%%N\:program name, %%U\:uid, %%P\:pid, %%T\:time stamp)' \ + '(-o)-c+[specify format of core file name]:format (%N\:program name, %U\:uid, %P\:pid, %T\:time stamp)' \ '1:pid:_pids' ;; *) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index cbf577680..c4ed3c3e9 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -207,7 +207,8 @@ _git-archive () { _git-backfill() { _arguments -S \ '--min-batch-size=[specify minimum number of objects to request at a time]:number of objects' \ - '--sparse[only download objects at a path matching current sparse-checkout]' + '--sparse[only download objects at a path matching current sparse-checkout]' \ + '--no-include-edges[exclude blobs from boundary commits in the backfill]' } (( $+functions[_git-bisect] )) || @@ -557,7 +558,7 @@ _git-checkout () { elif [[ -n ${opt_args[(I)-b|-B|-t|--track|--orphan|--detach]} ]]; then _nothing - elif [[ -n $line[1] ]] && __git_is_treeish ${(Q)line[1]}; then + elif [[ -n $line[1] && $line[1] != (@|HEAD) ]] && __git_is_treeish ${(Q)line[1]}; then __git_ignore_line __git_tree_files ${PREFIX:-.} ${(Q)line[1]} && ret=0 else __git_ignore_line __git_modified_files && ret=0 @@ -698,7 +699,7 @@ _git-clone () { '(--single-branch)--no-single-branch[clone history leading up to each branch]' \ "--no-tags[don't clone any tags and make later fetches not follow them]" \ '--shallow-submodules[any cloned submodules will be shallow]' \ - '(--recursive --recurse-submodules)'{--recursive,--recurse-submodules}'=-[initialize submodules in the clone]::file:__git_files' \ + '(--recursive --recurse-submodules)'{--recursive,--recurse-submodules}'=-[initialize submodules in the clone]::file:_files' \ '--separate-git-dir[place .git dir outside worktree]:path to .git dir:_path_files -/' \ '--ref-format=[specify reference format to use]:format:(files reftable)' \ \*--server-option='[send specified string to the server when using protocol version 2]:option' \ @@ -2008,7 +2009,7 @@ _git-sparse-checkout() { _git-stash () { local curcontext=$curcontext state line ret=1 declare -A opt_args - local -a save_arguments + local -a save_arguments args save_arguments=( '(-p --patch -a --all -u --include-untracked)'{-p,--patch}'[interactively select hunks from diff between HEAD and working tree to stash]' @@ -2085,8 +2086,9 @@ _git-stash () { '(-u --include-untracked)--only-untracked[show only the untracked files in the stash entry as part of the diff]' \ ':: :__git_stashes' && ret=0 ;; - (pop|apply) - _arguments -S $endopt \ + apply) args=( '--label-'{ours,theirs,base}'=:label' ) ;& + pop) + _arguments -S $endopt $args \ '--index[try to reinstate the changes added to the index as well]' \ '(-q --quiet)'{-q,--quiet}'[suppress all output]' \ ':: :__git_stashes' && ret=0 @@ -4427,7 +4429,8 @@ _git-repack () { '--pack-kept-objects[repack objects in packs marked with .keep]' \ '--keep-pack=[ignore named pack]:pack' \ '(-g --geometric)'{-g+,--geometric=}'[find a geometric progression with specified factor]:factor' \ - '(-m --write-midx)'{-m,--write-midx}'[write a multi-pack index of the resulting packs]' \ + '(--write-midx)-m[write a multi-pack index of the resulting packs]' \ + '(-m)--write-midx=-[write a multi-pack index of the resulting packs]:mode:(default incremental)' \ '--expire-to=[pack prefix to store a pack containing pruned objects]:directory:_directories' \ '--filter-to=[pack prefix to store a pack containing filtered out objects]:directory:_directories' } @@ -4586,11 +4589,34 @@ _git-fsck () { '*: :__git_objects' } +(( $+functions[_git-format-rev] )) || +_git-format-rev() { + _arguments -S $endopt \ + '--format=[specify format]:format:__git_format_placeholders' \ + '--stdin-mode=[specify stdin mode]:mode:(revs text)' \ + '--notes=[display notes for pretty format]:reference' \ + '(-z --null --null-input --null-output)'{-z,--null}'[use NUL for input and output termination]' \ + '(-z --null)--null-input[use NUL for input termination]' \ + '(-z --null)--null-output[use NUL for output termination]' +} + (( $+functions[_git-get-tar-commit-id] )) || _git-get-tar-commit-id () { _message 'no arguments allowed; accepts tar-file on standard input' } +(( $+functions[_git-last-modified] )) || +_git-last-modified() { + _arguments -s \ + '(-r --recursive)'{-r,--recursive}'[recurse into subtrees]' \ + '(-t --show-trees)'{-t,--show-trees}'[show tree entries when recursing into subtrees]' \ + '--max-depth=[specify maximum tree depth to recurse]:depth [0]' \ + '-z[separate lines with NUL character]' \ + '1: :__git_commit_ranges' \ + \!--{,end-of-options}':*: :__git_tree_files ${PREFIX:-.} HEAD' \ + '*: :__git_tree_files ${PREFIX:-.} $line[1]' +} + (( $+functions[_git-help] )) || _git-help () { _arguments -S -s \ @@ -5499,7 +5525,7 @@ _git-mktree () { (( $+functions[_git-multi-pack-index] )) || _git-multi-pack-index() { - _arguments \ + _arguments -S \ '--object-dir=[specify location of git objects]:directory:_directories' \ '(--progress)--no-progress[turn progress off]' '!(--no-progress)--progress' \ '--preferred-pack=[break ties in favor of specified pack]:pack' \ @@ -5508,7 +5534,11 @@ _git-multi-pack-index() { '--refs-snapshot=[specify a file which contains a "refs snapshot" taken prior to repacking]:file:_files' \ '--incremental[write an incremental MIDX file]' \ '--batch-size=[during repack, select packs so as to have pack files of at least the specified size]:size' \ - '1:verb:(write compact verify expire repack)' + "--write-chain-file[write new MIDX layer but don't update multi-pack-index-chain file]" \ + '--base=[specify checksum of MIDX layer to use as base]:checksum' \ + '1:verb:(write compact verify expire repack)' \ + '2:from (checksum)' \ + '3:to (checksum)' } (( $+functions[_git-pack-objects] )) || @@ -6426,6 +6456,7 @@ _git-hook() { '--allow-unknown-hook-name' \ '-z[terminate output lines with NUL instead of newlines]' \ '--show-scope[prefix each hook name with a config scope]' \ + '(-j --jobs)'{-j+,--jobs=}'[allow specified number of simultaneous hooks]:jobs' \ '1:subcommand:(run list)' \ '2:hook name:compadd $gitdir/hooks/*(x\:t)' } @@ -6483,6 +6514,13 @@ _git-stripspace () { '(-c --comment-lines -s --strip-comments)'{-c,--comment-lines}'[prepend comment character and blank to each line]' } +(( $+functions[_git-url-parse] )) || +_git-url-parse() { + _arguments -S $endopt \ + '(-c --component)'{-c+,--component=}'[specific URL component]:component:(scheme user password host port path)' \ + '*: :_guard "^-*" url' +} + # INTERNAL GIT COMPLETION FUNCTIONS # Generic Helpers @@ -6769,13 +6807,16 @@ _git_commands () { diff-tree:'compare content and mode of blobs found via two tree objects' for-each-ref:'output information on each ref' for-each-repo:'run a git command on a list of repositories' + format-rev:'pretty format revisions from stdin' get-tar-commit-id:'extract commit ID from an archive created using git archive' + last-modified:'show when files were last modified' 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' merge-base:'find as good a common ancestor as possible for a merge' name-rev:'find symbolic names for given revisions' pack-redundant:'find redundant pack files' + repo:'retrieve information about repository' 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' @@ -6811,8 +6852,10 @@ _git_commands () { mailinfo:'extract patch and authorship from a single email message' mailsplit:'split mbox file into a list of files' merge-one-file:'standard helper-program to use with git merge-index' - patch-id:'compute unique ID for a patch' - stripspace:'filter out empty lines') + patch-id:'compute unique ID for patches' + stripspace:'filter out empty lines' + url-parse:'parse and extract git URL components' + ) zstyle -a :completion:$curcontext: user-commands user_commands @@ -8457,7 +8500,7 @@ __git_format_placeholders() { _alternative \ 'formats:: _describe -t formats "built-in format" builtin_fmts' \ 'user-formats:: _describe -t user-formats "user format" user_fmts' \ - 'custom-formats:: _describe -t custom-formats "custom format" custom_fmts -qS:' \ + 'custom-formats:: _describe -t custom-formats "custom format" custom_fmts -r: -S:' \ && return # @todo: still unsupported: more complicated place-holders like %C() and @@ -8714,11 +8757,13 @@ __git_setup_fetch_options () { '(-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]' - '--shallow-since=[deepen history of shallow repository based on time]:time' \ - '*--shallow-exclude=[deepen history of shallow clone by excluding ref]:reference' \ - '--deepen[deepen history of shallow clone]:number of commits' \ + '--shallow-since=[deepen history of shallow repository based on time]:time' + '*--shallow-exclude=[deepen history of shallow clone by excluding ref]:reference' + '--deepen[deepen history of shallow clone]:number of commits' \*{-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' \ + '--negotiation-restrict=[only report refs reachable from specified object to the server]:commit:__git_commits' + '!--negotiation-tip=:commit:__git_commits' + '--negotiation-include=[report given commit as "have" in negotiation]:commit:__git_commits' ) } diff --git a/Completion/Unix/Command/_gnutls b/Completion/Unix/Command/_gnutls index 4c1698857..c62269afc 100644 --- a/Completion/Unix/Command/_gnutls +++ b/Completion/Unix/Command/_gnutls @@ -182,7 +182,8 @@ case "$service" in '--cprint[prints certain information is C-friendly format]' '--null-password[enforce a NULL password]' '--empty-password[enforce an empty password]' - '--key-type=[specify the key type to use on key generation]:key type' + '--key-type=[specify key type to use on key generation]:key type' + '--key-format=[specify key format to use on key generation]:key format:(seed expanded both)' '(-i --certificate-info)'{-i,--certificate-info}'[print information on a certificate]' '(-l --crl-info)'{-l,--crl-info}'[print information on a CRL]' '--crq-info[print information on a certificate request]' diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg index ea0a452f2..d704af92f 100644 --- a/Completion/Unix/Command/_gpg +++ b/Completion/Unix/Command/_gpg @@ -95,7 +95,6 @@ fi '(--encrypt-to)--no-encrypt-to[disable the use of all --encrypt-to keys]' '--group[set up email aliases]:spec' '-z[specify compression level]:compression level:((0\:no\ compression 1\:minimum 2 3 4 5 6\:default 7 8 9\:maximum))' - '(-t --textmode)'{-t,--textmode}'[use canonical text mode]' '(-n --dry-run)'{-n,--dry-run}"[don't make any changes]" '(-i --interactive --batch)'{-i,--interactive}'[prompt before overwriting files]' '(-i --interactive --no-batch)--batch[use batch mode]' diff --git a/Completion/Unix/Command/_gphoto2 b/Completion/Unix/Command/_gphoto2 index df17aa111..4ff5ce1c1 100644 --- a/Completion/Unix/Command/_gphoto2 +++ b/Completion/Unix/Command/_gphoto2 @@ -72,6 +72,8 @@ _arguments -s -C \ '--get-all-raw-data[get all raw data from folder]' \ '--get-audio-data=[get audio data given in range]:range' \ '--get-all-audio-data[get all audio data from folder]' \ + '--get-exif=[get files in given range]:range' \ + '--get-all-exif[get all files from folder]' \ '(-d --delete-file)'{-d,--delete-file=}'[delete files in given range]:range' \ '(-D --delete-all-files)'{-D,--delete-all-files}'[delete all files in folder]' \ '(-u --upload-file)'{-u,--upload-file=}'[upload a file to camera]:file:_files' \ @@ -80,6 +82,7 @@ _arguments -s -C \ '(-f --folder)'{-f,--folder=}'[specify camera folder]:folder [/]' \ '(-R --recurse --no-recurse)'{-R,--recurse}'[recursion (default for download)]' \ '(-R --recurse)--no-recurse[no recursion (default for deletion)]' \ + '--reverse[reverse order of file operations]' \ '--new[process new files only]' \ '--force-overwrite[overwrite files without asking]' \ '--skip-existing[skip files that already exist on local filesystem]' && ret=0 diff --git a/Completion/Unix/Command/_grep b/Completion/Unix/Command/_grep index 0f1e712fd..120d1feea 100644 --- a/Completion/Unix/Command/_grep +++ b/Completion/Unix/Command/_grep @@ -68,7 +68,9 @@ arguments+=( '(-)--help[display help information]' ) -_pick_variant -r variant -c "$command" gnu=gnu gpl2=2.5.1 unix --version +_pick_variant -r variant -c "$command" \ + gnu=gnu gpl2='(2.5.1|GNU compatible)' unix --version + case $variant:$OSTYPE in (gnu:*|gpl2:freebsd*)) [[ $service != (|g|z|gz|bz)[ef]grep ]] && arguments+=( diff --git a/Completion/Unix/Command/_hardlink b/Completion/Unix/Command/_hardlink new file mode 100644 index 000000000..8a62779aa --- /dev/null +++ b/Completion/Unix/Command/_hardlink @@ -0,0 +1,43 @@ +#compdef hardlink + +local ign +local -a args + +(( $#words > 2 )) && ign='!(- *)' + +if _pick_variant linux=util-linux jak -V; then + args=( + '(-c --content -p --ignore-mode -o --ignore-owner -t --ignore-time)'{-c,--content}'[compare only file contents, same as -pot]' + '(-b --io-size)'{-b+,--io-size=}'[specify I/O buffer size for file reading]: :_numbers "IO buffer size" K M G T P' + '(-d --respect-dir)'{-d,--respect-dir}'[directory names have to be identical]' + '(-F --prioritize-trees)'{-F,--prioritize-trees}'[keep files found in the earliest specified top-level]' + '(-l --list-duplicates)'{-l,--list-duplicates}"[just list paths of duplicates, don't link them]" + '--mount[stay within the same filesystem]' + '(-q --quiet)'{-q,--quiet}"[quiet mode - don't print anything]" + '(-r --cache-size)'{-r+,--cache-size=}'[specify memory limit for cached file content data]: :_numbers size K M G T P' + '(--skip-reflinks)--reflink=-[create clone/CoW copies]::when [auto]:(auto always never)' + '--skip-reflinks[skip already cloned files]' + '(-S --maximum-size)'{-S+,--maximum-size=}'[specify maximum size for files]: :_numbers -u bytes -d 0 size K M G T P E Z Y' + '--exclude-subtree[specify regular expression to exclude directories]:regex' + '(-X --respect-xattrs)'{-X,--respect-xattrs}'[respect extended attributes]' + '(-y --method)'{-y+,--method=}'[specify file content comparison method]:method [sha256]:(sha256 sha1 crc32c memcmp)' + '(-z --zero)'{-z,--zero}'[delimit output with NULs instead of newlines]' + ) +fi + +_arguments -S -s $args \ + '(-f --respect-name)'{-f,--respect-name}'[filenames have to be identical]' \ + '(-i --include)'{-i+,--include=}'[regular expression to include files/dirs]:regex' \ + '(-m --maximize -M --minimize)'{-m,--maximize}'[keep the file with the most links]' \ + '(-M --minimize -m --maximize)'{-M,--minimize}'[keep the file with the fewest links]' \ + '(-n --dry-run)'{-n,--dry-run}"[don't actually link anything]" \ + '(-o --ignore-owner -c --content)'{-o,--ignore-owner}'[ignore owner changes]' \ + '(-O --keep-oldest)'{-O,--keep-oldest}'[keep the oldest file of multiple equal files]' \ + '(-p --ignore-mode -c --content)'{-p,--ignore-mode}'[ignore changes of file mode]' \ + '(-s --minimum-size)'{-s+,--minimum-size=}'[specify minimum size for files]: :_numbers -u bytes -d 1 size K M G T P E Z Y' \ + '(-t --ignore-time -c --content)'{-t,--ignore-time}'[ignore timestamps (when testing for equality)]' \ + \*{-v,--verbose}'[more verbose output]' \ + '(-x --exclude)'{-x+,--exclude=}'[specify regular expression to exclude files]:regex' \ + "$ign"{-h,--help}'[display usage information]' \ + "$ign"{-V,--version}'[display version information]' \ + '*:file or directory:_files' diff --git a/Completion/Linux/Command/_htop b/Completion/Unix/Command/_htop index e8d2fffb1..73a6ea9fa 100644 --- a/Completion/Linux/Command/_htop +++ b/Completion/Unix/Command/_htop @@ -19,6 +19,8 @@ args=( '(-)'{-h,--help}'[display usage information]' '(-H --highlight-changes)'{-H+,--highlight-changes=}'[highlight new and old processes (optionally specify delay)]::delay (seconds) (1-86400) [5]' '(-M --no-mouse)'{-M,--no-mouse}'[disable mouse]' + '--no-meters[hide meters]' + '(-n --max-iterations)'{-n+,--max-iterations=}'[exit after given number of frame updates]:number' \*{-p+,--pid=}'[show only specified PIDs]: : _sequence _pids' '--readonly[disable all system and process changing features]' '(-s --sort-key)'{-s+,--sort-key=}'[sort by specified column]: :->sort-keys' @@ -48,7 +50,7 @@ case $state in tmp=( ${tmp//:/\\:} ) tmp=( ${tmp/[[:space:]]##/:} ) tmp=( ${tmp/(#m):[A-Z]/${(L)MATCH}} ) - _describe -t sort-keys 'column (key)' tmp && ret=0 + _describe -t sort-keys 'column' tmp -M 'b:=M_ b:=IO_' && ret=0 ;; esac diff --git a/Completion/Unix/Command/_imagemagick b/Completion/Unix/Command/_imagemagick index 6553868d9..958b2741d 100644 --- a/Completion/Unix/Command/_imagemagick +++ b/Completion/Unix/Command/_imagemagick @@ -12,7 +12,7 @@ typeset -A opt_args # # and certainly many other things... -formats=(jpg jpeg jp2 j2k jpc jpx jpf tif tiff miff ras bmp cgm dcx ps eps fig fits fpx gif mpeg pbm pgm ppm pcd pcl pdf pcx png rad rgb rgba rle sgi html shtml tga ttf uil xcf xwd xbm xpm yuv svg webp) +formats=(jpg jpeg jp2 j2k jpc jpx jpf tif tiff miff ras bmp cgm dcx ps eps fig fits fpx gif heic mpeg pbm pgm ppm pcd pcl pdf pcx png rad rgb rgba rle sgi html shtml tga ttf uil xcf xwd xbm xpm yuv svg webp) if (( $# )); then _files "$@" -g "*.(#i)(${(j:|:)formats})(-.)" diff --git a/Completion/Unix/Command/_initctl b/Completion/Unix/Command/_initctl deleted file mode 100644 index b60bdbc5b..000000000 --- a/Completion/Unix/Command/_initctl +++ /dev/null @@ -1,184 +0,0 @@ -#compdef initctl start stop restart reload status -# Written by Bernhard Tittelbach -# based on completion script by Mildred - -typeset -g -a -U _initctl_events_list _initctl_eventargs_list - -# run show-config -e and if possible parse out all events and KEY= arguments -# otherwise provide some common values -_initctl_fillarray_events_args () -{ - setopt extendedglob - local showconfig="$(initctl show-config -e 2>| /dev/null)" - if [[ -n "$showconfig" ]]; then - _initctl_events_list=() - _initctl_eventargs_list=() - for cline in "${(f)showconfig}"; do - if [[ "$cline" == (#s)\ \ (stop\ on|start\ on|emit)\ (#b)([[:alpha:]-_]##)(*)(#e) ]]; then - _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 remaining strings and try again - local stml="$match[2]" - while [[ "$stml" == (#b)(*)\ ([[:upper:]_]##\=)[^[:space:]](#b)(*) ]]; do - _initctl_eventargs_list+=($match[2]) - stml="$match[1] $match[3]" - done - unset stml - fi - done - else - _initctl_events_list=( socket login-session-start desktop-session-start virtual-filesystems local-filesystems remote-filesystems all-swaps filesystem mounting mounted net-device-up start-portmap runlevel unmounted-remote-filesystems ) - _initctl_eventargs_list=( PRIMARY_DEVICE_FOR_DISPLAY= EXIT_STATUS= EXIT_SIGNAL= RUNLEVEL= MOUNTPOINT= TYPE= INTERFACE= ) - fi - return 0 -} - -# list all upstart jobs, i.e. all files in /etc/init/ -_initctl_helper_jobs() -{ - _path_files -W "/etc/init/" -g "*.conf(-.:r)" -} - -# list events, generate array if necessary -_initctl_known_events() -{ - [[ ${#_initctl_events_list} -eq 0 ]] && _initctl_fillarray_events_args - _values "Event" "$_initctl_events_list[@]" -} - -# list events, allow multiple choices, generate array if necessary -_initctl_multiple_known_events() -{ - [[ ${#_initctl_events_list} -eq 0 ]] && _initctl_fillarray_events_args - _values -s "," "event" "$_initctl_events_list[@]" -} - -# list KEY= arguments, generate array if necessary -_initctl_known_eventargs() -{ - [[ ${#_initctl_eventargs_list} -eq 0 ]] && _initctl_fillarray_events_args - _values "argument key" "$_initctl_eventargs_list[@]" -} - -# describe and offer commands for initctl, then call matching completion function -_initctl_command() -{ - local cmds - cmds=( - start:"Start jobs" - stop:"Stop jobs" - restart:"Restart jobs" - reload:"Send SIGHUP to process instance" - status:"Query status of jobs" - list:"List known jobs" - emit:"Emit an event" - reload-configuration:"tell init to reload config files (generally inotify is used)" - version:"Request the version of the init daemon" - log-priority:"Change the minimum priority of log messages from the init daemon" - show-config:"Show start/stop/emit for processes" - check-config:"Find jobs than can't be started" - help:"display list of commands" - ) - - if (( CURRENT == 1 )); then - _describe -t command "initctl command" cmds - fi - - local cmd=$words[1] - - local curcontext="${curcontext%:*}:initctl-${cmd}" - _call_function ret _initctl_${cmd_completion_funcs[${cmd}]-${cmd_completion_default}} -} - -# completion for start/stop/restart/reload i.e. anything that take one job and multiple KEY= arguments's -_initctl_startstop() -{ - _arguments \ - '--no-wait[do not wait for operation to complete before exiting]' \ - "${common_args[@]}" \ - ':upstart job:_initctl_helper_jobs' \ - '*::argument key:_initctl_known_eventargs' -} - -# completion for anything that takes one job -_initctl_argjob() -{ - _arguments \ - "${common_args[@]}" \ - ':upstart job:_initctl_helper_jobs' \ - '*::' -} - -# completion for emit, providing options, one event and multiple KEY= arguments's -_initctl_emit() -{ - _arguments \ - '--no-wait[do not wait for event to finish before exiting]' \ - "${common_args[@]}" \ - ':event:_initctl_known_events' \ - '*::argument key:_initctl_known_eventargs' -} - -# the fallback, just the options -_initctl_basic() -{ - _arguments \ - "${common_args[@]}" -} - -# completion for show-config, additional option and one job -_initctl_show-config() -{ - _arguments \ - "(-e --enumerate)"{-e,--enumerate}"[enumerate emit lines]" \ - "${common_args[@]}" \ - '::upstart job:_initctl_helper_jobs' \ - '*::' -} - -# completion for show-config, additional options and one job -_initctl_check-config() -{ - _arguments \ - "(-i --ignore-events)"{-i,--ignore-events}"[list of comma-separated events to ignore]:Events:_initctl_multiple_known_events" \ - "(-w --warn)"{-w,--warn}"[treat any unknown jobs or events as error]" \ - "${common_args[@]}" \ - '::upstart job:_initctl_helper_jobs' \ - '*::' -} - -# after defining above functions, overwrite _initctl function so helper-functions are loaded only once -_initctl() -{ - local -a common_args - common_args=( - '--session[use D-Bus session bus to connect to init daemon (for testing)]' - '--system[talk via DBUS system bus instead of socket]' - '(-q --quiet)'{-q,--quiet}'[reduce output to errors only]' - '(-v --verbose)'{-v,--verbose}'[increase output to include informational messages]' - '--dest=[specify D-Bus name for init]:D-Bus name [com.ubuntu.Upstart]' - '--help[display help and exit]' - '--version[output version information and exit]' - ) - - # map each initctl function to a completion function - local -A cmd_completion_funcs - cmd_completion_funcs=( start startstop stop startstop restart startstop reload startstop show-config show-config status argjob emit emit check-config check-config ) - - # define fallback completion function - local cmd_completion_default=basic - - # depending on which command was used, call different completion functions - case $service in - initctl) - _arguments "${common_args[@]}" '*::initctl command:_initctl_command' - ;; - start|stop|restart|reload|status) - _call_function ret _initctl_${cmd_completion_funcs[${service}]-${cmd_completion_default}} - ;; - *) return 1 ;; - esac -} - -_initctl "$@" diff --git a/Completion/Unix/Command/_ldd b/Completion/Unix/Command/_ldd index 98ac41e14..bbac09225 100644 --- a/Completion/Unix/Command/_ldd +++ b/Completion/Unix/Command/_ldd @@ -26,6 +26,17 @@ else '-s[display search path used]' '-v[displays all dependency relationships]' ) + ;| + solaris2.<11->) + args+=( + '-c[disable configuration file used]' + '-D[skip deferred dependency loading]' + '-p[display unresolved parent and external references]' + '-S+[specify system root]:directory:_directories' + '-w[display unresolved weak references]' + '(- *)'{-\?,--help}'[display usage information]' + '(- *)'{-V,--version}'[display version information]' + ) ;; freebsd*) args=( diff --git a/Completion/Unix/Command/_less b/Completion/Unix/Command/_less index b7e658d7e..f20a50818 100644 --- a/Completion/Unix/Command/_less +++ b/Completion/Unix/Command/_less @@ -88,17 +88,25 @@ _arguments -S -s -A "[-+]*" \ '(-\" --quotes)'{'-\"+',--quotes=}'[change quoting character]:quoting characters' \ '(-~ --tilde)'{-~,--tilde}"[don't display tildes after end of file]" \ '(-\# --shift)'{'-\#+',--shift=}"[specify amount to move when scrolling horizontally]:number of columns or fraction of screen width [.5]" \ + '--autosave=[set additional actions which cause the history file to be saved]: : _values -s "" action + "(*)m[setting or clearing a mark]" + "(*)/[searching]" + "(*)\![running a shell command]" + "(m / !)\*[any action; same as m/!]"' \ + '--emouse=[enable mouse features]:mouse feature:_sequence compadd - vscroll vdrag hscroll hdrag lclick rclick scroll drag hmove vmove move click all' \ + '--end-prompt=[specify string to be printed after erasing the prompt]:string' \ '--exit-follow-on-close[exit F command on a pipe when writer closes pipe]' \ '--file-size[automatically determine the size of the input file]' \ '--follow-name[the F command changes file if the input file is renamed]' \ '--form-feed[stop scrolling when a form feed character (^L) is reached]' \ '--header=[set header size]:lines,columns,first-line' \ + '--hilite-target=[highlight the target line]' \ '--incsearch[search file as each pattern character is typed in]' \ '--intr=[specify interrupt character instead of ^X]:char [^X]' \ '--line-num-width=[set the width of line number field]:width [7]' \ '--match-shift=[with -S, shift horizontally to make the match visible]:number of columns or fraction of screen width' \ '--modelines=[look for vim modelines]:number of lines to search' \ - '(--MOUSE)--mouse[enable mouse input]' \ + '(--MOUSE)--mouse[enable mouse clicking and vertical scrolling]' \ '(--mouse)--MOUSE[enable mouse input, wheel down moves backwards in the file]' \ "--no-edit-warn[don't warn when using v command on a file opened by LESSOPEN]" \ '--no-histdups[remove duplicates from command history]' \ @@ -123,6 +131,7 @@ _arguments -S -s -A "[-+]*" \ "E[multi-file]" "F[from first line]" "K[highlight]" "N[non-matching]" "R[literal]" "W[wrap]" -' \ '--show-preproc-errors[display a message if preprocessor exits with an error status]' \ + '--past-eof[scrolling commands continue past end of file]' \ '--status-col-width=[set the width of the -J status column]:width [2]' \ '--status-line[highlight or color the entire line containing a mark]' \ '--use-backslash[subsequent options use backslash as escape char]' \ diff --git a/Completion/Unix/Command/_monotone b/Completion/Unix/Command/_monotone deleted file mode 100644 index bcaab87f0..000000000 --- a/Completion/Unix/Command/_monotone +++ /dev/null @@ -1,43 +0,0 @@ -#compdef mtn - -local -a cmds -cmds=( - automate:automation db:database fdiff:debug fload:debug fmerge:debug - get_roster:debug identify:debug rcs_import:debug annotate:informative - cat:informative complete:informative diff:informative help:informative - list:informative log:informative ls:informative show_conflicts:informative - status:informative cert:key+cert chkeypass:key+cert dropkey:key+cert - genkey:key+cert trusted:key+cert pull:network push:network serve:network - sync:network privkey:packet\ i/o pubkey:packet\ i/o read:packet\ i/o - cvs_import:rcs approve:review comment:review disapprove:review tag:review - testresult:review checkout:tree co:tree explicit_merge:tree heads:tree - merge:tree merge_into_dir:tree migrate_workspace:tree propagate:tree - refresh_inodeprints:tree setup:tree set:vars unset:vars add:workspace - attr:workspace ci:workspace commit:workspace drop:workspace mv:workspace - pivot_root:workspace pluck:workspace rename:workspace revert:workspace - rm:workspace update:workspace -) - -_arguments \ - '--brief[print a brief version of the normal output]' \ - '--confdir[set location of configuration directory]:confdir:_files -/' \ - '(-d --db)'{-d,--db}'[set name of database]:dbname' \ - '--debug[print debug log to stderr while running]' \ - '--dump[file to dump debugging log to, on failure]:dumpfile:_files' \ - '--full-version[print detailed version number, then exit]' \ - '(-h --help)'{-h,--help}'[display help message]' \ - '(-k --key)'{-k,--key}'[set key for signatures]:key:' \ - '--keydir[set location of key store]:keydir:_files -/' \ - '--log[file to write the log to]:logfile:_files' \ - '--norc[do not load ~/.monotone/monotonerc or _MTN/monotonerc lua files]' \ - '--nostd[do not load standard lua hooks]' \ - '--pid-file[record process id of server]:arg:' \ - '--quiet[suppress verbose, informational and progress messages]' \ - '--rcfile[load extra rc file]:extra rcfile:_files' \ - '--reallyquiet[suppress warning, verbose, informational and progress messages]' \ - '--root[limit search for workspace to specified root]:root:_files -/' \ - '--ticker[set ticker style]:ticker style:(count dot none)' \ - '--version[print version number, then exit]' \ - '(-@ --xargs)'{-@,--xargs}'[insert command line arguments taken from the given file]:file:_files' \ - '1:command: _describe -t commands command cmds' \ - '*:file:_files' diff --git a/Completion/Unix/Command/_moosic b/Completion/Unix/Command/_moosic deleted file mode 100644 index 475a0c75c..000000000 --- a/Completion/Unix/Command/_moosic +++ /dev/null @@ -1,487 +0,0 @@ -#compdef moosic - -_moosic_add_cmds() { - - # querying for information - typeset -a queries - queries=( - "help:print brief description of command" - "current:print name of currently playing song" - "current-time:print the amount of time the current song has been playing" - "list:print the list of items in the current song queue" - "plainlist:print the current song queue without numbering each line" - "history:print a list of items that were recently played" - {status,state}":print the current state of the music daemon" - "length:print the number of items in the queue" - "ispaused:show whether the current song is paused or not" - "islooping:show whether the server is in loop mode" - "isadvancing:show whether the server is advancing through the song queue" - "version:print version information for client and server" - ) - - - # appending to song queue - typeset -a appending - appending=( - {append,add}":add the files to be played to the end of the song queue" - {pl-append,pl-add}":add the items listed in the given playlist files to end of queue" - "prepend:add the files to be played to the beginning of the song queue" - "pl-prepend:add the items in the given playlist files to beginning of queue" - "mixin:add the files to the song queue and reshuffle the entire queue" - "pl-mixin:add items in given playlist files to song queue and reshuffle the entire queue" - "replace:replace the current contents of the song queue with files listed" - "pl-replace:replace current contents of song queue with songs given in playlists" - "insert:insert the given items at a given point in the song queue" - "pl-insert:insert items from playlist files at specified point in queue" - "putback:reinsert current song at start of song queue" - "stagger-add:adds file list to end of queue after rearranging queue into staggered order" - "stagger-merge:adds given file list to queue in interleaved fashion" - "interval-add:inserts given songs with regular frequency specified by interval argument" - ) - - # removing - typeset -a removing - removing=( - {cut,del}":removes all song queue items in given range" - "crop:removes all song queue items that do not fall within given range" - "remove:remove all song queue items matching any one of given regexps" - "filter:remove all queue items not matching all given regexps" - "clear:clear song queue" - "wipe:clear song queue and stop current song" - ) - - # rearranging - typeset -a rearranging - rearranging=( - "move:move all items in given range to new position in song queue" - "move-pattern:moves all items matching the given regexp to new position" - "swap:trade places of songs in two specified ranges" - {shuffle,reshuffle}":reshuffle song queue within an optional range" - "sort:sort queue within optional range" - "reverse:reverse order of song queue" - "partial-sort:sort items matching each regexp" - "stagger:stagger items matching each regexp" - "sub:perform regular expression substitution on all items in queue" - "suball:like sub, but replace all occurrences of the pattern" - ) - - # general management - typeset -a general - general=( - "next:jumps ahead, number of songs optional" - "previous:retreats to previously played song" - "goto:jumps to next song matching regexp" - "gobackto:jumps back to most recent previous song matching regexp" - "noadvance:halt queue advancement" - "advance:resume queue advancement" - "toggle-advance:toggle queue advancement" - "stop:stop playing current song, stop processing queue, put current song back" - "pause:suspend current song to resume it later" - "unpause:unpause current song" - "play:resume playing" - "loop:turn loop mode on" - "noloop:turn loop mode off" - "toggle-loop:toggle loop mode" - "reconfigure:daemon reload configuration file" - "showconfig:show daemon filetype associations" - "start-server:starts new instance of daemon with given options" - {quit,exit,die}":quit daemon" - ) - - _describe queries queries -J queries - _describe appending appending -J appending - _describe removing removing -J removing - _describe rearranging rearranging -J rearranging - _describe general general -J general -} - -_moosic() { - typeset context state line - typeset -A opt_args - - typeset -a filelist_opts - filelist_opts=( - '(-g --shuffle-global)'{-g,--shuffle-global}'[shuffle filelist after directory expansion]' - '(-d --shuffle-dir)'{-d,--shuffle-dir}'[shuffle results of expanding the directories]' - '(-a --shuffle-args)'{-a,--shuffle-args}'[shuffle actual command line arguments]' - '(-o --inorder)'{-o,--inorder}'[do not shuffle filelist]' - '(-s --sort)'{-s,--sort}'[sort filelist lexicographically after expansion]' - '(-r --no-recurse)'{-r,--no-recurse}'[do not recurse through directories]' - '(-n --no-file-munge)'{-n,--no-file-munge}'[do not modify names in expanded filelist]' - '(-f --auto-find)'{-f,--auto-find}'[perform fuzzy search for music files]' - '(-F --auto-grep)'{-F,--auto-grep}'[like --auto-find but with regexp]' - '(-U --allow-unplayable)'{-U,--allow-unplayable}'[allow addition of unknown song types]' - ) - - typeset -a auto_opts - auto_opts=( - '(-m --music-dir)'{-m,--music-dir}'[directory used for auto-find, auto-grep]:directory:_files' - ) - - typeset -a main_opts - main_opts=( - '(-i --ignore-case)'{-i,--ignore-case}'[treat regexps as if they are case-insensitive]' - '(-S --showcommands)'{-S,--showcommands}'[show all moosic commands, then exit]' - '(-h --help)'{-h,--help}'[print help message then exit]' - '(-v --version)'{-v,--version}'[print version information, then exit]' - '(-c --config-dir)'{-c,--config-dir}'[configuration directory]:directory:_files' - '(-t --tcp)'{-t,--tcp}'[talk to server at specified host and port]:host\:port:' - '(-N --no-startserver)'{-N,--no-startserver}'[do not start moosicd server]' - ) - - typeset -a list_opts - list_opts=( - '(-C --current-in-list)'{-C,--current-in-list}'[print currently playing song in list]' - ) - - # GLOBAL ARGUMENTS - # do not use the -A option here. It will break the processing of - # positional arguments. - _arguments $main_opts $list_opts $auto_opts $filelist_opts \ - '1: :->cmd' \ - '*:: :->posarg' - - if [[ $state == cmd ]]; then - _moosic_add_cmds - elif [[ $state == posarg ]]; then - _moosic_cmd_${line[1]} - fi -} - -# Do something, but only if the current word is 2. -_do2() { - if (( CURRENT == 2 )); then - $@ - else - _message 'no more arguments' - fi -} - -### QUERY COMMANDS - -_moosic_cmd_help() { - _do2 '_moosic_add_cmds' -} - -_moosic_cmd_current() { - _message 'no arguments' -} - -_moosic_cmd_current-time() { - _do2 '_message' 'strftime string' -} - -_moosic_cmd_list() { - _do2 '_message' 'range' -} - -_moosic_cmd_plainlist() { - _do2 '_message' 'range' -} - -_moosic_cmd_history() { - _do2 '_message' 'maximum number of entries' -} - -_moosic_cmd_status() { - _message 'no arguments' -} - -_moosic_cmd_state() { - _message 'no arguments' -} - -_moosic_cmd_length() { - _message 'no arguments' -} - -_moosic_cmd_ispaused() { - _message 'no arguments' -} - -_moosic_cmd_islooping() { - _message 'no arguments' -} - -_moosic_cmd_isadvancing() { - _message 'no arguments' -} - -_moosic_cmd_version() { - _message 'no arguments' -} - -### APPENDING COMMANDS - -_moosic_song_files() -{ - _arguments -A '-*' $main_opts $filelist_opts $auto_opts \ - '*:song file:_files' -} - -_moosic_cmd_append() { - _moosic_song_files -} - -_moosic_cmd_add() { - _moosic_song_files -} - -_moosic_cmd_pl-append() { - _moosic_song_files -} - -_moosic_cmd_pl-add() { - _moosic_song_files -} - -_moosic_cmd_prepend() { - _moosic_song_files -} - -_moosic_cmd_pl-prepend() { - _moosic_song_files -} - -_moosic_cmd_mixin() { - _moosic_song_files -} - -_moosic_cmd_pl-mixin() { - _moosic_song_files -} - -_moosic_cmd_replace() { - _moosic_song_files -} - -_moosic_cmd_pl-replace() { - _moosic_song_files -} - -_moosic_cmd_insert() { - _moosic_song_files -} - -_moosic_cmd_pl-insert() { - _moosic_song_files -} - -_moosic_cmd_putback() { - _message 'no arguments' -} - -_moosic_cmd_stagger-add() { - _moosic_song_files -} - -_moosic_cmd_stagger-merge() { - _moosic_song_files -} - -_moosic_cmd_interval-add() { - _arguments -A '-*' $main_opts $filelist_opts \ - '1:interval:' \ - '*:song file:_files' -} - -### REMOVING COMMANDS - -_moosic_cmd_cut() { - _do2 '_message' 'range' -} - -_moosic_cmd_del() { - _do2 '_message' 'range' -} - -_moosic_cmd_crop() { - _do2 '_message' 'range' -} - -_moosic_cmd_remove() { - _do2 '_message' 'regex' -} - -_moosic_cmd_filter() { - _do2 '_message' 'regex' -} - -_moosic_cmd_clear() { - _message 'no arguments' -} - -_moosic_cmd_wipe() { - _message 'no arguments' -} - -### REARRANGING COMMANDS - -_moosic_cmd_move() { - _arguments -A '-*' $main_opts \ - '1:range:' \ - '2:index:' \ - '*:no more arguments:' -} - -_moosic_cmd_move-pattern() { - _arguments -A '-*' $main_opts \ - '1:regex:' \ - '2:index:' \ - '*:no more arguments:' -} - -_moosic_cmd_swap() { - _arguments -A '-*' $main_opts \ - '1:range:' \ - '2:range:' \ - '*:no more arguments:' -} - -_moosic_cmd_shuffle() { - _arguments -A '-*' $main_opts \ - '1:range (optional):' \ - '*:no more arguments:' -} - -_moosic_cmd_reshuffle() { - _arguments -A '-*' $main_opts \ - '1:range (optional):' \ - '*:no more arguments:' -} - -_moosic_cmd_sort() { - _arguments -A '-*' $main_opts \ - '1:range (optional):' \ - '*:no more arguments:' -} - -_moosic_cmd_reverse() { - _arguments -A '-*' $main_opts \ - '1:range (optional):' \ - '*:no more arguments:' -} - -_moosic_cmd_partial-sort() { - _do2 '_message' 'regex' -} - -_moosic_cmd_stagger() { - _do2 '_message' 'regex' -} - -_moosic_cmd_sub() { - _arguments -A '-*' $main_opts \ - '1:pattern:' \ - '2:replacement:' \ - '3:range (optional):' \ - '*:no more arguments:' -} - -_moosic_cmd_suball() { - _arguments -A '-*' $main_opts \ - '1:pattern:' \ - '2:replacement:' \ - '3:range (optional):' \ - '*:no more arguments:' -} - -### GENERAL COMMANDS - -_moosic_cmd_next() { - if (( CURRENT == 2 )); then - - typeset -a display display_cmd - if zstyle -a ":completion:${curcontext}:next" \ - 'command' display_cmd; then - $display_cmd - else - display=(${(f)"$(moosic list)"}) - fi - - typeset -a numbers - numbers=({1..${#display}}) - - compadd -V songs -d display -a numbers - else - _message 'no more arguments' - fi -} - -_moosic_cmd_previous() { - _do2 '_message' 'number to skip' -} - -_moosic_cmd_goto() { - _do2 '_message' 'regex' -} - -_moosic_cmd_gobackto() { - _do2 '_message' 'regex' -} - -_moosic_cmd_noadvance() { - _message 'no arguments' -} - -_moosic_cmd_advance() { - _message 'no arguments' -} - -_moosic_cmd_toggle-advance() { - _message 'no arguments' -} - -_moosic_cmd_stop() { - _message 'no arguments' -} - -_moosic_cmd_pause() { - _message 'no arguments' -} - -_moosic_cmd_unpause() { - _message 'no arguments' -} - -_moosic_cmd_play() { - _message 'no arguments' -} - -_moosic_cmd_loop() { - _message 'no arguments' -} - -_moosic_cmd_noloop() { - _message 'no arguments' -} - -_moosic_cmd_toggle-loop() { - _message 'no arguments' -} - -_moosic_cmd_reconfigure() { - _message 'no arguments' -} - -_moosic_cmd_showconfig() { - _message 'no arguments' -} - -_moosic_cmd_start-server() { - _message 'options' -} - -_moosic_cmd_quit() { - _message 'no arguments' -} - -_moosic_cmd_exit() { - _message 'no arguments' -} - -_moosic_cmd_die() { - _message 'no arguments' -} - -_moosic "$@" diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc index 45b181f55..83700d828 100644 --- a/Completion/Unix/Command/_mpc +++ b/Completion/Unix/Command/_mpc @@ -234,7 +234,7 @@ _mpc_play() { } _mpc_seek() { - _message -e position 'position ([+-][HH:MM:SS]|<0-100>%%)' + _message -e position 'position ([+-][HH:MM:SS]|<0-100>%)' } _mpc_seekthrough() { diff --git a/Completion/Unix/Command/_nano b/Completion/Unix/Command/_nano index e2333b9f4..29fb5337a 100644 --- a/Completion/Unix/Command/_nano +++ b/Completion/Unix/Command/_nano @@ -20,7 +20,7 @@ args=( '(-N --noconvert -u --unix)'{-N,--noconvert}"[don't convert files from DOS/Mac format]" '(-O --bookstyle)'{-O,--bookstyle}'[when justifying, leading whitespace means new paragraph]' '(-P --positionlog)'{-P,--positionlog}'[remember cursor position]' - '(-Q --quotestr)'{-Q+,--quotestr=}'[specify regular expression to match quoting]:quoting regex [^([ \t]*([!#%%\:;>|}]|//))+]' + '(-Q --quotestr)'{-Q+,--quotestr=}'[specify regular expression to match quoting]:quoting regex [^([ \t]*([!#%\:;>|}]|//))+]' '(-R --restricted)'{-R,--restricted}'[restrict access to the file system]' '(-S --softwrap)'{-S,--softwrap}'[soft-wrap long lines]' '(-T --tabsize)'{-T+,--tabsize=}'[specify tab width]: :_numbers -u columns -l1 -d8 "tab width"' @@ -73,7 +73,7 @@ case $state in tmp=( ${(f)"$( _call_program syntaxes $words[1] --listsyntaxes )"} ) tmp=( ${tmp:#(#i)*available syntax*} ) tmp=( ${(@Z<n>)tmp} ) - _wanted volume-names expl 'syntax' compadd -a - tmp && ret=0 + _wanted syntaxes expl syntax compadd -a - tmp && ret=0 ;; files) diff --git a/Completion/Unix/Command/_ngrep b/Completion/Unix/Command/_ngrep index 924597826..28d6ddc88 100644 --- a/Completion/Unix/Command/_ngrep +++ b/Completion/Unix/Command/_ngrep @@ -25,6 +25,8 @@ _arguments -s -S \ '-S+[set the upper limit on size of packets matched]:size (bytes)' \ '(-x)-W+[set the dump format]:packet display format:(normal byline single none)' \ '-c+[force the column width to the specified size]:columns' \ + '-C[colorize matches in packet contents output]' \ + '-u[show payload as UTF-8 characters]' \ '-P+[set the non-printable display char to what is specified]:character [.]' \ '-F+[read the bpf filter from the specified file]:file:_files' \ '-N[show sub protocol number]' \ diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm index a78eb7068..725ed3c39 100644 --- a/Completion/Unix/Command/_nm +++ b/Completion/Unix/Command/_nm @@ -69,7 +69,13 @@ if _pick_variant -r variant binutils=GNU elftoolchain=elftoolchain elfutils=elfu '--special-syms[include special symbols in the output]' '--synthetic[display synthetic symbols as well]' "--target=[target object format]:target:(${${(@M)${(f)$(_call_program targets nm --help)}:#*supported targets:*}##*: })" - '--unicode=[specify how to treat UTF-8 encoded unicode characters]:how_to_treat:(default show invalid hex escape highlight)' + '--unicode=[specify how to treat UTF-8 encoded unicode characters]: : _values "treatment [default]" + {d,default}"[no special treatment]" + {l,locale}"[convert to current locale]" + {i,invalid}"[not part of a valid string]" + {x,hex}"[<> enclosed hex byte sequences]" + {e,escape}"[escape sequences (\\\\uxxxx)]" + {h,highlight}"[escape sequences highlighted in red]"' \ '(-W --no-weak)'{-W,--no-weak}'[ignore weak symbols]' '--with-symbol-versions[display version strings after symbol names]' '--without-symbol-versions[not display of symbol version information]' diff --git a/Completion/Unix/Command/_nmap b/Completion/Unix/Command/_nmap index 2a507baa3..4325a5317 100644 --- a/Completion/Unix/Command/_nmap +++ b/Completion/Unix/Command/_nmap @@ -1,63 +1,125 @@ #compdef nmap -local curcontext="$curcontext" state line suf ret=1 +local curcontext="$curcontext" ign dir ret=1 +local -a state line expl suf +local -A opt_args +local -aU scripts categories -_arguments -C \ +(( $#words == 2 )) || ign='!(- *)' +_arguments -s -S -C \ + '!(-6)-4' \ '!-sI:zombie host:_hosts' \ - '!-P'{T,S,U}'+:port list' \ - '*-s-[specify scan type]:scan type:((S\:TCP\ SYN\ scan T\:TCP\ connect\(\)\ scan F\:stealth\ FIN\ scan X\:stealth\ Xmas\ tree\ scan N\:stealth\ null\ scan P\:ping\ scanning U\:UDP\ scan O\:IP\ protocol\ scan I\:idle\ scan A\:ACK\ scan W\:window\ scan R\:RPC\ scan L\:list\ scan V\:version\ detection))' \ - '-b[specify ftp relay host]:ftp relay host:_hosts' \ - '*-P-[specify probe types and options]:probe type/options:->probe-opts' \ - '-A[enable OS detection and version scanning]' \ - '-O[enable remote OS identification]' \ - '-6[enable IPv6 support]' \ - '-I[enable TCP reverse ident scanning]' \ - '-f[use tiny fragmented IP packets]' \ - '*-v[verbose mode]' \ - '-h[show help information]' \ - '*-o-[log results]:log format:->log-forms:log filename:_files' \ - '--resume[resume cancelled scan]:log filename:_files' \ - '--append-output[append results to any log files]' \ + '!-P'{S,A,U,Y}'+:port list' \ + '!-PO+:protocol list' \ + '!(-F -p --exclude-ports)-sn' \ '-iL[read target specifications from file]:file:_files' \ '-iR[scan random hosts]:num hosts' \ - '-p[specify ports to try]:port numbers' \ + '--exclude[specify hosts/networks to exclude]:host list:_sequence _hosts' \ + '--excludefile[use exclude list from a file]:file:_files' \ + '*-s-[specify scan type]:scan type:((S\:TCP\ SYN\ scan T\:TCP\ connect\(\)\ scan F\:stealth\ FIN\ scan X\:stealth\ Xmas\ tree\ scan N\:stealth\ null\ scan P\:ping\ scanning U\:UDP\ scan O\:IP\ protocol\ scan I\:idle\ scan A\:TCP\ ACK\ scan W\:TCP\ window\ scan M\:TCP\ Maimon\ scan R\:RPC\ scan L\:list\ scan Y\:SCTP\ INIT\ scan Z\:SCTP\ COOKIE-ECHO\ scan V\:version\ detection n\:no\ port\ scan C\:equivalent\ to\ --script=default))' \ + '*-P-[specify probe types and options]:probe type/options:->probe-opts' \ + '(-R --dns-servers --system-dns)-n[skip reverse DNS to speed things up]' \ + '(-n)-R[always do reverse DNS on targets]' \ + '--resolve-all[scan all addresses resolved via DNS]' \ + '--unique[scan each address only once]' \ + '(--dns-servers -n)--system-dns[use OS DNS resolver for reverse lookups]' \ + '(--system-dns -n)--dns-servers[specify custom DNS servers for reverse lookups]:server:_sequence _hosts' \ + "--disable-arp-ping[don't do ARP or IPv6 ND of locally connected ethernet hosts]" \ + "--discovery-ignore-rst[don't treat RST replies as proof of a target being up]" \ + '--traceroute[trace hop path to each host]' \ + '--scanflags[customize TCP scan flags]:TCP flags:->tcp-flags' \ + '-b[specify ftp relay host]:ftp relay host:_hosts' \ + '-p+[specify ports to try]:port numbers' \ + '--exclude-ports[exclude specified ports]:port numbers' \ '-F[scan only ports listed in services file]' \ - '-D[perform decoy scan]:host list:_sequence -s, _hosts' \ - '-S[specify source address]:address:_hosts' \ + "-r[don't randomize order in which ports are scanned]" \ + '--top-ports[scan most common ports]:number of ports' \ + '--port-ratio[scan ports more common than specified ratio]: :_numbers -l 0.0 -m 1.0 ratio' \ + "--allports[don't exclude any ports from version detection]" \ + '(--version-light --version-all)--version-intensity[limit version probes to try]:level:((0\:light 1 2 3 4 5 6 7 8 9\:try\ all))' \ + '(--version-intensity --version-all)--version-light[alias for --version-intensity 2]' \ + '(--version-intensity --version-light)--version-all[alias for --version-intensity 9]' \ + '--version-trace[show packets related to version scanning]' \ + '-O[enable remote OS identification]' \ + '--osscan-limit[limit OS detection to promising targets]' \ + '(--osscan-guess --fuzzy)'{--osscan-guess,--fuzzy}'[guess OS more aggressively]' \ + '--max-os-tries[set maximum number of OS detection tries against a target]:tries [5]' \ + '--script=[specify Lua scripts]:script:->scripts' \ + '--script-args[provide arguments to scripts]:arguments' \ + '--script-args-file[provide script arguments in a file]:file:_files' \ + '--script-trace[show all data sent and received]' \ + '--script-updatedb[update the script database]' \ + "$ign--script-help=[show help about scripts]:script:->scripts" \ + --{min,max}-hostgroup'[set parallel scan group size]:size' \ + --{min,max}-parallelism'[specify number of scans to perform in parallel]:number' \ + --{min,max}-rtt-timeout'[set time to wait for a probe response]: :_numbers -u seconds time \:s ms m h' \ + '--initial-rtt-timeout[specify initial probe timeout]: :_numbers -u seconds timeout \:s ms m h' \ + '--max-retries[cap number of port scan probe retransmissions]:tries' \ + '--host-timeout[specify maximum time for scanning a single host]: :_numbers -u seconds timeout \:s ms m h' \ + '--script-timeout[set a ceiling on script execution time]:max time' \ + '(--scan-delay --max-scan-delay)'--{max-,}'scan-delay[set amount of time between probes to a given host]: :_numbers -u seconds delay \:s ms m h' \ + '--min-rate[send packets no slower than number per second]:packets' \ + '--max-rate[send packets no faster than number per second]:packets' \ + '--defeat-'{rst,icmp}'-ratelimit' \ + '--nsock-engine:IO multiplexing engine:(iocp epoll kqueue poll select)' \ + '-T[set a timing template]:timing policy:(paranoid sneaky polite normal aggressive insane)' \ + '-f[fragment packets]' \ + '--mtu=[specify MTU, with -f]:mtu' \ + '-D[perform decoy scan]:host list:_sequence _hosts' \ + '-S[spoof source address]:address:_hosts' \ '-e[specify interface to use]:network interface:_net_interfaces' \ - '-g[specify source port number]:port number' \ + '(-g --source-port)'{-g,--source-port=}'[specify source port number]:port number' \ + '--data=[append a custom payload to sent packets]:payload (hex string)' \ + '--data-string=[append a custom ASCII string to sent packets]:string' \ '--data-length[add random data to packets]:data length' \ - '(-R)-n[skip reverse DNS to speed things up]' \ - '(-n)-R[always do reverse DNS on targets]' \ - "-r[don't randomize order in which ports are scanned]" \ - '-ttl[specify IPv4 time to live for sent packets]' \ + '--ip-options=[send packets with specified IP options]:IP options:->ip-options' \ + '--ttl[specify IPv4 time to live for sent packets]:time-to-live' \ '--randomize-hosts[scan hosts in random order]' \ - '-M[specify maximum number of parallel TCP connects]:maximum TCP connects' \ + '--spoof-mac=[spoof your MAC address]:MAC address' \ + '--proxies=[relay connections through HTTP/SOCKS4 proxies]:proxy:_sequence _urls' \ + '--badsum[send packets with a bogus TCP/UDP/SCTP checksum]' \ + '--adler32[use deprecated Adler32 instead of CRC32C for SCTP checksums]' \ + '*-o-[log results]:log format:->log-forms: :{_files || _date_formats}' \ + '*-v-[increase verbosity]::level' \ + '*-d-[increase debugging level]::level' \ + '--reason[show why a port is in a particular state]' \ + '--stats-every=[print periodic timing stats]: :_numbers -u seconds interval \:s ms m h' \ + '--open[only show open (or possibly open) ports]' \ '--packet-trace[show all packets sent in tcpdump-like format]' \ - '--version-trace[show packets related to version scanning]' \ - '--datadir[specify directory containing data files]:directory:_directories' \ - '-T[specify timing policy]:timing policy:(Paranoid Sneaky Polite Normal Aggressive Insane)' \ - '--host-timeout[specify maximum time for scanning a single host]:timeout (ms)' \ - '--max-rtt-timeout[maximum time for a probe response]:timeout (ms)' \ - '--min-rtt-timeout[minimum time to wait for a probe response]:time (ms)' \ - '--initial-rtt-timeout[specify initial probe timeout]:timeout (ms)' \ - '--max-parallelism[specify max number of scans to perform in parallel]:number' \ - '--min-parallelism[scan at least specified number of ports in parallel]:number' \ - '--scan-delay[specify minimum amount of time between probes]:delay (ms)' \ - '--interactive[go into interactive mode]' \ + "$ign--iflist[list interfaces and routes]" \ + '--append-output[append results to any log files]' \ + "$ign--resume[resume aborted scan]:log filename:_files" \ + '--noninteractive[disable runtime interactions via keyboard]' \ + '(--webxml)--stylesheet[specify XSL stylesheet to transform XML output to HTML]:stylesheet:_urls' \ + '(--stylesheet)--webxml[load stylesheet from Nmap.Org]' \ + '--no-stylesheet[omit XSL stylesheet declaration from XML]' \ + '-6[enable IPv6 scanning]' \ + '(-O)-A[enable OS detection, version detection, script scanning and traceroute]' \ + '--datadir=[specify custom Nmap data file location]:directory:_directories' \ + '--servicedb=[specify custom services file]:services file:_files' \ + '--versiondb=[specify custom service probes file]:service probes file:_files' \ + '(--send-ip)--send-eth[send using raw ethernet frames]' \ + '(--send-eth)--send-ip[send using raw IP packets]' \ + '(--unprivileged)--privileged[assume user is fully privileged]' \ + '(--privileged)--unprivileged[assume user lacks raw socket privileges]' \ + '!--release-memory' \ + "$ign"{-V,--version}'[print version number]' \ + "$ign"{-h,--help}'[print help summary]' \ '*:host:_hosts' && ret=0 case $state in probe-opts) - _values -S '' 'probe type/option' \ - "0[don't try to ping hosts before scanning]" \ - 'T[use TCP "ping"]' \ - 'S[use SYN packets instead of ACK]' \ - 'U[send UDP probes]' \ - 'E[use a true ping]' \ - 'P[use an ICMP timestamp request]' \ - 'M[use a netmask request]' \ - 'B[use ACK and ICMP echo in parallel]' && ret=0 + _values -S '' 'discovery probe type [R]' \ + 'n[skip host discovery]' \ + 'A[use TCP with ACK flag]' \ + 'S[use TCP with SYN flag]' \ + 'U[use UDP discovery probe]' \ + 'Y[use SCTP discovery probe]' \ + 'E[use ICMP echo request ]' \ + 'P[use ICMP timestamp request]' \ + 'M[use ICMP netmask request]' \ + 'O[IP protocol ping]' \ + 'R[use ARP]' && ret=0 ;; log-forms) _values 'log format' \ @@ -65,13 +127,50 @@ case $state in 'X[XML]' \ 'G[grepable]' \ 'A[all]' \ - 'S[S|<ipT kiDdI3]' && ret=0 + 'S[S|<rIpt kIddi3]' && ret=0 ;; - host-list) - suf=() - compset -P '*,' + tcp-flags) + compset -P '(URG|ACK|PSH|RST|SYN|FIN)#' + _wanted tcp-flags expl 'TCP flag' compadd -S '' \ + URG ACK PSH RST SYN FIN && ret=0 + ;; + ip-options) + _values -S ' ' "IP option" \ + 'R[record route (9 slots available)]' \ + 'T[record internet timestamps (9 slots)]' \ + 'U[record timestamps and ip addresses (4 slots)]' \ + 'L[loose source routing (8 slots)]:hop ip' \ + 'S[strict source routing (8 slots)]:hop ip' && ret=0 + ;; + scripts) + compset -P '*,(|+)' compset -S ',*' || suf=(-qS ,) - _hosts "$suf[@]" && ret=0 + + if [[ $PREFIX$SUFFIX = */* ]]; then + _files -g "*.nse(-.)" + return + fi + + categories=( all ) + for dir in \ + ${opt_args[--datadir]:+${~opt_args[--datadir]}/scripts(/N)} \ + $NMAPDIR/scripts(/N) \ + ${${commands[$words[1]]:-$words[1]}:P:h:h}/share/nmap/scripts(/N) \ + ~/.nmap/scripts(/N) \ + ../share/nmap/scripts(/N) \ + $NMAPDATADIR/scripts(/N) \ + . + do + if [[ -r $dir/script.db ]]; then + scripts+=( ${${${(SM)${(f)"$(<$dir/script.db)"}#filename = \"[^.]##.}%.}#*\"} ) + categories+=( ${${(s.,.)${(SM)${(f)"$(<$dir/script.db)"}##categories = [^\}]#}#*\{}//[ \"]/} ) + else + scripts+=( $dir/*.nse(N:t:r) ) + fi + done + _alternative \ + 'categories:category:compadd $suf -a categories' \ + 'scripts:script:compadd -M "r:|-=* r:|=*" $suf -a scripts' && ret=0 ;; esac diff --git a/Completion/Unix/Command/_numfmt b/Completion/Unix/Command/_numfmt index 999c412a1..dd8f6182f 100644 --- a/Completion/Unix/Command/_numfmt +++ b/Completion/Unix/Command/_numfmt @@ -15,6 +15,7 @@ _arguments -S \ '(H)--padding=[pad the output to specified width]:width; positive - right-align; negative - left-align' \ '(H)--round=[use specified method for rounding when scaling]:method [from-zero]:(up down from-zero towards-zero nearest)' \ '(H)--suffix=[add suffix to output numbers and accept optional suffix in input numbers]:suffix' \ + '(H)--unit-separator=[insert separator between number and unit on output]:separator' \ "(H)--to=[auto-scale output numbers to specified unit]:unit:$units" \ '(H)--to-unit=[specify output unit size]:unit size [1]' \ '(H -z --zero-terminated -d --delimiter)'{-z,--zero-terminated}'[line delimiter is NUL, not newline]' \ diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump index 71a615c97..0a8820327 100644 --- a/Completion/Unix/Command/_objdump +++ b/Completion/Unix/Command/_objdump @@ -67,8 +67,13 @@ case $variant in '!(--no-recurse-limit)--recurse-limit' '--no-recurse-limit[disable demangling recursion limit]' '(-w --wide)'{-w,--wide}'[format output for more than 80 columns]' - '-U+[specify how to display unicode characters]:method:(d l e x h i)' - '--unicode=[specify how to display unicode characters]:method:(default locale escape hex highlight invalid)' + '(-U --unicode)'{-U+,--unicode=}'[specify how to treat UTF-8 encoded unicode characters]: : _values "treatment [default]" + {d,default}"[no special treatment]" + {l,locale}"[convert to current locale]" + {i,invalid}"[not part of a valid string]" + {x,hex}"[<> enclosed hex byte sequences]" + {e,escape}"[escape sequences (\\\\uxxxx)]" + {h,highlight}"[escape sequences highlighted in red]"' \ '(-z --disassemble-zeroes)'{-z,--disassemble-zeroes}"[don't skip blocks of zeroes when disassembling]" '--start-address=[only process data whose address is >= ADDR]:address' diff --git a/Completion/Unix/Command/_opustools b/Completion/Unix/Command/_opustools index 1fd97798a..c860a170f 100644 --- a/Completion/Unix/Command/_opustools +++ b/Completion/Unix/Command/_opustools @@ -14,7 +14,7 @@ case $service in '--cvbr[use constrained variable bitrate encoding]' \ '--downmix-mono[downmix to mono]' \ '--downmix-stereo[downmix to stereo (if >2 channels)]' \ - '--expect-loss[set expected packet loss]:expected packet loss (%%) (0-100) [0]' \ + '--expect-loss[set expected packet loss]:expected packet loss (%) (0-100) [0]' \ '--framesize[set maximum frame size]:maximum frame size (milliseconds) [20]:(2.5 5 10 20 40 60)' \ '--hard-cbr[use hard constant bitrate encoding]' \ '--max-delay[set maximum container delay]:maximum container delay (milliseconds) (0-1000) [1000]' \ @@ -57,7 +57,7 @@ case $service in '--no-dither[do not dither 16-bit output]' \ '--float[output 32-bit floating-point samples]' \ '--force-wav[force RIFF wav header on output]' \ - '--packet-loss[simulate random packet loss]:packet loss probability (%%) (0-100)' \ + '--packet-loss[simulate random packet loss]:packet loss probability (%) (0-100)' \ '--save-range[save check values for every frame to a file]:output for check values:_files' ;; opusinfo) diff --git a/Completion/Unix/Command/_pandoc b/Completion/Unix/Command/_pandoc index 243b1ac8b..0bf017882 100644 --- a/Completion/Unix/Command/_pandoc +++ b/Completion/Unix/Command/_pandoc @@ -214,6 +214,7 @@ _arguments -s \ '--highlight-style=[specify coloring style to be used in highlighted source code]: :_pandoc_highlight_style' \ '(- :)--print-highlight-style=[prints a JSON version of a highlighting style]: :_pandoc_highlight_style' \ '--syntax-definition=[load a KDE XML syntax definition file]:file:_files -g "*.xml(-.)"' \ + '--syntax-highlighting=[specify method to use for syntax highlighting]:method' \ \*{-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' \ diff --git a/Completion/Unix/Command/_patchutils b/Completion/Unix/Command/_patchutils index a5f6441b1..83bf1d67f 100644 --- a/Completion/Unix/Command/_patchutils +++ b/Completion/Unix/Command/_patchutils @@ -13,6 +13,9 @@ case $service in '(-z --decompress)'{-z,--decompress}'[decompress .gz and .bz2 files]' ) ;| + (combine|inter|filter|flip)diff) + args+=( '--in-place[write output to original input files]' ) + ;| interdiff|combinediff|flipdiff) args+=( '(-q --quiet)'{-q,--quiet}'[quieter output]' @@ -22,6 +25,7 @@ case $service in '(-B --ignore-blank-lines)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' '(-i --ignore-case)'{-i,--ignore-case}'[ignore case differences]' '(-b --ignore-space-change)'{-b,--ignore-space-change}'[ignore changes in the amount of whitespace]' + '--color=-[colorize the output]::when [auto]:(never always auto)' '!(--in-place)--interpolate' '!-h' '!(--no-revert-omitted --in-place)--combinediff' '!(--no-revert-omitted)--flip' @@ -33,7 +37,6 @@ case $service in "--no-revert-omitted[don't revert files changed in only the first patch]" ) ;; - flipdiff) args+=( '--in-place[write output to original input files]' ) ;; filterdiff|grepdiff|lsdiff) args+=( '(-i --include)'{-i,--include}'[include only files matching pattern]:pattern:_files' @@ -42,6 +45,8 @@ case $service in '--lines=[only list hunks containing lines within specified range]:range' '(-F --files)'{-F+,--files=}'[only list files within specified range]:range' '--strip=[remove specified number of pathname components before displaying]:components' + '--git-prefixes=[specify handling of a/ and b/ prefixes in git diffs]:handling:(strip keep)' + '--git-extended-diffs=[process git diffs without hunks]:action [include]:(exclude include)' '--addprefix=[insert specified path prefix before displaying path names]:prefix:_directories' '*:diff file:_files' ) @@ -68,7 +73,7 @@ case $service in '--format=[use specified output format]:format:(unified context)' '--addnewprefix=[insert specified path prefix before new file path names]:prefix:_directories' '--addoldprefix=[insert specified path prefix before original file path names]:prefix:_directories' - '--as-numbered-lines=[display lines of selected hunks]:line numbers:(before after)' + '--as-numbered-lines=[display lines of selected hunks]:line numbers:(before after original-before original-after)' "--remove-timestamps[don't include timestamps in output]" ) ;| @@ -103,5 +108,6 @@ case $service in ;; esac + _arguments -s $args diff --git a/Completion/Unix/Command/_perl b/Completion/Unix/Command/_perl index 1631560ce..ad0c7c553 100644 --- a/Completion/Unix/Command/_perl +++ b/Completion/Unix/Command/_perl @@ -7,7 +7,7 @@ _perl () { '-0-[input record separator ($/)]:: :_perl_input_seps' \ '-a[autosplit mode with -n or -p (splits $_ into @F)]' \ '-C-[control some unicode features]: :_perl_unicode_flags' \ - "-c[check syntax only (runs BEGIN and END blocks)]" \ + "-c[check syntax only]" \ '( -dt -d: -dt:)-d[run scripts under debugger]' \ '(-d -d: -dt:)-dt[run scripts under debugger (debugged code uses threads)]' \ '(-d -dt -dt:)-d\:-[run under control of a debugging/tracing module]:debugging/tracing module:_perl_modules --strip-prefix --perl-hierarchy=Devel' \ diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep index b7009eafb..b3ef86223 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -1,8 +1,7 @@ -#compdef pgrep pkill +#compdef pgrep pkill pidwait # Notes: -# - We assume that Linux systems use procps-ng - specifically, procps-ng >=3.3.4 -# (which changed the behaviour of -f and added -a) +# - We assume that Linux systems use procps-ng # - We don't really need to keep pgopts and pkopts separate, but it seems like # it should make things a bit easier to follow @@ -17,13 +16,13 @@ typeset -a arguments sig_arguments aopts arguments=( '-a[include process ancestors in match list]' '-c+[match only on specified login class]:login class:_login_classes' - '(-F --pidfile)'{-F+,--pidfile=}'[match only processes in specified PID file]:PID file:_files' + '(-F --pidfile -p --pid)'{-F+,--pidfile=}'[match only processes in specified PID file]:PID file:_files' '(-f --full)'{-f,--full}'[match against full command line]' '(-G --group)'{-G+,--group=}'[match only on specified real group IDs]: :_sequence _groups' '(-g --pgroup)'{-g+,--pgroup=}'[match only on specified process group IDs]: :->pgid' '(: * -)'{-h,--help}'[display help information]' '-I[request confirmation before signalling each process]' - '-i[ignore case distinctions]' + '(-i --ignore-case)'{-i,--ignore-case}'[ignore case distinctions]' '-j+[match only on specified jail IDs]:jail:_sequence _jails -0 -o jid' '(-L --logpidfile)'{-L,--logpidfile}'[fail if PID file not locked (with -F)]' '(-N)-M+[extract name list from specified core]:core file:_files' @@ -67,15 +66,25 @@ arguments=( case $OSTYPE in linux*) # Note: We deliberately exclude -v but not --inverse from pkill - pgopts=AacdFfGghLlnoOPrstUuVvwx- - pkopts=AceFfGgHhLnoOPstUuVx- + pgopts=AacdFfGghLlnopOPQrstUuVvwx- + pkopts=AceFfGgHhLmnoOPstUuVx- + pwopts=AceFfGghiLnOoPpQrstUuVx- arguments=( ${arguments:#((#s)|*\))(\*|)-[acl]*} '(-c --count)'{-c,--count}'[display count of matching processes]' + '(-p --pid -F --pidfile)'{-p+,--pid=}'[match process PIDs]: :_sequence _pids' + '(-Q --shell-quote)'{-Q,--shell-quote}'[output the command line in shell-quoted form]' + ) + [[ $service == pkill ]] && arguments+=( + '(-m --mrelease)'{-m,--mrelease}'[release process memory immediately after kill]' ) [[ $service == pgrep ]] && arguments+=( '(-a -l --list-full --list-name)'{-a,--list-full}'[display full command line]' '(-a -l --list-full --list-name)'{-l,--list-name}'[display process name]' + '--quiet[suppress all normal output]' + ) + [[ $service == pidwait ]] && arguments+=( + '(-e --echo)'{-e,--echo}'[display PIDs before waiting]' ) ;; dragonfly*|freebsd*) @@ -110,7 +119,9 @@ case $OSTYPE in ;; esac -if [[ $service == pgrep ]]; then +if [[ $service == pidwait ]]; then + arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pwopts]*} ) +elif [[ $service == pgrep ]]; then arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pgopts]*} ) else arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pkopts]*} ) @@ -140,7 +151,7 @@ fi arguments+=( $sig_arguments + o '*: :->pname' ) -[[ $OSTYPE == linux* ]] || aopts+=( -A '*-' ) +[[ $OSTYPE == linux* ]] || aopts+=( -A '-?*' ) _arguments -C -s -S $aopts : $arguments && ret=0 # complete comma-separated list of various IDs diff --git a/Completion/Unix/Command/_php b/Completion/Unix/Command/_php index 9a8f519b1..3ed3e2705 100644 --- a/Completion/Unix/Command/_php +++ b/Completion/Unix/Command/_php @@ -155,7 +155,7 @@ _php() { if compset -P 1 '*='; then _default && ret=0 else - compset -S '=*' || suf=( -qS '=' ) + compset -S '=*' || suf=( -r= -S= ) _wanted directives expl 'INI directive' \ compadd "$suf[@]" -a directives && ret=0 fi diff --git a/Completion/Unix/Command/_pip b/Completion/Unix/Command/_pip index bafc7f9e9..370012d56 100644 --- a/Completion/Unix/Command/_pip +++ b/Completion/Unix/Command/_pip @@ -85,7 +85,6 @@ case $state in '--src=[check out --editable packages into given directory]: :_directories' '--ignore-requires-python[ignore the Requires-Python information]' "--no-deps[don't install package dependencies]" - '(-b --build)'{-https://cloud.kiddleb+,--build=}'[specify directory to unpack packages into]: :_directories' '--global-option=[extra global options to be supplied to the setup.py call before the install command]:options' "--no-clean[don't clean up build directories]" '--require-hashes[require a hash to check each requirement against]' diff --git a/Completion/Unix/Command/_pmap b/Completion/Unix/Command/_pmap index 5fd92ab9e..2226d3329 100644 --- a/Completion/Unix/Command/_pmap +++ b/Completion/Unix/Command/_pmap @@ -1,11 +1,11 @@ #compdef pmap if _pick_variant procps=procps-ng unix -V 2>/dev/null; then - # 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 -k --use-kernel-name)'{-k,--use-kernel-name}'[use names provided by kernel]' \ '(exit)*: :_pids' \ + '(format)' \ '(exit)'{-d,--device}'[show the device format]' \ diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix index 006c950e3..8c172b424 100644 --- a/Completion/Unix/Command/_postfix +++ b/Completion/Unix/Command/_postfix @@ -67,7 +67,7 @@ case $service in '-d[delete]:queue id:_postfix_queue_id' \ '-h[hold]:queue id:_postfix_queue_id' \ '-H[release]:queue id:_postfix_queue_id' \ - '*-r[requeue]:queue id, or "ALL":_postfix_queue_id' \ + '*-r[requeue]:queue id:_phony ALL _postfix_queue_id' \ '1:queue:(hold incoming active deferred)' ;; (postqueue) diff --git a/Completion/Unix/Command/_postgresql b/Completion/Unix/Command/_postgresql index 595eb1cb4..aff245578 100644 --- a/Completion/Unix/Command/_postgresql +++ b/Completion/Unix/Command/_postgresql @@ -200,7 +200,7 @@ __pgsql_cfg_params_values() { _message -e values 'PostgreSQL run-time configuration-parameter value' else compset -S '=*' - __pgsql_cfg_params "$@" -qS= + __pgsql_cfg_params "$@" -r= -S= fi } @@ -332,7 +332,7 @@ __pgsql_cfg_variables_values() { _message -e values 'PostgreSQL special-variable value' else compset -S '=*' - __pgsql_variables "$@" -qS= + __pgsql_variables "$@" -r= -S= fi } diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps index 57fee983c..7e3db03a7 100644 --- a/Completion/Unix/Command/_ps +++ b/Completion/Unix/Command/_ps @@ -206,6 +206,7 @@ case $OSTYPE in '-M[show security data]' '(--forest -H)'{--forest,-H}'[show process hierarchy]' '-P[add psr column]' + '--delimiter=[specify column delimiter]:string' '--headers[repeat header lines, one per page of output]' '(--cols --columns --width)'{--cols,--columns,--width}'[set screen width]:width' '(--lines --rows)'{--lines,--rows}'[set screen height]' diff --git a/Completion/Unix/Command/_pump b/Completion/Unix/Command/_pump deleted file mode 100644 index 08ec026ed..000000000 --- a/Completion/Unix/Command/_pump +++ /dev/null @@ -1,24 +0,0 @@ -#compdef pump - -_arguments \ - '(-c --config-file=)'{-c,--config-file=}'[specify configuration file to use]:configuration file:_files' \ - '(-h --hostname=)'{-h,--hostname=}'[specify hostname to request]:hostname:_hosts' \ - '(-i --interface=)'{-i,--interface=}'[specify interface to configure]:interface:_net_interfaces' \ - '(-k --kill)'{-k,--kill}'[kill daemon (and disable all interfaces)]' \ - '(-l --lease=)'{-l,--lease=}'[specify lease time to request]:time (hours)' \ - '(-L --leasesecs=)'{-L,--leasesecs=}'[specify seconds to request for]:time (seconds)]' \ - '(-r --release)'{-r,--release}'[release interface]:interface:_net_interfaces' \ - '(-R --renew)'{-R,--renew}'[force immediate lease renewal]:interface:_net_interfaces' \ - '(-v --verbose)'{-v,--verbose}'[log verbose debug info]' \ - '(-s --status)'{-s,--status}'[display interface status]:interface:_net_interfaces' \ - '(-d --no-dns)'{-d,--no-dns}"[don't update resolv.conf]" \ - '(- *)'{-?,--help}'[display help information]' \ - "--no-gateway[don't set a gateway for this interface]" \ - "--no-setup[don't set up anything]" \ - "--no-resolvconf[don't set up resolvconf]" \ - '--no-bootp[ignore non-DHCP BOOTP responses]' \ - '--lookup-hostname[force lookup of hostname]' \ - '--script=[specify script to use]:script:_files' \ - "--win-client-ident[set the client identifier to match window's]" \ - '--usage[display brief usage message]' \ - ':interface:_net_interfaces' diff --git a/Completion/Unix/Command/_rar b/Completion/Unix/Command/_rar index d1d381974..27120dfa5 100644 --- a/Completion/Unix/Command/_rar +++ b/Completion/Unix/Command/_rar @@ -15,17 +15,19 @@ common=( '-dh[open shared files]' '-ep[exclude paths from name]' '-f[freshen files]' - '-idn[hide archived names]' - '-idp[disable percentage display]' + '-id-[disable messages]: : _values -s "" message + "c[copyright]" "d[done]" "n[archived names]" "p[percentage indicator]" "q[quiet]"' \ '-ierr[send all messages to stderr]' '-inul[disable all messages]' '-kb[keep broken extracted files]' '-o\+[overwrite existing files]' '-o\-[do not overwrite existing files]' + '-ol-[save symbolic links as the link instead of the file]:: :((a\:absolute s\:skip))' \ '-ow[save or restore file owner and group]' '-p+:password' '-p\-[do not query password]' '-r[recurse subdirectories]' + '-si-[read data from standard input]::name' '-ta+[process files modified after a date]:date (YYYYMMDDHHMMSS)' '-tb+[process files modified before a date]:date (YYYYMMDDHHMMSS)' '-tn+[process files newer than a specified time]:time' @@ -56,9 +58,8 @@ case $service in else _arguments -S \ '-ep3[expand paths to full including the drive letter]' \ - '-idc[disable ___ display]' \ - '-idd[disable ___ display]' \ - '-idq[disable ___ display]' \ + '-mes[skip encrypted files]' \ + '-op-[set output path for extracted files]:path:_directories' \ '-n+:file to include:_files' \ '-n@+:file of files to include:_files' \ "$common[@]" \ @@ -106,6 +107,7 @@ case $service in '-en[do not put end of archive block]' \ '-ep1[exclude base directory from names]' \ '-ep2[expand paths to full]' \ + '-ep4-[exclude path prefix from names]:prefix' \ '-hp[encrypt both file data and headers]' \ '-ilog[log errors to file (registered versions only)]' \ '-isnd[enable sound]' \ @@ -113,7 +115,6 @@ case $service in '-m+[set compression level]:compression level:(( 0\:store 1\:fastest 2\:fast 3\:normal 4\:good 5\:maximal ))' \ '-md+[dictionary size]:dictionary size (KB):( 64 128 256 512 1024 2048 4096 a b c d e f g )' \ '-ms[specify file types to store]' \ - '-ol[save symbolic links as the link instead of the file]' \ '-p[set password]' \ '-r0[recurse subdirectories for wildcard names only]' \ '-rr[add data recovery record]' \ diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf index 43cbc81c6..a0ecdaf2a 100644 --- a/Completion/Unix/Command/_readelf +++ b/Completion/Unix/Command/_readelf @@ -2,11 +2,11 @@ local variant args sections -sections=( .bss .data .dynamic .dynsym .got .interp .shstrtab .symtab .text ) +sections=( .bss .comment .data .dynamic .dynsym .got .interp .shstrtab .symtab .text ) _pick_variant -r variant elftoolchain=elftoolchain elfutils=elfutils binutils --version args=( - '(-a --all)'{-a,--all}'[show all tables]' + '(-a --all -h --file-header -l --program-headers --segments -S --section-headers --sections -r --relocs -d --dynamic -V --version-info -A --arch-specific -I --histogram --got-contents)'{-a,--all}'[show all tables]' '(-g --section-groups)'{-g,--section-groups}'[show section groups]' '(-h --file-header)'{-h,--file-header}'[show file header]' '(-l --program-headers --segments)'{-l,--program-headers,--segments}'[show program headers]' @@ -57,8 +57,12 @@ case $variant in '(-C)--demangle=-[decode symbol names]::style [auto]:(none auto gnu-v3 java gnat dlang rust)' '!(--no-recurse-limit)--recurse-limit' '--no-recurse-limit[disable demangling recursion limit]' - '-U+[specify how to display unicode characters]:method:(d l e x h i)' - '--unicode=[specify how to display unicode characters]:method:(default locale escape hex highlight invalid)' + '(-U --unicode)'{-U+,--unicode=}'[specify how to treat UTF-8 encoded unicode characters]: : _values "treatment [locale]" + {l,locale,d,default}"[convert to current locale]" + {i,invalid}"[not part of a valid string]" + {x,hex}"[<> enclosed hex byte sequences]" + {e,escape}"[escape sequences (\\\\uxxxx)]" + {h,highlight}"[escape sequences highlighted in red]"' \ '(-X --extra-sym-info)'{-X,--extra-sym-info}'[display extra information when showing symbols]' '!(-X --extra-sym-info)--no-extra-sym-info' '(-L --lint --enable-checks)'{-L,--lint,--enable-checks}'[display warning messages for possible problems]' @@ -71,6 +75,7 @@ case $variant in '--ctf-symbols=[use specified section as the CTF external symbol table]:section' '--ctf-strings=[use specified section as the CTF external string table]:section' '--sframe=-[display SFrame info from section]::section name [.sframe]' + '(-a --all)--got-contents[display GOT section contents]' '(-T --silent-truncation)'{-T,--silent-truncation}"[if a symbol name is truncated, don't add ... suffix]" ) ;; diff --git a/Completion/Unix/Command/_ruby b/Completion/Unix/Command/_ruby index 82111b455..eebf6c25f 100644 --- a/Completion/Unix/Command/_ruby +++ b/Completion/Unix/Command/_ruby @@ -1,8 +1,8 @@ #compdef ruby irb erb ruby-mri -P (ruby|[ei]rb)[0-9.]# -value-,RUBY(LIB|OPT|PATH),-default- -local curcontext="$curcontext" state line expl desc RUBY ret=1 +local curcontext="$curcontext" state line expl desc RUBY variant ret=1 typeset -A opt_args -local -a opts irb erb all common charsets suf +local -a opts irb erb all common charsets suf jit_opts all=( '*-r+[require the library before executing your script]:library name:->library' @@ -47,23 +47,112 @@ opts=( '--backtrace-limit=[limit the maximum length of backtrace]:number' '!'{-y,--yydebug} '!--dump=:target:(version copyright usage yydebug syntax parsetree parsetree_with_comment insns)' - '(--mjit --yjit)--jit[enable jit for the platform]' - '(--jit --yjit)--mjit[enable C compiler-based JIT compiler]' - '(--jit --mjit)--yjit[enable in-process JIT compiler]' - '--mjit-warnings[enable printing JIT warnings]' - '--mjit-debug[enable JIT debugging (very slow)]' - '--mjit-wait[wait until JIT compilation finishes every time (for testing)]' - '--mjit-save-temps[save JIT temporary files]' - '--mjit-verbose=-[print JIT logs of level num or less to stderr]:maximum log level [0]' - '--mjit-max-cache=-[specify max number of methods to be JIT-ed in a cache]:number [100]' - '--mjit-min-calls=-[specify number of calls to trigger JIT]:calls [10000]' - '--yjit-stat[enable collecting YJIT statistics]' - '--yjit-exec-mem-size=-[size of executable memory block in MiB]:mem size' - '--yjit-call-threshold=-[number of calls to trigger JIT]:number' - '--yjit-max-versions=-[maximum number of versions per basic block]:versions' - '--yjit-greedy-versioning[greedy versioning mode]' ) +if [[ $service == ruby[0-9.]# ]]; then + _pick_variant -r variant -c "$service --version" \ + ruby_no_jit='ruby ([01].|2.[0-5])' \ + ruby_experimental_jit='ruby (2.[67]|3.0)' \ + ruby31='ruby 3.1' ruby32='ruby 3.2' ruby33='ruby 3.3' ruby34='ruby 3.4' \ + ruby40='ruby 4.0' ruby41_higher + + if [[ $variant != "ruby_no_jit" ]]; then + jit_opts=('(--jit --mjit --yjit --rjit --zjit)--jit[enable default JIT for the platform]') + fi + + case "$variant" in + (ruby_experimental_jit|ruby31) + jit_opts+=( + '--jit-warnings[enable printing JIT warnings]' + '--jit-debug[enable JIT debugging (very slow)]' + '--jit-wait[wait until JIT compilation finishes every time (for testing)]' + '--jit-save-temps[save JIT temporary files]' + '--jit-verbose=-[print JIT logs of level num or less to stderr]:log level' + '--jit-max-cache=-[specify max number of methods to be JIT-ed in a cache]:num' + '--jit-min-calls=-[specify number of calls to trigger JIT]:num' + ) + ;| + (ruby31|ruby32) + jit_opts+=( + '(--jit --mjit --yjit)--mjit[enable C compiler-based JIT compiler]' + '(--jit --mjit --yjit)--yjit[enable in-process JIT compiler]' + ) + ;| + (ruby31|ruby32) + jit_opts+=( + '--mjit-warnings[enable printing JIT warnings]' + '--mjit-debug[enable JIT debugging (very slow)]' + '--mjit-wait[wait until JIT compilation finishes every time (for testing)]' + '--mjit-save-temps[save JIT temporary files]' + '--mjit-verbose=-[print JIT logs of level num or less to stderr]:log level' + '--mjit-max-cache=-[specify max number of methods to be JIT-ed in a cache]:num' + '--mjit-min-calls=-[specify number of calls to trigger JIT]:num' + '--yjit-max-versions=[Maximum number of versions per basic block (default: 4)]:num' + '--yjit-greedy-versioning[Greedy versioning mode (default: disabled)]' + ) + ;| + (ruby32|ruby33|ruby34|ruby40|ruby41_higher) + jit_opts+=( + '--yjit-stats[Enable collecting YJIT statistics]' + '--yjit-exec-mem-size=[Hard limit on executable memory block in MiB]:mem size' + '--yjit-call-threshold=[Number of calls to trigger JIT]:num' + ) + ;| + (ruby33|ruby34|ruby40|ruby41_higher) + # mjit was removed since Ruby 3.3 + jit_opts+=( + '--yjit-cold-threshold=[Global calls after which ISEQs not compiled (default: 200K)]:num' + '--yjit-disable[Disable YJIT for lazily enabling it with RubyVM::YJIT.enable]' + '--yjit-code-gc[Run code GC when the code size reaches the limit]' + '--yjit-perf[Enable frame pointers and perf profiling]' + '--yjit-trace-exits[Record Ruby source location when exiting from generated code]' + '--yjit-trace-exits-sample-rate=[Trace exit locations only every Nth occurrence]:num' + ) + ;| + (ruby34|ruby40|ruby41_higher) + jit_opts+=( + '--yjit-mem-size=[Soft limit on YJIT memory usage in MiB (default: 128)]:mem size' + "--yjit-log=[Enable logging of YJIT's compilation activity]: :_files" + ) + ;| + (ruby33|ruby34) + # ruby 3.3 and 3.4 provide rjit + jit_opts+=( + '(--jit --yjit --rjit)--yjit[Enable in-process JIT compiler]' + '--rjit-exec-mem-size=[Size of executable memory block in MiB (default: 64)]:mem size' + '--rjit-call-threshold=[Number of calls to trigger JIT (default: 10)]:num' + '--rjit-stats[Enable collecting RJIT statistics]' + '--rjit-disable[Disable RJIT for lazily enabling it with RubyVM::RJIT.enable]' + '--rjit-trace[Allow TracePoint during JIT compilation]' + '--rjit-trace-exits[Trace side exit locations]' + ) + ;| + (ruby40|ruby41_higher) + # zjit was introduced since ruby 4 + jit_opts+=( + '(--jit --yjit --zjit)--yjit[Enable in-process JIT compiler]' + '(--jit --yjit --zjit)--zjit[enable method-based JIT compiler]' + '--zjit-mem-size=[Max amount of memory that ZJIT can use in MiB (default: 128)]:mem size' + '--zjit-call-threshold=[Number of calls to trigger JIT (default: 30)]:num' + '--zjit-num-profiles=[Number of profiled calls before JIT (default: 5)]:num' + '--zjit-stats-quiet[Collect ZJIT stats and suppress output]' + '--zjit-stats=-[Collect ZJIT stats]: :_files' + '--zjit-disable[Disable ZJIT for lazily enabling it with RubyVM::ZJIT.enable]' + '--zjit-perf[Dump ISEQ symbols into /tmp/perf-{}.map for Linux perf]' + '--zjit-log-compiled-iseqs=[Log compiled ISEQs to the file. The file will be truncated]: :_files' + '--zjit-trace-exits=-[Record source on side-exit]:counter' + '--zjit-trace-exits-sample-rate=[Frequency at which to record side exits]:frequency' + ) + ;| + (ruby41_higher) + jit_opts+=( + '--zjit-trace-compiles[Record compilation phases as Perfetto trace events]' + '--zjit-trace-invalidation[Record invalidation events as Perfetto trace events]' + ) + ;| + esac +fi + irb=( '-f[suppress read of ~/.irbrc]' $opts[(r)*-d\[*] @@ -121,7 +210,7 @@ case "$service" in ;; ruby[0-9.]#) RUBY=$words[1] - _arguments -C -s -S : $opts $all $common && ret=0 + _arguments -C -s -S : $opts $all $common $jit_opts && ret=0 ;; irb[0-9.]#) RUBY=${words[1]/irb/ruby} diff --git a/Completion/Unix/Command/_screen b/Completion/Unix/Command/_screen index 9336ae82d..65cb63e31 100644 --- a/Completion/Unix/Command/_screen +++ b/Completion/Unix/Command/_screen @@ -76,6 +76,7 @@ _arguments -C \ '-m[ignore $STY variable, do create a new screen session]' \ '-O[choose optimal output rather than exact vt100 emulation]' \ '-p[preselect the named window]:window number or name:((\=\:windowlist -\:blank\ window \:window\ number))' \ + '-P[enable authentication]' \ '-q[quiet startup, exit with non-zero return code if unsuccessful]' \ '-Q[send response to stdout of command query process]:screen command:(echo info lastmsg number select time title windows)' \ '-r[reattach to a detached screen process]: :->detached-sessions' \ diff --git a/Completion/Unix/Command/_script b/Completion/Unix/Command/_script index 25f8ea35f..431a112e1 100644 --- a/Completion/Unix/Command/_script +++ b/Completion/Unix/Command/_script @@ -30,7 +30,7 @@ case $OSTYPE in "(-T --log-timing -t --timing $hlp)"{-T+,--log-timing=}'[log timing information to file]:file:_files' "(-m --logging-format $hlp)"{-m+,--logging-format=}'[specify log file format]:format:(classic advanced)' "(-a --append $hlp)"{-a,--append}'[append to the log file]' - "(-c --command $hlp)"{-c,--command=}'[run specified command instead of a shell]:command:_cmdstring' + "(-c --command $hlp --)"{-c,--command=}'[run specified command instead of a shell]:command:_cmdstring' "(-e --return $hlp)"{-e,--return}'[return exit status of the child process]' "(-f --flush $hlp)"{-f,--flush}'[flush output after each write]' "(-E --echo $hlp)"{-E+,--echo=}'[echo input]:when:(auto always never)' @@ -40,6 +40,7 @@ case $OSTYPE in "(-t --timing $hlp)"{-t-,--timing=-}'[output timing data]::timing file:_files' '(- 1)'{-h,--help}'[display help information]' '(- 1)'{-V,--version}'[display version information]' + '!--:*::: : _normal $service' ) ;; darwin*|dragonfly*|netbsd*|freebsd*) diff --git a/Completion/Unix/Command/_sh b/Completion/Unix/Command/_sh index f0f18d4bb..d50b81ccc 100644 --- a/Completion/Unix/Command/_sh +++ b/Completion/Unix/Command/_sh @@ -1,36 +1,151 @@ -#compdef sh ash csh dash ksh ksh88 ksh93 mksh oksh pdksh rc tcsh yash +#compdef sh ash csh dash ksh ksh88 ksh93 lksh mksh oksh osh pdksh posh rc rksh rksh93 tcsh yash ysh -local bourne argv0 -local -a args all_opts=( -{{0..9},{A..Z},{a..z}} ) +(( $+functions[_sh_set_options] )) || +_sh_set_options() { + local MATCH MBEGIN MEND k_ v_ + local -a opts_ tmp_ expl_ -[[ $service == (csh|?csh|fish|rc) ]] || bourne=1 + tmp_=( ${(f)"$( _call_program options $words[1] -c '"set -o"' )"} ) -# Bourne-style shells support +x variants -# @todo Uncomment when workers/45422 is fixed -# (( bourne )) && all_opts+=( ${all_opts/#-/+} ) -# Bourne-style shells take argv[0] as the second argument to -c -(( bourne )) && argv0=':argv[0]:' + # remove heading + [[ $tmp_[1] == (#i)*'current option'* ]] && tmp_=( $tmp_[2,-1] ) + # convert osh/ysh syntax + [[ $tmp_[1] == set\ [+-]o\ * ]] && { + tmp_=( ${(@)tmp_##set [+-]o } ) + tmp_=( ${tmp_:^tmp_} ) + } + # loop since some shells arrange the options in columns + for k_ v_ in $=tmp_; do + opts_+=( $k_ ) + done -# All of the recognised shells support at least these arguments -args=( - "(1 -)-c[execute specified command string]: :_cmdstring$argv0" - '-e[exit immediately on non-zero return]' - '-i[act as interactive shell]' - '-l[act as login shell]' - '-x[print command trace]' - '1:script file:_files' - '*:: :_files' -) -# Bourne-style shells support -o/+o option. Not all of them support -ooption in -# the same argument, but we'll allow it here for those that do -(( bourne )) && args+=( - '-o+[set specified option]:option:' - '+o+[unset specified option]:option:' -) -# Since this is a generic function we don't know what other options these shells -# support, but we don't want them to break the ones listed above, so we'll just -# ignore any other single-alphanumeric option. Obviously this doesn't account -# for long options -args+=( '!'${^${all_opts:#(${(~j<|>)${(@M)${(@M)args#(*[\*\)]|)[+-]?}%[+-]?}})}} ) + _wanted set-options expl_ 'set option' compadd -a "$@" - opts_ +} -_arguments -s -S -A '-*' : $args +local variant apat='[+-]?*' +local -a args oopts + +case ${${(Q)words[1]}:t} in + r#ksh) + _pick_variant -r variant \ + ksh93=showme \ + mksh='utf8-#mode' \ + oksh='csh-#history' \ + '' \ + -c '"set -o"' + ;; + sh) + _pick_variant -r variant \ + zsh=junkie \ + bash=onecmd \ + ksh93=showme \ + mksh='utf8-#mode' \ + oksh='csh-#history' \ + ksh=keyword \ + dash=debug \ + '' \ + -c '"set -o"' + ;; +esac +case $variant in + bash|zsh) _$variant "$@"; return ;; + ?*) service=$variant ;; +esac + +# bourne/ksh/posix-style shells. not meant to be totally accurate, but mostly +if [[ $service != (csh|?csh|rc) ]]; then + args=( + # invocation options + '(1 -)-c[execute specified command string]: :_cmdstring:argv[0]:' + '-i[act as interactive shell]' + '-l[act as login shell]' # not defined by posix but very widely supported + '-o+[set specified option]: :_sh_set_options' + '+o+[unset specified option]: :_sh_set_options' + '(-c)-s[read commands from standard input]' + # set options. these are all defined by posix + '(-a +a)'{'-a[',"+a[don't "}'mark all variables for export]' + '(-b +b)'{'-b[',"+b[don't "}'report status of terminated background jobs immediately]' + '(-C +C)'{'-C[',"+C[don't "}'prevent output redirection from overwriting existing files]' + '(-e +e)'{'-e[',"+e[don't "}'exit immediately on non-zero return]' + '(-f +f)'{'-f[',"+f[don't "}'disable file globbing]' + '(-h +h)'{'-h[',"+h[don't "}'hash commands]' + '(-m +m)'{'-m[',"+m[don't "}'enable job control]' + '(-n +n)'{'-n[',"+n[don't "}'read (syntax-check) commands only]' + '(-u +u)'{'-u[',"+u[don't "}'treat unset variables as an error during parameter expansion]' + '(-v +v)'{'-v[',"+v[don't "}'print shell input lines as they are read]' + '(-x +x)'{'-x[',"+x[don't "}'print command trace]' + ) + + case $service in + dash) + args=( + ${args:#\(*\)[+-]h\[*} + '(-E +E -V +V)'{'-E[',"+E[don't "}'use emacs-style command-line editing]' + '(-I +I)'{'-I[',"+I[don't "}'ignore EOF]' + '(-E +E -V +V)'{'-V[',"+V[don't "}'use vi-style command-line editing]' + ) + ;; + yash) + PREFIX= _sh_set_options -O oopts + oopts=( ${oopts:#cmdline} ) + args+=( + '(- : *)--help[display help information]' + '(- : *)'{-V,--version}'[display version information]' + "(--profile)--noprofile[don't load ~/.yash_profile]" + "(--rcfile)--norcfile[don't load ~/.yashrc]" + '(--noprofile)--profile=[load specified file instead of ~/.yash_profile]:.yash_profile file:_files' + '(--norcfile)--rcfile=[load specified file instead of ~/.yashrc]:.yashrc file:_files' + ${${(M)args:#\(*\)-c\[*}/-c/--cmdline} + --$^oopts + ++$^oopts + ) + ;; + *ksh*) + args+=( + '(-k +k)'{'-k[',"+k[don't "}'recognise parameter assignments anywhere in a command]' + '(-p +p)'{'-p[',"+p[don't "}'enable privileged mode]' + '(-r +r)'{'-r[',"+r[don't "}'enable restricted mode]' + ) + ;| + oksh|r#[lm]ksh) + args+=( + '(-X +X)'{'-X[',"+X[don't "}'mark directories with trailing / when globbing]' + ) + ;| + ksh93) + PREFIX= _sh_set_options -O oopts + oopts=( ${${oopts:#rc}//[_-]/} ) + args+=( + '(-B +B)'{'-B[',"+B[don't "}'enable brace expansion]' + '(-D +D)'{'-D[',"+D[don't "}'display strings subject to language translation]' + '(-E +E --rc)'{'--rc[','-E[',"+E[don't "}'load $ENV or ~/.kshrc]' + '(-G +G)'{'-G[',"+G[don't "}'enable ** pattern (globstar)]' + '(-H +H)'{'-H[',"+H[don't "}'enable history expansion]' + '(-t +t)'{'-t[',"+t[don't "}'read one command and exit]' + --$^oopts + ) + [[ $PREFIX == --n* ]] && args+=( --no$^oopts ) + ;; + r#[lm]ksh) + args+=( + '(-U +U)'{'-U[',"+U[don't "}'enable UTF-8 support]' + '-T+[spawn on specified tty]:tty:_files -g "*(%c)"' + ) + ;; + esac + +# others. these options are common to all of those currently enumerated +else + apat='-?*' + args=( + '(1 -)-c[execute specified command string]: :_cmdstring' + '-e[exit immediately on non-zero return]' + '-i[act as interactive shell]' + '-l[act as login shell]' + '-x[print command trace]' + ) +fi + +args+=( '1:script file:_files' '*:: :_files' ) + +_arguments -s -S -A $apat : $args diff --git a/Completion/Unix/Command/_shutdown b/Completion/Unix/Command/_shutdown index a237b14e0..fdadd3b12 100644 --- a/Completion/Unix/Command/_shutdown +++ b/Completion/Unix/Command/_shutdown @@ -1,35 +1,39 @@ #compdef shutdown -local -a args +local curcontext="$curcontext" variant="$OSTYPE" ret=1 +local -a state line args suffixes -if [[ -d /etc/systemd ]]; then - _arguments \ - '--help[display usage information]' \ - '(-H --halt)'{-H,--halt}'[halt the machine]' \ - '(-P --poweroff -h)'{-P,--poweroff,-h}'[power-off the machine (default)]' \ - '(-r --reboot)'{-r,--reboot}'[reboot the machine]' \ - "(--no-wall)-k[don't shutdown, just write wall message]" \ - "(-k)--no-wall[don't send a wall message]" \ - '-c[cancel pending shutdown]' \ - '1: :_guard "^-*" "time (now/hh\:mm/+mins)"' \ - '*:warning message' - return -fi +[[ -d /run/systemd/system ]] && variant=systemd -case $OSTYPE in +case $variant in + systemd) + args=( + "(-k)--no-wall[don't send a wall message]" + '1: :->times' + '*:warning message' + + '(action)' + '(* : -)--help[display usage information]' + "(--no-wall)-k[don't shutdown, just write wall message]" + {-H,--halt}'[halt the machine]' + {-P,--poweroff,-h}'[power-off the machine (default)]' + {-r,--reboot}'[reboot the machine]' + '-c[cancel pending shutdown]' + ) + ;; *bsd*|dragonfly*|linux*|darwin*) args=( - '-h[halt the system after shutdown]' - '-r[reboot the system]' + '(-p -r -c)-h[halt the system after shutdown]' + '(-p -h -c)-r[reboot the system]' '-k[kick everybody off]' '-n[prevent file system cache from being flushed]' - '1: :_guard "^-*" "time (now/hh\:mm/+mins)"' + '1: :->times' + '(*)-[read warning message from standard input]' \ '*:warning message' ) ;| *bsd*|dragonfly*) args+=( - '-p[turn off power after shutdown]' + '(-h -r -c)-p[turn off power after shutdown]' ) ;| (net|open)bsd*) @@ -39,13 +43,14 @@ case $OSTYPE in ) ;| freebsd*|dragonfly*) + suffixes=( s:seconds :m:minutes h:hours ) args+=( '-o[execute halt or reboot instead of sending a signal to init]' ) ;| freebsd<12->.*) args+=( - '-c[power cycle the system instead of halting if possible]' + '(-h -r -p)-c[power cycle the system instead of halting if possible]' ) ;; netbsd*) @@ -74,4 +79,16 @@ case $OSTYPE in ;; esac -_arguments $args +_arguments -C $args && ret=0 + +if [[ -n $state ]]; then + if compset -P '+'; then + _numbers -u minutes "grace period" $suffixes + else + _alternative \ + 'relative-times:relative time:{ compadd "$expl[@]" -S "" +; compadd "$expl[@]" now }' \ + 'absolute-times: :_guard "^-*" "time ([yymmdd]hhmm)"' && ret=0 + fi +fi + +return ret diff --git a/Completion/Unix/Command/_sleep b/Completion/Unix/Command/_sleep new file mode 100644 index 000000000..677062ab9 --- /dev/null +++ b/Completion/Unix/Command/_sleep @@ -0,0 +1,25 @@ +#compdef sleep + +local sum inf fraction +local -a expl units + +case $OSTYPE in + linux-gnu) + args=( + -S + '--help[display help information]' + '--version[display version information]' + ) + ;& # fall-through + solaris*) + inf="_phony infinity --" + ;& # fall-through + darwin*|freebsd*) + units=( :s:seconds m:minutes h:hours d:days ) + sum='*' + fraction='-f' + ;; +esac + +_arguments $args \ + "${sum}:interval:$inf _numbers $fraction -u seconds interval $units" diff --git a/Completion/Unix/Command/_sqlite b/Completion/Unix/Command/_sqlite index 218b92b4a..9b8431248 100644 --- a/Completion/Unix/Command/_sqlite +++ b/Completion/Unix/Command/_sqlite @@ -50,18 +50,21 @@ options+=( $^dashes'-escape[set rendering of control characters in output]:escape [ascii]:(symbol ascii off)' '(-*batch -*interactive)'$^dashes'-batch[force batch I/O]' '(-*batch -*interactive)'$^dashes'-interactive[force interactive I/O]' + $^dashes'-ifexists[only open if database already exists]' $^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'-nofollow[refuse to open symbolic links to database files]' + $^dashes"-noinit[don't read ~/.sqliterc file at startup]" $^dashes'-nonce[set the safe-mode escape nonce]:string' $^dashes'-no-rowid-in-view[disable rowid-in-view using sqlite3_config()]' $^dashes'-pagecache[specify size and number of slots for page cache memory]:size (bytes): :slots' $^dashes'-pcachetrace[trace all page cache operations]' $^dashes'-readonly[open the database read-only]' $^dashes'-safe[enable safe-mode]' + $^dashes'-screenwidth[use specified default screen width]:width' $^dashes'-stats[print memory stats before each finalize]' $^dashes'-unsafe-testing[allow unsafe commands and modes for testing]' $^dashes'-vfs[use specified default VFS]:vfs:(unix-dotfile unix-excl unix-none unix-namedsem)' diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index 9ab1a1139..c95849e84 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -13,7 +13,7 @@ _ssh () { '-A[enable forwarding of the authentication agent connection]' '-C[compress data]' '-c+[select encryption cipher]:encryption cipher:->ciphers' - '-F+[specify alternate config file]:config file:_files' + '-F+[specify alternate config file]:config file:_phony none _files' '*-i+[select identity file]:SSH identity file:_files -g "*(-.^AR)"' '*-o+[specify extra options]:option string:->option' ) @@ -41,7 +41,7 @@ _ssh () { '-B+[bind to specified interface before attempting to connect]:interface:_net_interfaces' \ '(-P)-b+[specify interface to transmit on]:bind address:_bind_addresses' \ '-D+[specify a dynamic port forwarding]:dynamic port forwarding:->dynforward' \ - '-e+[set escape character]:escape character (or `none'\''):' \ + '-e+[set escape character]:escape character:_phony none' \ '-E+[append log output to file instead of stderr]:log file:_files' \ '(-n)-f[go to background]' \ '-g[allow remote hosts to connect to local forwarded ports]' \ @@ -61,7 +61,7 @@ _ssh () { '-p+[specify port on remote host]:port number on remote host' \ '(-v)*-q[quiet operation]' \ '*-R+[specify remote port forwarding]:remote port forwarding:->forward' \ - '-S+[specify location of control socket for connection sharing]:path to control socket:_files' \ + '-S+[specify location of control socket for connection sharing]:path to control socket:_phony none _files' \ '(- 1 *)-Q+[query parameters]:query option:((cipher\:"supported symmetric ciphers" cipher-auth\:"supported symmetric ciphers that support authenticated encryption" compression mac\:"supported message integrity codes" kex\:"key exchange algorithms" kex-gss\:"GSSAPI key exchange algorithms" key\:"key types" key-cert\:"certificate key types" key-plain\:"non-certificate key types" key-sig\:"all key types and signature algorithms" protocol-version\:"supported SSH protocol versions" sig\:"supported signature algorithms" help\:"show supported queries" HostbasedAcceptedAlgorithms HostKeyAlgorithms KexAlgorithms MACs PubkeyAcceptedAlgorithms))' \ '-s[invoke subsystem]' \ '(-t)-T[disable pseudo-tty allocation]' \ @@ -263,7 +263,7 @@ _ssh () { "$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 -u)-V+[specify certificate validity interval]:interval" \ + "$p1($cmn -f -u)-V+[specify certificate validity interval]:interval:_phony -S\: always" \ "($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 \ @@ -402,8 +402,8 @@ _ssh () { 'values:truth value:(yes no)' && ret=0 ;; (#i)escapechar=*) - _message -e 'escape character (or `none'\'')' - ret=0 + _description escape-characters expl 'escape character' + _phony "$expl[@]" none && ret=0 ;; (#i)fingerprinthash=*) _values 'fingerprint hash algorithm' \ diff --git a/Completion/Unix/Command/_strings b/Completion/Unix/Command/_strings index 685daa286..774399328 100644 --- a/Completion/Unix/Command/_strings +++ b/Completion/Unix/Command/_strings @@ -18,6 +18,13 @@ if _pick_variant -r variant binutils=GNU elftoolchain=elftoolchain elfutils=elfu l\:16-bit\ little-endian B\:32-bit\ big-endian L\:32-bit\ little-endian))' + '(-U --unicode -e --encoding)'{-U+,--unicode=}'[specify how to treat UTF-8 encoded unicode characters]: : _values "treatment [default]" + {d,default}"[rely on --encoding]" + {l,locale}"[convert to current locale]" + {i,invalid}"[not part of a valid string]" + {x,hex}"[<> enclosed hex byte sequences]" + {e,escape}"[escape sequences (\\\\uxxxx)]" + {h,highlight}"[escape sequences highlighted in red]"' \ '(-f --print-file-name)'{-f,--print-file-name}'[print name of the file before each string]' '(-n --bytes)'{-n+,--bytes=}"$bytes" '(-d -t --radix)'{-t+,--radix=}"$format" diff --git a/Completion/Unix/Command/_strip b/Completion/Unix/Command/_strip index 59cb537b9..930080f89 100644 --- a/Completion/Unix/Command/_strip +++ b/Completion/Unix/Command/_strip @@ -49,7 +49,9 @@ if _pick_variant -r variant gnu=GNU elftoolchain=elftoolchain $OSTYPE --version; '(*)-o+[output file]:output file:_files' '--keep-section-symbols[retain section symbols]' '--keep-file-symbols[retain symbols specifying source file names]' - '(-v --verbose)'{-v,--verbose}'[list all object files modified or members of archives]') + '(-v --verbose)'{-v,--verbose}'[list all object files modified or members of archives]' + '--plugin=[load specified plugin]:plugin' + ) ;; elftoolchain) args+=( diff --git a/Completion/Unix/Command/_sudo b/Completion/Unix/Command/_sudo index 33a9d6c0c..e3b3565ef 100644 --- a/Completion/Unix/Command/_sudo +++ b/Completion/Unix/Command/_sudo @@ -1,7 +1,7 @@ #compdef sudo sudoedit local curcontext="$curcontext" environ e cmd cpp ret=1 -local -a context state line args _comp_priv_prefix +local -a context state state_descr line args _comp_priv_prefix local -A opt_args zstyle -a ":completion:${curcontext}:" environ environ @@ -41,7 +41,8 @@ args=( # # TODO: use _arguments' $opt_args to detect the cases '-u jrandom -e' and '-Ae' if [[ $service = sudoedit ]] || (( $words[(i)-e] < $words[(i)^(*sudo|-[^-]*)] )) ; then - args=( -A "-*" $args '!(-V --version -h --help)-e' '*:file:_files' ) + args+=( '!(-V --version -h --help)-e' '*: :_files' ) + _arguments -s -S -A '-?*' : $args && ret=0 else cmd="$words[1]" args+=( @@ -53,38 +54,41 @@ else '(-E -i --login -s --shell -e --edit)--preserve-env=-[preserve user environment when running command]::environment variable:_sequence _parameters -g "*export*"' \ '(-H --set-home -i --login -s --shell -e --edit)'{-H,--set-home}"[set HOME variable to target user's home dir]" \ '(-P --preserve-groups -i --login -s --shell -e --edit)'{-P,--preserve-groups}"[preserve group vector instead of setting to target's]" \ - '*:: :->normal' + '*: :->normal' ) + # sudo allows environment-variable assignments to be interspersed with + # options. this pattern represents the lax method it uses to determine whether + # an arg is an assignment + _arguments -s -S -A '(-?*|[^/=]*=*)' : $args && ret=0 fi -_arguments -s -S $args && ret=0 - if [[ $state = normal ]]; then _comp_priv_prefix=( $cmd -n ${(kv)opt_args[(I)(-[ugHEP]|--(user|group|set-home|preserve-env|preserve-groups))]} ) + + # there's no special handling for assignments with -l. they're parsed as + # normal, just ignored. we'll ignore them too if (( $+opt_args[-l] || $+opt_args[--list] )); then + CURRENT=$#line words=( "${(@)line}" ) _normal -p $service return fi - while [[ $words[1] = *=* ]]; do - if (( CURRENT == 1 )); then - compstate[parameter]="${PREFIX%%\=*}" - compset -P 1 '*=' - _value && ret=0 - return ret - fi - shift words - (( CURRENT-- )) - done - if (( CURRENT == 1 )); then + + # $line excludes words that match the -A pattern, except when it's the current + # word. so if $#line == 1 we haven't seen a command yet + if (( $#line == 1 )) && [[ $PREFIX == *=* ]]; then + compstate[parameter]="${PREFIX%%\=*}" + compset -P 1 '*=' + _value && ret=0 + elif (( $#line == 1 )); then curcontext="${curcontext%:*:*}:-command-:" _alternative \ 'commands:: _command_names -e' \ - 'options:option:(-s --shell -l --login)' \ 'parameters: :_parameters -g "*export*~*readonly*" -qS=' && ret=0 else + CURRENT=$#line words=( "${(@)line}" ) _normal && ret=0 fi fi diff --git a/Completion/Unix/Command/_tcpdump b/Completion/Unix/Command/_tcpdump index 7047b2d34..25605875f 100644 --- a/Completion/Unix/Command/_tcpdump +++ b/Completion/Unix/Command/_tcpdump @@ -94,9 +94,6 @@ _data_link_types () { fi } -_bpf_filter () { -} - args=( '-A[print each packet in ASCII]' '-c+[exit after receiving specified number of packets]:number of packets' diff --git a/Completion/Unix/Command/_texinfo b/Completion/Unix/Command/_texinfo index 2f5d0f91f..a37bc8ae9 100644 --- a/Completion/Unix/Command/_texinfo +++ b/Completion/Unix/Command/_texinfo @@ -123,13 +123,16 @@ case $service in '--conf-dir=[specify additional directory for configuration files]:directory:_directories' \ '--init-file=[specify initialisation file]:file:_files' \ \*{-c+,--set-customization-variable=}'[set customization variable]:variable' \ + '--trace-includes[print names of included files]' \ '(-v --verbose)'{-v,--verbose}'[explain what is being done]' \ '(* -)--version[display version info]' \ - '(--html --xml --plaintext)--docbook[output in DocBook XML format]' \ - '(--docbook --xml --plaintext)--html[output in HTML format]' \ + '(--html --xml --epub3 --latex --plaintext)--docbook[output in DocBook XML format]' \ + '(--docbook --xml --epub3 --latex --plaintext)--html[output in HTML format]' \ '--no-headers[suppress node separators and menus]' \ - '(--docbook --html --plaintext)--xml[output in XML (TexinfoML) format]' \ - '(--docbook --html --xml)--plaintext[output in plain text format]' \ + '(--docbook --html --epub3 --latex --plaintext)--xml[output in XML (TexinfoML) format]' \ + '(--docbook --html --xml --latex --plaintext)--epub3[output in EPUB 3 format]' \ + '(--docbook --html --xml --epub3 --plaintext)--latex[output in LaTeX format]' \ + '(--docbook --html --xml --epub3 --latex)--plaintext[output in plain text format]' \ '--dvi[output in dvi format]' \ '--dvipdf[output in pdf format]' \ '--ps[output in ps format]' \ @@ -138,11 +141,13 @@ case $service in '(--docbook --xml)--no-split[suppress splitting of output]' \ '--no-number-sections[output chapter and section numbers]' \ '!(--no-number-sections)--number-sections' \ + '--no-number-footnotes[number footnotes sequentially]' \ + '!(--no-number-footnotes)--number-footnotes' \ '(-o --output=)'{-o,--output}'[specify output file]:output file:_files' \ '(--docbook --html --xml)--disable-encoding[output special characters]' \ '!(--disable-encoding)--enable-encoding' \ '(--docbook --html --xml)--fill-column=[specify width to break lines at]:width [72]' \ - '(--docbook --html --xml)--footnote-style=[specify style for output of footnotes]:((separate\:in\ own\ node end\:at\ end\ of\ node))' \ + '(--docbook --html --xml)--footnote-style=[specify style for output of footnotes]:style [end]:((separate\:in\ own\ node end\:at\ end\ of\ node))' \ '(--docbook --html --xml)--paragraph-indent=[specify spaces to indent paragraphs by]:indent [3]' \ '(--docbook --html --xml)--split-size=[split Info files at specified size]:size [300000]' \ '(--docbook --xml --plaintext)--css-include=[specify file in include in HTML <style> output]:file:_files' \ @@ -151,7 +156,7 @@ case $service in '(--docbook --xml --plaintext)--split=[split output at specified boundary]:split boundary:(chapter section node)' \ '(--docbook --xml --plaintext)--transliterate-file-names[produce file names in ASCII transliteration]' \ '(--docbook --xml --plaintext)--node-files[produce redirection files for nodes]' \ - '-Xopt=[specify option to texi2dvi]:options' \ + '*-Xopt=[pass option to texi2dvi]:option' \ '-D[define variable]:variable' \ '-I[specify directory to append to @include search path]:directory:_files -/' \ '-P[specify directory to prepend to @include search path]:directory:_files -/' \ diff --git a/Completion/Unix/Command/_tiff b/Completion/Unix/Command/_tiff index 1aeff3ff7..f44df0ec9 100644 --- a/Completion/Unix/Command/_tiff +++ b/Completion/Unix/Command/_tiff @@ -157,7 +157,8 @@ tiffinfo) '-s[display offsets and byte counts for all data strips]' \ '-i[ignore read errors]' \ '-f+[force fill order]:fill order:(lsb2msb msb2lsb)' \ - '-w[display raw data in words]' \ + '-w[show image data as 16-bit words]' \ + '-W[warn about unknown tags]' \ '-z[enable strip chopping]' \ '-M+[set the memory allocation limit]:limit (MiB), 0 for unlimited' \ '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 @@ -172,7 +173,7 @@ tiffmedian) ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffsplit) - _arguments \ + _arguments : \ '-M+[set the memory allocation limit]:limit (MiB), 0 for unlimited' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file prefix' && ret=0 @@ -235,6 +236,7 @@ pal2rgb) *) _description files expl 'picture file' _files "$expl[@]" -g "$pat" && ret=0 +;; esac if [[ -n "$state" ]]; then @@ -265,7 +267,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 zstd webp jpeg g3 && ret=0 + compadd "$expl[@]" -qS: - lzw zip lerc lzma zstd webp jpeg g3 && ret=0 done (( ret )) || return 0 done diff --git a/Completion/Unix/Command/_tla b/Completion/Unix/Command/_tla deleted file mode 100644 index ec7e76d44..000000000 --- a/Completion/Unix/Command/_tla +++ /dev/null @@ -1,631 +0,0 @@ -#compdef tla - -autoload -z is-at-least -local TLA=$words[1] -local tla_version -local hide_short - -# ask the user which version of tla this is -if ! zstyle -s ":completion:${curcontext}:" tla-version tla_version; then - # ask tla instead - tla_version="$($TLA --version)" - if [[ "${${(f)tla_version}[1]}" == The\ GNU\ Arch\ Revision\ Control\ System\ \(tla\)\ (#b)([0-9.]##) ]]; then - tla_version="$match[1]" - else - tla_version="${${$($TLA --version)#tla tla-}%% from regexps.com*}" - [[ $tla_version == *[a-zA-Z]* ]] && tla_version=1.3 # tla doesn't know - fi -fi - -# test whether to hide short options from completion -if zstyle -s ":completion:${curcontext}:" hide-shortopts hide_short; then - case $hide_short in - true|yes|on|1) hide_short='!' ;; - *) hide_short='' ;; - esac -fi - -# completion functions - -(( $+functions[_tla_archives] )) || -_tla_archives () { _arch_archives tla "$@" } - -(( $+functions[_tla_categories] )) || -_tla_categories () { _arch_namespace tla 1 "$argv[@]" } - -(( $+functions[_tla_branches] )) || -_tla_branches () {_arch_namespace tla 2 "$argv[@]" } - -(( $+functions[_tla_versions] )) || -_tla_versions () { _arch_namespace tla 3 "$argv[@]" } - -(( $+functions[_tla_revisions] )) || -_tla_revisions () { _arch_namespace tla 4 "$argv[@]" } - -(( $+functions[_tla_local_revisions] )) || -_tla_local_revisions () { - local expl1 expl2 tree_version=`$TLA tree-version` - _description -V applied-patches expl1 "patch from this version" - _description -V other-patches expl2 "patch from other versions" - compadd "$expl1[@]" `$TLA logs` - compadd "$expl2[@]" `$TLA logs --full $($TLA log-versions | grep -v $tree_version)` - # This is incredibly slow. - # Should complete based on -A, -R, -d -} - -(( $+functions[_tla_config] )) || -_tla_config () { - - # zsh 4.1.1+ is recommended; 4.0.6 gives the error below when doing - # tla build-config e<TAB> - # _path_files:322: no matches found: configs//e/.(/) - # whereas 4.1.1 completes correctly - - local configdir root ret=1 n expl - - n=$opt_args[(i)(-d|--dir)] - [[ -n "$n" ]] && configdir=$opt_args[$n] - root="$(_call_program tla $TLA tree-root ${configdir} 2>&1)" - if (( $? )); then - _message -e messages "Error: $root" - return $ret - fi - - if [[ -d "$root/configs" ]]; then - configdir=("$root/configs") - _description files expl 'config file' - _files -W configdir "$expl[@]" && ret=0 - else - _message -e messages "No configs/ directory in tree whose root is $root" - fi - return $ret -} - -(( $+functions[_tla_limit] )) || -_tla_limit () { #presently only does push-mirror style limits - [[ $words[$CURRENT] == *@* ]] && return 1 - - local expl archive - archive=${words[(r)*@*]:-$($TLA my-default-archive 2> /dev/null)} - if [ $archive ]; then - - if [[ $PREFIX != *--* ]]; then - _description -V categories expl "category in $archive" - compadd -q -S -- "$expl[@]" `$TLA categories -A $archive` - else - _tla_namespace_branches 3 - fi - fi -} - -(( $+functions[_tla_tree_or_rev] )) || -_tla_tree_or_rev () { - _alternative 'trees:tree:_files -/' 'revisions:revision:_tla_revisions' -} - -(( $+functions[_tla_libraries] )) || -_tla_libraries () { - local libraries expl - libraries=($(_call_program tla $TLA my-revision-library)) - _description -V libraries expl "revision library" - compadd "$expl[@]" -a libraries -} - -(( $+functions[_tla_my_revision_library] )) || -_tla_my_revision_library () { - if [[ -n $words[(r)-d] ]] || [[ -n $words[(r)--delete] ]]; then - _tla_libraries - else - _files -/ - fi -} - -(( $+functions[_tla_log_versions] )) || -_tla_log_versions () { - local logs expl - if is-at-least 1.1 $tla_version; then - logs=($(_call_program tla $TLA log-versions)) - else - logs=($(_call_program tla $TLA logs)) - fi - _description -V versions expl "log version" - compadd "$expl[@]" -a logs -} - -# command argument definitions -# commands with different versions - -local cmd_register_archive cmd_archives cmd_ls_archives cmd_redo -local cmd_redo_changes cmd_changes cmd_what_changed cmd_categories -local cmd_branches cmd_versions cmd_cacherev cmd_logs cmd_log_versions -local cmd_log_ls cmd_update cmd_join_branch cmd_replay cmd_deltapatch -local cmd_delta_patch cmd_apply_delta cmd_sync_tree cmd_make_sync_tree -local cmd_delta cmd_revdelta cmd_library_categories cmd_library_branches -local cmd_library_versions cmd_library_revisions -local cmd_archive_register - -cmd_log_ls=('*:version:_tla_log_versions') -cmd_log_versions=() -# the options should only complete items that are in the tree - -if is-at-least 1.1 $tla_version; then - cmd_register_archive=('::archive:_tla_archives' ':location:_files -/') - cmd_archive_register=($cmd_register_archive) - cmd_archives=('::regex:') - cmd_redo=('::changeset:_files -/') - cmd_changes=('::revision:_tla_revisions' - # ':separator:(--)' '*::limit:_files' - #don't understand the limit usage - ) - cmd_categories=('::archive:_tla_archives') - cmd_branches=('::category:_tla_categories') - cmd_versions=('::branch:_tla_branches') - cmd_cacherev=('::revision:_tla_revisions') - #should only complete non-cached revisions - - cmd_logs=($cmd_log_ls) - cmd_update=('::revision:_tla_revisions') - cmd_join_branch=(':revision:_tla_revisions') - #should only complete continuation revisions - - cmd_replay=('*::revision:_tla_revisions') - cmd_deltapatch=(':FROM:_tla_tree_or_rev' ':TO:_tla_tree_or_rev') - cmd_sync_tree=(':revision:_tla_revisions') - cmd_delta=(':FROM:_tla_tree_or_rev' ':TO:_tla_tree_or_rev' '::DEST:_files -/') - cmd_library_categories=('::archive:_tla_archives --library') - cmd_library_branches=('::category:_tla_categories --library') - cmd_library_versions=('::branch:_tla_branches --library') - cmd_library_revisions=('::version:_tla_versions --library') -else - cmd_register_archive=(':archive:_tla_archives' ':location:_files -/') - cmd_archives=() - cmd_redo=() - cmd_changes=('::revision:_tla_revisions') - cmd_categories=() - cmd_branches=(':category:_tla_categories') - cmd_versions=(':branch:_tla_branches') - cmd_cacherev=(':revision:_tla_revisions' '::dir:_files -/') - cmd_logs=($cmd_log_versions) - cmd_update=(':dir:_files -/' '::newdir:_files -/' - '::revision:_tla_revisions') - cmd_join_branch=(':dir:_files -/' '::newdir:_files -/' - ':revision:_tla_revisions') - cmd_replay=(':dir:_files -/' '::newdir:_files -/' '::revision:_tla_revisions') - cmd_deltapatch=(':FROM:_tla_tree_or_rev' ':TO:_tla_tree_or_rev' - ':UPON:_tla_tree_or_rev' '::DEST:_files -/') - cmd_sync_tree=(':dir:_files -/' '::newdir:_files -/' - ':revision:_tla_revisions') - cmd_delta=(':FROM:_tla_tree_or_rev' ':TO:_tla_tree_or_rev') - cmd_library_categories=() - cmd_library_branches=(':category:_tla_categories --library') - cmd_library_versions=(':branch:_tla_branches --library') - cmd_library_revisions=(':version:_tla_versions --library') -fi - -cmd_ls_archives=($cmd_archives) -cmd_redo_changes=($cmd_redo) -cmd_what_changed=($cmd_changes) -cmd_delta_patch=($cmd_deltapatch) -cmd_apply_delta=($cmd_deltapatch) -cmd_make_sync_tree=($cmd_sync_tree) -cmd_revdelta=($cmd_delta) - -# commands the same in all versions - -local cmd_help -cmd_help=() - -local cmd_my_id -cmd_my_id=('::id-string:') - -local cmd_my_default_archive -cmd_my_default_archive=('::archive:_tla_archives') - -local cmd_whereis_archive -cmd_whereis_archive=(':archive:_tla_archives') - -local cmd_init_tree -cmd_init_tree=('::version:_tla_versions') - -local cmd_tree_root -cmd_tree_root=('::directory:_files -/') - -local cmd_tree_version -cmd_tree_version=('::directory:_files -/') - -local cmd_set_tree_version -cmd_set_tree_version=(':version:_tla_versions') - -local cmd_build_config cmd_buildcfg -cmd_build_config=(':config:_tla_config') -cmd_buildcfg=($cmd_build_config) - -local cmd_cat_config cmd_catcfg cmd_cfgcat -cmd_cat_config=(':config:_tla_config') -cmd_catcfg=($cmd_cat_config) -cmd_cfgcat=($cmd_cat_config) - -local cmd_undo cmd_undo_changes -cmd_undo=('::revision:_tla_revisions') -cmd_undo_changes=($cmd_undo) - -local cmd_file_diffs -cmd_file_diffs=(':file:_files' '::revision:_tla_revisions') - -local cmd_file_find -cmd_file_find=(':file:_files' '::revision:_tla_revisions') - -local cmd_inventory cmd_srcfind -cmd_inventory=('::separator:(--)' '*:directory:_files -/') -cmd_srcfind=($cmd_inventory) - -local cmd_tree_lint cmd_lint -cmd_tree_lint=('::directory:_files -/') -cmd_lint=($cmd_tree_lint) - -local cmd_id cmd_invtag -cmd_id=('*:file:_files') -cmd_invtag=($cmd_id) - -local cmd_id_tagging_method cmd_tagging_method methods -cmd_id_tagging_method=('::tagging method:(($methods))') -methods=( - 'names:use naming conventions only' - 'implicit:use naming conventions but permit for inventory tags' - 'tagline:use naming conventions but permit for inventory tags' - 'explicit:require explicit designation of source' -) -cmd_tagging_method=($cmd_id_tagging_method) - -local cmd_add cmd_add_id cmd_add_tag -cmd_add=('*:file to add:_files') -cmd_add_id=($cmd_add) -cmd_add_tag=($cmd_add) - -local cmd_delete cmd_delete_id cmd_delete_tag -cmd_delete=('*:file to delete:_files') -cmd_delete_id=($cmd_delete) -cmd_delete_tag=($cmd_delete) - -local cmd_move cmd_move_id cmd_move_tag -cmd_move_id=(':old name:_files' ':new name:_files') -cmd_move_id=($cmd_move) -cmd_move_tag=($cmd_move) -#would be nice not to offer dirs for newname if oldname is a file, and -#vice versa - -local cmd_mv -cmd_mv=('*:file:_files') -# not really right, but close enough - -local cmd_default_id cmd_explicit_default cmd_default_tag -cmd_default_id=('::TAG-PREFIX:') -cmd_explicit_default=($cmd_default_id) -cmd_default_tag=($cmd_default_id) - -local cmd_tagging_defaults cmd_id_tagging_defaults -cmd_tagging_defaults=() -cmd_id_tagging_defaults=($cmd_tagging_defaults) - -local cmd_changeset cmd_mkpatch -cmd_changeset=( - ':ORIG:_files -/' - ':MOD:_files -/' - ':DEST:_files -/' - '*:file:_files' -) -cmd_mkpatch=("$cmd_changeset[@]") - -local cmd_dopatch cmd_do_changeset cmd_apply_changeset -cmd_dopatch=(':changeset:_files -/' ':target:_files -/') -cmd_do_changeset=($cmd_dopatch) -cmd_apply_changeset=($cmd_dopatch) - -local cmd_show_changeset -cmd_show_changeset=('::changeset:_files -/') - -local cmd_make_archive -cmd_make_archive=('::name:' ':location:_files -/') - -local cmd_archive_setup -cmd_archive_setup=('*:version:_tla_branches --trailing-dashes') - -local cmd_make_category -cmd_make_category=(':category:_tla_archives -S /') - -local cmd_make_branch -cmd_make_branch=(':branch:_tla_categories --trailing-dashes') - -local cmd_make_version -cmd_make_version=(':version:_tla_branches --trailing-dashes') - -local cmd_import cmd_imprev -cmd_import=('::version:_tla_versions') -cmd_imprev=($cmd_import) - -local cmd_commit cmd_cmtrev -cmd_commit=('::version:_tla_versions' ':separator:(--)' '*:file:_files') -cmd_cmtrev=($cmd_commit) - -local cmd_get cmd_getrev -cmd_get=(':revision:_tla_revisions' '::directory:_files -/') -cmd_getrev=($cmd_get) - -local cmd_get_patch cmd_get_changeset -cmd_get_patch=(':revision:_tla_revisions' '::dir:_files -/') -cmd_get_changeset=($cmd_get_patch) - -local cmd_lock_revision -cmd_lock_revision=(':revision:_tla_revisions') - -local cmd_push_mirror cmd_archive_mirror -cmd_push_mirror=( - '::FROM or MINE:_tla_archives' - '::TO:_tla_archives' - '::LIMIT:_tla_limit' -) -cmd_archive_mirror=($cmd_push_mirror) - -local cmd_revisions -cmd_revisions=('::version:_tla_versions') - -local cmd_ancestry -cmd_ancestry=('::revision:_tla_revisions') - -local cmd_ancestry_graph -cmd_ancestry_graph=('::revision:_tla_revisions') - -local cmd_cat_archive_log -cmd_cat_archive_log=(':revision:_tla_revisions') - -local cmd_cachedrevs -cmd_cachedrevs=(':version:_tla_versions') - -local cmd_uncacherev -cmd_uncacherev=(':revision:_tla_revisions' '::dir:_files -/') - -local cmd_archive_meta_info -cmd_archive_meta_info=(':item-name:((name\:foo mirror\:bar))') - -local cmd_archive_snapshot -cmd_archive_snapshot=(':dir:_files -/' '::limit:_tla_revisions') - -local cmd_archive_version -cmd_archive_version=() - -local cmd_archive_fixup -cmd_archive_fixup=() - -local cmd_make_log -cmd_make_log=('::version:_tla_versions') - -local cmd_add_log cmd_add_log_version -cmd_add_log=(':version:_tla_versions') -cmd_add_log_version=($cmd_add_log) - -local cmd_remove_log cmd_remove_log_version -cmd_remove_log=(':version:_tla_log_versions') -cmd_remove_log_version=($cmd_remove_log) - -local cmd_abrowse -cmd_abrowse=('::LIMIT:_tla_revisions') - -local cmd_cat_log -cmd_cat_log=(':revision-spec:_tla_local_revisions') - -local cmd_changelog -cmd_changelog=('::version:_tla_versions') - -local cmd_log_for_merge -cmd_log_for_merge=('::version:_tla_versions') - -local cmd_merges -cmd_merges=(':INTO:_tla_revisions' '::FROM:_tla_revisions') - -local cmd_new_merges -cmd_new_merges=('::version:_tla_versions') - -local cmd_tag cmd_tagrev cmd_branch -cmd_tag=(':SOURCE-REVISION:_tla_revisions' ':TAG-VERSION:_tla_versions') -cmd_tagrev=($cmd_tag) -cmd_branch=($cmd_tag) - -local cmd_star_merge -cmd_star_merge=(':FROM:_tla_revisions') - -local cmd_missing cmd_whats_missing -cmd_missing=('::revision:_tla_revisions') -cmd_whats_missing=($cmd_missing) - -local cmd_pristines cmd_ls_pristines -cmd_pristines=('::limit:_tla_revisions') -cmd_ls_pristines=($cmd_pristines) - -local cmd_lock_pristine -cmd_lock_pristine=(':revision:_tla_revisions') - -local cmd_add_pristine -cmd_add_pristine=(':revision:_tla_revisions') - -local cmd_find_pristine -cmd_find_pristine=(':revision:_tla_revisions') - -local cmd_my_revision_library cmd_library_dir -cmd_my_revision_library=(':library:_tla_my_revision_library') -cmd_library_dir=($my_revision_library) - -local cmd_library_find -cmd_library_find=(':revision:_tla_revisions --library') - -local cmd_library_add -cmd_library_add=(':revision:_tla_revisions --exclude-library-revisions') - -local cmd_library_remove -cmd_library_remove=(':revision:_tla_revisions --library') - -local cmd_library_archives -cmd_library_archives=() - -local cmd_library_log -cmd_library_log=(':revision:_tla_revisions --library') - -local cmd_library_file -cmd_library_file=(':file:_files' ':revision:_tla_revisions --library') - -local cmd_grab -cmd_grab=(':location:_files') - -local cmd_parse_package_name -cmd_parse_package_name=(':name:') - -local cmd_valid_package_name -cmd_valid_package_name=(':name:') - -local cmd_library_config -cmd_library_config=(':library:_tla_libraries') - -local cmd_rbrowse -cmd_rbrowse=('::regular expression:') - -local cmd_rm -cmd_rm=('*:file:_files') - -local cmd_escape -cmd_escape=(':string:') - -local cmd_diff -cmd_diff=('::revision:_tla_revisions') - -local cmd_export -cmd_export=(':revision:_tla_revisions' ':dir:_files -/') - -#mutually exclusive options - -local -A excludes -excludes=( -# This first line means that if --output was given, don't complete -# --no-output or --keep. The converse is not true. ---output '--no-output --keep' ---no-output --output - ---silent ' --quiet --report --verbose --debug' ---quiet '--silent --report --verbose --debug' ---report '--silent --quiet --verbose --debug' ---verbose '--silent --quiet --report --debug' ---debug '--silent --quiet --report --verbose ' - ---sparse --non-sparse ---non-sparse --sparse - ---files ' --directories --both' ---directories '--files --both' ---both '--files --directories ' - ---mirror --mirror-from ---mirror-from --mirror - ---no-cached --cached-tags ---cached-tags --no-cached - ---non-greedy --greedy ---greedy --non-greedy -) - -_tla_main () { - typeset -A opt_args - local arguments - if (( CURRENT > 2 )); then - local cmd=${words[2]} - local var_cmd=cmd_${cmd//-/_} - curcontext="${curcontext%:*:*}:tla-$cmd:" - (( CURRENT-- )) - shift words - - arguments=() - local input - input=(${${(M)${(f)"$($TLA $cmd -h)"}:# *}# }) - - local i j=1 - local short long arg desc action - short=() - long=() - arg=() - desc=() - action=() - for (( i=1 ; i <= ${#input} ; i++ )); do - [[ "$input[i]" != *[^\ ]* ]] && continue # stupid blank lines - short[j]="${${${input[i]}[1,2]}#--}" - long[j]="${${input[i]#-?, }%% *}" - - arg[j]="${${${input[i]%% *}##* }##-*}" - [[ $long[j] == --archive ]] && arg[j]=ARCHIVE # tla doesn't mention this - - desc[j]="${input[i]##* }" - if [[ "$input[i+1]" == \ *[^\ ]* ]]; then # description continues - (( i++ )) - desc[j]="$desc[j] ${input[i]##* }" - fi - [[ "$short[j]" == -[hHV] ]] && continue - desc[j]="${${desc[j]//\[/\\[}//\]/\\]}" # escape brackets - - case $arg[j] in - DIR|PATCH-DIR|DEST|OUTPUT|PATH) - action[j]='_files -/' ;; - FILES|FILE|SNAP-FILE) - action[j]='_files' ;; - MASTER|MASTER-SOURCE|ARCHIVE) - action[j]='_tla_archives' ;; - CATEGORY) - action[j]='_tla_categories' ;; - BRANCH) - action[j]='_tla_branches' ;; - VERSION) - action[j]='_tla_versions' ;; - CFG) - action[j]='_tla_configs' ;; - LIB) - action[j]='_tla_libraries' ;; -# PATCH,FILE) # not sure how to complete this -# action[j]='_tla_patch_file' ;; - *) - action[j]='' ;; - esac - - (( j++ )) - - done - - local excluded k - for (( i = 1 ; i < j ; i++ )); do - excluded=($short[i] $long[i]) - foreach opt (${=excludes[$long[i]]}) - k=$long[(i)$opt] - excluded=($excluded $short[k] $long[k]) - #excludes matching short options too :-) - end - - - # generate arguments to _arguments ;-) - # make long and short options mutually exclusive - [ $short[i] ] && arguments=("$arguments[@]" - "${hide_short}(${excluded})${short[i]}[${desc[i]}]${arg[i]:+:$arg[i]:$action[i]}") - [ $long[i] ] && arguments=("$arguments[@]" - "(${excluded})${long[i]}[${desc[i]}]${arg[i]:+:$arg[i]:$action[i]}") - done - - arguments=("$arguments[@]" "${(@P)var_cmd-*:FILE:_files}") - else - local help - local -U cmds - help=(${(f)"$($TLA help)"}) - cmds=(${${${${(M)help:#* :*}/ #: #/:}%% ##}## #}) - arguments=(':command:(($cmds))') - fi - _arguments -S -A '-*' \ - {"${hide_short}(: -)-V",'(: -)--version'}'[display version]' \ - {"${hide_short}(: -)-h",'(: -)--help'}'[display help]' \ - '(: -)-H[display verbose help]' \ - "$arguments[@]" -} - -_tla_main "$@" diff --git a/Completion/Unix/Command/_totd b/Completion/Unix/Command/_totd deleted file mode 100644 index 4d55d29bb..000000000 --- a/Completion/Unix/Command/_totd +++ /dev/null @@ -1,13 +0,0 @@ -#compdef totdconfig - -_arguments \ - - set1 \ - '-a[add totd specific options]' \ - '-D[add totd specific config into dhclient-enter-hooks]' \ - '-d:name server:_hosts' \ - '-l[configure resolv.conf]' \ - - set2 \ - '-r:config to remove:(dhcp totd resolv all)' \ - - set3 \ - '-h[help]' - diff --git a/Completion/Unix/Command/_twidge b/Completion/Unix/Command/_twidge deleted file mode 100644 index d8b3b3def..000000000 --- a/Completion/Unix/Command/_twidge +++ /dev/null @@ -1,77 +0,0 @@ -#compdef twidge -## completion for twidge 1.0.8, based on twidge(1) - -function _twidge_command { - typeset -a twidge_commands - typeset -i skip=1 - - twidge lscommands | while read cmd desc; do - if [[ $cmd == ---* ]] { - skip=0 - continue - } - if (( skip )) { - continue - } - twidge_commands+="${cmd}:${desc}" - done - - _describe command twidge_commands -} - -function _twidge_args { - typeset -a args_common args_more args_other args_update - - args_common=( - '(-a --all)'{-a,--all}'[receive all content]' - '(-e --exec)'{-e,--exec}'[execute command for each retrieved item]:command' - '(-l --long)'{-l,--long}'[long output format]' - '(-m --mailto)'{-m,--mailto}'[mail retrieved items]:mail address' - ) - - args_more=( - '(-s --saveid)'{-s,--saveid}'[save ID of most recent message]' - '(-u --unseen)'{-u,--unseen}'[only show unseen messages]' - ) - - args_other=( - '(-U --username)'{-U,--username}'[show updates of different user]:username' - ) - - args_update=( - '(-i --inreplyto)'{-i,--inreplyto}'[update in reply to a message]:message id' - '(-i --inreplyto 1)-r[read RFC2822 Mail]' - ':status' - ) - - case ${words[1]} in - lsarchive) - _arguments $args_common $args_more $args_other - ;; - ls(dm(|archive)|recent|replies|rt(|archive|replies))) - _arguments $args_common $args_more - ;; - lsfollow(ers|ing)) - _arguments $args_common :username - ;; - dmsend) - _arguments :recipient :status - ;; - (un|)follow) - _message username - ;; - update) - _arguments $args_update - ;; - esac -} - -function _twidge { - _arguments \ - '(-c --config)'{-c,--config}'[config file]:file:_files' \ - '(-d --debug)'{-d,--debug}'[enable debugging output]' \ - '(-): :_twidge_command' \ - '(-)*:: :_twidge_args' -} - -_twidge "$@" diff --git a/Completion/Unix/Command/_vim b/Completion/Unix/Command/_vim index 5a805b9f6..2e7c70064 100644 --- a/Completion/Unix/Command/_vim +++ b/Completion/Unix/Command/_vim @@ -91,6 +91,7 @@ else '(- *)--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]' + '--log[start logging to given file]:log file:_files' '-i[use specified viminfo file]:viminfo file [~/.viminfo]:_files' ) fi diff --git a/Completion/Unix/Command/_w b/Completion/Unix/Command/_w index 2da57a8f6..b63018024 100644 --- a/Completion/Unix/Command/_w +++ b/Completion/Unix/Command/_w @@ -9,6 +9,7 @@ case $OSTYPE in '(-c --container)'{-c,--container}'[show container uptime]' '(H -h)--no-header[suppress the heading]' '(H -i --ip-addr)'{-i,--ip-addr}'[display IP address instead of hostname]' + '(H -t --terminal)'{-t,--terminal}'[scan terminal devices to locate user sessions]' '(H -o --old-style -s --short)'{-o,--old-style}'[old style output format]' '(H -s --short -o --old-style)'{-s,--short}'[use short output format]' '(H -u --no-current)'{-u,--no-current}'[ignore the username while figuring out the current process and cpu times]' @@ -41,12 +42,18 @@ case $OSTYPE in '-A[sort tty names alphabetically instead of utmp or utmpx order]' ) ;| - solaris*) + aix*|solaris*) args+=( '!(-s -w -l)'{-l,-w} '-s[short output form]' '(-)-u[produce only the heading line]' ) ;| + aix*) + args+=( + "-X[don't truncate user names]" + '-@[tag system activity with workload partition name]:wpar' + ) + ;; esac _arguments -S -s \ diff --git a/Completion/Unix/Command/_w3m b/Completion/Unix/Command/_w3m index de425cfb1..65c150590 100644 --- a/Completion/Unix/Command/_w3m +++ b/Completion/Unix/Command/_w3m @@ -14,6 +14,8 @@ _arguments -C \ '(-e -s )-j[JIS]' \ '(-v *)-B[load bookmark]' \ '-bookmark[specify bookmark file]:bookmark file:_files' \ + '-R[restore from session file]' \ + '-session[specify session file]:session file:_files' \ '-T[specify content-type]:content type:_mime_types' \ '-m[internet message mode]' \ '(-B *)-v[visual startup mode]' \ @@ -36,9 +38,11 @@ _arguments -C \ "-no-proxy[don't use proxy]" \ '(-6)-4[IPv4 only (-o dns_order=4)]' \ '(-4)-6[IPv6 only (-o dns_order=6)]' \ + '-insecure[use insecure SSL config options]' \ "-no-mouse[don't use mouse]" \ '(-no-cookie)-cookie[use cookie]' \ "(-cookie)-no-cookie[don't use cookie]" \ + '-cookie-jar[use specified cookie file]:file:_files' \ '(-no-graph)-graph[use DEC special graphics for border of table and menu]' \ '(-graph)-no-graph[use ASCII character for border of table and menu]' \ '-S[squeeze multiple blank lines]' \ @@ -86,13 +90,13 @@ case "$state" in 'history:history:compadd -a w3mhistory' && ret=0 ;; option) - local -a options - options=( ${${(M)${(f)"$(_call_program options $words[1] -show-option 2>/dev/null)"}:# -o *}/(#b) -o (*)=[^ ]#[[:blank:]]##(*)/$match[1]:${match[2]:l}} ) + local -a wopts + wopts=( ${${(M)${(f)"$(_call_program options $words[1] -show-option)"}:# -o *}/(#b) -o (*)=[^ ]#[[:blank:]]##(*)/$match[1]:${match[2]:l}} ) if compset -P 1 '*='; then _message -e values 'value' else compset -S '=*' || suf=( -S '=' ) - _describe -t options 'option' options "$suf[@]" && ret=0 + _describe -t config-options 'option' wopts "$suf[@]" && ret=0 fi ;; esac diff --git a/Completion/Unix/Command/_webbrowser b/Completion/Unix/Command/_webbrowser index e4f5fe092..17a98669a 100644 --- a/Completion/Unix/Command/_webbrowser +++ b/Completion/Unix/Command/_webbrowser @@ -1,3 +1,3 @@ -#compdef amaya arena chimera dillo dwb express galeon grail gzilla hotjava konqueror light mmm Mosaic netrik opera opera-next retawq skipstone www xmosaic zen +#compdef dillo eolie epiphany falkon konqueror ladybird netrik _alternative 'files: :_files' 'urls: :_urls' diff --git a/Completion/Unix/Command/_xmlsoft b/Completion/Unix/Command/_xmlsoft index b8cf92700..aefb0e978 100644 --- a/Completion/Unix/Command/_xmlsoft +++ b/Completion/Unix/Command/_xmlsoft @@ -37,9 +37,8 @@ case $service in '--novalid[skip the DTD loading phase]' \ '--nodtdattr[do not default attributes from the DTD]' \ '--noout[do not dump the result]' \ - '--maxdepth[increase the maximum depth]:depth' \ - '--maxvars[increase the maximum variables]:variables' \ - '--maxparserdepth[increase the maximum parser depth]:depth' \ + '--maxdepth[increase the maximum depth]:depth [3000]' \ + '--maxvars[increase the maximum variables]:variables [15000]' \ '--huge[relax hardcoded limits of the parser]' \ '--seed-rand[initialise random number generator]:seed' \ '--html[input document is an HTML file]' \ @@ -64,7 +63,6 @@ case $service in '--version[display the version of the XML library used]' \ '--debug[dump a debug tree of the in-memory document]' \ '--shell[run a navigating shell]' \ - '--debugent[debug the entities defined in the document]' \ '--copy[used to test the internal copy implementation]' \ '--recover[output what was parsable on broken XML documents]' \ '--huge[remove any internal arbitrary parser limits]' \ @@ -75,8 +73,6 @@ case $service in '--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]' \ - '--nowrap[do not put HTML doc wrapper]' \ '--valid[validate the document in addition to std well-formed check]' \ '(--dtdvalid --relaxng --schema)--postvalid[do a posteriori validation, i.e after parsing]' \ '(--postvalid --relaxng --schema --dtdvalidfpi)--dtdvalid[do a posteriori validation against a given DTD]:DTD:_webbrowser' \ @@ -86,17 +82,19 @@ case $service in '(--noout --output -o)'{--output,-o}'[save to a given file]:output file:_files' \ '--repeat[repeat 100 times, for timing or profiling]' \ '--insert[ad-hoc test for valid insertions]' \ + '--strict-namespace[return failure if document has namespace errors]' \ '--compress[turn on gzip compression of output]' \ '--html[use the HTML parser]' \ '--xmlout[use the XML serializer when using --html]' \ '--nodefdtd[do not default HTML doctype]' \ '--push[use the push mode of the parser]' \ - '--pushsmall[use the push mode of the parser using tiny increments]' \ '--memory[parse from memory]' \ - '--maxmem[limit memory allocation]:bytes' \ + '--maxmem[limit memory allocation]:maximum (bytes)' \ '--nowarning[do not emit warnings from parser/validator]' \ '--noblanks[drop (ignorable?) blanks spaces]' \ '--nocdata[replace cdata section with text nodes]' \ + '--nodict[create document without dictionary]' \ + '--pedantic[enable additional warnings]' \ '--format[reformat/reindent the input]' \ '--encode[output in the given encoding]:encoding:(${encoding[@]})' \ '--dropdtd[remove the DOCTYPE of the input docs]' \ @@ -124,6 +122,8 @@ case $service in '--sax[do not build a tree but work just at the SAX level]' \ '--oldxml10[use XML-1.0 parsing rules before the 5th edition]' \ '(--noout)--xpath[evaluate the XPath expression, implies --noout]:XPath expression' \ + '(--noout)--xpath0[evaluate the XPath expression separating results by NUL, implies --noout]:XPath expression' \ + '--max-ampl[set maximum amplification factor]:factor [5]' \ '*:XML file:_webbrowser' && return ;; *XML_CATALOG_FILES*) diff --git a/Completion/Unix/Command/_xxd b/Completion/Unix/Command/_xxd index e9015a081..f56590915 100644 --- a/Completion/Unix/Command/_xxd +++ b/Completion/Unix/Command/_xxd @@ -22,13 +22,14 @@ local arguments arguments=( # output options - '(-b -bits -i -include -p -postscript -plain -ps -r -revert -u -uppercase)'{-b,-bits}'[output in binary digits, rather than hex]' - '( -E -EBCDIC -i -include -p -postscript -plain -ps -r -revert )'{-E,-EBCDIC}'[print human-readable part in EBCDIC rather than ASCII]' - '(-i -include -p -postscript -plain -ps -r -revert)-e[little-endian dump]' - '(-b -bits -E -EBCDIC -i -include -p -postscript -plain -ps -r -revert )'{-i,-include}'[output in C include file style]' - '(-b -bits -E -EBCDIC -i -include -p -postscript -plain -ps -C -capitalize )'{-p,-postscript,-plain,-ps}'[read or write a plain hexdump (no line numbers or ASCII rendering)]' + '(-b -bits -i -include -t -p -postscript -plain -ps -r -revert -u -uppercase)'{-b,-bits}'[output in binary digits, rather than hex]' + '(-E -EBCDIC -i -include -t -p -postscript -plain -ps -r -revert)'{-E,-EBCDIC}'[print human-readable part in EBCDIC rather than ASCII]' + '(-i -include -t -p -postscript -plain -ps -r -revert)-e[little-endian dump]' + '(-E -EBCDIC -i -include -p -postscript -plain -ps -r -revert)'{-i,-include}'[output in C include file style]' + '(-E -EBCDIC -p -postscript -plain -ps -r -revert)-t[append terminating zero to C include output]' + '(-b -bits -E -EBCDIC -i -include -t -p -postscript -plain -ps -C -capitalize)'{-p,-postscript,-plain,-ps}'[read or write a plain hexdump (no line numbers or ASCII rendering)]' - '(-b -bits -E -EBCDIC -i -include -r -revert -u -uppercase)'{-r,-revert}'[reverse mode\: read a hex dump and output binary data]' + '(-b -bits -E -EBCDIC -i -include -t -r -revert -u -uppercase)'{-r,-revert}'[reverse mode\: read a hex dump and output binary data]' '(-b -bits -r -revert -u -uppercase)'{-u,-uppercase}'[output upper-case hex digits]' '(- :)'{-h,-help}'[display usage message]' @@ -42,7 +43,7 @@ arguments=( '(-o -offset)'{-o+,-offset}'[add specified offset to displayed file position]:offset' '-d[show offset in decimal instead of hex]' '-R+[colorize the output]:when:(always auto never)' - '(-s -skip -seek)'{-s+,-skip,-seek}'[specify file offset to dump from]: :_guard "(0x|)[0-9a-fA-F]#" "file offset to dump from (absolute or relative)"' + '(-s -skip -seek)'{-s+,-skip,-seek}'[specify file offset to dump from]: :_guard "([+-]|)(0x|)[0-9a-fA-F]#" "file offset to dump from (bytes, absolute or +/- relative)"' ': :_files' ) diff --git a/Completion/Unix/Command/_xz b/Completion/Unix/Command/_xz index 6e68e0f69..d441a6545 100644 --- a/Completion/Unix/Command/_xz +++ b/Completion/Unix/Command/_xz @@ -18,12 +18,13 @@ case "$service" in '(I -k --keep)'{-k,--keep}"[keep (don't delete) input files]" \ '(I -f --force)'{-f,--force}'[force overwrite]' \ '(I -c --stdout)'{-c,--stdout}'[write on standard output]' \ + "(I)--no-sync[don't flush writes before removing input file]" \ '(I)*'{-q,--quiet}'[suppress all warnings]' \ '(I)*'{-v,--verbose}'[verbose mode]' \ '(I * --files --files0)--files=-[read list of files to process from file]::file:_files' \ '(I * --files --files0)--files0=-[read null terminated list of files to process from file]::file:_files' \ '(I -F --format)'{-F+,--format=}'[specify file format]:format:(auto xz lzma lzip raw)' \ - '(I -T --threads)'{-T+,--threads=}'[use specified number of threads]:threads [1]' \ + '(I -T --threads)'{-T+,--threads=}'[use specified number of threads]:threads [0]' \ '(I -M --memlimit --memory)'{-M+,--memlimit=,--memory=}'[set memory usage limit]: :_numbers -u bytes "memory limit" KiB MiB GiB %\:percentage\ of\ available\ RAM' \ '(I)--no-adjust[give error if settings exceed memory limit]' \ '(I -Q --no-warn)'{-Q,--no-warn}'[make warnings not affect exit status]' \ @@ -49,11 +50,14 @@ case "$service" in '(* comp decomp level filters common)--info-memory[display amount of RAM and memory usage limits]' \ '(- *)'{-h,--help}'[display help message]' \ '(- *)'{-H,--long-help}'[display the long help (lists also the advanced options)]' \ + '(- *)--filters-help[display liblzma filter string syntax information]' \ '(* comp decomp level filters common)'{-V,--version}'[display version number]' \ + '(level)' \ '(I filters decomp)-'{-best,-fast,1,2,3,4,5,6,7,8,9} \ + filters \ - '(I level decomp --extreme)'--{x86,powerpc,ia64,arm,armthumb,arm64,sparc}=-'[add a branch/call/jump filter]::option:->bcj-options' \ + '(I level decomp --extreme)'--{x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv}=-'[add a branch/call/jump filter]::option:->bcj-options' \ + '(I level decomp --extreme)--filters=[set filter chain using liblzma filter string]:filter string' \ + '!(I level decomp --extreme)--filters'{1..9}'=:filter string' \ '(I level decomp --extreme)'--lzma{1,2}=-'[add lzma filter]::option:->lzma-options' \ '(I level decomp --extreme)--delta=-[add delta filter]::option:->delta-options' && ret=0 ;; diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs index 3a884439b..412469521 100644 --- a/Completion/Unix/Command/_zfs +++ b/Completion/Unix/Command/_zfs @@ -169,8 +169,8 @@ case $service:$implementation in 'userobjquota@' 'vscan:value:(on off)' 'xattr:value:(on off dir sa)' - "filesystem_limit: :{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ -prefix n ]]; then compadd none; else _message -e limits 'number or none'; fi}" - "snapshot_limit: :{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ -prefix n ]]; then compadd none; else _message -e limits 'number or none'; fi}" + "filesystem_limit:unlimited:_phony none _numbers limit" + "snapshot_limit:unlimited:_phony none _numbers limit" 'volmode:mode:(( default\:use\ system-wide\ tunable full\:expose\ as\ block\ devices @@ -477,9 +477,11 @@ case $service:$words[1] in ;; zfs:clone) - [[ $implementation = solaris ]] && args+=( - '-K[create encryption key]' - ) + if [[ $implementation = solaris ]]; then + args+=( '-K[create encryption key]' ) + else + args+=( "-u[don't mount newly created dataset]" ) + fi _arguments -C -A "-*" -S $args \ '-p[create parent datasets]' \ '*-o+[set property]:property:->create-properties' \ @@ -642,7 +644,7 @@ case $service:$words[1] in '-l[load keys for encrypted filesystems as they are being mounted]' '(-a)-R[mount filesystems along with all their children]' ) - _arguments -A "-*" -S $args \ + _arguments -A "-*" -S : $args \ '(- :)'{-j,--json}'[show all mounted file systems in JSON format]' \ '-o+[specify temporary file system options]: :_values -s , "option" {,no}{atime,dev,exec,relatime,suid,xattr} ro rw' \ '-v[report mount progress]' \ @@ -1023,7 +1025,7 @@ case $service:$words[1] in '-f[force use of in-use devices]' \ '-n[display configuration without creating pool]' \ '-R+[use alternate root]:alternate root:_directories' \ - '-m+[set mountpoint for root dataset]:mountpoint' \ + '-m+[set mountpoint for root dataset]:mountpoint:_phony none _path_files -/ -P / -W /' \ '-t+[use a temporary pool name]:pool name' \ ':pool :_guard "^-*" "pool name"' \ '*: :->virtual-devices' diff --git a/Completion/Unix/Command/_zip b/Completion/Unix/Command/_zip index cfa51be36..29c242caa 100644 --- a/Completion/Unix/Command/_zip +++ b/Completion/Unix/Command/_zip @@ -166,7 +166,7 @@ case $state in elif [[ -f $testfile.ZIP ]]; then zipfile=$testfile.ZIP else - return 1 + return ret fi 2>/dev/null if [[ $zipfile != $_zip_cache_name ]]; then _zip_cache_name="$zipfile" diff --git a/Completion/Unix/Command/_zstd b/Completion/Unix/Command/_zstd index 92c4a8e41..db23e541b 100644 --- a/Completion/Unix/Command/_zstd +++ b/Completion/Unix/Command/_zstd @@ -52,6 +52,7 @@ elif (( $words[(I)(-d|--decompress|--uncompress|-l|--list|-t|--test)] )); then '(--sparse)-o[specify output file]:file:_files -g "^*.(|t)zst(-.)"' "(M)--no-check[ignore checksums in compressed frame]" '!(M --no-check)'{-C,--check} + '--pass-through[pass through uncompressed files as-is]' '*:files:_files -g "*.(|t)zst(-.)"' ) else @@ -108,6 +109,7 @@ _arguments -s -S : $args \ '--filelist=[read list of files to operate upon from file]: :_files' \ '--output-dir-flat=[store processed files in directory]: :_directories' \ '--output-dir-mirror=[store processed files in directory respecting original structure]: :_directories' \ + '--no-asyncio[disable asynchronous IO]' \ '--trace=[log tracing information to file]: :_files' \ + '(M)' \ \!{-z,--compress,--uncompress} \ diff --git a/Completion/Unix/Type/_arch_archives b/Completion/Unix/Type/_arch_archives deleted file mode 100644 index 9ffd7e3d3..000000000 --- a/Completion/Unix/Type/_arch_archives +++ /dev/null @@ -1,14 +0,0 @@ -#autoload - -local ARCHCMD="$1" -shift -local expl completions library name_arg='-n' -if [[ -n $argv[(r)--library] ]]; then - library='library-' - # remove parameter from $@ before calling compadd - argv[(r)--library]=() - name_arg= -fi -completions=($(_call_program ${ARCHCMD} ${ARCHCMD} ${library:-}archives $name_arg)) -_description -V archives expl "${library:-}archives" -compadd "$@" "$expl[@]" -- "$completions[@]" diff --git a/Completion/Unix/Type/_arch_namespace b/Completion/Unix/Type/_arch_namespace deleted file mode 100644 index 171293887..000000000 --- a/Completion/Unix/Type/_arch_namespace +++ /dev/null @@ -1,105 +0,0 @@ -#autoload - -_arch_namespace () { #double as arch_namespace_categories - local ARCHCMD="$1" - shift -# takes an integer argument specifying how many components: -# 1: category -# 2: branch -# 3: version -# 4: revision - local suffix expl archive=`$ARCHCMD my-default-archive 2> /dev/null` - local trailing_dashes=0 - [[ -n $argv[(r)--trailing-dashes] ]] && trailing_dashes=1 - local library - [[ -n $argv[(r)--library] ]] && library='library-'; - local exclude_library_revisions=0 - [[ -n $argv[(r)--exclude-library-revisions] ]] && exclude_library_revisions=1 - - if [ $1 -gt 1 ] || (( trailing_dashes )); then - suffix=(-q -S --) - fi - if [[ $PREFIX = */* ]]; then - compset -P '*/' - archive=${IPREFIX%/*} - _description -V categories expl "${library:-}categories in $archive" - compadd $suffix "$expl[@]" `$ARCHCMD ${library:-}categories $archive` - elif [ -z $IPREFIX ]; then - local index=$(( words[(i)-A] + 1 )) - (( index < CURRENT )) || index=$(( words[(i)--archive] + 1 )) - (( index < CURRENT )) && archive=$words[$index] - - if [ $archive ]; then - _description -V categories expl "${library:-}categories in $archive" - compadd "$expl[@]" $suffix `$ARCHCMD ${library:-}categories $archive` - fi - - _arch_archives "$ARCHCMD" -S / ${library:+--library} - fi - if [ $archive ] && [ $1 -gt 1 ] && [[ $PREFIX != *@* ]] \ - && [[ $PREFIX = *--* ]]; then - #this match could be better - _arch_namespace_branches "$ARCHCMD" $(($1 - 1)) - fi -} - -(( $+functions[_arch_namespace_branches] )) || -_arch_namespace_branches () { - local ARCHCMD="$1" - shift - local suffix expl - if [ $1 -gt 1 ] || (( $trailing_dashes )); then - suffix=(-q -S --) - fi - if [[ $IPREFIX != *-- ]]; then - compset -P 1 '*--' - local category=${IPREFIX%--} - _description -V branches expl "${library:-}branches" - compadd $suffix "$expl[@]" \ - ${${(@)$($ARCHCMD ${library:-}branches $category)}##*--} - fi - if [ $1 -gt 1 ] && [[ $IPREFIX = *-- ]] && [[ $PREFIX = *--* ]]; then - _arch_namespace_versions "${ARCHCMD}" $(($1 - 1)) - fi -} - -(( $+functions[_arch_namespace_versions] )) || -_arch_namespace_versions () { - local ARCHCMD="$1" - shift - local suffix expl - if [ $1 -gt 1 ]; then - suffix=(-q -S --) - fi - if [[ $IPREFIX != *--*-- ]] || [[ $IPREFIX != */*--*-- ]]; then - compset -P 1 '*--' - local branch=${IPREFIX%--} - _description -V versions expl "${library:-}versions" - compadd $suffix "$expl[@]" \ - ${${(@)$($ARCHCMD ${library:-}versions $branch)}##*--} - fi - if [ $1 -gt 1 ] && [[ $IPREFIX = *--*-- ]] && ([[ $IPREFIX = */*--*-- ]] \ - || [[ $PREFIX != */* ]]) && [[ $PREFIX = *--* ]]; then - _arch_namespace_revisions "${ARCHCMD}" - fi -} - -(( $+functions[_arch_namespace_revisions] )) || -_arch_namespace_revisions () { - local ARCHCMD="$1" - local expl - if [[ $IPREFIX != *--*--*-- ]] || [[ $IPREFIX != */*--*--*-- ]]; then - compset -P 1 '*--' - local version=${IPREFIX%--} - _description -V revisions expl "${library:-}revisions" - local completions c - completions=( - ${${(@)$($ARCHCMD ${library:-}revisions $version)}##*--} - ) - (( exclude_library_revisions )) && \ - foreach c ($($ARCHCMD library-revisions $version)); do completions[(r)$c]=(); done - compadd "$expl[@]" -a completions - fi -} - -_arch_namespace "$@" diff --git a/Completion/Unix/Type/_date_formats b/Completion/Unix/Type/_date_formats index 0527d706c..2b7139492 100644 --- a/Completion/Unix/Type/_date_formats +++ b/Completion/Unix/Type/_date_formats @@ -107,6 +107,6 @@ done _describe -t date-format-specifier 'date format specifier' specs \ -p "${(Q)PREFIX:-%}" -S '' && ret=0 -[[ $1 == zsh ]] && _message -e date-format-precision 'precision for %%. (1-9)' +[[ $1 == zsh ]] && _message -e date-format-precision 'precision for %. (1-9)' return ret diff --git a/Completion/Unix/Type/_diff_options b/Completion/Unix/Type/_diff_options index 03ea1d7fe..ba3f02c8f 100644 --- a/Completion/Unix/Type/_diff_options +++ b/Completion/Unix/Type/_diff_options @@ -26,7 +26,7 @@ _diff_palette() { } if _pick_variant -r variant -c $cmd gnu=GNU unix -v || - [[ $OSTYPE = (freebsd<12->|darwin<22->).* ]]; then + [[ $OSTYPE = (freebsd<12->.|darwin<22->.|netbsd)* ]]; then (( $#words > 2 )) && ign='!' # output formats diff --git a/Completion/Unix/Type/_urls b/Completion/Unix/Type/_urls index f9cdd58cd..75b6dfbd2 100644 --- a/Completion/Unix/Type/_urls +++ b/Completion/Unix/Type/_urls @@ -37,7 +37,7 @@ # E.g.: # zstyle ':completion:*:urls' local www /usr/local/apache/htdocs public_html -local ipre scheme host user uhosts ret=1 expl match glob suf +local ipre scheme host user uhosts urls ret=1 expl match glob suf local localhttp zstyle -a ":completion:${curcontext}:urls" local localhttp local localhttp_servername="$localhttp[1]" diff --git a/Completion/X/Command/_acroread b/Completion/X/Command/_acroread deleted file mode 100644 index 4a5cb5cb8..000000000 --- a/Completion/X/Command/_acroread +++ /dev/null @@ -1,119 +0,0 @@ -#compdef acroread - -local curcontext="$curcontext" state line -local cmdfile - -if [[ -z $_acroread_version ]]; then - _acroread_version="$($words[1] -version 2>/dev/null)" -fi - -if [[ -z $_acroread_version ]]; then - if [[ $words[1] = */* && -x $words[1] ]]; then - cmdfile=$words[1] - elif [[ -x $commands[$words[1]] ]]; then - cmdfile=$commands[$words[1]] - fi - - # Try extracting the version number directly from the executable. - # (This will fail if the executable is a wrapper script for acroread.) - _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=} - - if [[ -z $_acroread_version ]]; then - local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]} - if [[ -r $acropath ]]; then - _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=} - fi - fi -fi - -if [[ $_acroread_version == [789].* ]]; then - local -a extra_args - extra_args=() - if [[ $_acroread_version == [89].* ]]; then - extra_args+=(-man '-installCertificate:server ip::server port') - fi - if [[ $_acroread_version == 9.* ]]; then - extra_args+=(-openInNewInstance) - fi - _arguments -C \ - "${extra_args[@]}" \ - '--display=:X display:_x_display' \ - '--screen=:X screen (overrides the screen part of DISPLAY)' \ - --sync \ - '-geometry:[<width>x<height>][{+|-}<x offset>{+|-}<y offset>]' \ - -help \ - -iconic \ - '*-setenv:<var>=<value>' \ - -tempFile \ - '-tempFileTitle:title' \ - -openInNewWindow \ - -version \ - '-visual:X visual:_x_visual' \ - '-toPostScript:*::PostScript conversion options:= ->tops' \ - '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return - - [[ -n "$state" ]] && _arguments \ - '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \ - -binary \ - '-start:integer' \ - '-end:integer' \ - -optimizeForSpeed \ - -landscape \ - -reverse \ - '(-even)-odd' \ - '(-odd)-even' \ - -commentsOff \ - -annotsOff \ - -stampsOff \ - -markupsOn \ - '(-level3)-level2' \ - '(-level2)-level3' \ - -printerhalftones \ - -saveVM \ - '-scale:integer' \ - -shrink \ - -expand \ - '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \ - '-transQuality:transparency flattening level:(1 2 3 4 5)' \ - '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return -else - _x_arguments -C \ - -help \ - -helpall \ - \*-iconic \ - \*+iconic \ - '-name:application name:_x_name' \ - '*-setenv:<var>=<value>' \ - -tempFile \ - '-tempFileTitle:title' \ - '(+useFrontEndProgram)-useFrontEndProgram' \ - '(-useFrontEndProgram)+useFrontEndProgram' \ - '-visual:X visual:_x_visual' \ - '-xrm:X resource specification:_x_resource' \ - '-toPostScript:*::PostScript conversion options:= ->tops' \ - '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return - - [[ -n "$state" ]] && _arguments \ - '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \ - -binary \ - '-start:integer' \ - '-end:integer' \ - -optimizeForSpeed \ - -landscape \ - -reverse \ - '(-even)-odd' \ - '(-odd)-even' \ - -commentsOff \ - '(-level2 -level3)-level1' \ - '(-level1 -level3)-level2' \ - '(-level1 -level2)-level3' \ - -printerhalftones \ - -saveVM \ - '-scale:integer' \ - -shrink \ - '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \ - '-transQuality:transparency flattening level:(1 2 3 4 5)' \ - '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return -fi - -return 1 diff --git a/Completion/X/Command/_chromium b/Completion/X/Command/_chromium new file mode 100644 index 000000000..be5e9bab3 --- /dev/null +++ b/Completion/X/Command/_chromium @@ -0,0 +1,192 @@ +#compdef chrome chromium google-chrome brave cromite helium helium-browser microsoft-edge opera opera-gx ungoogled-chromium vivaldi -P google-chrome-* brave-* microsoft-edge-* opera-* vivaldi-* + +(( $+functions[_chromium_urls] )) || +_chromium_urls() { + # chromium doesn't allow you to open about: or chrome:// urls from the cli, + # except for about:blank + _alternative \ + 'files: :_files' \ + 'urls: :_urls' \ + 'urls-about:about page:(about\:blank)' +} + +# complete possible data directories (and, without -0, generic paths). as with +# firefox, we could try harder to look for the *exact* directory we need, but +# this is probably fine +# -0 <name> instead of completing, insert directories into array <name> +# -a use all possible directories instead of service-specific ones +(( $+functions[_chromium_data_dirs] )) || +_chromium_data_dirs() { + local cfg=${XDG_CONFIG_HOME:-$HOME/.config} + local -a ca_opts expl dirs + local -A opth + + zparseopts -A opth -D -F - \ + {M+:,P+:,q+:,r+:,R+:,S+:}=ca_opts 1 2 J: o: O: V: x: X: \ + 0: a \ + || return + + local -a chrome_dirs=( + $cfg/google-chrome{,-beta,-unstable,-canary} + $HOME/.var/app/com.google.Chrome/config/google-chrome + "$HOME/Library/Application Support/Google/Chrome"{,\ Beta,\ Dev,\ Canary} + ) + local -a chromium_dirs=( + $cfg/chromium + $HOME/snap/chromium/current/.config/chromium + $HOME/.var/app/org.chromium.Chromium/config/chromium + "$HOME/Library/Application Support/Chromium" + ) + local -a brave_dirs=( + $cfg/brave{,-beta,-development,-unstable} + $cfg/BraveSoftware/Brave-Browser{,-Beta,-Dev,-Development,-Nightly} + $HOME/.var/app/com.brave.Browser/config/BraveSoftware/Brave-Browser + "$HOME/Library/Application Support/BraveSoftware/Brave-Browser"{,-Beta,-Dev,-Development,-Nightly} + ) + local -a cromite_dirs=( + $cfg/cromite + ) + local -a helium_dirs=( + $cfg/net.imput.helium + "$HOME/Library/Application Support/net.imput.helium" + ) + local -a edge_dirs=( + $cfg/microsoft-edge{,-beta,-dev,-canary} + "$HOME/Library/Application Support/Microsoft Edge"{,\ Beta,\ Dev,\ Canary} + ) + local -a opera_gx_dirs=( + $cfg/opera-gx + $HOME/.var/app/com.opera.opera-gx/config/opera + "$HOME/Library/Application Support/com.operasoftware.OperaGX" + ) + local -a opera_dirs=( + $cfg/opera{,-beta,-developer} + $HOME/.var/app/com.opera.Opera/config/opera + "$HOME/Library/Application Support/com.operasoftware.Opera" + ) + local -a vivaldi_dirs=( + $cfg/vivaldi{,-snapshot} + $HOME/.var/app/com.vivaldi.Vivaldi/config/vivaldi + "$HOME/Library/Application Support/Vivaldi"{,\ Snapshot} + ) + + if (( $+opth[-a] )); then + dirs=( + $chrome_dirs $chromium_dirs $brave_dirs $cromite_dirs + $helium_dirs $edge_dirs $opera_gx_dirs $opera_dirs $vivaldi_dirs + ) + + else + case $service in + google*|chrome*) dirs=( $chrome_dirs ) ;; + chromium*|ungoogled*) dirs=( $chromium_dirs ) ;; + brave*) dirs=( $brave_dirs ) ;; + cromite*) dirs=( $cromite_dirs ) ;; + helium*) dirs=( $helium_dirs ) ;; + microsoft*|edge*) dirs=( $edge_dirs ) ;; + opera-gx*) dirs=( $opera_gx_dirs ) ;; + opera*) dirs=( $opera_dirs ) ;; + vivaldi*) dirs=( $vivaldi_dirs ) ;; + esac + fi + + dirs=( $^dirs/'Local State'(#qN.-) ) + dirs=( ${dirs:h} ) + dirs=( ${(u)dirs} ) + + (( $+opth[-0] )) && { + trap "${opth[-0]}=( ${(j< >)${(@q+)dirs}} )" EXIT + return $(( ! $#dirs )) + } + + dirs=( ${dirs//:/\:} ) + + _describe -t data-directories 'user data directory' \ + dirs "${(@)ca_opts}" && ret=0 + _wanted files expl 'user data directory' \ + _files -/ "${(@)ca_opts}" && ret=0 + + return ret +} + +(( $+functions[_chromium_profile_dirs] )) || +_chromium_profile_dirs() { + local -a ca_opts cli_dirs dirs profiles disp inst + local -A opth + + zparseopts -A opth -D -F - \ + {1,2,J+:,M+:,o+:,O+:,P+:,q+,r+:,R+:,S+:,V+:,x+:,X+:}=ca_opts \ + a \ + || return + + cli_dirs=( ${${(MQ)words:#--user-data-dir=*}#*=} ) + + if (( $+opth[-a] )); then + _chromium_data_dirs -a0dirs + dirs+=( $cli_dirs ) + else + dirs=( $cli_dirs ) + (( $#dirs )) || _chromium_data_dirs -0dirs + fi + + # the name given to a profile by the user has no relationship at all to the + # profile's directory name. to make the results meaningful, we'll try to parse + # the dirs + names out of the config + (( $+commands[python3] )) && + profiles=( ${(f)"$( + python3 -c 'if 1: + import json, re, sys + for st in sys.argv[1:]: + with open(st) as f: + ps = json.load(f).get("profile", {}).get("info_cache", {}) + for k, v in ps.items(): + dir = k + nam = v.get("name", "") + print(f"{nam}\0{dir}") + ' $^dirs/'Local State'(#qN.-) + )"} ) + + (( $#profiles )) || profiles=( $^dirs/(Default|Profile\ *)(#qN/-:t) ) + + disp=( ${${profiles//:/\\:}/$'\0'/:} ) + inst=( ${profiles#*$'\0'} ) + + _describe -t profiles 'profile directory' disp inst "${(@)ca_opts}" +} + +# chromium has hundreds of options, largely undocumented and apparently +# unstable. we make no attempt to support them all. these are the ones i found +# to be most commonly referenced +local -a args=( + + '(excl)' + '(- : *)--version[display version information]' + + + '(open)' + '--incognito[open new Incognito window or tab]' + '--new-tab[open new tab]' + '--new-window[open new window]' + + + '(proxy)' + '--proxy-server=-[specify proxy server]:proxy server:{ + compset -P "(http|socks|socks4|socks5)\://" + _hosts "${(@)expl}" + }' + '--no-proxy-server[disable proxy server]' + '--proxy-auto-detect[auto-detect proxy configuration]' + # @todo this has to be http://, https://, or data: + '--proxy-pac-url=-[specify proxy auto-configuration URL]:PAC-file URL:_urls' + + + misc + '(*)--app=-[open specified URL in app mode]: :_chromium_urls' + '--password-store=-[specify password storage back-end]:password store:( + basic gnome gnome-libsecret kwallet kwallet5 kwallet6 + )' + '--user-data-dir=-[specify user data directory]: :_chromium_data_dirs -a' + '--profile-directory=-[specify profile directory]: :_chromium_profile_dirs' + '(--app)*: :_chromium_urls' +) + +[[ $service == (microsoft|edge)* ]] && +args=( ${${args//incognito/inprivate}//Incognito/InPrivate} ) + +_arguments -s -S : $args diff --git a/Completion/X/Command/_dcop b/Completion/X/Command/_dcop deleted file mode 100644 index a0329e110..000000000 --- a/Completion/X/Command/_dcop +++ /dev/null @@ -1,119 +0,0 @@ -#compdef dcop dcopstart dcopfind dcopref dcopclient dcopobject - -local curcontext="$curcontext" desc vals arg base max=0 ret=1 -local app obj fun -local -a state line expl - -case $service in - dcop(client|object)) - state=( dcopref ) - max=2 - ;; - dcopref) max=3 ;; - dcopstart) - if (( CURRENT > 2 )); then - _urls && return - fi - ;; - dcopfind) - local cmd=$words[1] - _arguments -C \ - '-a[print application id instead of DCOPRef]' \ - '-l[if object not found, run dcopstart and retry]' \ - '*::args:->args' && ret=0 - unset state - words=( $cmd $words ) - (( CURRENT++ )) - ;; -esac - -if (( max && CURRENT > max )); then - _message 'no more arguments' - return 1 -fi - -if [[ -z "$state" ]]; then - state=(application object function) - [[ $words[2] = DCOPRef* && CURRENT -ne 2 ]] - base=$? - state=( ${state[CURRENT-base]:-arg} ) - - [[ $state[1] = application && $service = dcop(|find) ]] && state+=( dcopref ) -fi - -while (( $#state )); do - unset app obj fun - - if [[ $words[2] = (#b)DCOPRef*\(([^,]#)((#e)|,)([^\\\)]#)(*) ]]; then - if [[ -n $match[2] ]]; then - app=$match[1] - if [[ -n $match[4] ]]; then - obj=$match[3] - [[ -n $words[3] && CURRENT -gt 3 ]] && fun=$words[3] - fi - fi - else - case $CURRENT in - <5->) fun="$words[4]" ;& - 4) obj="$words[3]" ;& - 3) app="$words[2]" ;; - esac - fi - vals=( ${(f)"$(_call_program dcop-$state[1]s ${(M)words[1]##*/}dcop $app $obj 2>/dev/null)"} ) - - case "$state[1]" in - application|object) - [[ -n ${(M)vals:#*\(default\)} ]] && vals+=( default ) - _wanted dcop-$state[1]s expl $state[1] compadd "$@" - ${vals% \(default\)} && ret=0 - ;; - - function) - [[ $service = dcopfind ]] && vals=( ${(M)vals:#bool *} ) - _wanted dcop-$state[1]s expl $state[1] compadd "$@" - ${${vals#* }%\(*} && ret=0 - ;; - - arg) - arg=${${${(M)vals:#*$fun\(*}#*\(}%\)*}, - arg=${${(s.,.)arg}[CURRENT-base-3]} - if [[ -n $arg ]]; then - if [[ $arg = (Q(|C)String|*int )* || $arg != *\ * ]]; then - # don't mention the argument's type - desc="${arg##* }" - else - desc="${arg##* } (${arg% *})" - fi - case $arg in - bool*) _wanted argument expl "$desc" compadd true false && return ;; - (#i)*(file|path|dir)*) _wanted argument expl "$desc" _files && return ;; - (#i)*url*) _wanted argument expl "$desc" _urls && return ;; - *) _message -e argument "$desc" ;; - esac - else - _message 'no more arguments' - fi - ;; - - dcopref) - if ! compset -P '*\('; then - _wanted dcoprefs expl 'dcop ref' compadd -S '' 'DCOPRef(' && ret=0 - elif compset -P '*,'; then - if compset -S '(|\\)\)*'; then - set -- -S '' "$@" - else - set -- "$@" -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " - fi - state+=( object ) - else - if compset -S ',*'; then - set -- "$@" -S '' - else - set -- "$@" -S , - fi - state+=( application ) - fi - ;; - esac - shift state -done - -return ret diff --git a/Completion/X/Command/_firefox b/Completion/X/Command/_firefox new file mode 100644 index 000000000..c8a9f0ec0 --- /dev/null +++ b/Completion/X/Command/_firefox @@ -0,0 +1,328 @@ +#compdef firefox mozilla-firefox=firefox floorp librewolf mullvad-browser mullvadbrowser palemoon tor-browser torbrowser waterfox zen zen-browser -P firefox* + +(( $+functions[_firefox_urls] )) || +_firefox_urls() { + if compset -P about:; then + _describe -t urls-about 'about page' '( + about addons buildconfig cache certificate checkerboard compat + config crashes credits debugging downloads firefoxview home + keyboard license logging logins loginsimportreport logo memory + mozilla networking newtab policies preferences privatebrowsing + processes profiles profiling protections rights robots + serviceworkers studies support sync-log telemetry translations + unloads url-classifier webauthn webrtc welcome + )' + elif compset -P mailto:; then + _email_addresses -c + else + _alternative 'files: :_files' 'urls: :_urls' + fi +} + +# complete possible config directories. we could try harder to look for the +# *exact* directory we need, but this should work in most cases +# -0 <name> instead of completing, insert directories into array <name> +# -a use all possible directories instead of service-specific ones +(( $+functions[_firefox_config_dirs] )) || +_firefox_config_dirs() { + local cfg=${XDG_CONFIG_HOME:-$HOME/.config} + local -a ca_opts dirs + local -A opth + + zparseopts -A opth -D -F - \ + {1,2,J+:,M+:,o+:,O+:,P+:,q+,r+:,R+:,S+:,V+:,x+:,X+:}=ca_opts \ + 0: a \ + || return + + local -a firefox_dirs=( + $cfg/mozilla/firefox + $HOME/.mozilla/firefox + $HOME/.var/app/org.mozilla.firefox/.mozilla/firefox + $HOME/snap/firefox/common/.mozilla/firefox + "$HOME/Library/Application Support/Firefox" + ) + local -a floorp_dirs=( + $cfg/floorp/floorp # unverified + $HOME/.floorp + $HOME/.var/app/one.ablaze.floorp/.floorp + "$HOME/Library/Application Support/Floorp" + ) + local -a librewolf_dirs=( + $cfg/librewolf/librewolf + $HOME/.librewolf + $HOME/.var/app/io.gitlab.librewolf-community/.librewolf + "$HOME/Library/Application Support/librewolf" + ) + local -a mullvad_dirs=( + # based on tor browser, probably works similar + $HOME/.var/app/net.mullvad.MullvadBrowser/.mullvad-browser/.mullvad/mullvadbrowser + "$HOME/Library/Application Support/MullvadBrowser" + ) + local -a palemoon_dirs=( + "$HOME/.moonchild productions/pale moon" + "$HOME/Library/Application Support/Pale Moon" + ) + local -a tor_dirs=( + # i think on linux the ~/.mozilla equivalent normally lives inside the same + # directory the browser is installed to? but i couldn't verify + "$HOME/Library/Application Support/TorBrowser-Data/Browser" + ) + local -a waterfox_dirs=( + $cfg/waterfox/waterfox # unverified + $HOME/.waterfox + $HOME/.var/app/net.waterfox.waterfox/.waterfox + "$HOME/Library/Application Support/Waterfox" + ) + local -a zen_dirs=( + $cfg/zen/zen + $HOME/.zen + $HOME/.var/app/app.zen_browser.zen/.zen + $HOME/.var/app/io.github.zen_browser.zen/.zen + "$HOME/Library/Application Support/zen" + ) + + if (( $+opth[-a] )); then + dirs=( + $firefox_dirs $floorp_dirs $librewolf_dirs $mullvad_dirs + $palemoon_dirs $tor_dirs $waterfox_dirs $zen_dirs + ) + else + case $service in + firefox*) dirs=( $firefox_dirs ) ;; + floorp*) dirs=( $floorp_dirs ) ;; + librewolf*) dirs=( $librewolf_dirs ) ;; + mullvad*) dirs=( $mullvad_dirs ) ;; + palemoon*) dirs=( $palemoon_dirs ) ;; + tor*) dirs=( $tor_dirs ) ;; + waterfox*) dirs=( $waterfox_dirs ) ;; + zen*) dirs=( $zen_dirs ) ;; + esac + fi + + dirs=( $^dirs/profiles.ini(#qN-.) ) + dirs=( ${dirs:h} ) + dirs=( ${(u)dirs} ) + + (( $+opth[-0] )) && { + trap "${opth[-0]}=( ${(j< >)${(@q+)dirs}} )" EXIT + return $(( ! $#dirs )) + } + + dirs=( ${dirs//:/\:} ) + + _describe -t profile-directories 'profile directory' dirs "${(@)ca_opts}" +} + +# complete old-style ToolkitProfileService profiles +# -0 <name> instead of completing, insert NUL-separated name/path pairs into +# array <name> +# -a see _firefox_profile_dirs +(( $+functions[_firefox_toolkit_profiles] )) || +_firefox_toolkit_profiles() { + local dir + local -a ca_opts tmp dirs profiles + local -A opth + + zparseopts -A opth -D -F - \ + {1,2,J+:,M+:,o+:,O+:,P+:,q+,r+:,R+:,S+:,V+:,x+:,X+:}=ca_opts \ + 0: a \ + || return + + _firefox_config_dirs ${opth[-a]+-a} -0dirs + + # if we don't care about the paths we can use a simpler method + if (( ! $+opth[-0] )); then + for dir in $dirs; do + tmp=( ${(f)"$( < $dir/profiles.ini )"} ) + tmp=( ${(M)tmp:#[[:space:]]#Name=*} ) + tmp=( ${tmp#*=} ) + profiles+=( $tmp ) + done + + elif (( $+commands[python3] )); then + profiles=( ${(f)"$( + python3 -c 'if 1: + import configparser, re, sys + for dir in sys.argv[1:]: + cfg = configparser.ConfigParser() + cfg.read(f"{dir}/profiles.ini") + for sct in cfg.sections(): + if not sct.startswith("Profile") or not cfg[sct].get("Name"): + continue + name = cfg[sct].get("Name") + path = cfg[sct].get("Path") + # ignore Windows path + if "/" not in path and "\\" in path: + continue + if cfg[sct].get("IsRelative") == "1": + path = f"{dir}/{path}" + print(f"{name}\0{path}") + ' $dirs + )"} ) + fi + + (( $+opth[-0] )) && { + trap "${opth[-0]}=( ${(j< >)${(@q+)profiles}} )" EXIT + return $(( ! $#profiles )) + } + + profiles=( ${profiles%%$'\0'*} ) + profiles=( ${profiles//:/\:} ) + + _describe -t toolkit-profiles 'toolkit profile' profiles "${(@)ca_opts}" +} + +# complete new-style SelectableProfileService profiles +# -0 <name> see _firefox_toolkit_profiles +# -a see _firefox_toolkit_profiles +(( $+functions[_firefox_selectable_profiles] )) || +_firefox_selectable_profiles() { + local dir db + local -a ca_opts tmp dirs profiles + local -A opth + + zparseopts -A opth -D -F - \ + {1,2,J+:,M+:,o+:,O+:,P+:,q+,r+:,R+:,S+:,V+:,x+:,X+:}=ca_opts \ + 0: a \ + || return + + _firefox_config_dirs ${opth[-a]+-a} -0dirs + + (( $+commands[sqlite3] )) && + for dir in $dirs; do + # apparently firefox sometimes re-creates these databases, so there can be + # more than one in the directory. the active one is stored in preferences, + # but we'll just assume it's the newest + for db in "$dir/Profile Groups/"*.sqlite(#qN-.om[1]); do + tmp+=( ${${(f)"$( + sqlite3 -separator $'\x1f' $db 'SELECT name, path FROM Profiles;' + )"}//$'\x1f'/$'\0'} ) + for 1 2 in "${(@0)tmp}"; do + [[ $2 != */* && $2 == *\\* ]] && continue # ignore Windows path + [[ $2 == /* ]] || 2=${db:h:h}/$2 # make absolute + profiles+=( $1$'\0'$2 ) + done + done + done + + (( $+opth[-0] )) && { + trap "${opth[-0]}=( ${(j< >)${(@q+)profiles}} )" EXIT + return $(( ! $#profiles )) + } + + profiles=( ${profiles%%$'\0'*} ) + profiles=( ${profiles//:/\:} ) + + _describe -t selectable-profiles 'selectable profile' profiles "${(@)ca_opts}" +} + +# at time of writing, there's no specific way to use/manage the newer +# SelectableProfileService profiles from the cli. however, it's possible to load +# one by giving its path to --profile, which is a common work-around. to make +# this more convenient, we offer these profile paths in addition to the generic +# path completion +# -a see _firefox_toolkit_profiles +(( $+functions[_firefox_profile_dirs] )) || +_firefox_profile_dirs() { + local ret=1 + local -a ca_opts expl profiles disp inst + + zparseopts -A opth -D -F - \ + {M+:,P+:,q+:,r+:,R+:,S+:}=ca_opts 1 2 J: o: O: V: x: X: \ + a \ + || return + + _firefox_toolkit_profiles ${opth[-a]+-a} -0profiles && { + disp=( ${${profiles//:/\\:}/$'\0'/:} ) + inst=( ${profiles#*$'\0'} ) + _describe -t toolkit-profiles 'toolkit profile directory' \ + disp inst "${(@)ca_opts}" && ret=0 + } + + _firefox_selectable_profiles ${opth[-a]+-a} -0profiles && { + disp=( ${${profiles//:/\\:}/$'\0'/:} ) + inst=( ${profiles#*$'\0'} ) + _describe -t selectable-profiles 'selectable profile directory' \ + disp inst "${(@)ca_opts}" && ret=0 + } + + _wanted files expl 'profile directory' _files -/ "${(@)ca_opts}" && ret=0 + + return ret +} + +local x +local -a match mbegin mend tmp args + +tmp=( + + '(excl)' + '(- : *)'{-h,--help}'[display help information]' + '(- : *)'{-v,--version}'[display version information]' + '(- : *)--full-version[display version and build information]' + + + '(start)' + # not in help output for some reason + '--CreateProfile=[create new profile with specified name]:profile name' + '-P=[start with profile manager or specified profile]:: :_firefox_toolkit_profiles' + '--profile=[start with profile at specified path]: :_firefox_profile_dirs -a' + '--migration[start with migration wizard]' + '--ProfileManager[start with profile manager]' + + + misc + '--g-fatal-warnings[make all warnings fatal]' + '--origin-to-force-quic-on=[force to use QUIC for specified origin]: :_urls' + '--new-instance[open new instance instead of new window]' + '--safe-mode[disable extensions and themes]' + '--allow-downgrade[allow downgrading profile]' + '--MOZ_LOG=[specify log modules]:log modules' + '--MOZ_LOG_FILE=[specify log file]:log file:_files' + '--headless[run without GUI]' + '--browser[open browser window]' + '*--new-window=[open new window (specify URL)]:: :_firefox_urls' + '*--new-tab=[open new tab (specify URL)]:: :_firefox_urls' + '*--private-window=[open new private window (specify URL)]:: :_firefox_urls' + '--preferences[open about\:preferences]' + '--screenshot=[save screenshot (specify path)]::screenshot path:_files' + '--window-size=[specify width and height of screenshot (with --screenshot)]:screenshot window size (width[,height])' + '--search=[search for specified term with default search engine]:search term' + '--setDefaultBrowser[set as default browser]' + '--first-startup[run post-install actions before opening new window]' + '--kiosk[start in kiosk mode]' + '--kiosk-monitor=[place kiosk browser window on specified monitor]: :_numbers "monitor number"' + '--disable-pinch[disable touch-screen and touch-pad pinch gestures]' + '--jsconsole[open Browser Console]' + '--devtools[open DevTools on initial load]' + '--jsdebugger=[open Browser Toolbox (specify Firefox path)]::Firefox path:_files' + '--wait-for-jsdebugger[spin event loop until JS debugger connects (with --jsdebugger)]' + '--start-debugger-server=[start devtools server at specified port or socket path]: :{ + compset -P ws\: + _alternative \ + "ports\: \:_numbers -l1 -m65535 \"port number\"" \ + "files\:socket path\:_files -g \"(#q-=)\"" + }' + '--marionette[enable remote control server]' + '--remote-debugging-port=[start Firefox Remote Agent (specify port)]:: :\ + _numbers -l1 -m65535 -d9222 "port number" + ' + '--remote-allow-hosts=[specify Host header values to allow for incoming requests (with --remote-debugging-port)]:Host header value:\ + _sequence -s, _hosts + ' + '--remote-allow-origins=[specify Origin header values to allow for incoming requests (with --remote-debugging-port)]:Origin header value:\ + _sequence -s, _urls + ' + "--remote-allow-system-access[enable privileged access to application's parent process (with --remote-debugging-port)]" + + '*: :_firefox_urls' +) + +# options support both single and double hyphens. recognise the alternate forms +for x in $tmp; do + args+=( $x ) + [[ $x == (#b)(|\(*\))(|\*)(--|-)([^-]*) ]] && { + [[ $match[3] == - ]] && match[3]=-- || match[3]=- + args+=( \!${(j<>)match} ) + } +done + +# options are also case-insensitive +_arguments -s -S -M 'm:{A-Za-z}={a-zA-Z} r:|[_-]=* r:|=*' : $args diff --git a/Completion/X/Command/_mozilla b/Completion/X/Command/_mozilla deleted file mode 100644 index 0be25b8d3..000000000 --- a/Completion/X/Command/_mozilla +++ /dev/null @@ -1,150 +0,0 @@ -#compdef mozilla mozilla-firefox mozilla-xremote-client firefox iceweasel=firefox - -local curcontext="$curcontext" state line expl ret=1 suf -typeset -A opt_args - -local popts="-installer -CreateProfile -P -ProfileWizard -ProfileManager -SelectProfile" -local -a mozopts - -if [[ $service = *remote* ]]; then - state=remote -else - if [[ $service = *firefox* ]]; then - mozopts=( - '-browser[open browser window]' \ - '-console[start with debugging console]' \ - '-h[output help message]' \ - '-help[output help message]' \ - '-inspector[start with DOM Inspector]:URL to inspect:->location' \ - '-install-global-extension[install an extension]:extension to install:_files' \ - '-new-window[load URL in new window]:URL to load:->location' \ - '-new-tab[load URL in new tab]:URL to load:->location' \ - '-no-remote[run with multiple profiles]' \ - '-profile[specify profile file]:profile file:_files' \ - '-v[show version]' \ - '-version[show version]' \ - '-safe-mode[disable extensions and themes for this session]' - ) - else - mozopts=( - "($popts)-installer[start with 4.x migration window]" - "($popts)-ProfileWizard[start with profile wizard]" - "($popts)-SelectProfile[start with profile selection dialog]" - '-splash[enable splash screen]' - '-chat[start with IRC client]' - '-news[start with news]' - '-venkman[start with JavaScript debugger]' - '-terminal[start with command line terminal]' - '-mail[start with mail]' - '-compose[start with messenger compose]:URL:_urls' - ) - fi - _x_arguments -C $mozopts \ - '-height[height of startup window]:height' \ - '(-)'{-h,-help}'[show usage message]' \ - "($popts)-CreateProfile:profile" \ - '-width[width of startup window]:width' \ - '(-)'{-v,-version}'[show the version number and build date]' \ - "($popts)-P[start with profile]:profile:->profile" \ - "($popts)-ProfileManager[start with profile manager]" \ - '-UILocale:locale' \ - '-contentLocale:locale' \ - '-remote[execute a command in an existing Mozilla]:remote command:->remote' \ - '-jsconsole[start with JavaScript Console]' \ - '-edit[start with editor]:URL:_urls' \ - '-chrome[load the specified chrome]:URL:_urls' \ - '*:location:->urls' && ret=0 -fi - -[[ "$state" = "urls" ]] && - _files "$@" && return 0 - -# Handle mozilla remote commands -if [[ "$state" = "remote" ]]; then - local -a remote_commands - remote_commands=(openURL openFile saveAs mailto addBookmark ping) - - compset -P '*\(' - if compset -S '(|\\)\)*'; then - set - -S "" "$@" - else - set - -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " "$@" - fi - case $IPREFIX in - openURL*) - if compset -P "*,"; then - _wanted option expl 'option' compadd "$@" new-tab new-window && ret=0 - else - compset -S ',*' - state=urls - fi - ;; - addBookmark*) state=urls;; - openFile*) _files "$@" -W ~;; - saveAs*) - if compset -P "*,"; then - _wanted types expl 'data type' \ - compadd "$@" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && ret=0 - else - compset -S ",*" || suf="," - _files -qS "$suf" -W ~ && ret=0 - fi - ;; - mailto*) - _email_addresses -s, -c && ret=0 - ;; - *) - compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}" - _wanted commands expl 'remote command' \ - compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \ - remote_commands && ret=0 - ;; - esac -fi - -if [[ "$state" = "urls" ]]; then - # Complete mozilla urls - if compset -P about: ; then - _wanted values expl 'about what' \ - compadd "$@" authors blank cache document fonts global hype image-cache \ - license logo memory-cache mozilla plugins && ret=0 - elif compset -P news: ; then - _newsgroups "$@" && ret=0 - elif compset -P mailto: ; then - _email_addresses -c && ret=0 - else - _tags prefixes - while _tags; do - while _next_label prefixes expl 'URL prefix' "$@"; do - _urls "$expl[@]" && ret=0 - compset -S '[^:]*' - compadd -S '' "$expl[@]" about: news: mailto: mocha: javascript: && ret=0 - done - (( ret )) || return 0 - done - fi -fi - -if [[ $state == "profile" ]]; then - if [[ $service == *firefox* ]]; then - local -a profiles text profiledir - case "$OSTYPE" in - darwin*) profiledir=~/"Library/Application Support/Firefox" ;; - *) profiledir=~/.mozilla/firefox/ ;; - esac - profiles=(${(f)"$(< ${profiledir}/profiles.ini)"}) - profiles=(${(M)${profiles}:#(\[Profile|(Path|Name)=)*}) - text=${(F)profiles} - profiles=(${(f)text//(#b)\[Profile([0-9]##)\] -Name=([^ -]##|) -Path=([^ -]##|)/$match[2]}) - profiles=(${profiles%:}) - compadd $profiles - else - compadd ~/.mozilla/*/*.slt(\:h\:t) - fi -fi - -return ret diff --git a/Completion/X/Command/_mplayer b/Completion/X/Command/_mplayer index 1f99a1789..e954744de 100644 --- a/Completion/X/Command/_mplayer +++ b/Completion/X/Command/_mplayer @@ -115,7 +115,7 @@ case "$state" in _tags files urls while _tags; do _requested files expl 'media file' _files -g \ - "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4a|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && ret=0 + "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4a|m4b|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && ret=0 if _requested urls; then while _next_label urls expl URL; do _urls "$expl[@]" && ret=0 diff --git a/Completion/X/Command/_netscape b/Completion/X/Command/_netscape deleted file mode 100644 index 78b2da649..000000000 --- a/Completion/X/Command/_netscape +++ /dev/null @@ -1,93 +0,0 @@ -#compdef netscape - -local curcontext="$curcontext" state line expl ret=1 suf files -typeset -A opt_args - -_x_arguments -C \ - '-xrm:resource:_x_resource' \ - '-help[show usage message]' \ - '-version[show the version number and build date]' \ - '-visual[use a specific server visual]:visual:_x_visual -b' \ - '-install[install a private colormap]' \ - '-no-install[use the default colormap]' \ - '-ncols[max no. of colors to allocate for images]:n:' \ - '-mono[force 1-bit-deep image display]' \ - '-iconic[start up iconified]' \ - '-remote[execute a command in an existing Netscape]:remote command:->remote' \ - '-id[id of X window to send remote commands to]:window-id:' \ - '-raise[raise window following remote command]' \ - "-noraise[don't raise window following remote command]" \ - '-nethelp[show nethelp]' \ - -{dont-force-window-stacking,no-about-splash} \ - -{,no-}{,irix-}session-management \ - -{done-save,ignore}-geometry-prefs \ - -{component-bar,composer,edit,messenger,mail,discussions,news} \ - '*:location:->urls' && ret=0 - -# Handle netscape remote commands -if [[ "$state" = "remote" ]]; then - local -a remote_commands - remote_commands=(openURL openFile saveAs mailto addBookmark) - - compset -P '*\(' - if compset -S '(|\\)\)*'; then - set - -S "" "$@" - else - set - -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " "$@" - fi - case $IPREFIX in - openURL*|addBookmark*) state=urls;; - openFile*) _files "$@" -W ~;; - saveAs*) - if compset -P "*,"; then - _wanted types expl 'data type' \ - compadd "$@" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && ret=0 - else - compset -S ",*" || suf="," - _files -qS "$suf" -W ~ && ret=0 - fi - ;; - mailto*) - _email_addresses -s, -c && ret=0 - ;; - *) - compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}" - _wanted commands expl 'remote command' \ - compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \ - remote_commands && ret=0 - ;; - esac -fi - -if [[ "$state" = "urls" ]]; then - _tags files urls - while _tags; do - _requested files expl 'file' _files "$@" && files=yes ret=0 - if _requested urls; then - # Complete netscape urls - if compset -P about: ; then - _wanted values expl 'about what' \ - compadd "$@" authors blank cache document fonts global hype \ - image-cache license logo memory-cache mozilla plugins && ret=0 - elif compset -P news: ; then - _newsgroups "$@" && ret=0 - elif compset -P mailto: ; then - _email_addresses -c && ret=0 - else - _tags prefixes - while _tags; do - while _next_label prefixes expl 'URL prefix' "$@"; do - _urls "$expl[@]" && ret=0 - compset -S '[^:]*' - compadd -S '' "$expl[@]" about: news: mailto: mocha: javascript: && ret=0 - done - (( ret )) || return 0 - done - [[ -z "$files" ]] && _tags files - fi - fi - (( ret )) || return 0 - done -fi - -return ret diff --git a/Completion/X/Command/_papers b/Completion/X/Command/_papers new file mode 100644 index 000000000..1c6076728 --- /dev/null +++ b/Completion/X/Command/_papers @@ -0,0 +1,18 @@ +#compdef papers + +_arguments -s -S : \ + + '(help)' \ + '(- : *)--version[display version information]' \ + '(- : *)'{-h,--help}'[display help information]' \ + '(- : *)--help-all[display all help information]' \ + '(- : *)--help-gapplication[display help information for GApplication options]' \ + + '(mode)' \ + {-f,--fullscreen}'[run in fullscreen mode]' \ + {-s,--presentation}'[run in presentation mode]' \ + + '(page)' \ + {-p,--page-label=}'[specify page label of document to display]:page label:' \ + {-i,--page-index=}'[specify page number of document to display]:page index:' \ + {-n,--named-dest=}'[specify named destination to display]:named destination:' \ + + etc \ + '--gapplication-service[enter GApplication service mode]' \ + '*:document file:_files -g "*.(#i)(cb7|cbr|cbt|cbz|djv|djvu|pdf|tif|tiff)(-.)"' diff --git a/Completion/X/Command/_sioyek b/Completion/X/Command/_sioyek deleted file mode 100644 index d9b15a953..000000000 --- a/Completion/X/Command/_sioyek +++ /dev/null @@ -1,29 +0,0 @@ -#compdef sioyek - -_arguments -S \ - '--new-instance[create a new instance of sioyek when opening a file]' \ - '--instance-name[select a specific sioyek instance by name]:name: ' \ - '--new-window[open file in a new window within same instance]' \ - '--reuse-window[force reuse of current window]' \ - '--nofocus[do not bring instance to foreground]' \ - '--version[print sioyek version]' \ - '--page[which page to open]:page number: ' \ - '--focus-text[set a visual mark on line including text]:text: ' \ - '--focus-text-page[page to use for focus-text]:page number: ' \ - '--inverse-search[command to execute for inverse search]:command: ' \ - '--execute-command[command to execute on running instance]:command: ' \ - '--execute-command-data[optional data for execute-command]:data: ' \ - '--forward-search-file[forward search on file]:file:_files' \ - '--forward-search-line[forward search on line]:line: ' \ - '--forward-search-column[forward search on column]:column: ' \ - '--zoom[set zoom level]:zoom level: ' \ - '--xloc[set x position within page]:x-coordinate: ' \ - '--yloc[set y position within page]:y-coordinate: ' \ - '--window-id[apply command to specific window id]:window id: ' \ - '--shared-database-path[path for shared bookmarks/highlights]:database path:_files' \ - '--verbose[print extra information]' \ - '--wait-for-response[wait for command to finish before returning]' \ - '--no-auto-config[disable all config files except those next to executable]' \ - '(-h --help)'{-h,--help}'[display help information]' \ - '--help-all[display help including generic Qt options]' \ - '*:pdf file:_files -g "*.pdf(-.)"' diff --git a/Completion/X/Command/_xv b/Completion/X/Command/_xv index 513a953dc..1c35d3a2c 100644 --- a/Completion/X/Command/_xv +++ b/Completion/X/Command/_xv @@ -42,4 +42,4 @@ _x_arguments \ '-gsres:ghostscript resolution' \ '-gsgeom:ghostscript page size' \ '-DEBUG:debug level' \ - '*:picture file:_files -g \*.\(\#i\)\(png\|gif\|jpeg\|jpg\|tiff\|tif\|pbm\|pgm\|ppm\|xbm\|xpm\|ras\(\|t\)\|tga\|rle\|rgb\|bmp\|pcx\|fits\|pm\)\(-.\)' + '*:picture file:_files -g \*.\(\#i\)\(png\|gif\|jpeg\|jpg\|tiff\|tif\|pbm\|pgm\|ppm\|xbm\|xpm\|ras\(\|t\)\|tga\|rle\|rgb\|bmp\|pcx\|fits\|pm\|eps\)\(-.\)' diff --git a/Completion/Zsh/Command/_alias b/Completion/Zsh/Command/_alias index 617627cbe..86e9a88f0 100644 --- a/Completion/Zsh/Command/_alias +++ b/Completion/Zsh/Command/_alias @@ -3,7 +3,7 @@ local curcontext="$curcontext" state line expl type suf typeset -A opt_args -_arguments -C -s -A "-*" -S \ +_arguments -C -s -A "-*" -S -S : \ '(-r +r -s +s)-+g[list or define global aliases]' \ '(-g +g -s +s)-+r[list or define regular aliases]' \ '(-r +r -g +g)-+s[list or define suffix aliases]' \ diff --git a/Completion/Zsh/Command/_bindkey b/Completion/Zsh/Command/_bindkey index df9c8f225..81016fe4f 100644 --- a/Completion/Zsh/Command/_bindkey +++ b/Completion/Zsh/Command/_bindkey @@ -10,7 +10,7 @@ local state expl line curcontext="$curcontext" ret=1 typeset -A opt_args -_arguments -C -s -S \ +_arguments -C -s -S -S : \ '(-v -a -M -l -D -A -N -p)-e[select emacs keymap and bind it to main]' \ '(-e -a -M -l -D -A -N -p)-v[select viins keymap and bind it to main]' \ '(-e -v -M -l -D -A -N -p)-a[select vicmd keymap]' \ diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command index 503f860a2..02ff985c3 100644 --- a/Completion/Zsh/Command/_command +++ b/Completion/Zsh/Command/_command @@ -1,6 +1,6 @@ #compdef command -_arguments \ +_arguments -S : \ '-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]' \ diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd index 4456cf71e..e42e1dd36 100644 --- a/Completion/Zsh/Command/_compadd +++ b/Completion/Zsh/Command/_compadd @@ -88,7 +88,7 @@ case $service in ;; esac -_arguments -C -s -S -A "-*" $args && ret=0 +_arguments -C -s -S -S -A "-*" : $args && ret=0 if [[ -n $state ]]; then if (( $+opt_args[-a] )); then diff --git a/Completion/Zsh/Command/_dirs b/Completion/Zsh/Command/_dirs index 0281f3736..489366f08 100644 --- a/Completion/Zsh/Command/_dirs +++ b/Completion/Zsh/Command/_dirs @@ -1,6 +1,6 @@ #compdef dirs -_arguments -s \ +_arguments -s -S -S : \ '(-)-c[clear the directory stack]' \ '(* -c)-l[display directory names in full]' \ '(* -c)-v[display numbered list of directory stack]' \ diff --git a/Completion/Zsh/Command/_disable b/Completion/Zsh/Command/_disable index da3803039..c4cc00243 100644 --- a/Completion/Zsh/Command/_disable +++ b/Completion/Zsh/Command/_disable @@ -6,7 +6,7 @@ ali_arr=(${(k)aliases} ${(k)galiases}) sali_arr=(${(k)saliases}) func_arr=(${(k)functions}) -_arguments -C -s -A "-*" -S \ +_arguments -C -s -A "-*" -S -S : \ "(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global alias:compadd -k ali_arr" \ "(-a -r -s -p)-f[act on functions]:*:function:compadd -k func_arr" \ "(-a -f -s -p)-r[act on reserved words]:*:reserved-word:compadd -k reswords" \ diff --git a/Completion/Zsh/Command/_emulate b/Completion/Zsh/Command/_emulate index a16738cdb..3477bc556 100644 --- a/Completion/Zsh/Command/_emulate +++ b/Completion/Zsh/Command/_emulate @@ -1,6 +1,6 @@ #compdef emulate -_arguments -s -S -A '-*' : \ +_arguments -s -S -S -A '-*' : \ '(2 3)-l[list options to be set or unset]' \ '(2 3)-L[set local_options and local_traps as well]' \ '-R[reset all options instead of only those needed for script portability]' \ diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable index b62619d89..c581e49a3 100644 --- a/Completion/Zsh/Command/_enable +++ b/Completion/Zsh/Command/_enable @@ -6,7 +6,7 @@ ali_arr=(${(k)dis_aliases} ${(k)dis_galiases}) sali_arr=(${(k)dis_saliases}) func_arr=(${(k)dis_functions}) -_arguments -C -s -A "-*" -S \ +_arguments -C -s -A "-*" -S -S : \ "(-f -r -s -p)-a[act on regular or global aliases]:*:alias:compadd -k ali_arr" \ "(-a -r -s -p)-f[act on functions]:*:function:compadd -k func_arr" \ "(-a -f -s -p)-r[act on reserved words]:*:reserved-word:compadd -k dis_reswords" \ diff --git a/Completion/Zsh/Command/_exec b/Completion/Zsh/Command/_exec index 2498b57c0..76f11b69d 100644 --- a/Completion/Zsh/Command/_exec +++ b/Completion/Zsh/Command/_exec @@ -1,6 +1,6 @@ #compdef exec -_arguments -s -S -A '-*' : \ +_arguments -s -S -S -A '-*' : \ '-a+[set argv\[0\] to specified string]:argv[0] string' \ '-c[clear environment]' \ '-l[simulate login shell (prepend - to argv\[0\])]' \ diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index 626d35956..fc35114f5 100644 --- a/Completion/Zsh/Command/_fc +++ b/Completion/Zsh/Command/_fc @@ -12,7 +12,7 @@ words=( "${(@)words[1,CURRENT-1]:#*=*}" "${(@)words[CURRENT,-1]}" ) (( CURRENT -= cur )) fc_common=( - -s -S + -s -S -S : '(-A -R -W -p -P)-I[include internal (new) events only]' '(-A -R -W -p -P)-L[include local events only]' '(-A -R -W -p -P)-r[reverse order of the events]' diff --git a/Completion/Zsh/Command/_hash b/Completion/Zsh/Command/_hash index d4bb59d28..b7af750c2 100644 --- a/Completion/Zsh/Command/_hash +++ b/Completion/Zsh/Command/_hash @@ -9,7 +9,7 @@ common_args=( \ case ${service} in hash) - _arguments -C -s -S \ + _arguments -C -s -S -S : \ '(-f -m -v)-r[empty hash table]' \ '(-f -r)-m[treat arguments as patterns]' \ '(-f -r -m)-v[list entries as they are added]' \ @@ -18,7 +18,7 @@ case ${service} in '(-d -f -r -m -v -L)*:hash:->hashval' && ret=0 ;; rehash) - _arguments -C -s ${common_args[@]} && return 0 + _arguments -C -s -S -S : ${common_args[@]} && return 0 ;; esac diff --git a/Completion/Zsh/Command/_jobs_builtin b/Completion/Zsh/Command/_jobs_builtin index 70804cf0f..46146986b 100644 --- a/Completion/Zsh/Command/_jobs_builtin +++ b/Completion/Zsh/Command/_jobs_builtin @@ -1,6 +1,6 @@ #compdef jobs -_arguments -C -s \ +_arguments -C -s -S -S : \ "(-d -l -p -r -s *)-Z[specify string to replace shell's argument and environment with]:string" \ '(-Z)-d[show directory from which each job was started]' \ '(-Z)-l[list process IDs]' \ diff --git a/Completion/Zsh/Command/_kill b/Completion/Zsh/Command/_kill index 3b5c02151..24bf67fac 100644 --- a/Completion/Zsh/Command/_kill +++ b/Completion/Zsh/Command/_kill @@ -3,7 +3,7 @@ local curcontext="$curcontext" line state ret=1 typeset -A opt_args -_arguments -C \ +_arguments -C -s -S -S : \ '(-s -l -L 1)-n[specify signal number]:signal number' \ '(-l -L)-q[send the specified integer with the signal using sigqueue]:value' \ '(-n -l -L 1)-s[specify signal name]:signal:_signals -s' \ diff --git a/Completion/Zsh/Command/_print b/Completion/Zsh/Command/_print index 0610cd4cf..506bf8ca6 100644 --- a/Completion/Zsh/Command/_print +++ b/Completion/Zsh/Command/_print @@ -19,7 +19,7 @@ if [[ $service = print ]]; then rest='*: :_default' fi - _arguments -C -s -A "-*" -S \ + _arguments -C -s -A "-*" -S -S : \ '-r[ignore escape conventions of echo]' \ '(-r -b -f -m -s -S -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \ '-b[recognise bindkey escape sequences]' \ diff --git a/Completion/Zsh/Command/_prompt b/Completion/Zsh/Command/_prompt index ef6aac355..e44d02e0f 100644 --- a/Completion/Zsh/Command/_prompt +++ b/Completion/Zsh/Command/_prompt @@ -1,6 +1,6 @@ #compdef prompt -_arguments -s \ +_arguments -s -S : \ '-l[list themes]:*:' \ '-c[show selected theme]:*:' \ "-h[help]::prompt theme:($prompt_themes):*:" \ diff --git a/Completion/Zsh/Command/_read b/Completion/Zsh/Command/_read index 1f733b0e8..e71531c31 100644 --- a/Completion/Zsh/Command/_read +++ b/Completion/Zsh/Command/_read @@ -6,7 +6,7 @@ local pflag (:>&p) 2>/dev/null && pflag='(-q -s -u -z)-p[input is read from the coprocess]' -_arguments -s -A "-*" -S \ +_arguments -s -A "-*" -S -S : \ '-r[raw mode]' \ '(-p -k -s -u -z)-q[read y or n character from terminal]' \ '(-q)-k+[specify number of characters to read]:: :_guard "[0-9]#" "number of characters"' \ diff --git a/Completion/Zsh/Command/_set b/Completion/Zsh/Command/_set index 720c667a9..5939b48af 100644 --- a/Completion/Zsh/Command/_set +++ b/Completion/Zsh/Command/_set @@ -1,6 +1,6 @@ #compdef set -noglob _arguments -s -S \ +noglob _arguments -s -S -S : \ - list '+[list names of parameters]' - others \ '-o+[set specified option]:option:_options' \ '+o+[unset specified option]:option:_options' \ diff --git a/Completion/Zsh/Command/_strftime b/Completion/Zsh/Command/_strftime index a57a76ce4..fce1f5d95 100644 --- a/Completion/Zsh/Command/_strftime +++ b/Completion/Zsh/Command/_strftime @@ -6,7 +6,7 @@ if (( words[(I)-r] )); then two='date string' fi -_arguments -S -A '-*' -s \ +_arguments -S -S -A '-*' -s : \ '-n[omit trailing newline]' \ '-q[run quietly]' \ '(3)-r[reverse lookup using strptime]' \ diff --git a/Completion/Zsh/Command/_tcpsys b/Completion/Zsh/Command/_tcpsys index 1240ffbf8..c22a2c3a8 100644 --- a/Completion/Zsh/Command/_tcpsys +++ b/Completion/Zsh/Command/_tcpsys @@ -21,7 +21,7 @@ case $service in else argargs+=(':host:_hosts' ':port:_ports' '*:session:->session') fi - _arguments -C $argargs + _arguments -C -s -S : $argargs ;; esac diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index 99b9e7e0d..895a3aa5d 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -93,7 +93,7 @@ for ((i=1;i<=$#use;++i)); do args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[dUurRtT]]:+$func}]} ) done -_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq' && ret=0 +_arguments -C -s -A "-*" -S -S : "${args[@]}" '*::vars:= ->vars_eq' && ret=0 if [[ "$state" = vars_eq ]]; then if [[ $func = f ]]; then diff --git a/Completion/Zsh/Command/_unhash b/Completion/Zsh/Command/_unhash index ff0c03f49..97ccd098a 100644 --- a/Completion/Zsh/Command/_unhash +++ b/Completion/Zsh/Command/_unhash @@ -1,6 +1,6 @@ #compdef unhash -_arguments -s -S \ +_arguments -s -S -S : \ '(-a -f -s *)-d[remove named directories]:*:named directory:compadd -k nameddirs' \ '(-d -f -s *)-a[remove aliases]:*:alias:_aliases' \ '(-a -d -f *)-s[remove suffix aliases]:*:suffix alias:_aliases -s s' \ diff --git a/Completion/Zsh/Command/_vared b/Completion/Zsh/Command/_vared index e7072ca6d..493bae698 100644 --- a/Completion/Zsh/Command/_vared +++ b/Completion/Zsh/Command/_vared @@ -1,6 +1,6 @@ #compdef vared -_arguments -s -A "-*" \ +_arguments -s -S -S -A "-*" : \ '(-a)-A[edit associative array]' \ '(-A)-a[edit array parameter]' \ "-c[create parameter or change type]" \ diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which index 7eb5129ab..95ad5ab2d 100644 --- a/Completion/Zsh/Command/_which +++ b/Completion/Zsh/Command/_which @@ -15,14 +15,14 @@ xarg='-x+[specify spaces to use for indentation in function expansion]: :_number case ${service} in whence) - _arguments -C -s -A "-*" -S \ + _arguments -C -s -A "-*" -S -S : \ '(-c -w)-v[verbose output]' \ '(-v -w)-c[csh-like output]' \ "${cargs[@]}" "$farg" "$aarg" "$xarg" && ret=0 ;; - where) _arguments -C -s -A "-*" -S "${cargs[@]}" "$xarg" && ret=0;; - which) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$xarg" && ret=0;; - type) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$farg" && ret=0;; + where) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$xarg" && ret=0;; + which) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$aarg" "$xarg" && ret=0;; + type) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$aarg" "$farg" && ret=0;; esac if [[ "$state" = command ]]; then diff --git a/Completion/Zsh/Command/_zattr b/Completion/Zsh/Command/_zattr index e48047f6c..c7033de71 100644 --- a/Completion/Zsh/Command/_zattr +++ b/Completion/Zsh/Command/_zattr @@ -4,24 +4,24 @@ local context state line expl ret=1 REPLY case $service in zgetattr) -_arguments \ +_arguments -S -S : \ '1:file:_files' \ '2:attribute:->attrs' \ '3:parameter' ;; zsetattr) -_arguments \ +_arguments -S -S : \ '1:file:_files' \ '2:attribute:->attrs' \ '3:value' ;; zdelattr) -_arguments \ +_arguments -S -S : \ '1:file:_files' \ '2:attribute:->attrs' ;; zlistattr) -_arguments \ +_arguments -S -S : \ '1:file:_files' \ '2:parameter' ;; diff --git a/Completion/Zsh/Command/_zcompile b/Completion/Zsh/Command/_zcompile index 727ead3b1..f1d1e9ac9 100644 --- a/Completion/Zsh/Command/_zcompile +++ b/Completion/Zsh/Command/_zcompile @@ -3,7 +3,7 @@ local state line expl curcontext="$curcontext" ret=1 typeset -A opt_args -_arguments -C -s \ +_arguments -C -s -S -S -A '-*' : \ "(-t -c -m -a)-U[don't expand aliases]" \ '(-t -M)-R[mark as read]' \ '(-t -R)-M[mark as mapped]' \ diff --git a/Completion/Zsh/Command/_zed b/Completion/Zsh/Command/_zed index f84993d73..25763d3fb 100644 --- a/Completion/Zsh/Command/_zed +++ b/Completion/Zsh/Command/_zed @@ -1,11 +1,11 @@ #compdef zed fned histed case $service in -(fned) _arguments -S : ':shell function:_functions';; -(histed) _arguments -S : \ +(fned) _arguments -S -S : ':shell function:_functions';; +(histed) _arguments -S -S : \ '1:history file:_files' \ '2:history size: ';; -(zed) _arguments -S : \ +(zed) _arguments -s -S -S -A '-*' : \ '(-h 1 3 4)-f[edit function]' \ '(-h 1 3 4)-x+[specify spaces to use for indentation in function expansion]:spaces' \ '(-f -x 1 2)-h[edit history]' \ diff --git a/Completion/Zsh/Command/_zformat b/Completion/Zsh/Command/_zformat new file mode 100644 index 000000000..e0f5dc699 --- /dev/null +++ b/Completion/Zsh/Command/_zformat @@ -0,0 +1,24 @@ +#compdef zformat + +local -a args=( + - align + '-a[align strings]' + '1:array to store formatted strings in:_parameters -g "*array*~*readonly*"' + '2:separator string' + '*:strings to align (left\:right)' + + - format + '(-F)-f[format string (ternary tests spec value)]' + '(-f)-F[format string (ternary tests spec length)]' + '(-Q)-q[escape % in specs by default, preserve escapes in format string (with -fF)]' + '(-q)-Q[escape % in specs by default (with -fF)]' + '1:parameter to store formatted string in:_parameters -g "^*readonly*"' + '2:format string' + '*:format spec ([quote]char\:string)' +) + +# don't complete operands until we see one of -afF +[[ -n ${(M)${(@Q)words}:#-[A-Za-z]#[afF][A-Za-z]#} ]] || +args=( ${args:#(|<->|\*):?*} ) + +_arguments -s -S -S -A '-?*' : $args diff --git a/Completion/Zsh/Command/_zle b/Completion/Zsh/Command/_zle index 97ec8c875..ec83c38fa 100644 --- a/Completion/Zsh/Command/_zle +++ b/Completion/Zsh/Command/_zle @@ -15,7 +15,7 @@ compwids=(accept-and-menu-complete opts=(-A -C -D -F -L -M -N -R -T -U -a -c -l -r \* :) -_arguments -s -S \ +_arguments -s -S -S : \ "($opts)-A[define widget alias]:old widget:->widget :new widget:->widget" \ "($opts)-C[define completion widget]:new widget name:->comp-widget :completion widget:->builtin-comp-widget :widget shell function:->function" \ "($opts)-D[delete widget]:*:widget:->widget" \ @@ -36,14 +36,14 @@ _arguments -s -S \ '(-)*::widget args:->args' && ret=0 [[ $state == listing ]] && - _arguments -s -S '!-l' \ + _arguments -s -S -S : '!-l' \ "(-a)-L[list as commands]" \ "(-L)-a[list all widgets]" \ '*:widget name:->widget' && ret=0 case "$state[1]" in (args) - _arguments \ + _arguments -s -S : \ '(-N)-n[numeric prefix]:number:' \ '(-n)-N[reset numeric prefix]' \ '-K[specify temporary keymap]:keymap:compadd -a keymaps' \ @@ -67,7 +67,7 @@ case "$state[1]" in compadd -M 'r:|-=* r:|=*' -k "widgets[(I)(.|)(${(j(|))compwids})]" && ret=0 ;; (redisplay) - _arguments -s -S '!-R' \ + _arguments -s -S -S : '!-R' \ "-c[clear listing]" \ ":status line" "*:strings to list" && ret=0 ;; diff --git a/Completion/Zsh/Command/_zmodload b/Completion/Zsh/Command/_zmodload index f3e38c0f6..3acb75c6e 100644 --- a/Completion/Zsh/Command/_zmodload +++ b/Completion/Zsh/Command/_zmodload @@ -4,7 +4,7 @@ local suf comp state line expl curcontext="$curcontext" ret=1 NORMARG typeset -A opt_args suf=() -_arguments -n -C -S -s \ +_arguments -n -C -S -S -s -A '-*' : \ '(-R -P -i -u -d -a -b -c -I -p -f -e -F -m)-A[create module aliases]' \ '(-)-R[remove module aliases]' \ '(-A -R -F -L -m -P -l -e)-u[unload module]' \ diff --git a/Completion/Zsh/Command/_zmv b/Completion/Zsh/Command/_zmv index df5cb5113..8b4b60897 100644 --- a/Completion/Zsh/Command/_zmv +++ b/Completion/Zsh/Command/_zmv @@ -1,6 +1,6 @@ #compdef zmv zln zcp -_arguments -s -S -A '-*' \ +_arguments -s -S -S -A '-*' : \ '(-C -L -s -p)-M[force mv]' \ '(-M -L -s -p)-C[force cp]' \ '(-M -C -p)-L[force ln]' \ diff --git a/Completion/Zsh/Command/_zparseopts b/Completion/Zsh/Command/_zparseopts index cc5e28a9a..72dc787a4 100644 --- a/Completion/Zsh/Command/_zparseopts +++ b/Completion/Zsh/Command/_zparseopts @@ -4,7 +4,7 @@ local ret=1 local -a context line state state_descr alts opts local -A opt_args -_arguments -A '-*' : \ +_arguments -S -S -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]' \ diff --git a/Completion/Zsh/Command/_zpty b/Completion/Zsh/Command/_zpty index 99251aa0a..75393ecf1 100644 --- a/Completion/Zsh/Command/_zpty +++ b/Completion/Zsh/Command/_zpty @@ -3,7 +3,7 @@ local state line list names expl sep curcontext="$curcontext" typeset -A opt_args -_arguments -C -s -S \ +_arguments -C -s -S -S -A '-*' : \ '(-r -w -t -n -L -d)-e[echo input characters]' \ '(-r -w -t -n -L -d)-b[io to pseudo-terminal blocking]' \ '(-r -w -t -n -L -e -b)-d[delete command]:*:name:->name' \ diff --git a/Completion/Zsh/Command/_zsocket b/Completion/Zsh/Command/_zsocket index eeed9f1d8..bf0298b17 100644 --- a/Completion/Zsh/Command/_zsocket +++ b/Completion/Zsh/Command/_zsocket @@ -1,6 +1,6 @@ #compdef zsocket -_arguments -s -w -A "-*" \ +_arguments -s -w -S -S -A "-*" : \ '-v[verbose output]' \ '-d[target file descriptor]:fd:_file_descriptors' \ - outbound \ diff --git a/Completion/Zsh/Function/__arguments b/Completion/Zsh/Function/__arguments index af7710971..1264d372b 100644 --- a/Completion/Zsh/Function/__arguments +++ b/Completion/Zsh/Function/__arguments @@ -32,7 +32,7 @@ else '-W[(rarely needed) enable single-letter option stacking with arguments in the same word (-x X -y == -xXy)]' \ "-C[modify \$curcontext for \`->action' (instead of \$context)]" \ "-R[when \`->action' matches, return 300]" \ - "-S[honour \`--' as end-of-options guard]" \ + "*-S[honour \`--' (and \`-' if given twice) as end-of-options guard]" \ "-A[do not complete options after non-options]:pattern matching unknown options (e.g., '-*')" \ '-O[pass elements of array variable to function calls in actions]:array variable name:_parameters -g array' \ "-M[specify matchspec for completing option names and values]:matchspec for completing option names and values [ 'r\\:|[_-]=* r\\:|=*' ]" \ diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names index d445be06e..01a93abcf 100644 --- a/Completion/Zsh/Type/_command_names +++ b/Completion/Zsh/Type/_command_names @@ -62,7 +62,7 @@ zstyle -a ":completion:${curcontext}" command-path cmdpath # otherwise overridden (bash-completion's _sudo does something similar) if (( ! $#cmdpath && $#_comp_priv_prefix )); then cmdpath=( $path ${path/%\/bin//sbin} ) - cmdpath=( ${(u)^cmdpath}(/-N) ) + cmdpath=( ${(u)^cmdpath}(-/N) ) fi if (( $#cmdpath )); then diff --git a/Completion/Zsh/Type/_history_modifiers b/Completion/Zsh/Type/_history_modifiers index 1a049d6cb..bb704b3a3 100644 --- a/Completion/Zsh/Type/_history_modifiers +++ b/Completion/Zsh/Type/_history_modifiers @@ -60,6 +60,7 @@ while true; do else list=( "s:substitute string" + "S:substitute pattern" "&:repeat substitution" ) if (( ! global )); then diff --git a/Completion/Zsh/Type/_jobs_fg b/Completion/Zsh/Type/_jobs_fg index 57117f0d6..49bf72425 100644 --- a/Completion/Zsh/Type/_jobs_fg +++ b/Completion/Zsh/Type/_jobs_fg @@ -1,3 +1,8 @@ #compdef disown fg -_jobs "$@" +local -a ca_args=( "$@" ) +local -a args=( '(-)*: :_jobs' ) + +[[ $service == disown ]] && args+=( '(: *)-a[disown all jobs]' ) + +_arguments -s -S -A '-*' -O ca_args : $args diff --git a/Completion/compdump b/Completion/compdump index 6daf92f9f..c0c31ba63 100644 --- a/Completion/compdump +++ b/Completion/compdump @@ -10,66 +10,46 @@ # create the .dump file as before. Again, compinit -d handles this # automatically. -# Print the number of files used for completion. This is used in compinit -# to see if auto-dump should re-dump the dump-file. - emulate -L zsh -setopt extendedglob noshglob +setopt bareglobqual extendedglob noshglob -typeset _d_file _d_f _d_fd _d_bks _d_line _d_als _d_files _d_name _d_tmp +typeset _d_complist _d_fd _d_file +typeset -a _d_als _d_bks _d_files _d_tmp _d_file=${_comp_dumpfile-${0:h}/compinit.dump}.$HOST.$$ [[ $_d_file = //* ]] && _d_file=${_d_file[2,-1]} [[ -w ${_d_file:h} ]] || return 1 -_d_files=( ${^~fpath:/.}/^([^_]*|*~|*.zwc)(N) ) +# avoid scanning fpath again if compinit has already done it +if (( ${+funcstack[(re)compinit]} && $#_i_files )); then + _d_files=( $_i_files ) +else + _d_files=( ${^fpath:/.}/^([^_]*|*[\;\|\&]*|*~|*.zwc)(NoN) ) +fi if [[ -n "$_comp_secure" ]]; then - _d_wdirs=( ${^fpath}(Nf:g+w:,f:o+w:,^u0u${EUID}) ) - _d_wfiles=( ${^~fpath:/.}/^([^_]*|*~|*.zwc)(N^u0u${EUID}) ) + local -a _d_wdirs _d_wfiles + + _d_wdirs=( ${^fpath}(NoNf:g+w:,f:o+w:,^u0u${EUID}) ) + _d_wfiles=( ${^fpath:/.}/^([^_]*|*~|*.zwc)(NoN^u0u${EUID}) ) (( $#_d_wfiles )) && _d_files=( "${(@)_d_files:#(${(j:|:)_d_wfiles})}" ) (( $#_d_wdirs )) && _d_files=( "${(@)_d_files:#(${(j:|:)_d_wdirs})/*}" ) fi exec {_d_fd}>$_d_file -print "#files: $#_d_files\tversion: $ZSH_VERSION" >& $_d_fd -# Dump the arrays _comps, _services and _patcomps. The quoting -# hieroglyphics ensure that a single quote inside a variable is itself -# correctly quoted. - -print "\n_comps=(" >& $_d_fd -for _d_f in ${(ok)_comps}; do - print -r - "${(qq)_d_f}" "${(qq)_comps[$_d_f]}" -done >& $_d_fd -print ")" >& $_d_fd - -print "\n_services=(" >& $_d_fd -for _d_f in ${(ok)_services}; do - print -r - "${(qq)_d_f}" "${(qq)_services[$_d_f]}" -done >& $_d_fd -print ")" >& $_d_fd - -print "\n_patcomps=(" >& $_d_fd -for _d_f in ${(ok)_patcomps}; do - print -r - "${(qq)_d_f}" "${(qq)_patcomps[$_d_f]}" -done >& $_d_fd -print ")" >& $_d_fd +# Print the number of files used for completion. This is used in compinit +# to see if auto-dump should re-dump the dump-file. -_d_tmp="_postpatcomps" -print "\n_postpatcomps=(" >& $_d_fd -for _d_f in ${(ok)_postpatcomps}; do - print -r - "${(qq)_d_f}" "${(qq)_postpatcomps[$_d_f]}" -done >& $_d_fd -print ")" >& $_d_fd +print "#files: $#_d_files\tversion: $ZSH_VERSION" >& $_d_fd -print "\n_compautos=(" >& $_d_fd -for _d_f in "${(ok@)_compautos}"; do - print -r - "${(qq)_d_f}" "${(qq)_compautos[$_d_f]}" +for 1 in _comps _services _patcomps _postpatcomps _compautos; do + print "\n${1}=(" + printf ' %s %s\n' "${(@Pkvqq)1}" + print ")" done >& $_d_fd -print ")" >& $_d_fd print >& $_d_fd @@ -79,63 +59,57 @@ print >& $_d_fd # We can ignore any zle -C which rebinds a standard widget (second # argument to zle does not begin with a `_'). -_d_bks=() -typeset _d_complist= -zle -lL | - while read -rA _d_line; do - if [[ ${_d_line[3]} = _* && ${_d_line[5]} = _* ]]; then - if [[ -z "$_d_complist" && ${_d_line[4]} = .menu-select ]]; then - print 'zmodload -i zsh/complist' - _d_complist=yes - fi - print -r - ${_d_line} - _d_bks+=(${_d_line[3]}) - fi - done >& $_d_fd -bindkey | - while read -rA _d_line; do - if [[ ${_d_line[2]} = (${(j.|.)~_d_bks}) ]]; then - print -r "bindkey '${_d_line[1][2,-2]}' ${_d_line[2]}" - fi - done >& $_d_fd +for 1 in ${(f)${ zle -lL }}; do + argv=( ${(z)1} ) + + [[ $3 == _* && $5 == _* ]] || continue + + if [[ -z $_d_complist && $4 == .menu-select ]]; then + print 'zmodload -i zsh/complist' + _d_complist=yes + fi + + print -r - $@ + _d_bks+=( $3 ) +done >& $_d_fd print >& $_d_fd +for 1 in ${(f)${ bindkey }}; do + argv=( ${(z)1} ) + + (( ${+_d_bks[(re)$2]} )) && + print -r bindkey $1 $2 +done >& $_d_fd + +print >& $_d_fd # Autoloads: look for all defined functions beginning with `_' (that also # exists in fpath: see workers/38547). -_d_als=($^fpath/(${(o~j.|.)$(typeset +fm '_*')})(N:t)) +_d_tmp=( ${${(M)_d_files:#*/(${(~j.|.)${(f)${ typeset +fm '_*' }}})}:t} ) # print them out: about five to a line looks neat -integer _i=5 -print -n autoload -Uz >& $_d_fd -while (( $#_d_als )); do - if (( ! $+_compautos[$_d_als[1]] )); then - print -n " $_d_als[1]" - if (( ! --_i && $#_d_als > 1 )); then - _i=5 - print -n ' \\\n ' - fi - fi - shift _d_als -done >& $_d_fd +printf -v _d_als ' %s %s %s %s %s' $_d_tmp +_d_als[-1]=${_d_als[-1]%%[[:space:]]##} # purely for aesthetics + +print -r autoload -Uz \\ >& $_d_fd +print -rl - ${(pj< \\\n>)_d_als} >& $_d_fd print >& $_d_fd -local _c -for _c in "${(ok@)_compautos}"; do - print "autoload -Uz $_compautos[$_c] $_c" >& $_d_fd -done +# note Oa to reverse key and val +printf 'autoload -Uz %s %s\n' "${(@kvOa)_compautos}" >& $_d_fd print >& $_d_fd print "typeset -gUa _comp_assocs" >& $_d_fd print "_comp_assocs=( ${(qq)_comp_assocs} )" >& $_d_fd + exec {_d_fd}>&- -mv -f $_d_file ${_d_file%.$HOST.$$} +mv -f -- $_d_file ${_d_file%.$HOST.$$} unfunction compdump autoload -Uz compdump diff --git a/Completion/compinit b/Completion/compinit index 900900644..2d6bf554a 100644 --- a/Completion/compinit +++ b/Completion/compinit @@ -77,38 +77,16 @@ setopt extendedglob typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1 typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name _i_why -while [[ $# -gt 0 && $1 = -[dDiuCw] ]]; do - case "$1" in - -d) - _i_autodump=1 - shift - if [[ $# -gt 0 && "$1" != -[dfQC] ]]; then - _i_dumpfile="$1" - shift - fi - ;; - -D) - _i_autodump=0 - shift - ;; - -i) - _i_fail=ign - shift - ;; - -u) - _i_fail=use - shift - ;; - -C) - _i_check= - shift - ;; - -w) - _i_why=1 - shift - ;; - esac -done +# note: for historical reasons it must be possible to give the optional arg to +# -d in the next parameter. zparseopts handles this by default +local -A _i_opth +zparseopts -A _i_opth -D -F - C d:: D i u w || return +(( $+_i_opth[-C] )) && _i_check= +(( $+_i_opth[-d] )) && _i_autodump=1 _i_dumpfile=$_i_opth[-d] +(( $+_i_opth[-D] )) && _i_autodump=0 +(( $+_i_opth[-i] )) && _i_fail=ign +(( $+_i_opth[-u] )) && _i_fail=use +(( $+_i_opth[-w] )) && _i_why=1 # The associative arrays containing the definitions for the commands and # services. diff --git a/Completion/openSUSE/Command/_SUSEconfig b/Completion/openSUSE/Command/_SUSEconfig deleted file mode 100644 index 737a80b17..000000000 --- a/Completion/openSUSE/Command/_SUSEconfig +++ /dev/null @@ -1,14 +0,0 @@ -#compdef SuSEconfig - -local modules -modules=( /sbin/conf.d/SuSEconfig.*~(*.rpm*|*.swap|*.bak|*.orig|*~|\#*)(N:e) ) - -_arguments \ - '--help' \ - '--quick' \ - '--force' \ - '--verbose' \ - '--nonewpackage' \ - '-norestarts' \ - '-nomodule' \ - '--module:module:compadd -a modules' diff --git a/Config/.cvsignore b/Config/.cvsignore deleted file mode 100644 index dd265a713..000000000 --- a/Config/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -defs.mk -*.swp diff --git a/Config/version.mk b/Config/version.mk index 637bade7a..0b34ea7a2 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.9.0.3-test -VERSION_DATE='August 24, 2025' +VERSION=5.9.999.3-test +VERSION_DATE='May 27, 2026' diff --git a/Doc/.cvsignore b/Doc/.cvsignore deleted file mode 100644 index 606228be7..000000000 --- a/Doc/.cvsignore +++ /dev/null @@ -1,20 +0,0 @@ -Makefile -help.txt -version.yo -zsh*.1 -zsh.texi -zsh.info* -*.html -zsh.aux zsh.toc -zsh.cp zsh.cps -zsh.fn zsh.fns -zsh.ky zsh.kys -zsh.pg zsh.pgs -zsh.vr zsh.vrs -zsh.log zsh.dvi -zsh.tp zsh.tps -zsh.idx -zsh_*.ps -infodir -*.swp -zsh.pdf zsh_a4.pdf zsh_us.pdf diff --git a/Doc/Zsh/.cvsignore b/Doc/Zsh/.cvsignore deleted file mode 100644 index 71e99e521..000000000 --- a/Doc/Zsh/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -modlist.yo -modmenu.yo -manmodmenu.yo -*.swp diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo index 095bc5783..ca9ba996b 100644 --- a/Doc/Zsh/builtins.yo +++ b/Doc/Zsh/builtins.yo @@ -464,13 +464,14 @@ enditem() ) findex(disown) cindex(jobs, disowning) -xitem(tt(disown) [ var(job) ... ]) +xitem(tt(disown) [ tt(-a) | var(job) ... ]) xitem(var(job) ... tt(&|)) item(var(job) ... tt(&!))( Remove the specified var(job)s from the job table; the shell will no longer report their status, and will not complain if you try to exit an interactive shell with them running or stopped. If no var(job) is specified, disown the current job. +With tt(-a), disown all jobs. If the var(job)s are currently stopped and the tt(AUTO_CONTINUE) option is not set, a warning is printed containing information about how to @@ -1744,7 +1745,7 @@ If the tt(-m) flag is given the arguments are taken as patterns options with names matching these patterns are set. Note that a bad option name does not cause execution of subsequent shell -code to be aborted; this is behaviour is different from that of `tt(set +code to be aborted; this behaviour is different from that of `tt(set -o)'. This is because tt(set) is regarded as a special builtin by the POSIX standard, but tt(setopt) is not. ) diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 7f748ad73..3aca78998 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -32,7 +32,7 @@ enditemize() A full context specification contains other elements, as we shall describe. -Besides commands names and contexts, the system employs two more +Besides command names and contexts, the system employs two more concepts, em(styles) and em(tags). These provide ways for the user to configure the system's behaviour. @@ -775,7 +775,7 @@ for color names kindex(commands, completion tag) item(tt(commands))( for names of external commands. Also used by complex commands such as -tt(cvs) when completing names subcommands. +tt(cvs) when completing names of subcommands. ) kindex(contexts, completion tag) item(tt(contexts))( @@ -3702,6 +3702,10 @@ example(foobar -x -- -y) the `tt(-x)' is considered an option, the `tt(-y)' is considered an argument, and the `tt(-)tt(-)' is considered to be neither. + +If this option is given twice (as tt(-S -S)), a single `tt(-)' is also +treated this way. This is useful for completing zsh's own builtins as +well as functions that use tt(zparseopts) for option parsing. ) item(tt(-A) var(pat))( Do not complete options after the first non-option @@ -3980,10 +3984,9 @@ typeset -A opt_args) to prevent tt(_arguments) from altering the global environment. ) item(tt({)var(eval-string)tt(}))( -vindex(expl, use of) -A string in braces is evaluated as shell code to generate matches. If the -var(eval-string) itself does not begin with an opening parenthesis or -brace it is split into separate words before execution. +A string in braces is evaluated as shell code to generate matches. +This is similar to the `tt(SP())var(word) var(...)' action described +below, but isn't limited to a single command. ) item(tt(= )var(action))( If the var(action) starts with `tt(= )' (an equals sign followed by a @@ -4001,8 +4004,9 @@ causes tt(_arguments) on a restricted range; it is necessary to use this trick to insert an appropriate command name into the range for the second call to tt(_arguments) to be able to parse the line. ) -xitem(var(tt(SP())word...)) -item(var(word...))( +xitem(tt(SP())var(word) var(...)) +item(var(word) var(...))( +vindex(expl, use of) This covers all forms other than those above. If the var(action) starts with a space, the remaining list of words will be invoked unchanged. @@ -4021,7 +4025,11 @@ enditem() During the performance of the action the array `tt(line)' will be set to the normal arguments from the command line, i.e. the words from the command line after the command name excluding all options and their -arguments. Options are stored in the associative array +arguments. Also excluded are any words appearing after the current +word, the parsing terminator `tt(-)tt(-)' or `tt(-)' if tt(_arguments) +was called with tt(-S), and any words ignored by the tt(-A) pattern. + +Options are stored in the associative array `tt(opt_args)' with option names as keys and their arguments as the values. By default, all colons and backslashes in the value are escaped with backslashes, and if an option has multiple arguments (for example, when @@ -4288,7 +4296,7 @@ The return status of tt(_call_function) itself is zero if the function var(name) exists and was called and non-zero otherwise. ) findex(_call_program) -item(tt(_call_program) [ tt(-l) ] [ tt(-p) ] var(tag) var(string) ...)( +item(tt(_call_program) [ tt(-lpqQ) ] var(tag) var(string) ...)( This function provides a mechanism for the user to override the use of an external command. It looks up the tt(command) style with the supplied var(tag). If the style is set, its value is used as the command to @@ -4310,6 +4318,15 @@ match the permissions to whatever the final command is likely to run under. When looking up the tt(gain-privileges) and tt(command) styles, the command component of the zstyle context will end with a slash (`tt(/)') followed by the command that would be used to gain privileges. + +By default, the var(string)s are passed directly to tt(eval), which may +require double-quoting in some cases. The options tt(-q) and tt(-Q) can +help with this: with tt(-q), all var(string)s are quoted, whereas with +tt(-Q) all var(string)s except the first one (usually the name of the +command to run) are quoted. tt(-Q) is useful when the first var(string) +is tt($words[1]), which may already be quoted since it is taken directly +from the typed command line. These options do not affect the quoting of +arguments derived from the tt(command) style. ) findex(_combination) item(tt(_combination) [ tt(-s) var(pattern) ] var(tag) var(style) var(spec) ... var(field) var(opts) ...)( @@ -4446,6 +4463,7 @@ it does not need to appear inside a loop over tag labels. ) findex(_description) item(tt(_description) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(spec) ... ])( +vindex(expl, use of) This function is not to be confused with the previous one; it is used as a helper function for creating options to tt(compadd). It is buried inside many of the higher level completion functions and so often does @@ -4907,6 +4925,24 @@ Finally, the tt(_path_files) function uses the styles tt(expand), tt(ambiguous), tt(special-dirs), tt(list-suffixes) and tt(file-sort) described above. ) +findex(_phony) +item(tt(_phony) ... [ var(word) ... ] [ [ tt(--) ] var(function) [ tt(-) ] ... ])( +This function allows extra matches to be mixed in with the matches +generated by a function. Sometimes a command accepts special values like +`tt(any)', `tt(all)', or `tt(none)' to be specified but the applicable +completion function only generates real values. + +tt(_phony) takes all the same arguments as tt(compadd). With the exception +of `tt(-a)', `tt(-d)', `tt(-k)' and `tt(-l)', these are passed on to the +following function. Unless there is only one word, a `tt(--)' separator is +needed to indicate where the words finish and the function begins. You can +also omit the function in which case an empty input won't match the phony +values, allowing descriptions to be displayed. This is useful where real +values can't be generated and tt(_message -e) would otherwise be used. + +To ensure that real and phony matches are grouped together, any options +defining the match group should be passed to tt(_phony). +) findex(_pick_variant) redef(SPACES)(0)(tt(ifztexi(NOTRANS(@ @ @ @ @ @ @ @ @ @ @ @ @ @ ))ifnztexi( ))) xitem(tt(_pick_variant )[ tt(-b) var(builtin-label) ] [ tt(-c) var(command) ] [ tt(-r) var(name) ]) diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo index ff8aca5f0..3e8e9f446 100644 --- a/Doc/Zsh/compwid.yo +++ b/Doc/Zsh/compwid.yo @@ -873,16 +873,20 @@ builtin, but in the case of the condition codes the contents of the special parameters are not modified. startitem() +findex(-prefix, within [[) item(tt(-prefix) [ var(number) ] var(pattern))( true if the test for the tt(-P) option of tt(compset) would succeed. ) +findex(-suffix, within [[) item(tt(-suffix) [ var(number) ] var(pattern))( true if the test for the tt(-S) option of tt(compset) would succeed. ) +findex(-after, within [[) item(tt(-after) var(beg-pat))( true if the test of the tt(-N) option with only the var(beg-pat) given would succeed. ) +findex(-between, within [[) item(tt(-between) var(beg-pat end-pat))( true if the test for the tt(-N) option with both patterns would succeed. ) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index eb52c1fe7..aeb47851c 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -4406,7 +4406,7 @@ the context prefix `tt(:completion:nslookup)'. 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))( +item(tt(regexp-replace) var(var) var(regexp) [ var(replace) ])( Use regular expressions to perform a global search and replace operation on a variable. POSIX extended regular expressions (ERE) are used, unless the option tt(RE_MATCH_PCRE) has been set, in which case @@ -4416,7 +4416,8 @@ library). var(var) is the name of the variable containing the string to be matched. The variable will be modified directly by the function. The -variables tt(MATCH), tt(MBEGIN), tt(MEND), tt(match), tt(mbegin), tt(mend) +variables tt(MATCH), tt(MBEGIN), tt(MEND), tt(match), tt(mbegin), tt(mend), +as well as any variables starting with tt(_regexp_replace) should be avoided as these are used by the regular expression code. var(regexp) is the regular expression to match against the string. @@ -4424,6 +4425,7 @@ var(regexp) is the regular expression to match against the string. var(replace) is the replacement text. This can contain parameter, command and arithmetic expressions which will be replaced: in particular, a reference to tt($MATCH) will be replaced by the text matched by the pattern. +If not given, matches are replaced with nothing. The return status is 0 if at least one match was performed, else 1. diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 0cefaf7d1..cbdaddead 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -663,7 +663,7 @@ item(tt(${)var(name)tt(::=)var(word)tt(}))( In the first form, if var(name) is unset then set it to var(word); in the second form, if var(name) is unset or null then set it to var(word); and in the third form, unconditionally set var(name) to var(word). In all -forms, the value of the parameter is then substituted. +forms, the value of var(name) is then substituted. ) xitem(tt(${)var(name)tt(?)var(word)tt(})) item(tt(${)var(name)tt(:?)var(word)tt(}))( @@ -1699,7 +1699,7 @@ are not the same as the flags used within parameter substitutions. At the outermost level of substitution, the `tt((P))' flag (rule tt(4.)) ignores these transformations and uses the unmodified value of the parameter as the name to be replaced. This is usually the desired -behavior because padding may make the value syntactically illegal as a +behavior because padding may make the value syntactically invalid as a parameter name, but if capitalization changes are desired, use the tt(${${(P)foo}}) form (rule tt(25.)). ) diff --git a/Doc/Zsh/mod_ksh93.yo b/Doc/Zsh/mod_ksh93.yo index 9e995caac..a99592c8e 100644 --- a/Doc/Zsh/mod_ksh93.yo +++ b/Doc/Zsh/mod_ksh93.yo @@ -16,9 +16,7 @@ item(tt(nameref) [ tt(-gpur) ] var(pname)[tt(=)var(rname)])( Equivalent to tt(typeset -n )var(pname)tt(=)var(rname) However, tt(nameref) is a builtin command rather than a reserved word, -so when var(rname) uses subscript syntax it must be quoted against -globbing. Subscripts in referenced parameters are not supported in -ksh93, so this is not a significant compatibility issue. +so handling of assigments in the argument list may differ. ) enditem() diff --git a/Doc/Zsh/mod_nearcolor.yo b/Doc/Zsh/mod_nearcolor.yo index df7771397..ef565fff3 100644 --- a/Doc/Zsh/mod_nearcolor.yo +++ b/Doc/Zsh/mod_nearcolor.yo @@ -23,10 +23,14 @@ it will be compared against each of the available colours and the closest will be selected. The first sixteen colours are never matched in this process due to being unpredictable. -It isn't possible to reliably detect support for true colour in the -terminal emulator. It is therefore recommended to be selective in -loading the tt(zsh/nearcolor) module. For example, the following -checks the tt(COLORTERM) environment variable: +The use of a hex triplet will automatically load the tt(zsh/nearcolor) +module if the terminal doesn't support 24-bit colour. This behaviour can +be modified via the tt(.term.extensions) parameter DASH()- see +sectref(Terminal Extensions)(zshzle). + +The module can also be loaded manually. It is recommended to be +selective in doing so. For example, the following checks the +tt(COLORTERM) environment variable: example([[ $COLORTERM = *LPAR()24bit|truecolor+RPAR()* ]] || \ zmodload zsh/nearcolor) diff --git a/Doc/Zsh/mod_watch.yo b/Doc/Zsh/mod_watch.yo index 06ab3cbea..df477a770 100644 --- a/Doc/Zsh/mod_watch.yo +++ b/Doc/Zsh/mod_watch.yo @@ -40,7 +40,8 @@ vindex(WATCHFMT) item(tt(WATCHFMT))( The format of login/logout reports if the tt(watch) parameter is set. Default is `tt(%n has %a %l from %m)'. -Recognizes the following escape sequences: +Recognizes the following escape sequences, many of which are described +further in sectref(Simple Prompt Escapes)(zshmisc): startitem() item(tt(%n))( @@ -71,6 +72,10 @@ Start (stop) using a different foreground color. item(tt(%K{)var(color)tt(}) LPAR()tt(%k)RPAR())( Start (stop) using a different background color. ) +item(tt(%H{)var(group)tt(}))( +Change all character visual attributes using a highlighting +specification from the tt(.zle.hlgroups) associative array. +) item(tt(%S) LPAR()tt(%s)RPAR())( Start (stop) standout mode. ) diff --git a/Doc/Zsh/mod_zpty.yo b/Doc/Zsh/mod_zpty.yo index 599b9e6d2..b0b5fdf20 100644 --- a/Doc/Zsh/mod_zpty.yo +++ b/Doc/Zsh/mod_zpty.yo @@ -30,10 +30,13 @@ 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) ... ])( -The second form, with the tt(-d) option, is used to delete commands -previously started, by supplying a list of their var(name)s. If no -var(name) is given, all commands are deleted. Deleting a command causes -the HUP signal to be sent to the corresponding process. +The tt(-d) option is used to delete commands previously started, by +supplying a list of their var(name)s. If no var(name) is given, all +commands are deleted. Deleting a command causes the HUP signal to be sent +to the corresponding process. It is not a good idea to use this form in a +subshell, as it will kill the command but leave the parent shell confused +about the state, and it may try to kill another process that re-used the +process ID. ) item(tt(zpty) tt(-w) [ tt(-n) ] var(name) [ var(string) ... ])( The tt(-w) option can be used to send the to command var(name) the given @@ -82,9 +85,10 @@ when the command has exited: the return value is zero if at least one character could still be read even if the pattern failed to match. ) item(tt(zpty) tt(-t) var(name))( -The tt(-t) option without the tt(-r) option can be used to test -whether the command var(name) is still running. It returns a zero -status if the command is running and a non-zero value otherwise. +The tt(-t) option without the tt(-r) option can be used to test whether the +command var(name) is still running. It returns a zero status if the command +is running and a non-zero value otherwise. Note that this does not indicate +whether or not any output is available to read. ) item(tt(zpty) [ tt(-L) ])( The last form, without any arguments, is used to list the commands diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo index c33e3c721..11fe8a073 100644 --- a/Doc/Zsh/mod_zutil.yo +++ b/Doc/Zsh/mod_zutil.yo @@ -158,11 +158,13 @@ var(pattern) matches at least one of the strings in the value. enditem() ) findex(zformat) -xitem(tt(zformat -f) var(param) var(format) var(spec) ...) -xitem(tt(zformat -F) var(param) var(format) var(spec) ...) +xitem(tt(zformat -f) [ tt(-qQ) ] ] var(param) var(format) var(spec) ...) +xitem(tt(zformat -F) [ tt(-qQ) ] ] var(param) var(format) var(spec) ...) item(tt(zformat -a) var(array) var(sep) var(spec) ...)( -This builtin provides different forms of formatting. The first form -is selected with the tt(-f) option. In this case the var(format) +This builtin provides different forms of formatting. + +The first form is selected with the tt(-f) option. +In this case the var(format) string will be modified by replacing sequences starting with a percent sign in it with strings from the var(spec)s. Each var(spec) should be of the form `var(char)tt(:)var(string)' which will cause every @@ -176,9 +178,21 @@ width makes the result be padded with spaces to the right if the var(string) is shorter than the requested width. Padding to the left can be achieved by giving a negative minimum field width. If a maximum field width is specified, the var(string) will be truncated after that -many characters. After all `tt(%)' sequences for the given var(spec)s -have been processed, the resulting string is stored in the parameter -var(param). The sequence `tt(%%)' can be used to produce a literal tt(%). +many characters. + +The var(char) in each var(spec) may optionally be preceded by an +escaping indicator, either `tt(%)' to explicitly enable the +var(spec)-escaping behaviour of tt(-q) described below, or `tt(%%)' to +explicitly disable it. The default behaviour is to em(not) escape specs. + +Any `tt(%)' sequence in tt(format) that does not match a given var(spec) +(or one of the special sequences described below) is output as-is. If +desired, these sequences may be processed by a second round of +formatting, by prompt expansion, etc. DASH()- see also tt(-q). + +The sequence `tt(%%)' can be used to produce a literal tt(%). +After all `tt(%)' sequences have been processed, the resulting string is +stored in the parameter var(param). The tt(%)-escapes also understand ternary expressions in the form used by prompts. The tt(%) is followed by a `tt(LPAR())' and then an ordinary @@ -207,11 +221,42 @@ expression. With tt(-F) instead of tt(-f), ternary expressions choose between the `true' or `false' text on the basis of whether the format specifier is -present and non-empty. A test number indicates a minimum width for the -value given in the format specifier. Negative numbers reverse this, -so the test is for whether the value exceeds a maximum width. +present and non-empty. If a test number is provided, it tests the width +of the value given in the format specifier DASH()- with a positive +number the condition is true when the width is em(greater than) that +number, and with a negative number the condition is true when the width +is em(less than or equal to) the absolute value of that number. + +With tt(-q), `tt(%)' characters in the var(spec)s are escaped by default +as they are inserted into the formatted string, and pre-escaped `tt(%)' and +`tt(RPAR())` characters in the format string are left as they are. For +example: + +example(zformat -qF REPLY '%%foo%% %B%d%b' d:%bar%) + +outputs `tt(%%foo%% %B%%bar%%%b)' to tt(REPLY). This is useful when the +formatted string will undergo further expansion DASH()- in this example +the tt(%B)...tt(%b) sequences could be used with prompt expansion to +produce bold text. One notable use case is formatting a description to +be passed to tt(compadd -x) in a completion function. + +Since the output with tt(-q) is expected to be subject to further +processing, width specifiers don't count the extra escape characters, +ensuring that the widths are correct em(after) that processing. +Additionally, with tt(-F), ternary-expression test numbers are compared +against the em(pre-escaped) spec lengths. + +tt(-Q) is like tt(-q) except that it interprets pre-escaped `tt(%)' and +`tt(RPAR())` characters in the format string as normal. + +The optional escaping indicator can be used to exempt individual +var(spec)s from escaping as described above. For example: + +example(zformat -qF REPLY '%d %D' d:%foo% %%D:%bar%) + +outputs `tt(%%foo%% %bar%)' to tt(REPLY). -The form, using the tt(-a) option, can be used for aligning +The form using the tt(-a) option can be used for aligning strings. Here, the var(spec)s are of the form `var(left)tt(:)var(right)' where `var(left)' and `var(right)' are arbitrary strings. These strings are modified by replacing the colons diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index 3e745ec3d..6f3bef189 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -240,7 +240,7 @@ pindex(AUTONAMEDIRS) pindex(NOAUTONAMEDIRS) cindex(directories, named) item(tt(AUTO_NAME_DIRS))( -Any parameter that is set to the absolute name of a directory +Any global parameter that is set to the absolute name of a directory immediately becomes a name for that directory, that will be used by the `tt(%~)' and related prompt sequences, and will be available when completion @@ -1194,7 +1194,7 @@ This option is only used if the option tt(CLOBBER) is not set: note that it is set by default. If this option is set, then regular files of zero length may be -ovewritten (`clobbered'). Note that it is possible another process +overwritten (`clobbered'). Note that it is possible another process has written to the file between this test and use of the file by the current process. This option should therefore not be used in cases where files to be clobbered may be written to asynchronously. diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo index 635589be4..a4dd1a2ca 100644 --- a/Doc/Zsh/params.yo +++ b/Doc/Zsh/params.yo @@ -1082,7 +1082,7 @@ Code specified by the tt(-c) option to the command line that invoked the shell. ) item(tt(cmdsubst))( -Command substitution using of the tt(`)var(...)tt(`), +Command substitution using the tt(`)var(...)tt(`), tt($+LPAR())var(...)tt(RPAR()), tt(${{)var(name)tt(}) var(...)tt(}), tt(${|)var(...)tt(}), or tt(${ )var(...)tt( }) constructs. ) @@ -1120,6 +1120,12 @@ The tt(>LPAR())var(...)tt(RPAR()) form of process substitution. item(tt(loadautofunc))( Code read directly from a file to define an autoloaded function. ) +item(tt(math))( +Code executed in the tt($+LPAR()LPAR())var(...)tt(RPAR()RPAR()) or +tt(LPAR()LPAR())var(...)tt(RPAR()RPAR()) constructs, +by the tt(let) builtin, in an array subscript, or in +another arithmetic context. +) item(tt(outsubst))( The tt(<LPAR())var(...)tt(RPAR()) form of process substitution. ) @@ -1259,6 +1265,12 @@ vindex(COLUMNS) item(tt(COLUMNS) <S>)( The number of columns for this terminal session. Used for printing select lists and for the line editor. +If the shell is non-interactive and a legal value is imported from the +environment, it is preserved. Otherwise, the value is reset on start-up +and in response to certain events such as the receipt of a tt(SIGWINCH) +signal. Explicitly setting it to an illegal value such as tt(0) also +resets it. (Unsetting the parameter does not have this effect; it +simply `hides' the value that the shell is tracking internally.) ) vindex(CORRECT_IGNORE) item(tt(CORRECT_IGNORE))( @@ -1465,6 +1477,7 @@ vindex(LINES) item(tt(LINES) <S>)( The number of lines for this terminal session. Used for printing select lists and for the line editor. +See tt(COLUMNS). ) vindex(LISTMAX) item(tt(LISTMAX))( diff --git a/Doc/help/.cvsignore b/Doc/help/.cvsignore deleted file mode 100644 index 0751b2579..000000000 --- a/Doc/help/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -[_a-zA-Z0-9]* diff --git a/Doc/intro.ms b/Doc/intro.ms index 3aabf1519..60aa01a19 100644 --- a/Doc/intro.ms +++ b/Doc/intro.ms @@ -6,7 +6,7 @@ .if "\*(.T"html" .nr HTML 1 .nr De \n[.ss] .\} -.\" ----- macro defintions ----- +.\" ----- macro definitions ----- .\" Ds/De: start/end of example .\" Sh: section header .\" XXX: It seems we can't use the same definition for both pdf and html @@ -2626,7 +2626,7 @@ foo % .De -With \fICSHJUNKIEQUOTES\fP set, this is illegal, as it is +With \fICSHJUNKIEQUOTES\fP set, this is invalid, as it is in csh. .Ds %\0setopt\0cshjunkiequotes diff --git a/Etc/.cvsignore b/Etc/.cvsignore deleted file mode 100644 index 937897a04..000000000 --- a/Etc/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -Makefile -FAQ -FAQ.html -*.swp diff --git a/Etc/CONTRIBUTORS b/Etc/CONTRIBUTORS index 0c8190a93..7275a8ee8 100644 --- a/Etc/CONTRIBUTORS +++ b/Etc/CONTRIBUTORS @@ -35,7 +35,7 @@ Anderson, arno, Frank Benkstein, Jay Berkenbilt, Frank Blendinger, Zack Cerza, Brendan Cully, Baptiste Daroussin, Danek Duvall, Ryan F, Sean Finney, Daniel Friesel, Alexey I. Froloff, Tobias Gruetzmacher, Pierre Habouzit, Richard Hartmann, Benjamin R. Haskell, Ag. D. Hatzimanikas, -Pete Hollobon, Erik Johansson, Kohsuke Kawaguchi, Dough Kearns, Hannu +Pete Hollobon, Erik Johansson, Kohsuke Kawaguchi, Doug Kearns, Hannu Koivisto, Henryk Konsek, Chris Lamb, Vincent Lefevre, Roger Leigh, Eric Mangold, Max Mikhanosha, Arkadiusz Miskiewicz, Matthieu Moy, Scott Murray, Alexander Myodov, Štěpán Němec, Kalle Olavi Niemitalo, Kazuhiro diff --git a/Etc/creating-a-release.txt b/Etc/creating-a-release.txt index 80fe2b301..631eb3dc8 100644 --- a/Etc/creating-a-release.txt +++ b/Etc/creating-a-release.txt @@ -1,6 +1,6 @@ To create a zsh release: -- Be satisfied that 'master' is releaseable. +- Be satisfied that the branch you're working from is releaseable. (No recent destabilizing changes, `make check` passes, etc) - Bump or update: @@ -11,17 +11,20 @@ To create a zsh release: README (first two paragraphs, 'incompatibilities since' sections) NEWS ('changes since' sections) - The version-number sequence is as follows: + The version-number sequence for master releases 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 + 5.8, 5.8.999.1-dev, 5.8.999.2-test, 5.9, 5.9.999.1-dev, ... + + The version-number sequence for release-branch releases is as follows: + + 5.8, 5.8.0.1-dev, 5.8.0.2-test, 5.8.1, 5.8.1.1-dev, ... 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. + - The versioning scheme has changed a few times in the shell's history. + The current scheme was introduced following the release of zsh 5.9.1. - 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 @@ -52,11 +55,33 @@ To create a zsh release: - If the tagged release is a stable release (as opposed to a test release): - vi Config/version.mk # bump to 5.9.0.1-dev and tomorrow's date + vi Config/version.mk # bump to x.y.z.1-dev and tomorrow's date git commit -am "Post-release version bump." && zshdev-add-nnnnn-and-changelog unposted # or local equivalent (see above) + "x.y.z.1-dev" will be different depending on whether the release was produced + from master or a release branch. Refer to the version sequence above. + +- If the tagged release is a stable release of a new major version produced from + master (the version string is like "5.9"), create a release branch for the + development of minor updates to that version: + + git checkout zsh-5.9 # tag you just created + git switch -c zsh-5.9-patches # release branch + + Then bump the version number there too (see previous step). + + In summary, for a stable release of a new major version like "5.9": + + - Bump 5.8.999.2-test to 5.9 (and update README etc) in master + - Tag zsh-5.9 in master + - Bump 5.9 to 5.9.999.1-dev in master + - Create zsh-5.9-patches branch from zsh-5.9 tag + - Bump 5.9 to 5.9.0.1-dev in zsh-5.9-patches + +- Remember to push all of these changes, including the tag. + - Create tarball: git checkout zsh-5.8.1.2-test diff --git a/Functions/.cvsignore b/Functions/.cvsignore deleted file mode 100644 index 89ff7b089..000000000 --- a/Functions/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -*.swp diff --git a/Functions/Misc/is-at-least b/Functions/Misc/is-at-least index 5985684be..954990dcf 100644 --- a/Functions/Misc/is-at-least +++ b/Functions/Misc/is-at-least @@ -1,62 +1,53 @@ # -# Test whether $ZSH_VERSION (or some value of your choice, if a second argument -# is provided) is greater than or equal to x.y.z-r (in argument one). In fact, -# it'll accept any dot/dash-separated string of numbers as its second argument -# and compare it to the dot/dash-separated first argument. Leading non-number -# parts of a segment (such as the "zefram" in 3.1.2-zefram4) are not considered -# when the comparison is done; only the numbers matter. Any left-out segments -# in the first argument that are present in the version string compared are -# considered as zeroes, eg 3 == 3.0 == 3.0.0 == 3.0.0.0 and so on. +# is-at-least: compare two version strings # -# Usage examples: -# is-at-least 3.1.6-15 && setopt NO_GLOBAL_RCS -# is-at-least 3.1.0 && setopt HIST_REDUCE_BLANKS -# is-at-least 586 $MACHTYPE && echo 'You could be running Mandrake!' -# is-at-least $ZSH_VERSION || print 'Something fishy here.' +# Usage: is-at-least minimum_version [current_version] +# +# Returns true if current_version is equal to or newer than minimum_version. +# If current_version is omitted, $ZSH_VERSION is used. +# {minimum,current}_version is a string consisting of a few 'segments' +# joined by either '.' or '-'. For example: +# 1.2-test 3.1.2-zefram4 +# 4.4.5beta23 12.34-patch23a +# +# A segment with no digits, such as 'test' above, is ignored. +# +# Two segments are compared numerically if the first differing characters +# are both digits, and lexically otherwise. +# +# If number of segments in the two version strings differ, missing +# segments are assumed to be '0'. This means +# 5.9, 5.9.0, 5.9.0.0, 5.9-test +# are all considered to be the same version. # -# Note that segments that contain no digits at all are ignored, and leading -# text is discarded if trailing digits follow, because this was the meaning -# of certain zsh version strings in the early 2000s. Other segments that -# begin with digits are compared using NUMERIC_GLOB_SORT semantics, and any -# other segments starting with text are compared lexically. - emulate -L zsh +setopt extended_glob -local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version order +local IFS=".-" min_ver cur_ver n order : ${2=$ZSH_VERSION} # sort out the easy corner cases first -[[ $1 = $2 ]] && return 0 # same version -[[ -n $2 ]] || return 1 # no version +[[ -z $1 || -z $2 ]] && return 1 # no version +[[ $1 = $2 ]] && return 0 # same version +# split into segments min_ver=(${=1}) -version=(${=2} 0) +cur_ver=(${=2}) -while (( $min_cnt <= ${#min_ver} )); do - while [[ "$part" != <-> ]]; do - (( ++ver_cnt > ${#version} )) && return 0 - if [[ ${version[ver_cnt]} = *[0-9][^0-9]* ]]; then - # Contains a number followed by text. Not a zsh version string. - order=( ${version[ver_cnt]} ${min_ver[ver_cnt]} ) - if [[ ${version[ver_cnt]} = <->* ]]; then - # Leading digits, compare by sorting with numeric order. - [[ $order != ${${(On)order}} ]] && return 1 - else - # No leading digits, compare by sorting in lexical order. - [[ $order != ${${(O)order}} ]] && return 1 - fi - [[ $order[1] != $order[2] ]] && return 0 - fi - part=${version[ver_cnt]##*[^0-9]} - done +# remove segments containing no digits +min_ver=( ${min_ver:#[^0-9]##} ) +cur_ver=( ${cur_ver:#[^0-9]##} ) +(( $#min_ver == 0 || $#cur_ver == 0 )) && return 1 - while true; do - (( ++min_cnt > ${#min_ver} )) && return 0 - [[ ${min_ver[min_cnt]} = <-> ]] && break - done - - (( part > min_ver[min_cnt] )) && return 0 - (( part < min_ver[min_cnt] )) && return 1 - part='' +# find the first segment that differs +for (( n = 1; n <= $#min_ver; ++n )) do + [[ ${min_ver[n]} != ${cur_ver[n]-0} ]] && break done + +# if all segments in $min_ver are equal to those in $cur_ver +(( n > $#min_ver )) && return 0 + +# now compare the two segments that differ +order=( ${cur_ver[n]-0} ${min_ver[n]-0} ) +[[ $order != ${${(On)order}} ]] && return 1 || return 0 diff --git a/Functions/Misc/regexp-replace b/Functions/Misc/regexp-replace index d4408f0f7..86b28c5aa 100644 --- a/Functions/Misc/regexp-replace +++ b/Functions/Misc/regexp-replace @@ -1,91 +1,98 @@ -# Replace all occurrences of a regular expression in a variable. The -# variable is modified directly. Respects the setting of the -# option RE_MATCH_PCRE. +# Replace all occurrences of a regular expression in a scalar variable. +# The variable is modified directly. Respects the setting of the option +# RE_MATCH_PCRE, but otherwise sets the zsh emulation mode. # -# First argument: *name* (not contents) of variable. -# Second argument: regular expression -# Third argument: replacement string. This can contain all forms of -# $ and backtick substitutions; in particular, $MATCH will be replaced -# by the portion of the string matched by the regular expression. +# Arguments: +# +# 1. *name* (not contents) of variable or more generally any lvalue; +# expected to be scalar. +# +# 2. regular expression +# +# 3. replacement string. This can contain all forms of +# $ and backtick substitutions; in particular, $MATCH will be +# replaced by the portion of the string matched by the regular +# expression. Parsing errors are fatal to the shell process. -# we use positional parameters instead of variables to avoid -# clashing with the user's variable. Make sure we start with 3 and only -# 3 elements: -argv=("$1" "$2" "$3") +if (( $# < 2 || $# > 3 )); then + print -ru2 "Usage: $0 <varname> <regexp> [<replacement>]" + return 2 +fi -# $4 records whether pcre is enabled as that information would otherwise -# be lost after emulate -L zsh -4=0 -[[ -o re_match_pcre ]] && 4=1 +local _regexp_replace_use_pcre=0 +[[ -o re_match_pcre ]] && _regexp_replace_use_pcre=1 emulate -L zsh +local _regexp_replace_subject=${(P)1} \ + _regexp_replace_regexp=$2 \ + _regexp_replace_replacement=$3 \ + _regexp_replace_result \ + MATCH MBEGIN MEND -local MATCH MBEGIN MEND local -a match mbegin mend -if (( $4 )); then +if (( _regexp_replace_use_pcre )); then # if using pcre, we're using pcre_match and a running offset # That's needed for ^, \A, \b, and look-behind operators to work # properly. zmodload zsh/pcre || return 2 - pcre_compile -- "$2" && pcre_study || return 2 + pcre_compile -- "$_regexp_replace_regexp" && pcre_study || return 2 - # $4 is the current *byte* offset, $5, $6 reserved for later use - 4=0 6= + local _regexp_replace_offset=0 _regexp_replace_start _regexp_replace_stop _regexp_replace_new ZPCRE_OP + local -a _regexp_replace_finds - local ZPCRE_OP - while pcre_match -b -n $4 -- "${(P)1}"; do - # append offsets and computed replacement to the array - # we need to perform the evaluation in a scalar assignment so that if - # it generates an array, the elements are converted to string (by + while pcre_match -b -n $_regexp_replace_offset -- "$_regexp_replace_subject"; do + # we need to perform the evaluation in a scalar assignment so that + # if it generates an array, the elements are converted to string (by # joining with the first character of $IFS as usual) - 5=${(e)3} - argv+=(${(s: :)ZPCRE_OP} "$5") + _regexp_replace_new=${(Xe)_regexp_replace_replacement} + + _regexp_replace_finds+=( ${(s[ ])ZPCRE_OP} "$_regexp_replace_new" ) # for 0-width matches, increase offset by 1 to avoid # infinite loop - 4=$((argv[-2] + (argv[-3] == argv[-2]))) + (( _regexp_replace_offset = _regexp_replace_finds[-2] + (_regexp_replace_finds[-3] == _regexp_replace_finds[-2]) )) done - (($# > 6)) || return # no match + (( $#_regexp_replace_finds )) || return # no match - set +o multibyte + unsetopt multibyte - # $5 contains the result, $6 the current offset - 5= 6=1 - for 2 3 4 in "$@[7,-1]"; do - 5+=${(P)1[$6,$2]}$4 - 6=$(($3 + 1)) + _regexp_replace_offset=1 + for _regexp_replace_start _regexp_replace_stop _regexp_replace_new in "$_regexp_replace_finds[@]"; do + _regexp_replace_result+=${_regexp_replace_subject[_regexp_replace_offset,_regexp_replace_start]}$_regexp_replace_new + (( _regexp_replace_offset = _regexp_replace_stop + 1 )) done - 5+=${(P)1[$6,-1]} -else + _regexp_replace_result+=${_regexp_replace_subject[_regexp_replace_offset,-1]} + +else # no PCRE # in ERE, we can't use an offset so ^, (and \<, \b, \B, [[:<:]] where # available) won't work properly. - # $4 is the string to be matched - 4=${(P)1} - - while [[ -n $4 ]]; do - if [[ $4 =~ $2 ]]; then - # append initial part and substituted match - 5+=${4[1,MBEGIN-1]}${(e)3} - # truncate remaining string - if ((MEND < MBEGIN)); then - # zero-width match, skip one character for the next match - ((MEND++)) - 5+=${4[1]} - fi - 4=${4[MEND+1,-1]} - # indicate we did something - 6=1 - else - break + local _regexp_replace_ok=0 + while [[ $_regexp_replace_subject =~ $_regexp_replace_regexp ]]; do + # append initial part and substituted match + _regexp_replace_result+=$_regexp_replace_subject[1,MBEGIN-1]${(Xe)_regexp_replace_replacement} + # truncate remaining string + if (( MEND < MBEGIN )); then + # zero-width match, skip one character for the next match + (( MEND++ )) + _regexp_replace_result+=$_regexp_replace_subject[MBEGIN] fi + _regexp_replace_subject=$_regexp_replace_subject[MEND+1,-1] + _regexp_replace_ok=1 + [[ -z $_regexp_replace_subject ]] && break done - [[ -n $6 ]] || return # no match - 5+=$4 + (( _regexp_replace_ok )) || return + _regexp_replace_result+=$_regexp_replace_subject fi -eval $1=\$5 +# assign result to target variable if at least one substitution was +# made. At this point, if the variable was originally array or assoc, it +# is converted to scalar. If $1 doesn't contain a valid lvalue +# specification, an exception is raised (exits the shell process if +# non-interactive). +: ${(P)1::="$_regexp_replace_result"} + diff --git a/Functions/Misc/zgetopt b/Functions/Misc/zgetopt index 718381cbd..4d5481abd 100755 --- a/Functions/Misc/zgetopt +++ b/Functions/Misc/zgetopt @@ -6,13 +6,16 @@ emulate -L zsh -o extended_glob zmodload -i zsh/zutil || return 3 +local func=${funcstack[1]:-${0:t}} local caller=${funcstack[2]:-${ZSH_ARGZERO:t}} -local errname=$caller:${0:t} +local errname=$caller:$func local optspec pat i posix=0 local -a match mbegin mend optvv argvv local -a array lopts sopts name local -a specs no_arg_opts req_arg_opts opt_arg_opts tmp +[[ $zsh_eval_context[-1] == toplevel ]] && errname=$func + # same as leading + in short-opts spec (( $+POSIXLY_CORRECT )) && posix=1 @@ -22,7 +25,7 @@ zparseopts -n $errname -D -F -G - \ {n,-name}:-=name \ {o,-options}:-=sopts \ || { - print -ru2 "usage: ${0:t} [-A <array>] [-l <spec>] [-n <name>] [-o <spec>] -- <arg> ..." + print -ru2 "usage: $func [-A <array>] [-l <spec>] [-n <name>] [-o <spec>] -- <arg> ..." return 2 } @@ -31,7 +34,7 @@ name=( ${(@)name/#(-n|--name=)/} ) (( $#array )) && array=( "${(@)array/#(-A|--array=)/}" ) -if [[ $zsh_eval_context[-1] == shfunc ]]; then +if [[ $zsh_eval_context[-1] != toplevel ]]; then [[ $array == *[^A-Za-z0-9_.]* ]] && { print -ru2 - "$errname: invalid array name: $array" return 2 @@ -165,7 +168,7 @@ if [[ -n $array ]]; then trap "$array=( ${(j< >)${(@q+)optvv}} -- ${(j< >)${(@q+)argvv}} )" EXIT # called as function, print -elif [[ $zsh_eval_context[-1] == shfunc ]]; then +elif [[ $zsh_eval_context[-1] != toplevel ]]; then print -r - "${(@q+)optvv}" -- "${(@q+)argvv}" # called as a script, print. use unconditional single-quoting. this is ugly but diff --git a/Functions/Misc/zmv b/Functions/Misc/zmv index 2002af5a6..ed4868346 100644 --- a/Functions/Misc/zmv +++ b/Functions/Misc/zmv @@ -183,7 +183,7 @@ repl=$2 shift 2 if [[ -n $opt_s && $action != ln ]]; then - print -r -- "$myname: invalid option: -s" >&2 + print -r -- "$myname: bad option: -s" >&2 return 1 fi @@ -28,17 +28,30 @@ README to see if you are affected. In region_highlight and zle_highlight, italic and faint can be specified as font attributes for terminals that support them. +Additionally, a layer number can be specified using layer= to indicate +precedence where highlighted regions overlap, and colours can be mixed +with a previous layer's using opacity=. -Highlighting groups can be referenced in region_highlight, -zle_highlight, WATCHFMT and completion explanation strings for -common attribute combinations and a layer can be specified to -indicate precedence where highlighted regions overlap. -Highlighting groups are also supported in the prompt via a new %H -prompt escape. +Highlighting groups with arbitrary text attribute combinations can be +defined via the .zle.hlgroups parameter. These groups can be referenced +by name in region_highlight and zle_highlight via hl=, and in prompt +expansion, WATCHFMT, and completion explanation strings via the %H +escape sequence. Ellipsis markers shown by the line editor to indicate where the line doesn't fit in the terminal can be highlighted. +The shell now keeps track of various terminal settings and capabilities, +such as support for 24-bit colour, via .term.extensions and related +parameters. By default the terminal is queried to determine the +appropriate values when ZLE starts. + +The zsh/nearcolor module is automatically loaded when an RGB hex triplet +is used and the terminal doesn't support 24-bit colour. + +The shape and colour of the terminal cursor can be controlled, similarly +to highlight regions, via the zle_cursorform parameter. + The ERR_EXIT and ERR_RETURN options were refined to be more self- consistent and better aligned with the POSIX-2017 specification of `set -e`. For details on what exactly changed, see the list of @@ -54,6 +67,16 @@ NTP, etc. For the most part this is transparent to users. However, as a side effect, some features like $SECONDS and the time keyword gained (nominal) nanosecond precision. +POSIX real-time signals (SIGRTMIN etc) are now supported by the kill +and trap builtins, TRAP* functions, and the signals parameter, where +available. + +The kill builtin learnt a new option -q to send the signal via +sigqueue(3) along with an arbitrary integer value, where available. + +The kill builtin also learnt a new -L option to print a list of all +known signal numbers and their names. + The zsh/zutil module's zparseopts builtin learnt the following: - a new -G option enables GNU-style argument parsing @@ -80,6 +103,9 @@ and zrand_int() math functions. The shell keyword time now works on builtins, assignments, and current-shell actions. +The new completion helper _as_if can be used to complete one command as +if it were another command with particular arguments. + The new completion helper _shadow can be used to temporarily wrap or substitute a function. The contrib function mkshadow makes it easier to use outside of completion contexts. @@ -89,8 +115,28 @@ The zsh/mathfunc module now provides isnan() and isinf() functions. The getopts builtin learnt a -p option to make it behave like the POSIX_BUILTINS option has been temporarily enabled. -Changes since 5.8.1 -------------------- +The shell now keeps track of the 'current' job inside subshells. This +enables some job-control features (disown without arguments, the %% job +spec, etc) to work where they previously didn't. + +The disown builtin learnt a new -a option to disown all jobs. + +The zsh/zutil module's zformat builtin learnt two new options, -q and +-Q, to escape '%' characters in format strings and/or specs so further +processing can be applied to the result. Quoting of each spec can also +be controlled via the spec prefixes '%' and '%%'. + +A 'math' context now appears in $zsh_eval_context within arithmetic +constructs. This can be used to create dual-purpose math functions. + +The shell now preserves COLUMNS and LINES from the environment when run +non-interactively. + +The completion helper _call_program learnt two new options, -q and -Q, +to quote its arguments before passing them to eval. + +Changes from 5.8.1 to 5.9 +------------------------- zsh 5.9 is dedicated to the memory of Sven Guckes, who was, amongst other things, a long-time zsh advocate. For more information, see: @@ -102,6 +102,13 @@ consistent and better aligned with the POSIX-2017 specification of f() { { false; echo "This is printed only since 5.10." } || true } if f; then true; fi +The vcs_info git back-end now respects the get-unapplied style as +documented. As a result it may omit information it previously showed +during rebase and cherry-pick operations. The previous behaviour can be +restored by setting the style as follows: + + zstyle ':vcs_info:git*:*:*' get-unapplied true + PCRE support is now PCRE2. Parameter names may begin with a "." and follow a relaxed implementation @@ -160,6 +167,42 @@ enabled. Additionally, as a consequence of learning the related -p option, an opt spec beginning with a hyphen must be guarded by - or --. (Note that the effect of a hyphen in the opt spec is unspecified.) +The zsh/zutil module's zformat builtin now interprets the sequences %% +and %) differently. Previously they were implemented via implicit +specs, which could lead to unexpected behaviour in some (uncommon) +circumstances. + +Local parameters are no longer converted to named directories. For +example, the following now emits an error (assuming there is no other +candidate for ~b): + + () { local b=/bin; cd ~b } + +Completion utility functions like _description now escape '%' characters +in most format specs by default, eliminating the need for function +authors to manually escape them in _arguments optarg descriptions, etc. +'%' characters output by some third-party functions may appear doubled +until they're updated to account for this. + +Previously, the (w) subscript flag coerced an out-of-range index to the +nearest in-range one. (e.g., given x='a b c', $x[(w)4] expanded to c.) +This has been changed so that an out-of-range index now yields an empty +string, as in other subscripting cases. + +Assignment and expansion via ${name=word}, ${name:=word}, and +${name::=word} now respect parameter attributes (e.g. `typeset -u`) and +generally behave more consistently, especially when name contains a +subscript. + +The behaviour of the is-at-least function has been improved. Notably, +`is-at-least 5.9.0.3 5.9` now correctly returns false. Also, segments +containing non-digit characters are now compared numerically instead of +lexicographically if possible. + +The completion helper _message now has more regular option parsing. As +a consequence it is always necessary to guard a message beginning with a +hyphen by - or --. + Incompatibilities between 5.8.1 and 5.9 --------------------------------------- diff --git a/Src/.cvsignore b/Src/.cvsignore deleted file mode 100644 index 47b31911f..000000000 --- a/Src/.cvsignore +++ /dev/null @@ -1,35 +0,0 @@ -*.dll -*.epro -*.export -*.mdh -*.mdh.tmp -*.mdhi -*.mdhs -*.o -*.o.c -*.so -*.swp -*.syms -Makefile -Makemod.in Makemod -[_a-zA-Z0-9]*.pro -ansi2knr -bltinmods.list -cscope.out -libzsh.so* -modules-bltin -modules.index -modules.index.tmp -modules.stamp -patchlevel.h -sigcount.h -signames.c signames2.c -stamp-modobjs -stamp-modobjs.tmp -tags TAGS -version.h -zsh -zshcurses.h -zshpaths.h -zshterm.h -zshxmods.h diff --git a/Src/Builtins/.cvsignore b/Src/Builtins/.cvsignore deleted file mode 100644 index 1f8af3e1c..000000000 --- a/Src/Builtins/.cvsignore +++ /dev/null @@ -1,17 +0,0 @@ -Makefile -Makefile.in -*.export -so_locations -*.pro -*.epro -*.syms -*.o -*.o.c -*.so -*.mdh -*.mdhi -*.mdhs -*.mdh.tmp -rlimits.h -*.swp -*.dll diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c index e76c2118d..6184f178b 100644 --- a/Src/Builtins/rlimits.c +++ b/Src/Builtins/rlimits.c @@ -236,7 +236,7 @@ free_resinfo(void) /**/ static int -find_resource(char c) +find_resource(convchar_t c) { int i; for (i=0; i<RLIM_NLIMITS; ++i) { @@ -738,13 +738,14 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) return 1; } res = -1; - if (options && *options == '-') { + if (options && *options++ == '-') { argv++; - while (*++options) { - if(*options == Meta) - *++options ^= 32; + while (*options) { + int sz; + convchar_t opt = unmeta_one(options, &sz); + options += sz; res = -1; - switch (*options) { + switch (opt) { case 'H': hard = 1; continue; @@ -752,8 +753,8 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) soft = 1; continue; case 'N': - if (options[1]) { - number = options + 1; + if (*options) { + number = options; } else if (*argv) { number = *argv++; } else { @@ -768,7 +769,7 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) /* * fake it so it looks like we just finished an option... */ - while (options[1]) + while (*options) options++; break; case 'a': @@ -781,15 +782,15 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) nres = RLIM_NLIMITS; continue; default: - res = find_resource(*options); + res = find_resource(opt); if (res < 0) { /* unrecognised limit */ - zwarnnam(name, "bad option: -%c", *options); + zwarnnam(name, "bad option: -%c", opt); return 1; } break; } - if (options[1]) { + if (*options) { resmask |= 1 << res; nres++; } diff --git a/Src/Builtins/sched.c b/Src/Builtins/sched.c index 835e72cb7..49c66d040 100644 --- a/Src/Builtins/sched.c +++ b/Src/Builtins/sched.c @@ -194,9 +194,10 @@ bin_sched(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) } else if (!strcmp(arg, "o")) { flags |= SCHEDFLAG_TRASH_ZLE; } else { - if (*arg) - zwarnnam(nam, "bad option: -%c", *arg); - else + if (*arg) { + convchar_t warg = unmeta_one(arg, NULL); + zwarnnam(nam, "bad option: -%c", warg); + } else zwarnnam(nam, "option expected"); return 1; } diff --git a/Src/Modules/.cvsignore b/Src/Modules/.cvsignore deleted file mode 100644 index f72db844e..000000000 --- a/Src/Modules/.cvsignore +++ /dev/null @@ -1,18 +0,0 @@ -Makefile -Makefile.in -*.export -so_locations -*.pro -*.epro -*.syms -*.o -*.o.c -*.so -*.mdh -*.mdhi -*.mdhs -*.mdh.tmp -*.swp -errnames.c errcount.h -*.dll -curses_keys.h diff --git a/Src/Modules/cap.c b/Src/Modules/cap.c index 6db7cbc2a..a99e15c88 100644 --- a/Src/Modules/cap.c +++ b/Src/Modules/cap.c @@ -30,8 +30,6 @@ #include "cap.mdh" #include "cap.pro" -#ifdef HAVE_CAP_GET_PROC - static int bin_cap(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) { @@ -116,14 +114,6 @@ bin_setcap(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) return ret; } -#else /* !HAVE_CAP_GET_PROC */ - -# define bin_cap bin_notavail -# define bin_getcap bin_notavail -# define bin_setcap bin_notavail - -#endif /* !HAVE_CAP_GET_PROC */ - /* module paraphernalia */ static struct builtin bintab[] = { diff --git a/Src/Modules/cap.mdd b/Src/Modules/cap.mdd index 905f7ca47..543cf0139 100644 --- a/Src/Modules/cap.mdd +++ b/Src/Modules/cap.mdd @@ -1,5 +1,5 @@ name=zsh/cap -link=dynamic +link=`if test "x$enable_cap" = xyes; then echo dynamic; else echo no; fi` load=no autofeatures="b:cap b:getcap b:setcap" diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c index 5cb03046d..f07ce7fd2 100644 --- a/Src/Modules/curses.c +++ b/Src/Modules/curses.c @@ -1419,7 +1419,7 @@ zccmd_position(const char *nam, char **args) } array[6] = NULL; - !setaparam(args[1], array); + return !setaparam(args[1], array); } diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c index 34f577e30..4df86089e 100644 --- a/Src/Modules/db_gdbm.c +++ b/Src/Modules/db_gdbm.c @@ -38,20 +38,8 @@ #define PM_UPTODATE PM_DONTIMPORT_SUID /* Safe PM_ bit to re-use */ #endif -static Param createhash( char *name, int flags ); -static int append_tied_name( const char *name ); -static int remove_tied_name( const char *name ); -static char *unmetafy_zalloc(const char *to_copy, int *new_len); -static void myfreeparamnode(HashNode hn); - static int no_database_action = 0; -/* - * Make sure we have all the bits I'm using for memory mapping, otherwise - * I don't know what I'm doing. - */ -#if defined(HAVE_GDBM_H) && defined(HAVE_GDBM_OPEN) - #include <gdbm.h> static char *backtype = "db/gdbm"; @@ -112,6 +100,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func)) char *resource_name, *pmname; GDBM_FILE dbf = NULL; int read_write = GDBM_SYNC, pmflags = PM_REMOVABLE|PM_SINGLE; + int fdflags = 0; Param tied_param; if(!OPT_ISSET(ops,'d')) { @@ -124,9 +113,11 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func)) } if (OPT_ISSET(ops,'r')) { read_write |= GDBM_READER; + fdflags |= O_RDONLY; pmflags |= PM_READONLY; } else { read_write |= GDBM_WRCREAT; + fdflags |= O_RDWR|O_CREAT; } /* Here should be a lookup of the backend type against @@ -139,7 +130,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func)) resource_name = OPT_ARG(ops, 'f'); pmname = *args; - if ((tied_param = (Param)paramtab->getnode(paramtab, pmname)) && + if ((tied_param = (Param)realparamtab->getnode(realparamtab, pmname)) && !(tied_param->node.flags & PM_UNSET)) { /* * Unset any existing parameter. Note there's no implicit @@ -159,14 +150,21 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func)) } gdbm_errno=0; - dbf = gdbm_open(resource_name, 0, read_write, 0666, 0); - if(dbf == NULL) { - zwarnnam(nam, "error opening database file %s (%s)", resource_name, gdbm_strerror(gdbm_errno)); + int fd = movefd(open(resource_name, fdflags, 0666)); + if (fd < 0) { + zwarnnam(nam, "error opening database file %s: %e", resource_name, errno); + return 1; + } + dbf = gdbm_fd_open(fd, resource_name, 0, read_write, 0); + if (dbf == NULL) { + zwarnnam(nam, "error opening database file %s: %s", resource_name, gdbm_strerror(gdbm_errno)); + zclose(fd); return 1; } - if (!(tied_param = createhash(pmname, pmflags))) { + if (!(tied_param = creategdbmhash(pmname, pmflags))) { zwarnnam(nam, "cannot create the requested parameter %s", pmname); + fdtable[gdbm_fdesc(dbf)] = FDT_UNUSED; gdbm_close(dbf); return 1; } @@ -191,7 +189,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func)) dbf_carrier->dbfile_path = ztrdup(resource_name); addmodulefd(gdbm_fdesc(dbf), FDT_INTERNAL); - append_tied_name(pmname); + append_tied_name(tied_param->node.nam); return 0; } @@ -205,7 +203,7 @@ bin_zuntie(char *nam, char **args, Options ops, UNUSED(int func)) int ret = 0; for (pmname = *args; *args++; pmname = *args) { - pm = (Param) paramtab->getnode(paramtab, pmname); + pm = (Param) realparamtab->getnode(realparamtab, pmname); if(!pm) { zwarnnam(nam, "cannot untie %s", pmname); ret = 1; @@ -245,7 +243,7 @@ bin_zgdbmpath(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) return 1; } - pm = (Param) paramtab->getnode(paramtab, pmname); + pm = (Param) realparamtab->getnode(realparamtab, pmname); if(!pm) { zwarnnam(nam, "no such parameter: %s", pmname); return 1; @@ -657,7 +655,8 @@ finish_(UNUSED(Module m)) * Utility functions * *********************/ -static Param createhash( char *name, int flags ) { +/**/ +static Param creategdbmhash( char *name, int flags ) { Param pm; HashTable ht; @@ -666,20 +665,11 @@ static Param createhash( char *name, int flags ) { return NULL; } - if (pm->old) - pm->level = locallevel; - /* This creates standard hash. */ ht = pm->u.hash = newparamtable(17, name); - if (!pm->u.hash) { - paramtab->removenode(paramtab, name); - paramtab->freenode(&pm->node); - zwarnnam(name, "out of memory when allocating hash"); - return NULL; - } /* Does free Param (unsetfn is called) */ - ht->freenode = myfreeparamnode; + ht->freenode = freegdbmnode; /* These provide special features */ ht->getnode = ht->getnode2 = getgdbmnode; @@ -692,6 +682,7 @@ static Param createhash( char *name, int flags ) { * Adds parameter name to `zgdbm_tied` */ +/**/ static int append_tied_name( const char *name ) { int old_len = arrlen(zgdbm_tied); char **new_zgdbm_tied = zshcalloc( (old_len+2) * sizeof(char *)); @@ -717,6 +708,7 @@ static int append_tied_name( const char *name ) { * Removes parameter name from `zgdbm_tied` */ +/**/ static int remove_tied_name( const char *name ) { int old_len = arrlen(zgdbm_tied); int new_len; @@ -772,6 +764,8 @@ static int remove_tied_name( const char *name ) { * - does zalloc of exact size for the new string, * - restores work buffer to original content, to restore strlen */ + +/**/ static char * unmetafy_zalloc(const char *to_copy, int *new_len) { char *work, *to_return; @@ -795,8 +789,9 @@ unmetafy_zalloc(const char *to_copy, int *new_len) { return to_return; } +/**/ static void -myfreeparamnode(HashNode hn) +freegdbmnode(HashNode hn) { Param pm = (Param) hn; @@ -817,7 +812,3 @@ myfreeparamnode(HashNode hn) } zfree(pm, sizeof(struct param)); } - -#else -# error no gdbm -#endif /* have gdbm */ diff --git a/Src/Modules/db_gdbm.mdd b/Src/Modules/db_gdbm.mdd index 210c22177..122ba8a36 100644 --- a/Src/Modules/db_gdbm.mdd +++ b/Src/Modules/db_gdbm.mdd @@ -1,5 +1,5 @@ name=zsh/db/gdbm -link='if test "x$ac_cv_lib_gdbm_gdbm_open" = xyes && test "x$ac_cv_header_gdbm_h" = xyes; then +link='if test "x$enable_gdbm" = xyes; then echo dynamic else echo no @@ -10,3 +10,5 @@ load=no autofeatures="b:ztie b:zuntie b:zgdbmpath p:zgdbm_tied" objects="db_gdbm.o" + +libs="@GDBM_LIBS@" diff --git a/Src/Modules/ksh93.c b/Src/Modules/ksh93.c index 159a4fe7c..5204ab8cc 100644 --- a/Src/Modules/ksh93.c +++ b/Src/Modules/ksh93.c @@ -80,6 +80,7 @@ matchgetfn(Param pm) *ap++ = match ? match : ztrdup(""); while (*zsh_match) *ap++ = ztrdup(*zsh_match++); + *ap = NULL; } else pm->u.arr = zarrdup(zsh_match); } else if (isset(KSHARRAYS)) { @@ -196,8 +197,7 @@ ksh93_wrapper(Eprog prog, FuncWrap w, char *name) strcpy(sh_edmode, "\033"); else strcpy(sh_edmode, ""); - if (sh_edchar == sh_unsetval) - sh_edchar = dupstring(getsparam("KEYS")); + sh_edchar = dupstring(getsparam("KEYS")); if (varedarg) { char *ie = itype_end((sh_name = dupstring(varedarg)), INAMESPC, 0); if (ie && *ie) { @@ -266,18 +266,8 @@ boot_(Module m) int cleanup_(Module m) { - struct paramdef *p; - deletewrapper(m, wrapper); - /* Clean up namerefs, otherwise deleteparamdef() is confused */ - for (p = partab; p < partab + sizeof(partab)/sizeof(*partab); ++p) { - if (p->flags & PM_NAMEREF) { - HashNode hn = gethashnode2(paramtab, p->name); - if (hn) - ((Param)hn)->node.flags &= ~PM_NAMEREF; - } - } return setfeatureenables(m, &module_features, NULL); } diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index 6d1f74d22..2bcfe81a3 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -217,10 +217,20 @@ getpmcommand(UNUSED(HashTable ht), const char *name) Cmdnam cmd; Param pm = NULL; - if (!(cmd = (Cmdnam) cmdnamtab->getnode(cmdnamtab, name)) && - isset(HASHLISTALL)) { - cmdnamtab->filltable(cmdnamtab); - cmd = (Cmdnam) cmdnamtab->getnode(cmdnamtab, name); + if (!(cmd = (Cmdnam) cmdnamtab->getnode(cmdnamtab, name))) { + if (isset(HASHLISTALL)) { + cmdnamtab->filltable(cmdnamtab); + cmd = (Cmdnam) cmdnamtab->getnode(cmdnamtab, name); + } else { + /* this will return the path even if hashcmds is disabled, + * and store it in the hash if it is enabled */ + char *found = findcmd((char*)name, 1, 0); + if (found) { + cmd = (Cmdnam) hcalloc(sizeof(*cmd)); + cmd->u.cmd = found; + cmd->node.flags = HASHED; + } + } } pm = (Param) hcalloc(sizeof(struct param)); pm->node.nam = dupstring(name); diff --git a/Src/Modules/pcre.mdd b/Src/Modules/pcre.mdd index 3e1579117..dac271b48 100644 --- a/Src/Modules/pcre.mdd +++ b/Src/Modules/pcre.mdd @@ -5,3 +5,5 @@ load=no autofeatures="b:pcre_compile b:pcre_study b:pcre_match" objects="pcre.o" + +libs="@PCRE_LIBS@" diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c index 2c8a48c28..95235453e 100644 --- a/Src/Modules/socket.c +++ b/Src/Modules/socket.c @@ -56,7 +56,7 @@ static int bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func)) { - int err=1, verbose=0, test=0, targetfd=0; + int verbose=0, test=0, targetfd=0; ZSOCKLEN_T len; struct sockaddr_un soun = { 0 }; int sfd; @@ -119,17 +119,18 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func)) return 1; } - addmodulefd(sfd, FDT_EXTERNAL); - if (targetfd) { sfd = redup(sfd, targetfd); - } - else { - /* move the fd since no one will want to read from it */ + if (sfd == -1) { + zerrnam(nam, "cannot duplicate socket fd to %d: %e", targetfd, errno); + return 1; + } + } else { + targetfd = sfd; /* for error message */ sfd = movefd(sfd); } if (sfd == -1) { - zerrnam(nam, "cannot duplicate fd %d: %e", sfd, errno); + zerrnam(nam, "could not move socket fd %d: %e", targetfd, errno); return 1; } @@ -209,20 +210,20 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func)) return 1; } - addmodulefd(rfd, FDT_EXTERNAL); - if (targetfd) { sfd = redup(rfd, targetfd); - if (sfd < 0) { + if (sfd == -1) { zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno); - zclose(rfd); return 1; } - fdtable[sfd] = FDT_EXTERNAL; + } else { + sfd = movefd(rfd); } - else { - sfd = rfd; + if (sfd == -1) { + zerrnam(nam, "could not move socket fd %d: %e", rfd, errno); + return 1; } + fdtable[sfd] = FDT_EXTERNAL; setiparam_no_convert("REPLY", (zlong)sfd); @@ -236,8 +237,7 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func)) return 1; } - int err = shutdown(atoi(args[0]), SHUT_WR); - if (err) + if (shutdown(atoi(args[0]), SHUT_WR)) zwarn("shutdown failed: %e", errno); } else @@ -262,24 +262,28 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func)) soun.sun_family = AF_UNIX; strncpy(soun.sun_path, args[0], sizeof(soun.sun_path)-1); - if ((err = connect(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))) { + if (connect(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un))) { zwarnnam(nam, "connection failed: %e", errno); close(sfd); return 1; } else { - addmodulefd(sfd, FDT_EXTERNAL); - if (targetfd) { - if (redup(sfd, targetfd) < 0) { + if (redup(sfd, targetfd) == -1) { zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno); - zclose(sfd); return 1; } sfd = targetfd; - fdtable[sfd] = FDT_EXTERNAL; + } else { + targetfd = sfd; /* for error message */ + sfd = movefd(sfd); } + if (sfd == -1) { + zerrnam(nam, "could not move socket fd %d: %e", targetfd, errno); + return 1; + } + fdtable[sfd] = FDT_EXTERNAL; setiparam_no_convert("REPLY", (zlong)sfd); diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c index f7ec06e9e..cb216f33a 100644 --- a/Src/Modules/stat.c +++ b/Src/Modules/stat.c @@ -450,7 +450,8 @@ bin_stat(char *name, char **args, Options ops, UNUSED(int func)) ops->ind['s'] = 1; break; } else { - zwarnnam(name, "bad option: -%c", *arg); + convchar_t warg = unmeta_one(arg, NULL); + zwarnnam(name, "bad option: -%c", warg); return 1; } } diff --git a/Src/Modules/system.c b/Src/Modules/system.c index 3c0b8421a..57daf0d87 100644 --- a/Src/Modules/system.c +++ b/Src/Modules/system.c @@ -556,7 +556,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) #endif while (*args && **args == '-') { - int opt; + convchar_t opt; char *optptr = *args + 1, *optarg; args++; if (!*optptr || !strcmp(optptr, "-")) @@ -653,7 +653,8 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) break; default: - zwarnnam(nam, "flock: unknown option: %c", *optptr); + opt = unmeta_one(optptr, NULL); + zwarnnam(nam, "flock: bad option: %c", opt); return 1; } optptr++; diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c index 4366f3c02..36c3dca37 100644 --- a/Src/Modules/tcp.c +++ b/Src/Modules/tcp.c @@ -489,18 +489,26 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) if (targetfd) { sess->fd = redup(sess->fd, targetfd); + if (sess->fd < 0) { + zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno); + tcp_close(sess); + return 1; + } } else { - /* move the fd since no one will want to read from it */ + targetfd = sess->fd; /* just stashing here for error message */ sess->fd = movefd(sess->fd); } if (sess->fd == -1) { - zwarnnam(nam, "cannot duplicate fd %d: %e", sess->fd, errno); + zwarnnam(nam, "cannot duplicate fd %d: %e", targetfd, errno); tcp_close(sess); return 1; } + /* disallow to be closed explicitly, after movefd set it to INTERNAL */ + fdtable[sess->fd] = FDT_MODULE; + setiparam_no_convert("REPLY", (zlong)sess->fd); if (verbose) @@ -588,19 +596,24 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func)) return 1; } - /* redup expects fd is already registered */ - addmodulefd(rfd, FDT_MODULE); - if (targetfd) { sess->fd = redup(rfd, targetfd); if (sess->fd < 0) { zerrnam(nam, "could not duplicate socket fd to %d: %e", targetfd, errno); + tcp_close(sess); return 1; } } else { - sess->fd = rfd; + sess->fd = movefd(rfd); + } + if (sess->fd < 0) { + zerrnam(nam, "could not move socket fd %d: %e", rfd, errno); + tcp_close(sess); + return 1; } + /* disallow to be closed explicitly */ + fdtable[sess->fd] = FDT_MODULE; setiparam_no_convert("REPLY", (zlong)sess->fd); diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c index fade8f151..2187bec42 100644 --- a/Src/Modules/termcap.c +++ b/Src/Modules/termcap.c @@ -59,7 +59,7 @@ ztgetflag(const char *s) * off, but other curses variants can't, so we fudge it. * * This feature of ncurses appears to have gone away as * * of NCURSES_MAJOR_VERSION == 5, so don't rely on it. */ - switch (tgetflag(s)) { + switch (tgetflag((char *) s)) { case -1: break; case 0: @@ -177,7 +177,7 @@ gettermcap(UNUSED(HashTable ht), const char *name) /* logic in the following cascade copied from echotc, above */ - if ((num = tgetnum(name)) != -1) { + if ((num = tgetnum((char *) name)) != -1) { pm->gsu.i = &nullsetinteger_gsu; pm->u.val = num; pm->node.flags |= PM_INTEGER; @@ -197,7 +197,7 @@ gettermcap(UNUSED(HashTable ht), const char *name) pm->node.flags |= PM_SCALAR; return &pm->node; } - if ((tcstr = tgetstr(name, &u)) != NULL && tcstr != (char *)-1) { + if ((tcstr = tgetstr((char *) name, &u)) != NULL && tcstr != (char *)-1) { pm->u.str = dupstring(tcstr); pm->node.flags |= PM_SCALAR; } else { diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c index 7ce162e81..1df5f5c30 100644 --- a/Src/Modules/terminfo.c +++ b/Src/Modules/terminfo.c @@ -164,15 +164,16 @@ getterminfo(UNUSED(HashTable ht), const char *name) pm->node.nam = dupstring(name); pm->node.flags = PM_READONLY; - if (((num = tigetnum(name)) != -1) && (num != -2)) { + if (((num = tigetnum((char *) name)) != -1) && (num != -2)) { pm->u.val = num; pm->node.flags |= PM_INTEGER; pm->gsu.i = &nullsetinteger_gsu; - } else if ((num = tigetflag(name)) != -1) { + } else if ((num = tigetflag((char *) name)) != -1) { pm->u.str = num ? dupstring("yes") : dupstring("no"); pm->node.flags |= PM_SCALAR; pm->gsu.s = &nullsetscalar_gsu; - } else if ((tistr = (char *)tigetstr(name)) != NULL && tistr != (char *)-1) { + } else if ((tistr = (char *)tigetstr((char *) name)) != NULL && + tistr != (char *)-1) { pm->u.str = metafy(tistr, -1, META_HEAPDUP); pm->node.flags |= PM_SCALAR; pm->gsu.s = &nullsetscalar_gsu; diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c index c4571c7e7..dc601619f 100644 --- a/Src/Modules/watch.c +++ b/Src/Modules/watch.c @@ -747,9 +747,9 @@ boot_(UNUSED(Module m)) /* These two parameters are only set to defaults if not set. * So setting them in .zshrc will not be enough to load the * module. It's useless until the watch array is set anyway. */ - if (!paramtab->getnode(paramtab, "WATCHFMT")) + if (!realparamtab->getnode2(realparamtab, "WATCHFMT")) setsparam("WATCHFMT", ztrdup_metafy(default_watchfmt)); - if (!paramtab->getnode(paramtab, "LOGCHECK")) + if (!realparamtab->getnode2(realparamtab, "LOGCHECK")) setiparam("LOGCHECK", 60); addprepromptfn(&checksched); diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index ecabf3430..b631c57cf 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -458,7 +458,7 @@ zfunpipe(void) } /* - * Same as movefd(), but don't mark the fd in the zsh tables, + * Same as movefd(), but mark the fd as FDT_MODULE in the zsh tables, * because we only want it closed by zftp. However, we still * need to shift the fd's out of the way of the user-visible 0-9. */ @@ -473,9 +473,10 @@ zfmovefd(int fd) #else int fe = zfmovefd(dup(fd)); #endif - close(fd); + zclose(fd); fd = fe; } + addmodulefd(fd, FDT_MODULE); return fd; } @@ -492,7 +493,7 @@ zfsetparam(char *name, void *val, int flags) Param pm = NULL; int type = (flags & ZFPM_INTEGER) ? PM_INTEGER : PM_SCALAR; - if (!(pm = (Param) paramtab->getnode(paramtab, name)) + if (!(pm = (Param) realparamtab->getnode2(realparamtab, name)) || (pm->node.flags & PM_UNSET)) { /* * just make it readonly when creating, in case user @@ -526,7 +527,7 @@ zfunsetparam(char *name) { Param pm; - if ((pm = (Param) paramtab->getnode(paramtab, name))) { + if ((pm = (Param) realparamtab->getnode2(realparamtab, name))) { pm->node.flags &= ~PM_READONLY; unsetparam_pm(pm, 0, 1); } @@ -1040,7 +1041,7 @@ zfclosedata(void) { if (zfsess->dfd == -1) return; - close(zfsess->dfd); + zclose(zfsess->dfd); zfsess->dfd = -1; } @@ -2034,7 +2035,7 @@ zfgetinfo(char *prompt, int noecho) } if (fgets(instr, 256, stdin) == NULL) - instr[len = 0] = '\0'; + instr[0] = '\0'; else if (instr[len = strlen(instr)-1] == '\n') instr[len] = '\0'; @@ -2559,7 +2560,7 @@ zftp_getput(char *name, char **args, int flags) for (; *args; args++) { char *ln, *rest = NULL; off_t startat = 0; - if (progress && (shfunc = getshfunc("zftp_progress"))) { + if (progress && getshfunc("zftp_progress")) { off_t sz = -1; /* * This calls the SIZE command to get the size for remote @@ -3093,8 +3094,13 @@ bin_zftp(char *name, char **args, UNUSED(Options ops), UNUSED(int func)) break; default: - zwarnnam(name, "preference %c not recognized", *ptr); - break; + { + int sz; + convchar_t p = unmeta_one(ptr, &sz); + ptr += sz - 1; + zwarnnam(name, "preference %c not recognized", p); + break; + } } } } diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index d87e32744..1d381cdc8 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -37,6 +37,13 @@ #endif #endif +#ifdef HAVE_POLL_H +# include <poll.h> +#endif +#if defined(HAVE_POLL) && !defined(POLLIN) +# undef HAVE_POLL +#endif + /* The number of bytes we normally read when given no pattern and the * upper bound on the number of bytes we read (even if we are give a * pattern). */ @@ -447,9 +454,8 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) return 1; } } -#else - addmodulefd(master, FDT_INTERNAL); #endif + addmodulefd(master, FDT_MODULE); p = (Ptycmd) zalloc(sizeof(*p)); @@ -530,15 +536,34 @@ deleteallptycmds(void) /**** a better process handling would be nice */ +#ifdef HAVE_POLL +static void +checkptycmd(Ptycmd cmd) +{ + struct pollfd pfd; + + if (cmd->fin) + return; + pfd.fd = cmd->fd; + pfd.events = POLLIN; + pfd.revents = 0; + if (poll(&pfd, 1, 0) <= 0) + return; /* no events: slave still open, not finished */ + if (pfd.revents & POLLIN) + return; /* data available, not finished */ + /* POLLHUP without POLLIN: slave closed, no data */ + cmd->fin = 1; + zclose(cmd->fd); +} +#else static void checkptycmd(Ptycmd cmd) { unsigned char c; - int r; if (cmd->read != -1 || cmd->fin) return; - if ((r = read(cmd->fd, &c, 1)) <= 0) { + if (read(cmd->fd, &c, 1) <= 0) { if (kill(cmd->pid, 0) < 0) { cmd->fin = 1; zclose(cmd->fd); @@ -547,6 +572,7 @@ checkptycmd(Ptycmd cmd) } cmd->read = (int) c; } +#endif static int ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch) @@ -804,7 +830,7 @@ bin_zpty(char *nam, char **args, Options ops, UNUSED(int func)) OPT_ISSET(ops,'m'))) || (OPT_ISSET(ops,'L') && (OPT_ISSET(ops,'b') || OPT_ISSET(ops,'e') || OPT_ISSET(ops,'m')))) { - zwarnnam(nam, "illegal option combination"); + zwarnnam(nam, "invalid option combination"); return 1; } if (OPT_ISSET(ops,'r') || OPT_ISSET(ops,'w')) { diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c index e50f68ece..fce293dc4 100644 --- a/Src/Modules/zutil.c +++ b/Src/Modules/zutil.c @@ -595,7 +595,7 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) case 'q': min = 2; max = 2; break; case 'g': min = 1; max = 3; break; default: - zwarnnam(nam, "invalid option: %s", args[0]); + zwarnnam(nam, "bad option: %s", args[0]); return 1; } n = arrlen(args) - 1; @@ -809,11 +809,13 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) * olenp *olenp is the size allocated for *outp * endchar Terminator character in addition to `\0' (may be '\0') * presence -F: Ternary expressions test emptyness instead + * quote -q: >0 if instr should be %-quoted + * qspecs qspecs[c] is the number of %s added by %-quoting * skip If 1, don't output, just parse. */ static char *zformat_substring(char* instr, char **specs, char **outp, int *ousedp, int *olenp, int endchar, - int presence, int skip) + int presence, int quote, int *qspecs, int skip) { char *s; @@ -844,6 +846,15 @@ static char *zformat_substring(char* instr, char **specs, char **outp, } else if (*s == '.' || testit) s++; + // next char isn't a legal spec char -- unwind, treat the sequence + // literally + if (!testit && (!*s || *s == '%' || *s == ')' || *s == '-' || *s == '.')) { + // but swallow the % if no -q and this is %% or %) + if (!quote) + start += (s - start == 1 && (*s == '%' || *s == ')')); + s = start; + } + if (testit && (unsigned char) *s) { int actval, testval, endcharl; @@ -861,6 +872,8 @@ static char *zformat_substring(char* instr, char **specs, char **outp, actval = strlen(specs[(unsigned char) *s]); else actval = 1; + // don't count extra %s from quoting when testing this + actval -= qspecs[(unsigned char) *s]; actval = right ? (testval < actval) : (testval >= actval); } else { if (right) /* put the sign back */ @@ -879,20 +892,36 @@ static char *zformat_substring(char* instr, char **specs, char **outp, * Either skip true text and output false text, or * vice versa... unless we are already skipping. */ - if (!(s = zformat_substring(s+1, specs, outp, ousedp, - olenp, endcharl, presence, skip || actval)) || !*s) + if (!(s = zformat_substring(s+1, specs, outp, ousedp, olenp, + endcharl, presence, quote, qspecs, + skip || actval)) || !*s) return NULL; - if (!(s = zformat_substring(s+1, specs, outp, ousedp, - olenp, ')', presence, skip || !actval)) || !*s) + if (!(s = zformat_substring(s+1, specs, outp, ousedp, olenp, + ')', presence, quote, qspecs, + skip || !actval)) || !*s) return NULL; } else if (skip) { continue; } else if ((spec = specs[(unsigned char) *s])) { - int len; + int len, smin = min, smax = max; + + // the assumption with quoted specs is that the output will be + // subject to further % expansion -- adjust width specifiers so + // so that the result will be correct *after* that expansion + if ((smin > 0 || smax > 0) && qspecs[(unsigned char) *s]) { + int i; + for (i = 0; spec[i]; i++) { + if (spec[i] == '%') { + smin += (smin > 0 && i < smin) ? 1 : 0; + smax += (smax > 0 && i < smax) ? 1 : 0; + i++; + } + } + } - if ((len = strlen(spec)) > max && max >= 0) - len = max; - outl = (min >= 0 ? (min > len ? min : len) : len); + if ((len = strlen(spec)) > smax && smax >= 0) + len = smax; + outl = (smin >= 0 ? (smin > len ? smin : len) : len); if (*ousedp + outl >= *olenp) { int nlen = *olenp + outl + 128; @@ -952,44 +981,94 @@ static char *zformat_substring(char* instr, char **specs, char **outp, } static int -bin_zformat(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) +bin_zformat(char *nam, char **args, Options ops, UNUSED(int func)) { - char opt; + unsigned char qopt = OPT_ISSET(ops, 'q') ? 'q' : OPT_ISSET(ops, 'Q') ? 'Q' : 0; int presence = 0; - if (args[0][0] != '-' || !(opt = args[0][1]) || args[0][2]) { - zwarnnam(nam, "invalid argument: %s", args[0]); + if (OPT_ISSET(ops, 'q') && OPT_ISSET(ops, 'Q')) { + zwarnnam(nam, "only one of -qQ allowed"); + return 1; + } + if (OPT_ISSET(ops, 'a') + OPT_ISSET(ops, 'f') + OPT_ISSET(ops, 'F') < 1) { + zwarnnam(nam, "one of -afF expected"); + return 1; + } + if (OPT_ISSET(ops, 'a') + OPT_ISSET(ops, 'f') + OPT_ISSET(ops, 'F') > 1) { + zwarnnam(nam, "only one of -afF allowed"); + return 1; + } + if (OPT_ISSET(ops, 'a') && qopt) { + zwarnnam(nam, "-qQ not allowed with -a"); return 1; } - args++; - switch (opt) { + switch (OPT_ISSET(ops, 'a') ? 'a' : OPT_ISSET(ops, 'f') ? 'f' : 'F') { case 'F': presence = 1; /* fall-through */ case 'f': { - char **ap, *specs[256] = {0}, *out; - int olen, oused = 0; - - specs['%'] = "%"; - specs[')'] = ")"; + char **ap, *specs[256] = {0}, *out, *arg; + int quote, olen, oused = 0; + int qspecs[256] = {0}; /* Parse the specs in argv. */ - for (ap = args + 2; *ap; ap++) { - if (!ap[0][0] || ap[0][0] == '-' || ap[0][0] == '.' || - ap[0][0] == '%' || ap[0][0] == ')' || - idigit(ap[0][0]) || ap[0][1] != ':') { - zwarnnam(nam, "invalid argument: %s", *ap); + for (ap = args + 2; (arg = *ap); ap++) { + // quote by default (spec like d:...) with -qQ + quote = !!qopt; + + // spec like %%d:... -- explicitly disable quoting + if (arg[0] == '%' && arg[1] == '%') { + quote = 0; + arg += 2; + // spec like %d:... -- explicitly enable quoting + } else if (arg[0] == '%') { + quote = 1; + arg += 1; + } + + if (!arg[0] || arg[0] == '-' || arg[0] == '.' || + arg[0] == '%' || arg[0] == ')' || + idigit(arg[0]) || arg[1] != ':') { + zwarnnam(nam, "invalid spec: %s", *ap); return 1; } - specs[(unsigned char) ap[0][0]] = ap[0] + 2; + + if (quote) { + int len = 0, pct = 0; + char *aptr, *sptr, *spec = arg + 2; + + for (aptr = arg + 2; *aptr; aptr++, len++) { + if (*aptr == '%') { + len++, pct++; + } + } + + if (pct) { + spec = (char *) zhalloc(len + 1); + sptr = spec; + for (aptr = arg + 2; *aptr; aptr++) { + *sptr++ = *aptr; + if (*aptr == '%') { + *sptr++ = *aptr; + } + } + *sptr = '\0'; + } + + specs[(unsigned char) *arg] = spec; + qspecs[(unsigned char) *arg] = pct; + } else { + specs[(unsigned char) *arg] = arg + 2; + } } + out = (char *) zhalloc(olen = 128); if (!zformat_substring(args[1], specs, &out, &oused, &olen, '\0', - presence, 0)) { - zwarnnam(nam, "malformed format string"); + presence, qopt == 'q', qspecs, 0)) { + zwarnnam(nam, "malformed format string: %s", args[1]); return 1; } out[oused] = '\0'; @@ -1088,7 +1167,7 @@ bin_zformat(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) } break; } - zwarnnam(nam, "invalid option: -%c", opt); + DPUTS(1, "BUG: unhandled option"); return 1; } @@ -1911,10 +1990,15 @@ bin_zparseopts(char *nam, char **args, Options ops, UNUSED(int func)) while (*++o) { if (!(d = sopts[(unsigned char) *o])) { if (fail) { - if (*o != '-' || o > *pp + 1) - fprintf(stderr, "%s: bad option: -%c\n", progname, *o); - else + if (*o != '-' || o > *pp + 1) { + convchar_t wc = unmeta_one(o, NULL); + fprintf(stderr, "%s: bad option: -", progname); + MB_CHARINIT(); + zputs(MB_NICECHAR(wc), stderr); + fputc('\n', stderr); + } else { fprintf(stderr, "%s: bad option: -%s\n", progname, o); + } return 1; } o = NULL; @@ -2064,7 +2148,7 @@ bin_zparseopts(char *nam, char **args, Options ops, UNUSED(int func)) } static struct builtin bintab[] = { - BUILTIN("zformat", 0, bin_zformat, 3, -1, 0, NULL, NULL), + BUILTIN("zformat", 0, bin_zformat, 2, -1, 0, "afFqQ", NULL), BUILTIN("zparseopts", 0, bin_zparseopts, 0, -1, 0, "a:A:DEFGKMn:v:", NULL), BUILTIN("zregexparse", 0, bin_zregexparse, 3, -1, 0, "c", NULL), BUILTIN("zstyle", 0, bin_zstyle, 0, -1, 0, NULL, NULL), diff --git a/Src/Zle/.cvsignore b/Src/Zle/.cvsignore deleted file mode 100644 index 3295c6b85..000000000 --- a/Src/Zle/.cvsignore +++ /dev/null @@ -1,20 +0,0 @@ -Makefile -Makefile.in -*.export -so_locations -*.pro -*.epro -*.syms -*.o -*.o.c -*.so -*.mdh -*.mdhi -*.mdhs -*.mdh.tmp -thingies.list -widgets.list -zle_things.h -zle_widget.h -*.swp -*.dll diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 54e6146ad..b6a8dd235 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -83,7 +83,7 @@ mod_export int menuacc; /* Brace insertion stuff. */ /**/ -int hasunqu, useqbr, brpcs, brscs; +int useqbr, brpcs, brscs; /* Flags saying in what kind of string we are. */ @@ -307,7 +307,6 @@ do_completion(UNUSED(Hookdef dummy), Compldat dat) *compqstack = (instring == QT_NONE) ? QT_BACKSLASH : (char)instring; compqstack[1] = '\0'; - hasunqu = 0; useline = (wouldinstab ? -1 : (lst != COMP_LIST_COMPLETE)); useexact = isset(RECEXACT); zsfree(compexactstr); @@ -1176,7 +1175,7 @@ check_param(char *s, int set, int test) if (found && p[1] != Inpar && p[1] != Inbrack && p[1] != Snull) { /* This is a parameter expression, not $(...), $[...], $'...'. */ - char *b = p + 1, *e = b, *ie; + char *b = p + 1, *e, *ie; int br = 1, nest = 0; if (*b == Inbrace) { @@ -1719,7 +1718,7 @@ set_comp_sep(void) return 1; owb = offs; offs = soffs; - if ((p = check_param(ns, 0, 1))) { + if (check_param(ns, 0, 1)) { for (p = ns; *p; p++) if (*p == Dnull) *p = '"'; @@ -3288,7 +3287,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp) if ((*ap)->flags & (CMF_NOLIST | CMF_MULT)) nl++; } - /* used -O nosort or -V, don't sort */ + /* used -o nosort or -V, don't sort */ } else { /* didn't use -1 or -2, so remove all duplicates (efficient) */ if (!(flags & CGF_UNIQALL) && !(flags & CGF_UNIQCON)) { @@ -3309,12 +3308,14 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp) } else if (!ap[0]->disp) { /* Mark those, that would show the same string in the list. */ for (dup = 0; bp[0] && !(bp[0])->disp && - !strcmp((*ap)->str, (bp[0])->str); bp = ++sp) { + !strcmp((*ap)->str, (bp[0])->str); bp = ++asp) { (bp[0])->flags |= CMF_MULT; dup = 1; } - if (dup) + if (dup) { (*ap)->flags |= CMF_FMULT; + asp--; + } } } if (del) { diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c index de3ccdfce..347f5532c 100644 --- a/Src/Zle/compctl.c +++ b/Src/Zle/compctl.c @@ -383,7 +383,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) * cct is a temporary just to hold flags; it never needs freeing. */ struct compctl cct; - char **argv = *av, argv_end[2] = "x"; + char **argv = *av, argv_end[1] = ""; int ready = 0, hx = 0; /* Handle `compctl + foo ...' specially: turn it into @@ -412,10 +412,12 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) for (; !ready && argv[0] && argv[0][0] == '-' && (argv[0][1] || !first);) { if (!argv[0][1]) *argv = "-+"; - while (!ready && *++(*argv)) { - if(**argv == Meta) - *++*argv ^= 32; - switch (**argv) { + ++*argv; + while (!ready && **argv) { + int sz; + convchar_t arg = unmeta_one(*argv, &sz); + *argv += sz; + switch (arg) { case 'f': cct.mask |= CC_FILES; break; @@ -509,17 +511,18 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) case 't': { char *p; + convchar_t s; if (cl) { - zwarnnam(name, "illegal option -%c", **argv); + zwarnnam(name, "bad option: -%c", arg); return 1; } - if ((*argv)[1]) { - p = (*argv) + 1; + if (**argv) { + p = *argv; *argv = argv_end; } else if (!argv[1]) { zwarnnam(name, "retry specification expected after -%c", - **argv); + arg); return 1; } else { p = *++argv; @@ -539,8 +542,8 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) cct.mask2 = CC_DEFCONT; break; default: - zwarnnam(name, "invalid retry specification character `%c'", - *p); + s = unmeta_one(p, NULL); + zwarnnam(name, "invalid retry specification character `%c'", s); return 1; } if (p[1]) { @@ -551,11 +554,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'k': - if ((*argv)[1]) { - cct.keyvar = (*argv) + 1; + if (**argv) { + cct.keyvar = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "variable name expected after -%c", **argv); + zwarnnam(name, "variable name expected after -%c", arg); return 1; } else { cct.keyvar = *++argv; @@ -563,11 +566,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'K': - if ((*argv)[1]) { - cct.func = (*argv) + 1; + if (**argv) { + cct.func = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "function name expected after -%c", **argv); + zwarnnam(name, "function name expected after -%c", arg); return 1; } else { cct.func = *++argv; @@ -580,11 +583,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) case 'X': cct.mask &= ~CC_EXPANDEXPL; expl: - if ((*argv)[1]) { - cct.explain = (*argv) + 1; + if (**argv) { + cct.explain = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "string expected after -%c", **argv); + zwarnnam(name, "string expected after -%c", arg); return 1; } else { cct.explain = *++argv; @@ -592,23 +595,23 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'y': - if ((*argv)[1]) { - cct.ylist = (*argv) + 1; + if (**argv) { + cct.ylist = *argv; *argv = argv_end; } else if (!argv[1]) { zwarnnam(name, "function/variable expected after -%c", - **argv); + arg); } else { cct.ylist = *++argv; *argv = argv_end; } break; case 'P': - if ((*argv)[1]) { - cct.prefix = (*argv) + 1; + if (**argv) { + cct.prefix = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "string expected after -%c", **argv); + zwarnnam(name, "string expected after -%c", arg); return 1; } else { cct.prefix = *++argv; @@ -616,11 +619,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'S': - if ((*argv)[1]) { - cct.suffix = (*argv) + 1; + if (**argv) { + cct.suffix = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "string expected after -%c", **argv); + zwarnnam(name, "string expected after -%c", arg); return 1; } else { cct.suffix = *++argv; @@ -628,11 +631,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'g': - if ((*argv)[1]) { - cct.glob = (*argv) + 1; + if (**argv) { + cct.glob = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "glob pattern expected after -%c", **argv); + zwarnnam(name, "glob pattern expected after -%c", arg); return 1; } else { cct.glob = *++argv; @@ -640,12 +643,12 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 's': - if ((*argv)[1]) { - cct.str = (*argv) + 1; + if (**argv) { + cct.str = *argv; *argv = argv_end; } else if (!argv[1]) { zwarnnam(name, "command string expected after -%c", - **argv); + arg); return 1; } else { cct.str = *++argv; @@ -654,13 +657,13 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) break; case 'l': if (cl) { - zwarnnam(name, "illegal option -%c", **argv); + zwarnnam(name, "bad option: -%c", arg); return 1; - } else if ((*argv)[1]) { - cct.subcmd = (*argv) + 1; + } else if (**argv) { + cct.subcmd = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "command name expected after -%c", **argv); + zwarnnam(name, "command name expected after -%c", arg); return 1; } else { cct.subcmd = *++argv; @@ -669,13 +672,13 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) break; case 'h': if (cl) { - zwarnnam(name, "illegal option -%c", **argv); + zwarnnam(name, "bad option: -%c", arg); return 1; - } else if ((*argv)[1]) { - cct.substr = (*argv) + 1; + } else if (**argv) { + cct.substr = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "command name expected after -%c", **argv); + zwarnnam(name, "command name expected after -%c", arg); return 1; } else { cct.substr = *++argv; @@ -683,11 +686,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'W': - if ((*argv)[1]) { - cct.withd = (*argv) + 1; + if (**argv) { + cct.withd = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "path expected after -%c", **argv); + zwarnnam(name, "path expected after -%c", arg); return 1; } else { cct.withd = *++argv; @@ -695,11 +698,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'J': - if ((*argv)[1]) { - cct.gname = (*argv) + 1; + if (**argv) { + cct.gname = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "group name expected after -%c", **argv); + zwarnnam(name, "group name expected after -%c", arg); return 1; } else { cct.gname = *++argv; @@ -707,11 +710,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'V': - if ((*argv)[1]) { - cct.gname = (*argv) + 1; + if (**argv) { + cct.gname = *argv; *argv = argv_end; } else if (!argv[1]) { - zwarnnam(name, "group name expected after -%c", **argv); + zwarnnam(name, "group name expected after -%c", arg); return 1; } else { cct.gname = *++argv; @@ -730,9 +733,9 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) case 'M': if (cclist & COMP_LIST) { cclist |= COMP_LISTMATCH; - } else if ((*argv)[1]) { + } else if (**argv) { if ((cct.matcher = - parse_cmatcher(name, (cct.mstr = (*argv) + 1))) == + parse_cmatcher(name, (cct.mstr = *argv))) == pcm_err) { cct.matcher = NULL; cct.mstr = NULL; @@ -741,7 +744,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) *argv = argv_end; } else if (!argv[1]) { zwarnnam(name, "matching specification expected after -%c", - **argv); + arg); return 1; } else { if ((cct.matcher = @@ -755,16 +758,16 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; case 'H': - if ((*argv)[1]) - cct.hnum = atoi((*argv) + 1); + if (**argv) + cct.hnum = atoi(*argv); else if (argv[1]) cct.hnum = atoi(*++argv); else { - zwarnnam(name, "number expected after -%c", **argv); + zwarnnam(name, "number expected after -%c", arg); return 1; } if (!argv[1]) { - zwarnnam(name, "missing pattern after -%c", **argv); + zwarnnam(name, "missing pattern after -%c", arg); return 1; } cct.hpat = *++argv; @@ -776,7 +779,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) break; case 'C': if (cl) { - zwarnnam(name, "illegal option -%c", **argv); + zwarnnam(name, "bad option: -%c", arg); return 1; } if (first && !hx) { @@ -788,7 +791,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) break; case 'D': if (cl) { - zwarnnam(name, "illegal option -%c", **argv); + zwarnnam(name, "bad option: -%c", arg); return 1; } if (first && !hx) { @@ -801,7 +804,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) break; case 'T': if (cl) { - zwarnnam(name, "illegal option -%c", **argv); + zwarnnam(name, "bad option: -%c", arg); return 1; } if (first && !hx) { @@ -813,11 +816,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) break; case 'L': if (cl) { - zwarnnam(name, "illegal option -%c", **argv); + zwarnnam(name, "bad option: -%c", arg); return 1; } if (!first || hx) { - zwarnnam(name, "illegal use of -L flag"); + zwarnnam(name, "invalid use of -L flag"); return 1; } cclist |= COMP_LIST; @@ -828,7 +831,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) return 1; } if (!argv[1]) { - zwarnnam(name, "condition expected after -%c", **argv); + zwarnnam(name, "condition expected after -%c", arg); return 1; } if (first) { @@ -845,10 +848,10 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) } break; default: - if (!first && (**argv == '-' || **argv == '+') && !argv[0][1]) - (*argv)--, argv--, ready = 1; + if (!first && (arg == '-' || arg == '+') && !**argv) + *argv -= sz + 1, argv--, ready = 1; else { - zwarnnam(name, "bad option: -%c", **argv); + zwarnnam(name, "bad option: -%c", arg); return 1; } } @@ -857,7 +860,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl) if (*++argv && (!ready || ready == 2) && **argv == '+' && !argv[0][1]) { if (cl) { - zwarnnam(name, "xor'ed completion illegal"); + zwarnnam(name, "xor'ed completion invalid"); return 1; } /* There's an alternative (+) completion: assign @@ -1462,8 +1465,6 @@ printcompctl(char *s, Compctl cc, int printflags, int ispat) while (cc2) { /* loop over conditions */ - c = cc2->cond; - printf(" '"); for (c = cc2->cond; c;) { /* loop over or's */ @@ -2041,6 +2042,13 @@ addmatch(char *s, char *t) } if (!ms) return; + + /* when inserting braces on the command line, always use the quoted length */ + for (bp = brbeg; bp; bp = bp->next) + bp->curpos = bp->qpos; + for (bp = brend; bp; bp = bp->next) + bp->curpos = bp->qpos; + add_match_data(isalt, ms, s, lc, ipre, ripre, isuf, (incompfunc ? dupstring(curcc->prefix) : curcc->prefix), prpre, @@ -2886,7 +2894,7 @@ sep_comp_string(char *ss, char *s, int noffs) return 1; owb = offs; offs = soffs; - if ((p = check_param(ns, 0, 1))) { + if (check_param(ns, 0, 1)) { for (p = ns; *p; p++) if (*p == Dnull) *p = '"'; @@ -3609,8 +3617,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) } else { /* Otherwise ignore the path we * * prepended to the pattern. */ - while ((p2 = p3 = - (char *)ugetnode(l))) { + while ((p3 = (char *) ugetnode(l))) { for (ns = sf1; *p3 && ns; p3++) if (*p3 == '/') ns--; @@ -3657,7 +3664,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) dumphashtable(cmdnamtab, -3); /* And parameter names if autocd and cdablevars are set. */ if (isset(AUTOCD) && isset(CDABLEVARS)) - dumphashtable(paramtab, -4); + dumphashtable(realparamtab, -4); } oaw = addwhat = (cc->mask & CC_QUOTEFLAG) ? -2 : CC_QUOTEFLAG; @@ -3669,7 +3676,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) dumphashtable(optiontab, addwhat); if (cc->mask & CC_VARS) { /* And parameter names. */ - dumphashtable(paramtab, -9); + dumphashtable(realparamtab, -9); addwhat = oaw; } if (cc->mask & CC_BINDINGS) { @@ -3836,7 +3843,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) if ((t = cc->mask & (CC_ARRAYS | CC_INTVARS | CC_ENVVARS | CC_SCALARS | CC_READONLYS | CC_SPECIALS | CC_PARAMS))) /* Add various flavours of parameters. */ - dumphashtable(paramtab, t); + dumphashtable(realparamtab, t); if ((t = cc->mask & CC_SHFUNCS)) /* Add shell functions. */ dumphashtable(shfunctab, t | (cc->mask & (CC_DISCMDS|CC_EXCMDS))); diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c index 5152764b8..96d58d380 100644 --- a/Src/Zle/complete.c +++ b/Src/Zle/complete.c @@ -269,9 +269,10 @@ parse_cmatcher(char *name, char *s) case 'M': fl = CMF_LINE; break; case 'x': break; default: - if (name) - zwarnnam(name, "unknown match specification character `%c'", - *s); + if (name) { + convchar_t c = unmeta_one(s, NULL); + zwarnnam(name, "unknown match specification character `%c'", c); + } return pcm_err; } if (s[1] != ':') { @@ -496,9 +497,16 @@ parse_class(Cpattern p, char *iptr) } /* find end of class. End character can appear literally first. */ - for (optr = iptr; optr == iptr || *optr != endchar; optr++) + for (optr = iptr; optr == iptr || *optr != endchar; optr++) { if (!*optr) return optr; + /* skip POSIX class names like [:alpha:] */ + if (endchar == ']' && *optr == '[' && optr[1] == ':') { + char *nptr = strchr(optr+2, ':'); + if (nptr && nptr[1] == ']') + optr = nptr + 1; + } + } /* * We can always fit the parsed class within the same length * because of the tokenization (including a null byte). @@ -789,10 +797,13 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) argv++; goto ca_args; default: - zwarnnam(name, "bad option: -%c", *p); - zsfree(mstr); - zfree(dat.dpar, dparsize); - return 1; + { + convchar_t c = unmeta_one(p, NULL); + zwarnnam(name, "bad option: -%c", c); + zsfree(mstr); + zfree(dat.dpar, dparsize); + return 1; + } } if (sp) { if (p[1]) { @@ -1156,8 +1167,11 @@ bin_compset(char *name, char **argv, UNUSED(Options ops), UNUSED(int func)) case 'S': test = CVT_SUFPAT; break; case 'q': return set_comp_sep(); default: - zwarnnam(name, "bad option -%c", argv[0][1]); - return 1; + { + convchar_t c = unmeta_one(&argv[0][1], NULL); + zwarnnam(name, "bad option: -%c", c); + return 1; + } } if (argv[0][2]) { sa = argv[0] + 2; @@ -1300,15 +1314,14 @@ addcompparams(struct compparam *cp, Param *pp) Param pm = createparam(cp->name, cp->type |PM_SPECIAL|PM_REMOVABLE|PM_LOCAL); if (!pm) - pm = (Param) paramtab->getnode(paramtab, cp->name); - DPUTS(!pm, "param not set in addcompparams"); + pm = (Param) paramtab->getnode2(paramtab, cp->name); + DPUTS1(!pm, "param %s not set in addcompparams", cp->name); *pp = pm; pm->level = locallevel + 1; if ((pm->u.data = cp->var)) { switch(PM_TYPE(cp->type)) { case PM_SCALAR: - case PM_NAMEREF: pm->gsu.s = &compvarscalar_gsu; break; case PM_INTEGER: @@ -1333,23 +1346,21 @@ void makecompparams(void) { Param cpm; - HashTable tht; addcompparams(comprparams, comprpms); if (!(cpm = createparam( COMPSTATENAME, PM_SPECIAL|PM_REMOVABLE|PM_SINGLE|PM_LOCAL|PM_HASHED))) - cpm = (Param) paramtab->getnode(paramtab, COMPSTATENAME); - DPUTS(!cpm, "param not set in makecompparams"); + cpm = (Param) realparamtab->getnode2(realparamtab, COMPSTATENAME); + DPUTS1(!cpm, "param %s not set in makecompparams", COMPSTATENAME); comprpms[CPN_COMPSTATE] = cpm; - tht = paramtab; cpm->level = locallevel + 1; cpm->gsu.h = &compstate_gsu; cpm->u.hash = paramtab = newparamtable(31, COMPSTATENAME); addcompparams(compkparams, compkpms); - paramtab = tht; + paramtab = realparamtab; } /**/ diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 21d0d6e60..f4d22a968 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -670,7 +670,7 @@ doiscol(int pos) static int clprintfmt(char *p, int ml) { - int cc = 0, i = 0, ask, beg; + int cc = 0, i = 0, ask; initiscol(); @@ -696,7 +696,7 @@ clprintfmt(char *p, int ml) chrlen--; p++; } - if ((beg = !(cc % zterm_columns))) + if (!(cc % zterm_columns)) ml++; if (mscroll && !(cc % zterm_columns) && !--mrestlines && (ask = asklistscroll(ml))) @@ -1072,7 +1072,7 @@ static int compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) { char *p, nc[2*DIGBUFSIZE + 12], nbuf[2*DIGBUFSIZE + 12]; - int l = 0, cc = 0, m, ask, beg, stat; + int l = 0, cc = 0, m, beg, stat; if ((stat = !fmt)) { if (mlbeg >= 0) { @@ -1301,7 +1301,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) ml++; fputs(" \010", shout); } - if (mscroll && beg && !--mrestlines && (ask = asklistscroll(ml))) { + if (mscroll && beg && !--mrestlines && asklistscroll(ml)) { *stop = 1; if (stat && n) mfirstl = -1; @@ -1624,7 +1624,7 @@ compprintlist(int showall) q = p; while (n && i-- && !errflag) { wid = (g->widths ? g->widths[mc] : g->width); - if (!(m = *q)) { + if (!*q) { if (clprintm(g, NULL, mc, ml, (!i), wid)) goto end; break; @@ -2640,6 +2640,7 @@ domenuselect(Hookdef dummy, Chdata dat) } do_last_key = 0; + int was_inter = (mode == MM_INTER); if (!cmd || cmd == Th(z_sendbreak)) { zbeep(); molbeg = -1; @@ -2778,9 +2779,13 @@ domenuselect(Hookdef dummy, Chdata dat) metafy_line(); iforcemenu = 0; - if (cmd != Th(z_acceptandinfernexthistory)) + if (cmd != Th(z_acceptandinfernexthistory)) { modeline = setmstatus(status, saveline, savell, savecs, &modecs, &modell, &modelen); + /* if we are completing a quoted word, by this point we've + * lost track of this, so put we back where it should be */ + we = savecs; + } if (nmatches < 1 || !minfo.cur || !*(minfo.cur)) { nolist = 1; @@ -2822,8 +2827,12 @@ domenuselect(Hookdef dummy, Chdata dat) Menustack s = (Menustack) zhalloc(sizeof(*s)); int ol; - if (mode == MM_INTER) - do_single(*minfo.cur); + if (mode == MM_INTER) { + Cmatch *cur = minfo.cur; + minfo.cur = NULL; + do_single(*cur); + minfo.cur = cur; + } mode = 0; s->prev = u; u = s; @@ -3279,6 +3288,7 @@ domenuselect(Hookdef dummy, Chdata dat) strncpy(zlemetaline, origline, origll); zlemetacs = origcs; minfo.len = modelen; + we = wb + modelen; } else { mode = 0; comprecursive = 1; @@ -3407,6 +3417,8 @@ domenuselect(Hookdef dummy, Chdata dat) acc = 1; break; } + if (was_inter) + minfo.cur = NULL; do_single(**p); mselect = (**p)->gnum; } @@ -3423,7 +3435,12 @@ domenuselect(Hookdef dummy, Chdata dat) clearlist = listshown = 1; if (acc && validlist && minfo.cur) { menucmp = lastambig = hasoldlist = 0; - do_single(*(minfo.cur)); + if (mode == MM_INTER) { + Cmatch *cur = minfo.cur; + minfo.cur = NULL; + do_single(*cur); + } else + do_single(*(minfo.cur)); } if (wasnext || broken) { menucmp = 1; diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index bc82ff4d0..7e0411294 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -189,7 +189,7 @@ free_cline(Cline l) Cline cp_cline(Cline l, int deep) { - Cline r = NULL, *p = &r, t, lp = NULL; + Cline r = NULL, *p = &r, t; while (l) { if ((t = freecl)) @@ -203,7 +203,7 @@ cp_cline(Cline l, int deep) if (t->suffix) t->suffix = cp_cline(t->suffix, 0); } - *p = lp = t; + *p = t; p = &(t->next); l = l->next; } @@ -1250,8 +1250,6 @@ comp_match(char *pfx, char *sfx, char *w, Patprog cp, Cline *clp, int qu, } else *exact = !strcmp(pfx, w); } - if (!qu) - hasunqu = 1; return r; } @@ -2046,7 +2044,7 @@ join_strs(int la, char *sa, int lb, char *sb) NULL, 0); if (rr <= convlen) { ptrdiff_t diff = rp - rs; - int alloclen = (convlen > 20) ? convlen : 20; + int alloclen = (convlen >= 20) ? convlen + 1 : 20; rs = realloc(rs, (rl += alloclen)); rr += alloclen; @@ -2088,7 +2086,7 @@ join_strs(int la, char *sa, int lb, char *sb) lb--; } } - if (la || lb) + if (la || lb || !rp) return NULL; *rp = '\0'; diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index 45f01fef5..e8a6b6422 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -186,7 +186,7 @@ cline_str(Cline l, int ins, int *csp, LinkList posl) if ((brp = brbeg)) { for (bp = brbeg; bp; bp = bp->next) { - bp->curpos = (hasunqu ? bp->pos : bp->qpos); + bp->curpos = bp->qpos; olen -= strlen(bp->str); } } @@ -195,7 +195,7 @@ cline_str(Cline l, int ins, int *csp, LinkList posl) olen -= strlen(bp->str); for (bp = brend; bp; bp = bp->next) - bp->curpos = olen - (hasunqu ? bp->pos : bp->qpos); + bp->curpos = olen - bp->qpos; } while (brp && !brp->curpos) { inststrlen(brp->str, 1, -1); @@ -588,9 +588,7 @@ instmatch(Cmatch m, int *scs) /* Ignored prefix. */ if (m->ipre) { - char *p = m->ipre + (menuacc ? m->qipl : 0); - - inststrlen(p, 1, (l = strlen(p))); + inststrlen(m->ipre, 1, (l = strlen(m->ipre))); r += l; } /* -P prefix. */ @@ -965,10 +963,9 @@ do_single(Cmatch m) int l, sr = 0, scs; int havesuff = 0; int partest = (m->ripre || ((m->flags & CMF_ISPAR) && parpre)); - char *str = m->orig, *ppre = m->ppre, *psuf = m->psuf, *prpre = m->prpre; + char *str = m->orig, *psuf = m->psuf, *prpre = m->prpre; if (!prpre) prpre = ""; - if (!ppre) ppre = ""; if (!psuf) psuf = ""; fixsuffix(); @@ -1085,7 +1082,7 @@ do_single(Cmatch m) } else n = p + 1; - if ((pm = (Param) paramtab->getnode(paramtab, n)) && + if ((pm = (Param) realparamtab->getnode(realparamtab, n)) && PM_TYPE(pm->node.flags) != PM_SCALAR) tryit = 0; } @@ -1138,7 +1135,6 @@ do_single(Cmatch m) /*{{*/ /* Otherwise, add a `,' suffix, and let `}' remove it. */ zlemetacs = scs; - havesuff = 1; inststrlen(",", 1, 1); minfo.insc++; makesuffix(1); @@ -2123,7 +2119,7 @@ printlist(int over, CLPrintFunc printm, int showall) q = p; while (n && i--) { wid = (g->widths ? g->widths[mc] : g->width); - if (!(m = *q)) { + if (!*q) { printm(g, NULL, mc, ml, (!i), wid); break; } diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index 74370d0fc..e666d93ba 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -890,7 +890,7 @@ bin_compdescribe(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) return 1; } } - zwarnnam(nam, "invalid option: %s", args[0]); + zwarnnam(nam, "bad option: %s", args[0]); return 1; } @@ -921,7 +921,8 @@ struct cadef { char *nonarg; /* pattern for non-args (-A argument) */ }; -#define CDF_SEP 1 /* -S was specified: -- terminates options */ +#define CDF_SEP 1 /* -S was specified: -- terminates options */ +#define CDF_ZSEP 2 /* -S -S was specified: - terminates options */ /* Description for an option. */ @@ -1255,7 +1256,7 @@ parse_cadef(char *nam, char **args) if (*p == 's') single = 1; else if (*p == 'S') - flags |= CDF_SEP; + flags |= (flags & CDF_SEP) ? CDF_ZSEP : CDF_SEP; else if (*p == 'A') { if (p[1]) { nonarg = p + 1; @@ -1470,6 +1471,9 @@ parse_cadef(char *nam, char **args) zwarnnam(nam, "invalid option definition: %s", *args); return NULL; } + // treat empty description as if missing + if (p == descr) + descr = NULL; *p++ = '\0'; c = *p; } else @@ -1718,6 +1722,8 @@ get_cadef(char *nam, char **args) * * "d" is a complete set of argument/option definitions to scan. * "line" is the word we are scanning. + * "ign_active" indicates that whether an option def is active or not + * should be ignored when matching * "full" indicates that the option must match a full word; otherwise * we look for "=" arguments or prefixes. * *"end" is set to point to the end of the option, in some cases @@ -1725,24 +1731,25 @@ get_cadef(char *nam, char **args) */ static Caopt -ca_get_opt(Cadef d, char *line, int full, char **end) +ca_get_opt(Cadef d, char *line, int ign_active, int full, char **end) { Caopt p; /* The full string may be an option. */ - for (p = d->opts; p; p = p->next) - if (p->active && !strcmp(p->name, line)) { + for (p = d->opts; p; p = p->next) { + if ((ign_active || p->active) && !strcmp(p->name, line)) { if (end) *end = line + strlen(line); return p; } + } if (!full) { /* The string from the line probably only begins with an option. */ for (p = d->opts; p; p = p->next) - if (p->active && ((!p->args || p->type == CAO_NEXT) ? + if ((ign_active || p->active) && ((!p->args || p->type == CAO_NEXT) ? !strcmp(p->name, line) : strpfx(p->name, line))) { int l = strlen(p->name); if ((p->type == CAO_OEQUAL || p->type == CAO_EQUAL) && @@ -1766,7 +1773,7 @@ ca_get_opt(Cadef d, char *line, int full, char **end) /* Same as above, only for single-letter-style. */ static Caopt -ca_get_sopt(Cadef d, char *line, char **end, LinkList *lp) +ca_get_sopt(Cadef d, char *line, int ign_active, char **end, LinkList *lp) { Caopt p, pp = NULL; char pre = *line++; @@ -1775,8 +1782,8 @@ ca_get_sopt(Cadef d, char *line, char **end, LinkList *lp) *lp = NULL; for (p = NULL; *line; line++) { - if ((sidx = single_index(pre, *line)) != -1 && - (p = d->single[sidx]) && p->active && p->args) { + if (d->single && (sidx = single_index(pre, *line)) != -1 && + (p = d->single[sidx]) && (ign_active || p->active) && p->args) { if (p->type == CAO_NEXT) { if (!l) *lp = l = newlinklist(); @@ -1792,7 +1799,7 @@ ca_get_sopt(Cadef d, char *line, char **end, LinkList *lp) pp = p; break; } - } else if (!p || (p && !p->active)) + } else if (!p || (p && !(ign_active || p->active))) return NULL; pp = (p->name[0] == pre ? p : NULL); p = NULL; @@ -1809,16 +1816,15 @@ static int ca_foreign_opt(Cadef curset, Cadef all, char *option) { Cadef d; - Caopt p; + LinkList l; for (d = all; d; d = d->snext) { if (d == curset) continue; - - for (p = d->opts; p; p = p->next) { - if (!strcmp(p->name, option)) - return 1; - } + if (ca_get_opt(d, option, 1, 0, NULL)) + return 1; + if (ca_get_sopt(d, option, 1, NULL, &l)) + return 1; } return 0; } @@ -1928,7 +1934,7 @@ ca_inactive(Cadef d, char **xor, int cur, int opts) if (a && a->num == n && (!grp || (a->gsname && !strncmp(a->gsname, grp, grplen)))) a->active = 0; - } else if ((opt = ca_get_opt(d, x, 1, NULL)) && + } else if ((opt = ca_get_opt(d, x, 0, 1, NULL)) && (!grp || (opt->gsname && !strncmp(opt->gsname, grp, grplen))) && !(single && *opt->name && opt->name[1] && opt->name[2])) opt->active = 0; @@ -2118,8 +2124,10 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first) ca_inactive(d, argxor, cur - 1, 0); argxor = NULL; } - if ((d->flags & CDF_SEP) && cur != compcurrent && state.actopts && - !strcmp(line, "--")) { + if (cur != compcurrent && state.actopts && + !(state.def && state.inopt) && + (((d->flags & CDF_SEP) && !strcmp(line, "--")) || + ((d->flags & CDF_ZSEP) && !strcmp(line, "-")))) { ca_inactive(d, NULL, cur, 1); state.actopts = 0; continue; @@ -2147,6 +2155,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first) } else if ((state.def = state.def->next)) { state.argbeg = cur; state.argend = argend; + goto cont; } else if (sopts && nonempty(sopts)) { state.curopt = (Caopt) uremnode(sopts, firstnode(sopts)); state.def = state.curopt->args; @@ -2161,6 +2170,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first) } else { state.curopt = NULL; state.opt = 1; + goto cont; } } else { state.opt = state.arg = 1; @@ -2176,7 +2186,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first) /* See if it's an option. */ if (state.opt == 2 && (*line == '-' || *line == '+') && - (state.curopt = ca_get_opt(d, line, 0, &pe)) && + (state.curopt = ca_get_opt(d, line, 0, 0, &pe)) && (state.curopt->type == CAO_OEQUAL ? (compwords[cur] || pe[-1] == '=') : (state.curopt->type == CAO_EQUAL ? @@ -2225,7 +2235,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first) } } else if (state.opt == 2 && d->single && (*line == '-' || *line == '+') && - ((state.curopt = ca_get_sopt(d, line, &pe, &sopts)) || + ((state.curopt = ca_get_sopt(d, line, 0, &pe, &sopts)) || (cur != compcurrent && sopts && nonempty(sopts)))) { /* Or maybe it's a single-letter option? */ @@ -2632,7 +2642,7 @@ bin_comparguments(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) case 'W': min = 3; max = 3; break; case 'n': min = 1; max = 1; break; default: - zwarnnam(nam, "invalid option: %s", args[0]); + zwarnnam(nam, "bad option: %s", args[0]); return 1; } n = arrlen(args) - 1; @@ -2807,7 +2817,7 @@ bin_comparguments(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) subc = newlinklist(); while (lstate) { - opt = ca_get_opt(lstate->d, args[1], 1, NULL); + opt = ca_get_opt(lstate->d, args[1], 0, 1, NULL); if (opt && opt->args) { ret = 0; @@ -3481,7 +3491,6 @@ cv_parse_word(Cvdef d) more[-1] = sav; } else { zaddlinknode(state.vals, tricat(arg, compsuffix, "")); - nosfx = 1; } } else zaddlinknode(state.vals, ztrdup("")); @@ -3525,7 +3534,7 @@ bin_compvalues(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) case 'L': min = 3; max = 4; break; case 'v': min = 1; max = 1; break; default: - zwarnnam(nam, "invalid option: %s", args[0]); + zwarnnam(nam, "bad option: %s", args[0]); return 1; } n = arrlen(args) - 1; @@ -3887,7 +3896,7 @@ bin_comptags(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) case 'S': min = 1; max = 1; break; case 'A': min = 2; max = 3; break; default: - zwarnnam(nam, "invalid option: %s", args[0]); + zwarnnam(nam, "bad option: %s", args[0]); return 1; } n = arrlen(args) - 1; @@ -4680,7 +4689,7 @@ cfp_opt_pats(char **pats, char *matcher) q = dupstring(q); t = q + strlen(q) - 1; if (*t == ')') { - for (s = t--; t > q; t--) + while (--t > q) if (*t == ')' || *t == '|' || *t == '~' || *t == '(') break; if (t != q && *t == '(') @@ -4694,10 +4703,9 @@ cfp_opt_pats(char **pats, char *matcher) for (s = add; *s && !idigit(*s); s++); *s = '\0'; } else if (*q == '[') { - int not; char *x = ++q; - if ((not = (*x == '!' || *x == '^'))) + if (*x == '!' || *x == '^') x++; for (; *x; x++) { if (x[1] == '-' && x[2]) { @@ -5009,7 +5017,7 @@ bin_compfiles(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) case 'p': case 'P': if (args[0][2] && (args[0][2] != '-' || args[0][3])) { - zwarnnam(nam, "invalid option: %s", *args); + zwarnnam(nam, "bad option: %s", *args); return 1; } else { char **tmp; @@ -5037,7 +5045,7 @@ bin_compfiles(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) } case 'i': if (args[0][2]) { - zwarnnam(nam, "invalid option: %s", *args); + zwarnnam(nam, "bad option: %s", *args); return 1; } else { char **tmp; @@ -5093,7 +5101,7 @@ bin_compfiles(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) return ret; } } - zwarnnam(nam, "invalid option: %s", *args); + zwarnnam(nam, "bad option: %s", *args); return 1; } diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c index e26895a2b..e28ff6f35 100644 --- a/Src/Zle/zle_keymap.c +++ b/Src/Zle/zle_keymap.c @@ -1778,7 +1778,6 @@ getkeycmd(void) if(!func) { if (++hops == 20) { zerr("string inserting another one too many times"); - hops = 0; return NULL; } ungetbytes_unmeta(str, strlen(str)); diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index 37d587d02..921ebb9ec 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -1154,7 +1154,7 @@ zlecore(void) break; } handleprefixes(); - /* for vi mode, make sure the cursor isn't somewhere illegal */ + /* for vi mode, make sure the cursor isn't somewhere invalid */ if (invicmdmode() && zlecs > findbol() && (zlecs == zlell || zleline[zlecs] == ZWC('\n'))) DECCS(); @@ -1867,7 +1867,7 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func)) createparam(args[0], type); } queue_signals(); - pm = (Param) paramtab->getnode(paramtab, args[0]); + pm = (Param) realparamtab->getnode(realparamtab, args[0]); if (pm && (PM_TYPE(pm->node.flags) & (PM_ARRAY|PM_HASHED))) { char **a; @@ -2185,6 +2185,14 @@ zle_main_entry(int cmd, va_list ap) break; } + case ZLE_CMD_GET_HIST_LINE: + { + zlong *p = va_arg(ap, zlong *); + *p = histline; + + break; + } + case ZLE_CMD_PREEXEC: mark_output(1); break; diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c index 7f4678683..f13305b78 100644 --- a/Src/Zle/zle_move.c +++ b/Src/Zle/zle_move.c @@ -51,7 +51,7 @@ alignmultiwordleft(int *pos, int setpos) int loccs = *pos; /* generic nothing to do test */ - if (!isset(COMBININGCHARS) || loccs == zlell || loccs == 0) + if (!isset(COMBININGCHARS) || loccs >= zlell || loccs <= 0) return 0; /* need to be on combining character */ @@ -642,7 +642,7 @@ vimatchbracket(UNUSED(char **args)) DECCS(); else INCCS(); - if (zlecs < 0 && zlecs >= zlell) + if (zlecs < 0 || zlecs >= zlell) break; if (zleline[zlecs] == oth) ct--; diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c index 6ac7d4f0a..b828e145c 100644 --- a/Src/Zle/zle_params.c +++ b/Src/Zle/zle_params.c @@ -200,14 +200,13 @@ makezleparams(int ro) Param pm = createparam(zp->name, (zp->type |PM_SPECIAL|PM_REMOVABLE| PM_LOCAL|(ro ? PM_READONLY : 0))); if (!pm) - pm = (Param) paramtab->getnode(paramtab, zp->name); - DPUTS(!pm, "param not set in makezleparams"); + pm = (Param) realparamtab->getnode2(realparamtab, zp->name); + DPUTS1(!pm, "param %s not set in makezleparams", zp->name); pm->level = locallevel + 1; pm->u.data = zp->data; switch(PM_TYPE(zp->type)) { case PM_SCALAR: - case PM_NAMEREF: pm->gsu.s = zp->gsu; break; case PM_ARRAY: diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c index d5309f77c..b3a648056 100644 --- a/Src/Zle/zle_refresh.c +++ b/Src/Zle/zle_refresh.c @@ -1437,26 +1437,60 @@ zrefresh(void) #ifdef MULTIBYTE_SUPPORT if (WC_ISPRINT(*u)) { int width = WCWIDTH(*u); - /* Handle wide characters as above */ - if (width > rpms.sen - rpms.s) { - do { - *rpms.s++ = zr_sp; - } while (rpms.s < rpms.sen); - nbuf[rpms.ln][winw + 1] = zr_nl; - snextline(&rpms); - } - if (width > rpms.sen - rpms.s) { - rpms.s->chr = ZWC('?'); - rpms.s->atr = all_attr; - rpms.s++; - } else { - rpms.s->chr = *u; - rpms.s->atr = 0; - rpms.s++; - while (--width > 0) { - rpms.s->chr = WEOF; + if (width > 0) { + int ichars = 1; + if (isset(COMBININGCHARS) && IS_BASECHAR(*u)) { + for (ichars = 1; u + ichars < outputline + outll; ichars++) + if (!IS_COMBINING(u[ichars])) + break; + } + /* Handle wide characters as above */ + if (width > rpms.sen - rpms.s) { + do { + *rpms.s++ = zr_sp; + } while (rpms.s < rpms.sen); + nbuf[rpms.ln][winw + 1] = zr_nl; + snextline(&rpms); + } + if (width > rpms.sen - rpms.s) { + rpms.s->chr = ZWC('?'); + rpms.s->atr = all_attr; + rpms.s++; + } else { rpms.s->atr = 0; + if (ichars > 1) + addmultiword(rpms.s, u, ichars); + else + rpms.s->chr = *u; rpms.s++; + while (--width > 0) { + rpms.s->chr = WEOF; + rpms.s->atr = 0; + rpms.s++; + } + } + u += ichars - 1; + } else { + /* either the COMBINING_CHARS option is off, + or there was no base character, then render as special */ + char dispchars[11]; + char *dispptr = dispchars; + wchar_t wc; + if ((unsigned)*u > 0xffffU) + sprintf(dispchars, "<%.08x>", (unsigned)*u); + else + sprintf(dispchars, "<%.04x>", (unsigned)*u); + while (*dispptr) { + if (mbtowc(&wc, dispptr, 1) == 1) { + rpms.s->chr = wc; + rpms.s->atr = all_attr; + rpms.s++; + if (rpms.s == rpms.sen) { + nbuf[rpms.ln][winw + 1] = zr_nl; + snextline(&rpms); + } + } + dispptr++; } } } @@ -1475,9 +1509,32 @@ zrefresh(void) rpms.s->atr = all_attr; rpms.s++; } else { +#ifdef MULTIBYTE_SUPPORT + /* non-printable wide char */ + char dispchars[11]; + char *dispptr = dispchars; + wchar_t wc; + if ((unsigned)*u > 0xffffU) + sprintf(dispchars, "<%.08x>", (unsigned)*u); + else + sprintf(dispchars, "<%.04x>", (unsigned)*u); + while (*dispptr) { + if (mbtowc(&wc, dispptr, 1) == 1) { + rpms.s->chr = wc; + rpms.s->atr = all_attr; + rpms.s++; + if (rpms.s == rpms.sen) { + nbuf[rpms.ln][winw + 1] = zr_nl; + snextline(&rpms); + } + } + dispptr++; + } +#else rpms.s->chr = *u; rpms.s->atr = 0; rpms.s++; +#endif } if (rpms.s == rpms.sen) { nbuf[rpms.ln][winw + 1] = zr_nl; /* text wrapped */ @@ -1631,7 +1688,7 @@ zrefresh(void) zfree(obuf[iln], (winw + 2) * sizeof(**obuf)); for (t0 = iln; t0 != olnct; t0++) obuf[t0] = obuf[t0 + 1]; - obuf[--olnct] = NULL; + obuf[olnct--] = NULL; } /* don't try to insert a line if olnct = vmaxln (vmaxln is the number of lines that have been displayed by this routine) so that we don't @@ -1641,6 +1698,7 @@ zrefresh(void) obuf[iln] && !ZR_strncmp(obuf[iln], nbuf[iln + 1], 16)) { moveto(iln, 0); tcout(TCINSLINE); + zfree(obuf[olnct], (winw + 2) * sizeof(**obuf)); for (t0 = olnct; t0 != iln; t0--) obuf[t0] = obuf[t0 - 1]; obuf[iln] = NULL; @@ -2006,7 +2064,7 @@ refreshline(int ln) /* * inserting characters - characters pushed off the right * should be annihilated, but we don't do this if we're on the - * last line lest undesired scrolling occurs due to `illegal' + * last line lest undesired scrolling occurs due to `invalid' * characters on screen */ if (tccan(TCINS) && (vln != zterm_lines - 1)) { diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c index 94e67f838..ce9639531 100644 --- a/Src/Zle/zle_thingy.c +++ b/Src/Zle/zle_thingy.c @@ -683,7 +683,8 @@ bin_zle_flags(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) if (invicmdmode()) { startvichange(-1); if (zmod.flags & (MOD_MULT|MOD_TMULT)) { - Param pm = (Param) paramtab->getnode(paramtab, "NUMERIC"); + Param pm = (Param) + realparamtab->getnode2(realparamtab, "NUMERIC"); if (pm && pm->node.flags & PM_SPECIAL) pm->node.flags &= ~PM_UNSET; } @@ -780,7 +781,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) setbindk = 1; break; default: - zwarnnam(name, "unknown option: %s", *args); + zwarnnam(name, "bad option: %s", *args); goto cleanup_zle_call; } } diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index 77fa5fbe4..8f8776da3 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -437,8 +437,8 @@ checkparams(char *p) int t0, n, l = strlen(p), e = 0; struct hashnode *hn; - for (t0 = paramtab->hsize - 1, n = 0; n < 2 && t0 >= 0; t0--) - for (hn = paramtab->nodes[t0]; n < 2 && hn; hn = hn->next) + for (t0 = realparamtab->hsize - 1, n = 0; n < 2 && t0 >= 0; t0--) + for (hn = realparamtab->nodes[t0]; n < 2 && hn; hn = hn->next) if (pfxlen(p, hn->nam) == l) { n++; if ((int)strlen(hn->nam) == l) @@ -538,7 +538,7 @@ parambeg(char *s) * This is really a parameter expression (not $(...) or $[...] * or $'...'). */ - char *b = p + 1, *e = b; + char *b = p + 1, *e; int n = 0, br = 1; if (*b == Inbrace) { @@ -1512,7 +1512,8 @@ get_comp_string(void) zlemetacs_qsub - wb) { s = NULL; inwhat = IN_MATH; - if ((keypm = (Param) paramtab->getnode(paramtab, varname)) && + if ((keypm = (Param) + realparamtab->getnode(realparamtab, varname)) && (keypm->node.flags & PM_HASHED)) insubscr = 2; else @@ -1612,7 +1613,8 @@ get_comp_string(void) zsfree(varname); varname = ztrdup(nb); *ne = sav; - if ((keypm = (Param) paramtab->getnode(paramtab, varname)) && + if ((keypm = (Param) + realparamtab->getnode(realparamtab, varname)) && (keypm->node.flags & PM_HASHED)) insubscr = 2; } @@ -1655,7 +1657,7 @@ get_comp_string(void) * so start at the beginning of the line and continue * until cspos. */ - wptr = cptr = zlemetaline; + wptr = zlemetaline; for (;;) { cptr = itype_end(wptr, IIDENT, 0); if (cptr == wptr) { @@ -1678,7 +1680,7 @@ get_comp_string(void) char *sqbr = zlemetaline + wb - 1, *cptr, *wptr; /* Need to search forward for word characters */ - cptr = wptr = zlemetaline; + wptr = zlemetaline; for (;;) { cptr = itype_end(wptr, IIDENT, 0); if (cptr == wptr) { @@ -1693,7 +1695,8 @@ get_comp_string(void) if (wptr < sqbr) { zsfree(varname); varname = ztrduppfx(wptr, sqbr - wptr); - if ((keypm = (Param) paramtab->getnode(paramtab, varname)) && + if ((keypm = (Param) + realparamtab->getnode(realparamtab, varname)) && (keypm->node.flags & PM_HASHED)) { if (insubscr != 3) insubscr = 2; @@ -1706,7 +1709,7 @@ get_comp_string(void) } /* This variable will hold the current word in quoted form. */ offs = zlemetacs - wb; - if ((p = parambeg(s))) { + if (parambeg(s)) { for (p = s; *p; p++) if (*p == Dnull) *p = '"'; @@ -1771,9 +1774,9 @@ get_comp_string(void) * \! in double quotes is extracted by the history code before normal * parsing, so sanitize it here, too. */ - if (instring == QT_DOUBLE) { + if (instring == QT_DOUBLE && isset(BANGHIST) && bangchar) { for (q = s; *q; q++) - if (*q == '\\' && q[1] == '!') + if (*q == '\\' && (unsigned char)q[1] == bangchar) *q = Bnull; } } @@ -2205,7 +2208,7 @@ get_comp_string(void) char sav = *lastp; *lastp = '\0'; - untokenize(lastprebr = ztrdup(s)); + untokenize(lastprebr = ztrdup(quotename(s))); *lastp = sav; } if ((lastpostbr = ztrdup(firsts))) diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c index 4c60a5bb7..ff799369f 100644 --- a/Src/Zle/zle_utils.c +++ b/Src/Zle/zle_utils.c @@ -1335,7 +1335,7 @@ showmsg(char const *msg) p++; putc('\n', shout); - up += 1 + cc / zterm_columns; + up += 1 + (cc - 1) / zterm_columns; cc = 0; } else { /* @@ -1386,7 +1386,7 @@ showmsg(char const *msg) c = *++p ^ 32; if(c == '\n') { putc('\n', shout); - up += 1 + cc / zterm_columns; + up += 1 + (cc - 1) / zterm_columns; cc = 0; } else { char const *n = nicechar(c); @@ -1395,7 +1395,7 @@ showmsg(char const *msg) } } #endif - up += cc / zterm_columns; + up += (cc - 1) / zterm_columns; if (clearflag) { putc('\r', shout); diff --git a/Src/builtin.c b/Src/builtin.c index 706191832..ef3cc723b 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -58,7 +58,7 @@ static struct builtin builtins[] = BUILTIN("declare", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%afghi:%klmnp:%rtuxz", NULL), BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "clpv", NULL), BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmprs", NULL), - BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL), + BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, "a", NULL), BUILTIN("echo", BINF_SKIPINVALID, bin_print, 0, -1, BIN_ECHO, "neE", "-"), BUILTIN("emulate", 0, bin_emulate, 0, -1, 0, "lLR", NULL), BUILTIN("enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmprs", NULL), @@ -387,9 +387,8 @@ execbuiltin(LinkList args, LinkList assigns, Builtin bn) /* The above loop may have exited on an invalid option. (We * * assume that any option requiring metafication is invalid.) */ if (*arg) { - if(*arg == Meta) - *++arg ^= 32; - zwarnnam(name, "bad option: %c%c", "+-"[sense], *arg); + convchar_t warg = unmeta_one(arg, NULL); + zwarnnam(name, "bad option: %c%c", "+-"[sense], warg); return 1; } arg = *++argv; @@ -619,18 +618,20 @@ bin_set(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) hadplus |= !action; if(!args[0][1]) *args = "--"; - while (*++*args) { - if(**args == Meta) - *++*args ^= 32; - if(**args != '-' || action) + ++*args; + while (**args) { + int sz; + convchar_t arg = unmeta_one(*args, &sz); + *args += sz; + if(arg != '-' || action) hadopt = 1; /* The pseudo-option `--' signifies the end of options. */ - if (**args == '-') { + if (arg == '-') { hadend = 1; args++; goto doneoptions; - } else if (**args == 'o') { - if (!*++*args) + } else if (arg == 'o') { + if (!**args) args++; if (!*args) { printoptionstates(hadplus); @@ -642,8 +643,8 @@ bin_set(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) else if(dosetopt(optno, action, 0, opts)) zerrnam(nam, "can't change option: %s", *args); break; - } else if(**args == 'A') { - if(!*++*args) + } else if(arg == 'A') { + if(!**args) args++; array = action ? 1 : -1; arrayname = *args; @@ -655,13 +656,13 @@ bin_set(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) goto doneoptions; } break; - } else if (**args == 's') + } else if (arg == 's') sort = action ? 1 : -1; else { - if (!(optno = optlookupc(**args))) - zerrnam(nam, "bad option: -%c", **args); + if (!(optno = optlookupc(arg))) + zerrnam(nam, "bad option: -%c", arg); else if(dosetopt(optno, action, 0, opts)) - zerrnam(nam, "can't change option: -%c", **args); + zerrnam(nam, "can't change option: -%c", arg); } } args++; @@ -803,13 +804,13 @@ set_pwd_env(void) /* update the PWD and OLDPWD shell parameters */ - pm = (Param) paramtab->getnode(paramtab, "PWD"); + pm = (Param) realparamtab->getnode2(realparamtab, "PWD"); if (pm && PM_TYPE(pm->node.flags) != PM_SCALAR) { pm->node.flags &= ~PM_READONLY; unsetparam_pm(pm, 0, 1); } - pm = (Param) paramtab->getnode(paramtab, "OLDPWD"); + pm = (Param) realparamtab->getnode2(realparamtab, "OLDPWD"); if (pm && PM_TYPE(pm->node.flags) != PM_SCALAR) { pm->node.flags &= ~PM_READONLY; unsetparam_pm(pm, 0, 1); @@ -818,10 +819,10 @@ set_pwd_env(void) assignsparam("PWD", ztrdup(pwd), 0); assignsparam("OLDPWD", ztrdup(oldpwd), 0); - pm = (Param) paramtab->getnode(paramtab, "PWD"); + pm = (Param) realparamtab->getnode2(realparamtab, "PWD"); if (!(pm->node.flags & PM_EXPORTED)) addenv(pm, pwd); - pm = (Param) paramtab->getnode(paramtab, "OLDPWD"); + pm = (Param) realparamtab->getnode2(realparamtab, "OLDPWD"); if (!(pm->node.flags & PM_EXPORTED)) addenv(pm, oldpwd); } @@ -2038,13 +2039,8 @@ typeset_single(char *cname, char *pname, Param pm, int func, (on & ~(PM_NAMEREF|PM_LOCAL|PM_READONLY))) { /* Changing type of PM_SPECIAL|PM_AUTOLOAD is a fatal error. * * Should this be a fatal error as well, rather than warning? */ - if (pm->width) - zwarnnam(cname, - "%s: can't change type via subscript reference", - pm->u.str); - else - zwarnnam(cname, "%s: can't change type of a named reference", - pname); + zwarnnam(cname, "%s: can't change type of a named reference", + pname); return NULL; } } @@ -2213,6 +2209,17 @@ typeset_single(char *cname, char *pname, Param pm, int func, on |= PM_EXPORTED; */ } + if (usepm && (on & PM_HIDE) && + (pm->node.flags & (PM_SPECIAL|PM_AUTOLOAD)) && + pm->level <= locallevel) { +#if 0 + zwarnnam(cname, "%s: can't change parameter attribute", pname); + /* return NULL; */ /* this has always been a no-op */ +#else + zerrnam(cname, "%s: can't change parameter attribute", pname); + return NULL; /* this was previously a no-op */ +#endif + } /* * A parameter will be local if @@ -2256,7 +2263,6 @@ typeset_single(char *cname, char *pname, Param pm, int func, return NULL; } if ((on & PM_UNIQUE) && !(pm->node.flags & PM_READONLY & ~off)) { - Param apm; char **x; if (PM_TYPE(pm->node.flags) == PM_ARRAY) { x = (*pm->gsu.a->getfn)(pm); @@ -2267,10 +2273,10 @@ typeset_single(char *cname, char *pname, Param pm, int func, (*pm->gsu.a->setfn)(pm, x); } else if (pm->ename && x) arrfixenv(pm->ename, x); - } else if (PM_TYPE(pm->node.flags) == PM_SCALAR && pm->ename && - (apm = - (Param) paramtab->getnode(paramtab, pm->ename))) { - x = (*apm->gsu.a->getfn)(apm); + } else if (PM_TYPE(pm->node.flags) == PM_SCALAR && pm->ename) { + x = *(pm->node.flags & PM_SPECIAL + ? (char ***)pm->u.data + : ((struct tieddata *)pm->u.data)->arrptr); uniqarray(x); if (x) arrfixenv(pm->node.nam, x); @@ -2280,17 +2286,12 @@ typeset_single(char *cname, char *pname, Param pm, int func, paramtab->printnode(&pm->node, PRINT_TYPESET|PRINT_WITH_NAMESPACE); return pm; } - if (usepm == 2) /* do not change the PM_UNSET flag */ - pm->node.flags = (pm->node.flags | (on & ~PM_READONLY)) & ~off; - else { - /* - * Keep unset if using readonly in POSIX mode. - */ - if (!(on & PM_READONLY) || !isset(POSIXBUILTINS)) - off |= PM_UNSET; - pm->node.flags = (pm->node.flags | - (on & ~PM_READONLY)) & ~off; - } + /* + * Keep unset if using readonly in POSIX mode unless specified otherwise. + */ + if ((usepm != 2) && !((on & PM_READONLY) && isset(POSIXBUILTINS))) + off |= PM_UNSET; + pm->node.flags = (pm->node.flags | (on & ~PM_READONLY)) & ~off; if (on & (PM_LEFT | PM_RIGHT_B | PM_RIGHT_Z)) { if (typeset_setwidth(cname, pm, ops, on, 0)) return NULL; @@ -2525,8 +2526,8 @@ typeset_single(char *cname, char *pname, Param pm, int func, pm = createparam(pname, on & ~PM_READONLY); if (!pm) { if (on & (PM_LEFT | PM_RIGHT_B | PM_RIGHT_Z | - PM_INTEGER | PM_EFLOAT | PM_FFLOAT)) - zerrnam(cname, "can't change variable attribute: %s", pname); + PM_INTEGER | PM_EFLOAT | PM_FFLOAT | PM_NAMEREF)) + zerrnam(cname, "%s: can't change parameter attribute", pname); return NULL; } if (on & (PM_LEFT | PM_RIGHT_B | PM_RIGHT_Z)) { @@ -2698,14 +2699,14 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func) else continue; if (OPT_MINUS(ops,'n')) { - if (bit & ~(PM_READONLY|PM_UPPER|PM_HIDEVAL)) { + if (bit & ~(PM_READONLY|PM_UPPER|PM_HIDEVAL|PM_HIDE)) { zwarnnam(name, "-%c not allowed with -n", optval); /* return 1; */ } } } if (OPT_MINUS(ops,'n')) { - if ((on|off) & ~(PM_READONLY|PM_UPPER|PM_HIDEVAL)) { + if ((on|off) & ~(PM_READONLY|PM_UPPER|PM_HIDEVAL|PM_HIDE)) { /* zwarnnam(name, "no other attributes allowed with -n"); */ return 1; } @@ -3168,11 +3169,11 @@ eval_autoload(Shfunc shf, char *name, Options ops, int func) if (!(shf->node.flags & PM_UNDEFINED)) return 1; - if (shf->funcdef) { - freeeprog(shf->funcdef); - shf->funcdef = &dummy_eprog; - } if (OPT_MINUS(ops,'X')) { + if (shf->funcdef) { + freeeprog(shf->funcdef); + shf->funcdef = &dummy_eprog; + } char *fargv[3]; fargv[0] = quotestring(name, QT_SINGLE_OPTIONAL); fargv[1] = "\"$@\""; @@ -3298,7 +3299,7 @@ add_autoload_function(Shfunc shf, char *funcname) Shfunc shf2; Funcstack fs; const char *calling_f = NULL; - char buf[PATH_MAX+1]; + char buf[PATH_MAX*4]; /* Find calling function */ for (fs = funcstack; fs; fs = fs->prev) { @@ -3315,10 +3316,11 @@ add_autoload_function(Shfunc shf, char *funcname) && (shf2->node.flags & PM_LOADDIR) && (shf2->node.flags & PM_ABSPATH_USED) && shf2->filename) { - if (snprintf(buf, PATH_MAX, "%s/%s", shf2->filename, funcname) < PATH_MAX) + if (snprintf(buf, sizeof(buf), "%s/%s", shf2->filename, funcname) < sizeof(buf)) { /* Set containing directory if the function file * exists (do normal FPATH processing otherwise) */ + unmetafy(buf, NULL); if (!access(buf, R_OK)) { dircache_set(&shf->filename, NULL); dircache_set(&shf->filename, shf2->filename); @@ -3395,7 +3397,7 @@ bin_functions(char *name, char **argv, Options ops, int func) (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)"); + zwarnnam(name, "bad option(s)"); return 1; } @@ -3472,7 +3474,7 @@ bin_functions(char *name, char **argv, Options ops, int func) */ if (on || off || pflags || OPT_ISSET(ops,'X') || OPT_ISSET(ops,'u') || OPT_ISSET(ops,'U') || OPT_ISSET(ops,'w')) { - zwarnnam(name, "invalid option(s)"); + zwarnnam(name, "bad option(s)"); return 1; } if (!*argv) { @@ -3840,10 +3842,9 @@ bin_unset(char *name, char **argv, Options ops, int func) /* record pointer to next, since we may free this one */ next = (Param) pm->node.next; if (pattry(pprog, pm->node.nam)) { - if (!OPT_ISSET(ops,'n') && - (pm->node.flags & PM_NAMEREF) && pm->u.str) - unsetparam(pm->u.str); - else + if (OPT_ISSET(ops,'n') || + ((pm = resolve_nameref(pm)) && + !(pm->node.flags & PM_NAMEREF))) unsetparam_pm(pm, 0, 1); match++; } @@ -3893,8 +3894,7 @@ bin_unset(char *name, char **argv, Options ops, int func) if (!pm) continue; else if (ss) { - if ((pm->node.flags & PM_NAMEREF) && - (!(pm = resolve_nameref(pm)) || pm->width)) { + if ((pm->node.flags & PM_NAMEREF) && !(pm = resolve_nameref(pm))) { /* warning? */ continue; } @@ -3936,22 +3936,11 @@ bin_unset(char *name, char **argv, Options ops, int func) zerrnam(name, "%s: invalid element for unset", s); returnval = 1; } - } else { - if (!OPT_ISSET(ops,'n')) { - int ref = (pm->node.flags & PM_NAMEREF); - if (!(pm = resolve_nameref(pm))) - continue; - if (ref && pm->level < locallevel && - !(pm->node.flags & PM_READONLY)) { - /* Just mark unset, do not remove from table */ - stdunsetfn(pm, 0); - pm->node.flags |= PM_DECLARED; - continue; - } - } + } else if (OPT_ISSET(ops,'n') || + ((pm = resolve_nameref(pm)) && + !(pm->node.flags & PM_NAMEREF))) if (unsetparam_pm(pm, 0, 1)) returnval = 1; - } if (ss) *ss = '['; } @@ -4463,7 +4452,7 @@ bin_alias(char *name, char **argv, Options ops, UNUSED(int func)) OPT_ISSET(ops, 's'); if (type_opts) { if (type_opts > 1) { - zwarnnam(name, "illegal combination of options"); + zwarnnam(name, "invalid combination of options"); return 1; } if (OPT_ISSET(ops,'g')) @@ -5615,7 +5604,7 @@ bin_shift(char *name, char **argv, Options ops, UNUSED(int func)) for (; *argv; argv++) if ((s = getaparam(*argv))) { if (arrlen_lt(s, num)) { - zwarnnam(name, "shift count must be <= $#"); + zwarnnam(name, "shift count must be <= ${#%s}", *argv); ret++; continue; } @@ -5675,6 +5664,7 @@ bin_getopts(UNUSED(char *name), char **argv, Options ops, UNUSED(int func)) char *optstr = unmetafy(*argv++, &lenoptstr), *var = *argv++; char **args = (*argv) ? argv : pparams; char *str, optbuf[2] = " ", *p, opch; + convchar_t wopch; // note that resetting + restoring OPTIND happens in doshfunc(), so using -p // or enabling POSIX_BUILTINS inside a function that calls getopts is not @@ -5716,7 +5706,9 @@ bin_getopts(UNUSED(char *name), char **argv, Options ops, UNUSED(int func)) } optcind++; } - opch = str[optcind++]; + opch = str[optcind]; + MB_CHARINIT(); + optcind += MB_CHARLENCONV(str + optcind, lenstr - optcind, &wopch); if(str[0] == '+') { optbuf[0] = '+'; lenoptbuf = 2; @@ -5738,7 +5730,7 @@ bin_getopts(UNUSED(char *name), char **argv, Options ops, UNUSED(int func)) zoptarg = metafy(optbuf, lenoptbuf, META_DUP); } else { zwarn("bad option: %c%c", - "?-+"[lenoptbuf], opch); + "?-+"[lenoptbuf], wopch); zoptarg=ztrdup(""); } return 0; @@ -5761,7 +5753,7 @@ bin_getopts(UNUSED(char *name), char **argv, Options ops, UNUSED(int func)) setsparam(var, ztrdup("?")); zoptarg = ztrdup(""); zwarn("argument expected after %c%c option", - "?-+"[lenoptbuf], opch); + "?-+"[lenoptbuf], wopch); } return 0; } @@ -5830,13 +5822,13 @@ bin_break(char *name, char **argv, UNUSED(Options ops), int func) switch (func) { case BIN_CONTINUE: if (!loops) { /* continue is only permitted in loops */ - zerrnam(name, "not in while, until, select, or repeat loop"); + zerrnam(name, "not in for, while, until, select, or repeat loop"); return 1; } contflag = 1; /* FALLTHROUGH */ case BIN_BREAK: if (!loops) { /* break is only permitted in loops */ - zerrnam(name, "not in while, until, select, or repeat loop"); + zerrnam(name, "not in for, while, until, select, or repeat loop"); return 1; } breaks = nump ? minimum(num,loops) : 1; @@ -6023,7 +6015,7 @@ zexit(int val, enum zexit_t from_where) killrunjobs(from_where == ZEXIT_SIGNAL); } cleanfilelists(); - if (isset(RCS) && interact) { + if (isset(RCS) && interact && !subsh) { if (!nohistsave) { int writeflags = HFILE_USE_OPTIONS; if (from_where == ZEXIT_SIGNAL) @@ -6031,7 +6023,7 @@ zexit(int val, enum zexit_t from_where) saveandpophiststack(1, writeflags); savehistfile(NULL, 1, writeflags); } - if (islogin && !subsh) { + if (islogin) { sourcehome(".zlogout"); #ifdef GLOBAL_ZLOGOUT if (isset(RCS) && isset(GLOBALRCS)) @@ -6591,8 +6583,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func)) if (OPT_ISSET(ops,'t')) { zlong timeout = 0; if (OPT_HASARG(ops,'t')) { - mnumber mn = zero_mnumber; - mn = matheval(OPT_ARG(ops,'t')); + mnumber mn = matheval(OPT_ARG(ops,'t')); if (errflag) return 1; if (mn.type == MN_FLOAT) { diff --git a/Src/exec.c b/Src/exec.c index 2c730b910..a9ef66477 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -263,6 +263,11 @@ static int doneps4; static char *STTYval; static char *blank_env[] = { NULL }; +/* total allocated elements in zsh_eval_context array */ +static int zsh_eval_context_len; +/* number of in-use elements in zsh_eval_context array */ +static int zsh_eval_context_alen; + /* Execution functions. */ static int (*execfuncs[WC_COUNT-WC_CURSH]) (Estate, int) = { @@ -547,10 +552,11 @@ zexecve(char *pth, char **argv, char **newenvp) for (t0 = 0; t0 != ct; t0++) if (execvebuf[t0] == '\n') break; - if (t0 == ct) + if (t0 == ct) { zerr("%s: bad interpreter: %s: %e", pth, metafy(execvebuf + 2, -1, META_STATIC), eno); - else { + _exit(126); + } else { while (inblank(execvebuf[t0])) execvebuf[t0--] = '\0'; for (ptr = execvebuf + 2; *ptr && *ptr == ' '; ptr++); @@ -574,6 +580,7 @@ zexecve(char *pth, char **argv, char **newenvp) } zerr("%s: bad interpreter: %s: %e", pth, metafy(ptr2, -1, META_STATIC), eno); + _exit(126); } else if (*ptr) { *ptr = '\0'; argv[-2] = ptr2; @@ -693,7 +700,7 @@ search_defpath(char *cmd, char *pbuf, int plen) { char *ps = DEFAULT_PATH, *pe = NULL, *s; - for (ps = DEFAULT_PATH; ps; ps = pe ? pe+1 : NULL) { + for (; ps; ps = pe ? pe+1 : NULL) { pe = strchr(ps, ':'); if (*ps == '/') { s = pbuf; @@ -724,7 +731,7 @@ static void execute(LinkList args, int flags, int defpath) { Cmdnam cn; - char buf[MAXCMDLEN+1], buf2[MAXCMDLEN+1]; + char buf[MAXCMDLEN], buf2[MAXCMDLEN]; char *s, *z, *arg0; char **argv, **pp, **newenvp = NULL; int eno = 0, ee; @@ -748,10 +755,12 @@ execute(LinkList args, int flags, int defpath) zsfree(s); } + argv = makecline(args, flags & BINF_DASH); + /* If ARGV0 is in the commands environment, we use * * that as argv[0] for this external command */ if ((z = zgetenv("ARGV0"))) { - setdata(firstnode(args), (void *) ztrdup(z)); + argv[0] = ztrdup(z); /* * Note we don't do anything with the parameter structure * for ARGV0: that's OK since we're about to exec or exit @@ -766,10 +775,9 @@ execute(LinkList args, int flags, int defpath) /* Else if the pre-command `-' was given, we add `-' * * to the front of argv[0] for this command. */ sprintf(buf2, "-%s", arg0); - setdata(firstnode(args), (void *) ztrdup(buf2)); + argv[0] = ztrdup(buf2); } - argv = makecline(args); if (flags & BINF_CLEARENV) newenvp = blank_env; @@ -785,9 +793,9 @@ execute(LinkList args, int flags, int defpath) } #endif child_unblock(); - if ((int) strlen(arg0) >= PATH_MAX) { + if ((int) ztrlen(arg0) >= PATH_MAX) { zerr("command too long: %s", arg0); - _exit(1); + _exit(127); } for (s = arg0; *s; s++) if (*s == '/') { @@ -803,10 +811,10 @@ execute(LinkList args, int flags, int defpath) /* for command -p, search the default path */ if (defpath) { - char pbuf[PATH_MAX+1]; + char pbuf[MAXCMDLEN]; char *dptr; - if (!search_defpath(arg0, pbuf, PATH_MAX)) { + if (!search_defpath(arg0, pbuf, MAXCMDLEN)) { if (commandnotfound(arg0, args) == 0) _realexit(); zerr("command not found: %s", arg0); @@ -823,28 +831,43 @@ execute(LinkList args, int flags, int defpath) } else { if ((cn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, arg0))) { - char nn[PATH_MAX+1], *dptr; + char nn[MAXCMDLEN], *dptr; - if (cn->node.flags & HASHED) - strcpy(nn, cn->u.cmd); - else { - for (pp = path; pp < cn->u.name; pp++) + if (cn->node.flags & HASHED) { + if (snprintf(nn, sizeof(nn), "%s", cn->u.cmd) >= (int)sizeof(nn) || + ztrlen(nn) >= PATH_MAX) + { + zerr("command too long: %s", arg0); + _exit(127); + } + } else { + for (pp = path; pp < cn->u.name; pp++) { if (!**pp || (**pp == '.' && (*pp)[1] == '\0')) { ee = zexecve(arg0, argv, newenvp); if (isgooderr(ee, *pp)) eno = ee; } else if (**pp != '/') { z = buf; - strucpy(&z, *pp); + struncpy(&z, *pp, sizeof(buf) - 1); *z++ = '/'; + if ((z - buf) + strlen(arg0) >= sizeof(buf)) + continue; strcpy(z, arg0); + if (ztrlen(buf) >= PATH_MAX) + continue; ee = zexecve(buf, argv, newenvp); if (isgooderr(ee, *pp)) eno = ee; } - strcpy(nn, cn->u.name ? *(cn->u.name) : ""); - strcat(nn, "/"); - strcat(nn, cn->node.nam); + } + if (snprintf(nn, sizeof(nn), "%s/%s", + cn->u.name ? *(cn->u.name) : "", + cn->node.nam) >= (int)sizeof(nn) || + ztrlen(nn) >= PATH_MAX) + { + eno = ENAMETOOLONG; + goto execute_skip_exec; + } } ee = zexecve(nn, argv, newenvp); @@ -853,6 +876,7 @@ execute(LinkList args, int flags, int defpath) if (isgooderr(ee, *nn ? nn : "/")) eno = ee; } +execute_skip_exec: for (pp = path; *pp; pp++) if (!(*pp)[0] || ((*pp)[0] == '.' && !(*pp)[1])) { ee = zexecve(arg0, argv, newenvp); @@ -860,9 +884,13 @@ execute(LinkList args, int flags, int defpath) eno = ee; } else { z = buf; - strucpy(&z, *pp); + struncpy(&z, *pp, sizeof(buf) - 1); *z++ = '/'; + if ((z - buf) + strlen(arg0) >= sizeof(buf)) + continue; strcpy(z, arg0); + if (ztrlen(buf) >= PATH_MAX) + continue; ee = zexecve(buf, argv, newenvp); if (isgooderr(ee, *pp)) eno = ee; @@ -908,9 +936,9 @@ findcmd(char *arg0, int docopy, int default_path) return NULL; } cn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, arg0); - if (!cn && isset(HASHCMDS) && !isrelative(arg0)) + if (!cn && isset(HASHCMDS)) cn = hashcmd(arg0, path); - if ((int) strlen(arg0) > PATH_MAX) + if ((int) ztrlen(arg0) >= PATH_MAX) return NULL; if ((s = strchr(arg0, '/'))) { RET_IF_COM(arg0); @@ -920,32 +948,42 @@ findcmd(char *arg0, int docopy, int default_path) } } if (cn) { - char nn[PATH_MAX+1]; + char nn[MAXCMDLEN]; - if (cn->node.flags & HASHED) - strcpy(nn, cn->u.cmd); - else { - for (pp = path; pp < cn->u.name; pp++) + if (cn->node.flags & HASHED) { + if (snprintf(nn, sizeof(nn), "%s", cn->u.cmd) >= (int)sizeof(nn)) { + nn[0] = '\0'; + } + } else { + for (pp = path; pp < cn->u.name; pp++) { if (**pp != '/') { z = buf; if (**pp) { - strucpy(&z, *pp); + struncpy(&z, *pp, sizeof(buf) - 1); *z++ = '/'; + if ((z - buf) + strlen(arg0) >= sizeof(buf)) + continue; } strcpy(z, arg0); RET_IF_COM(buf); } - strcpy(nn, cn->u.name ? *(cn->u.name) : ""); - strcat(nn, "/"); - strcat(nn, cn->node.nam); + } + if (snprintf(nn, sizeof(nn), "%s/%s", + cn->u.name ? *(cn->u.name) : "", + cn->node.nam) >= (int)sizeof(nn)) + { + nn[0] = '\0'; + } } RET_IF_COM(nn); } for (pp = path; *pp; pp++) { z = buf; if (**pp) { - strucpy(&z, *pp); + struncpy(&z, *pp, sizeof(buf) - 1); *z++ = '/'; + if ((z - buf) + strlen(arg0) >= sizeof(buf)) + continue; } strcpy(z, arg0); RET_IF_COM(buf); @@ -975,14 +1013,16 @@ isreallycom(Cmdnam cn) { char fullnam[MAXCMDLEN]; - if (cn->node.flags & HASHED) - strcpy(fullnam, cn->u.cmd); - else if (!cn->u.name) + if (cn->node.flags & HASHED) { + if (snprintf(fullnam, sizeof(fullnam), "%s", cn->u.cmd) + >= (int)sizeof(fullnam)) + return 0; + } else if (!cn->u.name) { return 0; - else { - strcpy(fullnam, *(cn->u.name)); - strcat(fullnam, "/"); - strcat(fullnam, cn->node.nam); + } else { + if (snprintf(fullnam, sizeof(fullnam), "%s/%s", + *(cn->u.name), cn->node.nam) >= (int)sizeof(fullnam)) + return 0; } return iscom(fullnam); } @@ -1011,17 +1051,17 @@ mod_export Cmdnam hashcmd(char *arg0, char **pp) { Cmdnam cn; - char *s, buf[PATH_MAX+1]; + char *s, buf[MAXCMDLEN]; char **pq; - if (*arg0 == '/') + if ((*arg0 == '/') || !strncmp(arg0, "./", 2) || !strncmp(arg0, "../", 3)) return NULL; for (; *pp; pp++) if (**pp == '/') { s = buf; - struncpy(&s, *pp, PATH_MAX); + struncpy(&s, *pp, sizeof(buf) - 1); *s++ = '/'; - if ((s - buf) + strlen(arg0) >= PATH_MAX) + if ((s - buf) + strlen(arg0) >= sizeof(buf)) continue; strcpy(s, arg0); if (iscom(buf)) @@ -1241,30 +1281,44 @@ execstring(char *s, int dont_change_job, int exiting, char *context) popheap(); } +/* append a context to the zsh_eval_context array */ + /**/ mod_export void -execode(Eprog p, int dont_change_job, int exiting, char *context) +zsh_eval_context_push(char *context) { - struct estate s; - static int zsh_eval_context_len; - int alen; - if (!zsh_eval_context_len) { zsh_eval_context_len = 16; - alen = 0; + zsh_eval_context_alen = 0; zsh_eval_context = (char **)zalloc(zsh_eval_context_len * sizeof(*zsh_eval_context)); - } else { - alen = arrlen(zsh_eval_context); - if (zsh_eval_context_len == alen + 1) { - zsh_eval_context_len *= 2; - zsh_eval_context = zrealloc(zsh_eval_context, - zsh_eval_context_len * - sizeof(*zsh_eval_context)); - } + } else if (zsh_eval_context_len == zsh_eval_context_alen + 1) { + zsh_eval_context_len *= 2; + zsh_eval_context = zrealloc(zsh_eval_context, + zsh_eval_context_len * + sizeof(*zsh_eval_context)); } - zsh_eval_context[alen] = context; - zsh_eval_context[alen+1] = NULL; + zsh_eval_context[zsh_eval_context_alen] = context; + zsh_eval_context[++zsh_eval_context_alen] = NULL; +} + +/* remove the last context from the zsh_eval_context array */ + +/**/ +mod_export void +zsh_eval_context_pop(void) +{ + if (zsh_eval_context_alen) + zsh_eval_context[--zsh_eval_context_alen] = NULL; +} + +/**/ +mod_export void +execode(Eprog p, int dont_change_job, int exiting, char *context) +{ + struct estate s; + + zsh_eval_context_push(context); s.prog = p; s.pc = p->prog; @@ -1279,7 +1333,7 @@ execode(Eprog p, int dont_change_job, int exiting, char *context) * zsh_eval_context may have been altered by a recursive * call, but that's OK since we're using the global value. */ - zsh_eval_context[alen] = NULL; + zsh_eval_context_pop(); } /* Execute a simplified command. This is used to execute things that @@ -1500,9 +1554,9 @@ execlist(Estate state, int dont_change_job, int exiting) case WC_SUBLIST_AND: /* If the return code is non-zero, we skip pipelines until * * we find a sublist followed by ORNEXT. */ - if ((ret = ((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_SIMPLE) ? + if (((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_SIMPLE) ? execsimple(state) : - execpline(state, code, Z_SYNC, 0))) || breaks) { + execpline(state, code, Z_SYNC, 0)) || breaks) { state->pc = next; code = *state->pc++; next = state->pc + WC_SUBLIST_SKIP(code); @@ -1533,7 +1587,7 @@ execlist(Estate state, int dont_change_job, int exiting) case WC_SUBLIST_OR: /* If the return code is zero, we skip pipelines until * * we find a sublist followed by ANDNEXT. */ - if (!(ret = ((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_SIMPLE) ? + if (!(((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_SIMPLE) ? execsimple(state) : execpline(state, code, Z_SYNC, 0))) || breaks) { state->pc = next; @@ -2047,7 +2101,7 @@ execpline2(Estate state, wordcode pcode, /**/ static char ** -makecline(LinkList list) +makecline(LinkList list, int dash) { LinkNode node; char **argv, **ptr; @@ -2060,6 +2114,7 @@ makecline(LinkList list) if (!doneps4) printprompt4(); + if (dash) fputs("- ", xtrerr); for (node = firstnode(list); node; incnode(node)) { *ptr++ = (char *)getdata(node); quotedzputs(getdata(node), xtrerr); @@ -2689,11 +2744,8 @@ execsubst(LinkList strs) { if (strs) { prefork(strs, esprefork, NULL); - if (esglob && !errflag) { - LinkList ostrs = strs; + if (esglob && !errflag) globlist(strs, 0); - strs = ostrs; - } } } @@ -3250,14 +3302,17 @@ execcmd_exec(Estate state, Execcmd_params eparams, cflags |= BINF_DASH; break; default: - zerr("unknown exec flag -%c", *cmdopt); - lastval = 1; - errflag |= ERRFLAG_ERROR; - if (forked) - _realexit(); - if (how & Z_TIMED) - shelltime(&shti, &chti, &then, 1); - return; + { + convchar_t opt = unmeta_one(cmdopt, NULL); + zerr("unknown exec flag -%c", opt); + lastval = 1; + errflag |= ERRFLAG_ERROR; + if (forked) + _realexit(); + if (how & Z_TIMED) + shelltime(&shti, &chti, &then, 1); + return; + } } } if (!argnode) @@ -3832,10 +3887,12 @@ execcmd_exec(Estate state, Execcmd_params eparams, bad = 1; } if (!bad && fn->fd1 <= max_zsh_fd) { - if (fn->fd1 >= 10 && - (fdtable[fn->fd1] & FDT_TYPE_MASK) == - FDT_INTERNAL) - bad = 3; + int fdt = fdtable[fn->fd1] & FDT_TYPE_MASK; + if ((fn->fd1 >= 10 && fdt == FDT_INTERNAL) || + fdt == FDT_MODULE) + { + bad = 3 + (fdt == FDT_MODULE); + } } } } @@ -3843,7 +3900,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, const char *bad_msg[] = { "parameter %s does not contain a file descriptor", "can't close file descriptor from readonly parameter %s", - "file descriptor %d used by shell, not closed" + "file descriptor %d used by shell, not closed", + "file descriptor %d used by module, not closed", }; if (bad > 2) zwarn(bad_msg[bad-1], fn->fd1); @@ -3894,6 +3952,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, */ (fn->fd2 <= max_zsh_fd && ((fdtable[fn->fd2] != FDT_UNUSED && + fdtable[fn->fd2] != FDT_MODULE && fdtable[fn->fd2] != FDT_EXTERNAL) || fn->fd2 == coprocin || fn->fd2 == coprocout))) { @@ -4414,14 +4473,16 @@ static void save_params(Estate state, Wordcode pc, LinkList *restore_p, LinkList *remove_p) { Param pm; - char *s; wordcode ac; *restore_p = newlinklist(); *remove_p = newlinklist(); while (wc_code(ac = *pc) == WC_ASSIGN) { - s = ecrawstr(state->prog, pc + 1, NULL); + char *s = ecrawstr(state->prog, pc + 1, NULL); + char *ss = itype_end(s, INAMESPC, 0); + int slen = *ss == '[' || *ss == Inbrack ? ss - s : strlen(s); + addlinknode(*remove_p, s = dupstring_wlen(s, slen)); if ((pm = (Param) paramtab->getnode(paramtab, s))) { Param tpm = NULL; if (pm->env) @@ -4450,11 +4511,9 @@ save_params(Estate state, Wordcode pc, LinkList *restore_p, LinkList *remove_p) tpm->node.nam = pm->node.nam; copyparam(tpm, pm, 1); } - addlinknode(*remove_p, dupstring(s)); if (tpm) addlinknode(*restore_p, tpm); - } else - addlinknode(*remove_p, dupstring(s)); + } pc += (WC_ASSIGN_TYPE(ac) == WC_ASSIGN_SCALAR ? 3 : WC_ASSIGN_NUM(ac) + 2); @@ -5240,7 +5299,7 @@ static int execarith(Estate state, UNUSED(int do_exec)) { char *e; - mnumber val = zero_mnumber; + mnumber val; int htok = 0; if (isset(XTRACE)) { @@ -6227,29 +6286,34 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name) Eprog getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only) { - char **pp, buf[PATH_MAX+1]; + char **pp, buf[PATH_MAX]; off_t len; off_t rlen; char *d; Eprog r; int fd; + char *su = unmeta(s); + if (su != s) su = dupstring(su); pp = alt_path ? alt_path : fpath; + char *ppu = ""; for (; *pp; pp++) { if (**pp) { - if (snprintf(buf, PATH_MAX, "%s/%s", *pp, s) >= PATH_MAX) + ppu = unmeta(*pp); + if (ppu != *pp) ppu = dupstring(ppu); + if (snprintf(buf, PATH_MAX, "%s/%s", ppu, su) >= PATH_MAX) continue; - } else if (strlen(s) >= PATH_MAX) { + } else if (strlen(su) >= PATH_MAX) { continue; } else { - strcpy(buf, s); + strcpy(buf, su); + ppu = ""; } - if ((r = try_dump_file(*pp, s, buf, ksh, test_only))) { + if ((r = try_dump_file(ppu, s, buf, ksh, test_only))) { if (fdir) - *fdir = *pp; + *fdir = ppu; return r; } - unmetafy(buf, NULL); if (!access(buf, R_OK) && (fd = open(buf, O_RDONLY | O_NOCTTY)) != -1) { struct stat st; if (!fstat(fd, &st) && S_ISREG(st.st_mode) && @@ -6257,7 +6321,7 @@ getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only) if (test_only) { close(fd); if (fdir) - *fdir = *pp; + *fdir = ppu; return &dummy_eprog; } d = (char *) zalloc(len + 1); @@ -6274,7 +6338,7 @@ getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only) scriptname = oldscriptname; if (fdir) - *fdir = *pp; + *fdir = ppu; zfree(d, len + 1); @@ -6383,7 +6447,7 @@ cancd(char *s) char *t; if (*s != '/') { - char sbuf[PATH_MAX+1], **cp; + char sbuf[MAXCMDLEN], **cp; if (cancd2(s)) return s; @@ -6392,9 +6456,9 @@ cancd(char *s) if (!nocdpath) for (cp = cdpath; *cp; cp++) { if (**cp) { - if (snprintf(sbuf, PATH_MAX, "%s/%s", *cp, s) >= PATH_MAX) + if (snprintf(sbuf, sizeof(sbuf), "%s/%s", *cp, s) >= sizeof(sbuf)) continue; - } else if (strlen(s) >= PATH_MAX) { + } else if (ztrlen(s) >= PATH_MAX) { continue; } else { strcpy(sbuf, s); diff --git a/Src/glob.c b/Src/glob.c index 7511c1c15..0b516d226 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -849,7 +849,6 @@ qgetmodespec(char **s) if ((c = *p) == '=' || c == Equals || c == '+' || c == '-' || c == '?' || c == Quest || (c >= '0' && c <= '7')) { end = 0; - c = 0; } else { end = (c == '<' ? '>' : (c == '[' ? ']' : @@ -1756,10 +1755,13 @@ zglob(LinkList list, LinkNode np, int nountok) break; } default: - untokenize(--s); - zerr("unknown file attribute: %c", *s); - restore_globstate(saved); - return; + { + untokenize(--s); + convchar_t attr = unmeta_one(s, NULL); + zerr("unknown file attribute: %c", attr); + restore_globstate(saved); + return; + } } } if (func) { @@ -1931,6 +1933,7 @@ zglob(LinkList list, LinkNode np, int nountok) /* Parsed OK, execute for each name */ for (tmpptr = matchbuf; tmpptr < matchptr; tmpptr++) { + unsetparam("REPLY"); setsparam("REPLY", ztrdup(tmpptr->name)); execode(prog, 1, 0, "globsort"); if (!errflag) @@ -2324,12 +2327,8 @@ xpandbraces(LinkList list, LinkNode *np) do { char *ncptr; int nclen; -#ifdef MULTIBYTE_SUPPORT - mb_charinit(); - ncptr = wcs_nicechar(cend, NULL, NULL); -#else - ncptr = nicechar(cend); -#endif + MB_CHARINIT(); + ncptr = MB_NICECHAR(cend); nclen = strlen(ncptr); p = zhalloc(lenalloc + nclen); memcpy(p, str3, strp); @@ -2488,7 +2487,7 @@ xpandbraces(LinkList list, LinkNode *np) cnt++; else if (*str == Outbrace) cnt--; - DPUTS(!*str, "BUG: illegal brace expansion"); + DPUTS(!*str, "BUG: invalid brace expansion"); } /* Concatenate the string before the braces (str3), the section * * just found (str4) and the text after the braces (str2) */ @@ -3351,13 +3350,23 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr, /* Largest possible match at tail of string: * * move forward along string until we get a match. * * Again there's no optimisation. */ - for (ioff = 0, t = s, umlen = uml; t <= send; - ioff++, t++, umlen--) { + for (ioff = 0, t = s, umlen = uml; t <= send; ioff++) { set_pat_start(p, t-s); if (pattrylen(p, t, send - t, umlen, &patstralloc, ioff)) { *sp = get_match_ret(&imd, t-s, uml); return 1; } + if (fl & SUB_START) + break; + if (t == send) + break; + t++; + umlen--; + } + if (!(fl & SUB_START) && pattrylen(p, send, 0, 0, + &patstralloc, ioff)) { + *sp = get_match_ret(&imd, uml, uml); + return 1; } break; @@ -3916,6 +3925,7 @@ qualsheval(char *name, UNUSED(struct stat *buf), UNUSED(off_t days), char *str) int cshglob = badcshglob; unsetparam("reply"); + unsetparam("REPLY"); setsparam("REPLY", ztrdup(name)); badcshglob = 0; diff --git a/Src/hist.c b/Src/hist.c index 07358dfe4..c353601bf 100644 --- a/Src/hist.c +++ b/Src/hist.c @@ -231,6 +231,7 @@ static struct histsave { HashTable histtab; Histent hist_ring; zlong curhist; + zlong histline; zlong histlinect; zlong histsiz; zlong savehistsiz; @@ -946,7 +947,7 @@ histsubchar(int c) break; default: herrflush(); - zerr("illegal modifier: %c", c); + zerr("invalid modifier: %c", c); return -1; } } else { @@ -3873,6 +3874,10 @@ pushhiststack(char *hf, zlong hs, zlong shs, int level) h->histsiz = histsiz; h->savehistsiz = savehistsiz; h->locallevel = level; + if (zleactive) + zleentry(ZLE_CMD_GET_HIST_LINE, &h->histline); + else + h->histline = 0; memset(&lasthist, 0, sizeof lasthist); if (hf) { @@ -3925,7 +3930,7 @@ pophiststack(void) hist_ring = h->hist_ring; curhist = h->curhist; if (zleactive) - zleentry(ZLE_CMD_SET_HIST_LINE, curhist); + zleentry(ZLE_CMD_SET_HIST_LINE, h->histline); histlinect = h->histlinect; histsiz = h->histsiz; savehistsiz = h->savehistsiz; diff --git a/Src/init.c b/Src/init.c index a422036c7..d2b97daff 100644 --- a/Src/init.c +++ b/Src/init.c @@ -35,6 +35,14 @@ #include "init.pro" #include "version.h" +#ifdef CUSTOM_PATCHLEVEL +#define ZSH_PATCHLEVEL CUSTOM_PATCHLEVEL +#else +#include "patchlevel.h" +#ifndef ZSH_PATCHLEVEL +#define ZSH_PATCHLEVEL "unknown" +#endif +#endif #if defined(HAVE_SYS_SYSCTL_H) && !defined(__linux) #include <sys/sysctl.h> @@ -182,7 +190,7 @@ loop(int toplevel, int justonce) non_empty = 1; if (toplevel && (getshfunc("preexec") || - paramtab->getnode(paramtab, "preexec" HOOK_SUFFIX))) { + realparamtab->getnode2(realparamtab, "preexec" HOOK_SUFFIX))) { LinkList args; char *cmdstr; @@ -435,8 +443,15 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp, /* GNU-style long options */ ++*argv; if (!strcmp(*argv, "version")) { - printf("zsh %s (%s-%s-%s)\n", - ZSH_VERSION, MACHTYPE, VENDOR, OSTYPE); + // omit patchlevel for a tagged release, which looks like: + // zsh-x.y.z-0-gabcdef + static const char *pfx = "zsh-" ZSH_VERSION "-0-"; + if (strncmp(ZSH_PATCHLEVEL, pfx, strlen(pfx))) + printf("zsh %s [%s] (%s-%s-%s)\n", + ZSH_VERSION, ZSH_PATCHLEVEL, MACHTYPE, VENDOR, OSTYPE); + else + printf("zsh %s (%s-%s-%s)\n", + ZSH_VERSION, MACHTYPE, VENDOR, OSTYPE); LAST_OPTION(0); } if (!strcmp(*argv, "help")) { @@ -548,10 +563,8 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp, } doneargv: *argvp = argv; - if (emulate_required) { + if (emulate_required) parseopts_setemulate(top_emulation, flags); - emulate_required = 0; - } return 0; } @@ -869,7 +882,10 @@ init_term(void) tcstr[TCCLEARSCREEN] = ztrdup("\14"); tclen[TCCLEARSCREEN] = 1; } - rprompt_indent = 1; /* If you change this, update rprompt_indent_unsetfn() */ + + // don't touch this if it's been set explicitly by the user + if (!getsparam("ZLE_RPROMPT_INDENT")) + rprompt_indent = 1; /* If you change this, update rprompt_indent_unsetfn() */ /* The following is an attempt at a heuristic, * but it fails in some cases */ /* int hasbw = tgetflag("bw"); */ @@ -1275,6 +1291,23 @@ setupvals(char *cmd, char *runscript, char *zsh_name) condtab = NULL; wrappers = NULL; + zterm_columns_preserve = zterm_lines_preserve = 0; + + // preserve COLUMNS and LINES from environment when non-interactive + if (!isset(INTERACTIVE)) { + char *e, *p; + zlong v; + + if ((e = zgetenv("COLUMNS")) && (v = zstrtol(e, &p, 10)) > 0 && !*p) { + zterm_columns = v; + zterm_columns_preserve = 1; + } + if ((e = zgetenv("LINES")) && (v = zstrtol(e, &p, 10)) > 0 && !*p) { + zterm_lines = v; + zterm_lines_preserve = 1; + } + } + #ifdef TIOCGWINSZ adjustwinsize(0); #else diff --git a/Src/jobs.c b/Src/jobs.c index fc79a3f3a..fef3c708e 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -324,7 +324,10 @@ handle_sub(int job, int fg) deletejob(jn, 1); } } - curjob = jn - jobtab; + if (fg) + /* don't change curjob if we got here from a signal handler, the superjob + * might not be the current job at all then */ + curjob = jn - jobtab; } else if (sj->stat & STAT_STOPPED) { struct process *p; @@ -523,6 +526,10 @@ update_job(Job jn) * fg/bg is the superjob) a SIGCONT if we need it. */ sjn->stat |= STAT_CHANGED | STAT_STOPPED; + if (!(sjn->stat & STAT_DONE)) { + prevjob = curjob; + curjob = i; + } if (isset(NOTIFY) && (sjn->stat & STAT_LOCKED) && !(sjn->stat & STAT_NOPRINT)) { /* @@ -701,13 +708,15 @@ setprevjob(void) for (i = maxjob; i; i--) if ((jobtab[i].stat & STAT_INUSE) && (jobtab[i].stat & STAT_STOPPED) && - !(jobtab[i].stat & STAT_SUBJOB) && i != curjob && i != thisjob) { + !(jobtab[i].stat & (STAT_SUBJOB | STAT_NOPRINT)) && + i != curjob && i != thisjob) { prevjob = i; return; } for (i = maxjob; i; i--) - if ((jobtab[i].stat & STAT_INUSE) && !(jobtab[i].stat & STAT_SUBJOB) && + if ((jobtab[i].stat & STAT_INUSE) && + !(jobtab[i].stat & (STAT_SUBJOB | STAT_NOPRINT)) && i != curjob && i != thisjob) { prevjob = i; return; @@ -1608,7 +1617,7 @@ havefiles(void) for (i = 1; i <= maxjob; i++) if (jobtab[i].stat && jobtab[i].filelist && - peekfirst(jobtab[i].filelist)) { + nonempty(jobtab[i].filelist)) { return 1; } return 0; @@ -1896,21 +1905,19 @@ spawnjob(void) Process pn; DPUTS(thisjob == -1, "No valid job in spawnjob."); - /* if we are not in a subshell */ - if (!subsh) { - if (curjob == -1 || !(jobtab[curjob].stat & STAT_STOPPED)) { - curjob = thisjob; - setprevjob(); - } else if (prevjob == -1 || !(jobtab[prevjob].stat & STAT_STOPPED)) - prevjob = thisjob; - if (jobbing && jobtab[thisjob].procs) { - FILE *fout = shout ? shout : stdout; - fprintf(fout, "[%d]", thisjob); - for (pn = jobtab[thisjob].procs; pn; pn = pn->next) - fprintf(fout, " %ld", (long) pn->pid); - fprintf(fout, "\n"); - fflush(fout); - } + if (curjob == -1 || !(jobtab[curjob].stat & STAT_STOPPED)) { + curjob = thisjob; + setprevjob(); + } else if (prevjob == -1 || !(jobtab[prevjob].stat & STAT_STOPPED)) + prevjob = thisjob; + + if (!subsh && jobbing && jobtab[thisjob].procs) { + FILE *fout = shout ? shout : stdout; + fprintf(fout, "[%d]", thisjob); + for (pn = jobtab[thisjob].procs; pn; pn = pn->next) + fprintf(fout, " %ld", (long) pn->pid); + fprintf(fout, "\n"); + fflush(fout); } if (!hasprocs(thisjob)) deletejob(jobtab + thisjob, 0); @@ -2075,7 +2082,7 @@ getjob(const char *s, const char *prog) if (*s == '%' || *s == '+' || !*s) { if (curjob == -1) { if (prog && !isset(POSIXBUILTINS)) - zwarnnam(prog, "no current job"); + zwarnnam(prog, "%%%c: no such job", *s ? *s : '%'); returnval = -1; goto done; } @@ -2086,7 +2093,7 @@ getjob(const char *s, const char *prog) if (*s == '-') { if (prevjob == -1) { if (prog && !isset(POSIXBUILTINS)) - zwarnnam(prog, "no previous job"); + zwarnnam(prog, "%%-: no such job"); returnval = -1; goto done; } @@ -2421,6 +2428,12 @@ int bin_fg(char *name, char **argv, Options ops, int func) { int job, lng, firstjob = -1, retval = 0, ofunc = func; + int disown_all = (func == BIN_DISOWN && OPT_ISSET(ops, 'a')); + + if (disown_all && *argv) { + zwarnnam(name, "argument not meaningful with -a: %s", *argv); + return 1; + } if (OPT_ISSET(ops,'Z')) { int len; @@ -2460,7 +2473,7 @@ bin_fg(char *name, char **argv, Options ops, int func) if ((func == BIN_FG || func == BIN_BG) && !jobbing) { /* oops... maybe bg and fg should have been disabled? */ - zwarnnam(name, "no job control in this shell."); + zwarnnam(name, "no job control in this shell"); return 1; } @@ -2485,10 +2498,12 @@ bin_fg(char *name, char **argv, Options ops, int func) * will prevent zexit from complaining about stopped jobs */ stopmsg = 2; if (!*argv) { + if (disown_all) { + firstjob = 0; /* This block handles all of the default cases (no arguments). bg, fg and disown act on the current job, and jobs and wait act on all the jobs. */ - if (func == BIN_FG || func == BIN_BG || func == BIN_DISOWN) { + } else if (func == BIN_FG || func == BIN_BG || func == BIN_DISOWN) { /* W.r.t. the above comment, we'd better have a current job at this point or else. */ if (curjob == -1 || (jobtab[curjob].stat & STAT_NOPRINT)) { @@ -2576,7 +2591,7 @@ bin_fg(char *name, char **argv, Options ops, int func) } /* The only type of argument allowed now is a job spec. Check it. */ job = (*argv) ? getjob(*argv, name) : firstjob; - firstjob = -1; + firstjob = (disown_all && job <= maxjob) ? job + 1 : -1; if (job == -1) { retval = 127; break; @@ -2584,6 +2599,8 @@ bin_fg(char *name, char **argv, Options ops, int func) jstat = oldjobtab ? oldjobtab[job].stat : jobtab[job].stat; if (!(jstat & STAT_INUSE) || (jstat & STAT_NOPRINT)) { + if (disown_all) + continue; if (!isset(POSIXBUILTINS)) zwarnnam(name, "%s: no such job", *argv); unqueue_signals(); @@ -2630,12 +2647,20 @@ bin_fg(char *name, char **argv, Options ops, int func) } /* It's time to shuffle the jobs around! Reset the current job, and pick a sensible secondary job. */ - if (curjob == job) { + if (func != BIN_BG && curjob == job) { curjob = prevjob; - prevjob = (func == BIN_BG) ? -1 : job; + prevjob = job; } - if (prevjob == job || prevjob == -1) + if (prevjob == job) { + int saved_thisjob = thisjob; + if (func != BIN_BG && curjob != -1) + /* Exclude this job from setprevjob() consideration. */ + thisjob = job; setprevjob(); + thisjob = saved_thisjob; + } else if (prevjob == -1) { + setprevjob(); + } if (curjob == -1) { curjob = prevjob; setprevjob(); @@ -2819,7 +2844,6 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) while (*++argv) { status = zstrtol(*argv, &signame, 10); if (signame == *argv) { - int rtsig; signame = casemodify(signame, CASMOD_UPPER); if (!strncmp(signame, "SIG", 3)) signame += 3; @@ -2837,6 +2861,7 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) } } #if defined(SIGRTMIN) && defined(SIGRTMAX) + int rtsig; if (sig > SIGCOUNT && (rtsig = rtsigno(signame))) { printf("%d\n", rtsig); } else @@ -2849,6 +2874,7 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) printf("%d\n", sig); } else { if (*signame) { + signame = casemodify(*argv, CASMOD_UPPER); zwarnnam(nam, "unknown signal: SIG%s", signame); returnval++; @@ -3010,7 +3036,7 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func)) killjb(jobtab + p, SIGCONT); } } else if (!isanum(*argv)) { - zwarnnam("kill", "illegal pid: %s", *argv); + zwarnnam("kill", "invalid pid: %s", *argv); returnval++; } else { int pid = atoi(*argv); diff --git a/Src/loop.c b/Src/loop.c index db78f00c7..351edde89 100644 --- a/Src/loop.c +++ b/Src/loop.c @@ -377,13 +377,13 @@ selectlist(LinkList l, size_t start) do { #ifdef MB_METASTRWIDTH size_t t2 = MB_METASTRWIDTH(*ap) + 2; - (void) unmetafy(*ap, NULL); #else size_t t2 = strlen(*ap) + 2; #endif - int t3; + int t3 = ap - arr + 1; - fprintf(stderr, "%d) %s", t3 = ap - arr + 1, *ap); + fprintf(stderr, "%d) ", t3); + zputs(*ap, stderr); while (t3) t2++, t3 /= 10; for (; t2 < fw; t2++) diff --git a/Src/math.c b/Src/math.c index d97dae238..517c18118 100644 --- a/Src/math.c +++ b/Src/math.c @@ -1100,8 +1100,10 @@ callmathfunc(char *o) break; } } - if (*a && !errflag) - zerr("bad math expression: illegal character: %c", *a); + if (*a && !errflag) { + convchar_t wa = unmeta_one(a, NULL); + zerr("bad math expression: invalid character: %c", wa); + } if (!errflag) { if (argc >= f->minargs && (f->maxargs < 0 || argc <= f->maxargs)) { @@ -1493,10 +1495,14 @@ matheval(char *s) x.u.l = 0; return x; } + zsh_eval_context_push("math"); x = mathevall(s, MPREC_TOP, &junk); + zsh_eval_context_pop(); mtok = xmtok; - if (*junk) - zerr("bad math expression: illegal character: %c", *junk); + if (*junk) { + convchar_t j = unmeta_one(junk, NULL); + zerr("bad math expression: invalid character: %c", j); + } return x; } @@ -1531,7 +1537,9 @@ mathevalarg(char *s, char **ss) zerr("bad math expression: empty string"); return (zlong)0; } + zsh_eval_context_push("math"); x = mathevall(s, MPREC_ARG, ss); + zsh_eval_context_pop(); if (mtok == COMMA) (*ss)--; mtok = xmtok; diff --git a/Src/mkmakemod.sh b/Src/mkmakemod.sh index 3ccf9c5e5..5e5adc070 100644 --- a/Src/mkmakemod.sh +++ b/Src/mkmakemod.sh @@ -28,6 +28,7 @@ # headers extra headers for this module (default none) # hdrdeps extra headers on which the .mdh depends (default none) # otherincs extra headers that are included indirectly (default none) +# libs extra libraries to link this module against (default none) # # The .mdd file may also include a Makefile.in fragment between lines # `:<<\Make' and `Make' -- this will be copied into Makemod.in. @@ -186,7 +187,7 @@ if $first_stage; then unset name moddeps nozshdep alwayslink hasexport unset autofeatures autofeatures_emu - unset objects proto headers hdrdeps otherincs + unset objects proto headers hdrdeps otherincs libs . $top_srcdir/$the_subdir/${mddname}.mdd q_name=`echo $name | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'` test -n "${moddeps+set}" || moddeps= @@ -324,7 +325,7 @@ if $first_stage; then echo echo "${mddname}.\$(DL_EXT): \$(MODDOBJS_${mddname}) ${mddname}.export $exportdeps \$(@LINKMODS@_${mddname})" echo ' rm -f $@' - echo " \$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(MODDOBJS_${mddname}) \$(@LINKMODS@_${mddname}) \$(LIBS) " + echo " \$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(MODDOBJS_${mddname}) \$(@LINKMODS@_${mddname}) \$(LIBS) ${libs} " echo fi echo "${mddname}.mdhi: ${mddname}.mdhs \$(INCS_${mddname})" diff --git a/Src/module.c b/Src/module.c index 0b5cd5649..9577cc278 100644 --- a/Src/module.c +++ b/Src/module.c @@ -426,14 +426,13 @@ static int add_autobin(const char *module, const char *bnam, int flags) { Builtin bn; - int ret; bn = zshcalloc(sizeof(*bn)); bn->node.nam = ztrdup(bnam); bn->optstr = ztrdup(module); if (flags & FEAT_AUTOALL) bn->node.flags |= BINF_AUTOALL; - if ((ret = addbuiltin(bn))) { + if (addbuiltin(bn)) { builtintab->freenode(&bn->node); if (!(flags & FEAT_IGNORE)) return 1; @@ -1027,7 +1026,7 @@ checkaddparam(const char *nam, int opt_i) { Param pm; - if (!(pm = (Param) gethashnode2(paramtab, nam))) + if (!(pm = (Param) realparamtab->getnode2(realparamtab, nam))) return 0; if (pm->level || !(pm->node.flags & PM_AUTOLOAD)) { @@ -1071,7 +1070,7 @@ addparamdef(Paramdef d) return 1; } else if (!(pm = createparam(d->name, d->flags)) && - !(pm = (Param) paramtab->getnode(paramtab, d->name))) + !(pm = (Param) realparamtab->getnode2(realparamtab, d->name))) return 1; d->pm = pm; @@ -1128,7 +1127,7 @@ addparamdef(Paramdef d) int deleteparamdef(Paramdef d) { - Param pm = (Param) paramtab->getnode(paramtab, d->name); + Param pm = (Param) realparamtab->getnode2(realparamtab, d->name); if (!pm) return 1; @@ -1147,10 +1146,10 @@ deleteparamdef(Paramdef d) if (!searchpm) return 1; - paramtab->removenode(paramtab, pm->node.nam); + realparamtab->removenode(realparamtab, pm->node.nam); prevpm->old = searchpm->old; searchpm->old = pm; - paramtab->addnode(paramtab, searchpm->node.nam, searchpm); + realparamtab->addnode(realparamtab, searchpm->node.nam, searchpm); pm = searchpm; } @@ -1239,7 +1238,7 @@ add_autoparam(const char *module, const char *pnam, int flags) static int del_autoparam(UNUSED(const char *modnam), const char *pnam, int flags) { - Param pm = (Param) gethashnode2(paramtab, pnam); + Param pm = (Param) realparamtab->getnode2(realparamtab, pnam); if (!pm) { if (!(flags & FEAT_IGNORE)) @@ -2462,7 +2461,7 @@ bin_zmodload(char *nam, char **args, Options ops, UNUSED(int func)) if (OPT_ISSET(ops,'A') || OPT_ISSET(ops,'R')) { if (ops_bcpf || ops_au || OPT_ISSET(ops,'d') || (OPT_ISSET(ops,'R') && OPT_ISSET(ops,'e'))) { - zwarnnam(nam, "illegal flags combined with -A or -R"); + zwarnnam(nam, "invalid flags combined with -A or -R"); return 1; } if (!OPT_ISSET(ops,'e')) @@ -2760,7 +2759,7 @@ bin_zmodload_auto(char *nam, char **args, Options ops) } else if (OPT_ISSET(ops,'p')) { if (!*args) { /* list autoloaded parameters */ - scanhashtable(paramtab, 1, 0, 0, printautoparams, + scanhashtable(realparamtab, 1, 0, 0, printautoparams, OPT_ISSET(ops,'L')); return 0; } @@ -3528,7 +3527,7 @@ autofeatures(const char *cmdnam, const char *module, char **features, } if (strchr(fnam, '/')) { - zwarnnam(cmdnam, "%s: `/' is illegal in a %s", fnam, typnam); + zwarnnam(cmdnam, "%s: `/' is invalid in a %s", fnam, typnam); ret = 1; continue; } diff --git a/Src/options.c b/Src/options.c index 8127ccdca..9bf56cf81 100644 --- a/Src/options.c +++ b/Src/options.c @@ -591,24 +591,26 @@ bin_setopt(char *nam, char **args, UNUSED(Options ops), int isun) /* loop through command line options (begins with "-" or "+") */ while (*args && (**args == '-' || **args == '+')) { action = (**args == '-') ^ isun; - if(!args[0][1]) + if (!args[0][1]) *args = "--"; - while (*++*args) { - if(**args == Meta) - *++*args ^= 32; + ++*args; + while (**args) { + int sz; + convchar_t arg = unmeta_one(*args, &sz); + *args += sz; /* The pseudo-option `--' signifies the end of options. */ - if (**args == '-') { + if (arg == '-') { args++; goto doneoptions; - } else if (**args == 'o') { - if (!*++*args) + } else if (arg == 'o') { + if (!**args) args++; if (!*args) { zwarnnam(nam, "string expected after -o"); inittyptab(); return 1; } - if(!(optno = optlookup(*args))) { + if (!(optno = optlookup(*args))) { zwarnnam(nam, "no such option: %s", *args); retval |= 1; } else if (dosetopt(optno, action, 0, opts)) { @@ -616,14 +618,14 @@ bin_setopt(char *nam, char **args, UNUSED(Options ops), int isun) retval |= 1; } break; - } else if(**args == 'm') { + } else if (arg == 'm') { match = 1; } else { - if (!(optno = optlookupc(**args))) { - zwarnnam(nam, "bad option: -%c", **args); + if (!(optno = optlookupc(arg))) { + zwarnnam(nam, "bad option: -%c", arg); retval |= 1; } else if (dosetopt(optno, action, 0, opts)) { - zwarnnam(nam, "can't change option: -%c", **args); + zwarnnam(nam, "can't change option: -%c", arg); retval |= 1; } } @@ -718,7 +720,7 @@ optlookup(char const *name) /**/ int -optlookupc(char c) +optlookupc(convchar_t c) { if(c < FIRST_OPT || c > LAST_OPT) return 0; diff --git a/Src/params.c b/Src/params.c index 5fe7107af..716dd66c3 100644 --- a/Src/params.c +++ b/Src/params.c @@ -107,6 +107,11 @@ mod_export zlong ppid, /* $PPID */ zsh_subshell; /* $ZSH_SUBSHELL */ +// whether COLUMNS and LINES should be preserved because they were imported from +// the environment into a non-interactive shell +/**/ +mod_export int zterm_columns_preserve, zterm_lines_preserve; + /* $FUNCNEST */ /**/ mod_export @@ -224,6 +229,8 @@ static const struct gsu_integer ttyidle_gsu = static const struct gsu_scalar argzero_gsu = { argzerogetfn, argzerosetfn, nullunsetfn }; +static const struct gsu_scalar argn_gsu = +{ argngetfn, argnsetfn, argnunsetfn }; static const struct gsu_scalar username_gsu = { usernamegetfn, usernamesetfn, stdunsetfn }; static const struct gsu_scalar dash_gsu = @@ -484,6 +491,8 @@ static initparam argvparam_pm = IPDEF9("", &pparams, NULL, \ (zsfree((PM)->u.str), (PM)->u.str = (S))) static Param argvparam; +static Param *argnparams; +static size_t argnparams_size; /* * Lists of references to nested variables ("Param" instances) indexed @@ -499,6 +508,16 @@ static Param argvparam; * times in the same list. Non of that is harmful as long as only * instances that are still references referring to the ending scope * are updated when the scope ends. + * + * The list corresponding to the global scope never receives any of + * the named references described above. Instead, it's used to track + * global parameters that were unset via a named reference while in a + * scope where they were hidden by a nested parameter with the same + * name. In such cases, the global parameter's Param instance can't be + * deleted as usual. Instead, it's marked as unset and added to the + * global scope's list. Each time a scope ends, the list is traversed + * and parameters that are still unset but no longer hidden are + * deleted. */ static LinkList *scoperefs = NULL; static int scoperefs_num = 0; @@ -846,6 +865,9 @@ createparamtable(void) } argvparam = (Param) &argvparam_pm; + argnparams = zshcalloc(8 * sizeof(Param)); + argnparams_size = 8; + argnparams[0] = (Param) paramtab->getnode(paramtab, "0"); noerrs = 2; @@ -935,7 +957,7 @@ createparamtable(void) * For native emulation we always set the variable home * (see setupvals()). */ - pm = (Param) paramtab->getnode(paramtab, "HOME"); + pm = (Param) realparamtab->getnode2(realparamtab, "HOME"); if (EMULATION(EMULATE_ZSH)) { pm->node.flags &= ~PM_UNSET; @@ -943,10 +965,10 @@ createparamtable(void) addenv(pm, home); } else if (!home) pm->node.flags |= PM_UNSET; - pm = (Param) paramtab->getnode(paramtab, "LOGNAME"); + pm = (Param) realparamtab->getnode2(realparamtab, "LOGNAME"); if (!(pm->node.flags & PM_EXPORTED)) addenv(pm, pm->u.str); - pm = (Param) paramtab->getnode(paramtab, "SHLVL"); + pm = (Param) realparamtab->getnode2(realparamtab, "SHLVL"); sprintf(buf, "%d", (int)++shlvl); /* shlvl value in environment needs updating unconditionally */ addenv(pm, buf); @@ -1131,7 +1153,6 @@ createparam(char *name, int flags) pm = oldpm; pm->base = pm->width = 0; - oldpm = pm->old; } else { pm = (Param) zshcalloc(sizeof *pm); if ((pm->old = oldpm)) { @@ -1146,7 +1167,7 @@ createparam(char *name, int flags) paramtab->addnode(paramtab, ztrdup(name), pm); } - if (isset(ALLEXPORT) && !(flags & PM_HASHELEM)) + if (isset(ALLEXPORT) && !(flags & (PM_NAMEREF | PM_HASHELEM))) flags |= PM_EXPORTED; } else { pm = (Param) hcalloc(sizeof *pm); @@ -1600,15 +1621,15 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w, } if (word && !v->scanflags) { s = t = getstrvalue(v); + if (!s || !*s) + return 0; + i = wordcount(s, sep, 0); if (r < 0) r += i + 1; - if (r < 1) - r = 1; - if (r > i) - r = i; - if (!s || !*s) + if (r < 1 || r > i) return 0; + while ((d = findword(&s, sep)) && --r); if (!d) return 0; @@ -2226,7 +2247,6 @@ fetchvalue(Value v, char **pptr, int bracks, int scanflags) } else { Param pm; int isvarat; - int isrefslice = 0; isvarat = (t[0] == '@' && !t[1]); if (scanflags & SCANPM_NONAMEREF) @@ -2244,32 +2264,6 @@ fetchvalue(Value v, char **pptr, int bracks, int scanflags) if (!pm || ((pm->node.flags & PM_UNSET) && !(pm->node.flags & PM_DECLARED))) return NULL; - if ((pm->node.flags & PM_NAMEREF) && !(scanflags & SCANPM_NONAMEREF)) { - char *refname = GETREFNAME(pm); - if (refname && *refname) { - /* only happens for namerefs pointing to array elements */ - char *ref = dupstring(refname); - char *ss = pm->width ? ref + pm->width : NULL; - if (ss) { - sav = *ss; - *ss = 0; - } - Param p1 = (Param)gethashnode2(paramtab, ref); - if (p1) - pm = loadparamnode(paramtab, upscope(p1, pm), ref); - if (!(p1 && pm) || - ((pm->node.flags & PM_UNSET) && - !(pm->node.flags & PM_DECLARED))) - return NULL; - if (ss) { - scanflags |= SCANPM_NOEXEC; - *ss = sav; - s = dyncat(ss,*pptr); - isrefslice = 1; - } else - s = *pptr; - } - } if (!v) v = (Value) zhalloc(sizeof *v); memset(v, 0, sizeof(*v)); @@ -2283,8 +2277,6 @@ fetchvalue(Value v, char **pptr, int bracks, int scanflags) v->scanflags = SCANPM_ARRONLY; } v->pm = pm; - if (isrefslice) - v->valflags = VALFLAG_REFSLICE; v->end = -1; if (bracks > 0 && (*s == '[' || *s == Inbrack)) { if (getindex(&s, v, scanflags)) { @@ -2719,31 +2711,30 @@ assignstrvalue(Value v, char *val, int flags) !v->pm->width) v->pm->width = strlen(val); } else { - char *z, *x; - int zlen, vlen, newsize; - - z = v->pm->gsu.s->getfn(v->pm); - zlen = strlen(z); + char *const old = v->pm->gsu.s->getfn(v->pm); + char *new; + const int oldlen = strlen(old), vallen = strlen(val); + int newlen; if ((v->valflags & VALFLAG_INV) && unset(KSHARRAYS)) v->start--, v->end--; if (v->start < 0) { - v->start += zlen; + v->start += oldlen; if (v->start < 0) v->start = 0; } - if (v->start > zlen) - v->start = zlen; + if (v->start > oldlen) + v->start = oldlen; if (v->end < 0) { - v->end += zlen; + v->end += oldlen; if (v->end < 0) { v->end = 0; - } else if (v->end >= zlen) { - v->end = zlen; + } else if (v->end >= oldlen) { + v->end = oldlen; } else { #ifdef MULTIBYTE_SUPPORT if (isset(MULTIBYTE)) { - v->end += MB_METACHARLEN(z + v->end); + v->end += MB_METACHARLEN(old + v->end); } else { v->end++; } @@ -2754,36 +2745,33 @@ assignstrvalue(Value v, char *val, int flags) } if (v->end < v->start) v->end = v->start; - else if (v->end > zlen) - v->end = zlen; + else if (v->end > oldlen) + v->end = oldlen; - vlen = strlen(val); - /* Characters preceding start index + - characters of what is assigned + - characters following end index */ - newsize = v->start + vlen + (zlen - v->end); + /* Chars before slice + chars from val + chars after slice */ + newlen = v->start + vallen + (oldlen - v->end); - /* Does new size differ? */ - if (newsize != zlen || v->pm->gsu.s->setfn != strsetfn) { - x = (char *) zalloc(newsize + 1); - strncpy(x, z, v->start); - strcpy(x + v->start, val); - strcat(x + v->start, z + v->end); - v->pm->gsu.s->setfn(v->pm, x); - } else { - Param pm = v->pm; - /* Size doesn't change, can limit actions to only - * overwriting bytes in already allocated string */ - memcpy(z + v->start, val, vlen); - /* Implement remainder of strsetfn */ - if (!(pm->node.flags & PM_HASHELEM) && - ((pm->node.flags & PM_NAMEDDIR) || - isset(AUTONAMEDIRS))) { - pm->node.flags |= PM_NAMEDDIR; - adduserdir(pm->node.nam, z, 0, 0); - } - } - zsfree(val); + if (v->pm->gsu.s->setfn == strsetfn && old == v->pm->u.str) { + v->pm->u.str = NULL; /* Steal the old string */ + /* If the string shrinks, move left chars after the slice */ + if (newlen < oldlen && v->end < oldlen) + memmove(old + v->start + vallen, old + v->end, + oldlen - v->end); + /* If the string shrinks or expands, reallocate it */ + new = oldlen == newlen ? old : (char *) zrealloc(old, newlen + 1); + /* If the string expands, move right chars after the slice */ + if (newlen > oldlen && v->end < oldlen) + memmove(new + v->start + vallen, new + v->end, + oldlen - v->end); + } else { + new = (char *) zalloc(newlen + 1); + strncpy(new, old, v->start); + strncpy(new + v->start + vallen, old + v->end, oldlen - v->end); + } + strncpy(new + v->start, val, vallen); + zsfree(val); + new[newlen] = '\0'; + v->pm->gsu.s->setfn(v->pm, new); } break; case PM_INTEGER: @@ -2847,7 +2835,8 @@ assignstrvalue(Value v, char *val, int flags) setscope(v->pm); if (errflag || ((!v->pm->env && !(v->pm->node.flags & PM_EXPORTED) && - !(isset(ALLEXPORT) && !(v->pm->node.flags & PM_HASHELEM))) || + !(isset(ALLEXPORT) && + !(v->pm->node.flags & (PM_NAMEREF | PM_HASHELEM)))) || (v->pm->node.flags & PM_ARRAY) || v->pm->ename)) return; export_param(v->pm); @@ -2930,13 +2919,9 @@ setarrvalue(Value v, char **val) return; } else { char **const old = v->pm->gsu.a->getfn(v->pm); - char **new; - char **p, **q, **r; /* index variables */ - const int pre_assignment_length = arrlen(old); - int post_assignment_length; - int i; - - q = old; + char **new, **p, **q; + const int oldlen = arrlen(old), vallen = arrlen(val); + int newlen, i; if ((v->valflags & VALFLAG_INV) && unset(KSHARRAYS)) { if (v->start > 0) @@ -2944,98 +2929,55 @@ setarrvalue(Value v, char **val) v->end--; } if (v->start < 0) { - v->start += pre_assignment_length; + v->start += oldlen; if (v->start < 0) v->start = 0; } if (v->end < 0) { - v->end += pre_assignment_length + 1; + v->end += oldlen + 1; if (v->end < 0) v->end = 0; } - if (v->end < v->start) + if (v->end < v->start || v->start > oldlen) v->end = v->start; + else if (v->end > oldlen) + v->end = oldlen; - post_assignment_length = v->start + arrlen(val); - if (v->end < pre_assignment_length) { - /* - * Allocate room for array elements between the end of the slice `v' - * and the original array's end. - */ - post_assignment_length += pre_assignment_length - v->end; - } + /* Strings before slice + strings from val + strings after slice */ + newlen = v->start + vallen + maximum(0, oldlen - v->end); - if (pre_assignment_length == post_assignment_length - && v->pm->gsu.a->setfn == arrsetfn - /* ... and isn't something that arrsetfn() treats specially */ - && 0 == (v->pm->node.flags & (PM_SPECIAL|PM_UNIQUE)) - && NULL == v->pm->ename) - { - /* v->start is 0-based */ - p = old + v->start; - for (r = val; *r;) { - /* Free previous string */ - zsfree(*p); - /* Give away ownership of the string */ - *p++ = *r++; - } + if (v->pm->gsu.a->setfn == arrsetfn && old == v->pm->u.arr) { + v->pm->u.arr = NULL; /* Steal the old array */ + /* Free strings that are part of the slice */ + for (q = old + v->start, i = v->end - v->start; i > 0; i--) + zsfree(*q++); + /* If the array shrinks, move left strings after the slice */ + if (newlen < oldlen && v->end < oldlen) + memmove(old + v->start + vallen, old + v->end, + sizeof(char *) * (oldlen - v->end)); + /* If the array shrinks or expands, reallocate it */ + new = oldlen == newlen ? old : + (char **) zrealloc(old, sizeof(char *) * (newlen + 1)); + /* If the array expands, move right strings after the slice */ + if (newlen > oldlen && v->end < oldlen) + memmove(new + v->start + vallen, new + v->end, + sizeof(char *) * (oldlen - v->end)); } else { - /* arr+=( ... ) - * arr[${#arr}+x,...]=( ... ) */ - if (post_assignment_length > pre_assignment_length && - pre_assignment_length <= v->start && - pre_assignment_length > 0 && - v->pm->gsu.a->setfn == arrsetfn) - { - p = new = (char **) zrealloc(old, sizeof(char *) - * (post_assignment_length + 1)); - - p += pre_assignment_length; /* after old elements */ - - /* Consider 1 < 0, case for a=( 1 ); a[1,..] = - * 1 < 1, case for a=( 1 ); a[2,..] = */ - if (pre_assignment_length < v->start) { - for (i = pre_assignment_length; i < v->start; i++) { - *p++ = ztrdup(""); - } - } - - for (r = val; *r;) { - /* Give away ownership of the string */ - *p++ = *r++; - } - - /* v->end doesn't matter: - * a=( 1 2 ); a[4,100]=( a b ); echo "${(q@)a}" - * 1 2 '' a b */ - *p = NULL; - - v->pm->u.arr = NULL; - v->pm->gsu.a->setfn(v->pm, new); - } else { - p = new = (char **) zalloc(sizeof(char *) - * (post_assignment_length + 1)); - for (i = 0; i < v->start; i++) - *p++ = i < pre_assignment_length ? ztrdup(*q++) : ztrdup(""); - for (r = val; *r;) { - /* Give away ownership of the string */ - *p++ = *r++; - } - if (v->end < pre_assignment_length) - for (q = old + v->end; *q;) - *p++ = ztrdup(*q++); - *p = NULL; - - v->pm->gsu.a->setfn(v->pm, new); - } - - DPUTS2(p - new != post_assignment_length, "setarrvalue: wrong allocation: %d 1= %lu", - post_assignment_length, (unsigned long)(p - new)); + new = (char **) zalloc(sizeof(char *) * (newlen + 1)); + for (p = new, q = old, i = minimum(v->start, oldlen); i > 0; i--) + *p++ = ztrdup(*q++); + if (v->end < oldlen) + for (p = new + v->start + vallen, q = old + v->end; *q;) + *p++ = ztrdup(*q++); } - - /* Ownership of all strings has been - * given away, can plainly free */ + /* Copy and give away ownership of the strings from val */ + memcpy(new + v->start, val, sizeof(char *) * vallen); free(val); + /* Fill any gap between the old array end and the slice start */ + for (p = new + oldlen, i = v->start - oldlen; i > 0; i--) + *p++ = ztrdup(""); + new[newlen] = NULL; + v->pm->gsu.a->setfn(v->pm, new); } } @@ -3236,7 +3178,6 @@ assignsparam(char *s, char *val, int flags) createparam(t, PM_SCALAR); created = 1; } else if ((((v->pm->node.flags & PM_ARRAY) && - !(v->valflags & VALFLAG_REFSLICE) && !(flags & ASSPM_AUGMENT)) || (v->pm->node.flags & PM_HASHED)) && !(v->pm->node.flags & (PM_SPECIAL|PM_TIED)) && @@ -3259,7 +3200,7 @@ assignsparam(char *s, char *val, int flags) } if (*val && (v->pm->node.flags & PM_NAMEREF)) { if (!valid_refname(val, v->pm->node.flags)) { - zerr("invalid name reference: %s", val); + zerr("invalid variable name: %s", val); zsfree(val); unqueue_signals(); errflag |= ERRFLAG_ERROR; @@ -3399,7 +3340,6 @@ assignaparam(char *s, char **val, int flags) unqueue_signals(); return NULL; } else if (!(PM_TYPE(v->pm->node.flags) & (PM_ARRAY|PM_HASHED)) && - !(v->valflags & VALFLAG_REFSLICE) && !(v->pm->node.flags & (PM_SPECIAL|PM_TIED))) { int uniq = v->pm->node.flags & PM_UNIQUE; if ((flags & ASSPM_AUGMENT) && !(v->pm->node.flags & PM_UNSET)) { @@ -3626,8 +3566,7 @@ sethparam(char *s, char **val) if (!(v = fetchvalue(&vbuf, &s, 1, SCANPM_ASSIGNING))) { createparam(t, PM_HASHED); checkcreate = 1; - } else if (!(PM_TYPE(v->pm->node.flags) & PM_HASHED) && - !(v->valflags & VALFLAG_REFSLICE)) { + } else if (!(PM_TYPE(v->pm->node.flags) & PM_HASHED)) { if (!(v->pm->node.flags & PM_SPECIAL)) { if (resetparam(v->pm, PM_HASHED)) { unqueue_signals(); @@ -3914,17 +3853,30 @@ unsetparam_pm(Param pm, int altflag, int exp) (pm->node.flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL) return 0; + /* + * Global variables can only be deleted if they aren't hidden by a + * local one with the same name. + */ + if (!pm->level && + pm != (Param) (paramtab == realparamtab ? + /* getnode2() to avoid autoloading */ + paramtab->getnode2(paramtab, pm->node.nam) : + paramtab->getnode(paramtab, pm->node.nam))) { + LinkList refs; + if (!scoperefs) + scoperefs = zshcalloc((scoperefs_num = 8) * sizeof(refs)); + if (!scoperefs[0]) + scoperefs[0] = znewlinklist(); + zpushnode(scoperefs[0], pm); + return 0; + } + /* remove parameter node from table */ paramtab->removenode(paramtab, pm->node.nam); if (pm->old) { oldpm = pm->old; paramtab->addnode(paramtab, oldpm->node.nam, oldpm); - if ((PM_TYPE(oldpm->node.flags) == PM_SCALAR) && - !(pm->node.flags & PM_HASHELEM) && - (oldpm->node.flags & PM_NAMEDDIR) && - oldpm->gsu.s == &stdscalar_gsu) - adduserdir(oldpm->node.nam, oldpm->u.str, 0, 0); if (oldpm->node.flags & PM_EXPORTED) { /* * Re-export the old value which we removed in typeset_single(). @@ -4024,7 +3976,7 @@ floatsetfn(Param pm, double x) pm->u.dval = x; } -/* Function to get value of a scalar (string) parameter */ +/* Function to get value of a scalar (string) or nameref parameter */ /**/ mod_export char * @@ -4033,21 +3985,22 @@ strgetfn(Param pm) return pm->u.str ? pm->u.str : (char *) hcalloc(1); } -/* Function to set value of a scalar (string) parameter */ +/* Function to set value of a scalar (string) or nameref parameter */ /**/ mod_export void strsetfn(Param pm, char *x) { - zsfree(pm->u.str); - pm->u.str = x; - if (!(pm->node.flags & PM_HASHELEM) && + if (pm->u.str != x) { + if (pm->u.str) zsfree(pm->u.str); + pm->u.str = x; + } + if (!(pm->node.flags & PM_HASHELEM) && !pm->level && + (PM_TYPE(pm->node.flags) == PM_SCALAR) && ((pm->node.flags & PM_NAMEDDIR) || isset(AUTONAMEDIRS))) { pm->node.flags |= PM_NAMEDDIR; adduserdir(pm->node.nam, x, 0, 0); } - /* If you update this function, you may need to update the - * `Implement remainder of strsetfn' block in assignstrvalue(). */ } /* Function to get value of an array parameter */ @@ -4067,16 +4020,15 @@ arrgetfn(Param pm) mod_export void arrsetfn(Param pm, char **x) { - if (pm->u.arr && pm->u.arr != x) - freearray(pm->u.arr); + if (pm->u.arr != x) { + if (pm->u.arr) freearray(pm->u.arr); + pm->u.arr = x; + } if (pm->node.flags & PM_UNIQUE) uniqarray(x); - pm->u.arr = x; /* Arrays tied to colon-arrays may need to fix the environment */ if (pm->ename && x) arrfixenv(pm->ename, x); - /* If you extend this function, update the list of conditions in - * setarrvalue(). */ } /* Function to get value of an association parameter */ @@ -4960,6 +4912,49 @@ argzerogetfn(UNUSED(Param pm)) return argzero; } +/* Function to get value for positional parameters */ + +/**/ +static char * +argngetfn(Param pm) +{ + return arrlen_gt(pparams, pm->u.val - 1) ? + pparams[pm->u.val - 1] : (char *) hcalloc(1); +} + +/* Function to set value for positional parameters */ + +/**/ +static void +argnsetfn(Param pm, char *x) +{ + int len = arrlen(pparams); + int ppar = pm->u.val; + if (ppar <= len) + zsfree(pparams[ppar - 1]); + else if (x) { + int i; + pparams = (char **) zrealloc(pparams, sizeof(char *) * ppar + 1); + for (i = len; i < ppar - 1; i++) + pparams[i] = ztrdup(""); + pparams[ppar] = 0; + } + if (x) { + pparams[ppar - 1] = ztrdup(x); + zsfree(x); + } else if (ppar <= len) + memmove(pparams + ppar - 1, pparams + ppar, (len - ppar + 1) * sizeof(char *)); +} + +/* Function to unset positional parameters */ + +/**/ +static void +argnunsetfn(Param pm, UNUSED(int exp)) +{ + argnsetfn(pm, NULL); +} + /* Function to get value for special parameter `HISTSIZE' */ /**/ @@ -5894,6 +5889,15 @@ endparamscope(void) setscope(pm); } } + /* Delete unset global variables that were hidden at unset time */ + if ((refs = scoperefs ? scoperefs[0] : NULL)) { + scoperefs[0] = NULL; + for (Param pm; refs && (pm = (Param)getlinknode(refs));) { + if ((pm->node.flags & PM_UNSET) && !(pm->node.flags & PM_DECLARED)) + unsetparam_pm(pm, 1, 0); + } + freelinklist(refs, NULL); + } unqueue_signals(); } @@ -6336,22 +6340,29 @@ resolve_nameref_rec(Param pm, const Param stop, int keep_lastref) Param ref = pm; char *refname; if (!pm || !(pm->node.flags & PM_NAMEREF) || (pm->node.flags & PM_UNSET) - /* pm->width is the offset of any subscript */ - /* If present, it has to be the end of any chain, see fetchvalue() */ - || pm->width || !(refname = GETREFNAME(pm)) || !*refname) + || !(refname = GETREFNAME(pm)) || !*refname) return pm; - if (pm->node.flags & PM_TAGGED) { - zerr("%s: invalid self reference", pm->node.nam); - return NULL; - } queue_signals(); if ((pm = (Param)gethashnode2(realparamtab, refname))) { if ((pm = loadparamnode(paramtab, upscope(pm, ref), refname)) && - pm != stop && !(pm->node.flags & PM_UNSET)) { - /* user can't tag a nameref, safe for loop detection */ - ref->node.flags |= PM_TAGGED; + pm != stop && !(pm->node.flags & PM_UNSET)) pm = resolve_nameref_rec(pm, stop, keep_lastref); - ref->node.flags &= ~PM_TAGGED; + } else if (idigit(*refname)) { + int ppar = zstrtol(refname, NULL, 10); + if (ppar >= argnparams_size) { + size_t old_size = argnparams_size; + size_t new_size = argnparams_size = maximum(2 * old_size, ppar); + argnparams = zrealloc(argnparams, new_size * sizeof(Param)); + memset(argnparams + old_size, 0, + (new_size - old_size) * sizeof(Param)); + } + if (!(pm = argnparams[ppar])) { + pm = argnparams[ppar] = zshcalloc(sizeof(*pm)); + pm->node.nam = zalloc(snprintf(NULL, 0, "%d", ppar) + 1); + sprintf(pm->node.nam, "%d", ppar); + pm->node.flags = PM_SCALAR | PM_SPECIAL; + pm->u.val = ppar; + pm->gsu.s = &argn_gsu; } } else if (keep_lastref) pm = ref; @@ -6371,7 +6382,11 @@ setloopvar(char *name, char *value) zerr("read-only reference: %s", pm->node.nam); return; } - pm->base = pm->width = 0; + if (!valid_refname(value, pm->node.flags)) { + zerr("invalid variable name: %s", value); + return; + } + pm->base = 0; SETREFNAME(pm, ztrdup(value)); pm->node.flags &= ~PM_UNSET; setscope(pm); @@ -6387,21 +6402,8 @@ setscope(Param pm) if (pm->node.flags & PM_NAMEREF) { Param basepm = NULL; char *refname = GETREFNAME(pm); - char *t = refname ? itype_end(refname, INAMESPC, 0) : NULL; int q = queue_signal_level(); - /* Compute pm->width */ - /* Temporarily change nameref to array parameter itself */ - if (t && *t == '[') - *t = 0; - else - t = 0; - if (t) { - pm->width = t - refname; - *t = '['; - refname = dupstrpfx(refname, pm->width); - } - /* Compute pm->base */ if (!(pm->node.flags & PM_UPPER) && refname && (basepm = (Param)gethashnode2(realparamtab, refname)) && @@ -6420,7 +6422,7 @@ setscope(Param pm) } /* Check for self references */ - if (refname && *refname && !pm->width && basepm != pm) { + if (refname && *refname && basepm != pm) { dont_queue_signals(); /* Prevent unkillable loops */ basepm = resolve_nameref_rec(pm, pm, 0); restore_queue_signals(q); @@ -6441,7 +6443,7 @@ setscope_base(Param pm, int base) LinkList refs; if (base >= scoperefs_num) { int old_num = scoperefs_num; - int new_num = scoperefs_num = MAX(2 * base, 8); + int new_num = scoperefs_num = maximum(2 * base, 8); scoperefs = zrealloc(scoperefs, new_num * sizeof(refs)); memset(scoperefs + old_num, 0, (new_num - old_num) * sizeof(refs)); } @@ -6467,47 +6469,14 @@ upscope(Param pm, const Param ref) static int valid_refname(char *val, int flags) { - char *t; - if (flags & PM_UPPER) { /* Upward reference to positionals is doomed to fail */ - if (idigit(*val)) - return 0; - t = itype_end(val, INAMESPC, 0); - if ((t - val == 4) && - (!strncmp(val, "argv", 4) || - !strncmp(val, "ARGC", 4))) - return 0; - } else if (idigit(*val)) { - t = val; - while (*++t) - if (!idigit(*t)) - break; - if (*t && *t != '[') /* Need to test Inbrack here too? */ - return 0; - } else - t = itype_end(val, INAMESPC, 0); - - if (t == val) { - if (!(*t == '!' || *t == '?' || - *t == '$' || *t == '-' || - *t == '_')) + if (idigit(*val) || !strcmp(val, "argv") || !strcmp(val, "ARGC")) return 0; - ++t; } - if (*t == '[') { - /* Another bit of isident() to emulate */ - tokenize(t = dupstring(t+1)); - while ((t = parse_subscript(t, 0, ']')) && *t++ == Outbrack) { - if (*t == Inbrack) - ++t; - else - break; - } - if (t && *t) { - /* zwarn("%s: stuff after subscript: %s", val, t); */ - return 0; - } - } - return !!t; + + if (*val == '!' || *val == '?' || *val == '$' || *val == '-') + return !*(++val); + + return !*itype_end(val, INAMESPC, 0) && isident(val); } diff --git a/Src/parse.c b/Src/parse.c index 21b95bcb7..beb9be059 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -3187,7 +3187,7 @@ bin_zcompile(char *nam, char **args, Options ops, UNUSED(int func)) (OPT_ISSET(ops,'c') && (OPT_ISSET(ops,'U') || OPT_ISSET(ops,'k') || OPT_ISSET(ops,'z'))) || (!(OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a')) && OPT_ISSET(ops,'m'))) { - zwarnnam(nam, "illegal combination of options"); + zwarnnam(nam, "invalid combination of options"); return 1; } if ((OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a')) && isset(KSHAUTOLOAD)) @@ -3882,10 +3882,16 @@ check_dump_file(char *file, struct stat *sbuf, char *name, int *ksh, #ifdef USE_MMAP if (f) { - Eprog prog = (Eprog) zalloc(sizeof(*prog)); + Eprog prog; Patprog *pp; - int np; + size_t np; + if (h->npats > h->len / sizeof(wordcode)) { + zwarn("%s: invalid description: %s", file, name); + return NULL; + } + + prog = (Eprog) zalloc(sizeof(*prog)); prog->flags = EF_MAP; prog->len = h->len; prog->npats = np = h->npats; @@ -3917,7 +3923,15 @@ check_dump_file(char *file, struct stat *sbuf, char *name, int *ksh, { Eprog prog; Patprog *pp; - int np, fd, po = h->npats * sizeof(Patprog); + int fd; + size_t np, po; + + if (h->npats > h->len / sizeof(wordcode)) { + zwarn("%s: invalid description: %s", file, name); + return NULL; + } + + po = h->npats * sizeof(Patprog); if ((fd = open(file, O_RDONLY)) < 0 || lseek(fd, ((h->start * sizeof(wordcode)) + diff --git a/Src/pattern.c b/Src/pattern.c index 1e0ae88d9..017c20a1e 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -1369,6 +1369,11 @@ patcomppiece(int *flagp, int paren) } } slen = (patparse - str0) - nmeta; +#ifdef MULTIBYTE_SUPPORT + if ((patglobflags & GF_MULTIBYTE) && slen > 1) + /* for multibyte single characters, treat x# as (x)# */ + flags &= ~P_SIMPLE; +#endif /* First add length, which is a long */ patadd((char *)&slen, 0, sizeof(long), 0); /* @@ -3348,10 +3353,14 @@ patmatch(Upat prog) return 0; /* Yes, just position appropriately and test. */ patinput += ptlen - P_LS_LEN(next); - /* - * Here we will need to be careful that patinput is not - * in the middle of a multibyte character. - */ +#ifdef MULTIBYTE_SUPPORT + /* Make sure we aren't in the middle of + * a multibyte character */ + if ((patglobflags & GF_MULTIBYTE) && + ptlen < P_LS_LEN(next) && + !charstart[patinput - start]) + return 0; +#endif /* Continue loop with P_EXACTLY test. */ break; } diff --git a/Src/prompt.c b/Src/prompt.c index 8325bfe2c..7db074da8 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -1956,7 +1956,7 @@ truecolor_terminal(void) mod_export zattr match_colour(const char **teststrp, int is_fg, int colour) { - int shft, named = 0, tc; + int shft, tc; zattr on; if (is_fg) { @@ -1997,7 +1997,7 @@ match_colour(const char **teststrp, int is_fg, int colour) } else if (colour <= -2) { return TXT_ERROR; } - } else if ((named = ialpha(**teststrp))) { + } else if (ialpha(**teststrp)) { colour = match_named_colour(teststrp); if (colour == 8) /* default */ return 0; diff --git a/Src/sort.c b/Src/sort.c index ce2b4bbc3..224741b00 100644 --- a/Src/sort.c +++ b/Src/sort.c @@ -255,7 +255,7 @@ strmetasort(char **array, int sortwhat, int *unmetalenp) for (arrptr = array, sortptrarrptr = sortptrarr, sortarrptr = sortarr; *arrptr; arrptr++, sortptrarrptr++, sortarrptr++) { char *metaptr; - int needlen, needalloc; + int needlen; *sortptrarrptr = sortarrptr; sortarrptr->orig = *arrptr; @@ -286,8 +286,7 @@ strmetasort(char **array, int sortwhat, int *unmetalenp) * Either we're going to need to copy it to transform it, * or we need to unmetafy it. */ - if ((needalloc = (sortwhat & - (SORTIT_IGNORING_CASE|SORTIT_IGNORING_BACKSLASHES))) + if ((sortwhat & (SORTIT_IGNORING_CASE|SORTIT_IGNORING_BACKSLASHES)) || *metaptr == Meta) { char *s, *t, *src = *arrptr, *dst; int len; diff --git a/Src/subst.c b/Src/subst.c index 5f8436e28..1b75c035a 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -242,7 +242,7 @@ stringsubst(LinkList list, LinkNode node, int pf_flags, int *ret_flags, char *str = str3, c; while (!errflag && (c = *str)) { - if (((c = *str) == Inang || c == OutangProc || + if ((c == Inang || c == OutangProc || (str == str3 && c == Equals)) && str[1] == Inpar) { char *subst, *rest, *snew, *sptr; @@ -1494,6 +1494,8 @@ substevalchar(char *ptr) int saved_errflag = errflag; errflag = 0; + ptr = dupstring(ptr); + untokenize(ptr); ires = mathevali(ptr); if (errflag) { /* not a valid numerical expression */ @@ -2348,7 +2350,6 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, postmul = untok_and_escape(s + arglen, escapes, tok_arg); *t = sav; - sav = *s; s = t + arglen; /* again, continue only if another start delimiter */ if (memcmp(del0, s, dellen)) { @@ -3301,13 +3302,35 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, Param pm = sethparam(idbeg, a); if (pm) aval = paramvalarr(pm->gsu.h->getfn(pm), hkeys|hvals); - } else - setaparam(idbeg, a); + } else { + Param pm = setaparam(idbeg, a); + if (pm) { + struct value vbuf = { 0 }; + char *p = idbeg; + Value v = getvalue(&vbuf, &p, 1); + if (v) { + aval = getarrvalue(v); + } + } + } isarr = 1; arrasg = 0; } else { untokenize(val); - setsparam(idbeg, ztrdup(val)); + Param pm = setsparam(idbeg, ztrdup(val)); + if (pm) { + /* this check isn't needed for correctness, but array values + * aren't affected by SUBST flags anyway */ + if ((PM_TYPE(pm->node.flags) & (PM_HASHED|PM_ARRAY)) == 0) { + struct value vbuf = { 0 }; + char *p = idbeg; + Value v = getvalue(&vbuf, &p, 1); + if (v) { + v->valflags = VALFLAG_SUBST; + val = ztrdup(getstrvalue(v)); + } + } + } } *idend = sav; copied = 1; @@ -3381,7 +3404,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, if (haserr) shtokenize(s); } else if (haserr || errflag) { - zerr("parse error in ${...%c...} substitution", s[-1]); + zerr("parse error in ${...%c...} substitution", s[-1] == Pound ? '#' : s[-1]); return NULL; } } @@ -4060,13 +4083,16 @@ colonsubscript: if (quotemod > 0) { if (quotetype == QT_QUOTEDZPUTS) { - for (; *ap; ap++) + for (; *ap; ap++) { + untokenize(*ap); *ap = quotedzputs(*ap, NULL); + } } else if (quotetype > QT_BACKSLASH) { int sl; char *tmp; for (; *ap; ap++) { + untokenize(*ap); tmp = quotestring(*ap, quotetype); sl = strlen(tmp); *ap = (char *) zhalloc(pre + sl + post + 1); @@ -4106,10 +4132,12 @@ colonsubscript: val = dupstring(val), copied = 1; if (quotemod > 0) { if (quotetype == QT_QUOTEDZPUTS) { + untokenize(val); val = quotedzputs(val, NULL); } else if (quotetype > QT_BACKSLASH) { int sl; char *tmp; + untokenize(val); tmp = quotestring(val, quotetype); sl = strlen(tmp); val = (char *) zhalloc(pre + sl + post + 1); @@ -4728,7 +4756,6 @@ modify(char **str, char **ptr, int inbrace) *e = '\0'; if (c != 'l' && c != 'u') copy = dupstring(tt); - *e = tc; switch (c) { case 'a': chabspath(©); @@ -4795,6 +4822,7 @@ modify(char **str, char **ptr, int inbrace) copy = xsymlink(copy, 1); break; } + *e = tc; tc = *tt; *tt = '\0'; nl = al + strlen(t) + strlen(copy); diff --git a/Src/utils.c b/Src/utils.c index 94844e422..372d2a828 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -313,12 +313,12 @@ zerrmsg(FILE *file, const char *fmt, va_list ap) switch (*fmt++) { case 's': str = va_arg(ap, const char *); - nicezputs(str, file); + nicezputs(str ? str : "(null)", file); break; case 'l': { str = va_arg(ap, const char *); num = va_arg(ap, int); - fwrite(str, num, 1, file); + fwrite(str ? str : "(null)", num, 1, file); break; } case 'L': @@ -342,12 +342,8 @@ zerrmsg(FILE *file, const char *fmt, va_list ap) break; case 'c': num = va_arg(ap, int); -#ifdef MULTIBYTE_SUPPORT - mb_charinit(); - zputs(wcs_nicechar(num, NULL, NULL), file); -#else - zputs(nicechar(num), file); -#endif + MB_CHARINIT(); + zputs(MB_NICECHAR(num), file); break; case 'e': /* print the corresponding message for this errno */ @@ -760,12 +756,13 @@ zwcwidth(wint_t wc) char * pathprog(char *prog, char **namep) { - char **pp, ppmaxlen = 0, *buf, *funmeta; + char **pp, *buf, *funmeta; + size_t ppmaxlen = 0; struct stat st; for (pp = path; *pp; pp++) { - int len = strlen(*pp); + size_t len = strlen(*pp); if (len > ppmaxlen) ppmaxlen = len; } @@ -1257,7 +1254,8 @@ getnameddir(char *name) /* Check if there is a scalar parameter with this name whose value * * begins with a `/'. If there is, add it to the hash table and * * return the new value. */ - if ((pm = (Param) paramtab->getnode(paramtab, name)) && + if ((pm = (Param) realparamtab->getnode2(realparamtab, name)) && + !pm->level && (PM_TYPE(pm->node.flags) == PM_SCALAR) && (str = getsparam(name)) && *str == '/') { pm->node.flags |= PM_NAMEDDIR; @@ -1835,7 +1833,7 @@ adjustlines(int signalled) int oldlines = zterm_lines; #ifdef TIOCGWINSZ - if (signalled || zterm_lines <= 0) + if ((signalled && !zterm_lines_preserve) || zterm_lines <= 0) zterm_lines = shttyinfo.winsize.ws_row; else shttyinfo.winsize.ws_row = zterm_lines; @@ -1860,7 +1858,7 @@ adjustcolumns(int signalled) int oldcolumns = zterm_columns; #ifdef TIOCGWINSZ - if (signalled || zterm_columns <= 0) + if ((signalled && !zterm_columns_preserve) || zterm_columns <= 0) zterm_columns = shttyinfo.winsize.ws_col; else shttyinfo.winsize.ws_col = zterm_columns; @@ -2052,7 +2050,7 @@ redup(int x, int y) if (dup2(x, y) == -1) { ret = -1; } else { - check_fd_table(y); + check_fd_table(maximum(x, y)); fdtable[y] = fdtable[x]; if (fdtable[y] == FDT_FLOCK || fdtable[y] == FDT_FLOCK_EXEC) fdtable[y] = FDT_INTERNAL; @@ -2061,16 +2059,18 @@ redup(int x, int y) * Closing any fd to the locked file releases the lock. * This isn't expected to happen, it's here for completeness. */ + check_fd_table(x); if (fdtable[x] == FDT_FLOCK) fdtable_flocks--; zclose(x); - } + } else + check_fd_table(x); return ret; } /* - * Add an fd opened ithin a module. + * Add an fd opened within a module. * * fdt is the type of the fd; see the FDT_ definitions in zsh.h. * The most likely failures are: @@ -29,6 +29,7 @@ /* A few typical macros */ #define minimum(a,b) ((a) < (b) ? (a) : (b)) +#define maximum(a,b) ((a) > (b) ? (a) : (b)) /* * Our longest integer type: will be a 64 bit either if long already is, @@ -758,7 +759,6 @@ enum { VALFLAG_INV = 0x0001, /* We are performing inverse subscripting */ VALFLAG_EMPTY = 0x0002, /* Subscripted range is empty */ VALFLAG_SUBST = 0x0004, /* Substitution, so apply padding, case flags */ - VALFLAG_REFSLICE= 0x0008 /* Value is a reference to an array slice */ }; #define MAX_ARRLEN 262144 @@ -1301,8 +1301,8 @@ enum { struct cmdnam { struct hashnode node; union { - char **name; /* full pathname for external commands */ - char *cmd; /* file name for hashed commands */ + char **name; /* pointer into path array for external commands */ + char *cmd; /* file name for hashed commands */ } u; }; @@ -2518,7 +2518,6 @@ enum { RCS, RECEXACT, REMATCHPCRE, - RESTRICTED, RMSTARSILENT, RMSTARWAIT, SHAREHISTORY, @@ -3239,6 +3238,7 @@ enum { ZLE_CMD_SET_KEYMAP, ZLE_CMD_GET_KEY, ZLE_CMD_SET_HIST_LINE, + ZLE_CMD_GET_HIST_LINE, ZLE_CMD_PREEXEC, ZLE_CMD_POSTEXEC, ZLE_CMD_CHPWD @@ -3287,6 +3287,8 @@ typedef wint_t convchar_t; #define MB_CHARLENCONV(str, len, cp) mb_charlenconv((str), (len), (cp)) #define MB_CHARLEN(str, len) mb_charlenconv((str), (len), NULL) +#define MB_NICECHAR(cp) wcs_nicechar((cp), NULL, NULL) + /* * We replace broken implementations with one that uses Unicode * characters directly as wide characters. In principle this is only @@ -3366,6 +3368,8 @@ typedef int convchar_t; #define MB_CHARLENCONV(str, len, cp) charlenconv((str), (len), (cp)) #define MB_CHARLEN(str, len) ((len) ? 1 : 0) +#define MB_NICECHAR(cp) nicechar((cp)) + #define WCWIDTH_WINT(c) (1) /* Leave character or string as is. */ diff --git a/Src/zsh.mdd b/Src/zsh.mdd index da8d58322..9a5e9daab 100644 --- a/Src/zsh.mdd +++ b/Src/zsh.mdd @@ -41,7 +41,7 @@ signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@ sigcount.h: signames.c grep 'define.*SIGCOUNT' signames.c > $@ -init.o: bltinmods.list zshpaths.h zshxmods.h +init.o: bltinmods.list zshpaths.h zshxmods.h patchlevel.h init.o params.o parse.o: version.h diff --git a/Src/zsh_system.h b/Src/zsh_system.h index 21446a9b1..d46135e10 100644 --- a/Src/zsh_system.h +++ b/Src/zsh_system.h @@ -371,15 +371,6 @@ struct timespec { # endif #endif -#if defined(__APPLE__) && defined(HAVE_SELECT) -/* - * Prefer select() to poll() on MacOS X since poll() is known - * to be problematic in 10.4 - */ -#undef HAVE_POLL -#undef HAVE_POLL_H -#endif - #ifdef HAVE_SYS_FILIO_H # include <sys/filio.h> #endif diff --git a/Test/.cvsignore b/Test/.cvsignore deleted file mode 100644 index 855d72909..000000000 --- a/Test/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -*.tmp -*.swp diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst index a65dc57f1..eea6ede2b 100644 --- a/Test/A01grammar.ztst +++ b/Test/A01grammar.ztst @@ -128,11 +128,11 @@ 0:`exec' with -l option >-zsh - (exec -a /bin/SPLATTER /bin/sh -c 'echo $0') + (exec -a /bin/SPLATTER $ZTST_testdir/../Src/zsh -fc 'echo $0') 0:`exec' with -a option >/bin/SPLATTER - (exec -a/bin/SPLOOSH /bin/sh -c 'echo $0') + (exec -a/bin/SPLOOSH $ZTST_testdir/../Src/zsh -fc 'echo $0') 0:`exec' with -a option, no space >/bin/SPLOOSH @@ -144,7 +144,7 @@ ( opts=(-a /bin/WHOOOSH) - exec $opts /bin/sh -c 'echo $0' + exec $opts $ZTST_testdir/../Src/zsh -fc 'echo $0' ) 0:`exec' with -a option from expansion >/bin/WHOOOSH diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst index 1c6969e74..f866ab4d1 100644 --- a/Test/A02alias.ztst +++ b/Test/A02alias.ztst @@ -58,30 +58,26 @@ >And this too >And aliases are expanded - $ZTST_testdir/../Src/zsh -fis <<<' - unsetopt PROMPT_SP - PROMPT="" PS2="" PS3="" PS4="" RPS1="" RPS2="" - exec 2>&1 - alias \{=echo - { begin - {end - fc -l -2' 2>/dev/null + PS1= $ZTST_testdir/../Src/zsh -fis <<<' + alias \{=echo + { begin + {end + fc -l -2 + ' 0:Aliasing reserved tokens >begin >end -*>*5*{ begin -*>*6*{end +*>*2*{ begin +*>*3*{end - $ZTST_testdir/../Src/zsh -fis <<<' - unsetopt PROMPT_SP - PROMPT="" PS2="" PS3="" PS4="" RPS1="" RPS2="" - exec 2>&1 - alias -g S=\" - echo S a string S " - fc -l -1' 2>/dev/null + PS1= $ZTST_testdir/../Src/zsh -fis <<<' + alias -g S=\" + echo S a string S " + fc -l -1 + ' 0:Global aliasing quotes > a string S -*>*5*echo S a string S " +*>*2*echo S a string S " # " # Note there is a trailing space on the "> a string S " line diff --git a/Test/A05execution.ztst b/Test/A05execution.ztst index 07a24f9c8..57d6b402e 100644 --- a/Test/A05execution.ztst +++ b/Test/A05execution.ztst @@ -375,7 +375,7 @@ F:anonymous function, and a descriptor leak when backgrounding a pipeline ?(eval):wait:13: job not found: ?bar # Test 'wait' for unknown job/process ID (POSIX mode). - (setopt POSIX_BUILTINS + () { setopt localoptions POSIX_BUILTINS wait 1 echo $? wait %% @@ -388,16 +388,15 @@ F:anonymous function, and a descriptor leak when backgrounding a pipeline echo $? wait %foo echo $? - wait %\?bar) + wait %\?bar + } 127:'wait' exit status for unknown ID (POSIX mode) >127 ->0 >127 >127 >127 >127 -# TBD: the 0 above is believed to be bogus and should also be turned -# into 127 when the ccorresponding bug is fixed in the main shell. +>127 sleep 2 & pid=$! kill -STOP $pid diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst index af6f889cb..3cb73a3fe 100644 --- a/Test/A06assign.ztst +++ b/Test/A06assign.ztst @@ -539,6 +539,8 @@ call HELLO=${HELLO}liness call call + HELLO[2,4]=oo call + call unset HELLO 0:save and restore when using original value in temporary >world @@ -546,6 +548,8 @@ >world >worldliness >world +>wood +>world (integer i n x float f @@ -762,3 +766,24 @@ ) 0:regression workers/53033: assigning $! to array element *>typeset -g -a x=\( <-> \) + + ( + typeset -a a + a[1]=() + a=( a b c ) + ) +0:regression workers/54340 + + ( + typeset s # Creates a string with pm->u.str = NULL + s[1]="" # Value from pm->gsu.s->getfn() may not be stored in pm->u.str + s="abcde" # Frees pm->u.str => Crashes if it contained value from pm->gsu.s->getfn() + ) +0:string assignments don't take ownership of non-freeable pointers + + ( + typeset -a a # Creates an array with pm->u.arr = NULL + a[1]=() # Value from pm->gsu.a->getfn() may not be stored in pm->u.arr + a=( a b c ) # Frees pm->u.arr => Crashes if it contained value from pm->gsu.a->getfn() + ) +0:array assignments don't take ownership of non-freeable pointers diff --git a/Test/A07control.ztst b/Test/A07control.ztst index b1a248732..a3a82a68d 100644 --- a/Test/A07control.ztst +++ b/Test/A07control.ztst @@ -24,11 +24,18 @@ >255 $ZTST_testdir/../Src/zsh -fc 'fn() { + break + } + fn' +1:break outside loop +?fn:break:1: not in for, while, until, select, or repeat loop + + $ZTST_testdir/../Src/zsh -fc 'fn() { continue } fn' 1:continue outside loop -?fn:continue:1: not in while, until, select, or repeat loop +?fn:continue:1: not in for, while, until, select, or repeat loop for outer in 0 1 2 3; do print outer $outer diff --git a/Test/A09zwc.ztst b/Test/A09zwc.ztst new file mode 100644 index 000000000..be180db1e --- /dev/null +++ b/Test/A09zwc.ztst @@ -0,0 +1,39 @@ +# tests for .zwc loading + +%prep + + mkdir zwc.tmp + print 'print victim ran' >zwc.tmp/victim + zcompile zwc.tmp/victim + cp zwc.tmp/{victim,orig}.zwc + chmod u+w zwc.tmp/*.zwc + # on little-endian systems, the first magic number will be \x07\x06\x05\x04; + # on big-endian ones, the reverse + zwc_order=little + () { + local LC_ALL=C + [[ ${${"$( < zwc.tmp/orig.zwc )"}[1]} == $'\x07' ]] || zwc_order=big + } + +%test + + ( cp zwc.tmp/{orig,victim}.zwc + source zwc.tmp/victim ) +0:Unmodified .zwc loads and runs +>victim ran + +# FDHead.npats sits at byte offset FD_PRELEN*4 + sizeof(wordcode)*2 = 56. +# 0x40000000 (npats ~= 1 billion) is the value from the original +# crash report; with the bound check in check_dump_file it must be +# rejected, rather than triggering an out-of-bounds write or absurd allocation. + ( cp zwc.tmp/{orig,victim}.zwc + if [[ $zwc_order == little ]]; then + printf '\x00\x00\x00\x40' + else + printf '\x40\x00\x00\x00' + fi | + dd of=zwc.tmp/victim.zwc bs=1 seek=56 count=4 conv=notrunc 2>/dev/null + source zwc.tmp/victim ) +0:workers/54571: Malformed .zwc with implausible npats does not crash the shell +?(eval):8: zwc.tmp/victim.zwc: invalid description: victim +>victim ran diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index 8839e3891..8b66c184f 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -18,7 +18,7 @@ # Function tracing (typeset -ft) E02xtrace # Not yet tested: -# Assorted illegal flag combinations +# Assorted invalid flag combinations # For a few tests, we include a # typeset -p param @@ -301,6 +301,20 @@ >local unique tied array SCALAR >array local tied SCALAR array + typeset -T VAR var=(a b c b a) + () { + typeset -i var=1 + typeset -g -U VAR + typeset -p VAR var + } + typeset -p VAR var +0:Regression test for not segfaulting when uniquifying a hidden tied array +F:BUG:The inner "typeset -p VAR" should contain the value of the outer "var" +>typeset -g -UT VAR var=1 +>typeset -i var=1 +>typeset -UT VAR var=( a b c ) +>typeset -aT VAR var=( a b c ) + typeset -T SCALAR array typeset +T SCALAR 1:Untying is prohibited @@ -1123,13 +1137,39 @@ zmodload -u zsh/random echo v=${SRANDOM/<->/integer} - typeset SRANDOM + typeset -g SRANDOM echo v=${SRANDOM/<->/integer} 0:Global non -h variable doesn't hide special variable >v=integer >v=integer zmodload -u zsh/random + echo v=${SRANDOM/<->/integer} + { typeset -gh SRANDOM 2>&1; echo alive } always { echo status=$?; TRY_BLOCK_ERROR=0 } + echo v=${SRANDOM/<->/integer} +0:Global -h variable doesn't hide special variable +>v=integer +>(eval):typeset:3: SRANDOM: can't change parameter attribute +>status=1 +>v=integer + + zmodload -u zsh/random + echo v=${SRANDOM/<->/integer} + typeset SRANDOM + echo v=${SRANDOM/<->/integer} +0:Local non -h variable doesn't hide special variable +>v=integer +>v=integer + + zmodload -u zsh/random + echo v=${SRANDOM/<->/integer} + typeset -h SRANDOM + echo v=${SRANDOM/<->/integer} +0:Local -h variable hides special variable +>v=integer +>v= + + zmodload -u zsh/random echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} typeset -g SRANDOM echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} @@ -1141,23 +1181,17 @@ zmodload -u zsh/random echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} - typeset -gh SRANDOM + { typeset -gh SRANDOM 2>&1; echo alive } always { echo status=$?; TRY_BLOCK_ERROR=0 } echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} echo v=${SRANDOM/<->/integer} 0:Global -h variable doesn't hide autoload variable >z=SRANDOM (zsh/random) +>(eval):typeset:3: SRANDOM: can't change parameter attribute +>status=1 >z=SRANDOM (zsh/random) >v=integer zmodload -u zsh/random - echo v=${SRANDOM/<->/integer} - typeset SRANDOM - echo v=${SRANDOM/<->/integer} -0:Local non -h variable doesn't hide special variable ->v=integer ->v=integer - - zmodload -u zsh/random echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} typeset SRANDOM echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} diff --git a/Test/B06fc.ztst b/Test/B06fc.ztst index 922b0010f..31ec27087 100644 --- a/Test/B06fc.ztst +++ b/Test/B06fc.ztst @@ -10,16 +10,13 @@ 1:Checking that fc -l foo doesn't core dump when history is empty ?./fcl:fc:1: event not found: foo - PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:' + PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:' 0:Checking that fc -p doesn't core dump when history size is zero -*?*%* - PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0' + PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0' 1:Checking that fc -p rejects non-integer history size -*?*% fc: HISTSIZE must be an integer -*?*%* +?fc: HISTSIZE must be an integer - PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a' + PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a' 1:Checking that fc -p rejects non-integer history save size -*?*% fc: SAVEHIST must be an integer -*?*%* +?fc: SAVEHIST must be an integer diff --git a/Test/B08shift.ztst b/Test/B08shift.ztst index 0aa922673..a01128e4f 100644 --- a/Test/B08shift.ztst +++ b/Test/B08shift.ztst @@ -31,3 +31,21 @@ >mether pip azer sezar akker conter dick >mether pip azer sezar >mether pip azer + + () { local -a arr=( a b c ); shift 9 arr } + () { local -a .tmp.arr=( a b c ); shift 9 .tmp.arr } + () { shift 9 argv } a b c + () { shift 9 } a b c +1:shifting more elements than exist in array +?(anon):shift: shift count must be <= ${#arr} +?(anon):shift: shift count must be <= ${#.tmp.arr} +?(anon):shift: shift count must be <= ${#argv} +?(anon):shift: shift count must be <= $# + + () { local -i i=3; shift 9 i; print -r - $i } + () { local s=x; shift 9 s; print -r - $s } + () { local -A h=( a b ); shift 9 h; print -r - ${(kv)h} } +0:shifting non-array +>3 +>x +>a b diff --git a/Test/B10getopts.ztst b/Test/B10getopts.ztst index 5ababebcc..4e1893fc4 100644 --- a/Test/B10getopts.ztst +++ b/Test/B10getopts.ztst @@ -73,11 +73,11 @@ >test_getopts:3: argument expected after +c option test_getopts -x -1:one illegal option +1:one invalid option >test_getopts:3: bad option: -x test_getopts +x -1:one illegal option, + variant +1:one invalid option, + variant >test_getopts:3: bad option: +x set -- -x diff --git a/Test/B11kill.ztst b/Test/B11kill.ztst index dc6bf9b89..655e00c80 100644 --- a/Test/B11kill.ztst +++ b/Test/B11kill.ztst @@ -35,17 +35,17 @@ kill a b c ) 3:kill with multiple wrong inputs should increment status -?(eval):kill:2: illegal pid: a -?(eval):kill:2: illegal pid: b -?(eval):kill:2: illegal pid: c +?(eval):kill:2: invalid pid: a +?(eval):kill:2: invalid pid: b +?(eval):kill:2: invalid pid: c ( kill -INT a b c ) 3:kill with sigspec and wrong inputs should increment status -?(eval):kill:2: illegal pid: a -?(eval):kill:2: illegal pid: b -?(eval):kill:2: illegal pid: c +?(eval):kill:2: invalid pid: a +?(eval):kill:2: invalid pid: b +?(eval):kill:2: invalid pid: c ( kill @@ -75,12 +75,35 @@ kill -URG '' ) 1:kill with empty pid and sigspec should not send signal to current process group -?(eval):kill:3: illegal pid: +?(eval):kill:3: invalid pid: ( trap 'exit 19' TERM kill '' ) 1:Plain kill with empty pid should not send signal to current process group -?(eval):kill:3: illegal pid: +?(eval):kill:3: invalid pid: +# posix doesn't actually define which numbers map to which signals, but the +# first three seem pretty universal so we'll trust them + kill -l + kill -l HUP + kill -l sighup + kill -l 1 + kill -l 137 + kill -l 9009 + kill -l 6term + kill -l sig6term +1:kill -l +*>HUP INT QUIT * +*>1 +*>1 +*>HUP +*>KILL +*>9009 +*?*: SIG6TERM +*?*: SIG6TERM + + print -r - ${(f)${ kill -L }} +0:kill -L +*>*1*HUP*2*INT*3*QUIT* diff --git a/Test/B12limit.ztst b/Test/B12limit.ztst index 9dce59824..bc73d660a 100644 --- a/Test/B12limit.ztst +++ b/Test/B12limit.ztst @@ -1,6 +1,7 @@ %prep + ZSH_TEST_LANG=$(ZTST_find_UTF8) if ! zmodload zsh/rlimits 2>/dev/null then ZTST_unimplemented="the zsh/rlimits module was disabled by configure (see config.modules)" @@ -26,3 +27,27 @@ F:report this to zsh-workers mailing list. } 0:check if limit option letters are unique + ulimit -z +1:bad option letter +?(eval):ulimit:1: bad option: -z + + ulimit -N +1:missing number after -N +?(eval):ulimit:1: number required after -N + + ulimit -N abc +1:invalid number after -N +?(eval):ulimit:1: invalid number: abc + + ulimit -at +1:resource option combined with -a +?(eval):ulimit:1: no limits allowed with -a + + if [[ -z $ZSH_TEST_LANG ]]; then + ZTST_skip='no UTF-8 locale' + else + LANG=$ZSH_TEST_LANG + ulimit -の + fi +1:bad multibyte option letter +?(eval):ulimit:5: bad option: -の diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst index d68db35fa..d7f57afdc 100644 --- a/Test/D03procsubst.ztst +++ b/Test/D03procsubst.ztst @@ -25,12 +25,9 @@ 0:>(...) substitution >SEcond ViErtE - diff =(cat FILE1) =(cat FILE2) -1:=(...) substitution ->1c1 ->< First Second Third Fourth ->--- ->> Erste Zweite Dritte Vierte + paste =(cut -f1 FILE1) =(cut -f3 FILE2) +0:=(...) substitution +>First Dritte copycat <(print First) <(print Zweite) 0:FDs remain open for external commands called from functions diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index e192d480d..b80564db2 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -82,6 +82,58 @@ >wasnull2d >wasnull2d + typeset -Z3 zerothree + print ${zerothree::=15} + zerothree= + print ${zerothree[1]::=2} $zerothree[1] $zerothree + zerothree= + print ${zerothree[1,2]::=34} $zerothree[1,2] $zerothree + zerothree= + print ${zerothree[2,3]::=7} $zerothree[2,3] $zerothree + typeset -E3 ethree + five=5 + print ${ethree::=five} + typeset -a -U uniquearr + typeset -a duplicates=(1 2 1 1 2 3) + print ${(A)uniquearr::=$duplicates} + print ${(A)uniquearr[1,2]::=$duplicates} + typeset -a normalarray=( a b c d e ) + print ${(A)normalarray[2,4]::=o} + typeset -u upper=aaaaa + print ${upper[2,3]::=hi} $upper $upper[2,3] + print ${(A)upper::=big} $upper ${(t)upper} +0:::= respects expansion flags +>015 +>0 0 002 +>03 03 034 +>07 07 007 +>5.00e+00 +>1 2 3 +>1 2 +>o e +>HI AHIAA HI +>big big array-local + + local foo=xxx + () { echo ${2::=$foo} ${3::=$foo} ${4::=$foo}; echo $2 } yyy + () { echo ${11::=$foo}; echo $11 } yyy blah +0:::= doesn't do weird things with positional arguments +>xxx xxx xxx +>xxx +>xxx +>xxx + + local five=5 arr=( a b ) + print -rl - ${arr[2]::=$five} + () { print -rl - ${1::=$2} } x y + () { print -rl - ${1::=$five} ${2::=$five} ${9::=$five} } x y +0:regression: ::= with multiple assignments +>5 +>y +>5 +>5 +>5 + unset array print ${#${(A)=array=word}} 0:${#${(A)=array=word}} counts array elements @@ -95,19 +147,17 @@ ?(eval):1: unset1: exiting1 ?(eval):2: null1: exiting2 - PROMPT="" $ZTST_testdir/../Src/zsh -fis <<<' - unsetopt PROMPT_SP - PS1="" PS2="" PS3="" PS4="" RPS1="" RPS2="" - exec 2>&1 - foo() { - print ${1:?no arguments given} - print not reached - } - foo - print reached - ' 2>/dev/null + PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<' + exec 2>&1 + foo() { + print ${1:?no arguments given} + print not reached + } + foo + print reached + ' 0:interactive shell returns to top level on ${...?...} error -*>*foo:1: 1: no arguments given +>foo:1: 1: no arguments given >reached message="expand me and remove quotes" @@ -1649,11 +1699,97 @@ print $zsh_eval_context[1] [[ $ZSH_EVAL_CONTEXT = ${(j.:.)zsh_eval_context} ]] || print Not equal! (( icontext = ${#zsh_eval_context} + 1 )) - contextfn() { print $(print $zsh_eval_context[icontext,-1]); } + contextfn() { print -r - $zsh_eval_context[icontext,-1] } + functions -M contextfn contextfn + () { contextfn } + () { trap contextfn EXIT } + eval contextfn + print -r - $( contextfn ) + print -r - ${ contextfn } + : ${| contextfn } + (( contextfn(0) )) + : $(( contextfn(0) )) + let 'contextfn(0)' + : /(e*contextfn*) + : /(o+contextfn) + cat <( contextfn ) + cat < <( contextfn ) + cat =( contextfn ) + # ': >( contextfn )' would hang if FIFO is used for process substitution + () { : > $1 } >( read; contextfn ) + : > >( contextfn ) + source <( <<< contextfn ) + $ZTST_testdir/../Src/zsh -fc 'print -r - $zsh_eval_context' + () { () { print -r - $( : $(( contextfn(0) )) ) } } 0:$ZSH_EVAL_CONTEXT and $zsh_eval_context >toplevel ->shfunc cmdsubst +>shfunc +>shfunc shfunc +>trap shfunc +>eval shfunc +>cmdsubst shfunc +>cmdsubst shfunc +>cmdsubst shfunc +>math shfunc +>math shfunc +>math shfunc +>globqual shfunc +>globsort shfunc +>outsubst shfunc +>outsubst shfunc +>equalsubst shfunc +>insubst shfunc +>insubst shfunc +>file shfunc +>cmdarg +>shfunc shfunc cmdsubst math shfunc + + (( icontext = ${#zsh_eval_context} + 1 )) + contextfn() { + print -r - $#zsh_eval_context[icontext,-1] $zsh_eval_context[icontext,-1] + } + cmd='() { eval contextfn }' + repeat 48 cmd="() { $cmd }" + eval $cmd +0:zsh_eval_context resizing +*>52 eval shfunc * shfunc eval shfunc + + (( icontext = ${#zsh_eval_context} + 1 )) + context1() { + print -r - $zsh_eval_context[icontext,-1] + context2 + } + context2() { + print -r - $zsh_eval_context[icontext,-1] + } + functions -M context1 + functions -M context2 + echo '((...))' + (( context1(context2()) )) + echo '$((...))' + : $(( context1(context2()) )) + echo let + let 'context1(context2())' + echo subscript + arr=( ) exp='context1()+2' + : $arr[$exp] +0:more math context +>((...)) +>math shfunc +>math shfunc +>math shfunc shfunc +>$((...)) +>math shfunc +>math shfunc +>math shfunc shfunc +>let +>math shfunc +>math shfunc +>math shfunc shfunc +>subscript +>math shfunc +>math shfunc shfunc foo="123456789" print ${foo:3} @@ -1813,6 +1949,14 @@ > > + wu='aa bb cc' + echo $wu:wu + W=FOOBAR + echo $W:W_B_l +0:repeated upper/lowercase modifiers +>AA BB CC +>fooBar + # This used to cause uncontrolled behaviour, but at best # you got the wrong output so the check is worth it. args() { print $#; } @@ -2227,6 +2371,26 @@ 0:(q) and (b) quoting deal with the EQUALS option >\=foo =foo '=foo' + print -r - ${(q):-=} ${(qq):-=} ${(qqq):-=} ${(qqqq):-=} ${(q+):-=} ${(q-):-=} + print -r - \ + ${(q):-a = b}, ${(qq):-a = b}, ${(qqq):-a = b}, ${(qqqq):-a = b}, \ + ${(q+):-a = b}, ${(q-):-a = b} + print -r - \ + ${(qq):-a= {b,c}*}, ${(qqq):-a= {b,c}*}, ${(qqqq):-a= {b,c}*}, \ + ${(q+):-a= {b,c}*}, ${(q-):-a= {b,c}*} + ( print -r - ${(q):-=}a ) + ( print -r - ${(q+):-= } ) + ( print -r - ${(q+):-=a} ) + ( print -r - ${(q):-a= {b,c}*} ) +-:regression: workers/54909, (q) etc tokenised chars +>= '=' "=" $'=' '=' '=' +>a\ =\ b, 'a = b', "a = b", $'a = b', 'a = b', 'a = b' +>'a= b*' 'a= c*', "a= b*" "a= c*", $'a= b*' $'a= c*', 'a= b*' 'a= c*', 'a= b*' 'a= c*' +*?*no*found* +*?*no*found* +*?*no*found* +*?*no*found* + args() { print $#; } a=(foo) args "${a[3,-1]}" @@ -2323,13 +2487,13 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888 ( IFS=$'\x80' if [[ $IFS = $' \t\n\0' ]]; then - echo OK # if $'\x80' is illegal (e.g. Linux) + echo OK # if $'\x80' is invalid (e.g. Linux) else # otherwise (e.g. macOS), it should work as a separator s=$'foo\x80\bar' [[ ${${=s}[1]} = foo ]] && echo OK fi ) -0D:reset IFS to default if it contains illegal character +0D:reset IFS to default if it contains invalid character >OK ( @@ -2375,6 +2539,27 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888 >different >string + foo="abcdef" + print 1${foo/#abc/REPLACED} + print 2${foo/%abc/REPLACED} + print 3${foo/#%abc/REPLACED} + print 4${foo/#def/REPLACED} + print 5${foo/%def/REPLACED} + print 6${foo/#%def/REPLACED} + print 7${foo/#bc/REPLACED} + print 8${foo/%bc/REPLACED} + print 9${foo/#%bc/REPLACED} +0:Respect anchors +>1REPLACEDdef +>2abcdef +>3abcdef +>4abcdef +>5abcREPLACED +>6abcdef +>7abcdef +>8abcdef +>9abcdef + my_width=6 my_index=1 my_options=Option1 @@ -2828,7 +3013,7 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888 : ${(#X):-@} 1:${(#X)...}: bad math expression -?(eval):1: bad math expression: illegal character: @ +?(eval):1: bad math expression: invalid character: @ echo a${(#):-@}z 0:${(#)...}: bad math expression @@ -2902,3 +3087,35 @@ F:output ignorable as long as not an error fi -:ZSH_EXEPATH *>match: /* + + for 1 in '' -m; do + COLUMNS=47 LINES=47 $ZTST_testdir/../Src/zsh $1 -fc ' + echo $COLUMNS $LINES + COLUMNS=74 LINES=74 + echo $COLUMNS $LINES + command true + echo $COLUMNS $LINES + ' + done +-:COLUMNS and LINES preserved from environment when non-interactive +>47 47 +>74 74 +>74 74 +>47 47 +>74 74 +>74 74 + + $ZTST_testdir/../Src/zsh -fic ' + echo ${ZLE_RPROMPT_INDENT-unset} + for 1 in "" 0 1 2; do ( + ZLE_RPROMPT_INDENT=$1 + () { local TERM=dumb } + echo ${ZLE_RPROMPT_INDENT-unset} + ); done + ' +0:ZLE_RPROMPT_INDENT value +>unset +>0 +>0 +>1 +>2 diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst index 57cdc027c..42748577d 100644 --- a/Test/D06subscript.ztst +++ b/Test/D06subscript.ztst @@ -308,3 +308,18 @@ F:In math, (($i)) should be the same as ((i)), see workers/47748. F:Regression test for inconsistency of failed (i) on zero-length string >2 >1 + + string='foo bar baz' + for 1 in 0 1 2 3 4 -1 -2 -3 -4; do + print -r - $1 $string[(w)$1] + done +0:(w) +>0 +>1 foo +>2 bar +>3 baz +>4 +>-1 baz +>-2 bar +>-3 foo +>-4 diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst index 413c4fe73..28cb9d907 100644 --- a/Test/D07multibyte.ztst +++ b/Test/D07multibyte.ztst @@ -556,6 +556,23 @@ F:This is considered a bugfix in zsh [[ $'\xe3\x83\x9b' = ? ]] || print fail 4 0:Testing incomplete and invalid multibyte character components + [[ é != *$'\xc3'* ]] || print fail 1 + [[ é != *$'\xa9'* ]] || print fail 2 + [[ Stéphane != *$'\xc3'* ]] || print fail 3 + [[ Stéphane != *$'\xa9'* ]] || print fail 4 + [[ é != $'\xc3'* ]] || print fail 5 + [[ é != *$'\xa9' ]] || print fail 6 +0:Raw bytes don't match multibyte characters in * patterns + + [[ éé != é#$'\xa9' ]] || print fail 1 + [[ é != [aé]#$'\xa9' ]] || print fail 2 + [[ é != [^x]#$'\xa9' ]] || print fail 3 + [[ aé != [aé]#$'\xa9' ]] || print fail 4 + [[ aé != [^x]#$'\xa9' ]] || print fail 5 + [[ aé != [aé]##$'\xa9' ]] || print fail 6 + [[ aé != [^x]##$'\xa9' ]] || print fail 7 +0:Raw bytes don't match multibyte characters part 2 + print -r -- ${(q+):-ホ} foo='She said "ホ". I said "You can'\''t '\''ホ'\'' me!' print -r -- ${(q+)foo} @@ -643,3 +660,15 @@ F:support character sets outside the portable 7-bit range. 0:(workers/50150) zsh/stat with Unicode and metafication >50150-Ą 0 >50150-é 0 + + ( + COLUMNS=80 LINES=3 PS3='> ' + select REPLY in ⚃; do # U+2683 + print -r - ${(V)REPLY} + done + ) +0:workers/54583: select with multi-byte word +<1 +?1) ⚃ +?> > +>⚃ diff --git a/Test/E01options.ztst b/Test/E01options.ztst index dcb14e013..bcca69db7 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -5,7 +5,6 @@ # APPEND_HISTORY (history not maintained) # AUTO_LIST # AUTO_MENU -# AUTO_NAME_DIRS (named directory table not maintained) # AUTO_PARAM_KEYS # AUTO_PARAM_SLASH # AUTO_REMOVE_SLASH @@ -96,6 +95,15 @@ %test +# --version is technically an option + v=$( $ZTST_testdir/../Src/zsh --version ) + print -r - $v + # patchlevel should appear in output if different from version + [[ $ZSH_PATCHLEVEL == zsh-$ZSH_VERSION-0-* ]] || + [[ $v == *\[$ZSH_PATCHLEVEL\]* ]] +0:zsh --version output +*>zsh * \(*\) + # setopt should move on to the next operation in the face of an error, but # preserve the >0 return code unsetopt aliases @@ -1528,3 +1536,17 @@ F:compare E03posix.ztst foo " 42:ERR_RETURN inside 'source' and 'if' + + $ZTST_testdir/../Src/zsh --autonamedirs +Z -fic ' + b=/bin; hash -d | grep "^b=" + ' +0:AUTO_NAME_DIRS +>b=/bin + + $ZTST_testdir/../Src/zsh --autonamedirs +Z -fic ' + () { local b=/bin; hash -d | grep "^b=" } + c=/bin + () { local c=/sbin; hash -d | grep "^c=" } + ' +0:workers/54309: AUTO_NAME_DIRS: local parameter not considered +>c=/bin diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst index 0b4475827..0e1cc9e4e 100644 --- a/Test/K01nameref.ztst +++ b/Test/K01nameref.ztst @@ -33,44 +33,44 @@ } function g() { - if (($2)); then local -n $1 rs ra rs1 ra1; - else local -n $1 rs=s ra=a rs1="s[1]" ra1="a[1]"; fi; - if (($2 == 1)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi; - echo "$0:1: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + if (($2)); then local -n $1 rs ra; + else local -n $1 rs=s ra=a; fi; + if (($2 == 1)); then rs=s; ra=a; fi; + echo "$0:1: rs=$rs - ra=$ra"; local s=$0 a=($0); - if (($2 == 2)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi; - echo "$0:2: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + if (($2 == 2)); then rs=s; ra=a; fi; + echo "$0:2: rs=$rs - ra=$ra"; h "$@"; - echo "$0:3: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + echo "$0:3: rs=$rs - ra=$ra"; } function h() { - if (($2 == 3)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi; - echo "$0:1: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + if (($2 == 3)); then rs=s; ra=a; fi; + echo "$0:1: rs=$rs - ra=$ra"; local s=$0 a=($0); - if (($2 == 4)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi; - echo "$0:2: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + if (($2 == 4)); then rs=s; ra=a; fi; + echo "$0:2: rs=$rs - ra=$ra"; i "$@"; - echo "$0:3: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + echo "$0:3: rs=$rs - ra=$ra"; # Check that re-entering the same scope doesn't undo scope exit k "$@" } function i() { - if (($2 == 5)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi; - echo "$0:1: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + if (($2 == 5)); then rs=s; ra=a; fi; + echo "$0:1: rs=$rs - ra=$ra"; local s=$0 a=($0); - if (($2 == 6)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi; - echo "$0:2: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + if (($2 == 6)); then rs=s; ra=a; fi; + echo "$0:2: rs=$rs - ra=$ra"; j "$@"; - echo "$0:3: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + echo "$0:3: rs=$rs - ra=$ra"; k "$@"; } function j() { - echo "$0:1: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + echo "$0:1: rs=$rs - ra=$ra"; local s=$0 a=($0); - echo "$0:2: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1"; + echo "$0:2: rs=$rs - ra=$ra"; } functions -c j k @@ -276,94 +276,198 @@ F:note this causes "var" to become set >typeset -n ptr=var >typeset -t var - typeset -n ptr=var[2] - typeset -t ptr -1:change type of referenced array element -*?*var\[2\]: can't change type via subscript reference - typeset -n ptr[1]=var -1:illegal nameref name +1:invalid nameref name *?*reference variable cannot be an array typeset var=value typeset -n ptr=var print $ptr -0:basic nameref expansion, no braces + print $ptr[2,4] +0:nameref expansion, no braces >value +>alu typeset var=value typeset -n ptr=var print ${ptr} -0:basic nameref expansion, braces + print ${(U)ptr} + print ${ptr[2,5][1,3]} + print ${(U)ptr[2,5][1,3]} +0:nameref expansion, braces >value +>VALUE +>alu +>ALU typeset var=(val1 val2) typeset -n ptr=var print $ptr -0:nameref array expansion + print $ptr[2] +0:nameref array expansion, no braces >val1 val2 +>val2 - typeset -A var=(val1 val2) + typeset var=(val1 val2) typeset -n ptr=var - print ${(kv)ptr} -0:nameref hash expansion + print ${ptr} + print ${(O)ptr} + print ${ptr[2]} + print ${(U)ptr[2]} + print ${ptr[2][2,4]} + print ${(U)ptr[2][2,4]} +0:nameref array expansion, braces >val1 val2 +>val2 val1 +>val2 +>VAL2 +>al2 +>AL2 + typeset -A var=(key1 val1 key2 val2) typeset -n ptr=var + print $ptr + print $ptr[key2] +0:nameref hash expansion, no braces +>val1 val2 +>val2 + + typeset -A var=(key1 val1 key2 val2) + typeset -n ptr=var + print ${ptr} + print ${(kv)ptr} + print ${ptr[key2]} + print ${(U)ptr[key2]} + print ${ptr[key2][2,4]} + print ${(U)ptr[key2][2,4]} +0:nameref hash expansion, braces +>val1 val2 +>key1 val1 key2 val2 +>val2 +>VAL2 +>al2 +>AL2 + typeset var=value - typeset -p ptr var + typeset -n ptr=var ptr=newvalue - typeset -p ptr var -0:assign existing scalar via nameref ->typeset -n ptr=var ->typeset var=value ->typeset -n ptr=var + typeset -p var + ptr[3]=xt + typeset -p var + typeset ptr=newvalue + typeset -p var + typeset ptr[3]=xt + typeset -p var +0:assign/typeset existing scalar via nameref >typeset var=newvalue +>typeset var=nextvalue +>typeset var=newvalue +>typeset var=nextvalue + typeset var=(val1 val2) typeset -n ptr=var + ptr=(new1 new2 new3 new4 new5) + typeset -p var + ptr[3]=new6 + typeset -p var + ptr[2,4]=(new7 new8) + typeset -p var + typeset ptr=(new1 new2 new3 new4 new5) + typeset -p var + typeset ptr[3]=new6 + typeset -p var + typeset ptr[2,4]=(new7 new8) + typeset -p var +0:assign/typeset existing array via nameref +>typeset -a var=( new1 new2 new3 new4 new5 ) +>typeset -a var=( new1 new2 new6 new4 new5 ) +>typeset -a var=( new1 new7 new8 new5 ) +>typeset -a var=( new1 new2 new3 new4 new5 ) +>typeset -a var=( new1 new2 new6 new4 new5 ) +>typeset -a var=( new1 new7 new8 new5 ) + + typeset -A var=(key1 val1) + typeset -n ptr=var + ptr=(key2 val2 key3 val3) + typeset -p var + ptr[key3]=VAL3 + ptr[key4]=val4 + typeset -p var + typeset ptr=(key2 val2 key3 val3) + typeset -p var + typeset ptr[key3]=VAL3 + typeset ptr[key4]=val4 + typeset -p var +0:assign/typeset existing array via nameref +>typeset -A var=( [key2]=val2 [key3]=val3 ) +>typeset -A var=( [key2]=val2 [key3]=VAL3 [key4]=val4 ) +>typeset -A var=( [key2]=val2 [key3]=val3 ) +>typeset -A var=( [key2]=val2 [key3]=VAL3 [key4]=val4 ) + + () { + unset var + typeset -n ptr=var + ptr=value + typeset -p var + unset var + typeset ptr=value + typeset -p var + } + typeset -p var +1:assign/typeset new scalar via nameref +>typeset -g var=value +>typeset var=value +*?*no such variable: var + + () { + unset var + typeset -n ptr=var + ptr=(val1 val2) + typeset -p var + unset var + typeset ptr=(val1 val2) + typeset -p var + } + typeset -p var +1:assign/typeset new array via nameref +>typeset -g -a var=( val1 val2 ) +>typeset -a var=( val1 val2 ) +*?*no such variable: var + typeset var=value + typeset -n ptr=var + unset "ptr[3]" + typeset -p var + unset "ptr[2,3]" + typeset -p var + unset ptr + typeset -p var + typeset var=(val1 val2 val3 val4 val5) + unset "ptr[3]" + typeset -p var + unset "ptr[2,4]" + typeset -p var + unset ptr + typeset -p var + typeset -A var=(key1 val1 key2 val2) + unset "ptr[key2]" + typeset -p var unset ptr typeset -p var 0:unset via nameref +>typeset var=vaue +>typeset var=ve +>typeset -a var=( val1 val2 '' val4 val5 ) +>typeset -a var=( val1 '' val5 ) +>typeset -A var=( [key1]=val1 ) - typeset -n ptr=var typeset var=value + typeset -n ptr=var unset -n ptr typeset -p var ptr 0:unset of the nameref itself -F:If earlier tests change, might get "no such variable" here >typeset var=value - typeset -n ptr=var - typeset var=value - typeset -p ptr var - typeset ptr=newvalue - typeset -p ptr var -0:typeset existing scalar via nameref ->typeset -n ptr=var ->typeset var=value ->typeset -n ptr=var ->typeset var=newvalue - - typeset -n ptr=var - ptr=value - typeset -p var ptr -0:assign new scalar via nameref ->typeset -g var=value ->typeset -n ptr=var - - unset var - typeset -n ptr=var - typeset var=(val1 val2) - typeset -p ptr var - ptr=(new1 new2) - typeset -p ptr var -0:assign existing array via nameref ->typeset -n ptr=var ->typeset -a var=( val1 val2 ) ->typeset -n ptr=var ->typeset -a var=( new1 new2 ) - typeset -p ptr ptr1 ptr2 var 1:check state of paramtab ONE F:unexpected side-effects of previous tests @@ -372,13 +476,6 @@ F:unexpected side-effects of previous tests *?*no such variable: ptr2 *?*no such variable: var - typeset -n ptr=var - ptr=(val1 val2) - typeset -p var ptr -0:assign new array via nameref ->typeset -g -a var=( val1 val2 ) ->typeset -n ptr=var - unset var typeset -n ptr2=var typeset -n ptr1=ptr2 @@ -540,81 +637,10 @@ F:unexpected side-effects of previous tests } 0:regression: not a self reference (test 3) - - unset -n ptr2 - typeset -n ptr2='path[2]' - print -r -- $ptr2 -0q:nameref to array element, no braces ->${path[2]} - - unset -n ptr2 - typeset -n ptr2='path[2]' - print -r -- ${ptr2} -0q:nameref to array element, with braces ->${path[2]} - - unset -n ptr1 - typeset -A hash=(x MISS y HIT) - typeset -n ptr1='hash[y]' - print -r -- $ptr1 -0:nameref to hash element, no braces ->HIT - - unset -n ptr1 - typeset -A hash=(x MISS y HIT) - typeset -n ptr1='hash[y]' - print -r -- ${ptr1} -0:nameref to hash element, with braces ->HIT - - unset -n ptr2 - typeset -a ary=(1 2) - typeset -n ptr2='ary[2]' - ptr2=TWO - typeset -p ary -0:assign array element by nameref ->typeset -a ary=( 1 TWO ) - - unset -n ptr2 - typeset -n ptr2='ary[2]' - ptr2=TWO - typeset -p ary -0f:create array element by nameref -F:ksh93 does not implement this either ->typeset -a ary=( '' TWO ) - - unset -n ptr1 - typeset -A hash=(x MISS y MISS) - typeset -n ptr1='hash[y]' - ptr1=HIT - typeset -p hash -0:assign to hash element by nameref ->typeset -A hash=( [x]=MISS [y]=HIT ) - - unset -n ptr1 - typeset -A hash - typeset -n ptr1='hash[y]' - ptr1=HIT - typeset -p hash -0f:create hash by element nameref -F:ksh93 does not implement this either ->typeset -A hash=( [y]=HIT ) - unset -n ptr1 typeset -n ptr1='not[2]good' 1:invalid nameref -*?*invalid name reference: not\[2\]good - - unset -n ptr1 - unset hash - typeset -A hash - typeset -n ptr1='hash[y]' - print ${ptr1::=HIT} - typeset -p ptr1 hash -0f:create hash by element substitution ->HIT ->typeset -n ptr1='hash[y]' ->typeset -A hash=( [y]=HIT ) +*?*invalid variable name: not\[2\]good unset -n ptr unset gval @@ -683,9 +709,9 @@ F:unexpected side-effects of previous tests typeset -A var=(myself outside) () { - typeset -n myself=var[myself] + typeset -n myself=var local -h var - print -r -- $myself + print -r -- $myself[myself] typeset -p var } 0:up-reference part 3, hidden global @@ -800,15 +826,15 @@ F:Same test, should part 5 output look like this? if zmodload zsh/parameter; then () { zmodload -u zsh/parameter - typeset -n myself=parameters[myself] + typeset -n myself=parameters local -h parameters - print -r -- $myself + print -r -- $myself[myself] typeset -p parameters } else ZTST_skip='Cannot zmodload zsh/parameter, skipping autoload test' fi 0:up-reference part 9, autoloading with hidden special ->nameref-local-nameref-local +>nameref-local-association-readonly-hide-hideval-special >typeset -h parameters ( @@ -909,15 +935,6 @@ F:Checking for a bug in zmodload that affects later tests 0:named references with (P), as ${(P)nameref} >value - ary=( 'bry[1]' 'bry[2]' ) - bry=( lorem ipsum ) - typeset -n ptr='ary[2]' - print -r -- ${ptr} - print -r -- ${(P)ptr} -0:named references with (P), array element to array element ->bry[2] ->ipsum - unset -n ref unset var typeset -n ref=var @@ -1026,15 +1043,15 @@ F:Checking for a bug in zmodload that affects later tests typeset -p .K01.{scalar,assoc,array,integer,double,float,readonly} unset .K01.{scalar,assoc,array,integer,double,float} 0:unset various types via nameref, including a readonly special ->typeset -g .K01.scalar ->typeset -g -A .K01.assoc ->typeset -g -a .K01.array ->typeset -g -i .K01.integer ->typeset -g -E .K01.double ->typeset -g -F .K01.float >typeset -g -r .K01.readonly=RO *?*read-only variable: ARGC *?*read-only variable: .K01.readonly +*?*no such variable: .K01.scalar +*?*no such variable: .K01.assoc +*?*no such variable: .K01.array +*?*no such variable: .K01.integer +*?*no such variable: .K01.double +*?*no such variable: .K01.float unset -n ref unset one @@ -1053,6 +1070,19 @@ F:Checking for a bug in zmodload that affects later tests > *?*reference ref*to local variable one + typeset -n ref=var + { + for ref in valid1 inv@lid valid2; do typeset -p ref; done + } always { TRY_BLOCK_ERROR=0 } + typeset -nr ref=var + { + for ref in valid3 valid4; do typeset -p ref; done + } always { TRY_BLOCK_ERROR=0 } +1:for-loop variable is a reference, part 5, errors +>typeset -n ref=valid1 +*?*invalid variable name: inv@lid +*?*read-only reference: ref + unset -n ref typeset -n ref () { @@ -1065,13 +1095,6 @@ F:Checking for a bug in zmodload that affects later tests >typeset -n ref=inner *?*reference ref*to local variable inner - typeset -n ptr='ary[$(echo 2)]' - typeset -a ary=(one two three) - print $ptr -1:attempt deferred command substitution in subscript -F:runs in `setopt noexec` so $(...) returns nothing -*?*bad math expression: empty string - unset -n ref typeset -n ref=GLOBAL () { @@ -1155,93 +1178,93 @@ F:previously this could create an infinite recursion and crash e -u 0 0:assignment at different scope than declaration, -u 0 ->g:1: rs=f - ra=f - rs1=f - ra1=f ->g:2: rs=f - ra=f - rs1=f - ra1=f ->h:1: rs=f - ra=f - rs1=f - ra1=f ->h:2: rs=f - ra=f - rs1=f - ra1=f ->i:1: rs=f - ra=f - rs1=f - ra1=f ->i:2: rs=f - ra=f - rs1=f - ra1=f ->j:1: rs=f - ra=f - rs1=f - ra1=f ->j:2: rs=f - ra=f - rs1=f - ra1=f ->i:3: rs=f - ra=f - rs1=f - ra1=f ->k:1: rs=f - ra=f - rs1=f - ra1=f ->k:2: rs=f - ra=f - rs1=f - ra1=f ->h:3: rs=f - ra=f - rs1=f - ra1=f ->k:1: rs=f - ra=f - rs1=f - ra1=f ->k:2: rs=f - ra=f - rs1=f - ra1=f ->g:3: rs=f - ra=f - rs1=f - ra1=f +>g:1: rs=f - ra=f +>g:2: rs=f - ra=f +>h:1: rs=f - ra=f +>h:2: rs=f - ra=f +>i:1: rs=f - ra=f +>i:2: rs=f - ra=f +>j:1: rs=f - ra=f +>j:2: rs=f - ra=f +>i:3: rs=f - ra=f +>k:1: rs=f - ra=f +>k:2: rs=f - ra=f +>h:3: rs=f - ra=f +>k:1: rs=f - ra=f +>k:2: rs=f - ra=f +>g:3: rs=f - ra=f e '' 0 0:assignment at different scope than declaration, '' 0 ->g:1: rs=f - ra=f - rs1=f - ra1=f ->g:2: rs=f - ra=f - rs1=f - ra1=f ->h:1: rs=f - ra=f - rs1=f - ra1=f ->h:2: rs=f - ra=f - rs1=f - ra1=f ->i:1: rs=f - ra=f - rs1=f - ra1=f ->i:2: rs=f - ra=f - rs1=f - ra1=f ->j:1: rs=f - ra=f - rs1=f - ra1=f ->j:2: rs=f - ra=f - rs1=f - ra1=f ->i:3: rs=f - ra=f - rs1=f - ra1=f ->k:1: rs=f - ra=f - rs1=f - ra1=f ->k:2: rs=f - ra=f - rs1=f - ra1=f ->h:3: rs=f - ra=f - rs1=f - ra1=f ->k:1: rs=f - ra=f - rs1=f - ra1=f ->k:2: rs=f - ra=f - rs1=f - ra1=f ->g:3: rs=f - ra=f - rs1=f - ra1=f +>g:1: rs=f - ra=f +>g:2: rs=f - ra=f +>h:1: rs=f - ra=f +>h:2: rs=f - ra=f +>i:1: rs=f - ra=f +>i:2: rs=f - ra=f +>j:1: rs=f - ra=f +>j:2: rs=f - ra=f +>i:3: rs=f - ra=f +>k:1: rs=f - ra=f +>k:2: rs=f - ra=f +>h:3: rs=f - ra=f +>k:1: rs=f - ra=f +>k:2: rs=f - ra=f +>g:3: rs=f - ra=f e -u 2 0:assignment at different scope than declaration, -u 2 ->g:1: rs= - ra= - rs1= - ra1= ->g:2: rs=f - ra=f - rs1=f - ra1=f ->h:1: rs=f - ra=f - rs1=f - ra1=f ->h:2: rs=f - ra=f - rs1=f - ra1=f ->i:1: rs=f - ra=f - rs1=f - ra1=f ->i:2: rs=f - ra=f - rs1=f - ra1=f ->j:1: rs=f - ra=f - rs1=f - ra1=f ->j:2: rs=f - ra=f - rs1=f - ra1=f ->i:3: rs=f - ra=f - rs1=f - ra1=f ->k:1: rs=f - ra=f - rs1=f - ra1=f ->k:2: rs=f - ra=f - rs1=f - ra1=f ->h:3: rs=f - ra=f - rs1=f - ra1=f ->k:1: rs=f - ra=f - rs1=f - ra1=f ->k:2: rs=f - ra=f - rs1=f - ra1=f ->g:3: rs=f - ra=f - rs1=f - ra1=f +>g:1: rs= - ra= +>g:2: rs=f - ra=f +>h:1: rs=f - ra=f +>h:2: rs=f - ra=f +>i:1: rs=f - ra=f +>i:2: rs=f - ra=f +>j:1: rs=f - ra=f +>j:2: rs=f - ra=f +>i:3: rs=f - ra=f +>k:1: rs=f - ra=f +>k:2: rs=f - ra=f +>h:3: rs=f - ra=f +>k:1: rs=f - ra=f +>k:2: rs=f - ra=f +>g:3: rs=f - ra=f e -u 6 0:assignment at different scope than declaration, -u 6 ->g:1: rs= - ra= - rs1= - ra1= ->g:2: rs= - ra= - rs1= - ra1= ->h:1: rs= - ra= - rs1= - ra1= ->h:2: rs= - ra= - rs1= - ra1= ->i:1: rs= - ra= - rs1= - ra1= ->i:2: rs=f - ra=f - rs1=f - ra1=f ->j:1: rs=f - ra=f - rs1=f - ra1=f ->j:2: rs=f - ra=f - rs1=f - ra1=f ->i:3: rs=f - ra=f - rs1=f - ra1=f ->k:1: rs=f - ra=f - rs1=f - ra1=f ->k:2: rs=f - ra=f - rs1=f - ra1=f ->h:3: rs=f - ra=f - rs1=f - ra1=f ->k:1: rs=f - ra=f - rs1=f - ra1=f ->k:2: rs=f - ra=f - rs1=f - ra1=f ->g:3: rs=f - ra=f - rs1=f - ra1=f +>g:1: rs= - ra= +>g:2: rs= - ra= +>h:1: rs= - ra= +>h:2: rs= - ra= +>i:1: rs= - ra= +>i:2: rs=f - ra=f +>j:1: rs=f - ra=f +>j:2: rs=f - ra=f +>i:3: rs=f - ra=f +>k:1: rs=f - ra=f +>k:2: rs=f - ra=f +>h:3: rs=f - ra=f +>k:1: rs=f - ra=f +>k:2: rs=f - ra=f +>g:3: rs=f - ra=f e '' 6 0:assignment at different scope than declaration, '' 6 ->g:1: rs= - ra= - rs1= - ra1= ->g:2: rs= - ra= - rs1= - ra1= ->h:1: rs= - ra= - rs1= - ra1= ->h:2: rs= - ra= - rs1= - ra1= ->i:1: rs= - ra= - rs1= - ra1= ->i:2: rs=i - ra=i - rs1=i - ra1=i ->j:1: rs=i - ra=i - rs1=i - ra1=i ->j:2: rs=i - ra=i - rs1=i - ra1=i ->i:3: rs=i - ra=i - rs1=i - ra1=i ->k:1: rs=i - ra=i - rs1=i - ra1=i ->k:2: rs=i - ra=i - rs1=i - ra1=i ->h:3: rs=h - ra=h - rs1=h - ra1=h ->k:1: rs=h - ra=h - rs1=h - ra1=h ->k:2: rs=h - ra=h - rs1=h - ra1=h ->g:3: rs=g - ra=g - rs1=g - ra1=g +>g:1: rs= - ra= +>g:2: rs= - ra= +>h:1: rs= - ra= +>h:2: rs= - ra= +>i:1: rs= - ra= +>i:2: rs=i - ra=i +>j:1: rs=i - ra=i +>j:2: rs=i - ra=i +>i:3: rs=i - ra=i +>k:1: rs=i - ra=i +>k:2: rs=i - ra=i +>h:3: rs=h - ra=h +>k:1: rs=h - ra=h +>k:2: rs=h - ra=h +>g:3: rs=g - ra=g f1 0:Transitive references with scoping changes @@ -1333,125 +1356,254 @@ F:previously this could create an infinite recursion and crash >B8: ref1=l2 ref2=l2 >B9: ref1=l1 ref2=l1 -# -# The following two tests are linked, do not separate -# + check-valid-referent-name() { + local -n ref=$1 + [[ $ref = $2 ]] || echo "Unexpected expansion result: ref=$1, \$ref=$ref != $2" + } + check-invalid-variable-name() { + { + local -- $1=value-$1 2>/dev/null + echo "Unexpected valid variable name: $1" + } always { + TRY_BLOCK_ERROR=0 + } + } + check-invalid-referent-name() { + { + local -n -- ref=$1 2>/dev/null + echo "Unexpected valid referent name: $1" + } always { + TRY_BLOCK_ERROR=0 + } + } + local name value; + # Test valid variable names. + for name in \ + foo foo. foo.bar foo.456 foo.4ar \ + .foo .foo.bar .foo.456 + do + local $name=value-$name + check-valid-referent-name "$name" value-$name + check-invalid-referent-name "$name"@ + check-invalid-referent-name "$name""[1]" + done + # Test valid builtin variable names + for name value in 123 "" \! 0 \? 0 \$ $$ - 569X _ -n; do + check-valid-referent-name "$name" $value + check-invalid-referent-name "$name"@ + check-invalid-referent-name "$name""[1]" + done + # Test invalid variable names. + for name in \ + .foo. .foo.4ar . foo.. \ + 123. 123.bar 123.456 123.4ar .. .foo.. \ + .123 .123. .123.bar .123.456 .123.4ar \ + 1oo 1oo. 1oo.bar 1oo.456 1oo.4ar \ + .1oo .1oo. .1oo.bar .1oo.456 .1oo.4ar + do + check-invalid-variable-name "$name" + check-invalid-referent-name "$name" + check-invalid-referent-name "$name"@ + check-invalid-referent-name "$name""[1]" + done + # Any variable name with more than one non-leading '.' is invalid. + for name in {,.}{foo,123,1oo}.{bar,456,4ar}.{,baz,789,7az}; do + check-invalid-variable-name "$name" + check-invalid-referent-name "$name" + done + unfunction check-valid-referent-name + unfunction check-invalid-variable-name + unfunction check-invalid-referent-name + unset name value +0:references to invalid variable names edgelocal() ( local -n x=$1; typeset -p x; print -r $x ) edgeupper() ( local -nu x=$1; typeset -p x; print -r $x ) - for edge in argv ARGC \@ \* \# 0 1 01 \! \? - _ + for edge in argv ARGC \@ \* \# 0 00 2 02 \! \? \$ - _ do - edgelocal $edge - edgelocal "$edge""[1]" - edgeupper $edge + edgelocal $edge foo + edgeupper $edge foo done -0:references to builtin specials -F:Subscripting on 1 01 ! ? - should print first character but do not + unfunction edgelocal edgeupper +0q:references to builtin specials >typeset -n x=argv ->argv ->typeset -n x='argv[1]' ->argv[1] +>argv foo >typeset -n x=ARGC ->1 ->typeset -n x='ARGC[1]' ->1 +>2 >typeset -n x=0 >edgelocal ->typeset -n x='0[1]' ->e ->typeset -n x=1 -> ->typeset -n x='1[1]' -> ->typeset -n x=01 -> ->typeset -n x='01[1]' -> +>typeset -n x=00 +>edgelocal +>typeset -n x=2 +>foo +>typeset -n x=02 +>foo >typeset -n x=! >0 ->typeset -n x='![1]' -> >typeset -un x=! >0 >typeset -n x='?' >0 ->typeset -n x='?[1]' -> >typeset -un x='?' >0 +>typeset -n x='$' +>$$ +>typeset -un x='$' +>$$ >typeset -n x=- >569X ->typeset -n x='-[1]' -> >typeset -un x=- >569X >typeset -n x=_ >x ->typeset -n x='_[1]' ->x >typeset -un x=_ >x -?edgeupper: invalid name reference: argv -?edgeupper: invalid name reference: ARGC -?edgelocal: invalid name reference: @ -?edgelocal: invalid name reference: @[1] -?edgeupper: invalid name reference: @ -?edgelocal: invalid name reference: * -?edgelocal: invalid name reference: *[1] -?edgeupper: invalid name reference: * -?edgelocal: invalid name reference: # -?edgelocal: invalid name reference: #[1] -?edgeupper: invalid name reference: # -?edgeupper: invalid name reference: 0 -?edgeupper: invalid name reference: 1 -?edgeupper: invalid name reference: 01 +?edgeupper: invalid variable name: argv +?edgeupper: invalid variable name: ARGC +?edgelocal: invalid variable name: @ +?edgeupper: invalid variable name: @ +?edgelocal: invalid variable name: * +?edgeupper: invalid variable name: * +?edgelocal: invalid variable name: # +?edgeupper: invalid variable name: # +?edgeupper: invalid variable name: 0 +?edgeupper: invalid variable name: 00 +?edgeupper: invalid variable name: 2 +?edgeupper: invalid variable name: 02 - edgelocal \$ - edgelocal '$[1]' - edgeupper \$ - unfunction edgelocal edgeupper -0qf:references to $$ -F:$$[1] reference should print the first digit of $$ but prints nothing ->typeset -n x='$' ->$$ ->typeset -n x='\$[1]' ->$$[1] ->$$ + tst() { + typeset -n ref0=0 2>&1 + typeset -n ref00=00 2>&1 + typeset -n ref2=2 2>&1 + typeset -n ref02=02 2>&1 + echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02 + ref0=TST + ref2=BBB + echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02 + ref00=Tst + ref02=Bbb + echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02; typeset -p -- 0 00 2 02 2>&1 + unset ref0 + unset ref2 + echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02; typeset -p -- 0 00 2 02 2>&1 + ref0=tst + ref2=bbb + echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02; typeset -p -- 0 00 2 02 2>&1 + { ref0=(TST TST) 2>&1 } always { TRY_BLOCK_ERROR=0 } + { ref2=(BBB BBB) 2>&1 } always { TRY_BLOCK_ERROR=0 } + echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02; typeset -p -- 0 00 2 02 2>&1 + typeset -n ref5=5 2>&1 + ref5=zzz + echo ${(q)0} ${(q)*} + unset ref2 + echo ${(q)0} ${(q)*} + unset ref2 + echo ${(q)0} ${(q)*} + unset ref2 + echo ${(q)0} ${(q)*} + unset ref2 + echo ${(q)0} ${(q)*} + unset ref2 + echo ${(q)0} ${(q)*} + } + tst aaa bbb ccc + unfunction tst +0:references to positional parameters +>tst aaa bbb ccc - tst - tst - bbb - bbb +>TST aaa BBB ccc - TST - TST - BBB - BBB +>Tst aaa Bbb ccc - Tst - Tst - Bbb - Bbb +>tst:typeset:11: no such variable: 00 +>tst:typeset:11: no such variable: 2 +>tst:typeset:11: no such variable: 02 +>typeset -g 0=Tst +>Tst aaa ccc - Tst - Tst - ccc - ccc +>tst:typeset:14: no such variable: 00 +>tst:typeset:14: no such variable: 2 +>tst:typeset:14: no such variable: 02 +>typeset -g 0=Tst +>tst aaa bbb - tst - tst - bbb - bbb +>tst:typeset:17: no such variable: 00 +>tst:typeset:17: no such variable: 2 +>tst:typeset:17: no such variable: 02 +>typeset -g 0=tst +>tst:18: 0: attempt to assign array value to non-array +>tst:19: 2: attempt to assign array value to non-array +>tst aaa bbb - tst - tst - bbb - bbb +>tst:typeset:20: no such variable: 00 +>tst:typeset:20: no such variable: 2 +>tst:typeset:20: no such variable: 02 +>typeset -g 0=tst +>tst aaa bbb '' '' zzz +>tst aaa '' '' zzz +>tst aaa '' zzz +>tst aaa zzz +>tst aaa +>tst aaa # -# The following tests are run in interactive mode, using PS1 as an +# The following tests are run in interactive mode, using PS3 as an # assignable special with side-effects. This crashed at one time. # # Note bypassing TYPESET_TO_UNSET here - $ZTST_testdir/../Src/zsh -fis <<<$' - typeset -n p=PS1 - () { - typeset -p p - local p - typeset -p p - p=xx - typeset -p p - } + PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<' + typeset -n p=PS3 + () { + typeset -p p + local p + typeset -p p + p=xx + typeset -p p + } ' 0:regression: assign to local that shadows global named reference ->typeset -g -n p=PS1 +>typeset -g -n p=PS3 >typeset p='' >typeset p=xx -*?* # Note bypassing TYPESET_TO_UNSET here - $ZTST_testdir/../Src/zsh -fis <<<$' - () { - typeset p=PS1 - typeset -n p - p=zz - } - typeset -p PS1 + PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<' + () { + typeset p=PS3 + typeset -n p + p=zz + } + typeset -p PS3 ' 0:regression - converting a string into a named reference ->typeset PS1=zz -*?* +>typeset PS3=zz + +# Testing named directories requires to run in interactive mode + + # Use "${(kv)nameddirs}" because "typeset -p nameddirs" prints no value + PS1= $ZTST_testdir/../Src/zsh -fis <<<' + [[ -d Modules/zsh ]] && module_path=( $PWD/Modules ) + typeset v1=/1 v2 + typeset -n r1=v1 r2 + { echo "~v1:" ~v1 } 2>&1 + { echo "~r1:" ~r1 } 2>&1 + echo "nameddirs=( ${(kv)nameddirs} )" + r1=/A + echo "nameddirs=( ${(kv)nameddirs} )" + hash -d v2=/2 r2=/R + echo "nameddirs=( ${(kv)nameddirs} )" + setopt autonamedirs + v2=V2 + echo "nameddirs=( ${(kv)nameddirs} )" + r2=v2 + echo "nameddirs=( ${(kv)nameddirs} )" + r2=/B + echo "nameddirs=( ${(kv)nameddirs} )" + ' +0:Only string parameters are promoted to named directories +>~v1: /1 +>zsh: no such user or named directory: r1 +>nameddirs=( v1 /1 ) +>nameddirs=( v1 /A ) +>nameddirs=( v1 /A v2 /2 r2 /R ) +>nameddirs=( v1 /A r2 /R ) +>nameddirs=( v1 /A r2 /R ) +>nameddirs=( v1 /A v2 /B r2 /R ) unset var1 var2 typeset -n ref1=var1 @@ -1485,22 +1637,7 @@ F:$$[1] reference should print the first digit of $$ but prints nothing zmodload -u zsh/random echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} echo v=${ref/<->/integer} -0:Referring and dereferring an autoload variable loads it (direct) ->z=SRANDOM (zsh/random) ->z= ->v=integer ->z=SRANDOM (zsh/random) ->v=integer - - zmodload -u zsh/random - echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} - typeset -n ref=SRANDOM[1,20] - echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} - echo v=${ref/<->/integer} - zmodload -u zsh/random - echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} - echo v=${ref/<->/integer} -0:Referring and dereferring an autoload variable loads it (subscript) +0:Referring and dereferring an autoload variable loads it >z=SRANDOM (zsh/random) >z= >v=integer @@ -1514,21 +1651,7 @@ F:$$[1] reference should print the first digit of $$ but prints nothing typeset -h SRANDOM=local-variable echo v=${ref/<->/integer} echo NOT REACHED -1:Dereferring an autoload variable fails to load it if its hidden (direct) ->v=integer ->z=SRANDOM (zsh/random) -?(eval):6: Can't add module parameter `SRANDOM': local parameter exists -?(eval):zsh/random:6: error when adding parameter `SRANDOM' -?(eval):6: autoloading module zsh/random failed to define parameter: SRANDOM - - typeset -n ref=SRANDOM[1,20] - echo v=${ref/<->/integer} - zmodload -u zsh/random - echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*} - typeset -h SRANDOM=local-variable - echo v=${ref/<->/integer} - echo NOT REACHED -1:Dereferring an autoload variable fails to load it if its hidden (subscript) +1:Dereferring an autoload variable fails to load it if its hidden >v=integer >z=SRANDOM (zsh/random) ?(eval):6: Can't add module parameter `SRANDOM': local parameter exists @@ -1747,10 +1870,6 @@ F:converting from association/array to string should work here too 1:regression: reference loop with same name enclosing variable ?(anon):3: ptr2: invalid self reference - typeset -n ref=ref[1] -1:self reference with subscript -*?*: ref: invalid self reference - typeset var=foo typeset -n ref=var () { @@ -1933,6 +2052,220 @@ F:converting from association/array to string should work here too ># d:reference to not-yet-defined - local - ref1 >typeset -i var=42 + test-unset() { + typeset var0=foo + typeset -n ref1=var0 ref2=ref1 + typeset cmd=(unset $@); echo "#" $cmd; $cmd + typeset -p var0 ref1 ref2 + } + test-unset -n ref1 + test-unset -n ref2 + test-unset -n -m ref1 + test-unset -n -m ref2 + unfunction test-unset +0:unsetting references with -n unsets the references +># unset -n ref1 +>typeset var0=foo +>typeset -n ref2=ref1 +># unset -n ref2 +>typeset var0=foo +>typeset -n ref1=var0 +># unset -n -m ref1 +>typeset var0=foo +>typeset -n ref2=ref1 +># unset -n -m ref2 +>typeset var0=foo +>typeset -n ref1=var0 + + test-unset() { + typeset var0=foo + typeset -n ref1=var0 ref2=ref1 + typeset cmd=(unset $@); echo "#" $cmd; $cmd + typeset -p var0 ref1 ref2 + } + test-unset ref1 + test-unset ref2 + test-unset -m ref1 + test-unset -m ref2 + unfunction test-unset +0:unsetting references without -n unsets the referred parameters +># unset ref1 +>typeset -n ref1=var0 +>typeset -n ref2=ref1 +># unset ref2 +>typeset -n ref1=var0 +>typeset -n ref2=ref1 +># unset -m ref1 +>typeset -n ref1=var0 +>typeset -n ref2=ref1 +># unset -m ref2 +>typeset -n ref1=var0 +>typeset -n ref2=ref1 + + test-unset() { + typeset var0=12345 + typeset -n ref1=var0 ref2=ref1 + typeset cmd=(unset $@); echo "#" $cmd; $cmd + typeset -p var0 + } + test-unset ref1"[3]" + test-unset ref2"[3]" + test-unset -n ref1"[3]" + test-unset -n ref2"[3]" + unfunction test-unset +0:unsetting subscripted references unsets the referred elements +># unset ref1[3] +>typeset var0=1245 +># unset ref2[3] +>typeset var0=1245 +># unset -n ref1[3] +>typeset var0=1245 +># unset -n ref2[3] +>typeset var0=1245 + + test-unset() { + typeset -r var=foo + typeset -n ref=var + typeset cmd=(unset $@); echo "#" $cmd; { $cmd 2>&1 } always { TRY_BLOCK_ERROR=0 } + typeset -p var + } + test-unset var + test-unset -m var + test-unset ref + test-unset -m ref + test-unset var"[2]" + test-unset ref"[2]" + test-unset -n ref"[2]" + unfunction test-unset +0:unsetting read-only parameter triggers an error +># unset var +>test-unset:3: read-only variable: var +>typeset -r var=foo +># unset -m var +>test-unset:3: read-only variable: var +>typeset -r var=foo +># unset ref +>test-unset:3: read-only variable: var +>typeset -r var=foo +># unset -m ref +>test-unset:3: read-only variable: var +>typeset -r var=foo +># unset var[2] +>test-unset:3: read-only variable: var +>typeset -r var=foo +># unset ref[2] +>test-unset:3: read-only variable: var +>typeset -r var=foo +># unset -n ref[2] +>test-unset:3: read-only variable: var +>typeset -r var=foo + + test-unset() { + typeset -n ref1 ref2=ref1 + typeset cmd=(unset $@); echo "#" $cmd; $cmd + typeset -p ref1 ref2 + } + test-unset ref1 + test-unset ref2 + test-unset -m ref1 + test-unset -m ref2 + unfunction test-unset +0:unsetting placeholder references or their referents has no effect +># unset ref1 +>typeset -n ref1 +>typeset -n ref2=ref1 +># unset ref2 +>typeset -n ref1 +>typeset -n ref2=ref1 +># unset -m ref1 +>typeset -n ref1 +>typeset -n ref2=ref1 +># unset -m ref2 +>typeset -n ref1 +>typeset -n ref2=ref1 + + test-unset() { + typeset -n ref1=undefined ref2=ref1 + typeset cmd=(unset $@); echo "#" $cmd; $cmd + typeset -p ref1 ref2 + } + typeset -p undefined 2>&1 + test-unset ref1 + test-unset ref2 + test-unset -m ref1 + test-unset -m ref2 + unfunction test-unset +0:unsetting references to not-yet-defined variables or their referents has no effect +>(eval):typeset:6: no such variable: undefined +># unset ref1 +>typeset -n ref1=undefined +>typeset -n ref2=ref1 +># unset ref2 +>typeset -n ref1=undefined +>typeset -n ref2=ref1 +># unset -m ref1 +>typeset -n ref1=undefined +>typeset -n ref2=ref1 +># unset -m ref2 +>typeset -n ref1=undefined +>typeset -n ref2=ref1 + + test-unset() { + typeset -n refg1=g1 refl1=l1 + () { + typeset -g g1=glb1 g2=glb2 + typeset l1=lcl1 l2=lcl2 + () { + typeset -n refg2=g2 refl2=l2 + typeset cmd=(unset $@ refg1 refg2 refl1 refl2); echo "#" $cmd; $cmd + } $@ + typeset -p g1 g2 l1 l2 2>&1 + } $@ + unset g1 g2 + } + test-unset + test-unset -m + unfunction test-unset +0:unsetting references referring to parameters in enclosing scopes unsets the parameters +># unset refg1 refg2 refl1 refl2 +>(anon):typeset:7: no such variable: g1 +>(anon):typeset:7: no such variable: g2 +># unset -m refg1 refg2 refl1 refl2 +>(anon):typeset:7: no such variable: g1 +>(anon):typeset:7: no such variable: g2 + + test-unset() { + typeset -g g=glb + typeset l=lcl + typeset -n refg=g refl=l + () { + typeset g=hide-g + typeset l=hide-l + typeset cmd=(unset $@ refg refl); echo "#" $cmd; $cmd + echo "# inner scope" + typeset -p g l 2>&1 + } $@ + echo "# outer scope" + typeset -p g l 2>&1 + unset g + } + test-unset + test-unset -m + unfunction test-unset +0:unsetting references referring to hidden parameters unsets the hidden parameters +># unset refg refl +># inner scope +>typeset g=hide-g +>typeset l=hide-l +># outer scope +>test-unset:typeset:12: no such variable: g +># unset -m refg refl +># inner scope +>typeset g=hide-g +>typeset l=hide-l +># outer scope +>test-unset:typeset:12: no such variable: g + typeset -n ref1 typeset -n ref2 typeset -n ref3=ref2 @@ -2016,4 +2349,18 @@ F:converting from association/array to string should work here too >B:16#FF >C:16#FF + typeset -n ref1 + setopt allexport + ref1=var + typeset -n ref2 + unsetopt allexport + typeset -p ref1 ref2 +0:references are not exported +>typeset -n ref1=var +>typeset -n ref2 + + typeset -hn ref_h + typeset -Hn ref_H +0:unsusual but legal option combinations + %clean diff --git a/Test/V06parameter.ztst b/Test/V06parameter.ztst index 27d587852..c1f47a9dc 100644 --- a/Test/V06parameter.ztst +++ b/Test/V06parameter.ztst @@ -92,6 +92,25 @@ >foo >bar + for 1 in hash_cmds no_hash_cmds; do + ( + setopt no_hash_list_all $1 + : > ls + chmod +x ls + rm=$commands[rm] + path=( $PWD ) + rehash + a=$commands[ls] + $rm ls + b=$commands[ls] + [[ $a == $b ]] + print -r - $? $a:$b + ) + done +-:workers/54617: $commands look-up with no_hash_list_all +*>0 */ls:*/ls +*>1 */ls: + %clean rm -f autofn functrace.zsh rocky3.zsh sourcedfile myfunc diff --git a/Test/V08zpty.ztst b/Test/V08zpty.ztst index 057db2e18..cad6bb9bd 100644 --- a/Test/V08zpty.ztst +++ b/Test/V08zpty.ztst @@ -25,3 +25,15 @@ zpty -d cat 0:zpty with a process that does not set up the terminal: write via stdin >a line of text + + zpty loop 'while read; do echo hello; done' + zpty -w loop hi + zpty -rt loop | tr -d $'\r' + zpty -w loop hi + zpty -t loop + zpty -rt loop | tr -d $'\r' + zpty -rt loop + zpty -d loop +0:zpty doesn't duplicate data +>hello +>hello diff --git a/Test/V09datetime.ztst b/Test/V09datetime.ztst index 0eae31687..cbf6967b0 100644 --- a/Test/V09datetime.ztst +++ b/Test/V09datetime.ztst @@ -79,8 +79,8 @@ >1973^@03^@03 # We assume '%@' is not a valid format on any OSs. -# The result can be '%@' (Linux), '@' (BSDs) or an error (Cygwin). - [[ $(strftime '%@' 0 2> /dev/null) == (%|)@ || $? != 0 ]] +# The result can be '%@' (Linux), '@' (BSDs), '' (musl), or an error (Cygwin). + [[ $(strftime '%@' 0 2> /dev/null) == ((%|)@|) || $? != 0 ]] 0:bad format specifier # This test may fail at 23:59:59.xxx on New Year's Eve :/ diff --git a/Test/V11db_gdbm.ztst b/Test/V11db_gdbm.ztst index 6d74cef2c..1ac9fc0c2 100644 --- a/Test/V11db_gdbm.ztst +++ b/Test/V11db_gdbm.ztst @@ -204,34 +204,67 @@ local -a dbase dbase=( fromarray ) () { - local -a dbase + local dbase + () { ztie -d db/gdbm -f $dbfile dbase - echo ${(t)dbase} - zuntie dbase + echo "Connected:" $dbase[a] + } + echo "Still connected:" $dbase[a] } echo $dbase[1] ztie -d db/gdbm -f $dbfile dbase2 echo "Can connect, so untie happened:" $dbase2[a] zuntie dbase2 0:Test of automatic untie (use of local scope) and of scoping ->association-local-special +>Connected: b +>Still connected: b >fromarray >Can connect, so untie happened: b + local dbase + () { + local -n rbase=dbase + local dbase=not-a-dbase + ztie -d db/gdbm -f $dbfile rbase + echo $dbase + echo "Connected:" $rbase[a] + zuntie rbase + echo "Disconnected:" $rbase[a] + ztie -d db/gdbm -f $dbfile rbase + echo "Reconnected:" $rbase[a] + echo $dbase + } + echo "Still connected:" $dbase[a] + zuntie dbase +0:Test of tie to hidden local via named reference +>not-a-dbase +>Connected: b +>Disconnected: +>Reconnected: b +>not-a-dbase +>Still connected: b + echo $zgdbm_tied ${#zgdbm_tied} ztie -r -d db/gdbm -f $dbfile dbase echo $zgdbm_tied ${#zgdbm_tied} ztie -d db/gdbm -f ${dbfile}2 dbase2 echo $zgdbm_tied ${#zgdbm_tied} + local -n rbase3=dbase3 + ztie -d db/gdbm -f ${dbfile}3 rbase3 + echo $zgdbm_tied ${#zgdbm_tied} zuntie -u dbase echo $zgdbm_tied ${#zgdbm_tied} zuntie dbase2 echo $zgdbm_tied ${#zgdbm_tied} + zuntie rbase3 + echo $zgdbm_tied ${#zgdbm_tied} 0:zgdbm_tied parameter >0 >dbase 1 >dbase dbase2 2 ->dbase2 1 +>dbase dbase2 dbase3 3 +>dbase2 dbase3 2 +>dbase3 1 >0 unset zgdbm_tied 2>/dev/null @@ -311,9 +344,15 @@ zgdbmpath dbase [[ $REPLY = */Test/db.gdbm ]] && echo correct zuntie -u dbase + local -n rbase=dbase + ztie -r -d db/gdbm -f $dbfile rbase + zgdbmpath rbase + [[ $REPLY = */Test/db.gdbm ]] && echo correct + zuntie -u rbase 0:zgdbmpath builtin >correct >correct +>correct ztie -d db/gdbm -f $dbfile dbase fun() { while read line; do echo $line; done } diff --git a/Test/V13zformat.ztst b/Test/V13zformat.ztst index 035a0a495..72c4229a1 100644 --- a/Test/V13zformat.ztst +++ b/Test/V13zformat.ztst @@ -89,3 +89,251 @@ >ipsum.bar >bazbaz >\esc:ape + + zformat REPLY '' + zformat REPLY '' x: +1:one of -f -F -a required +?(eval):zformat:1: one of -afF expected +?(eval):zformat:2: one of -afF expected + + zformat -fff REPLY '' + zformat -FFF REPLY '' + zformat -aaa reply . +0:duplicate -f -F -a ignored + + zformat -af REPLY '' + zformat -fF REPLY '' x: +1:more than one of -f -F -a not allowed +?(eval):zformat:1: only one of -afF allowed +?(eval):zformat:2: only one of -afF allowed + + zformat -f + zformat -f REPLY + zformat -F + zformat -F REPLY +1:-f and -F: param and format string required +?(eval):zformat:1: not enough arguments +?(eval):zformat:2: not enough arguments +?(eval):zformat:3: not enough arguments +?(eval):zformat:4: not enough arguments + + zformat -a + zformat -a reply +1:-a: param and separator required +?(eval):zformat:1: not enough arguments +?(eval):zformat:2: not enough arguments + + zformat -a reply '' a:b && print -rl - $reply +0:-a with empty separator +>ab + + zformat -F REPLY '<%1d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%2d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%3d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%.1d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%.2d>' 'd:é' && print -r - $REPLY + zformat -F REPLY '<%.3d>' 'd:é' && print -r - $REPLY +0f:width specifier is multi-byte-aware +><é> +><é > +><é > +><é> +><é> +><é> + + zformat -F REPLY %B && print -r - $REPLY + zformat -F REPLY %3B && print -r - $REPLY +0:sequence with no matching spec falls through +>%B +>%3B + + for 1 in - . 0 9; do + REPLY1= REPLY2= + zformat -F REPLY1 %$1 + zformat -F REPLY2 %1$1 + zformat -F REPLY3 %1%$1 + print -r - $REPLY1 $REPLY2 $REPLY3 + done +0:impossible spec in format string +>%- %1- %1%- +>%. %1. %1%. +>%0 %10 %1%0 +>%9 %19 %1%9 + + # extra char at end to avoid triggering premature eos condition + zformat -F REPLY '%% %3% %) %3) x' + print -r - $REPLY +0:%% and %) in format string +>% %3% ) %3) x + + for 1 in % %% %%% %%%% %%%%% %%%%%%; do + zformat -F REPLY $1 && + print -r - $REPLY + done +0:more literal % in format string +>% +>% +>%% +>%% +>%%% +>%%% + + for 1 in % \) - . 0 9 ''; do + zformat -F REPLY '' $1: + done +1:spec with invalid char +?(eval):zformat:2: invalid spec: %: +?(eval):zformat:2: invalid spec: ): +?(eval):zformat:2: invalid spec: -: +?(eval):zformat:2: invalid spec: .: +?(eval):zformat:2: invalid spec: 0: +?(eval):zformat:2: invalid spec: 9: +?(eval):zformat:2: invalid spec: : + + zformat -F REPLY '' ab: + zformat -F REPLY '' é: +-:spec char longer than 1 byte +?(eval):zformat:1: invalid spec: ab: +?(eval):zformat:2: invalid spec: \M-C\M-): + + for 1 in ! $ + , : \; \\ $'\a' $'\xff'; do + zformat -F REPLY "<%$1>" $1:$1 && + print -r - ${(V)REPLY} + done +0:weird spec char +><!> +><$> +><+> +><,> +><:> +><;> +><\> +><^G> +><\M-^?> + + zformat -F REPLY '%(' && + print -r - $REPLY +0:%( at end of format string +>%( + + zformat -F REPLY '%(.' + zformat -F REPLY '%()' + zformat -F REPLY '%(..)' + zformat -F REPLY '<%(>' +1:incomplete ternary expression +?(eval):zformat:1: malformed format string: %(. +?(eval):zformat:2: malformed format string: %() +?(eval):zformat:3: malformed format string: %(..) +?(eval):zformat:4: malformed format string: <%(> + + for 1 in % - . 0 9; do + zformat -F REPLY "%($1.true.false)" && + print -r - $REPLY + done +1:ternary expression with impossible spec char +>false +?(eval):zformat:2: malformed format string: %(-.true.false) +>false +?(eval):zformat:2: malformed format string: %(0.true.false) +?(eval):zformat:2: malformed format string: %(9.true.false) + + for 1 in ! / : @; do + zformat -F REPLY "%(x${1}true${1}false)" && + print -r - $REPLY + done +0:ternary expression with alternate delimiters +>false +>false +>false +>false + + zformat -F REPLY '%(x.%t.%f)' x:123 t:true f:false && print -r - $REPLY + zformat -F REPLY '%(X.%t.%f)' x:123 t:true f:false && print -r - $REPLY +0:ternary expression returning matching spec +>true +>false + + zformat -F REPLY '%(x.%T.%F)' x:123 && print -r - $REPLY + zformat -F REPLY '%(X.%T.%F)' x:123 && print -r - $REPLY +0:ternary expression returning non-matching spec +>%T +>%F + + zformat -F REPLY '%(x/%../%--)' x:123 && print -r - $REPLY + zformat -F REPLY '%(X/%../%--)' x:123 && print -r - $REPLY + zformat -F REPLY '%(X.%1%-.%2%-)' x:123 && print -r - $REPLY +0:ternary expression returning impossible spec +>%.. +>%-- +>%2%- + + zformat -F REPLY '%(x.%%.%))' x:123 && print -r - $REPLY + zformat -F REPLY '%(X.%%.%))' x:123 && print -r - $REPLY +0:ternary expression returning literal % or ) +>% +>) + + zformat -qa reply . + zformat -aq reply . + zformat -aQ reply . +1:-a + -qQ not allowed +?(eval):zformat:1: -qQ not allowed with -a +?(eval):zformat:2: -qQ not allowed with -a +?(eval):zformat:3: -qQ not allowed with -a + + zformat -Fq REPLY F && print -r - $REPLY + zformat -qF REPLY F && print -r - $REPLY + zformat -FqF REPLY F && print -r - $REPLY + zformat -qqF REPLY F && print -r - $REPLY + zformat -qQF REPLY F && print -r - $REPLY +1:more than one of -qQ not allowed +>F +>F +>F +>F +?(eval):zformat:5: only one of -qQ allowed + + for 1 in -F -FQ -Fq; do + zformat $1 REPLY '%a, %b, %c, %d, %%e' a:%aaa% %b:%bbb% %%c:%ccc% + print -r - $REPLY + done +0:spec quoting indicators, -Q vs -q +>%aaa%, %%bbb%%, %ccc%, %d, %e +>%%aaa%%, %%bbb%%, %ccc%, %d, %e +>%%aaa%%, %%bbb%%, %ccc%, %d, %%e + + zformat -Fq REPLY '%(x.%%/%d.%%/%D)' x:1 d:%foo% D:%bar% && print -r - $REPLY + zformat -Fq REPLY '%(X.%%/%d.%%/%D)' x:1 d:%foo% D:%bar% && print -r - $REPLY +0:-q with ternary expression +>%%/%%foo%% +>%%/%%bar%% + + zformat -Fq REPLY '<%1d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%5d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%6d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%7d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%-7d>' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '<%-7d>' d:foo && print -r - $REPLY +0:-q: min-width specifier ignores extra %s +><%%foo%%> +><%%foo%%> +><%%foo%% > +><%%foo%% > +>< %%foo%%> +>< foo> + + zformat -Fq REPLY '%.1d' d:foo && print -r - $REPLY + zformat -Fq REPLY '%.1d' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '%.4d' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '%.5d' d:%foo% && print -r - $REPLY +0:-q: max-width specifier ignores extra %s +>f +>%% +>%%foo +>%%foo%% + + zformat -Fq REPLY '%4(d.t.f) %5(d.t.f) %6(d.t.f)' d:%foo% && print -r - $REPLY + zformat -Fq REPLY '%-6(d.t.f) %-5(d.t.f) %-4(d.t.f)' d:%foo% && print -r - $REPLY +0:-q: ternary width test ignores extra %s +>t f f +>t t f diff --git a/Test/V15nearcolor.ztst b/Test/V15nearcolor.ztst new file mode 100644 index 000000000..52c6ab2f1 --- /dev/null +++ b/Test/V15nearcolor.ztst @@ -0,0 +1,100 @@ +# tests for the zsh/nearcolor module + +%prep + + if ! zmodload -s zsh/nearcolor; then + ZTST_unimplemented='the zsh/nearcolor module is not available' + elif ! zmodload -s zsh/terminfo; then + ZTST_unimplemented='the zsh/terminfo module is not available' + fi + + term88= term256= + local t + for t in xterm-88color rxvt-unicode rxvt-88color; do + if ( TERM=$t; [[ $terminfo[colors] == 88 ]] ) 2> /dev/null; then + term88=$t + break + fi + done + for t in xterm-256color rxvt-256color; do + if ( TERM=$t; [[ $terminfo[colors] == 256 ]] ) 2> /dev/null; then + term256=$t + break + fi + done + if [[ -z $term88 && -z $term256 ]]; then + ZTST_unimplemented='no 88- and 256-color terminals' + else + print -u $ZTST_fd "88-color terminal: ${term88:-not found}" + print -u $ZTST_fd "256-color terminal: ${term256:-not found}" + fi + +%test + + for 1 in $term88 $term256; do + for 2 in '' -truecolor; do ( + TERM=$1 + typeset -a .term.extensions=( $2 ) + zmodload -iu zsh/nearcolor + zmodload | grep -q zsh/nearcolor && echo unexpectedly loaded + : ${(%):-'%F{#123456}'} + zmodload | grep -q zsh/nearcolor || echo not autoloaded + ); done + done +0:automatically loaded without truecolor extension + + for 1 in $term88 $term256; do ( + TERM=$1 + typeset -a .term.extensions=( truecolor ) + zmodload -iu zsh/nearcolor + zmodload | grep -q zsh/nearcolor && echo unexpectedly loaded + : ${(%):-'%F{#123456}'} + zmodload | grep -q zsh/nearcolor && echo unexpectedly loaded + ); done +1:not automatically loaded with truecolor extension + +# see https://github.com/exg/rxvt-unicode/blob/5865a435983be27c/src/init.C#L213 + if [[ -z $term88 ]]; then + ZTST_skip='88-color conversion (no 88-color terminal)' + else + ( + TERM=$term88 + for 1 in 123456 654321 8a6cb4 8bffcd a5e02d cccccc d0d0d0 f00 0f0 00f; do + print -r - $1 ${(V)${(%):-"%F{#$1}"}} + done + ) + fi +0:88-colour conversion +>123456 ^[[38;5;80m +>654321 ^[[38;5;81m +>8a6cb4 ^[[38;5;38m +>8bffcd ^[[38;5;46m +>a5e02d ^[[38;5;40m +>cccccc ^[[38;5;58m +>d0d0d0 ^[[38;5;86m +>f00 ^[[38;5;64m +>0f0 ^[[38;5;28m +>00f ^[[38;5;19m + +# see https://github.com/exg/rxvt-unicode/blob/5865a435983be27c/src/init.C#L293 + if [[ -z $term256 ]]; then + ZTST_skip='256-color conversion (no 256-color terminal)' + else + ( + TERM=$term256 + for 1 in 123456 654321 87af5f 8a6cb4 a5e02d cccccc d0d0d0 f00 0f0 00f; do + print -r - $1 ${(V)${(%):-"%F{#$1}"}} + done + ) + fi +0:256-colour conversion +>123456 ^[[38;5;24m +>654321 ^[[38;5;95m +>87af5f ^[[38;5;107m +>8a6cb4 ^[[38;5;97m +>a5e02d ^[[38;5;148m +>cccccc ^[[38;5;252m +>d0d0d0 ^[[38;5;252m +>f00 ^[[38;5;196m +>0f0 ^[[38;5;46m +>00f ^[[38;5;21m diff --git a/Test/W01history.ztst b/Test/W01history.ztst index 1d3f3cf6f..665a37f2c 100644 --- a/Test/W01history.ztst +++ b/Test/W01history.ztst @@ -6,26 +6,26 @@ %test - $ZTST_testdir/../Src/zsh -fis <<<' - print one two three four five six seven eight nine ten - print !:$ !:10 !:9 !:1 !:0 - print one two three four five six seven eight nine ten - print !:0-$ !:1-2 - ' 2>/dev/null + PS1= $ZTST_testdir/../Src/zsh -fis <<<' + print one two three four five six seven eight nine ten + print !:$ !:10 !:9 !:1 !:0 + print one two three four five six seven eight nine ten + print !:0-$ !:1-2 + ' 0:History word references >one two three four five six seven eight nine ten >ten ten nine one print >one two three four five six seven eight nine ten >print one two three four five six seven eight nine ten one two - $ZTST_testdir/../Src/zsh -fis <<<' - print line one of an arbitrary series - print issue two for some mystery sequence - print !-1:5-$ - print !1:2 - print !2:2 - print !-3:1-$ - ' 2>/dev/null + PS1= $ZTST_testdir/../Src/zsh -fis <<<' + print line one of an arbitrary series + print issue two for some mystery sequence + print !-1:5-$ + print !1:2 + print !2:2 + print !-3:1-$ + ' 0:History line numbering >line one of an arbitrary series >issue two for some mystery sequence @@ -34,12 +34,12 @@ >two >mystery sequence - $ZTST_testdir/../Src/zsh -fis <<<' - print All metaphor, Malachi, stilts and all - print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/ - print !1:2:& - print -l !1:2-3:gs/a/o/ - ' 2>/dev/null + PS1= $ZTST_testdir/../Src/zsh -fis <<<' + print All metaphor, Malachi, stilts and all + print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/ + print !1:2:& + print -l !1:2-3:gs/a/o/ + ' 0:History substitution >All metaphor, Malachi, stilts and all >metaphor? shmetaphor! @@ -47,10 +47,11 @@ >metophor, >Molochi, - $ZTST_testdir/../Src/zsh -fis <<<' - echo foo bar - echo $(!!) again - echo more $( !! )' 2>/dev/null + PS1= $ZTST_testdir/../Src/zsh -fis <<<' + echo foo bar + echo $(!!) again + echo more $( !! ) + ' 0:Regression test for history references in command substitution >foo bar >foo bar again @@ -59,17 +60,18 @@ 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 + PS1= $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 + ' 0:Modifiers :h and :t with arguments >/my/path/for/testing >/my/path/for/testing @@ -82,26 +84,28 @@ F:Check that a history bug introduced by workers/34160 is working again. >testing >path/for - $ZTST_testdir/../Src/zsh -fis <<<' - echo /my/path/for/testing - echo !1:1:P' 2>/dev/null + PS1= $ZTST_testdir/../Src/zsh -fis <<<' + echo /my/path/for/testing + echo !1:1:P + ' 0:Modifier :P >/my/path/for/testing >/my/path/for/testing - $ZTST_testdir/../Src/zsh -fgis <<<' - SAVEHIST=7 - print -rs "one\\" - print -rs "two\\\\" - print -rs "three\\\\\\" - print -rs "four\\\\\\\\" - print -rs "five\\\\\\\\\\" - print -s "while false\ndo\ntrue\\\\\n && break\ndone" - print -s "echo one\\\\\ntwo" - fc -W hist - fc -p -R hist - fc -l - rm hist' 2>/dev/null + PS1= $ZTST_testdir/../Src/zsh -fgis <<<' + SAVEHIST=7 + print -rs "one\\" + print -rs "two\\\\" + print -rs "three\\\\\\" + print -rs "four\\\\\\\\" + print -rs "five\\\\\\\\\\" + print -s "while false\ndo\ntrue\\\\\n && break\ndone" + print -s "echo one\\\\\ntwo" + fc -W hist + fc -p -R hist + fc -l + rm hist + ' 0:Lines ending in backslash saved and restored to history > 1 one\ > 2 two\\ diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst index d52888dd9..bdb6ab979 100644 --- a/Test/W02jobs.ztst +++ b/Test/W02jobs.ztst @@ -3,10 +3,12 @@ %prep if zmodload zsh/zpty 2> /dev/null; then + export ZTST_fd zpty_start() { export PS1= PS2= zpty -d zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z" + zpty -w zsh 'alias sleep="sleep </dev/null >/dev/null 2>&1"; exec {ZTST_fd}>&-' } zpty_input() { zpty -w zsh "${(F)@}" $'\n' @@ -22,8 +24,7 @@ zpty_stop() { # exit twice in case of check_jobs zpty -w zsh $'exit\nexit\n' - # zpty gives no output when piped without these braces (?) - { zpty -r zsh } | sed $'/[^[:space:]]/!d; s/\r$//;' + zpty -r zsh | sed $'/[^[:space:]]/!d; s/\r$//;' zpty -d : } @@ -193,6 +194,143 @@ *>\[2] ? interrupt*sleep* *>\[1] ? kill*sleep* + zpty_start + zpty_input jobs + zpty_input '( jobs ); :' + zpty_stop +0:jobs with no jobs + + zpty_start + zpty_input 'sleep 2 &; ( jobs ); disown' + zpty_stop +0:jobs in sub-shell with job in parent shell +*>\[1] <-> +*>\[1] + * sleep 2* + + zpty_start + zpty_input '( sleep 2 &; jobs ); :' + zpty_stop +0:jobs in sub-shell with job in same shell +*>\[2] + * sleep 2* + + zpty_start + zpty_input 'sleep 2 &; jobs; ( sleep 3 &; jobs ); jobs; disown' + zpty_stop +0:jobs in sub-shell with job in parent + same shell +*>\[1] <-> +*>\[1] + * sleep 2* +*>\[2] + * sleep 3* +*>\[1] + * sleep 2* + + zpty_start + zpty_input '( sleep 2 &; sleep 3 &; jobs ); :' + zpty_stop +0:jobs in sub-shell with two jobs in same shell +*>\[2] - * sleep 2* +*>\[3] + * sleep 3* + + zpty_start + zpty_input 'sleep 2 &; sleep 3 &; disown; jobs; disown' + zpty_stop +0:disown current job +*>\[1] <-> +*>\[2] <-> +*>\[1] + * sleep 2* + + zpty_start + zpty_input disown + zpty_stop +0:disown with no jobs +>disown: no current job + + zpty_start + zpty_input 'sleep 2 &; ( disown ); jobs; disown' + zpty_stop +0:disown in sub-shell with job in parent shell +*>\[1] <-> +*>disown: can't manipulate jobs in subshell +*>\[1] + * sleep 2* + + zpty_start + zpty_input '( sleep 3 &; disown; jobs ); :' + zpty_stop +0:disown in sub-shell with job in same shell + + zpty_start + zpty_input 'sleep 2 &; ( sleep 3 &; disown; jobs ); jobs; disown' + zpty_stop +0:disown in sub-shell with job in parent + same shell +*>\[1] <-> +*>\[1] + * sleep 2* + +# @todo apparently testing suspended jobs with zpty is error-prone. see above +# zpty_start +# zpty_input 'sleep 3 &' +# zpty_input 'kill -STOP ${${=${ jobs -p }}[3]}' +# zpty_input 'disown' +# zpty_stop +#0:disown with stopped job +#*>\[1] <-> +#*>\[1] * suspended * sleep 3 +#*>disown: warning: job is suspended* + + zpty_start + zpty_input 'sleep 2 &; sleep 3 &; sleep 4 &; disown -a; jobs' + zpty_stop +0:disown -a +*>\[1] <-> +*>\[2] <-> +*>\[3] <-> + + zpty_start + zpty_input '( sleep 2 &; sleep 3 &; sleep 4 &; disown -a; jobs ); :' + zpty_stop +0:disown -a in sub-shell + + zpty_start + zpty_input 'sleep 2 &; sleep 3 &|; jobs; disown' + zpty_input 'sleep 2 &; sleep 3 &!; jobs; disown' + zpty_stop +0:background and disown with &| and &! +*>\[1] <-> +*>\[1] * sleep 2* +*>\[1] <-> +*>\[1] * sleep 2* + + zpty_start + zpty_input '( fg ); :' + zpty_input '( bg ); :' + zpty_stop +0:fg + bg in sub-shell +*>fg: no job control in this shell +*>bg: no job control in this shell + +# The following test exercises a bug where setprevjob() could pick an +# internal NOPRINT job (e.g. a builtin's own job entry) as the previous +# job. This happened when a function superjob was involved, because the +# superjob's subjob was excluded but the builtin job was not. +# The function's child stops itself, triggering the superjob mechanism. +# Then fg %- resumes the superjob (which exits since the child is done). +# Afterwards, the remaining sleep job should still be accessible. + zpty_start + zpty_input "f() { sh -c 'kill -TSTP 0' }" + zpty_input 'f' + zpty_line # consume stopped message from f + zpty_input 'sleep 100 &' + zpty_line # consume [N] PID + zpty_input 'kill -STOP %sleep' + zpty_line # consume stopped message from kill + zpty_input 'fg %-' + zpty_line # consume continued message + zpty_input 'jobs' + zpty_stop +0:fg %- with function superjob does not pick internal job as previous +*>zsh:*(stopped|suspended)* +*>\[[0-9]##\] [0-9]## +*>\[[0-9]##\] + (stopped|suspended)*sleep* +*>\[[0-9]##\] continued* +*>\[[0-9]##\] + (stopped|suspended)*sleep* + %clean zmodload -ui zsh/zpty diff --git a/Test/W03jobparameters.ztst b/Test/W03jobparameters.ztst index a6f7a09b1..6b2b80d54 100644 --- a/Test/W03jobparameters.ztst +++ b/Test/W03jobparameters.ztst @@ -50,8 +50,7 @@ *>zsh:*SIGHUPed* # $jobstates refers to a job started in the main shell unless -# one has been started in the subshell. In the latter case, -# the subshell has no job control so the job is not marked as current. +# one has been started in the subshell. zpty_start zpty_input "MODULE_PATH=${(q)MODULE_PATH}" zpty_input 'sleep 3 &' @@ -63,7 +62,7 @@ >main *>running:+:*=running >sub -*>running::*=running +*>running:+:*=running *>zsh:*SIGHUPed* # output from zpty removes empty lines @@ -75,4 +74,4 @@ 0:$jobstate shows no job started in main shell but one started in subshell >main >sub -*>running::*=running +*>running:+:*=running diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst index 53d49df37..57cac2883 100644 --- a/Test/Y01completion.ztst +++ b/Test/Y01completion.ztst @@ -153,6 +153,31 @@ F:regression test workers/51641 >FI:{file1} >FI:{file2} + comptesteval '_tst() { compadd -V grp -S /a foo bar; compadd -V grp -S /b foo baz }' + comptest $'tst \t' +0:nosort dedup hides same-string non-duplicate matches +>line: {tst }{} +>NO:{foo} +>NO:{bar} +>NO:{baz} + + comptesteval '_tst() { local disp1=(Foo Bar); compadd -V grp -d disp1 -S /a foo bar; local disp2=(Foo Baz); compadd -V grp -d disp2 -S /b foo baz; }' + comptest $'tst \t' +0:nosort dedup with display strings does not hide same-string non-duplicate matches +>line: {tst }{} +>NO:{Foo} +>NO:{Bar} +>NO:{Foo} +>NO:{Baz} + + comptesteval '_tst() { compadd -V grp -S /a foo; compadd -V grp -S /b foo; compadd -V grp -S /c foo; compadd -V grp bar baz }' + comptest $'tst \t' +0:nosort dedup with three same-string non-duplicates +>line: {tst }{} +>NO:{foo} +>NO:{bar} +>NO:{baz} + # Temporarily modify format set in comptest comptesteval 'zstyle -s ":completion:*:descriptions" format oldfmt' comptesteval 'zstyle ":completion:*:descriptions" format \ @@ -393,6 +418,25 @@ F:regression test workers/31611 >NO:{y} >NO:{z} + comptesteval '_tst() { _message "%foo %BAR" }' + comptest $'tst \t' +0:% in message +>line: {tst }{} +>MESSAGE:{%foo %BAR} + + comptesteval '_tst() { _message -e abc }' + comptest $'tst \t' + comptesteval '_tst() { _message -e - abc }' + comptest $'tst \t' + comptesteval '_tst() { _message -e - tag abc }' + comptest $'tst \t' +0:_message -e +>line: {tst }{} +>DESCRIPTION:{abc} +>line: {tst }{} +>DESCRIPTION:{abc} +>line: {tst }{} +>DESCRIPTION:{abc} %clean diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst index 200c83e8c..6ff9bf0a5 100644 --- a/Test/Y03arguments.ztst +++ b/Test/Y03arguments.ztst @@ -373,20 +373,35 @@ tst_arguments -S -x ':word:()' comptest $'tst -- -\t' -0:disallowed option after -- +0:-S: disallowed option after -- >line: {tst -- -}{} tst_arguments -S -x ':word:()' + comptest $'tst - -\t' +0:-S: allowed option after - +>line: {tst - -x }{} + + tst_arguments -S -x ':word:()' comptest $'tst - --\eB\C-b\t' -0:allowed option before -- +0:-S: allowed option before -- >line: {tst -x }{ --} tst_arguments -S '1:one' '2:two' comptest $'tst -- -- \t' -0:only first of duplicate -- is ignored +0:-S: only first of duplicate -- is ignored >line: {tst -- -- }{} >DESCRIPTION:{two} + tst_arguments -S -S -x ':word:()' + comptest $'tst -- -\t' +0:-S -S: disallowed option after -- +>line: {tst -- -}{} + + tst_arguments -S -S -x ':word:()' + comptest $'tst - -\t' +0:-S -S: disallowed option after - +>line: {tst - -}{} + tst_arguments -x :word comptest $'tst word -\t' 0:option after a word @@ -641,16 +656,75 @@ F:shouldn't offer -b as it is already on the command-line >NO:{-b} >NO:{-c} + tst_arguments : -a:arg -b -c --d + comptest $'tst -a -b -\t' + comptest $'tst -a --d -\t' +0:single optarg that looks like an option +>line: {tst -a -b -}{} +>DESCRIPTION:{option} +>NO:{--d} +>NO:{-b} +>NO:{-c} +>line: {tst -a --d -}{} +>DESCRIPTION:{option} +>NO:{--d} +>NO:{-b} +>NO:{-c} + + tst_arguments : -a:arg1::arg2::arg3 -b -c -d: --e --f --g: + comptest $'tst -a -b -c -d -\t' + comptest $'tst -a --e --f --g -\t' +0:multiple optargs that look like options +>line: {tst -a -b -c -d -}{} +>DESCRIPTION:{option} +>NO:{--e} +>NO:{--f} +>NO:{--g} +>NO:{-b} +>NO:{-c} +>NO:{-d} +>line: {tst -a --e --f --g -}{} +>DESCRIPTION:{option} +>NO:{--e} +>NO:{--f} +>NO:{--g} +>NO:{-b} +>NO:{-c} +>NO:{-d} + + tst_arguments : - set1 -a: -b -c - set2 -d: -e -f + comptest $'tst -a -b -\t' + comptest $'tst -d -e -\t' +0:optarg that look like an option in a set +>line: {tst -a -b -}{} +>DESCRIPTION:{option} +>NO:{-b} +>NO:{-c} +>line: {tst -d -e -}{} +>DESCRIPTION:{option} +>NO:{-e} +>NO:{-f} + + tst_arguments -S -S : -a: -b -c + comptest $'tst -a - -\t' + comptest $'tst -a -- -\t' +0:optarg that looks like a terminator +>line: {tst -a - -}{} +>DESCRIPTION:{option} +>NO:{-b} +>NO:{-c} +>line: {tst -a -- -}{} +>DESCRIPTION:{option} +>NO:{-b} +>NO:{-c} + tst_arguments '-a:arg' -b '(-b)-c' comptest $'tst -a -c -\t' 0:exclusion with option argument that looks like an option >line: {tst -a -c -}{} ->MESSAGE:{no arguments} -F:The current behaviour is wrong; the correct expected output is: -F:>line: {tst -a -c -}{} -F:>DESCRIPTION:{option} -F:>NO:{-b} -F:>NO:{-c} +>DESCRIPTION:{option} +>NO:{-b} +>NO:{-c} tst_arguments + grp1 -a -b - onlyset '(-a grp3--y grp2 grp4--)-m' -n + grp2 -u -v + grp3 -x -y + grp4 -0 ':rest' comptest $'tst -m -\t' @@ -713,6 +787,35 @@ F:should offer both sets of arguments in first case >NO:{-d} F:shouldn't offer -t in the first case (with stacked options) + tst_arguments -s : - set1 -a -b -c+: --d=: - set2 -e -f + comptest $'tst -ab -\t' # stack with known options + comptest $'tst -ax -\t' # stack with unknown option + comptest $'tst -cx -\t' # short option with same-word optarg + comptest $'tst --d=x -\t' # long option with same-word optarg +0:detection of foreign-set option in stack or with same-word optarg +>line: {tst -ab -}{} +>DESCRIPTION:{option} +>NO:{--d} +>NO:{-c} +>line: {tst -ax -}{} +>DESCRIPTION:{option} +>NO:{--d} +>NO:{-a} +>NO:{-b} +>NO:{-c} +>NO:{-e} +>NO:{-f} +>line: {tst -cx -}{} +>DESCRIPTION:{option} +>NO:{--d} +>NO:{-a} +>NO:{-b} +>line: {tst --d=x -}{} +>DESCRIPTION:{option} +>NO:{-a} +>NO:{-b} +>NO:{-c} + tst_arguments -s '(set-a set--b grp-a grp--b grp-)-a' - set-a -s - set--b -t + grp-a -g + grp--b -h + grp- -i comptest $'tst -a\t' 0:sets and groups with - in their name @@ -796,6 +899,25 @@ F:shouldn't offer -t in the first case (with stacked options) >DESCRIPTION:{option} >NO:{-b} + tst_arguments : '-x+[%2Fxdesc%f]:%2Fxargdesc%f' -y '1:%2F1desc%f' + comptest $'tst -\t' + comptest $'tst -x\t' +0:% in descriptions +>line: {tst -}{} +>DESCRIPTION:{%2F1desc%f} +>DESCRIPTION:{option} +>NO:{-x -- %2Fxdesc%f} +>NO:{-y} +>line: {tst -x}{} +>DESCRIPTION:{%2Fxargdesc%f} + + tst_arguments : -x '-y[]' + comptest $'tst -\t' +0:empty description +>line: {tst -}{} +>DESCRIPTION:{option} +>NO:{-x} +>NO:{-y} %clean diff --git a/Test/Y05describe.ztst b/Test/Y05describe.ztst index ee8717a24..72953af7c 100644 --- a/Test/Y05describe.ztst +++ b/Test/Y05describe.ztst @@ -92,6 +92,14 @@ >NO:{x} >line: {tst cx}{} + tst_describe %2Fdesc%f '(a:adesc b:%2Fbdesc%f)' + comptest $'tst \t' +0:% in descriptions +>line: {tst }{} +>DESCRIPTION:{%2Fdesc%f} +>NO:{a -- adesc} +>NO:{b -- %2Fbdesc%f} + %clean zmodload -ui zsh/zpty diff --git a/Test/Y06values.ztst b/Test/Y06values.ztst index b80cc2927..720f990a5 100644 --- a/Test/Y06values.ztst +++ b/Test/Y06values.ztst @@ -233,6 +233,14 @@ >NO:{a} >NO:{d} + tst_values %2Fdesc%f 'a[adesc]' 'b[%2Fbdesc%f]' + comptest $'tst \t' +0:% in descriptions +>line: {tst }{} +>DESCRIPTION:{%2Fdesc%f} +>NO:{a -- adesc} +>NO:{b -- %2Fbdesc%f} + %clean zmodload -ui zsh/zpty diff --git a/Test/Y07call_program.ztst b/Test/Y07call_program.ztst new file mode 100644 index 000000000..19eca8f9f --- /dev/null +++ b/Test/Y07call_program.ztst @@ -0,0 +1,107 @@ +# tests for _call_program + +%prep + + if ( zmodload -s zsh/zpty ); then + source $ZTST_srcdir/comptest + mkdir comp.tmp + cd comp.tmp + comptestinit -z $ZTST_testdir/../Src/zsh && { + comptesteval ' + pp() { printf "<%s>" "$@"; print } + compdef _tst tst + ' + tst_call_program() { + comptesteval "_tst() { + [[ ${(q+)1} == -[lpqQ]#p[lpqQ]# ]] && + local -a _comp_priv_prefix=( print -r priv ) + local ret=\${ _call_program ${${(@q+)@}} } + _message - \$ret + }" + comptest $'tst \t' + } + } + else + ZTST_unimplemented='the zsh/zpty module is not available' + fi + +%test + + tst_call_program tag pp a b c + tst_call_program tag pp 'a b c' + tst_call_program tag pp '"a b c"' +0:basic command arguments +>line: {tst }{} +>MESSAGE:{<a><b><c>} +>line: {tst }{} +>MESSAGE:{<a><b><c>} +>line: {tst }{} +>MESSAGE:{<a b c>} + + for 1 in -q -Q; do + tst_call_program $1 tag pp $1 a b c + tst_call_program $1 tag pp $1 'a b c' + tst_call_program $1 tag pp $1 '"a b c"' + done +0:-qQ: argument quoting +>line: {tst }{} +>MESSAGE:{<-q><a><b><c>} +>line: {tst }{} +>MESSAGE:{<-q><a b c>} +>line: {tst }{} +>MESSAGE:{<-q><"a b c">} +>line: {tst }{} +>MESSAGE:{<-Q><a><b><c>} +>line: {tst }{} +>MESSAGE:{<-Q><a b c>} +>line: {tst }{} +>MESSAGE:{<-Q><"a b c">} + + tst_call_program tag '"pp"' a b c + tst_call_program -q tag '"pp"' a b c + tst_call_program -Q tag '"pp"' a b c +0:-qQ: command-name quoting +>line: {tst }{} +>MESSAGE:{<a><b><c>} +>line: {tst }{} +>MESSAGE:{} +>line: {tst }{} +>MESSAGE:{<a><b><c>} + + if [[ -z ${lc::=${ ZTST_find_UTF8 }} ]]; then + ZTST_skip='no utf8 locale' + else + comptesteval "old_LC_ALL=\$LC_ALL; LC_ALL=${(q+)lc}" + for 1 in '' -l; do + tst_call_program $1 tag ' + local -a arr=( z e é ) + print -r - ${(o)arr} + ' + done + comptesteval 'LC_ALL=$old_LC_ALL' + fi +0:-l +>line: {tst }{} +>MESSAGE:{e z é} +>line: {tst }{} +>MESSAGE:{e é z} + + tst_call_program tag print a b c + tst_call_program -p tag print a b c + comptesteval 'zstyle ":completion:*" gain-privileges yes' + tst_call_program tag print a b c + tst_call_program -p tag print a b c + comptesteval 'zstyle -d ":completion:*" gain-privileges' +0:-p +>line: {tst }{} +>MESSAGE:{a b c} +>line: {tst }{} +>MESSAGE:{a b c} +>line: {tst }{} +>MESSAGE:{a b c} +>line: {tst }{} +>MESSAGE:{priv print a b c} + +%clean + + zmodload -ui zsh/zpty diff --git a/Test/Z01is-at-least.ztst b/Test/Z01is-at-least.ztst index 039b3e737..57fb92696 100644 --- a/Test/Z01is-at-least.ztst +++ b/Test/Z01is-at-least.ztst @@ -16,12 +16,27 @@ done 0:is-at-least smoke test - is-at-least 5.8.0.2 5.8 -1f:regression test: Two trailing zeroes are filled in -# TODO: When fixing this, extend the smoke test to cover this. +# versions in v1 should be equal +# versions in v2 should be newer than those in v1 + v1=( 1 1.0 1.0.0 1.0.0.0 1-b 1.X-0 ) + v2=( 1.0.0.1 1.0.1 1.0.1.0 1.0.1.1 1-a-0-1 1-0-a.1) + for (( i = 1; i < $#v1; ++i )); do + for (( j = 1; j < $#v1; ++j )); do + is-at-least $v1[i] $v1[j] || echo "$v1[i] ≰ $v1[j]" + done + done + for (( i = 1; i < $#v1; ++i )); do + for (( j = 1; j < $#v2; ++j )); do + is-at-least $v1[i] $v2[j] || echo "$v1[i] ≰ $v2[j]" + { ! is-at-least $v2[j] $v1[i] } || echo "$v2[j] ≤ $v1[i]" + done + done +0:trailing zeroes are filled in, text-only segments are ignored - is-at-least 5.8.0.2 5.8.0.0 -1:regression test: Two trailing zeroes are filled in -# TODO: Extend the smoke test to cover this. + local min cur + for min cur in 1.2 1.12 1.2b 1.12a 1-a3 1-b1; do + is-at-least $min $cur || echo "$min ≰ $cur" + done +0:numerical or lexical order %clean diff --git a/Test/Z04zgetopt.ztst b/Test/Z04zgetopt.ztst index 4de79b417..a0546990f 100644 --- a/Test/Z04zgetopt.ztst +++ b/Test/Z04zgetopt.ztst @@ -8,13 +8,13 @@ %test - zgetopt -A '' -- a b c zgetopt -A '' -o '' -- a b c zgetopt -A '' -l '' -- a b c -0:-o or -l required -?(eval):zgetopt: missing option spec + zgetopt -A '' -- a b c +2:-o or -l required (usage error) >-- a b c >-- a b c +?(eval):zgetopt: missing option spec zgetopt -A '' -o - -- a b c zgetopt -A '' -o -a -- a b c @@ -198,3 +198,25 @@ arg_p "string with quotes and space: '' \"\" " 0:example from util-linux's getopt-example.bash >-a --a-long -b arg_bs1 -b arg_bs2 --b-long arg_bl1 --b-long arg_bl2 -c arg_cs1 -c '' --c-long arg_cl1 --c-long '' -- not_arg_cs1 not_arg_cl2 arg_p 'string with quotes and space: '\'\'' "" ' + + ( + unfunction zgetopt + autoload -Uz zgetopt + zgetopt + ) + ( + unfunction zgetopt + autoload -Uz zgetopt + zgetopt -o abc -- -ab + print -r - ${(q+)argv} + ) +-:result immediately after auto-load +?(eval):zgetopt: missing option spec +>-a -b -- + + ( + setopt no_function_argzero + zgetopt + ) +-:error name with no_function_argzero +?(eval):zgetopt: missing option spec diff --git a/Test/comptest b/Test/comptest index 39ad14768..13bbce3c8 100644 --- a/Test/comptest +++ b/Test/comptest @@ -21,7 +21,7 @@ comptestinit () { export PS1="<PROMPT>" zpty zsh "$comptest_zsh -f +Z" - zpty -r zsh log1 "*<PROMPT>*" || { + zpty_read log1 "*<PROMPT>*" || { print "first prompt hasn't appeared." return 1 } @@ -99,20 +99,47 @@ bindkey -a "^X" zle-finish ' } +# Reads output until the pattern $2 is matched or the end is reached. +# Detects, prints, and removes any DPUTS messages found in the output. +# Stores the result in the parameter named $1. Returns 0 iff the +# pattern was matched. +zpty_read() { + local logvar=$1 pattern=$2 + zpty -r -m zsh $logvar $pattern + local -i result=$? + zpty_handle_dputs $logvar + return result +} + zpty_flush() { local junk if zpty -r -t zsh junk \*; then + zpty_handle_dputs junk (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "$*: ${(V)junk}" while zpty -r -t zsh junk \* ; do + zpty_handle_dputs junk (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "${(V)junk}" done (( ZTST_verbose > 2 )) && print -u $ZTST_fd '' fi } +# Detects, prints as "DPUTS:{<message>}\n", and removes any DPUTS +# messages found in the parameter named $1. +zpty_handle_dputs() { + local -nu log=$1 + local -i lastend=0 + while (( ${(N)${log[lastend+1,-1]}#*(#b)((<->:|) *.c:<->: *[$'\r\n'])} )); do + print -u2 -r "DPUTS:{${match[1][1,-2]}}" + log[lastend+$mbegin[1],lastend+$mend[1]]="" + [[ $log[lastend+$mbegin[1]] != $'\n' ]] || log[lastend+$mbegin[1]]="" + lastend+=$mbegin[1] + done +} + zpty_run() { zpty -w zsh "$*" - zpty -r -m zsh log "*<PROMPT>*" || { + zpty_read log "*<PROMPT>*" || { print "prompt hasn't appeared." return 1 } @@ -122,7 +149,7 @@ comptesteval () { { # Avoid symlink attacks on the predictable filename # TODO: either use =(:) or create this file in the tests' workdir - local tmp=/tmp/comptest.$$ + local tmp=${TMPDIR:-/tmp}/comptest.$$ () { setopt localoptions NO_CLOBBER ERR_EXIT print -lr - "$@" > $tmp @@ -130,7 +157,7 @@ comptesteval () { # zpty_flush Before comptesteval zpty -w zsh ". ${(q)tmp}" - zpty -r -m zsh log_eval "*<PROMPT>*" || { + zpty_read log_eval "*<PROMPT>*" || { print "prompt hasn't appeared." return 1 } @@ -144,7 +171,7 @@ comptesteval () { comptest () { input="$*" zpty -n -w zsh "$input"$'\C-Z' - zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || { + zpty_read log "*<WIDGET><finish>*<PROMPT>*" || { print "failed to invoke finish widget." return 1 } @@ -184,7 +211,7 @@ zletest () { zpty -n -w zsh "$input" done zpty -n -w zsh $'\C-X' - zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || { + zpty_read log "*<WIDGET><finish>*<PROMPT>*" || { print "failed to invoke finish widget." return 1 } diff --git a/Test/runtests.zsh b/Test/runtests.zsh index 538663f50..ea862d2b3 100644 --- a/Test/runtests.zsh +++ b/Test/runtests.zsh @@ -8,21 +8,59 @@ emulate zsh # We could probably do that with subshells instead. integer success=0 failure=0 skipped=0 retval +typeset resln rule col +typeset -a ffiles res + +# colour to use for ztst failure messages. also used as a signal that colours +# are available generally +[[ -t 1 ]] && +(( ! $+ZTST_failcolour )) && +[[ -z $NO_COLOR ]] && +[[ $TERM == *color* || "$( tput colors 2> /dev/null )" == <8-> ]] && +typeset -x ZTST_failcolour=red + for file in "${(f)ZTST_testlist}"; do + file=${file#./} $ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh $file retval=$? if (( $retval == 2 )); then (( skipped++ )) elif (( $retval )); then (( failure++ )) - (( $retval > 128 )) && print "$file: failed: SIG$signals[$retval - 127]." + (( $retval > 128 )) && { + [[ -n $ZTST_failcolour ]] && print -rnP "%F{$ZTST_failcolour}" + print -r - "$file: test failed: SIG$signals[$retval - 127]." + [[ -n $ZTST_failcolour ]] && print -rnP %f + } + ffiles+=( $file ) else (( success++ )) fi + print done -print "************************************** -$success successful test script${${success:#1}:+s}, \ -$failure failure${${failure:#1}:+s}, \ -$skipped skipped -**************************************" + +res=( + "$success successful test script${${success:#1}:+s}" + "$failure failure${${failure:#1}:+s}" + "$skipped skipped" +) +resln=${(j<, >)res} +rule=${resln//?/\*} + +[[ -n $ZTST_failcolour ]] && +if (( failure )); then + col=red +elif (( success )); then + col=green +else + col=yellow +fi + +(( $#col )) && print -rnP - "%F{$col}" +print -rl - $rule $resln +(( $#ffiles )) && +print -rl - '' "failing test script${${#ffiles:#1}:+s}:" ${(@)ffiles/#/ } +print -rl - $rule +(( $#col )) && print -rnP - %f + return $(( failure ? 1 : 0 )) diff --git a/Test/ztst.zsh b/Test/ztst.zsh index aeb02cd54..ae5133e4d 100755 --- a/Test/ztst.zsh +++ b/Test/ztst.zsh @@ -148,7 +148,9 @@ ZTST_testfailed() { if [[ -n $ZTST_message ]]; then print -r "Was testing: $ZTST_message" fi + [[ -n $ZTST_failcolour ]] && print -rnP "%F{$ZTST_failcolour}" print -r "$ZTST_testname: test failed." + [[ -n $ZTST_failcolour ]] && print -rnP %f if [[ -n $ZTST_failmsg ]]; then print -r "The following may (or may not) help identifying the cause: $ZTST_failmsg" @@ -165,7 +167,9 @@ ZTST_testxpassed() { if [[ -n $ZTST_message ]]; then print -r "Was testing: $ZTST_message" fi + [[ -n $ZTST_failcolour ]] && print -rnP "%F{$ZTST_failcolour}" print -r "$ZTST_testname: test XPassed." + [[ -n $ZTST_failcolour ]] && print -rnP %f if [[ -n $ZTST_failmsg ]]; then print -r "The following may (or may not) help identifying the cause: $ZTST_failmsg" @@ -326,7 +330,6 @@ ZTST_diff() { emulate -L zsh setopt extendedglob - local -a diff_arg local diff_out integer diff_pat diff_ret @@ -343,8 +346,38 @@ ZTST_diff() { ;; esac shift - [[ $OSTYPE != (aix|solaris)* ]] && diff_arg=( -a ) - + + (( $+functions[ZTST_do_diff] )) || + ZTST_do_diff() { + local MATCH MBEGIN MEND ret + local -a out cmd + + cmd=( command diff -u ) + [[ $OSTYPE != (aix|solaris)* ]] && cmd+=( -a ) + + out=( ${(f)"$( $cmd "$@" )"} ) || ret=$? + + # massage + colourise diff + (( ret )) && { + local B=${(%):-%B} b=${(%):-%b} f=${(%):-%f} + local Fr=${(%):-'%F{red}'} Fg=${(%):-'%F{green}'} Fc=${(%):-'%F{cyan}'} + + [[ -n $ZTST_failcolour ]] || B= b= Fr= Fg= Fc= f= + + out[1]=${out[1]/#---*/$B--- expected$b} + out[2]=${out[2]/#+++*/$B+++ actual$b} + + (( $#B )) && { + out=( ${(@)out/#(#m)@@*/$Fc$MATCH$f} ) + out=( ${(@)out/#(#m)-*/$Fr$MATCH$f} ) + out=( ${(@)out/#(#m)+*/$Fg$MATCH$f} ) + } + } + + print -rl - $out + return ret + } + if (( diff_pat )); then local -a diff_lines1 diff_lines2 integer failed i l @@ -365,30 +398,19 @@ ZTST_diff() { done fi if (( failed )); then - for (( l = 1; l <= ${#diff_lines1}; ++l )); do - if (( l == i )); then - p="-" - else - p=" " - fi - print -r -- "$p<${diff_lines1[l]}" - done - for (( l = 1; l <= ${#diff_lines2}; ++l )); do - if (( l == i )); then - p="+" - else - p=" " - fi - print -r -- "$p>${diff_lines2[l]}" - done + diff_out=$( ZTST_do_diff \ + <( print -rl - "${(@)diff_lines1}" ) \ + <( print -rl - "${(@)diff_lines2}" ) + ) diff_ret=1 fi else - diff_out=$(diff $diff_arg "$@") + diff_out=$(ZTST_do_diff "$@") diff_ret="$?" - if [[ "$diff_ret" != "0" ]]; then - print -r -- "$diff_out" - fi + fi + + if [[ "$diff_ret" != "0" ]]; then + print -r -- "$diff_out" fi return "$diff_ret" @@ -526,7 +548,7 @@ $(<$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 $ZTST_out $ZTST_tout; then if (( expected_to_fail )); then ZTST_verbose 1 "Test failed, as expected." continue @@ -542,7 +564,7 @@ $(<$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 $ZTST_err $ZTST_terr; then if (( expected_to_fail )); then ZTST_verbose 1 "Test failed, as expected." continue @@ -472,7 +472,7 @@ fi ]) dnl -dnl zsh_SYS_DYNAMIC_STRIP_EXE +dnl zsh_SYS_DYNAMIC_STRIP_LIB dnl Check whether it is safe to strip dynamically loaded libraries. dnl diff --git a/config.guess b/config.guess index 11fda528b..c7f4c3294 100755 --- a/config.guess +++ b/config.guess @@ -1,12 +1,14 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2020 Free Software Foundation, Inc. +# Copyright 1992-2026 Free Software Foundation, Inc. -timestamp='2020-04-26' +# shellcheck disable=SC2006,SC2268 # see below for rationale + +timestamp='2026-05-17' # 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 -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -27,17 +29,25 @@ timestamp='2020-04-26' # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to <config-patches@gnu.org>. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] -Output the configuration name of the system \`$me' is run on. +Output the configuration name of the system '$me' is run on. Options: -h, --help print this help, then exit @@ -50,13 +60,13 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2020 Free Software Foundation, Inc. +Copyright 1992-2026 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." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -84,13 +94,16 @@ if test $# != 0; then exit 1 fi +# Just in case it came from the environment. +GUESS= + # 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 # headache to deal with in a portable fashion. -# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still -# use `HOST_CC' if defined, but it is deprecated. +# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still +# use 'HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. @@ -102,7 +115,7 @@ set_cc_for_build() { # prevent multiple calls if $tmp is already set test "$tmp" && return 0 : "${TMPDIR=/tmp}" - # shellcheck disable=SC2039 + # shellcheck disable=SC2039,SC3028 { 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 ; } || @@ -110,9 +123,9 @@ set_cc_for_build() { dummy=$tmp/dummy case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in ,,) echo "int x;" > "$dummy.c" - for driver in cc gcc c89 c99 ; do + for driver in cc gcc c17 c99 c89 ; do if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then - CC_FOR_BUILD="$driver" + CC_FOR_BUILD=$driver break fi done @@ -133,40 +146,59 @@ fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown -UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown -case "$UNAME_SYSTEM" in -Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu +case $UNAME_SYSTEM in +Ironclad|Linux|GNU|GNU/*) + LIBC=unknown set_cc_for_build cat <<-EOF > "$dummy.c" + #if defined(__ANDROID__) + LIBC=android + #else #include <features.h> #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #elif defined(__LLVM_LIBC__) + LIBC=llvm + #elif defined(__mlibc__) + LIBC=mlibc + #else + #include <stdarg.h> + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif + #endif #endif EOF - eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + eval "$cc_set_libc" - # If ldd exists, use it to detect musl libc. - if command -v ldd >/dev/null && \ - ldd --version 2>&1 | grep -q ^musl - then - LIBC=musl + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu fi ;; esac # Note: order is significant - the case branches are not exclusive. -case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in +case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, @@ -178,12 +210,12 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". - sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ - "/sbin/$sysctl" 2>/dev/null || \ - "/usr/sbin/$sysctl" 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ echo unknown)` - case "$UNAME_MACHINE_ARCH" in + case $UNAME_MACHINE_ARCH in + aarch64eb) machine=aarch64_be-unknown ;; armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; @@ -192,13 +224,13 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in earmv*) arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'` endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'` - machine="${arch}${endian}"-unknown + machine=${arch}${endian}-unknown ;; - *) machine="$UNAME_MACHINE_ARCH"-unknown ;; + *) machine=$UNAME_MACHINE_ARCH-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently (or will in the future) and ABI. - case "$UNAME_MACHINE_ARCH" in + case $UNAME_MACHINE_ARCH in earm*) os=netbsdelf ;; @@ -219,7 +251,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in ;; esac # Determine ABI tags. - case "$UNAME_MACHINE_ARCH" in + case $UNAME_MACHINE_ARCH in earm*) expr='s/^earmv[0-9]/-eabi/;s/eb$//' abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` @@ -230,7 +262,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. - case "$UNAME_VERSION" in + case $UNAME_VERSION in Debian*) release='-gnu' ;; @@ -241,51 +273,57 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "$machine-${os}${release}${abi-}" - exit ;; + GUESS=$machine-${os}${release}${abi-} + ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE + ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE + ;; + *:SecBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'` + GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE + ;; *:LibertyBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` - echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE + ;; *:MidnightBSD:*:*) - echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE + ;; *:ekkoBSD:*:*) - echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE + ;; *:SolidBSD:*:*) - echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE + ;; *:OS108:*:*) - echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE + ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE + ;; *:MirBSD:*:*) - echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE + ;; *:Sortix:*:*) - echo "$UNAME_MACHINE"-unknown-sortix - exit ;; + GUESS=$UNAME_MACHINE-unknown-sortix + ;; *:Twizzler:*:*) - echo "$UNAME_MACHINE"-unknown-twizzler - exit ;; + GUESS=$UNAME_MACHINE-unknown-twizzler + ;; *:Redox:*:*) - echo "$UNAME_MACHINE"-unknown-redox - exit ;; + GUESS=$UNAME_MACHINE-unknown-redox + ;; mips:OSF1:*.*) - echo mips-dec-osf1 - exit ;; + GUESS=mips-dec-osf1 + ;; alpha:OSF1:*:*) + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + trap '' 0 case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` @@ -299,7 +337,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` - case "$ALPHA_CPU_TYPE" in + case $ALPHA_CPU_TYPE in "EV4 (21064)") UNAME_MACHINE=alpha ;; "EV4.5 (21064)") @@ -336,117 +374,121 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`" - # Reset EXIT trap before exiting to avoid spurious non-zero exit code. - exitcode=$? - trap '' 0 - exit $exitcode ;; + OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + GUESS=$UNAME_MACHINE-dec-osf$OSF_REL + ;; Amiga*:UNIX_System_V:4.0:*) - echo m68k-unknown-sysv4 - exit ;; + GUESS=m68k-unknown-sysv4 + ;; *:[Aa]miga[Oo][Ss]:*:*) - echo "$UNAME_MACHINE"-unknown-amigaos - exit ;; + GUESS=$UNAME_MACHINE-unknown-amigaos + ;; *:[Mm]orph[Oo][Ss]:*:*) - echo "$UNAME_MACHINE"-unknown-morphos - exit ;; + GUESS=$UNAME_MACHINE-unknown-morphos + ;; *:OS/390:*:*) - echo i370-ibm-openedition - exit ;; + GUESS=i370-ibm-openedition + ;; *:z/VM:*:*) - echo s390-ibm-zvmoe - exit ;; + GUESS=s390-ibm-zvmoe + ;; *:OS400:*:*) - echo powerpc-ibm-os400 - exit ;; + GUESS=powerpc-ibm-os400 + ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix"$UNAME_RELEASE" - exit ;; + GUESS=arm-acorn-riscix$UNAME_RELEASE + ;; arm*:riscos:*:*|arm*:RISCOS:*:*) - echo arm-unknown-riscos - exit ;; + GUESS=arm-unknown-riscos + ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) - echo hppa1.1-hitachi-hiuxmpp - exit ;; + GUESS=hppa1.1-hitachi-hiuxmpp + ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then - echo pyramid-pyramid-sysv3 - else - echo pyramid-pyramid-bsd - fi - exit ;; + case `(/bin/universe) 2>/dev/null` in + att) GUESS=pyramid-pyramid-sysv3 ;; + *) GUESS=pyramid-pyramid-bsd ;; + esac + ;; NILE*:*:*:dcosx) - echo pyramid-pyramid-svr4 - exit ;; + GUESS=pyramid-pyramid-svr4 + ;; DRS?6000:unix:4.0:6*) - echo sparc-icl-nx6 - exit ;; + GUESS=sparc-icl-nx6 + ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7; exit ;; - esac ;; + sparc) GUESS=sparc-icl-nx7 ;; + esac + ;; s390x:SunOS:*:*) - echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL + ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-hal-solaris2$SUN_REL + ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris2$SUN_REL + ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux"$UNAME_RELEASE" - exit ;; + GUESS=i386-pc-auroraux$UNAME_RELEASE + ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) 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. # This test works for both compilers. - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if test "$CC_FOR_BUILD" != no_compiler_found; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH=x86_64 fi fi - echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=$SUN_ARCH-pc-solaris2$SUN_REL + ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. - echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=sparc-sun-solaris3$SUN_REL + ;; sun4*:SunOS:*:*) - case "`/usr/bin/arch -k`" in + case `/usr/bin/arch -k` in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac - # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" - exit ;; + # Japanese Language versions have a version number like '4.1.3-JL'. + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'` + GUESS=sparc-sun-sunos$SUN_REL + ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos"$UNAME_RELEASE" - exit ;; + GUESS=m68k-sun-sunos$UNAME_RELEASE + ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 - case "`/bin/arch`" in + case `/bin/arch` in sun3) - echo m68k-sun-sunos"$UNAME_RELEASE" + GUESS=m68k-sun-sunos$UNAME_RELEASE ;; sun4) - echo sparc-sun-sunos"$UNAME_RELEASE" + GUESS=sparc-sun-sunos$UNAME_RELEASE ;; esac - exit ;; + ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos"$UNAME_RELEASE" - exit ;; + GUESS=sparc-auspex-sunos$UNAME_RELEASE + ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -456,41 +498,41 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-atari-mint$UNAME_RELEASE + ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-milan-mint$UNAME_RELEASE + ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-hades-mint$UNAME_RELEASE + ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint"$UNAME_RELEASE" - exit ;; + GUESS=m68k-unknown-mint$UNAME_RELEASE + ;; m68k:machten:*:*) - echo m68k-apple-machten"$UNAME_RELEASE" - exit ;; + GUESS=m68k-apple-machten$UNAME_RELEASE + ;; powerpc:machten:*:*) - echo powerpc-apple-machten"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-apple-machten$UNAME_RELEASE + ;; RISC*:Mach:*:*) - echo mips-dec-mach_bsd4.3 - exit ;; + GUESS=mips-dec-mach_bsd4.3 + ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix"$UNAME_RELEASE" - exit ;; + GUESS=mips-dec-ultrix$UNAME_RELEASE + ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix"$UNAME_RELEASE" - exit ;; + GUESS=vax-dec-ultrix$UNAME_RELEASE + ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix"$UNAME_RELEASE" - exit ;; + GUESS=clipper-intergraph-clix$UNAME_RELEASE + ;; mips:*:*:UMIPS | mips:*:*:RISCos) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" @@ -518,82 +560,84 @@ EOF dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`"$dummy" "$dummyarg"` && { echo "$SYSTEM_NAME"; exit; } - echo mips-mips-riscos"$UNAME_RELEASE" - exit ;; + GUESS=mips-mips-riscos$UNAME_RELEASE + ;; Motorola:PowerMAX_OS:*:*) - echo powerpc-motorola-powermax - exit ;; + GUESS=powerpc-motorola-powermax + ;; Motorola:*:4.3:PL8-*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) - echo powerpc-harris-powermax - exit ;; + GUESS=powerpc-harris-powermax + ;; Night_Hawk:Power_UNIX:*:*) - echo powerpc-harris-powerunix - exit ;; + GUESS=powerpc-harris-powerunix + ;; m88k:CX/UX:7*:*) - echo m88k-harris-cxux7 - exit ;; + GUESS=m88k-harris-cxux7 + ;; m88k:*:4*:R4*) - echo m88k-motorola-sysv4 - exit ;; + GUESS=m88k-motorola-sysv4 + ;; m88k:*:3*:R3*) - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ - [ "$TARGET_BINARY_INTERFACE"x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then - echo m88k-dg-dgux"$UNAME_RELEASE" + GUESS=m88k-dg-dgux$UNAME_RELEASE else - echo m88k-dg-dguxbcs"$UNAME_RELEASE" + GUESS=m88k-dg-dguxbcs$UNAME_RELEASE fi else - echo i586-dg-dgux"$UNAME_RELEASE" + GUESS=i586-dg-dgux$UNAME_RELEASE fi - exit ;; + ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) - echo m88k-dolphin-sysv3 - exit ;; + GUESS=m88k-dolphin-sysv3 + ;; M88*:*:R3*:*) # Delta 88k system running SVR3 - echo m88k-motorola-sysv3 - exit ;; + GUESS=m88k-motorola-sysv3 + ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) - echo m88k-tektronix-sysv3 - exit ;; + GUESS=m88k-tektronix-sysv3 + ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) - echo m68k-tektronix-bsd - exit ;; + GUESS=m68k-tektronix-bsd + ;; *:IRIX*:*:*) - echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" - exit ;; + IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'` + GUESS=mips-sgi-irix$IRIX_REL + ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id + ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) - echo i386-ibm-aix - exit ;; + GUESS=i386-ibm-aix + ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then + if test -x /usr/bin/oslevel ; then IBM_REV=`/usr/bin/oslevel` else - IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" - exit ;; + GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV + ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> - main() + int + main () { if (!__power_pc()) exit(1); @@ -603,16 +647,16 @@ EOF EOF if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then - echo "$SYSTEM_NAME" + GUESS=$SYSTEM_NAME else - echo rs6000-ibm-aix3.2.5 + GUESS=rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then - echo rs6000-ibm-aix3.2.4 + GUESS=rs6000-ibm-aix3.2.4 else - echo rs6000-ibm-aix3.2 + GUESS=rs6000-ibm-aix3.2 fi - exit ;; + ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then @@ -620,56 +664,56 @@ EOF else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + if test -x /usr/bin/lslpp ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` else - IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" + IBM_REV=$UNAME_VERSION.$UNAME_RELEASE fi - echo "$IBM_ARCH"-ibm-aix"$IBM_REV" - exit ;; + GUESS=$IBM_ARCH-ibm-aix$IBM_REV + ;; *:AIX:*:*) - echo rs6000-ibm-aix - exit ;; + GUESS=rs6000-ibm-aix + ;; ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) - echo romp-ibm-bsd4.4 - exit ;; + GUESS=romp-ibm-bsd4.4 + ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to - exit ;; # report: romp-ibm BSD 4.3 + GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to + ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) - echo rs6000-bull-bosx - exit ;; + GUESS=rs6000-bull-bosx + ;; DPX/2?00:B.O.S.:*:*) - echo m68k-bull-sysv3 - exit ;; + GUESS=m68k-bull-sysv3 + ;; 9000/[34]??:4.3bsd:1.*:*) - echo m68k-hp-bsd - exit ;; + GUESS=m68k-hp-bsd + ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) - echo m68k-hp-bsd4.4 - exit ;; + GUESS=m68k-hp-bsd4.4 + ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` - case "$UNAME_MACHINE" in + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + case $UNAME_MACHINE in 9000/31?) HP_ARCH=m68000 ;; 9000/[34]??) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) - if [ -x /usr/bin/getconf ]; then + if test -x /usr/bin/getconf; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` - case "$sc_cpu_version" in + case $sc_cpu_version in 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 - case "$sc_kernel_bits" in + case $sc_kernel_bits in 32) HP_ARCH=hppa2.0n ;; 64) HP_ARCH=hppa2.0w ;; '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 esac ;; esac fi - if [ "$HP_ARCH" = "" ]; then + if test "$HP_ARCH" = ""; then set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" @@ -677,7 +721,8 @@ EOF #include <stdlib.h> #include <unistd.h> - int main () + int + main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); @@ -708,7 +753,7 @@ EOF test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ "$HP_ARCH" = hppa2.0w ] + if test "$HP_ARCH" = hppa2.0w then set_cc_for_build @@ -729,12 +774,12 @@ EOF HP_ARCH=hppa64 fi fi - echo "$HP_ARCH"-hp-hpux"$HPUX_REV" - exit ;; + GUESS=$HP_ARCH-hp-hpux$HPUX_REV + ;; ia64:HP-UX:*:*) - HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux"$HPUX_REV" - exit ;; + HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'` + GUESS=ia64-hp-hpux$HPUX_REV + ;; 3050*:HI-UX:*:*) set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" @@ -764,36 +809,36 @@ EOF EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } - echo unknown-hitachi-hiuxwe2 - exit ;; + GUESS=unknown-hitachi-hiuxwe2 + ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) - echo hppa1.1-hp-bsd - exit ;; + GUESS=hppa1.1-hp-bsd + ;; 9000/8??:4.3bsd:*:*) - echo hppa1.0-hp-bsd - exit ;; + GUESS=hppa1.0-hp-bsd + ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) - echo hppa1.0-hp-mpeix - exit ;; + GUESS=hppa1.0-hp-mpeix + ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) - echo hppa1.1-hp-osf - exit ;; + GUESS=hppa1.1-hp-osf + ;; hp8??:OSF1:*:*) - echo hppa1.0-hp-osf - exit ;; + GUESS=hppa1.0-hp-osf + ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then - echo "$UNAME_MACHINE"-unknown-osf1mk + if test -x /usr/sbin/sysversion ; then + GUESS=$UNAME_MACHINE-unknown-osf1mk else - echo "$UNAME_MACHINE"-unknown-osf1 + GUESS=$UNAME_MACHINE-unknown-osf1 fi - exit ;; + ;; parisc*:Lites*:*:*) - echo hppa1.1-hp-lites - exit ;; + GUESS=hppa1.1-hp-lites + ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) - echo c1-convex-bsd - exit ;; + GUESS=c1-convex-bsd + ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd @@ -801,17 +846,18 @@ EOF fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) - echo c34-convex-bsd - exit ;; + GUESS=c34-convex-bsd + ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) - echo c38-convex-bsd - exit ;; + GUESS=c38-convex-bsd + ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) - echo c4-convex-bsd - exit ;; + GUESS=c4-convex-bsd + ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=ymp-cray-unicos$CRAY_REL + ;; CRAY*[A-Z]90:*:*:*) echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ @@ -819,112 +865,153 @@ EOF -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=t90-cray-unicos$CRAY_REL + ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=alphaev5-cray-unicosmk$CRAY_REL + ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=sv1-cray-unicos$CRAY_REL + ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' - exit ;; + CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'` + GUESS=craynv-cray-unicosmp$CRAY_REL + ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'` - echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` - echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit ;; + GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL} + ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE + ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=sparc-unknown-bsdi$UNAME_RELEASE + ;; *:BSD/OS:*:*) - echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE + ;; 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 + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi else - echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf fi - exit ;; + ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` - case "$UNAME_PROCESSOR" in + UNAME_PROCESSOR=`uname -p` + case $UNAME_PROCESSOR in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" - exit ;; + FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL + ;; i*:CYGWIN*:*) - echo "$UNAME_MACHINE"-pc-cygwin - exit ;; + GUESS=$UNAME_MACHINE-pc-cygwin + ;; *:MINGW64*:*) - echo "$UNAME_MACHINE"-pc-mingw64 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw64 + ;; *:MINGW*:*) - echo "$UNAME_MACHINE"-pc-mingw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-mingw32 + ;; *:MSYS*:*) - echo "$UNAME_MACHINE"-pc-msys - exit ;; + GUESS=$UNAME_MACHINE-pc-msys + ;; i*:PW*:*) - echo "$UNAME_MACHINE"-pc-pw32 - exit ;; + GUESS=$UNAME_MACHINE-pc-pw32 + ;; + *:SerenityOS:*:*) + GUESS=$UNAME_MACHINE-pc-serenity + ;; *:Interix*:*) - case "$UNAME_MACHINE" in + case $UNAME_MACHINE in x86) - echo i586-pc-interix"$UNAME_RELEASE" - exit ;; + GUESS=i586-pc-interix$UNAME_RELEASE + ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix"$UNAME_RELEASE" - exit ;; + GUESS=x86_64-unknown-interix$UNAME_RELEASE + ;; IA64) - echo ia64-unknown-interix"$UNAME_RELEASE" - exit ;; + GUESS=ia64-unknown-interix$UNAME_RELEASE + ;; esac ;; i*:UWIN*:*) - echo "$UNAME_MACHINE"-pc-uwin - exit ;; + GUESS=$UNAME_MACHINE-pc-uwin + ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-pc-cygwin - exit ;; + GUESS=x86_64-pc-cygwin + ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" - exit ;; + SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'` + GUESS=powerpcle-unknown-solaris2$SUN_REL + ;; *:GNU:*:*) # the GNU system - echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" - exit ;; + GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'` + GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL + ;; *:GNU/*:*:*) # 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 ;; + GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"` + GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC + ;; + x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-pc-managarm-mlibc" + ;; + *:[Mm]anagarm:*:*) + GUESS="$UNAME_MACHINE-unknown-managarm-mlibc" + ;; *:Minix:*:*) - echo "$UNAME_MACHINE"-unknown-minix - exit ;; + GUESS=$UNAME_MACHINE-unknown-minix + ;; aarch64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __ARM_EABI__ + #ifdef __ARM_PCS_VFP + ABI=eabihf + #else + ABI=eabi + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;; + esac + fi + GUESS=$CPU-unknown-linux-$LIBCABI + ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -937,60 +1024,72 @@ EOF esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC=gnulibc1 ; fi - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; - arc:Linux:*:* | arceb:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; arm*:Linux:*:*) set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi else - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf fi fi - exit ;; + ;; avr32*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; cris:Linux:*:*) - echo "$UNAME_MACHINE"-axis-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; crisv32:Linux:*:*) - echo "$UNAME_MACHINE"-axis-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-axis-linux-$LIBC + ;; e2k:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; frv:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; hexagon:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:Linux:*:*) - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-pc-linux-$LIBC + ;; ia64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; k1om:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + kvx:cos:*:*) + GUESS=$UNAME_MACHINE-unknown-cos + ;; + kvx:mbr:*:*) + GUESS=$UNAME_MACHINE-unknown-mbr + ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m32r*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; m68*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; mips:Linux:*:* | mips64:Linux:*:*) set_cc_for_build IS_GLIBC=0 @@ -1035,113 +1134,138 @@ EOF #endif #endif EOF - eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`" + cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'` + eval "$cc_set_vars" test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; openrisc*:Linux:*:*) - echo or1k-unknown-linux-"$LIBC" - exit ;; + GUESS=or1k-unknown-linux-$LIBC + ;; or32:Linux:*:* | or1k*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; padre:Linux:*:*) - echo sparc-unknown-linux-"$LIBC" - exit ;; + GUESS=sparc-unknown-linux-$LIBC + ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-"$LIBC" - exit ;; + GUESS=hppa64-unknown-linux-$LIBC + ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in - PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; - PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; - *) echo hppa-unknown-linux-"$LIBC" ;; + PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;; + PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;; + *) GUESS=hppa-unknown-linux-$LIBC ;; esac - exit ;; + ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc64-unknown-linux-$LIBC + ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc-unknown-linux-$LIBC + ;; ppc64le:Linux:*:*) - echo powerpc64le-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpc64le-unknown-linux-$LIBC + ;; ppcle:Linux:*:*) - echo powerpcle-unknown-linux-"$LIBC" - exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=powerpcle-unknown-linux-$LIBC + ;; + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; s390:Linux:*:* | s390x:Linux:*:*) - echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-ibm-linux-$LIBC + ;; sh64*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sh*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; + sw_64:Linux:*:*) + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; tile*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; vax:Linux:*:*) - echo "$UNAME_MACHINE"-dec-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-dec-linux-$LIBC + ;; x86_64:Linux:*:*) - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" - exit ;; + set_cc_for_build + CPU=$UNAME_MACHINE + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + ABI=64 + sed 's/^ //' << EOF > "$dummy.c" + #ifdef __i386__ + ABI=x86 + #else + #ifdef __ILP32__ + ABI=x32 + #endif + #endif +EOF + cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'` + eval "$cc_set_abi" + case $ABI in + x86) CPU=i686 ;; + x32) LIBCABI=${LIBC}x32 ;; + esac + fi + GUESS=$CPU-pc-linux-$LIBCABI + ;; xtensa*:Linux:*:*) - echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" - exit ;; + GUESS=$UNAME_MACHINE-unknown-linux-$LIBC + ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. - echo i386-sequent-sysv4 - exit ;; + GUESS=i386-sequent-sysv4 + ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. - echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" - exit ;; + GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION + ;; i*86:OS/2:*:*) - # If we were able to find `uname', then EMX Unix compatibility + # If we were able to find 'uname', then EMX Unix compatibility # is probably installed. - echo "$UNAME_MACHINE"-pc-os2-emx - exit ;; + GUESS=$UNAME_MACHINE-pc-os2-emx + ;; i*86:XTS-300:*:STOP) - echo "$UNAME_MACHINE"-unknown-stop - exit ;; + GUESS=$UNAME_MACHINE-unknown-stop + ;; i*86:atheos:*:*) - echo "$UNAME_MACHINE"-unknown-atheos - exit ;; + GUESS=$UNAME_MACHINE-unknown-atheos + ;; i*86:syllable:*:*) - echo "$UNAME_MACHINE"-pc-syllable - exit ;; + GUESS=$UNAME_MACHINE-pc-syllable + ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=i386-unknown-lynxos$UNAME_RELEASE + ;; i*86:*DOS:*:*) - echo "$UNAME_MACHINE"-pc-msdosdjgpp - exit ;; + GUESS=$UNAME_MACHINE-pc-msdosdjgpp + ;; i*86:*:4.*:*) UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then - echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" + GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL else - echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" + GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL fi - exit ;; + ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in @@ -1149,12 +1273,12 @@ EOF *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}" - exit ;; + GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL" + GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL elif /bin/uname -X 2>/dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 @@ -1164,11 +1288,11 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" + GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL else - echo "$UNAME_MACHINE"-pc-sysv32 + GUESS=$UNAME_MACHINE-pc-sysv32 fi - exit ;; + ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about @@ -1176,31 +1300,31 @@ EOF # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. - echo i586-pc-msdosdjgpp - exit ;; + GUESS=i586-pc-msdosdjgpp + ;; Intel:Mach:3*:*) - echo i386-pc-mach3 - exit ;; + GUESS=i386-pc-mach3 + ;; paragon:*:*:*) - echo i860-intel-osf1 - exit ;; + GUESS=i860-intel-osf1 + ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then - echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4 + GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. - echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 + GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4 fi - exit ;; + ;; mini*:CTIX:SYS*5:*) # "miniframe" - echo m68010-convergent-sysv - exit ;; + GUESS=m68010-convergent-sysv + ;; mc68k:UNIX:SYSTEM5:3.51m) - echo m68k-convergent-sysv - exit ;; + GUESS=m68k-convergent-sysv + ;; M680?0:D-NIX:5.3:*) - echo m68k-diab-dnix - exit ;; + GUESS=m68k-diab-dnix + ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) @@ -1225,113 +1349,119 @@ EOF /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=m68k-unknown-lynxos$UNAME_RELEASE + ;; mc68030:UNIX_System_V:4.*:*) - echo m68k-atari-sysv4 - exit ;; + GUESS=m68k-atari-sysv4 + ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=sparc-unknown-lynxos$UNAME_RELEASE + ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=rs6000-unknown-lynxos$UNAME_RELEASE + ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-unknown-lynxos$UNAME_RELEASE + ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv"$UNAME_RELEASE" - exit ;; + GUESS=mips-dde-sysv$UNAME_RELEASE + ;; RM*:ReliantUNIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; RM*:SINIX-*:*:*) - echo mips-sni-sysv4 - exit ;; + GUESS=mips-sni-sysv4 + ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo "$UNAME_MACHINE"-sni-sysv4 + GUESS=$UNAME_MACHINE-sni-sysv4 else - echo ns32k-sni-sysv + GUESS=ns32k-sni-sysv fi - exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + ;; + PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit ;; + GUESS=i586-unisys-sysv4 + ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # How about differentiating between stratus architectures? -djm - echo hppa1.1-stratus-sysv4 - exit ;; + GUESS=hppa1.1-stratus-sysv4 + ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. - echo i860-stratus-sysv4 - exit ;; + GUESS=i860-stratus-sysv4 + ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo "$UNAME_MACHINE"-stratus-vos - exit ;; + GUESS=$UNAME_MACHINE-stratus-vos + ;; *:VOS:*:*) # From Paul.Green@stratus.com. - echo hppa1.1-stratus-vos - exit ;; + GUESS=hppa1.1-stratus-vos + ;; mc68*:A/UX:*:*) - echo m68k-apple-aux"$UNAME_RELEASE" - exit ;; + GUESS=m68k-apple-aux$UNAME_RELEASE + ;; news*:NEWS-OS:6*:*) - echo mips-sony-newsos6 - exit ;; + GUESS=mips-sony-newsos6 + ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then - echo mips-nec-sysv"$UNAME_RELEASE" + if test -d /usr/nec; then + GUESS=mips-nec-sysv$UNAME_RELEASE else - echo mips-unknown-sysv"$UNAME_RELEASE" + GUESS=mips-unknown-sysv$UNAME_RELEASE fi - exit ;; + ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. - echo powerpc-be-beos - exit ;; + GUESS=powerpc-be-beos + ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. - echo powerpc-apple-beos - exit ;; + GUESS=powerpc-apple-beos + ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. - echo i586-pc-beos - exit ;; + GUESS=i586-pc-beos + ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. - echo i586-pc-haiku - exit ;; - x86_64:Haiku:*:*) - echo x86_64-unknown-haiku - exit ;; + GUESS=i586-pc-haiku + ;; + ppc:Haiku:*:*) # Haiku running on Apple PowerPC + GUESS=powerpc-apple-haiku + ;; + *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat) + GUESS=$UNAME_MACHINE-unknown-haiku + ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx4-nec-superux$UNAME_RELEASE + ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx5-nec-superux$UNAME_RELEASE + ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx6-nec-superux$UNAME_RELEASE + ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx7-nec-superux$UNAME_RELEASE + ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx8-nec-superux$UNAME_RELEASE + ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sx8r-nec-superux$UNAME_RELEASE + ;; SX-ACE:SUPER-UX:*:*) - echo sxace-nec-superux"$UNAME_RELEASE" - exit ;; + GUESS=sxace-nec-superux$UNAME_RELEASE + ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody"$UNAME_RELEASE" - exit ;; + GUESS=powerpc-apple-rhapsody$UNAME_RELEASE + ;; *:Rhapsody:*:*) - echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE + ;; + arm64:Darwin:*:*) + GUESS=aarch64-apple-darwin$UNAME_RELEASE + ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` case $UNAME_PROCESSOR in @@ -1346,7 +1476,7 @@ EOF else set_cc_for_build fi - if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if test "$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 @@ -1367,109 +1497,125 @@ EOF # uname -m returns i386 or x86_64 UNAME_PROCESSOR=$UNAME_MACHINE fi - echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE + ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE + ;; *:QNX:*:4*) - echo i386-pc-qnx - exit ;; + GUESS=i386-pc-qnx + ;; NEO-*:NONSTOP_KERNEL:*:*) - echo neo-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=neo-tandem-nsk$UNAME_RELEASE + ;; NSE-*:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nse-tandem-nsk$UNAME_RELEASE + ;; NSR-*:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsr-tandem-nsk$UNAME_RELEASE + ;; NSV-*:NONSTOP_KERNEL:*:*) - echo nsv-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsv-tandem-nsk$UNAME_RELEASE + ;; NSX-*:NONSTOP_KERNEL:*:*) - echo nsx-tandem-nsk"$UNAME_RELEASE" - exit ;; + GUESS=nsx-tandem-nsk$UNAME_RELEASE + ;; *:NonStop-UX:*:*) - echo mips-compaq-nonstopux - exit ;; + GUESS=mips-compaq-nonstopux + ;; BS2000:POSIX*:*:*) - echo bs2000-siemens-sysv - exit ;; + GUESS=bs2000-siemens-sysv + ;; DS/*:UNIX_System_V:*:*) - echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE + ;; *:Plan9:*:*) # "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 + if test "${cputype-}" = 386; then UNAME_MACHINE=i386 - else - UNAME_MACHINE="$cputype" + elif test "x${cputype-}" != x; then + UNAME_MACHINE=$cputype fi - echo "$UNAME_MACHINE"-unknown-plan9 - exit ;; + GUESS=$UNAME_MACHINE-unknown-plan9 + ;; *:TOPS-10:*:*) - echo pdp10-unknown-tops10 - exit ;; + GUESS=pdp10-unknown-tops10 + ;; *:TENEX:*:*) - echo pdp10-unknown-tenex - exit ;; + GUESS=pdp10-unknown-tenex + ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) - echo pdp10-dec-tops20 - exit ;; + GUESS=pdp10-dec-tops20 + ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) - echo pdp10-xkl-tops20 - exit ;; + GUESS=pdp10-xkl-tops20 + ;; *:TOPS-20:*:*) - echo pdp10-unknown-tops20 - exit ;; + GUESS=pdp10-unknown-tops20 + ;; *:ITS:*:*) - echo pdp10-unknown-its - exit ;; + GUESS=pdp10-unknown-its + ;; SEI:*:*:SEIUX) - echo mips-sei-seiux"$UNAME_RELEASE" - exit ;; + GUESS=mips-sei-seiux$UNAME_RELEASE + ;; *:DragonFly:*:*) - echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" - exit ;; + DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'` + GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL + ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "$UNAME_MACHINE" in - A*) echo alpha-dec-vms ; exit ;; - I*) echo ia64-dec-vms ; exit ;; - V*) echo vax-dec-vms ; exit ;; + case $UNAME_MACHINE in + A*) GUESS=alpha-dec-vms ;; + I*) GUESS=ia64-dec-vms ;; + V*) GUESS=vax-dec-vms ;; esac ;; *:XENIX:*:SysV) - echo i386-pc-xenix - exit ;; + GUESS=i386-pc-xenix + ;; i*86:skyos:*:*) - echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" - exit ;; + SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'` + GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL + ;; i*86:rdos:*:*) - echo "$UNAME_MACHINE"-pc-rdos - exit ;; - i*86:AROS:*:*) - echo "$UNAME_MACHINE"-pc-aros - exit ;; + GUESS=$UNAME_MACHINE-pc-rdos + ;; + i*86:Fiwix:*:*) + GUESS=$UNAME_MACHINE-pc-fiwix + ;; + *:AROS:*:*) + GUESS=$UNAME_MACHINE-unknown-aros + ;; x86_64:VMkernel:*:*) - echo "$UNAME_MACHINE"-unknown-esx - exit ;; + GUESS=$UNAME_MACHINE-unknown-esx + ;; amd64:Isilon\ OneFS:*:*) - echo x86_64-unknown-onefs - exit ;; + GUESS=x86_64-unknown-onefs + ;; *:Unleashed:*:*) - echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" - exit ;; + GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE + ;; + x86_64:[Ii]ronclad:*:*|i?86:[Ii]ronclad:*:*) + GUESS=$UNAME_MACHINE-pc-ironclad-$LIBC + ;; + *:[Ii]ronclad:*:*) + GUESS=$UNAME_MACHINE-unknown-ironclad-$LIBC + ;; esac +# Do we have a guess based on uname results? +if test "x$GUESS" != x; then + echo "$GUESS" + exit +fi + # No uname command or uname output not recognized. set_cc_for_build cat > "$dummy.c" <<EOF @@ -1485,6 +1631,7 @@ cat > "$dummy.c" <<EOF #endif #endif #endif +int main () { #if defined (sony) @@ -1601,7 +1748,7 @@ main () } EOF -$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && +$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. @@ -1609,7 +1756,7 @@ test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } echo "$0: unable to guess system type" >&2 -case "$UNAME_MACHINE:$UNAME_SYSTEM" in +case $UNAME_MACHINE:$UNAME_SYSTEM in mips:Linux | mips64:Linux) # If we got here on MIPS GNU/Linux, output extra information. cat >&2 <<EOF @@ -1626,14 +1773,16 @@ This script (version $timestamp), has failed to recognize the operating system you are using. If your script is old, overwrite *all* copies of config.guess and config.sub with the latest versions from: - https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess + https://git.savannah.gnu.org/cgit/config.git/plain/config.guess and - https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + https://git.savannah.gnu.org/cgit/config.git/plain/config.sub EOF -year=`echo $timestamp | sed 's,-.*,,'` +our_year=`echo $timestamp | sed 's,-.*,,'` +thisyear=`date +%Y` # shellcheck disable=SC2003 -if test "`expr "\`date +%Y\`" - "$year"`" -lt 3 ; then +script_age=`expr "$thisyear" - "$our_year"` +if test "$script_age" -lt 3 ; then cat >&2 <<EOF If $0 has already been updated, send the following data and any @@ -1667,8 +1816,8 @@ fi exit 1 # Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp nil t) # time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-format: "%Y-%02m-%02d" # time-stamp-end: "'" # End: diff --git a/config.sub b/config.sub index 973a2980a..404aa0824 100755 --- a/config.sub +++ b/config.sub @@ -1,12 +1,14 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2020 Free Software Foundation, Inc. +# Copyright 1992-2026 Free Software Foundation, Inc. -timestamp='2020-05-04' +# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale + +timestamp='2026-05-17' # 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 -# the Free Software Foundation; either version 3 of the License, or +# the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but @@ -33,7 +35,7 @@ timestamp='2020-05-04' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -50,6 +52,13 @@ timestamp='2020-05-04' # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. +# The "shellcheck disable" line above the timestamp inhibits complaints +# about features and limitations of the classic Bourne shell that were +# superseded or lifted in POSIX. However, this script identifies a wide +# variety of pre-POSIX systems that do not have POSIX shells at all, and +# even some reasonably current systems (Solaris 10 as case-in-point) still +# have a pre-POSIX /bin/sh. + me=`echo "$0" | sed -e 's,.*/,,'` usage="\ @@ -67,13 +76,13 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright 1992-2020 Free Software Foundation, Inc. +Copyright 1992-2026 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." help=" -Try \`$me --help' for more information." +Try '$me --help' for more information." # Parse command line while test $# -gt 0 ; do @@ -111,75 +120,154 @@ case $# in esac # Split fields of configuration type -# shellcheck disable=SC2162 +saved_IFS=$IFS IFS="-" read field1 field2 field3 field4 <<EOF $1 EOF +IFS=$saved_IFS # Separate into logical components for further validation case $1 in *-*-*-*-*) - echo Invalid configuration \`"$1"\': more than four components >&2 + echo "Invalid configuration '$1': more than four components" >&2 exit 1 ;; *-*-*-*) basic_machine=$field1-$field2 - os=$field3-$field4 + basic_os=$field3-$field4 ;; *-*-*) # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two # parts maybe_os=$field2-$field3 case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \ - | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \ - | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \ - | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \ - | storm-chaos* | os2-emx* | rtmk-nova*) + cloudabi*-eabi* \ + | kfreebsd*-gnu* \ + | knetbsd*-gnu* \ + | kopensolaris*-gnu* \ + | ironclad-* \ + | linux-* \ + | managarm-* \ + | netbsd*-eabi* \ + | netbsd*-gnu* \ + | nto-qnx* \ + | os2-emx* \ + | rtmk-nova* \ + | storm-chaos* \ + | uclinux-gnu* \ + | uclinux-uclibc* \ + | windows-* ) basic_machine=$field1 - os=$maybe_os + basic_os=$maybe_os ;; android-linux) basic_machine=$field1-unknown - os=linux-android + basic_os=linux-android ;; *) basic_machine=$field1-$field2 - os=$field3 + basic_os=$field3 ;; esac ;; *-*) - # A lone config we happen to match not fitting any pattern case $field1-$field2 in + # Shorthands that happen to contain a single dash + convex-c[12] | convex-c3[248]) + basic_machine=$field2-convex + basic_os= + ;; decstation-3100) basic_machine=mips-dec - os= + basic_os= ;; *-*) # Second component is usually, but not always the OS case $field2 in - # Prevent following clause from handling this valid os + # Do not treat sunos as a manufacturer sun*os*) basic_machine=$field1 - os=$field2 + basic_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) + 3100* \ + | 32* \ + | 3300* \ + | 3600* \ + | 7300* \ + | acorn \ + | altos* \ + | apollo \ + | apple \ + | atari \ + | att* \ + | axis \ + | be \ + | bull \ + | cbm \ + | ccur \ + | cisco \ + | commodore \ + | convergent* \ + | convex* \ + | cray \ + | crds \ + | dec* \ + | delta* \ + | dg \ + | digital \ + | dolphin \ + | encore* \ + | gould \ + | harris \ + | highlevel \ + | hitachi* \ + | hp \ + | ibm* \ + | intergraph \ + | isi* \ + | knuth \ + | masscomp \ + | microblaze* \ + | mips* \ + | motorola* \ + | ncr* \ + | news \ + | next \ + | ns \ + | oki \ + | omron* \ + | pc533* \ + | rebel \ + | rom68k \ + | rombug \ + | semi \ + | sequent* \ + | sgi* \ + | siemens \ + | sim \ + | sni \ + | sony* \ + | stratus \ + | sun \ + | sun[234]* \ + | tektronix \ + | tti* \ + | ultra \ + | unicom* \ + | wec \ + | winbond \ + | wrs) basic_machine=$field1-$field2 - os= + basic_os= + ;; + tock* | zephyr*) + basic_machine=$field1-unknown + basic_os=$field2 ;; *) basic_machine=$field1 - os=$field2 + basic_os=$field2 ;; esac ;; @@ -191,447 +279,431 @@ case $1 in case $field1 in 386bsd) basic_machine=i386-pc - os=bsd + basic_os=bsd ;; a29khif) basic_machine=a29k-amd - os=udi + basic_os=udi ;; adobe68k) basic_machine=m68010-adobe - os=scout + basic_os=scout ;; alliant) basic_machine=fx80-alliant - os= + basic_os= ;; altos | altos3068) basic_machine=m68k-altos - os= + basic_os= ;; am29k) basic_machine=a29k-none - os=bsd + basic_os=bsd ;; amdahl) basic_machine=580-amdahl - os=sysv + basic_os=sysv ;; amiga) basic_machine=m68k-unknown - os= + basic_os= ;; amigaos | amigados) basic_machine=m68k-unknown - os=amigaos + basic_os=amigaos ;; amigaunix | amix) basic_machine=m68k-unknown - os=sysv4 + basic_os=sysv4 ;; apollo68) basic_machine=m68k-apollo - os=sysv + basic_os=sysv ;; apollo68bsd) basic_machine=m68k-apollo - os=bsd + basic_os=bsd ;; aros) basic_machine=i386-pc - os=aros + basic_os=aros ;; aux) basic_machine=m68k-apple - os=aux + basic_os=aux ;; balance) basic_machine=ns32k-sequent - os=dynix + basic_os=dynix ;; blackfin) basic_machine=bfin-unknown - os=linux + basic_os=linux ;; cegcc) 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 + basic_os=cegcc ;; cray) basic_machine=j90-cray - os=unicos + basic_os=unicos ;; crds | unos) basic_machine=m68k-crds - os= + basic_os= ;; da30) basic_machine=m68k-da30 - os= + basic_os= ;; decstation | pmax | pmin | dec3100 | decstatn) basic_machine=mips-dec - os= + basic_os= ;; delta88) basic_machine=m88k-motorola - os=sysv3 + basic_os=sysv3 ;; dicos) basic_machine=i686-pc - os=dicos + basic_os=dicos ;; djgpp) basic_machine=i586-pc - os=msdosdjgpp + basic_os=msdosdjgpp ;; ebmon29k) basic_machine=a29k-amd - os=ebmon + basic_os=ebmon ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson - os=ose + basic_os=ose ;; gmicro) basic_machine=tron-gmicro - os=sysv + basic_os=sysv ;; go32) basic_machine=i386-pc - os=go32 + basic_os=go32 ;; h8300hms) basic_machine=h8300-hitachi - os=hms + basic_os=hms ;; h8300xray) basic_machine=h8300-hitachi - os=xray + basic_os=xray ;; h8500hms) basic_machine=h8500-hitachi - os=hms + basic_os=hms ;; harris) basic_machine=m88k-harris - os=sysv3 + basic_os=sysv3 ;; hp300 | hp300hpux) basic_machine=m68k-hp - os=hpux + basic_os=hpux ;; hp300bsd) basic_machine=m68k-hp - os=bsd + basic_os=bsd ;; hppaosf) basic_machine=hppa1.1-hp - os=osf + basic_os=osf ;; hppro) basic_machine=hppa1.1-hp - os=proelf + basic_os=proelf ;; i386mach) basic_machine=i386-mach - os=mach + basic_os=mach ;; isi68 | isi) basic_machine=m68k-isi - os=sysv + basic_os=sysv ;; m68knommu) basic_machine=m68k-unknown - os=linux + basic_os=linux ;; magnum | m3230) basic_machine=mips-mips - os=sysv + basic_os=sysv ;; merlin) basic_machine=ns32k-utek - os=sysv + basic_os=sysv ;; mingw64) basic_machine=x86_64-pc - os=mingw64 + basic_os=mingw64 ;; mingw32) basic_machine=i686-pc - os=mingw32 + basic_os=mingw32 ;; mingw32ce) basic_machine=arm-unknown - os=mingw32ce + basic_os=mingw32ce ;; monitor) basic_machine=m68k-rom68k - os=coff + basic_os=coff ;; morphos) basic_machine=powerpc-unknown - os=morphos + basic_os=morphos ;; moxiebox) basic_machine=moxie-unknown - os=moxiebox + basic_os=moxiebox ;; msdos) basic_machine=i386-pc - os=msdos + basic_os=msdos ;; msys) basic_machine=i686-pc - os=msys + basic_os=msys ;; mvs) basic_machine=i370-ibm - os=mvs + basic_os=mvs ;; nacl) basic_machine=le32-unknown - os=nacl + basic_os=nacl ;; ncr3000) basic_machine=i486-ncr - os=sysv4 + basic_os=sysv4 ;; netbsd386) basic_machine=i386-pc - os=netbsd + basic_os=netbsd ;; netwinder) basic_machine=armv4l-rebel - os=linux + basic_os=linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony - os=newsos + basic_os=newsos ;; news1000) basic_machine=m68030-sony - os=newsos + basic_os=newsos ;; necv70) basic_machine=v70-nec - os=sysv + basic_os=sysv ;; nh3000) basic_machine=m68k-harris - os=cxux + basic_os=cxux ;; nh[45]000) basic_machine=m88k-harris - os=cxux + basic_os=cxux ;; nindy960) basic_machine=i960-intel - os=nindy + basic_os=nindy ;; mon960) basic_machine=i960-intel - os=mon960 + basic_os=mon960 ;; nonstopux) basic_machine=mips-compaq - os=nonstopux + basic_os=nonstopux ;; os400) basic_machine=powerpc-ibm - os=os400 + basic_os=os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson - os=ose + basic_os=ose ;; os68k) basic_machine=m68k-none - os=os68k + basic_os=os68k ;; paragon) basic_machine=i860-intel - os=osf + basic_os=osf ;; parisc) basic_machine=hppa-unknown - os=linux + basic_os=linux + ;; + psp) + basic_machine=mipsallegrexel-sony + basic_os=psp ;; pw32) basic_machine=i586-unknown - os=pw32 + basic_os=pw32 ;; rdos | rdos64) basic_machine=x86_64-pc - os=rdos + basic_os=rdos ;; rdos32) basic_machine=i386-pc - os=rdos + basic_os=rdos ;; rom68k) basic_machine=m68k-rom68k - os=coff + basic_os=coff ;; sa29200) basic_machine=a29k-amd - os=udi + basic_os=udi ;; sei) basic_machine=mips-sei - os=seiux + basic_os=seiux ;; sequent) basic_machine=i386-sequent - os= + basic_os= ;; sps7) basic_machine=m68k-bull - os=sysv2 + basic_os=sysv2 ;; st2000) basic_machine=m68k-tandem - os= + basic_os= ;; stratus) basic_machine=i860-stratus - os=sysv4 + basic_os=sysv4 ;; sun2) basic_machine=m68000-sun - os= + basic_os= ;; sun2os3) basic_machine=m68000-sun - os=sunos3 + basic_os=sunos3 ;; sun2os4) basic_machine=m68000-sun - os=sunos4 + basic_os=sunos4 ;; sun3) basic_machine=m68k-sun - os= + basic_os= ;; sun3os3) basic_machine=m68k-sun - os=sunos3 + basic_os=sunos3 ;; sun3os4) basic_machine=m68k-sun - os=sunos4 + basic_os=sunos4 ;; sun4) basic_machine=sparc-sun - os= + basic_os= ;; sun4os3) basic_machine=sparc-sun - os=sunos3 + basic_os=sunos3 ;; sun4os4) basic_machine=sparc-sun - os=sunos4 + basic_os=sunos4 ;; sun4sol2) basic_machine=sparc-sun - os=solaris2 + basic_os=solaris2 ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun - os= + basic_os= ;; sv1) basic_machine=sv1-cray - os=unicos + basic_os=unicos ;; symmetry) basic_machine=i386-sequent - os=dynix + basic_os=dynix ;; t3e) basic_machine=alphaev5-cray - os=unicos + basic_os=unicos ;; t90) basic_machine=t90-cray - os=unicos + basic_os=unicos ;; toad1) basic_machine=pdp10-xkl - os=tops20 + basic_os=tops20 ;; tpf) basic_machine=s390x-ibm - os=tpf + basic_os=tpf ;; udi29k) basic_machine=a29k-amd - os=udi + basic_os=udi ;; ultra3) basic_machine=a29k-nyu - os=sym1 + basic_os=sym1 ;; v810 | necv810) basic_machine=v810-nec - os=none + basic_os=none ;; vaxv) basic_machine=vax-dec - os=sysv + basic_os=sysv ;; vms) basic_machine=vax-dec - os=vms + basic_os=vms ;; vsta) basic_machine=i386-pc - os=vsta + basic_os=vsta ;; vxworks960) basic_machine=i960-wrs - os=vxworks + basic_os=vxworks ;; vxworks68) basic_machine=m68k-wrs - os=vxworks + basic_os=vxworks ;; vxworks29k) basic_machine=a29k-wrs - os=vxworks + basic_os=vxworks ;; xbox) basic_machine=i686-pc - os=mingw32 + basic_os=mingw32 ;; ymp) basic_machine=ymp-cray - os=unicos + basic_os=unicos ;; *) basic_machine=$1 - os= + basic_os= ;; esac ;; @@ -683,27 +755,38 @@ case $basic_machine in bluegene*) cpu=powerpc vendor=ibm - os=cnk + basic_os=cnk ;; decsystem10* | dec10*) cpu=pdp10 vendor=dec - os=tops10 + basic_os=tops10 ;; decsystem20* | dec20*) cpu=pdp10 vendor=dec - os=tops20 + basic_os=tops20 ;; - delta | 3300 | motorola-3300 | motorola-delta \ - | 3300-motorola | delta-motorola) + delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300) cpu=m68k vendor=motorola ;; - dpx2*) + # This used to be dpx2*, but that gets the RS6000-based + # DPX/20 and the x86-based DPX/2-100 wrong. See + # https://oldskool.silicium.org/stations/bull_dpx20.htm + # https://www.feb-patrimoine.com/english/bull_dpx2.htm + # https://www.feb-patrimoine.com/english/unix_and_bull.htm + dpx2 | dpx2[23]00 | dpx2[23]xx) cpu=m68k vendor=bull - os=sysv3 + ;; + dpx2100 | dpx21xx) + cpu=i386 + vendor=bull + ;; + dpx20) + cpu=rs6000 + vendor=bull ;; encore | umax | mmax) cpu=ns32k @@ -712,7 +795,7 @@ case $basic_machine in elxsi) cpu=elxsi vendor=elxsi - os=${os:-bsd} + basic_os=${basic_os:-bsd} ;; fx2800) cpu=i860 @@ -725,7 +808,7 @@ case $basic_machine in h3050r* | hiux*) cpu=hppa1.1 vendor=hitachi - os=hiuxwe2 + basic_os=hiuxwe2 ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) cpu=hppa1.0 @@ -768,36 +851,36 @@ case $basic_machine in i*86v32) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc - os=sysv32 + basic_os=sysv32 ;; i*86v4*) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc - os=sysv4 + basic_os=sysv4 ;; i*86v) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc - os=sysv + basic_os=sysv ;; i*86sol2) cpu=`echo "$1" | sed -e 's/86.*/86/'` vendor=pc - os=solaris2 + basic_os=solaris2 ;; j90 | j90-cray) cpu=j90 vendor=cray - os=${os:-unicos} + basic_os=${basic_os:-unicos} ;; iris | iris4d) cpu=mips vendor=sgi - case $os in + case $basic_os in irix*) ;; *) - os=irix4 + basic_os=irix4 ;; esac ;; @@ -808,28 +891,16 @@ case $basic_machine in *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) cpu=m68k vendor=atari - os=mint + basic_os=mint ;; news-3600 | risc-news) cpu=mips vendor=sony - os=newsos + basic_os=newsos ;; next | m*-next) cpu=m68k vendor=next - case $os in - openstep*) - ;; - nextstep*) - ;; - ns2*) - os=nextstep2 - ;; - *) - os=nextstep3 - ;; - esac ;; np1) cpu=np1 @@ -838,12 +909,12 @@ case $basic_machine in op50n-* | op60c-*) cpu=hppa1.1 vendor=oki - os=proelf + basic_os=proelf ;; pa-hitachi) cpu=hppa1.1 vendor=hitachi - os=hiuxwe2 + basic_os=hiuxwe2 ;; pbd) cpu=sparc @@ -880,12 +951,12 @@ case $basic_machine in sde) cpu=mipsisa32 vendor=sde - os=${os:-elf} + basic_os=${basic_os:-elf} ;; simso-wrs) cpu=sparclite vendor=wrs - os=vxworks + basic_os=vxworks ;; tower | tower-32) cpu=m68k @@ -902,7 +973,7 @@ case $basic_machine in w89k-*) cpu=hppa1.1 vendor=winbond - os=proelf + basic_os=proelf ;; none) cpu=none @@ -918,12 +989,13 @@ case $basic_machine in ;; *-*) - # shellcheck disable=SC2162 + saved_IFS=$IFS IFS="-" read cpu vendor <<EOF $basic_machine EOF + IFS=$saved_IFS ;; - # We use `pc' rather than `unknown' + # 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) @@ -951,15 +1023,19 @@ 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. + # 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. + c[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown) + vendor=convex + basic_os=${basic_os:-bsd} + ;; craynv-unknown) vendor=cray - os=${os:-unicosmp} + basic_os=${basic_os:-unicosmp} ;; c90-unknown | c90-cray) vendor=cray - os=${os:-unicos} + basic_os=${basic_os:-unicos} ;; fx80-unknown) vendor=alliant @@ -1000,10 +1076,33 @@ case $cpu-$vendor in ;; # Here we normalize CPU types with a missing or matching vendor - dpx20-unknown | dpx20-bull) - cpu=rs6000 - vendor=bull - os=${os:-bosx} + armh-unknown | armh-alt) + cpu=armv7l + vendor=alt + basic_os=${basic_os:-linux-gnueabihf} + ;; + + # Normalized CPU+vendor pairs that imply an OS, if not otherwise specified + m68k-isi) + basic_os=${basic_os:-sysv} + ;; + m68k-sony) + basic_os=${basic_os:-newsos} + ;; + m68k-tektronix) + basic_os=${basic_os:-bsd} + ;; + m88k-harris) + basic_os=${basic_os:-sysv3} + ;; + i386-bull | m68k-bull) + basic_os=${basic_os:-sysv3} + ;; + rs6000-bull) + basic_os=${basic_os:-bosx} + ;; + mips-sni) + basic_os=${basic_os:-sysv4} ;; # Here we normalize CPU types irrespective of the vendor @@ -1012,7 +1111,7 @@ case $cpu-$vendor in ;; blackfin-*) cpu=bfin - os=linux + basic_os=${basic_os:-linux} ;; c54x-*) cpu=tic54x @@ -1025,7 +1124,7 @@ case $cpu-$vendor in ;; e500v[12]-*) cpu=powerpc - os=$os"spe" + basic_os=${basic_os}"spe" ;; mips3*-*) cpu=mips64 @@ -1035,7 +1134,7 @@ case $cpu-$vendor in ;; m68knommu-*) cpu=m68k - os=linux + basic_os=${basic_os:-linux} ;; m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*) cpu=s12z @@ -1045,12 +1144,12 @@ case $cpu-$vendor in ;; parisc-*) cpu=hppa - os=linux + basic_os=${basic_os:-linux} ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) cpu=i586 ;; - pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*) + pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*) cpu=i686 ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) @@ -1059,9 +1158,6 @@ case $cpu-$vendor in pentium4-*) cpu=i786 ;; - pc98-*) - cpu=i386 - ;; ppc-* | ppcbe-*) cpu=powerpc ;; @@ -1095,17 +1191,17 @@ case $cpu-$vendor in tx39el-*) cpu=mipstx39el ;; - x64-*) - cpu=x86_64 - ;; xscale-* | xscalee[bl]-*) cpu=`echo "$cpu" | sed 's/^xscale/arm/'` ;; + arm64-* | aarch64le-* | arm64_32-*) + cpu=aarch64 + ;; # Recognize the canonical CPU Types that limit and/or modify the # company names they are paired with. cr16-*) - os=${os:-elf} + basic_os=${basic_os:-elf} ;; crisv32-* | etraxfs*-*) cpu=crisv32 @@ -1116,7 +1212,7 @@ case $cpu-$vendor in vendor=axis ;; crx-*) - os=${os:-elf} + basic_os=${basic_os:-elf} ;; neo-tandem) cpu=neo @@ -1138,123 +1234,245 @@ case $cpu-$vendor in cpu=nsx vendor=tandem ;; - s390-*) - cpu=s390 - vendor=ibm - ;; - s390x-*) - cpu=s390x - vendor=ibm + mipsallegrexel-sony) + cpu=mipsallegrexel + vendor=sony ;; tile*-*) - os=${os:-linux-gnu} + basic_os=${basic_os:-linux-gnu} ;; *) # Recognize the canonical CPU types that are allowed with any # company name. case $cpu in - 1750a | 580 \ + 1750a \ + | 580 \ + | [cjt]90 \ | a29k \ - | aarch64 | aarch64_be \ + | aarch64 \ + | aarch64_be \ + | aarch64c \ | abacus \ - | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ - | alphapca5[67] | alpha64pca5[67] \ + | alpha \ + | alpha64 \ + | alpha64ev56 \ + | alpha64ev6[78] \ + | alpha64ev[4-8] \ + | alpha64pca5[67] \ + | alphaev56 \ + | alphaev6[78] \ + | alphaev[4-8] \ + | alphapca5[67] \ | am33_2.0 \ | amdgcn \ - | arc | arceb \ - | arm | arm[lb]e | arme[lb] | armv* \ - | avr | avr32 \ + | arc \ + | arc32 \ + | arc64 \ + | arceb \ + | arm \ + | arm64e \ + | arm64ec \ + | arm[lb]e \ + | arme[lb] \ + | armv* \ | asmjs \ + | avr \ + | avr32 \ | 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 \ + | be32 \ + | be64 \ + | bfin \ + | bpf \ + | bs2000 \ + | c30 \ + | c4x \ + | c8051 \ + | c[123]* \ + | clipper \ + | craynv \ + | csky \ + | cydra \ + | d10v \ + | d30v \ + | dlx \ + | dsp16xx \ + | e2k \ + | elxsi \ + | epiphany \ + | f30[01] \ + | f700 \ + | fido \ + | fr30 \ + | frv \ + | ft32 \ + | fx80 \ + | h8300 \ + | h8500 \ | hexagon \ - | i370 | i*86 | i860 | i960 | ia16 | ia64 \ - | ip2k | iq2000 \ + | hppa \ + | hppa1.[01] \ + | hppa2.0 \ + | hppa2.0[nw] \ + | hppa64 \ + | i*86 \ + | i370 \ + | i860 \ + | i960 \ + | ia16 \ + | ia64 \ + | intelgt \ + | ip2k \ + | iq2000 \ + | javascript \ | k1om \ - | le32 | le64 \ + | kvx \ + | 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 \ + | loongarch32 \ + | loongarch64 \ + | m32c \ + | m32r \ + | m32rle \ + | m5200 \ + | m68000 \ + | m680[012346]0 \ + | m6811 \ + | m6812 \ + | m68360 \ + | m683?2 \ + | m68hc11 \ + | m68hc12 \ + | m68hcs12x \ + | m68k \ + | m88110 \ + | m88k \ + | maxq \ + | mb \ + | mcore \ + | mep \ + | metag \ + | microblaze \ + | microblazeel \ + | mips* \ | mmix \ - | mn10200 | mn10300 \ + | mn10200 \ + | mn10300 \ | moxie \ - | mt \ | msp430 \ - | nds32 | nds32le | nds32be \ + | mt \ + | nanomips* \ + | nds32 \ + | nds32be \ + | nds32le \ | nfp \ - | nios | nios2 | nios2eb | nios2el \ - | none | np1 | ns16k | ns32k | nvptx \ + | nios \ + | nios2 \ + | nios2eb \ + | nios2el \ + | none \ + | np1 \ + | ns16k \ + | ns32k \ + | nvptx \ | open8 \ | or1k* \ | or32 \ | orion \ + | pdp10 \ + | pdp11 \ | picochip \ - | pdp10 | pdp11 | pj | pjl | pn | power \ - | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pj \ + | pjl \ + | pn \ + | power \ + | powerpc \ + | powerpc64 \ + | powerpc64le \ + | powerpcle \ + | powerpcspe \ | pru \ | pyramid \ - | riscv | riscv32 | riscv64 \ - | rl78 | romp | rs6000 | rx \ + | riscv \ + | riscv32 \ + | riscv32be \ + | riscv64 \ + | riscv64be \ + | rl78 \ + | romp \ + | rs6000 \ + | rx \ + | s390 \ + | s390x \ | 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 \ + | sh \ + | sh64 \ + | sh64le \ + | sh[12345][lb]e \ + | sh[1234] \ + | sh[1234]e[lb] \ + | sh[23]e \ + | sh[23]ele \ + | sh[24]a \ + | sh[24]ae[lb] \ + | sh[lb]e \ + | she[lb] \ + | shl \ + | sparc \ + | sparc64 \ + | sparc64b \ + | sparc64v \ + | sparc86x \ + | sparclet \ | sparclite \ - | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | sparcv8 \ + | sparcv9 \ + | sparcv9b \ + | sparcv9v \ | spu \ + | sv1 \ + | sw_64 \ + | sx* \ | tahoe \ - | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | thumbv7* \ + | tic30 \ + | tic4x \ + | tic54x \ + | tic55x \ + | tic6x \ + | tic80 \ | tron \ | ubicom32 \ - | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | v70 \ + | v810 \ + | v850 \ + | v850e \ + | v850e1 \ + | v850e2 \ + | v850e2v3 \ + | v850es \ | vax \ + | vc4 \ | visium \ | w65 \ - | wasm32 | wasm64 \ + | wasm32 \ + | wasm64 \ | we32k \ - | x86 | x86_64 | xc16x | xgate | xps100 \ - | xstormy16 | xtensa* \ + | x86 \ + | x86_64 \ + | xc16x \ + | xgate \ + | xps100 \ + | xstormy16 \ + | xtensa* \ | ymp \ - | z8k | z80) + | z80 \ + | z8k) ;; *) - echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2 exit 1 ;; esac @@ -1275,8 +1493,57 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x$os != x ] +if test x"$basic_os" != x then + +# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just +# set os. +obj= +case $basic_os in + gnu/linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'` + ;; + os2-emx) + kernel=os2 + os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'` + ;; + nto-qnx*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'` + ;; + *-*) + saved_IFS=$IFS + IFS="-" read kernel os <<EOF +$basic_os +EOF + IFS=$saved_IFS + ;; + # Default OS when just kernel was specified + nto*) + kernel=nto + os=`echo "$basic_os" | sed -e 's|nto|qnx|'` + ;; + ironclad*) + kernel=ironclad + os=`echo "$basic_os" | sed -e 's|ironclad|gnu|'` + ;; + linux*) + kernel=linux + os=`echo "$basic_os" | sed -e 's|linux|gnu|'` + ;; + managarm*) + kernel=managarm + os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'` + ;; + *) + kernel= + os=$basic_os + ;; +esac + +# Now, normalize the OS (knowing we just have one component, it's not a kernel, +# etc.) case $os in # First match some system type aliases that might get confused # with valid system types. @@ -1288,7 +1555,7 @@ case $os in os=cnk ;; solaris1 | solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` + os=`echo "$os" | sed -e 's|solaris1|sunos4|'` ;; solaris) os=solaris2 @@ -1296,8 +1563,22 @@ case $os in unixware*) os=sysv4.2uw ;; - gnu/linux*) - os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + # The marketing names for NeXT's operating systems were + # NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is + # mapped to 'openstep3', but 'openstep1' and 'openstep2' are + # mapped to 'nextstep' and 'nextstep2', consistent with the + # treatment of SunOS/Solaris. + ns | ns1 | nextstep | nextstep1 | openstep1) + os=nextstep + ;; + ns2 | nextstep2 | openstep2) + os=nextstep2 + ;; + ns3 | nextstep3 | openstep | openstep3) + os=openstep3 + ;; + ns4 | nextstep4 | openstep4) + os=openstep4 ;; # es1800 is here to avoid being matched by es* (a different OS) es1800*) @@ -1320,12 +1601,9 @@ case $os in os=sco3.2v4 ;; sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'` ;; - sco3.2v[4-9]* | sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - ;; - scout) + sco*v* | scout) # Don't match below ;; sco*) @@ -1334,78 +1612,25 @@ case $os in psos*) os=psos ;; - # Now accept the basic system types. - # The portable systems comes first. - # Each alternative MUST end in a * to match a version number. - # sysv* is not here because it comes later, after sysvr4. - gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ - | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\ - | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ - | sym* | kopensolaris* | plan9* \ - | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ - | aos* | aros* | cloudabi* | sortix* | twizzler* \ - | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ - | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ - | knetbsd* | mirbsd* | netbsd* \ - | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ - | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \ - | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ - | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ - | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \ - | chorusrdb* | cegcc* | glidix* \ - | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ - | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \ - | linux-newlib* | linux-musl* | linux-uclibc* \ - | uxpv* | beos* | mpeix* | udk* | moxiebox* \ - | interix* | uwin* | mks* | rhapsody* | darwin* \ - | openstep* | oskit* | conix* | pw32* | nonstopux* \ - | storm-chaos* | tops10* | tenex* | tops20* | its* \ - | os2* | vos* | palmos* | uclinux* | nucleus* \ - | morphos* | superux* | rtmk* | windiss* \ - | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ - | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ - | nsk* | powerunix* | genode*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; qnx*) - case $cpu in - x86 | i*86) - ;; - *) - os=nto-$os - ;; - esac + os=qnx ;; hiux*) os=hiuxwe2 ;; - nto-qnx*) - ;; - nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` - ;; - sim | xray | os68k* | v88r* \ - | windows* | osx | abug | netware* | os9* \ - | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) - ;; - linux-dietlibc) - os=linux-dietlibc - ;; - linux*) - os=`echo $os | sed -e 's|linux|linux-gnu|'` - ;; lynx*178) os=lynxos178 ;; lynx*5) os=lynxos5 ;; + lynxos*) + # don't get caught up in next wildcard + ;; lynx*) os=lynxos ;; - mac*) + mac[0-9]*) os=`echo "$os" | sed -e 's|mac|macos|'` ;; opened*) @@ -1425,6 +1650,7 @@ case $os in ;; utek*) os=bsd + vendor=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'` ;; dynix*) os=bsd @@ -1441,21 +1667,25 @@ case $os in 386bsd) os=bsd ;; - ctix* | uts*) + ctix*) os=sysv + vendor=`echo "$vendor" | sed -e 's|^unknown$|convergent|'` ;; - nova*) - os=rtmk-nova + uts*) + os=sysv ;; - ns2) - os=nextstep2 + nova*) + kernel=rtmk + os=nova ;; # Preserve the version number of sinix5. sinix5.*) - os=`echo $os | sed -e 's|sinix|sysv|'` + os=`echo "$os" | sed -e 's|sinix|sysv|'` + vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'` ;; sinix*) os=sysv4 + vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'` ;; tpf*) os=tpf @@ -1475,18 +1705,12 @@ case $os in sysvr4) os=sysv4 ;; - # This must come after sysvr4. - sysv*) - ;; ose*) os=ose ;; *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) os=mint ;; - zvmoe) - os=zvmoe - ;; dicos*) os=dicos ;; @@ -1499,23 +1723,21 @@ case $os in os=eabi ;; *) - os=elf + os= + obj=elf ;; esac ;; - nacl*) - ;; - ios) - ;; - none) - ;; - *-eabi) + aout* | coff* | elf* | pe*) + # These are machine code file formats, not OSes + obj=$os + os= ;; *) - echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1528,42 +1750,54 @@ else # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. +kernel= +obj= case $cpu-$vendor in score-*) - os=elf + os= + obj=elf ;; spu-*) - os=elf + os= + obj=elf ;; *-acorn) os=riscix1.2 ;; arm*-rebel) - os=linux + kernel=linux + os=gnu ;; arm*-semi) - os=aout + os= + obj=aout ;; c4x-* | tic4x-*) - os=coff + os= + obj=coff ;; c8051-*) - os=elf + os= + obj=elf ;; clipper-intergraph) os=clix ;; hexagon-*) - os=elf + os= + obj=elf ;; tic54x-*) - os=coff + os= + obj=coff ;; tic55x-*) - os=coff + os= + obj=coff ;; tic6x-*) - os=coff + os= + obj=coff ;; # This must come before the *-dec entry. pdp10-*) @@ -1585,28 +1819,43 @@ case $cpu-$vendor in os=sunos3 ;; m68*-cisco) - os=aout + os= + obj=aout ;; mep-*) - os=elf + os= + obj=elf + ;; + # The -sgi and -siemens entries must be before the mips- entry + # or we get the wrong os. + *-sgi) + os=irix + ;; + *-siemens) + os=sysv4 ;; mips*-cisco) - os=elf + os= + obj=elf ;; - mips*-*) - os=elf + mips*-*|nanomips*-*) + os= + obj=elf ;; or32-*) - os=coff + os= + obj=coff ;; - *-tti) # must be before sparc entry or we get the wrong os. + # This must be before the sparc-* entry or we get the wrong os. + *-tti) os=sysv3 ;; sparc-* | *-sun) os=sunos4.1.1 ;; pru-*) - os=elf + os= + obj=elf ;; *-be) os=beos @@ -1630,7 +1879,7 @@ case $cpu-$vendor in os=hpux ;; *-hitachi) - os=hiux + os=hiuxwe2 ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=sysv @@ -1674,12 +1923,6 @@ case $cpu-$vendor in *-encore) os=bsd ;; - *-sgi) - os=irix - ;; - *-siemens) - os=sysv4 - ;; *-masscomp) os=rtu ;; @@ -1687,10 +1930,12 @@ case $cpu-$vendor in os=uxpv ;; *-rom68k) - os=coff + os= + obj=coff ;; *-*bug) - os=coff + os= + obj=coff ;; *-apple) os=macos @@ -1705,89 +1950,416 @@ case $cpu-$vendor in os=none ;; esac + fi +# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ). + +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + llvm* | musl* | newlib* | relibc* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # See `case $cpu-$os` validation below + ghcjs) + ;; + # Now accept the basic system types. + # Each alternative MUST end in a * to match a version number. + abug \ + | aix* \ + | amdhsa* \ + | amigados* \ + | amigaos* \ + | android* \ + | aof* \ + | aos* \ + | aros* \ + | atheos* \ + | auroraux* \ + | aux* \ + | banan_os* \ + | beos* \ + | bitrig* \ + | bme* \ + | bosx* \ + | bsd* \ + | cegcc* \ + | chorusos* \ + | chorusrdb* \ + | clix* \ + | cloudabi* \ + | cnk* \ + | conix* \ + | cos* \ + | cxux* \ + | cygwin* \ + | darwin* \ + | dgux* \ + | dicos* \ + | dnix* \ + | domain* \ + | dragonfly* \ + | drops* \ + | ebmon* \ + | ecoff* \ + | ekkobsd* \ + | emscripten* \ + | emx* \ + | es* \ + | fiwix* \ + | freebsd* \ + | fuchsia* \ + | genix* \ + | genode* \ + | glidix* \ + | gnu* \ + | go32* \ + | haiku* \ + | hcos* \ + | hiux* \ + | hms* \ + | hpux* \ + | ieee* \ + | interix* \ + | ios* \ + | iris* \ + | irix* \ + | isc* \ + | its* \ + | l4re* \ + | libertybsd* \ + | lites* \ + | lnews* \ + | luna* \ + | lynxos* \ + | mach* \ + | macos* \ + | magic* \ + | mbr* \ + | midipix* \ + | midnightbsd* \ + | mingw32* \ + | mingw64* \ + | minix* \ + | mint* \ + | mirbsd* \ + | mks* \ + | mlibc* \ + | mmixware* \ + | mon960* \ + | morphos* \ + | moss* \ + | moxiebox* \ + | mpeix* \ + | mpw* \ + | msdos* \ + | msys* \ + | mvs* \ + | nacl* \ + | netbsd* \ + | netware* \ + | newsos* \ + | nextstep* \ + | nindy* \ + | nonstopux* \ + | nova* \ + | nsk* \ + | nucleus* \ + | nx6 \ + | nx7 \ + | oabi* \ + | ohos* \ + | onefs* \ + | openbsd* \ + | openedition* \ + | openstep* \ + | os108* \ + | os2* \ + | os400* \ + | os68k* \ + | os9* \ + | ose* \ + | osf* \ + | oskit* \ + | osx* \ + | palmos* \ + | phoenix* \ + | plan9* \ + | powermax* \ + | powerunix* \ + | proelf* \ + | psos* \ + | psp* \ + | ptx* \ + | pw32* \ + | qnx* \ + | rdos* \ + | redox* \ + | rhapsody* \ + | riscix* \ + | riscos* \ + | rtems* \ + | rtmk* \ + | rtu* \ + | scout* \ + | secbsd* \ + | sei* \ + | serenity* \ + | sim* \ + | skyos* \ + | solaris* \ + | solidbsd* \ + | sortix* \ + | storm-chaos* \ + | sunos \ + | sunos[34]* \ + | superux* \ + | syllable* \ + | sym* \ + | sysv* \ + | tenex* \ + | tirtos* \ + | tock* \ + | toppers* \ + | tops10* \ + | tops20* \ + | tpf* \ + | tvos* \ + | twizzler* \ + | uclinux* \ + | udi* \ + | udk* \ + | ultrix* \ + | unicos* \ + | uniplus* \ + | unleashed* \ + | unos* \ + | uwin* \ + | uxpv* \ + | v88r* \ + |*vms* \ + | vos* \ + | vsta* \ + | vxsim* \ + | vxworks* \ + | wasi* \ + | watchos* \ + | wince* \ + | windiss* \ + | windows* \ + | winnt* \ + | xenix* \ + | xray* \ + | zephyr* \ + | zvmoe* ) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + # This refers to builds using the UEFI calling convention + # (which depends on the architecture) and PE file format. + # Note that this is both a different calling convention and + # different file format than that of GNU-EFI + # (x86_64-w64-mingw32). + uefi) + ;; + none) + ;; + kernel* | msvc* ) + # Restricted further below + ;; + '') + if test x"$obj" = x + then + echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2 + fi + ;; + *) + echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2 + exit 1 + ;; +esac + +case $obj in + aout* | coff* | elf* | pe*) + ;; + '') + # empty is fine + ;; + *) + echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2 + exit 1 + ;; +esac + +# Here we handle the constraint that a (synthetic) cpu and os are +# valid only in combination with each other and nowhere else. +case $cpu-$os in + # The "javascript-unknown-ghcjs" triple is used by GHC; we + # accept it here in order to tolerate that, but reject any + # variations. + javascript-ghcjs) + ;; + javascript-* | *-ghcjs) + echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os-$obj in + linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \ + | linux-mlibc*- | linux-musl*- | linux-newlib*- \ + | linux-relibc*- | linux-uclibc*- | linux-ohos*- ) + ;; + uclinux-uclibc*- | uclinux-gnu*- ) + ;; + ironclad-gnu*- | ironclad-mlibc*- ) + ;; + managarm-mlibc*- | managarm-kernel*- ) + ;; + windows*-msvc*-) + ;; + -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \ + | -uclibc*- ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2 + exit 1 + ;; + -kernel*- ) + echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2 + exit 1 + ;; + *-kernel*- ) + echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2 + exit 1 + ;; + *-msvc*- ) + echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2 + exit 1 + ;; + kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-) + ;; + vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-) + ;; + nto-qnx*-) + ;; + os2-emx-) + ;; + rtmk-nova-) + ;; + *-eabi*- | *-gnueabi*-) + ;; + ios*-simulator- | tvos*-simulator- | watchos*-simulator- ) + ;; + none--*) + # None (no kernel, i.e. freestanding / bare metal), + # can be paired with an machine code file format + ;; + -*-) + # Blank kernel with real OS is always fine. + ;; + --*) + # Blank kernel and OS with real machine code file format is always fine. + ;; + *-*-*) + echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. case $vendor in unknown) - case $os in - riscix*) + case $cpu-$os in + *-riscix*) vendor=acorn ;; - sunos*) + *-sunos* | *-solaris*) vendor=sun ;; - cnk*|-aix*) + *-cnk* | *-aix*) vendor=ibm ;; - beos*) + *-beos*) vendor=be ;; - hpux*) + *-hpux*) vendor=hp ;; - mpeix*) + *-mpeix*) vendor=hp ;; - hiux*) + *-hiux*) vendor=hitachi ;; - unos*) + *-unos*) vendor=crds ;; - dgux*) + *-dgux*) vendor=dg ;; - luna*) + *-luna*) vendor=omron ;; - genix*) + *-genix*) vendor=ns ;; - clix*) + *-clix*) vendor=intergraph ;; - mvs* | opened*) + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - os400*) + s390-* | s390x-*) vendor=ibm ;; - ptx*) + *-ptx*) vendor=sequent ;; - tpf*) + *-tpf*) vendor=ibm ;; - vxsim* | vxworks* | windiss*) + *-vxsim* | *-vxworks* | *-windiss*) vendor=wrs ;; - aux*) + *-aux*) vendor=apple ;; - hms*) + *-hms*) vendor=hitachi ;; - mpw* | macos*) + *-mpw* | *-macos*) vendor=apple ;; - *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*) vendor=atari ;; - vos*) + *-vos*) vendor=stratus ;; esac ;; esac -echo "$cpu-$vendor-$os" +echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}" exit # Local variables: -# eval: (add-hook 'before-save-hook 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp nil t) # time-stamp-start: "timestamp='" -# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-format: "%Y-%02m-%02d" # time-stamp-end: "'" # End: diff --git a/configure.ac b/configure.ac index 5002cca8b..d02abe7ce 100644 --- a/configure.ac +++ b/configure.ac @@ -422,11 +422,11 @@ AC_ARG_ENABLE(pcre, AS_HELP_STRING([--enable-pcre],[enable the search for the pcre2 library (may create run-time library dependencies)])) AC_ARG_VAR(PCRE_CONFIG, [pathname of pcre2-config if it is not in PATH]) +AC_ARG_VAR(PCRE_LIBS, [library linker flag to use for pcre module if pcre2-config is not available]) if test "x$enable_pcre" = xyes; then AC_CHECK_PROG([PCRE_CONFIG], pcre2-config, pcre2-config) if test "x$PCRE_CONFIG" = x; then - enable_pcre=no - AC_MSG_WARN([pcre2-config not found: pcre module is disabled.]) + AC_MSG_WARN([pcre2-config not found: will search for pcre library in specified paths. (You will probably need to pass PCRE_LIBS=-lpcre2-8 to configure for this to work.)]) AC_MSG_NOTICE( [Set PCRE_CONFIG to pathname of pcre2-config if it is not in PATH.]) fi @@ -438,8 +438,15 @@ AS_HELP_STRING([--enable-cap],[enable the search for POSIX capabilities (may req # Default off for licensing reasons AC_ARG_ENABLE(gdbm, -AS_HELP_STRING([--enable-gdbm],[enable the search for the GDBM library (see the zsh/db/gdbm module)]), -[gdbm="$enableval"], [gdbm=no]) +AS_HELP_STRING([--enable-gdbm],[enable the search for the GDBM library (see the zsh/db/gdbm module)])) + +dnl +dnl link all libraries in main shell +dnl +AC_ARG_ENABLE(link-all-libs, +AS_HELP_STRING([--disable-link-all-libs], + [do not link module-only libraries into the main binary]), +[enable_link_all_libs=$enableval], [enable_link_all_libs=yes]) dnl ------------------ dnl CHECK THE COMPILER @@ -615,8 +622,10 @@ dnl pcre2-config --cflags may produce a -I output which needs to go into dnl CPPFLAGS else configure's preprocessor tests don't pick it up, dnl producing a warning. if test "x$enable_pcre" = xyes; then - CPPFLAGS="`$PCRE_CONFIG --cflags` $CPPFLAGS" - AC_CHECK_HEADERS([pcre2.h],,,[#define PCRE2_CODE_UNIT_WIDTH 8]) + if test "x$PCRE_CONFIG" != x; then + CPPFLAGS="`$PCRE_CONFIG --cflags` $CPPFLAGS" + fi + AC_CHECK_HEADERS([pcre2.h],[],[AC_MSG_FAILURE([pcre2.h not found])],[#define PCRE2_CODE_UNIT_WIDTH 8]) fi AC_CHECK_HEADERS(sys/time.h sys/times.h sys/select.h termcap.h termio.h \ @@ -676,10 +685,10 @@ fi AH_TEMPLATE([WINSIZE_IN_PTEM], [Define if your should include sys/stream.h and sys/ptem.h.]) AC_CACHE_CHECK(for streams headers including struct winsize, -ac_cv_winsize_in_ptem, +zsh_cv_winsize_in_ptem, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stream.h> -#include <sys/ptem.h>]], [[struct winsize wsz]])],[ac_cv_winsize_in_ptem=yes],[ac_cv_winsize_in_ptem=no])]) -if test x$ac_cv_winsize_in_ptem = xyes; then +#include <sys/ptem.h>]], [[struct winsize wsz]])],[zsh_cv_winsize_in_ptem=yes],[zsh_cv_winsize_in_ptem=no])]) +if test x$zsh_cv_winsize_in_ptem = xyes; then AC_DEFINE(WINSIZE_IN_PTEM) fi @@ -719,7 +728,6 @@ AC_ARG_WITH(term-lib, AS_HELP_STRING([--with-term-lib=LIBS],[search space-separated LIBS for terminal handling]), [if test "x$withval" != xno && test "x$withval" != x ; then termcap_curses_order="$withval" - AC_SEARCH_LIBS(tigetstr, [$termcap_curses_order]) else termcap_curses_order="$ncursesw_test $ncurses_test tinfow tinfo termcap curses" fi], @@ -764,11 +772,11 @@ This is probably a library called 'curses' or 'ncurses'. You may need to install a package called 'curses-devel' or 'ncurses-devel' on your system."], 255)) AC_CHECK_HEADERS(curses.h, [], -[AC_CACHE_CHECK(for Solaris 8 curses.h mistake, ac_cv_header_curses_solaris, -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[]])],[ac_cv_header_curses_h=yes -ac_cv_header_curses_solaris=yes],[ac_cv_header_curses_h=no -ac_cv_header_curses_solaris=no])) -if test x$ac_cv_header_curses_solaris = xyes; then +[AC_CACHE_CHECK(for Solaris 8 curses.h mistake, zsh_cv_header_curses_solaris, +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[]])], + [zsh_cv_header_curses_solaris=yes], + [zsh_cv_header_curses_solaris=no])) +if test x$zsh_cv_header_curses_solaris = xyes; then AC_DEFINE(HAVE_CURSES_H) fi]) @@ -829,10 +837,19 @@ AC_CACHE_CHECK(if we need to ignore ncurses, zsh_cv_ignore_ncurses, zsh_cv_ignore_ncurses=yes ;; esac + LIBS="$LIBS_save" esac ;; esac]) +dnl Ensure the ncurses library is in LIBS on cached runs where the above code was skipped +if test x$zsh_cv_ignore_ncurses = xno; then + case $LIBS in + *-lncurses*|*-lcurses*) ;; + *) AC_SEARCH_LIBS(initscr, [ncursesw ncurses curses]) ;; + esac +fi + AC_SEARCH_LIBS(getpwnam, nsl) if test "x$dynamic" = xyes; then @@ -840,7 +857,7 @@ if test "x$dynamic" = xyes; then fi if test x$enable_cap = xyes; then - AC_CHECK_LIB(cap, cap_get_proc) + AC_CHECK_LIB(cap, cap_get_proc, [], [AC_MSG_FAILURE([cap_get_proc not found in libcap])]) fi AC_CHECK_LIB(socket, socket) @@ -931,9 +948,18 @@ elif test x$zsh_cv_decl_ospeed_must_define = xyes; then AC_DEFINE(MUST_DEFINE_OSPEED) fi -if test x$gdbm != xno; then - AC_CHECK_HEADERS(gdbm.h) - AC_CHECK_LIB(gdbm, gdbm_open) +if test x$enable_gdbm = xyes; then + AC_CHECK_HEADERS(gdbm.h, [], [AC_MSG_FAILURE([gdbm.h not found])]) + save_LIBS=$LIBS + LIBS= + AC_CHECK_LIB(gdbm, gdbm_fd_open, [], [AC_MSG_FAILURE([gdbm_fd_open not found in libgdbm])]) + GDBM_LIBS=$LIBS + LIBS=$save_LIBS + if test x$enable_link_all_libs = xyes; then + LIBS="$GDBM_LIBS $LIBS" + GDBM_LIBS= + fi + AC_SUBST(GDBM_LIBS) fi AC_CHECK_HEADERS(sys/xattr.h) @@ -1268,7 +1294,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \ grantpt unlockpt ptsname \ htons ntohs \ regcomp regexec regerror regfree \ - gdbm_open getxattr \ + getxattr \ realpath canonicalize_file_name \ symlink getcwd \ cygwin_conv_path \ @@ -1284,23 +1310,27 @@ AC_CHECK_DECLS([fpurge]) # isinf() and isnan() can exist as either functions or macros. AH_TEMPLATE([HAVE_ISINF], [Define to 1 if you have the `isinf' macro or function.]) -AC_MSG_CHECKING([for isinf]) -AC_LINK_IFELSE([AC_LANG_SOURCE( +AC_CACHE_CHECK([for isinf], zsh_cv_func_isinf, +[AC_LINK_IFELSE([AC_LANG_SOURCE( [[#include <math.h> int main () { return (isinf(1.0) != 0); }]])], - [AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_ISINF])], - [AC_MSG_RESULT([no])]) + [zsh_cv_func_isinf=yes], + [zsh_cv_func_isinf=no])]) +if test x$zsh_cv_func_isinf = xyes; then + AC_DEFINE([HAVE_ISINF]) +fi AH_TEMPLATE([HAVE_ISNAN], [Define to 1 if you have the `isnan' macro or function.]) -AC_MSG_CHECKING([for isnan]) -AC_LINK_IFELSE([AC_LANG_SOURCE([[ +AC_CACHE_CHECK([for isnan], zsh_cv_func_isnan, +[AC_LINK_IFELSE([AC_LANG_SOURCE([[ #include <math.h> int main () { return (isnan(1.0) != 0); }]])], - [AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_ISNAN])], - [AC_MSG_RESULT([no])]) + [zsh_cv_func_isnan=yes], + [zsh_cv_func_isnan=no])]) +if test x$zsh_cv_func_isnan = xyes; then + AC_DEFINE([HAVE_ISNAN]) +fi AH_TEMPLATE([REALPATH_ACCEPTS_NULL], [Define if realpath() accepts NULL as its second argument.]) @@ -1320,8 +1350,18 @@ if test x$zsh_cv_func_realpath_accepts_null = xyes; then fi if test x$enable_pcre = xyes; then - LIBS="`$PCRE_CONFIG --libs8` $LIBS" - AC_CHECK_FUNCS(pcre2_compile_8) + save_LIBS=$LIBS + if test "x$PCRE_CONFIG" != x; then + PCRE_LIBS="`$PCRE_CONFIG --libs8`" + fi + LIBS="$PCRE_LIBS $LIBS" + AC_CHECK_FUNCS(pcre2_compile_8, [], [AC_MSG_FAILURE([pcre2_compile_8 not found in $PCRE_LIBS])]) + LIBS=$save_LIBS + if test x$enable_link_all_libs = xyes; then + LIBS="$PCRE_LIBS $LIBS" + PCRE_LIBS= + fi + AC_SUBST(PCRE_LIBS) fi if test x$enable_cap = xyes; then @@ -1683,38 +1723,52 @@ if test x$zsh_cv_path_term_header != xnone; then term_includes="#include <$zsh_cv_path_term_header>" fi - AC_MSG_CHECKING(if boolcodes is available) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no]) - AC_MSG_RESULT($boolcodes) + AC_CACHE_CHECK(if boolcodes is available, zsh_cv_terminfo_boolcodes, + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolcodes; puts(*test);]])],[zsh_cv_terminfo_boolcodes=yes],[zsh_cv_terminfo_boolcodes=no])]) + if test x$zsh_cv_terminfo_boolcodes = xyes; then + AC_DEFINE(HAVE_BOOLCODES) + fi - AC_MSG_CHECKING(if numcodes is available) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no]) - AC_MSG_RESULT($numcodes) + AC_CACHE_CHECK(if numcodes is available, zsh_cv_terminfo_numcodes, + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numcodes; puts(*test);]])],[zsh_cv_terminfo_numcodes=yes],[zsh_cv_terminfo_numcodes=no])]) + if test x$zsh_cv_terminfo_numcodes = xyes; then + AC_DEFINE(HAVE_NUMCODES) + fi - AC_MSG_CHECKING(if strcodes is available) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no]) - AC_MSG_RESULT($strcodes) + AC_CACHE_CHECK(if strcodes is available, zsh_cv_terminfo_strcodes, + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strcodes; puts(*test);]])],[zsh_cv_terminfo_strcodes=yes],[zsh_cv_terminfo_strcodes=no])]) + if test x$zsh_cv_terminfo_strcodes = xyes; then + AC_DEFINE(HAVE_STRCODES) + fi - AC_MSG_CHECKING(if boolnames is available) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no]) - AC_MSG_RESULT($boolnames) + AC_CACHE_CHECK(if boolnames is available, zsh_cv_terminfo_boolnames, + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolnames; puts(*test);]])],[zsh_cv_terminfo_boolnames=yes],[zsh_cv_terminfo_boolnames=no])]) + if test x$zsh_cv_terminfo_boolnames = xyes; then + AC_DEFINE(HAVE_BOOLNAMES) + fi - AC_MSG_CHECKING(if numnames is available) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no]) - AC_MSG_RESULT($numnames) + AC_CACHE_CHECK(if numnames is available, zsh_cv_terminfo_numnames, + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numnames; puts(*test);]])],[zsh_cv_terminfo_numnames=yes],[zsh_cv_terminfo_numnames=no])]) + if test x$zsh_cv_terminfo_numnames = xyes; then + AC_DEFINE(HAVE_NUMNAMES) + fi - AC_MSG_CHECKING(if strnames is available) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no]) - AC_MSG_RESULT($strnames) + AC_CACHE_CHECK(if strnames is available, zsh_cv_terminfo_strnames, + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strnames; puts(*test);]])],[zsh_cv_terminfo_strnames=yes],[zsh_cv_terminfo_strnames=no])]) + if test x$zsh_cv_terminfo_strnames = xyes; then + AC_DEFINE(HAVE_STRNAMES) + fi dnl There are apparently defective terminal library headers on some dnl versions of Solaris before 11. - AC_MSG_CHECKING(if tgoto prototype is missing) - tgoto_includes="$term_includes + AC_CACHE_CHECK(if tgoto prototype is missing, zsh_cv_terminfo_tgoto_proto_missing, + [tgoto_includes="$term_includes /* guaranteed to clash with any valid tgoto prototype */ extern void tgoto(int **stuff, float **more_stuff);" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[$tgoto_includes]], [[int *stuff; float *more_stuff; tgoto(&stuff, &more_stuff);]])],[AC_DEFINE(TGOTO_PROTO_MISSING) tgotoprotomissing=yes],[tgotoprotomissing=no]) - AC_MSG_RESULT($tgotoprotomissing) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$tgoto_includes]], [[int *stuff; float *more_stuff; tgoto(&stuff, &more_stuff);]])],[zsh_cv_terminfo_tgoto_proto_missing=yes],[zsh_cv_terminfo_tgoto_proto_missing=no])]) + if test x$zsh_cv_terminfo_tgoto_proto_missing = xyes; then + AC_DEFINE(TGOTO_PROTO_MISSING) + fi else ZSH_TERM_H= fi @@ -2251,11 +2305,11 @@ dnl We need to open it read/write, so make sure it is writeable. dnl Yet another test which won't work when cross-compiling. dnl --------------- AC_CACHE_CHECK(if your system has /dev/ptmx, -ac_cv_have_dev_ptmx, +zsh_cv_have_dev_ptmx, [if test -w /dev/ptmx; then - ac_cv_have_dev_ptmx=yes + zsh_cv_have_dev_ptmx=yes else - ac_cv_have_dev_ptmx=no + zsh_cv_have_dev_ptmx=no fi]) dnl -------- @@ -2270,18 +2324,18 @@ dnl these is by defining _GNU_SOURCE. dnl ------- AH_TEMPLATE([USE_DEV_PTMX], [Define to 1 if all the kit for using /dev/ptmx for ptys is available.]) -if test x$ac_cv_have_dev_ptmx = xyes -o x$ac_cv_func_posix_openpt = xyes && \ +if test x$zsh_cv_have_dev_ptmx = xyes -o x$ac_cv_func_posix_openpt = xyes && \ test x$ac_cv_func_grantpt = xyes && \ test x$ac_cv_func_unlockpt = xyes && \ test x$ac_cv_func_ptsname = xyes; then AC_CACHE_CHECK([if /dev/ptmx is usable], - ac_cv_use_dev_ptmx, + zsh_cv_use_dev_ptmx, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if defined(__linux) || defined(__CYGWIN__) #define _GNU_SOURCE 1 #endif #include <stdlib.h> -int ptsname();]], [[]])],[ac_cv_use_dev_ptmx=no],[ac_cv_use_dev_ptmx=yes])]) - if test x$ac_cv_use_dev_ptmx = xyes; then +int ptsname();]], [[]])],[zsh_cv_use_dev_ptmx=no],[zsh_cv_use_dev_ptmx=yes])]) + if test x$zsh_cv_use_dev_ptmx = xyes; then AC_DEFINE(USE_DEV_PTMX) fi fi @@ -2290,11 +2344,14 @@ dnl ----------------- dnl multibyte support dnl ----------------- AC_ARG_ENABLE(multibyte, -AS_HELP_STRING([--enable-multibyte],[support multibyte characters]), -[zsh_cv_c_unicode_support=$enableval], -[AC_CACHE_VAL(zsh_cv_c_unicode_support, - AC_MSG_NOTICE([checking for functions supporting multibyte characters]) - [zfuncs_absent= +AS_HELP_STRING([--enable-multibyte],[support multibyte characters])) + +if test "x$enable_multibyte" = xno; then + zsh_use_multibyte=no +else + AC_CACHE_VAL(zsh_cv_c_unicode_capable, + [AC_MSG_NOTICE([checking for functions supporting multibyte characters]) + zfuncs_absent= dnl dnl Note that iswblank is not included and checked separately. dnl As iswblank() was added to C long after the others, we still @@ -2310,14 +2367,21 @@ wmemcpy wmemmove wmemset; do done if test x"$zfuncs_absent" = x; then AC_MSG_NOTICE([all functions found, multibyte support enabled]) - zsh_cv_c_unicode_support=yes + zsh_cv_c_unicode_capable=yes + zsh_cv_c_unicode_missing= else # Warns at the end of configure AC_MSG_NOTICE([missing functions, multibyte support disabled]) - zsh_cv_c_unicode_support=no + zsh_cv_c_unicode_capable=no + zsh_cv_c_unicode_missing=$zfuncs_absent fi - ]) -]) + ]) + zsh_use_multibyte=$zsh_cv_c_unicode_capable + if test "x$enable_multibyte" = xyes && test "x$zsh_cv_c_unicode_capable" = xno; then + AC_MSG_ERROR([--enable-multibyte requested but required functions are missing:$zsh_cv_c_unicode_missing]) + fi +fi + AH_TEMPLATE([MULTIBYTE_SUPPORT], [Define to 1 if you want support for multibyte character sets.]) @@ -2335,7 +2399,7 @@ fi]) AH_TEMPLATE([BROKEN_ISPRINT], [Define to 1 if the isprint() function is broken under UTF-8 locale.]) -if test x$zsh_cv_c_unicode_support = xyes; then +if test x$zsh_use_multibyte = xyes; then AC_DEFINE(MULTIBYTE_SUPPORT) dnl Test if wcwidth() and/or iswprint() is broken for @@ -2689,11 +2753,15 @@ int main(int argc, char *argv[]) changequote([, ]) AC_CACHE_CHECK(if we can use -rdynamic, zsh_cv_rdynamic_available, -old_LDFLAGS="$LDFLAGS" +[old_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -rdynamic" -AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[zsh_cv_rdynamic_available=yes -EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-rdynamic}"],[zsh_cvs_rdynamic_available=no]) -LDFLAGS="$old_LDFLAGS") +AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [zsh_cv_rdynamic_available=yes], + [zsh_cv_rdynamic_available=no]) +LDFLAGS="$old_LDFLAGS"]) +if test x$zsh_cv_rdynamic_available = xyes; then + EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-rdynamic}" +fi AC_CACHE_CHECK(if your dlsym() needs a leading underscore, zsh_cv_func_dlsym_needs_underscore, [echo failed >conftestval && cat >conftest.c <<EOM @@ -2903,7 +2971,7 @@ dnl config.status, and only change when configure is rerun. dnl So we need to run the autoconf tests here and store the results. dnl We then generate config.modules, preserving any user-generated dnl information, from config.status. -for modfile in `cd ${srcdir}; echo */*.mdd */*/*.mdd`; do +for modfile in `cd ${srcdir}; echo Src/*.mdd Src/*/*.mdd`; do name= link= load= @@ -3051,7 +3119,13 @@ if test "x$dynamic" = xyes; then module linker flags : ${LDFLAGS} ${LIBLDFLAGS} ${DLLDFLAGS}" fi echo "\ -library flags : ${LIBS} +library flags : ${LIBS}" +if test x$enable_link_all_libs != xyes; then +echo "\ +gdbm module library flags : ${GDBM_LIBS} +pcre module library flags : ${PCRE_LIBS}" +fi +echo "\ installation basename : ${tzsh_name} binary install path : ${zshbin2} man page install path : ${zshman2} @@ -3065,14 +3139,14 @@ fi echo "See config.modules for installed modules and functions. " -if test x$zsh_cv_c_unicode_support != xyes; then - if test "x$zfuncs_absent" = x; then +if test x$zsh_use_multibyte != xyes; then + if test "x$enable_multibyte" = xno; then # The user opted out. AC_MSG_WARN([You have chosen to build without multibyte support.]) AC_MSG_WARN([This configuration may not be suitable for production use. It is known to cause errors in 'make test'. We strongly recommend to re-run configure with --enable-multibyte.]) else # Some requisite functions are missing. - AC_MSG_WARN([Multibyte support cannot be enabled: some standard library functions are missing: $zfuncs_absent]) + AC_MSG_WARN([Multibyte support cannot be enabled: some standard library functions are missing: $zsh_cv_c_unicode_missing]) AC_MSG_WARN([This configuration may not be suitable for production use. It is known to cause errors in 'make test'. If your system provides those functions, we recommend to re-run configure appropriately.]) # If your system doesn't have those functions, consider patching the # test suite and sending the patch to zsh-workers@ for inclusion. |
