diff options
202 files changed, 9308 insertions, 3495 deletions
@@ -1,3 +1,682 @@ +2018-08-25 Daniel Shahaf <d.s@daniel.shahaf.name> + + * unposted: Etc/FAQ.yo: Fix FAQ build, broken by 43184. + + * unposted: Config/version.mk, NEWS, README: Test release: + 5.5.1-test-1. + + * 43331: Completion/Unix/Command/_diff3: Enhance positional + argument descriptions (thanks, Oliver). + +2018-08-24 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 43313 (log message tweaked): + Functions/VCS_Info/Backends/VCS_INFO_get_data_git: vcs_info git: + For the branch name, try to find a symbolic name before falling + back to a raw commit hash. + + * 43314: Functions/VCS_Info/Backends/VCS_INFO_get_data_git: + vcs_info git: Flatten a nested if. + +2018-08-24 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 43330: Completion/BSD/Command/_cu: complete more options + + * 43329: Completion/Unix/Command/_diff3: new diff3 completion + + * 43328: Completion/X/Command/_zeal: new completion + +2018-08-23 dana <dana@dana.is> + + * unposted: Completion/Unix/Command/_man: Fix --ascii typo + +2018-08-23 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 43325: Anton Shestakov: Completion/Unix/Command/_hg: + suggest merge tools for -t/--tool + + * 43326: Anton Shestakov: Completion/Unix/Command/_hg: + add completion of -S/--subrepos to many commands + + * github #27: Klas Mellbourn: Completion/X/Command/_code: + add --folder-uri to completion for Visual Studio Code + + * 43301 (based on work by Julien Nicoulaud): + Completion/Debian/Command/_debuild, Completion/Unix/Command/_ack, + Completion/Unix/Command/_scons, Completion/Unix/Command/_vpnc, + Completion/X/Command/_geany: functions from zsh-completions project + +2018-08-21 Daniel Shahaf <d.s@daniel.shahaf.name> + + * unposted: Doc/Zsh/compsys.yo: docs: Fix duplicated words + in _combination. + +2018-08-16 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * 43294: Doc/Zsh/zle.yo, Src/Zle/zle_main.c, + Src/Zle/zle_params.c: Add ZLE_RECURSIVE parameter. + +2018-08-15 dana <dana@dana.is> + + * 43302: Completion/Unix/Command/_du: Change -B to -B+ + +2018-08-13 Daniel Shahaf <d.s@daniel.shahaf.name> + + * unposted: Completion/Unix/Command/_make: Allow pasted arguments + for GNU make's -j option. + +2018-08-13 Peter Stephenson <p.stephenson@samsung.com> + + * dana: 43275: Doc/Zsh/mod_mathfunc.yo, Src/Modules/mathfunc.c, + Test/V03mathfunc.ztst, configure.ac: Add log2 to mathfunc. + +2018-08-12 Marc Cornellà <marc.cornella@live.com> + + * unposted (PR #26): Completion/Unix/Command/_git: __git_files: + fix double quotation of star + +2018-08-09 Peter Stephenson <p.stephenson@samsung.com> + + * 43264: Src/params.c, Test/D04parameter.ztst: + ${+assoc[nonexistent]} returned 1 with KSH_ARRAYS. + +2018-08-08 Peter Stephenson <p.stephenson@samsung.com> + + * 43261: Src/math.c, Test/C01arith.ztst: Apply unary minus to + entire lexical constant, so base doesn't get treated as negative. + +2018-08-07 Peter Stephenson <p.stephenson@samsung.com> + + * Anton Shestakov: 43254: Completion/Unix/Command/_hg: Remove hg + -w and add hg -S. + + * Anton Shestakov: 43252: Completion/Unix/Command/_hg: fix up + various hg options for completion. + + * Anton Shestakov: 43250: Completion/Unix/Command/_hg: Add hg + forget, phase, summary completions. + + * Anton Shestakov: 43251: Completion/Unix/Command/_hg: fix + return value of some hg completion functions. + + * Anton Shestakov: 43253: Completion/Unix/Command/_hg: hg + --style is deprecated, use --template. + +2018-08-01 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43227: Src/Modules/termcap.c, Src/Modules/terminfo.c, + Src/utils.c: fix memory leaks not fixed in 43219 + +2018-07-31 dana <dana@dana.is> + + * 43207 (tweaked): Completion/Unix/Type/_bind_addresses, + Completion/Unix/Command/_php: Add options to control _bind_addresses + behaviour, improve PHP completion + +2018-07-31 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43219 (except term{cap,info}.c): Src/Modules/db_gdbm.c, + Src/Modules/pcre.c, Src/Zle/compcore.c, Src/init.c, Src/math.c, + Src/subst.c: fix several memory leaks + +2018-07-30 Peter Stephenson <p.stephenson@samsung.com> + + * 43225: Src/Zle/zle_main.c: recalculate timeout after calling + handler within ZLE raw read. + +2018-07-29 Matthew Martin <phy1729@gmail.com> + + * 43185: Completion/Zsh/Type/_command_names: Use [ suffix for + associative arrays. Add + to remove-chars from Oliver. + + * 43184: Etc/FAQ.yo: Remove reference to ftp_sites.yo. + +2018-07-25 dana <dana@dana.is> + + * 43203: Completion/Unix/Command/_lua: Add completion for lua + + * Simon Ruderich: 43200: Completion/Linux/Command/_iptables: Add + completion for ip6tables* + +2018-07-20 dana <dana@dana.is> + + * 43196: Completion/Unix/Command/_nginx: Add completion for nginx + +2018-07-20 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43192: Completion/Unix/Command/_pgrep: simplify the completions + of comma-separated list of IDs. + +2018-07-19 dana <dana@dana.is> + + * 43186 (tweaked): Completion/Unix/Command/_crontab: Add completion + for cronie/dcron/Vixie crontab + +2018-07-19 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43189: Completion/Unix/Command/_install: similar fix as 43187 + for option -f (_flags was renamed to _file_flags) + + * 43183: Completion/Unix/Type/_ttys, Completion/Unix/Command/_gdb, + Completion/Unix/Command/_pgrep: fix '_ttys -o' on Linux, and use + it in _gdb and _pgrep. + +2018-07-19 Yasuhiro KIMURA <yasu@utahime.org> + + * 43187: Completion/Unix/Command/_install: Fix completion error + about 'm' option of 'install' command + +2018-07-17 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * Doron Behar: 43166: Completion/Unix/Type/_pspdf, + Completion/X/Command/_zathura: new zathura completion. + +2018-07-18 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43177: Completion/Unix/Command/_grep: support bzgrep, and add + a few options for macOS. + + * 43182: Completion/Unix/Command/_lldb: complete process name + after option -n/--attach-name + +2018-07-17 Peter Stephenson <p.stephenson@samsung.com> + + * unposted: Doc/Makefile.in: remove ftp_sites.yo. + + * Matthew Martin: 43179: Doc/Zsh/contrib.yo, + Doc/Zsh/ftp_sites.yo, Doc/Zsh/metafaq.yo: update distro docs to + remove dead links. + + * 43176: Doc/Zsh/intro.yo: note right at start of manual that + default mode is not POSIX. + +2018-07-16 Peter Stephenson <p.stephenson@samsung.com> + + * Tim Smith: 43172: Doc/Zsh/mod_zutil.yo: document escaping of + colon in zformat -a. + +2018-07-11 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43164: Completion/Unix/Command/_gcc: fix 'args=' to 'args+=', + and update a few options. + +2018-07-10 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43155: Completion/Unix/Command/_gcc: escape : in action for -std + +2018-07-10 Peter Stephenson <p.stephenson@samsung.com> + + * 43156, 43157: Src/exec.c: need to allow for possible + update of pointer by two in gethere(). + +2018-07-09 Peter Stephenson <p.stephenson@samsung.com> + + * users/23531: Src/exec.c, Test/C03traps.ztst: Fix error + exit/return from within shell construct inside nested function, + and in left hand side of pipe (regression due to broken tests); + stop tests from exiting too early and add new test for first fix. + +2018-07-07 Matthew Martin <phy1729@gmail.com> + + * 43106: Completion/BSD/Command/_ldap: Add ldap completer. + + * 43046: Completion/Unix/Type/_pdf, Completion/X/Command/_mupdf: + Add mupdf completer. + + * 42995: David Klann: Completion/Linux/Command/_networkmanager: + Only complete active connections for nmcli connection down. + +2018-07-03 dana <dana@dana.is> + + * 43105 (tweaked): Completion/Unix/Command/_pgrep: Add full procps + support, other improvements + +2018-07-03 Peter Stephenson <p.stephenson@samsung.com> + + * dana: 43134: Completion/Unix/Type/_signals: don't complete SIG + in front of numeric signals. + +2018-07-02 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43108, 43121: Completion/Unix/Command/_killall: complete + various options + +2018-07-01 Doron Behar <doron.behar@gmail.com> + + * 43059: Completion/Unix/Command/_gpg: Use explicit UIDs for + state = public keys. + +2018-07-01 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43107: Completion/Unix/Type/_ttys, Completion/Unix/Command/_ps, + Completion/BSD/Command/_watch-snoop: add an option to _ttys to + complete only open ttys, and use it in _ps and _watch-snoop. + +2018-06-29 Peter Stephenson <p.stephenson@samsung.com> + + * users/23519: README, Completion/Unix/Type/_remote_files: Use tag + remote-files instead of files for remote files. + +2018-06-27 Daniel Hahler <zsh@thequod.de> + + * 42746: Completion/Unix/Command/_vim: _vim: handle special values for + -u/-U. + +2018-06-27 Eric Cook <llua@gmx.com> + + * 43096: Eitan: Completion/Unix/Command/_vim, remove duplicate flag + +2018-06-25 Daniel Shahaf <d.s@daniel.shahaf.name> + + * 43091: Src/glob.c: In the (u) glob qualifier, expand and + correct "unknown user" error messages. + +2018-06-25 Peter Stephenson <p.stephenson@samsung.com> + + * 43084: Doc/Zsh/zle.yo, Functions/Chpwd/zsh_directory_name_cdr, + Src/Zle/zle_main.c: vared -g suppresses variable creation and + override warnings; also suppress in function. + +2018-06-25 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 43079, 43086: Completion/Unix/Type/_process_names, + Completion/Unix/Command/_dtruss, Completion/Darwin/Command/_fs_usage, + Completion/Darwin/Command/_sc_usage: new utility to complete names + of running processes, and three new completion functions which use it. + + * 43080: Completion/Unix/Type/_sys_calls: analyze recent syscall.h + properly + +2018-06-24 dana <dana@dana.is> + + * unposted: Completion/Linux/Command/_opkg: Fix mistyped variable + name + +2018-06-23 dana <dana@dana.is> + + * 43081: Completion/Darwin/Command/_networksetup: Add networksetup + completion + + * 43088: Completion/Debian/Command/_wajig: Fix sub-command completion + +2018-06-18 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 43074: Eitan: Completion/Unix/Command/_gcc: Completion for + additional linker options for clang and sanitizers for gcc + + * 43078: Completion/Unix/Command/_sed: add completion for the + sed expression + + * 43073: Completion/Linux/Command/_cryptsetup, + Completion/Linux/Command/_sysstat, Completion/Linux/Command/_ss, + Completion/Linux/Command/_kpartx, Completion/Linux/Command/_tune2fs, + Completion/Unix/Command/_ansible, Completion/Unix/Command/_git, + Completion/Unix/Command/_lynx, Completion/Unix/Command/_mpc, + Completion/Unix/Command/_readelf, Completion/Unix/Command/_sqlite, + Completion/Unix/Command/_subversion, Completion/Unix/Command/_tmux, + Completion/Unix/Command/_user_admin, Completion/Unix/Command/_wget, + Completion/Unix/Command/_xxd, Completion/X/Command/_qiv, + Completion/Zsh/Command/_which, Completion/Zsh/Command/_zed: + various completion option updates + +2018-06-20 Peter Stephenson <p.stephenson@samsung.com> + + * 43077: Src/builtin.c: failure of math evaluation didn't + propagate to status of shift builtin. + +2018-06-20 dana <dana@dana.is> + + * 43075 (based on 24059): Doc/Zsh/mod_stat.yo, Doc/Zsh/prompt.yo, + Src/Modules/datetime.c, Src/Modules/stat.c, Src/compat.c, + Src/prompt.c, Src/utils.c, Src/zsh_system.h, Test/D01prompt.ztst, + configure.ac: Support nanosecond precision in zsh/stat file times + and time formats generally (%9./%N) + + * 43061: Completion/Darwin/Command/_open, + Completion/Unix/Command/_webbrowser: Improve open completion, adjust + _webbrowser wording + + * 43060: Completion/Unix/Command/_stat, + Completion/Zsh/Command/_stat: Expand stat completion + +2018-06-18 dana <dana@dana.is> + + * 43047: Completion/Unix/Command/_hostname: Add hostname completion + + * 43047: Completion/Unix/Type/_bind_addresses: Always return local IPs + +2018-06-18 Peter Stephenson <p.stephenson@samsung.com> + + * unposted: Test/V01zmodload.ztst: updated for 43039. + + * Eitan: 43029: Src/Modules/zftp.c, Src/signals.c, Src/signals.h, + configure.ac: remove test for signal handler return type as no + longer needed. + +2018-06-18 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 43006: Tim Smith: Completion/Unix/Command/_git: complete + modified files after `git stash --` + + * users/23484: Completion/Unix/Command/_git: be consistent on + matcher specs for branches to fix issue with partial matching + + * 43048: Eitan: Completion/Unix/Command/_gcc: add sanitizers, + standards aliases and fix -flto + +2018-06-17 dana <dana@dana.is> + + * 43043: Completion/Unix/Command/_comm, + Completion/Unix/Command/_sed: Improve comm/sed completion + + * 43039: Src/Modules/parameter.mdd: Mark functions_source (et al.) + for auto-loading + +2018-06-16 dana <dana@dana.is> + + * 43030: Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr, + Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs, + Functions/VCS_Info/Backends/VCS_INFO_get_data_svn, + Functions/VCS_Info/Backends/VCS_INFO_get_data_tla, + Functions/VCS_Info/VCS_INFO_bydir_detect, + Functions/VCS_Info/VCS_INFO_realpath, + Functions/VCS_Info/vcs_info: Replace VCS_INFO_realpath() by :P + + * 43031: Etc/completion-style-guide: Add note about quoting/escaping + (cf. 42992) + + * 43031: Etc/completion-style-guide: Add note about optional/variant + syntax (cf. 43025) + +2018-06-15 dana <dana@dana.is> + + * 43024: Completion/Unix/Command/_man: Improve section-name matching + +2018-06-15 Matthew Martin <phy1729@gmail.com> + + * 42981: Completion/Unix/Command/_ed: Add ed completer + +2018-06-15 Peter Stephenson <p.stephenson@samsung.com> + + * users/23472: Doc/Zsh/mod_system.yo, Src/Modules/system.c, + Src/exec.c, Src/zsh.h: Add $sysparams[procsubstpid]. + + * 43008: Src/options.c: combine suggestion from Sebastian to + silence warnings for double setgid/setuid with suggestion + from Eitan to put setgid first. + +2018-06-13 dana <dana@dana.is> + + * 42992: Completion/Unix/Command/_bash: Fix minor escaping bug + + * 42992: Completion/Darwin/Command/_nvram, + Completion/Darwin/Command/_osascript, Completion/Darwin/Command/_say, + Completion/Darwin/Command/_scselect: Use _call_program to fetch + argument possibilities + +2018-06-12 dana <dana@dana.is> + + * unposted: Completion/Darwin/Type/_mac_applications: Change + 'Mac OS X' to 'macOS' + +2018-06-11 dana <dana@dana.is> + + * 42983: Completion/Unix/Command/_man: Address misc. feedback + + * 42984: Completion/Unix/Type/_files, + Completion/Unix/Type/_object_files: Fix argument pass-through to + compadd + +2018-06-10 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 42978: dana: Completion/Darwin/Command/_pbcopy: fix small bug + + * 42977: dana: Completion/Unix/Command/_man: Complete options to + major man variants, otherwise improve especially section matching + +2018-06-09 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 42968: Eitan Adler: Completion/Unix/Command/_shutdown: + add "-c" for _shutdown completion on FreeBSD 12-current + + * 42965: dana: Completion/Unix/Command/_bash, + Completion/Unix/Command/_sh: add full completion for bash + + * 42964: Eitan Adler: Completion/BSD/Type/_fbsd_architectures: + Update list of fbsd architectures + + * 42918: dana: Completion/Unix/Command/_jq: fix file completion + + * 42918: dana: Completion/Unix/Command/_ldd: adapt detection of + GNU variant to work on Ubuntu + +2018-06-07 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 42947: Doron Behar: Completion/Unix/Command/_luarocks: + new luarocks completion + + * 42948: dana: Completion/Linux/Command/_opkg: new opkg completion + + * 42931: dana: Completion/Unix/Command/_base64, + Completion/Unix/Command/_chroot, Completion/Unix/Command/_cksum, + Completion/Unix/Command/_lz4, Completion/Unix/Command/_md5sum, + Completion/Unix/Command/_tee, Completion/Unix/Command/_shasum, + Completion/Unix/Command/_readlink: completion for several + utilities especially for checksums across a variety of systems + + * users/23434: Functions/Misc/zed: initialise UNDO_LIMIT_NO so + that an initial undo doesn't clear the whole edit buffer + + * 42935: Eitan Adler: Completion/Unix/Command/_arp: + FreeBSD does not support -v for arp + + * 42937: Eitan Adler: Completion/BSD/Command/_powerd: add -M/-m + + * 43943: Completion/Unix/Command/_samba: update with long options + +2018-06-06 Peter Stephenson <p.stephenson@samsung.com> + + * Eitan: 42938: Src/Modules/mathfunc.c: name argument to + math_func is not unused. + + * Eitan: 42939: Src/Zle/zle_params.c: pm argument to + set_registers is not unused. + +2018-06-05 Peter Stephenson <p.stephenson@samsung.com> + + * Sebastian: 42929 (twaked): Functions/Misc/zed: additional + default bindings for emacs and vi modes. + +2018-06-03 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 42826: Eitan Adler: Misc/bash2zshprompt: remove link to + now-spam website + + * 42919: dana: Completion/Unix/Command/_uptime, + Completion/Unix/Command/_shuf: new shuf and uptime completions + + * 42922: dana: Completion/Unix/Command/_tac: new tac completion + + * 42881: Completion/Unix/Command/_ghostscript: update options in + ghostscript completion and query more matches directly from it + + * 42920: Completion/Linux/Command/_dkms: new dkms completion + +2018-06-01 Peter Stephenson <p.stephenson@samsung.com> + + * 42888: MACHINES: remove outdated issues and update general + description. + +2018-05-31 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 42870: Src/Zle/compcore.c: another improvement of 'compset -q' + +2018-05-29 Peter Stephenson <p.stephenson@samsung.com> + + * c.f. 42865: config.guess, config.sub: update from GNU + distribution. + + * Eitan Adler: 42862: configure.ac: AC_PROG_TRADITIONAL is no + longer needed. + + * Eitan Adler: 42863: configure.ac: autoconf update to latest + conventions. + +2018-05-25 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp> + + * 42809: Src/Zle/compcore.c: slightly improve 'compset -q' + +2018-05-19 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 42806: Completion/Unix/Command/_shutdown: fix where options + were lost due to args= assignment where args+= was needed + + * 42803: Completion/Unix/Command/_netstat: handle Linux and + the the BSDs in netstat completion + +2018-05-17 Oliver Kiddle <okiddle@yahoo.co.uk> + + * Stephane: 42790: Doc/Zsh/expn.yo, NEWS, Src/pattern.c, + configure.ac: make [[:blank:]] match non-ASCII blanks + + * 42784: Completion/Zsh/Command/_typeset: complete -s and -x + options to the functions builtin + +2018-05-17 Peter Stephenson <p.stephenson@samsung.com> + + * 42793: Src/jobs.c, Src/zsh.h: Always define FDT_PROC_SUBST to + avoid proliferating #ifdef's. + + * 42785: Src/builtins.c: redefining a user math function should + silently work as with redefining other shell objects. + +2018-05-14 Peter Stephenson <p.stephenson@samsung.com> + + * 42297: dana: Src/params.c, Test/D06subscript.ztst: (e) + subscript needs extra work with scalars. + + * 42234: Stephane: Src/signals.c: don't kill a process that's + already exited when killing a job. + +2018-05-13 Oliver Kiddle <okiddle@yahoo.co.uk> + + * 42488: Src/Modules/mathfunc.c, Src/builtin.c, Src/math.c, + Test/B03print.ztst, Test/C01arith.ztst, Test/V03mathfunc.ztst: + test cases for 42369 and address some issues in the code + + * Nelson H. F. Beebe: 19597 (rebased 42369): Src/math.c, + Src/params.c. Src/Modules/mathfunc.c, configure.ac: + return Inf, NaN etc from floating point operations instead + of errors to allow non-stop IEEE 754 arithmetic + + * 42760: Src/Zle/zle_thingy.c: move stack variable outside + while loop scope as it is accessed in the while condition + +2018-05-11 Peter Stephenson <p.stephenson@samsung.com> + + * 42180: dana: Src/Zle/compcore.c: safety when removing + separators in completion. + + * 42101 (tweaked): dana: Src/exec.c, Test/A06assign.ztst: + assigning shell status to array was broken. + +2018-05-08 Peter Stephenson <p.stephenson@samsung.com> + + * 42752: Completion/Unx/Command/_git: better completion + handling for git aliases expanding to external command. + + * 42751: Src/Zle/zle_main.c: Protect shell status around + time function execution in line editor. + +2018-05-02 Oliver Kiddle <okiddle@yahoo.co.uk> + + * Eitan Adler: 42740: Completion/BSD/Command/_systat: + Teach _systat about the 'zarc' screen + + * Eitan Adler: 42732: Completion/Unix/Command/_ifconfig: + Add several more entries to ifconfig + + * 42743: Completion/Unix/Command/_vorbis: update vorbis-tools + completion and include vorbiscomment with the rest + +2018-05-01 Peter Stephenson <p.stephenson@samsung.com> + + * from branch fork_early, c.f. 42702: Src/exec.c: Various changes + to make forking for a command work better. Move the fork even + earlier; add case of non-final pipeline elements; _exit when + forked; remove previous early fork in caller; replace fix for + leaked file descriptor in pipeline handling. + +2018-04-29 Oliver Kiddle <okiddle@yahoo.co.uk> + + * Matthew Martin: 42730: Completion/Unix/Command/_rmdir, + Completion/Unix/Type/_directories: Complete the options for rmdir + + * Matthew Martin: 42729: Completion/Unix/Command/_df: + update df completion for [DFNO]BSD + + * 42676: Completion/Unix/Command/_dd: deal with system + specific arguments + + * 42728: Completion/Unix/Command/_tiff: update options and + add handling for tiff2pdf + +2018-04-29 Barton E. Schaefer <schaefer@zsh.org> + + * Ricardo Giorni: 42701: fix 42355 for multiple backslashes + +2018-04-26 Peter Stephenson <p.stephenson@samsung.com> + + * c.f. 42726: Test/W02jobs.ztst: Back off fg and bg tests as they + are currently too hard to make robust. + +2018-04-25 Daniel Shahaf <d.s@daniel.shahaf.name> + + * unposted: Src/exec.c: Correct process substitution buffer + size in the PATH_DEV_FD codepath. + +2018-04-25 Peter Stephenson <p.stephenson@samsung.com> + + * 42722: Test/ztst.zsh, Test/W02jobs.ztst: replace ed with + dc and hope for better times. + + * 42714: Test/W02jobs.ztst, Test/ztst.zsh: add basic fg and bg + tests using ed. Improve output on pattern difference failure in + tests. + +2018-04-24 Peter Stephenson <p.stephenson@samsung.com> + + * 42708: Src/exec.c, Src/Modules/clone.c, Src/Modules/zpty.c, + Test/D03procsubst.ztst: don't close file descriptors for + process substitution on closem() tidy up unless we are exiting + as they need to be visible to external processes. + +2018-04-23 Peter Stephenson <p.stephenson@samsung.com> + + * 42705: Src/signals.c: another fix for 42630 --- also check + that killpg(pgrp, 0) is -1. + + * 23362: Src/parse.c: Allow short loops with "while". + +2018-04-20 Peter Stephenson <p.stephenson@samsung.com> + + * 42684 (with extra comments): Src/exec.c: Fork earlier + when executing command if run in background. + +2018-04-19 Peter Stephenson <p.stephenson@samsung.com> + + * 42686: Src/signals.c: Fix 42630 only to change process groups + on exited process. + +2018-04-17 Peter Stephenson <p.stephenson@samsung.com> + + * 42630: Src/exec.c, Src/signals.c: Improve process group + handling in pipelines. Main shell will reclaim terminal if + leader exits. Allow SIGCHLD to interrupt reading data from + command substitution. + + * unposted: Config/version.mk: update to 5.5.1-dev-0. + 2018-04-16 Peter Stephenson <p.w.stephenson@ntlworld.com> * unposted: NEWS, README, Config/version.mk, Etc/FAQ.yo: update diff --git a/Completion/BSD/Command/_cksum b/Completion/BSD/Command/_cksum deleted file mode 100644 index 4f5b68d8a..000000000 --- a/Completion/BSD/Command/_cksum +++ /dev/null @@ -1,67 +0,0 @@ -#compdef cksum sum=cksum md2 md4 md5 rmd160 sha1 sha256 sha384 sha512 sha512t256 - -if [[ $OSTYPE == (dragonfly|freebsd)* && service == cksum ]]; then - _arguments -s -S -A '-*' \ - '-o[use specified historic algorithm]:historic algorithm:(1 2 3)' \ - '*:_files' - -else - local -a args - - case $OSTYPE in - dragonfly*|freebsd*|netbsd*) - args+=( - '-t[run built-in time trial]' - ) - ;| - dragonfly*|freebsd*|openbsd*) - args+=( - '-r[reverse the output format]' - ) - ;| - dragonfly*) - args+=( - '-b+[begin at specified offset]:begin offset: ' - '-e+[end at specified offset]:end offset: ' - ) - ;; - freebsd*) - args+=( - '-c+[compare digest against specified string]:digest string: ' - ) - ;; - netbsd*) - args+=( - '(*)-c+[compare checksums against specifed sumfile]:sumfile:_files' - '-n[reverse the output format]' - '-w[warn on malformed checksum files]' - ) - if [[ $service == cksum ]]; then - args=( - '(-o)-a+[use the specfied algorithm(s)]:algorithm:(crc md2 md4 md5 old1 old2 rmd160 sha1 sha256 sha384 sha512)' - '(-a)-o+[use the specfied historic algorithm]:historic algorithm:(1 2)' - ) - fi - ;; - openbsd*) - args+=( - '-b[output in base 64]' - '-C+[compare checksums against specifed checklist]:checklist:_files' - '-c[file arguments are checklists]' - '-h+[output to specified hashfile]:hashfile:_files' - '*-t[run built-in time trial]' - ) - if [[ $service == cksum ]]; then - args+=('*-a+[use the specfied algorithm(s)]:algorithm:_values -s , algotithm cksum md5 rmd160 sha1 sha224 sha256 sha384 sha512/256 sha512') - fi - ;; - esac - - _arguments -s -S -A '-*' \ - $args \ - '-p[echo stdin to stdout]' \ - '-q[quiet mode]' \ - '-s+[checksum specified string]:string: ' \ - '-x[run built-in test]' \ - '*:_files' -fi diff --git a/Completion/BSD/Command/_cu b/Completion/BSD/Command/_cu index 90447c0af..1fe08601f 100644 --- a/Completion/BSD/Command/_cu +++ b/Completion/BSD/Command/_cu @@ -1,26 +1,67 @@ #compdef cu -local args +local variant ign +local -a args -case $OSTYPE in +_pick_variant -r variant taylor='Taylor UUCP' $OSTYPE --version + +case $variant in openbsd*) args+=( "-d[don't block waiting for a carrier to be detected]" '-r[start cu in restricted mode - prevent local operations]' ) ;; + taylor|(net|free)bsd*) + args+=( + '(-o -P --parity)-e[use even parity]' + '(-e -P --parity)-o[use odd parity]' + ) + ;| (net|free)bsd*) + args+=( '-t[connect via a hard-wired connection to a host on a dial-up line]' ) + ;| + taylor|netbsd*) + (( $#words > 2 )) && ign='!' + args+=( + "${ign}--help[display usage information]" + '(-s)--speed=[set line speed for the connection]:line speed [9600]:_baudrates' + '(-e -o -P)--parity=[set parity]:parity [none]:(even odd none)' + '(-h --halfduplex)'{-h,--halfduplex}'[echo characters locally]' + '--nostop[turn off XON/XOFF handling]' + '(-E --escape)'{-E+,--escape=}'[specify escape character]:escape character [~]' + '(-a -p --port)'{-a+,-p+,--port=}'[specify the port]:port' + '(-c --phone -n --prompt)'{-c+,--phone=}'[specify phone number to call]:phone number' + '(1 -l -z --system)--line=[specify line to use]:line:(/dev/(cuaU#<->|ttyS<->|tty.*)(N%c))' + ) + ;| + taylor) args+=( + "${ign}(-v --version)"{-v,--version}"[display version information]" + '(-n --prompt -c --phone)'{-n,--prompt}'[prompt for the phone number to use]' + '(-x --debug)-d[enter debugging mode]' + '(-d -x --debug)'{-x+,--debug=}'[turn on particular debugging types]:debug type:_sequence compadd - all abnormal chat handshake port config incoming outgoing' + '(-I --config)'{-I+,--config=}'[specify configuration file]:configuration file:_files' + '(1 -z --system)'{-z+,--system=}'[specify system to call]:system' + ) + ;; + netbsd*) + args+=( + '(-E --escape)-n+[disable escape character processing]' + '(-f -F --flow)'{-F+,--flow=}'[set flow control]:flow control:(hard soft none)' + '(-F --flow)-f[use no flow control]' + '(-e -o --parity)-P+[set parity]:parity [none]:(even odd none)' + ) + ;; + freebsd*) + args=( -A "-*" $args '-a[set the acu port]:acu' - '(-o)-e[use even parity]' '-h[echo characters locally]' - '(-e)-o[use odd parity]' - '-t[connect via a hard-wired connection to a host on a dial-up line]' ) ;; esac -_arguments -s -A '-*' $args \ - '-l[line to use]:line:(/dev/(cuaU#<->|ttyS<->)(N%c))' \ - '-s[line speed]:line speed:_baudrates' \ - '(-*)1:host:' +_arguments -s $args \ + '(--speed)-s+[set line speed for the connection]:line speed [9600]:_baudrates' \ + '(1 --line -z --system)-l+[specify line to use]:line:(/dev/(cuaU#<->|ttyS<->|tty.*)(N%c))' \ + '1: :_guard "^-*" system' diff --git a/Completion/BSD/Command/_ldap b/Completion/BSD/Command/_ldap new file mode 100644 index 000000000..8fa17e2f8 --- /dev/null +++ b/Completion/BSD/Command/_ldap @@ -0,0 +1,87 @@ +#compdef ldap + +local -a commands scopes +commands=( + search:'search a directory' +) +scopes=( + base:'base object only' + one:'one level' + sub:subtree +) + +_ldap_url() { + local nm=$compstate[nmatches] + local -a expl protocols suf_proto suf_scope tags + protocols=( + ldap:'TCP in plaintext' + ldaps:'TLS' + ldap+tls:'TCP and use StartTLS' + ldapi:'connect to a socket' + ) + + # [protocol://]host[:port][/basedn[?[attribute,...][?[scope][?[filter]]]]] + if ! compset -P '*://'; then + tags=(protocol) + compset -S ':*' || suf_proto=( -S :// ) + fi + + if ! compset -P '*/'; then + if compset -P '*:'; then + tags=(port) + compset -S '/*' + else + if ! compset -S '://*'; then + tags+=(host) + compset -S '[:/]*' + fi + fi + else + case $PREFIX in + *\?*\?*\?*) tags=(filter);; + *\?*\?*) tags=(scope); [[ -suffix \?* ]] || suf_scope=( -qS \? );; + *\?*) tags=(attribute);; + *) tags=(basedn);; + esac + compset -P '*\?' + compset -S '\?*' + fi + + _tags $tags + while _tags; do + _requested protocol && _describe -t protocol protocol protocols $suf_proto + _requested host && _hosts -S '' + _requested port expl port + _requested basedn expl 'base DN' + _requested attribute expl attribute + _requested scope && _describe -t scope scope scopes $suf_scope + _requested filter expl filter + [[ nm -ne compstate[nmatches] ]] && return 0 + done +} + +if (( CURRENT == 2 )); then + _describe command commands +else + shift words; (( CURRENT-- )) + case $words[1] in + search) + _arguments -s -S -A '-*' \ + '-b+[specify base DN]:base DN:' \ + '-c+[specify CA file]:CA file:' \ + '-D+[specify bind DN]:bind DN:' \ + '-H+[specify URL]: :_ldap_url' \ + '-L[output in LDIF]' \ + '-l+[specify time limit or 0 for no limit]:time limit [0]:' \ + '-s+[specify scope]:scope [sub]:(($scopes))' \ + '-v[be verbose]' \ + '-W[prompt for bind secret]' \ + '-w+[specify bind secret]:bind secret:' \ + '-x[use simple authentication]' \ + '-Z[use StartTLS]' \ + '-z+[specify maximum number of results or 0 for no limit]:size limit [0]:' \ + '::filter:' \ + '*:attribute:' + ;; + esac +fi diff --git a/Completion/BSD/Command/_powerd b/Completion/BSD/Command/_powerd index 18a9fb437..05c03ab15 100644 --- a/Completion/BSD/Command/_powerd +++ b/Completion/BSD/Command/_powerd @@ -6,6 +6,8 @@ _arguments -s \ "-a[mode to use while on AC power]:mode:($powerd_mode)" \ "-b[mode to use while on battery power]:mode:($powerd_mode)" \ '-i[CPU idle percent level when begin to degrade performance]:percent:' \ + '-m[minimum frequency to throttle down to]:frequency (MHz)' \ + '-M[maximum frequency to throttle up to]:frequency (MHz)' \ "-n[mode to use normally when the AC line state is unknown]:mode:($powerd_mode)" \ '-p[polling interval (in milliseconds) for AC line state and system idle levels]:interval:' \ '-P[alternative pidfile]:pidfile:_files' \ diff --git a/Completion/BSD/Command/_systat b/Completion/BSD/Command/_systat index 35b842188..73533e864 100644 --- a/Completion/BSD/Command/_systat +++ b/Completion/BSD/Command/_systat @@ -16,6 +16,7 @@ case $OSTYPE in 'vmstat:virtual memory statistics' 'netstat:network connection statistics' 'ifstat:network traffic statistics' + 'zarc:display arc cache usage' ) ;; openbsd*) diff --git a/Completion/BSD/Command/_watch-snoop b/Completion/BSD/Command/_watch-snoop index 182b6bb34..1a4af07cc 100644 --- a/Completion/BSD/Command/_watch-snoop +++ b/Completion/BSD/Command/_watch-snoop @@ -10,4 +10,4 @@ _arguments -w -S -s : \ "-o[reconnect on overflow]" \ "-t[print date and time at start]" \ "-W[allow write access to observed tty]" \ - ":tty device:_ttys -D" + "(-): : _ttys -Do" diff --git a/Completion/BSD/Type/_fbsd_architectures b/Completion/BSD/Type/_fbsd_architectures index 24bdf4620..011d0b466 100644 --- a/Completion/BSD/Type/_fbsd_architectures +++ b/Completion/BSD/Type/_fbsd_architectures @@ -3,4 +3,4 @@ local expl _description architectures expl 'architecture' -compadd "$@" "$expl[@]" amd64 arm arm64 i386 mips ppc sparc xbox +compadd "$@" "$expl[@]" amd64 arm arm64 i386 mips powerpc riscv sparc64 diff --git a/Completion/Darwin/Command/_fs_usage b/Completion/Darwin/Command/_fs_usage new file mode 100644 index 000000000..956816169 --- /dev/null +++ b/Completion/Darwin/Command/_fs_usage @@ -0,0 +1,28 @@ +#compdef fs_usage + +local curcontext="$curcontext" state state_descr line ret=1 +typeset -A opt_args + +_arguments -s -C -A '-*' : \ + '-e[exclude fs_usage and the specified processes from sampling]' \ + '-w[use wider output]' \ + '*-f+[specify output filtering mode]:mode:(nework filesys pathname exec diskio cachehit)' \ + '-b[annotate disk I/O events with BootCache info]' \ + '(-R -S -E)-t+[specify run timeout]:seconds' \ + '(-t)-R+[specify raw trace file to process]:raw trace file:_files' \ + '(-t)-S+[specify time to begin processing the trace file]:seconds' \ + '(-t)-E+[specify time to stop processing the trace file]:seconds' \ + '*: :->pid-or-pname' && ret=0 + +case $state in + (pid-or-pname) + if [[ -z $opt_args[-R] ]]; then + _alternative "processes:: _pids" \ + "processes-names:: _process_names -a" && ret=0 + else + _message 'pid or process name in the trace file' && ret=0 + fi + ;; +esac + +return ret diff --git a/Completion/Darwin/Command/_networksetup b/Completion/Darwin/Command/_networksetup new file mode 100644 index 000000000..85a91e893 --- /dev/null +++ b/Completion/Darwin/Command/_networksetup @@ -0,0 +1,320 @@ +#compdef networksetup + +# Notes: +# - Inconsistent option capitalisation is intentional; see networksetup(1) +# - Options related to user/log-in/system profiles are omitted, since they no +# longer function (despite appearing in the manual) +# - Each d/p/s could list associated d/p/s in the descriptions +# - Options that take multiple devices/services (e.g. -createBond) could exclude +# those previously specified on the command line +# - Bond, PPPoE, and VLAN functionality couldn't be tested; some option- +# arguments aren't completed (-deleteBond, -deleteVLAN, ...) +# - -createpppoeservice arguments in particular may not be right + +# Complete network devices +(( $+functions[_networksetup_devices] )) || +_networksetup_devices() { + local -a expl tmp + + tmp=( ${(f)"$( + _call_program network-devices $words[1] -listallhardwareports + )"} ) + tmp=( ${(@M)tmp##Device:*} ) + tmp=( ${(@)tmp##Device:[[:space:]]##} ) + + _wanted -x devices expl 'network device' compadd -a "$@" - tmp +} + +# Complete network locations +(( $+functions[_networksetup_locations] )) || +_networksetup_locations() { + local -a expl tmp + + tmp=( ${(f)"$( _call_program network-locations $words[1] -listlocations )"} ) + + _wanted -x locations expl 'network location' compadd -a "$@" - tmp +} + +# Complete hardware ports +(( $+functions[_networksetup_ports] )) || +_networksetup_ports() { + local -a expl tmp + + tmp=( ${(f)"$( + _call_program hardware-ports $words[1] -listallhardwareports + )"} ) + tmp=( ${(@M)tmp##Hardware Port:*} ) + tmp=( ${(@)tmp##Hardware Port:[[:space:]]##} ) + + _wanted -x ports expl 'hardware port' compadd -a "$@" - tmp +} + +# Complete network services +(( $+functions[_networksetup_services] )) || +_networksetup_services() { + local -a expl tmp + + tmp=( ${(f)"$( + _call_program network-services $words[1] -listallnetworkservices + )"} ) + # The command output doesn't distinguish between a leading asterisk used to + # indicate an inactive service and one that's just used in the service name + # itself... but the latter scenario seems uncommon, so we'll assume it's + # always the former + tmp=( ${(@)tmp#\*} ) + # The first line is an explanation of the asterisk thing; skip it + tmp=( ${(@)tmp[2,-1]} ) + + _wanted -x services expl 'network service' compadd -a "$@" - tmp +} + +# Complete Wi-Fi networks — this function expects the final argument to be the +# name of a wireless device (pre-escaped, as if taken from $words) +(( $+functions[_networksetup_wifi_networks] )) || +_networksetup_wifi_networks() { + local -a expl tmp + + tmp=( ${(f)"$( + _call_program wifi-networks $words[1] \ + -listpreferredwirelessnetworks ${(q-)@[-1]} + )"} ) + # Lines with Wi-Fi networks on them are prefixed by white space + tmp=( ${(@M)tmp##[[:space:]]*} ) + tmp=( ${(@)tmp##[[:space:]]##} ) + + shift -p # Discard device argument + _wanted -x wifi-networks expl 'Wi-Fi network' compadd -a "$@" - tmp +} + +_networksetup() { + local i j ret=1 + local -a context line state state_descr args tmp + local -A opt_args val_args proxies + + args=( + + '(cmd)' + '-addDeviceToBond[add specified device/port to bond]: :->dp: :->b' + '-addpreferredwirelessnetworkatindex[add preferred Wi-Fi network for specified device]: :->d: :->w:*::: :->wifi-idx-info' + '-connectpppoeservice[connect specified PPPoE service]: :->P' + '-create6to4service[create new 6to4 service]:6to4 service name' + '-createBond[create bond with specified devices/ports]:bond name: :*: :->dp' + '-createlocation[create new network location]:network location name: :*: :->s' + '-createnetworkservice[create new network service on specified device/port]: :->dp:network service name' + '-createpppoeservice[create new PPPoE service on specified device/port]: :->dp: :->s:PPPoE account name: :PPPoE password: :PPPoE service name' + '-createVLAN[create VLAN on specified device/port]:VLAN name: : :->dp:VLAN tag' + '-deleteBond[delete specified bond]: :->b' + '-deletelocation[delete specified network location]: :->l' + '-deletepppoeservice[delete specified PPPoE service]: :->P' + '-deleteVLAN[delete VLAN from specified device/port]:VLAN name: : :->dp:VLAN tag' + '-detectnewhardware[detect new network hardware]' + '-disconnectpppoeservice[disconnect specified PPPoE service]: :->P' + '-duplicatenetworkservice[duplicate specified network service]: :->s:network service name' + '-getadditionalroutes[list additional IPv4 routes for specified network service]: :->s' + '-getairportnetwork[display Wi-Fi network for specified device]: :->d' + '-getairportpower[display Wi-Fi power state for specified device]: :->d' + '-getautoproxyurl[display proxy auto-config URL for specified network service]: :->s' + '-getv6additionalroutes[list additional IPv6 routes for specified network service]: :->s' + '-getcomputername[display computer name]' + '-getcurrentlocation[display current network location]' + '-getdnsservers[display DNS info for specified network service]: :->s' + '-getinfo[display info for specified network service]: :->s' + '-getmacaddress[display MAC address for specified device/port]: :->dp' + '-getMedia[display media for specified device/port]: :->dp' + '-getMTU[display MTU for specified device/port]: :->dp' + '-getnetworkserviceenabled[get enabled state for specified network service]: :->s' + '-getpassiveftp[display passive FTP state for specified network service]: :->s' + '-getproxyautodiscovery[display proxy auto-discovery state for specified network service]: :->s' + '-getproxybypassdomains[display proxy bypass domains for specified network service]: :->s' + '-getsearchdomains[display DNS search domains for specified network service]: :->s' + '-help[display help information]' + '-isBondSupported[display whether device/port can be added to a bond]: :->dp' + '-listallhardwareports[list hardware ports]' + '-listallnetworkservices[list network services]' + '-listBonds[list bonds]' + '-listdevicesthatsupportVLAN[list devices that support VLANs]' + '-listlocations[list network locations]' + '-listnetworkserviceorder[list network services and their devices/ports in order]' + '-listpreferredwirelessnetworks[list preferred Wi-Fi networks for the specified device]: :->d' + '-listpppoeservices[list PPPoE services]' + '-listValidMedia[list valid media for specified device/port]: :->dp' + '-listValidMTURange[display valid MTU range for specified device/port]: :->dp' + '-listVLANs[list VLANs]' + '-ordernetworkservices[set network service order]:*: :->s' + '-printcommands[list commands]' + '-removeallpreferredwirelessnetwork[remove all preferred Wi-Fi networks from specified device]: :->d' + '-removeDeviceFromBond[remove specified device/port from bond]: :->dp: :->b' + '-removenetworkservice[remove specified network service]: :->s' + '-removepreferredwirelessnetwork[remove preferred Wi-Fi network from specified device]: :->d: :->w' + '-renamenetworkservice[rename specified network service]: :->s:network service name' + '-set6to4automatic[set specified 6to4 service to get relay address automatically]:6to4 service:->s' + '-set6to4manual[set specified 6to4 service to use manual relay address]:6to4 service:->s:relay address' + '-setadditionalroutes[set additional IPv4 routes for specified network service]: :->s:*::: :->routes-v4' + '-setairportnetwork[set Wi-Fi network for specified device]: :->d: :->w:Wi-Fi network password' + '-setairportpower[set Wi-Fi power state for specified device]: :->d:Wi-Fi power state:(on off)' + '-setautoproxyurl[set proxy auto-config URL for specified network service]: :->s:proxy auto-config URL:_urls' + '-setcomputername[set computer name]:computer name' + '-setbootp[set specified network service to use BOOTP]: :->s' + '-setdhcp[set specified network service to use DHCP]: :->s:client ID (optional)' + '-setdnsservers[set DNS servers for specified network service]: :->s:*:DNS server address' + '-setmanual[set specified network service to use manual IPv4 IP/subnet/router]: :->s:IP address: :subnet mask: :router address' + '-setmanualwithdhcprouter[set specified network service to use DHCP with manual IP]: :->s:IP address' + '-setMedia[set media for specified device/port]: :->dp: :->media:*:media option' + '-setMTU[set MTU for specified device/port]: :->dp: :->mtu' + '-setMTUAndMediaAutomatically[set specified device/port to automatically set MTU and media type]: :->dp' + '-setnetworkserviceenabled[set enabled state for specified network service]: :->s:network service enabled state:(on off)' + '-setpassiveftp[set passive FTP state for specified network service]: :->s:passive FTP state:(on off)' + '-setpppoeaccountname[set account name for specified PPPoE service]: :->P:PPPoE account name' + '-setpppoepassword[set password for specified PPPoE service]: :->P:PPPoE password' + '-setproxyautodiscovery[set proxy auto-discovery state for specified network service]: :->s:proxy auto-discovery state:(on off)' + '-setproxybypassdomains[set proxy bypass domains for specified network service]: :->s:*:proxy bypass domain' + '-setsearchdomains[set DNS search domains for specified network service]: :->s:*:DNS search domain' + '-setv6additionalroutes[set additional IPv6 routes for specified network service]: :->s:*::: :->routes-v6' + '-setv4automatic[set specified network service to get IPv4 address automatically]: :->s' + '-setv6automatic[set specified network service to get IPv6 address automatically]: :->s' + '-setv6linklocal[set specified network service to use link-local address only for IPv6]: :->s' + '-setv6manual[set specified network service to use manual IPv6 IP/prefix/router]: :->s:IP address: :prefix length: :router address' + '-setv4off[disable IPv4 for specified network service]: :->s' + '-setv6off[disable IPv6 for specified network service]: :->s' + '-showBondStatus[display status for specified bond]: :->b' + '-showpppoestatus[display status for specified PPPoE service]: :->P' + '-switchtolocation[switch to specified network location]: :->l' + ) + + proxies=( + ftp FTP + gopher Gopher + socks SOCKS + secureweb HTTPS + streaming RTSP + web HTTP + ) + + for i j in ${(kv)proxies}; do + args+=( + "-get${i}proxy[display $j proxy info for specified network service]: :->s" + "-set${i}proxy[set $j proxy info for specified network service]: :->s:*::: :->proxy-info" + "-set${i}proxystate[set $j proxy state for specified network service]: :->s:proxy state:(on off)" + ) + done + + _arguments : $args && ret=0 + + case $state in + b) _message -e bonds 'interface bond' && ret=0 ;; + d) _networksetup_devices && ret=0 ;; + l) _networksetup_locations && ret=0 ;; + p) _networksetup_ports && ret=0 ;; + P) _message -e pppoe-services 'PPPoE service' && ret=0 ;; + s) _networksetup_services && ret=0 ;; + dp) + _alternative \ + 'devices::_networksetup_devices' \ + 'ports::_networksetup_ports' \ + && ret=0 + ;; + dps) + _alternative \ + 'devices::_networksetup_devices' \ + 'ports::_networksetup_ports' \ + 'services::_networksetup_services' \ + && ret=0 + ;; + ps) + _alternative \ + 'ports::_networksetup_ports' \ + 'services::_networksetup_services' \ + && ret=0 + ;; + w) + # Wi-Fi network always follows device/port on command line + _networksetup_wifi_networks $words[(CURRENT - 1)] && ret=0 + ;; + media) + # Media type always follows device/port on command line + tmp=( ${(f)"$( + _call_program media-types $words[1] \ + -listValidMedia $words[(CURRENT - 1)] + )"} ) + tmp=( ${tmp##\**} ) # Error message + if (( $#tmp )); then + _describe -t media-types 'media type' tmp && ret=0 + else + _message -e media-types 'media type' && ret=0 + fi + ;; + mtu) + # MTU value always follows device/port on command line + tmp=( ${(f)"$( + _call_program mtu-ranges $words[1] \ + -listValidMTURange $words[(CURRENT - 1)] + )"} ) + tmp=( ${(M)tmp##Valid MTU Range:*} ) + tmp=( ${tmp##*:[[:space:]]#} ) + _message -e mtu-value "MTU value${tmp:+ (${tmp})}" && ret=0 + ;; + proxy-info) + (( CURRENT > 5 )) || + case $(( CURRENT % 5 )) in + 1) _message -e hosts 'proxy server address' && ret=0 ;; + 2) _message -e ports 'proxy port number' && ret=0 ;; + 3) _values 'authenticated proxy support' on off && ret=0 ;; + 4) + [[ $words[(CURRENT - 1)] == on ]] && + _message -e users 'proxy user name' && + ret=0 + ;; + 0) + [[ $words[(CURRENT - 2)] == on ]] && + _message -e passwords 'proxy password' && + ret=0 + ;; + esac + ;; + routes-v4) + case $(( CURRENT % 3 )) in + 1) _message -e addresses 'destination address' && ret=0 ;; + 2) _message -e masks 'subnet mask' && ret=0 ;; + 0) _message -e addresses 'router address' && ret=0 ;; + esac + ;; + routes-v6) + case $(( CURRENT % 3 )) in + 1) _message -e addresses 'destination address' && ret=0 ;; + 2) _message -e prefixes 'prefix length' && ret=0 ;; + 0) _message -e addresses 'router address' && ret=0 ;; + esac + ;; + wifi-idx-info) + (( CURRENT > 3 )) || + case $(( CURRENT % 3 )) in + 1) + _message -e wifi-indexes 'index in preferred Wi-Fi networks list' && + ret=0 + ;; + 2) + tmp=( + 'OPEN:none (unsecured)' + 'WPA:WPA Personal' + 'WPA2:WPA2 Personal' + 'WPA/WPA2:WPA/WPA2 Personal' + 'WPAE:WPA Enterprise' + 'WPA2E:WPA2 Enterprise' + 'WPAE/WPA2E:WPA/WPA2 Enterprise' + 'WEP:plain WEP' + '8021XWEP:802.1X WEP' + ) + _describe -t security-types 'Wi-Fi network security type' tmp && ret=0 + ;; + 0) + [[ ${(U)words[(CURRENT - 1)]} != OPEN ]] && + _message -e passwords 'Wi-Fi network password' && + ret=0 + ;; + esac + ;; + esac + + return ret +} + +_networksetup "$@" diff --git a/Completion/Darwin/Command/_nvram b/Completion/Darwin/Command/_nvram index 8158eb9d2..8853b0bee 100644 --- a/Completion/Darwin/Command/_nvram +++ b/Completion/Darwin/Command/_nvram @@ -15,7 +15,7 @@ _arguments -s : \ && ret=0 [[ $state == variables-* ]] && { - tmp=( ${${(f)"$( command $service -p )"}%%[[:space:]]*} ) + tmp=( ${${(f)"$( _call_program variables $words[1] -p )"}%%[[:space:]]*} ) [[ $state == variables-rw ]] && tmp=( ${^tmp}'::NVRAM variable value' ) diff --git a/Completion/Darwin/Command/_open b/Completion/Darwin/Command/_open index eadad1831..2563e5eb5 100644 --- a/Completion/Darwin/Command/_open +++ b/Completion/Darwin/Command/_open @@ -1,5 +1,12 @@ #compdef open +# Notes: +# - 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 zstyle -T ":completion:${curcontext}:files" prefix-needed && \ @@ -8,34 +15,69 @@ _open_absolute_application_path() { } _open() { - local curcontext="$curcontext" state line expl + local curcontext=$curcontext ret=1 + local -a context expl line state state_descr tmp + local -A opt_args val_args - _arguments -C \ - '-a[specify application]: :->open_mac_applications' \ - '-e[open with TextEdit]' \ - '-f[reads input from standard input and opens with TextEdit]' \ - '*: :->open_files' + # No +, and no -S (--args covers that) + _arguments -s -C : \ + '(-a -b -e -f -R -t)-a+[specify application name]: :->applications' \ + '(: * -)--args[pass remaining arguments to application]:*:::argument' \ + '(-a -b -e -f -R -t)-b+[specify application bundle identifier]: :->bundle-ids' \ + '(-a -b -e -f -R -t)-e[open with TextEdit]' \ + '(-h)-f[open standard input with TextEdit or specified application]' \ + '(-R)-F[open application with fresh state]' \ + '-g[do not bring application to foreground]' \ + '(-f)-h[open library header file]' \ + '(-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' \ + '(-a -b -e -f -R -t)-t[open with default text editor]' \ + '(-R)-W[wait for application to exit]' \ + '(-f)*: :->files' \ + && ret=0 - case "$state" in - open_mac_applications) + case $state in + applications) _alternative \ "commands: :_mac_applications" \ - "files:: _open_absolute_application_path" + "files:: _open_absolute_application_path" \ + && ret=0 + ;; + bundle-ids) + autoload -Uz zargs + _retrieve_mac_apps + tmp=( ${(@)_mac_apps:#/System/Library/(Private|)Frameworks/*} ) + 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 ;; - open_files) - local app - if [[ -n "$words[(r)-a]" ]]; then - app="${(Q)words[words[(i)-a] + 1]}" - elif [[ -n "$words[(r)-e]" || -n "$words[(r)-f]" ]]; then - app="Text Edit" + files) + if (( $+opt_args[-h] )); then + tmp=( + /System/Library/Frameworks/*/Headers/*.h(#q-.N:t) + /usr/local/include/**/*.h(#q-.N:t) + /usr/include/**/*.h(#q-.N:t) + ) + _describe -t headers 'header file' tmp && ret=0 + else + _webbrowser && ret=0 fi - if [[ -n "$app" ]]; then - _wanted files expl "file for $app" _mac_files_for_application "$app" + ;; + sdks) + tmp=( /Library/Developer/CommandLineTools/SDKs/*.*.sdk(#qN:t:r) ) + if (( $#tmp )); then + _describe -t sdks 'SDK name/version' tmp && ret=0 else - _webbrowser + _message -e sdks 'SDK name/version' && ret=0 fi ;; esac + + return ret } _open "$@" diff --git a/Completion/Darwin/Command/_osascript b/Completion/Darwin/Command/_osascript index 5e4a5f70c..5e6cebab5 100644 --- a/Completion/Darwin/Command/_osascript +++ b/Completion/Darwin/Command/_osascript @@ -18,7 +18,7 @@ case $state in # but adding the output of osalang makes this future-proof _values 'script language' \ AppleScript JavaScript 'Generic Scripting System' \ - ${(f)"$( command osalang 2> /dev/null )"} \ + ${(f)"$( _call_program languages command osalang )"} \ && ret=0 ;; modifiers) diff --git a/Completion/Darwin/Command/_pbcopy b/Completion/Darwin/Command/_pbcopy index fd60f00cc..deffd1160 100644 --- a/Completion/Darwin/Command/_pbcopy +++ b/Completion/Darwin/Command/_pbcopy @@ -8,7 +8,7 @@ args=( '(-)-help[display help information]' '-pboard[specify pasteboard to copy to or paste from]: :->pboards' ) -[[ $service == pbpaste ]] & args+=( +[[ $service == pbpaste ]] && args+=( '-Prefer[specify type of data to prefer when pasting]: :->dtypes' ) diff --git a/Completion/Darwin/Command/_say b/Completion/Darwin/Command/_say index d687cfa11..1459c7372 100644 --- a/Completion/Darwin/Command/_say +++ b/Completion/Darwin/Command/_say @@ -28,9 +28,9 @@ case $state in # also, not every file format supports bit-rate values (( $+opt_args[--file-format] )) && { tmp=( ${(f)"$( - command $service \ + _call_program bit-rates $words[1] \ --file-format=${opt_args[--file-format]##*:} \ - --bit-rate='?' 2> /dev/null + --bit-rate='\?' )"} ) tmp=( ${tmp//[[:space:]]##/} ) } @@ -46,9 +46,9 @@ case $state in _message 'data format' && ret=0 else tmp=( ${(f)"$( - command $service \ + _call_program data-formats $words[1] \ --file-format=${opt_args[--file-format]##*:} \ - --data-format='?' 2> /dev/null + --data-format='\?' )"} ) tmp=( ${tmp//:/\\:} ) tmp=( ${^tmp/[[:space:]]##/[}\] ) @@ -56,13 +56,13 @@ case $state in fi ;; devices) - tmp=( ${(f)"$( command $service -a '?' 2> /dev/null )"} ) + tmp=( ${(f)"$( _call_program devices $words[1] -a '\?' )"} ) tmp=( ${tmp##[[:space:]]#[0-9]##[[:space:]]##} ) tmp=( ${tmp//:/\\:} ) _values 'audio device name or ID' $tmp && ret=0 ;; file-formats) - tmp=( ${(f)"$( command $service --file-format='?' 2> /dev/null )"} ) + tmp=( ${(f)"$( _call_program file-formats $words[1] --file-format='\?' )"} ) tmp=( ${tmp%%[[:space:]]##\(.*} ) tmp=( ${tmp//:/\\:} ) tmp=( ${^tmp/[[:space:]]##/[}\] ) @@ -76,7 +76,7 @@ case $state in && ret=0 ;; voices) - tmp=( ${(f)"$( command $service -v '?' 2> /dev/null )"} ) + tmp=( ${(f)"$( _call_program voices $words[1] -v '\?' )"} ) tmp=( ${tmp%%[[:space:]](#c2,)*} ) _values voice $tmp && ret=0 ;; diff --git a/Completion/Darwin/Command/_sc_usage b/Completion/Darwin/Command/_sc_usage new file mode 100644 index 000000000..3a11a1bff --- /dev/null +++ b/Completion/Darwin/Command/_sc_usage @@ -0,0 +1,10 @@ +#compdef sc_usage + +_arguments -s -A '-*' : \ + '-c+[specify code file to use]:code file:_files' \ + '-e[sort output by call count]' \ + '-l[use scrolling output style instead of window updating style]' \ + '-s+[specify sampling interval]:seconds' \ + '(- :)-E[specify command path and args to excute]: :_absolute_command_paths:*:: :_normal' \ + '1: : _alternative "processes:: _pids" + "processes-names:: _process_names -a"' diff --git a/Completion/Darwin/Command/_scselect b/Completion/Darwin/Command/_scselect index 79df2f981..ff7d2610d 100644 --- a/Completion/Darwin/Command/_scselect +++ b/Completion/Darwin/Command/_scselect @@ -13,7 +13,7 @@ _arguments -s -S : \ # For some reason scselect expects location names to be encoded in Mac OS # Roman; in order to prevent completed arguments from breaking the tool, we'll # insert the UUID instead if the name would contain incompatible characters - tmp=( ${(f)"$( command $service 2> /dev/null )"} ) + tmp=( ${(f)"$( _call_program locations $words[1] )"} ) tmp=( ${tmp[2,-1]} ) tmp=( ${tmp##[*[:space:]]##} ) tmp=( ${tmp//:/\\:} ) diff --git a/Completion/Darwin/Type/_mac_applications b/Completion/Darwin/Type/_mac_applications index 51fa0c470..7b633579c 100644 --- a/Completion/Darwin/Type/_mac_applications +++ b/Completion/Darwin/Type/_mac_applications @@ -3,5 +3,5 @@ _retrieve_mac_apps local expl -_wanted commands expl 'Mac OS X application' \ +_wanted commands expl 'macOS application' \ compadd "$@" - "${(@)${_mac_apps[@]:t}%.app}" diff --git a/Completion/Debian/Command/_debuild b/Completion/Debian/Command/_debuild new file mode 100644 index 000000000..5b1d0ea37 --- /dev/null +++ b/Completion/Debian/Command/_debuild @@ -0,0 +1,20 @@ +#compdef debuild + +local ign noc + +(( $#words > 2 )) && ign='!' +(( CURRENT != 2 )) && noc='!' + +_arguments \ + "${ign}(- 1 *)"{-h,--help}'[display usage information]' \ + "${ign}(- 1 *)--version[display version and copyright information]" \ + ${noc}{--no-conf,--noconf}"[don't read devscripts config files]" \ + {-r-,--rootcmd=}'[specify command used to become root if debuild not setuid root]: : _command_names -e' \ + '(--preserve-env)*'{-e-,--preserve-envvar=}'[preserve environment variable]:environment variable:_parameters -g "*export*"' \ + '(-e --preserve-envvar)--preserve-env[preserve all environment vars (except PATH)]' \ + '*'{-e-,--set-envvar=}'[preserve environment variable]:environment variable:_parameters -g "*export*" -qS=' \ + '--prepend-path=[prepend to the sanitised PATH]: :_dir_list' \ + '(-D)-d[skip checking of build dependencies]' \ + '(-d)-D[force checking of build dependencies]' \ + '--check-dirname-level[specify how much to check directory names]:level [1]:((0\:never 1\:only\ if\ program\ changes\ directory 2\:always))' \ + '--check-dirname-regex[specify what constitutes a matching directory name]:perl regex [PACKAGE(-.*)?]' diff --git a/Completion/Debian/Command/_wajig b/Completion/Debian/Command/_wajig index 26d08cfd7..630507e67 100644 --- a/Completion/Debian/Command/_wajig +++ b/Completion/Debian/Command/_wajig @@ -14,7 +14,8 @@ _arguments -C -s \ case $state in cmds) - cmds=( ${${(M)${(f)"$(wajig commands 2>/dev/null)"}:# [^-]*}/(#b) ([^ ]#) #(*)/$match[1]:$match[2]:l} ) + cmds=( ${(f)"$( _call_program commands $words[1] commands )"} ) + cmds=( ${(@)cmds/(#b)([^ ]##) ##(?)(*)/$match[1]:${match[2]:l}${match[3]//:/\\:}} ) _describe -t commands 'wajig command' cmds && ret=0 ;; diff --git a/Completion/Linux/Command/_cryptsetup b/Completion/Linux/Command/_cryptsetup index ea7152ea1..351859586 100644 --- a/Completion/Linux/Command/_cryptsetup +++ b/Completion/Linux/Command/_cryptsetup @@ -33,7 +33,7 @@ _arguments -s \ '(--use-random)--use-urandom[use /dev/urandom to generate volume key]' \ '--shared[share device with another non-overlapping crypt segment]' \ '--uuid=[set device UUID]:uuid' \ - '--allow-discards[allow discards (aka TRIM) requests for device]' \ + '--allow-discards[allow discard (aka TRIM) requests for device]' \ '--header=[device or file with separated LUKS header]:file:_files' \ '--test-passphrase[do not activate device, just check passphrase]' \ '--tcrypt-hidden[use hidden header (hidden TCRYPT device)]' \ @@ -64,6 +64,7 @@ _arguments -s \ '--persistent[set activation flags persistent for device]' \ '--label=[set label for the LUKS2 device]:label' \ '--subsystem=[set subsystem label for the LUKS2 device]:subsystem' \ + '--unbound[create unbound (no assigned data segment) LUKS2 keyslot]' \ '(- : *)--version[show version information]' \ '(- : *)'{-\?,--help}'[display help information]' \ '(- : *)--usage[display brief usage]' \ @@ -86,6 +87,7 @@ case $state in 'luksAddKey:add a new key' 'luksRemoveKey:remove a key' 'luksChangeKey:change a key' + 'luksConvertKey:convert a key to new pbkdf parameters' 'luksKillSlot:wipe key from slot' 'luksUUID:print/change device UUID' 'isLuks:check if device is a LUKS partition' @@ -112,7 +114,7 @@ case $state in erase|convert|config|repair|(luks(AddKey|Erase|RemoveKey|DelKey|UUID|Dump)|isLuks)) args=( $device ) ;; - luks(Format|AddKey|RemoveKey|ChangeKey)) + luks(Format|AddKey|RemoveKey|ChangeKey|ConvertKey)) args=( $device ':key file:_files' ) ;; luksHeader*) args=( $device '--header-backup-file:file:_files' );; diff --git a/Completion/Linux/Command/_dkms b/Completion/Linux/Command/_dkms new file mode 100644 index 000000000..7ea34aa2e --- /dev/null +++ b/Completion/Linux/Command/_dkms @@ -0,0 +1,162 @@ +#compdef dkms + +local curcontext="$curcontext" ign cmds opts ret=1 +local -a state line expl args subcmds dirs +local -A opt_args + +subcmds=( + 'add:add a module/version combination to the tree for builds and installs' + 'remove:remove a module from the tree' + 'build:compile a module for a kernel' + "install:install a build module for it's corresponding kernel" + 'uninstall:uninstall a module for a kernel' + 'match:install every module that is installed for a template kernel for another kernel' + 'mkdriverdisk:create a floppy driver disk image for use when updated drivers are needed to install an OS' + 'mktarball:tar up files in the DKMS tree for a specific module' + 'ldtarball:extract a tarball created with mktarball into the DKMS tree' + 'mkrpm:create an RPM package for a module' + 'mkdeb:create a debian binary package for a module' + 'mkdsc:create a debian source package for a module' + 'mkkmp:create a Kernel Module Package source RPM for a module' + 'status:display the current status of modules, versions and kernels within the tree' + 'autoinstall:try to install the latest revision of all modules that have been installed for other kernel revisions' +) + +args=( + '(1)-m[specify module]:module:->modules' + '(1)-v[specify module version]:version' + '(-q --quiet)'{-q,--quiet}'[suppress output]' + '(--all)*'{-a,--arch}'[specify system architecture]:architecture:->architectures' + '*--directive=:directive' + '--dkmstree=:path:_directories' + '--installtree=:path:_directories' + '--sourcetree=:path:_directories' + '--dkmsframework=:path:_directories' + '1: : _describe -t commands command subcmds' +) + +cmd=${${${subcmds%%:*}:*words}[1]} +if [[ -n $cmd ]]; then + curcontext="${curcontext%:*}-$cmd:" +else + # exclude sub-commands based on any options specified so far + for cmds opts in \ + '(remove|build|install|uninstall|match|status|mk(^kmp))' 'k' \ + '(add|remove)' '-rpm_safe_upgrade' \ + 'mk(driverdisk|kmp)' '-spec' \ + 'mk(deb|dsc|rpm)' '-legacy-postinst' \ + 'mk(tarball|rpm|deb|dsc)' '-(source|binary)-only' \ + '(match|build|mkkmp)' '(k|-no-(prepare|clean)-kernel|-kernelsourcedir)' \ + '(|un)install' '-no-(depmod|initrd)' \ + 'mkdriverdisk' '([dr]|-distro|-release|-size|-media)' \ + '(add|build|install|ldtarball)' '-force' \ + 'match' '-templatekernel' \ + '*tarball' '-archive' \ + '(match|build|mkkmp)' '(j*|-no-(prepare|clean)-kernel|-kernelsourcedir)' \ + '(remove|build|install|status|mk(^kmp))' '-all' \ + 'build' '-config' + do + [[ -n ${(M)words:#-${~opts}*} ]] && + subcmds=( ${(M)subcmds:#${~cmds}:*} ) + done + args+=( '(1 -)'{-V,--version}'[display version information]' ) + ign='!' # hide some uncommon options but handle their arguments +fi + +case $cmd in + remove|build|install|uninstall|mk*|status) + args+=( ': :->modules' ) + ;| + |remove|build|install|uninstall|match|status|mk(^kmp)) + args+=( '(--all)*-k[specify kernel version]:kernel:->kernels' ) + ;| + |add|remove) args+=( "${ign}--rpm_safe_upgrade" ) ;| + |mk(driverdisk|kmp)) + args+=( "${ign}--spec=:spec file:_files -g '*.spec(-.)'" ) + ;| + |(mk|ld)tarball) + args+=( "${ign}--archive=:tarball:_files -g '*.tar(-.)'" ) + ;| + |mk(deb|dsc|rpm)) + args+=( "${ign}--legacy-postinst=:value [1]:(0 1)" ) + ;| + |mk(tarball|rpm|deb|dsc)) args+=( "${ign}(--source-only --binaries-only)--"{source,binaries}-only ) ;| + |match|build|mkkmp) + args+=( #TODO: check ignore needed in absence of parameters + "${ign}--no-prepare-kernel" + "${ign}--no-clean-kernel" + '--kernelsourcedir=:directory:_directories' + "${ign}-j+[specify maximum number of jobs to use when building]:jobs" + ) + ;| + |(|un)install) + args+=( + "${ign}--no-depmod" + "${ign}--no-initrd" + ) + ;| + |add) + args+=( + '-c[specify location of dkms.conf file]:location:_files' + ) + ;| + |remove|build|install|status|mk(^kmp)) + args+=( '(-a --arch -k)--all[specify all relevant kernels/arches]' ) + ;| + |build) + args+=( "${ign}--config=:kernel config file:_files" ) + ;| + |add|build|install|ldtarball) + args+=( '--force[force overwriting of extant files]' ) + ;| + |match) + args+=( "${ign}--templatekernel=:kernel:->kernels" ) + ;| + |mkdriverdisk) + args+=( + "${ign}(-d --distro)"{-d,--distro=}':distribution:(redhat'{,1,2,3}' suse unitedlinux)' + "${ign}(-r --release)"{-r,--release=}':release' + "${ign}--size=:size (kb) [1440]" + "${ign}--media=:media type [floppy]:(floppy iso tar)" + ) + ;| + add) + args+=( + '2:path:_directories' + '3:tarball:_files -g "*.tar(-.)"' + ) + ;; + install) + args+=( + '2:rpm file:_files -g "*.rpm(-.)"' + ) + ;; +esac + +_arguments -C $args && ret=0 + +case $state in + modules) + dirs=( ${(e)opt_args[--dkmstree]:-/var/lib/dkms}/*/*(/) ) + dirs=( ${${(M)dirs%/*/*}#/} ) + _description modules expl module + _multi_parts -i "$expl[@]" / dirs && ret=0 + ;; + kernels) + if compset -P 1 '*/'; then + _description architectures expl architecture + compadd "$expl[@]" /lib/modules/$IPREFIX/build/arch/*(/:t) && ret=0 + else + compset -S '/*' + dirs=( /lib/modules/*(/:t) ) + _description -V kernels expl kernel + compadd "$expl[@]" -r "/ \t\n\-" ${(on)dirs} && ret=0 + fi + ;; + architectures) + _description architectures expl architecture + compadd "$expl[@]" /lib/modules/$(uname -r)/build/arch/*(/:t) && ret=0 + ;; +esac + +return ret diff --git a/Completion/Linux/Command/_iptables b/Completion/Linux/Command/_iptables index 4178a1a2e..447d7c932 100644 --- a/Completion/Linux/Command/_iptables +++ b/Completion/Linux/Command/_iptables @@ -1,16 +1,16 @@ -#compdef iptables iptables-save iptables-restore +#compdef iptables iptables-save iptables-restore ip6tables ip6tables-save ip6tables-restore local curcontext="$curcontext" state line expl i ret=1 local -a cmds rcmds ropts rules states prev args case $service in - iptables-save) + iptables-save | ip6tables-save) _arguments -s \ {-c,--counters}'[include values of packet and byte counters in output]' \ {-t,--table}'[specify table]:table:(filter nat mangle)' return ;; - iptables-restore) + iptables-restore | ip6tables-restore) _arguments -s \ {-c,--counters}'[restore the values of all packet and byte counters]' \ {-n,--noflush}"[don't flush the previous contents of the table]" diff --git a/Completion/Linux/Command/_kpartx b/Completion/Linux/Command/_kpartx index 11c614c01..8f09c416d 100644 --- a/Completion/Linux/Command/_kpartx +++ b/Completion/Linux/Command/_kpartx @@ -1,6 +1,6 @@ #compdef kpartx -_arguments -s -w : \ +_arguments -s -S : \ '-a[add partition mappings]' \ '-r[read-only partition mappings]' \ '-d[delete partition mappings]' \ @@ -9,6 +9,6 @@ _arguments -s -w : \ '-p[set device name-partition number delimiter]' \ '-f[force creation of mappings]' \ '-g[force GUID partition table]' \ - '-v[Operate verbosely]' \ - '-s[don'\''t return until the partitions are created]' \ + '-v[operate verbosely]' \ + '-n[return before the partitions are created]' '!(-n)-s' \ '1: : _files' diff --git a/Completion/Linux/Command/_networkmanager b/Completion/Linux/Command/_networkmanager index 881445abb..e38215e76 100644 --- a/Completion/Linux/Command/_networkmanager +++ b/Completion/Linux/Command/_networkmanager @@ -102,7 +102,7 @@ _nm_connection_up() { } _nm_connection_down() { - _arguments "1:connection:_nm_connection_specs" + _arguments "1:connection:_nm_connection_active" } _nm_connection_modify() { @@ -162,6 +162,12 @@ _nm_connection_ids() { _describe 'select connection' con_ids } +_nm_connection_active() { + local -a con_ids + con_ids=(${(f)"$(_call_program nmcli nmcli -t -f name connection show --active)"}) + _describe 'select connection' con_ids +} + _nm_device() { local curcontext="$curcontext" state line diff --git a/Completion/Linux/Command/_opkg b/Completion/Linux/Command/_opkg new file mode 100644 index 000000000..d64567681 --- /dev/null +++ b/Completion/Linux/Command/_opkg @@ -0,0 +1,462 @@ +#compdef opkg ipkg + +# Notes: +# +# - This function has been designed with opkg in mind, but much of it should +# also work with ipkg. +# +# - Caching doesn't appear to save a HUGE amount of time given the scale of most +# opkg repos (compared to e.g. APT) and the resources available to the devices +# that use them. +# +# - _opkg_pkg_* functions can be called with --update to update their respective +# cache files without actually completing. +# +# - Lots of code redundancy here (@todo). +# +# Notable styles supported: +# +# % zstyle ':completion:*:opkg:*' use-cache <yes/no> +# Set to yes to enable caching of package names. Usually disabled by default. +# +# % zstyle ':completion:*:opkg:*' cache-path <directory> +# Set to a directory path to override the default cache-file directory. +# +# % zstyle ':completion:*:opkg:*' cache-persists <yes/no> +# Set to yes to keep cache data in memory for the remainder of the shell +# session. Most completion functions do this always, but opkg tends to be used +# on fairly resource-constrained devices, so it's disabled by default here. +# +# % zstyle ':completion:*:opkg:*' status-paths <pattern> ... +# Set to one or more paths or glob patterns to override the defaults used when +# checking cache validity. If any of the specified files has been modified +# more recently than the cache, the cache is considered invalid. +# +# % zstyle ':completion:*:opkg:*' conf-paths <pattern> ... +# Set to one or more paths or glob patterns to override the defaults used when +# searching opkg configuration data. + +## +# Check cache validity. +__opkg_cache_policy() { + local -a tmp + + # Always invalidate if it's been over a week + tmp=( $1(#qmw+1N) ) + (( $#tmp )) && return 0 + + zstyle -a ":completion:$curcontext:" status-paths tmp + + if (( $#tmp )); then + tmp=( $~tmp(#qN) ) + else + tmp=( + {/opt,/usr,/var}/lib/{i,o}pkg/status(#q-.N) + {/opt,/usr,/var}/lib/{i,o}pkg/lists/packages(#q-.N) + /opt/var/opkg-lists/packages(#q-.N) + ) + fi + + # Always invalidate if we found no status files + (( $#tmp )) || return 0 + + # Invalidate if any status file is newer than the cache file + for 2 in $tmp; do + [[ $2 -nt $1 ]] && return 0 + done + + return 1 +} + +## +# Search opkg config files. +__opkg_grep_conf() { + local -aU tmp + + zstyle -a ":completion:$curcontext:" conf-paths tmp + + if (( $#tmp )); then + tmp=( $~tmp(#qN) ) + else + tmp=( + {,/opt}/etc/{i,o}pkg*.conf(#q-.N) + {,/opt}/etc/{i,o}pkg/*.conf(#q-.N) + ) + fi + + (( $#tmp )) || return 1 + + GREP_OPTIONS= command grep -sE "$@" $tmp +} + +## +# Complete architecture/priority pair. +# +# Architecture names are essentially arbitrary (up to the packager), so we can't +# really complete every possibility here — but we'll account for most of the +# popular ones. +_opkg_arch_prio() { + local -a copts=( "$@" ) + local -aU tmp + + [[ -prefix *: ]] && { + _message priority + return + } + + # Already configured arches + tmp=( ${(f)"$( _call_program architectures $svc print-architecture )"} ) + tmp=( ${${tmp##arch[ ]##}%% *} ) + + tmp+=( + # 'Meta' arches + all any noarch + # Arches supported by entware-ng + armv5soft armv7soft mipselsf x86-32 x86-64 + # Arches mentioned in the optware-ng source + arm armeb fsg3be hpmv2 i686 ixp4xxbe ixp4xxle mssii nslu2 powerpc qemux86 + slugosbe slugosle + # Arches mentioned in the Ångström distribution's narcissus source + a780 ac100 akita am180x-evm am3517-crane am3517-evm am37x-evm archos5 + archos5it arm arm-oabi armeb armv4 armv4b armv4t armv4tb armv5 armv5-vfp + armv5e armv5e-vfp armv5eb armv5t armv5t-vfp armv5te armv5te-vfp armv5teb + armv6 armv6-vfp armv6t-vfp armv7 armv7-vfp armv7a armv7a-vfp armv7a-vfp-neon + armv7at2-vfp armv7at2-vfp-neon armv7t2-vfp at32stk1000 at91sam9263ek + atngw100 avr32 beagleboard beaglebone bug20 c6a816x-evm c6a816x_evm c7x0 + cm-t35 collie da830-omapl137-evm da850-omapl138-evm davinci-dvevm dht-walnut + dm355-evm dm355-leopard dm357-evm dm365-evm dm3730-am3715-evm dm37x-evm + dm6446-evm dm6467-evm dm6467t-evm dns323 eee701 efika h2200 h3900 h4000 + h5000 hawkboard htcalpine hx4700 i386 i486 i586 i686 igep0020 iwmmxt + ixp4xxbe ixp4xxle kuropro lsppchd lsppchg lspro mini2440 mini6410 mips + mv2120 n1200 n2100 neuros-osd2 nokia800 om-gta01 om-gta02 omap3-pandora + omap3-touchbook omap3evm omap4430-panda omap4430_panda omap5912osk omapzoom + omapzoom2 omapzoom36x openrd-base openrd-client overo palmt650 poodle + powerpc ppc ppc405 ppc603e qemuarm qemumips qemuppc qemux86 sheevaplug + simpad smartq5 spitz tosa ts409 tsx09 usrp-e1xx x86 + ) + + _values -O copts -w -S : architecture ${^tmp}:priority +} + +## +# Complete destination name. +_opkg_dest() { + local -a copts=( "$@" ) + local -aU tmp + + tmp=( ${(f)"$( __opkg_grep_conf '^\s*dest\s+\S+\s+\S+' )"} ) + tmp=( ${tmp##[[:space:]]#dest[[:space:]]##} ) + tmp=( ${tmp%%[[:space:]]*} ) + + (( $#tmp )) || { + _message destination + return + } + _values -O copts -w destination $tmp +} + +## +# Complete destination-name/path pair. +_opkg_dest_path() { + local -a copts=( "$@" ) + local -aU tmp + + tmp=( ${(f)"$( __opkg_grep_conf '^\s*dest\s+\S+\s+\S+' )"} ) + tmp=( ${tmp##[[:space:]]#dest[[:space:]]##} ) + tmp=( ${tmp%%[[:space:]]*} ) + + (( $#tmp )) || { + _message destination:path + return + } + _values -O copts -w -S : destination ${^tmp}': :_directories' +} + +## +# Complete any package name. +_opkg_pkg_all() { + local -a upd copts + + zparseopts -a upd -D -E -update + copts=( "$@" ) + + { (( ! $#_opkg_cache_pkg_all )) || _cache_invalid opkg-pkg-all } && + ! _retrieve_cache opkg-pkg-all && { + _opkg_cache_pkg_all=( ${(f)"$( _call_program pkg-all ${svc:-opkg} list )"} ) + _opkg_cache_pkg_all=( ${(@)_opkg_cache_pkg_all##[[:space:]]*} ) + _opkg_cache_pkg_all=( ${(@)_opkg_cache_pkg_all%%[[:space:]]*} ) + _store_cache opkg-pkg-all _opkg_cache_pkg_all + } + (( $#upd )) && return 0 + + (( $#_opkg_cache_pkg_all )) || { + _message package + return + } + _values -O copts -w package $_opkg_cache_pkg_all +} + +## +# Complete installed package name. +_opkg_pkg_inst() { + local -a upd copts + + zparseopts -a upd -D -E -update + copts=( "$@" ) + + { (( ! $#_opkg_cache_pkg_inst )) || _cache_invalid opkg-pkg-inst } && + ! _retrieve_cache opkg-pkg-inst && { + _opkg_cache_pkg_inst=( ${(f)"$( + _call_program pkg-inst ${svc:-opkg} list-installed + )"} ) + _opkg_cache_pkg_inst=( ${(@)_opkg_cache_pkg_inst##[[:space:]]*} ) + _opkg_cache_pkg_inst=( ${(@)_opkg_cache_pkg_inst%%[[:space:]]*} ) + _store_cache opkg-pkg-inst _opkg_cache_pkg_inst + } + (( $#upd )) && return 0 + + (( $#_opkg_cache_pkg_inst )) || { + _message 'installed package' + return + } + _values -O copts -w 'installed package' $_opkg_cache_pkg_inst +} + +## +# Complete new (installable) package name. +_opkg_pkg_new() { + local -a upd copts + + zparseopts -a upd -D -E -update + copts=( "$@" ) + + { (( ! $#_opkg_cache_pkg_new )) || _cache_invalid opkg-pkg-new } && + ! _retrieve_cache opkg-pkg-new && { + _opkg_pkg_all --update + _opkg_pkg_inst --update + _opkg_cache_pkg_new=( ${_opkg_cache_pkg_all:|_opkg_cache_pkg_inst} ) + _store_cache opkg-pkg-new _opkg_cache_pkg_new + } + (( $#upd )) && return 0 + + (( $#_opkg_cache_pkg_new )) || { + _message 'installable package' + return + } + _values -O copts -w 'installable package' $_opkg_cache_pkg_new +} + +## +# Complete upgradeable package name. +_opkg_pkg_upgr() { + local -a upd copts + + zparseopts -a upd -D -E -update + copts=( "$@" ) + + { (( ! $#_opkg_cache_pkg_upgr )) || _cache_invalid opkg-pkg-upgr } && + ! _retrieve_cache opkg-pkg-upgr && { + _opkg_cache_pkg_upgr=( ${(f)"$( + _call_program pkg-upgr ${svc:-opkg} list-upgradable + )"} ) + _opkg_cache_pkg_upgr=( ${(@)_opkg_cache_pkg_upgr##[[:space:]]*} ) + _opkg_cache_pkg_upgr=( ${(@)_opkg_cache_pkg_upgr%%[[:space:]]*} ) + _store_cache opkg-pkg-upgr _opkg_cache_pkg_upgr + } + (( $#upd )) && return 0 + + (( $#_opkg_cache_pkg_upgr )) || { + _message 'upgradable package' + return + } + _values -O copts -w 'upgradable package' $_opkg_cache_pkg_upgr +} + +_opkg() { + local curcontext=$curcontext ret=1 cache_policy help variant svc=$words[1] + local -a line state state_descr args tmp + local -A opt_args val_args + + if + zstyle -t ":completion:*:*:$service:*" cache-persists && + (( ! $+_opkg_cache_pkg_all )) + then + typeset -gaU _opkg_cache_pkg_all + typeset -gaU _opkg_cache_pkg_inst + typeset -gaU _opkg_cache_pkg_new + typeset -gaU _opkg_cache_pkg_upgr + else + local -aU _opkg_cache_pkg_all + local -aU _opkg_cache_pkg_inst + local -aU _opkg_cache_pkg_new + local -aU _opkg_cache_pkg_upgr + fi + + zstyle -s ":completion:*:*:$service:*" cache-policy cache_policy + [[ -n $cache_policy ]] || + zstyle ":completion:*:*:$service:*" cache-policy __opkg_cache_policy + + # Options are ordered by long name. Alternative names not listed in the usage + # help are (mostly) ignored + args=( + '*--add-arch=[register architecture with priority]: :_opkg_arch_prio' + '*--add-dest=[register destination with path]: :_opkg_dest_path' + '--autoremove[remove unnecessary packages]' + '--combine[combine upgrade and install operations]' + '(-f --conf)'{-f+,--conf=}'[specify opkg config file]:config file:_files' + '(-d --dest)'{-d+,--dest=}'[specify root directory for package operations]: :_opkg_dest' + '--download-only[make no changes (download only)]' + '--force-checksum[ignore checksum mismatches]' + '--force-downgrade[allow package downgrades]' + '--force-depends[ignore failed dependencies]' + '(--force-maintainer --ignore-maintainer)--force-maintainer[overwrite local config files with upstream changes]' + '--force-overwrite[overwrite files from other packages]' + '--force-postinstall[always run postinstall scripts]' + '--force-reinstall[reinstall packages]' + # This is obnoxiously long; maybe add --force-removal-* to ignored-patterns + '--force-removal-of-dependent-packages[remove packages and all dependencies]' + '--force-remove[ignore failed prerm scripts]' + '--force-space[disable free-space checks]' + '(--force-maintainer --ignore-maintainer)--ignore-maintainer[ignore upstream changes to config files]' + '(-l --lists-dir)'{-l+,--lists-dir=}'[specify package-list directory]:list directory:_directories' + '(--noaction --test)'{--noaction,--test}'[make no changes (test only)]' + '--nodeps[do not follow dependencies]' + # Undocumented variant + '!(-o --offline --offline-root)--offline=:root directory:_directories' + '(-o --offline --offline-root)'{-o+,--offline-root=}'[specify root directory for offline package operations]:root directory:_directories' + '(-A --query-all)'{-A,--query-all}'[query all packages (not just installed)]' + '--recursive[remove packages and all their dependencies]' + '--size[show package sizes]' + '(-t --tmp-dir)'{-t+,--tmp-dir=}'[specify temp directory]:temp directory:_directories' + '(-V --verbosity)'{-V+,--verbosity=}'[specify output verbosity level]: :->verbosity-levels' + '(: -)'{-v,--version}'[display version information]' + '1: :->commands' + '*::: :->extra' + ) + + # There are a few different variants of opkg, but we'll concern ourselves + # mainly with OpenWRT/Entware vs (up-stream) Yocto + _pick_variant -r variant openwrt=--nocase yocto --help + + if [[ $variant == openwrt ]]; then + args+=( + '--cache=[specify cache directory]:cache directory:_directories' + '--nocase[match patterns case-insensitively]' + ) + else + args+=( + '*--add-exclude=[register package for exclusion]: :_opkg_pkg_all' + '--cache-dir=[specify cache directory]:cache directory:_directories' + '--host-cache-dir[do not place cache in offline root directory]' + '--no-install-recommends[do not install recommended packages]' + '--prefer-arch-to-version[prefer higher architecture priorities to higher versions]' + '--volatile-cache[use volatile download cache]' + ) + fi + + _arguments -s -S -C : $args && ret=0 + + case $state in + commands) + tmp=( + 'compare-versions[compare version numbers]' + 'configure[configure unpacked package]' + 'depends[display dependencies of package]' + 'download[download package]' + 'files[display files belonging to package]' + 'find[search package names and descriptions]' + 'flag[flag package]' + 'info[display package information]' + 'install[install package]' + 'list[display available packages]' + 'list-changed-conffiles[display user-modified config files]' + 'list-installed[display installed packages]' + 'list-upgradable[display upgradable packages]' + 'print-architecture[display installable architectures]' + 'remove[remove package]' + 'search[display packages providing file]' + 'status[display package status]' + 'update[update list of available packages]' + 'upgrade[upgrade installed package]' + 'whatconflicts[display what conflicts with package]' + 'whatdepends[display what depends on package]' + 'whatdependsrec[display what depends on package (recursive)]' + 'whatprovides[display what provides package]' + 'whatrecommends[display what recommends package]' + 'whatreplaces[display what replaces package]' + 'whatsuggests[display what suggests package]' + ) + [[ $variant == openwrt ]] || + tmp+=( 'clean[clean internal cache]' ) + + _values sub-command $tmp && ret=0 + ;; + verbosity-levels) + _values 'verbosity level' \ + '0[show errors only]' \ + '1[show normal messages (default)]' \ + '2[show informational message]' \ + '3[show debug messages (level 1)]' \ + '4[show debug messages (level 2)]' \ + && ret=0 + ;; + extra) + case $line[1] in + compare-versions) + case $CURRENT in + 1|3) _message 'version string' && ret=0 ;; + 2) + _values operator \ + '<<[earlier]' \ + '<=[earlier or equal]' \ + '=[equal]' \ + '>=[later or equal]' \ + '>>[later]' \ + && ret=0 + ;; + esac + ;; + configure|files|list-*|status) + (( CURRENT == 1 )) && _opkg_pkg_inst && ret=0 + ;; + depends|what*) + if [[ -n ${opt_args[(I)-A|--query-all]} ]]; then + _opkg_pkg_all && ret=0 + else + _opkg_pkg_inst && ret=0 + fi + ;; + download) + _opkg_pkg_all && ret=0 + ;; + find|info|list) + (( CURRENT == 1 )) && _opkg_pkg_all && ret=0 + ;; + flag) + if (( CURRENT == 1 )); then + _values flag hold noprune user ok installed unpacked && ret=0 + else + _opkg_pkg_inst && ret=0 + fi + ;; + install) + _opkg_pkg_new && ret=0 + ;; + remove) + _opkg_pkg_inst && ret=0 + ;; + search) + (( CURRENT == 1 )) && _files && ret=0 + ;; + upgrade) + _opkg_pkg_upgr && ret=0 + ;; + esac + ;; + esac + + (( ret && $#state )) && _message 'no more arguments' && ret=0 + return ret +} + +_opkg "$@" diff --git a/Completion/Linux/Command/_ss b/Completion/Linux/Command/_ss index dff289947..b1bfa207c 100644 --- a/Completion/Linux/Command/_ss +++ b/Completion/Linux/Command/_ss @@ -18,6 +18,7 @@ _arguments -C -s \ "($info -m --memory)"{-m,--memory}'[show socket memory usage]' \ "($info -p --processes)"{-p,--processes}'[show process using each 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 -b --bpf)"{-b,--bpf}'[show bpf filter socket information]' \ "($info -E --events)"{-E,--events}'[continually display sockets as they are destroyed]' \ @@ -33,13 +34,14 @@ _arguments -C -s \ "($info -d --dccp)"{-d,--dccp}'[display DCCP sockets]' \ "($info -w --raw)"{-w,--raw}'[display RAW sockets]' \ "($info -x --unix)"{-x,--unix}'[display Unix domain sockets]' \ + "($info)--tipc[display only TIPC sockets]" \ "($info)--vsock[display only vsock sockets]" \ - "($info -f --family)"{-f,--family}'[display sockets of specified type]:family:(unix inet inet6 link netlink unix vsock)' \ + "($info -f --family)"{-f+,--family=}'[display sockets of specified type]:family:(unix inet inet6 link netlink unix vsock tipc)' \ "($info -K --kill)"{-K,--kill}'[forcibly close sockets, display what was closed]' \ "($info -H --no-header)"{-H,--no-header}'[suppress header line]' \ - "($info -A --query --socket)"{-A,--query,--socket}'[specify socket tables to show]: :_values -s , socket\ table all inet tcp udp raw unix packet netlink unix_dgram unix_stream unix_seqpacket packet_raw packet_dgram vsock_stream vsock_dgram' \ - "($info -D)"{-D,--diag=}'[dump raw info to file]:file:_files' \ - "($info -F)"{-F,--filter=}'[read filter information from a file]:file:_files' \ + "($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' \ "($info)*: :->filter" && ret=0 if [[ -n $state ]]; then diff --git a/Completion/Linux/Command/_sysstat b/Completion/Linux/Command/_sysstat index 855bf0a70..8b7929ddd 100644 --- a/Completion/Linux/Command/_sysstat +++ b/Completion/Linux/Command/_sysstat @@ -9,7 +9,7 @@ _mpstat() { '(-A)-N[specify NUMA nodes]:NUMA node' \ '(-A)-n[report summary CPU statistics based on NUMA node placement]' \ '-o[display statistics in JSON]:format:(JSON)' \ - '(-A)-P[specify processor number]:processor: _values -s "," processor ON ALL {0..$(_call_program processors getconf _NPROCESSORS_ONLN)}' \ + '(-A)-P[specify processor number]:processor: _values -s "," processor ALL {0..$(_call_program processors getconf _NPROCESSORS_ONLN)}' \ '-u[report CPU utilization]' \ '(- 1 2)-V[display version information]' \ '1: : _guard "^-*" interval' \ @@ -85,29 +85,31 @@ _sar() { '-F[display statistics for mounted filesystems]' \ '-f[extract records from file]:record:_files' \ '-H[report hugepages utilization]' \ - '-h[display help]' \ + '(--human -p)-h[make output easier to read: implies --human and -p]' \ + '(- 1 2)--help[display usage information]' \ '--human[print sizes in human readable format]' \ '*-I[report statistics for interrupts]:interrupts: _values -s "," interrupts 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 SUM ALL XALL' \ '-i[select records as close as possible to interval]:interval' \ '-j[display persistent device names]:type:(ID LABEL PATH UUID)' \ '-m[report power management statistics]:keywords: _values -s "," keywords CPU FAN FREQ IN TEMP USB ALL' \ - '-n[report network statistics]:keywords: _values -s "," keywords DEV EDEV NFS NFSD SOCK IP EIP ICMP EICMP TCP ETCP UDP SOCK6 IP6 EIP6 ICMP6 EICMP6 UDP6 ALL' \ + '-n[report network statistics]:keywords: _values -s "," keywords DEV EDEV NFS NFSD SOCK IP EIP ICMP EICMP TCP ETCP UDP SOCK6 IP6 EIP6 ICMP6 EICMP6 UDP6 FC SOFT ALL' \ '-o[save readings to file in binary form]:file:_files' \ '-P[report per-processor statistics]:processor: _values -s "," processors ALL' \ '-p[pretty-print device names]' \ '-q[report queue length and load averages]' \ '-R[report memory statistics]' \ - '-r[report memory utilization statistics]' \ + '-r[report memory utilization statistics]:: :(ALL)' \ '-S[report swap space utilization]' \ '-s[set starting time of report]:start time (HH\:MM\:SS)' \ '--sadc[print name of data collector]' \ '-t[display timestamps in original local time of file creator]' \ - '-u[report CPU utilization]: :(ALL)' \ + '-u[report CPU utilization]:: :(ALL)' \ '(- 1 2)-V[display version information]' \ '-v[report status of kernel tables]' \ '-W[report swapping statistics]' \ '-w[report task creation and system switching activity]' \ '-y[report TTY device activity]' \ + '-z[omit output for any devices lacking activity during sample period]' \ '1: : _guard "^-*" interval' \ '2: : _guard "^-*" count' } diff --git a/Completion/Linux/Command/_tune2fs b/Completion/Linux/Command/_tune2fs index af120e279..3d64f266c 100644 --- a/Completion/Linux/Command/_tune2fs +++ b/Completion/Linux/Command/_tune2fs @@ -24,7 +24,7 @@ _arguments -s -S \ '-m+[set the percentage of reserved filesystem blocks]:percentage' \ '-M+[set the last-mounted directory for the filesystem]:directory:_files -/' \ '-o+[mount options]:options:_values -s , debug bsdgroups user_xattr acl uid16 journal_data journal_data_ordered journal_data_writeback nobarrier block_validity discard nodelalloc' \ - '-O+[set or clear filesystem features]: :_values -s , feature dir_index dir_nlink encrypt extentextent extra_isize filetype flex_bg has_journalhuge_file large_file metadata_csum mmp project quota read-only resize_inode sparse_super uninit_bg' \ + '-O+[set or clear filesystem features]: :_values -s , feature 64bit dir_index dir_nlink ea_inode encrypt extent extra_isize filetype flex_bg has_journal large_dir huge_file large_file metadata_csum metadata_csum_seed mmp project quota read-only resize_inode sparse_super uninit_bg' \ '-r+[set the number of reserved filesystem blocks]:number' \ '-Q+[set quota feature on the superblock]: :_values -s , "quota option" usrquota grpquota prjquota' \ '-s+[set sparse super feature]:state:((0\:off 1\:on))' \ diff --git a/Completion/Solaris/Command/_netstat b/Completion/Solaris/Command/_netstat deleted file mode 100644 index bf8e5aaa4..000000000 --- a/Completion/Solaris/Command/_netstat +++ /dev/null @@ -1,61 +0,0 @@ -#compdef netstat - -_netstat() { - local -a f_rules - - f_rules=( - 'af\::specify address family: inet, inet6, unix, number' - 'outif\::specify output interface: ifName, ifIndex, any, none' - 'dst\::specify destination IP: ip-addr[/mask], any, none' - 'flags\::select routes tagged with flags: [+ -]?[ABDGHLMSU]+' - ) - - _arguments \ - - set1 \ - '-a[show state of all sockets, all routing tables or all interfaces]' \ - '-R[show extended security attributes for sockets and routing tables]' \ - '-n[do not resolve addresses to names]' \ - '-v[verbose]' \ - '-f[specify address family]:address family:(inet inet6 unix)' \ - '-P[specify protocol]:protocol:(ip ipv6 icmp icmpv6 igmp udp tcp rawip)' \ - - set2 \ - '-r[show routing table]' \ - '-f[filter routing table]:rule:(($f_rules))' \ - '-a[show state of all sockets, all routing tables or all interfaces]' \ - '-v[verbose]' \ - '-n[do not resolve addresses to names]' \ - '-R[show extended security attributes for sockets and routing tables]' \ - - set3 \ - '-g[show multicast group memberships]' \ - '-n[do not resolve addresses to names]' \ - '-v[verbose]' \ - '-f[specify address family]:address family:(inet inet6 unix)' \ - - set4 \ - '-i[show state of interfaces]' \ - '-a[show state of all sockets, all routing tables or all interfaces]' \ - '-f[specify address family]:address family:(inet inet6 unix)' \ - '-n[do not resolve addresses to names]' \ - '-I[select interface]:interface:_net_interfaces' \ - - set5 \ - '-m[show STREAMS memory statistics]' \ - '-v[verbose]' \ - - set6 \ - '-p[show net to media tables]' \ - '-n[do not resolve addresses to names]' \ - '-f[specify address family]:address family:(inet inet6 unix)' \ - - set7 \ - '-s[show per protocol statistics]' \ - '-f[specify address family]:address family:(inet inet6 unix)' \ - '-P[specify protocol]:protocol:(ip ipv6 icmp icmpv6 igmp udp tcp rawip)' \ - - set8 \ - '-M[show multicast routing tables]' \ - '-f[specify address family]:address family:(inet inet6 unix)' \ - '-n[do not resolve addresses to names]' \ - '-s[show per protocol statistics]' \ - - set9 \ - '-D[show status of DHCP configured interfaces]' \ - '-f[specify address family]:address family:(inet inet6 unix)' \ - '-I[select interface]:interface:_net_interfaces' \ -} - -_netstat "$@" diff --git a/Completion/Unix/Command/_ack b/Completion/Unix/Command/_ack new file mode 100644 index 000000000..626e54e0f --- /dev/null +++ b/Completion/Unix/Command/_ack @@ -0,0 +1,138 @@ +#compdef ack ack2 ack-grep ack-standalone + +local curcontext="$curcontext" update_policy ign suf ret=1 +local -a state line +local -A opt_args + +_ack_types_caching_policy() { + # Rebuild if ackrc more recent than cache. + [[ -f ${ACKRC:-$HOME/.ackrc} && ${ACKRC:-$HOME/.ackrc} -nt "$1" ]] && return 0 + + # Rebuild if cache is older than one week. + local -a oldp + oldp=( "$1"(Nmw+1) ) + (( $#oldp )) && return 0 + + return 1 +} + +zstyle -s ":completion:${curcontext}:" cache-policy update_policy +[[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _ack_types_caching_policy + +typeset -ga _ack_raw_types +if _cache_invalid ack-types || ! _retrieve_cache ack-types; then + (( ${+commands[${words[1]}]} )) && _ack_raw_types=( + ${(S)${(S)${(f)${${"$(_call_program file-types $words[1] --help=types)"}#*--\[no\]}}%; first line matches \/*\/}#*no\]} ) + [[ $#_ack_raw_types -gt 0 ]] && _store_cache ack-types _ack_raw_types +fi + +(( $#words > 2 )) && ign='!' + +_arguments -C -s -S \ + '(-i --ignore-case --smart-case --no-smart-case --nosmart-case --lines)'{-i,--ignore-case}'[match case-insensitively]' \ + '(-i --ignore-case --no-smart-case --nosmart-case --lines)--smart-case[case-insensitive match unless pattern includes uppercase]' \ + '(-i --ignore-case --smart-case --no-smart-case --nosmart-case --lines)'{--no-smart-case,--nosmart-case}'[disable --smart-case option]' \ + '(-v --invert-match)'{-v,--invert-match}'[select non-matching lines]' \ + '(-w --word-regexp)'{-w,--word-regexp}'[force pattern to match only whole words]' \ + '(-Q --literal)'{-Q,--literal}'[use literal strings]' \ + '(1)*--lines=[only print specific lines of each file]:line number (list and/or range)' \ + '(-l --files-with-matches -L --files-without-matches)'{-l,--files-with-matches}"[output matching files' names only]" \ + '(-L --files-without-matches -l --files-with-matches)'{-L,--files-without-matches}"[output non-matching files' names only]" \ + '--output=[output result of expression for each line (turns off text highlighting)]:perl expression' \ + '-o[show only matching part of line]' \ + '--passthru[print all lines, whether matching or not]' \ + '(1)--match=[specify the pattern explicitly]:pattern' \ + '(-m --max-count)'{-m+,--max-count=}'[stop after specified no of matches in each file]:max number of matches' \ + '-1[stop after reporting first match of any kind]' \ + '(-H --with-filename -h --no-filename)'{-H,--with-filename}'[print filename with each match]' \ + '(-h --no-filename -H --with-filename)'{-h,--no-filename}'[suppress printing of filenames]' \ + '(-c --count)'{-c,--count}'[only print a count of matching lines]' \ + '--column[print column number of first match on each line]' \ + '(-A --after-context -C --context)'{-A+,--after-context=}'[specify lines of trailing context]::lines [2]' \ + '(-B --before-context -C --context)'{-B+,--before-context=}'[specify lines of leading context]::lines [2]' \ + '(-C --context -A --after-context -B --before-context)'{-C+,--context=}'[specify lines of context]:lines [2]' \ + '--print0[separate filenames with a null instead of a newline]' \ + '-s[suppress error messages about nonexistent or unreadable files]' \ + "(--nopager)--pager=[direct ack's output through program]: : _command_names -e" \ + "(--pager)--nopager[don't send output through a pager; overrides .ackrc, ACK_PAGER & ACK_PAGER_COLOR]" \ + '(--noheading --heading)'{--noheading,--heading}'[print a filename heading above results, default on]' \ + '(--nobreak --break)'{--nobreak,--break}'[print a break between results from different files, default on]' \ + '(--nogroup)--group[group matches by file name]' \ + "(--group)--nogroup[don't group matches by file name]" \ + '(--nocolor --nocolour)--colo'{,u}'r[enable color highlighting of output]' \ + '(--color --colour --color-filename --color-match --color-lineno)--nocolo'{,u}'r[suppress the color]' \ + '(--nocolor --nocolour --color --colour)--color-filename=[sets the color to be used for filenames]:color:->colors' \ + '(--nocolor --nocolour --color --colour)--color-match=[sets the color to be used for matches]:color:->colors' \ + '(--nocolor --nocolour --color --colour)--color-lineno=[specify color for line numbers]:color:->colors' \ + '--flush[flush output on every line]' \ + '(1)-f[only print the files that would be searched, without actually doing any searching]' \ + '(1)-g[print files where the relative path + filename matches the given pattern]:pattern to match against filenames' \ + '--sort-files[sorts the found files lexically]' \ + '--show-types[print the file types that ack associates with each file]' \ + '(--files-from -x)--files-from=[read the list of files to search from specified file]:files:_files' \ + '(-x --files-from)-x[read the list of files to search from standard input]' \ + '*--ignore-dir'{,ectory}'=[ignore directory]:directory:_directories' \ + '*--noignore-dir'{,ectory}'=[remove directory from ignored list]:directory:_directories' \ + '*--ignore-file=[add filter for ignoring files]:filter:->filters' \ + '(-r -R --recurse -n --no-recurse)'{-r,-R,--recurse}'[recurse subdirectories]' \ + '(-n --no-recurse -r -R --recurse)'{-n,--no-recurse}"[don't descend into subdirectories]" \ + '(--nofollow)--follow[follow symlinks]' \ + "(--follow)--nofollow[don't follow symlinks]" \ + '(-k --known-types)'{-k,--known-types}'[include only files of types that ack recognizes]' \ + '*--type=[specify the types of files to include or exclude from a search]:type:->file-types' \ + '*--type-'{add,set}'=[files with the given extensions are recognized as being of the given type]:type-def:->type-defs' \ + '*--type-del=[remove all filters associated with specified file type]: :->file-types' \ + '(--env)--noenv[ignore environment variables and global ackrc files]' '!(--noenv)--env)' \ + '--ackrc=[specify an ackrc file to use]:files:_files' \ + '--ignore-ack-defaults[ignore default definitions included with ack]' \ + "${ign}(- 1 *)--create-ackrc[output an ackrc based on customizations]" \ + "${ign}(- 1 *)"{-\?,--help}'[display usage information]' \ + "${ign}(- 1 *)--help-types[display all known types]" \ + "${ign}(- 1 *)--dump[display information on which options are loaded and which RC files]" \ + '(--filter --nofilter)--filter[treat standard input as pipe]' \ + '(--filter --nofilter)--nofilter[treat standard input as tty]' \ + "${ign}(- 1 *)--man[display the manual page]" \ + "${ign}(- 1 *)--version[display version and copyright information]" \ + "${ign}(- 1 *)--bar[consult Admiral Ackbar]" \ + "${ign}(- 1 *)--thpppt[bill the cat]" \ + "${ign}(- 1 *)--cathy[chocolate chocolate chocolate]" \ + {'--','--no'}${_ack_raw_types/ ##/\[}']' \ + '1: :_guard "^-*" pattern' \ + '*:file:_files' && ret=0 + +case $state in + colors) + compset -P '* ' + compset -S ' *' + _wanted colors expl color compadd \ + {,on_}{,bright_}{black,red,green,yellow,blue,magenta,cyan,white} \ + clear reset dark bold under{line,score} blink reverse concealed && ret=0 + ;; + type-defs) + if ! compset -P 1 '*:'; then + _message -e type-name 'type name' + return + fi + ;& # fall-through + filters) + if compset -P 1 'ext:'; then + _sequence _wanted extensions expl 'extension' compadd - *.*(N:e) && ret=0 + elif compset -P 1 'is:'; then + _description files expl 'file name' + _files "$expl[@]" && ret=0 + elif compset -P 1 '(firstline|)match:'; then + _message -e patterns 'pattern' + else + compset -S ':*' || suf=-S + _description filters expl filter + compadd "$expl[@]" ${suf:+-S:} ext is && ret=0 + compadd "$expl[@]" ${suf:+-S:/} match firstlinematch && ret=0 + fi + ;; + file-types) + local types; types=( {,no}${^_ack_raw_types/ ##/:} ) + _describe -t file-types 'file type' types && ret=0 + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index f05dac8a6..330ef66b7 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -30,7 +30,7 @@ case $service in '(-D --diff)'{-D,--diff}'[show differences when changing small files and templates]' '(-b --become)'{-b,--become}'[escalate privileges on remote system]' '(-f --forks)'{-f+,--forks=}'[specify number of parallel processes to use]:processes [5]' - '--become-method=[specify privilege escalation method to use]:method [sudo]:(sudo su pbrun pfexec doas dzdo ksu runas pmrun)' + '--become-method=[specify privilege escalation method to use]:method [sudo]:(sesu sudo su pbrun pfexec doas dzdo ksu runas pmrun enable)' '--become-user=[specify remote user for running operations]:user:_users' "--syntax-check[perform a syntax check on the playbook, but don't execute it]" '!(-R --su-user -U --sudo-user)'{-R,-U,--su-user,--sudo-user}':user [root]:_users' @@ -39,17 +39,20 @@ case $service in ansible|ansible-console|ansible-inventory|ansible-playbook|ansible-pull|ansible-vault) args+=( '--ask-vault-pass[ask for vault password]' - '--new-vault-id=[specify new vault identity to use for rekey]:vault id' - '--new-vault-password-file=[specify new vault password file to use for rekey]:file:_files' '--vault-id=[specify vault identity to use]:vault identity' '--vault-password-file=[specify vault password file]:vault password file:_files' ) ;| ansible|ansible-console|ansible-inventory|ansible-playbook|ansible-pull) args+=( - '--list-hosts[output list of matching hosts]' - '(-i --inventory)'{-i+,--inventory=}'[specify inventory host file]:inventory file:_files' + '(-i --inventory)'{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files" + "hosts\:host\: _sequence _hosts"' '!(-i --inventory)--inventory-file=:inventory file:_files' + ) + ;| + ansible|ansible-console|ansible-playbook|ansible-pull) + args+=( + '--list-hosts[output list of matching hosts]' '(-l --limit)'{-l+,--limit=}'[further limit hosts to an additional pattern]:host subset:->hosts' ) ;| @@ -58,21 +61,22 @@ case $service in '(-e --extra-vars)'{-e+,--extra-vars=}'[set additional variables]:key=value or YAML/JSON' ) ;| - ansible-playbook|ansible-pull) + ansible|ansible-console|ansible-inventory) args+=( - '(-t --tags)'{-t,--tags}'[only run plays and tasks tagged with these values]' - "--skip-tags[only run plays and tasks whose tags don't match]" + '--playbook-dir=[specify substitute playbook directory]:directory:_directories' ) ;| - ansible|ansible-pull) + ansible-playbook|ansible-pull) args+=( - '(-m --module-name)'{-m+,--module-name=}'[specify module]:module:->plugins' + '(-t --tags)'{-t,--tags}'[only run plays and tasks tagged with these values]' + "--skip-tags[only run plays and tasks whose tags don't match]" ) ;| ansible) args+=( '(-a --args)'{-a+,--args=}'[specify command or module arguments]:arguments:->args' '(-B --background)'{-B+,--background=}'[run asynchronously, failing after specified time]:fail timeout (seconds)' + '(-m --module-name)'{-m+,--module-name=}'[specify module]:module:->plugins' '(-o --one-line)'{-o,--one-line}'[condense output]' '(-P --poll)'{-P+,--poll=}'[specify the poll interval if using -B]:interval (seconds) [15]' '(-t --tree)'{-t+,--tree=}'[specify directory for log output]:directory:_directories' @@ -98,14 +102,16 @@ case $service in ;; ansible-doc) args+=( - '(-l --list)'{-l,--list}'[list available plugins]' - '(-s --snippet)'{-s,--snippet}'[show playbook snippet for specified plugins]' + '(-l --list -F --list_files -s --snippet)'{-l,--list}'[list available plugins]' + '(-l --list -F --list_files -s --snippet)'{-F,--list_files}'[show plugin names and their source files without summaries]' + '(-l --list -F --list_files -s --snippet)'{-s,--snippet}'[show playbook snippet for specified plugins]' '(-t --type)'{-t+,--type=}'[choose plugin type]:plugin type [module]:(cache callback connection inventory lookup module strategy vars)' '*:plugin:->plugins' ) ;; ansible-inventory) args+=( + '--export[when doing an --list, represent in a way that is optimized for export]' '(-y --yaml)--graph[output inventory graph]' '--host[output specific host information]' '--list[output all hosts information]' @@ -125,7 +131,7 @@ case $service in ;; ansible-playbook) args+=( - '--flush-cache[clear the fact cache]' + '--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]' @@ -139,6 +145,7 @@ case $service in "--check[don't make any changes]" '(-d --directory)'{-d+,--directory=}'[specify directory to checkout repository to]:directory:_directories' '--full[do a full instead of a shallow clone]' + '(-m --module-name)'{-m+,--module-name=}'[specify repository module used for checking out repository]:module:(git subversion hg bzr)' '--accept-host-key[adds the hostkey for the repo url if not already added]' '--purge[purge checkout after playbook run]' '(-f --force)'{-f,--force}'[run the playbook even if the repository could not be updated]' @@ -153,6 +160,8 @@ case $service in ;; ansible-vault) args=( -A "-*" $args + '--new-vault-id=[specify new vault identity to use for rekey]:vault id' + '--new-vault-password-file=[specify new vault password file to use for rekey]:file:_files' '*::args:->vault' ) ;; @@ -200,9 +209,15 @@ case $state in plugins) plugvar=_ansible_${plug}_plugins typeset -ga ${plug} - (( ${(P)#plugvar} )) || set -A ${plugvar} \ - ${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}/ ##/:} - _describe -t plugins "${plug} plugin" $plugvar && ret=0 + if zstyle -T ":completion:${curcontext}:plugins" verbose; then + (( ${(P)#plugvar} )) || set -A ${plugvar} \ + ${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}/ ##/:} + _describe -t plugins "${plug} plugin" $plugvar && ret=0 + else + (( ${(P)#plugvar} )) || set -A ${plugvar} \ + ${${(f)"$(_call_program plugins ansible-doc -t $plug -F)"}%% *} + _wanted plugins expl "${plug} plugin" compadd -a $plugvar && ret=0 + fi ;; galaxy) curcontext="${curcontext%:*}-${line[1]}:" @@ -265,6 +280,11 @@ case $state in curcontext="${curcontext%:*}-${line[1]}:" args=() case $line[1] in + encrypt*|edit|rekey) + args+=( + '--encrypt-vault-id=[specify vault id to use to encrypt (required if more than one vault-id is provided)]:vault id' + ) + ;| (de|en)crypt*) args=( '--output=[specify output file name]:file:_files' ) ;| encrypt_string) args+=( diff --git a/Completion/Unix/Command/_arp b/Completion/Unix/Command/_arp index 5b047b2b8..90e30d6c2 100644 --- a/Completion/Unix/Command/_arp +++ b/Completion/Unix/Command/_arp @@ -37,7 +37,7 @@ case $OSTYPE in flags+=( netmask ) ;; darwin*|freebsd*|dragonfly*) - cmds+=( '(-n -v -i)-S[create an arp entry, replacing any existing entry]' ) + cmds+=( '(-n -i)-S[create an arp entry, replacing any existing entry]' ) ;| darwin*|freebsd*) args+=( '(-s -Q -f)-i+[select an interface]:interface:_net_interfaces' ) @@ -58,7 +58,6 @@ case $OSTYPE in args+=( $vopt ) ;; freebsd*) - args+=( $vopt ) flags+=( blackhole reject ) ;; openbsd*) diff --git a/Completion/Unix/Command/_base64 b/Completion/Unix/Command/_base64 new file mode 100644 index 000000000..47a650343 --- /dev/null +++ b/Completion/Unix/Command/_base64 @@ -0,0 +1,59 @@ +#compdef base64 gbase64 base32 gbase32 + +# Note: This does NOT cover `uuencode`/`uudecode`, which on some BSD systems +# have the aliases `b64encode`/`b64decode` — those are sufficiently different +# that they belong in another function. It DOES cover GNU's `base32`, since it +# is essentially the same program as their `base64`. + +local variant type=base${service//[^2346]/} + +_pick_variant -r variant \ + gnu='Free Soft' fourmilab=fourmi darwin=-D unix --version + +case $variant in + gnu) + _arguments -s -S : \ + '(: -)--help[display help information]' \ + '(: -)--version[display version information]' \ + + dec \ + '(enc -d --decode)'{-d,--decode}"[decode input from $type]" \ + '(enc -i --ignore-garbage)'{-i,--ignore-garbage}'[ignore irrelevant characters when decoding]' \ + + '(enc)' \ + '(dec)'{-w+,--wrap=}'[wrap encoded lines at specified number of columns]:number of columns' \ + + in \ + '1:input file:_files' + return + ;; + darwin) + _arguments -s -S : \ + '(: -)'{-h,--help}'[display help information]' \ + + '(dec)' \ + '(enc)'{-D,--decode}"[decode input from $type]" \ + + '(enc)' \ + '(dec)'{-b+,--break=}'[wrap encoded lines at specified number of columns]:number of columns' \ + + '(out)' \ + {-o+,--output=}'[specify output file]:output file:_files' \ + + '(in)' \ + {-i+,--input=}'[specify input file]:input file:_files' \ + '1:input file:_files' + return + ;; + fourmilab) + _arguments -s -S : \ + '(: -)--copyright[display copyright information]' \ + '(: -)'{-u,--help}'[display help information]' \ + '(: -)--version[display version information]' \ + + dec \ + '(enc -d --decode)'{-d,--decode}"[decode input from $type]" \ + '(enc -n --noerrcheck)'{-n,--noerrcheck}'[ignore errors when decoding]' \ + + '(enc)' \ + '(dec)'{-e,--encode}"[encode input to $type]" \ + + io \ + '1:input file:_files' \ + '2:output file:_files' + return + ;; +esac + +# A few other implementations exist, though they are rarely encountered +_default diff --git a/Completion/Unix/Command/_bash b/Completion/Unix/Command/_bash new file mode 100644 index 000000000..cc219f788 --- /dev/null +++ b/Completion/Unix/Command/_bash @@ -0,0 +1,85 @@ +#compdef bash + +local ret=1 +local -a context line state state_descr args tmp cmd +local -A opt_args val_args + +cmd=( $words[1] --noprofile --norc ) + +args=( + # Long options must appear before short options (take care — some of these are + # duplicated in the s group below!) + + l + '!--debug' + '--debugger[enable extended debugging mode]' + '(-D --dump-po-strings --dump-strings)--dump-po-strings[like -D, but display in gettext PO format]' + '(-D --dump-po-strings --dump-strings)--dump-strings[display strings subject to language translation]' + '(: -)--help[display help information]' + # The usual = is deliberately omitted here + '(--init-file --rcfile)'{--init-file,--rcfile}'[load specified file instead of ~/.bashrc]: :_files' + '(-l --login)--login[act as login shell]' + '--noediting[disable readline editing]' + '--noprofile[do not load /etc/profile, ~/.bash_profile, etc.]' + '--norc[do not load ~/.bashrc]' + '--posix[enable POSIX mode]' + '(-r --restricted)--restricted[act as restricted shell]' + '(: -)--version[display version information]' + # This is ugly, but this way the + variants have accurate descriptions. Note + # that bash does accept + variants of -i, -l, -s, etc., but they don't seem to + # actually do anything, so we don't bother with them + + s + '(l)'{'-a[','+a[do not '}'mark all functions and variables for export]' + '(l)'{'-B[','+B[do not '}'enable brace expansion]' + '(l)'{'-b[','+b[do not '}'report status of terminated background jobs immediately]' + '(l)'{'-C[','+C[do not '}'prevent output redirection from overwriting existing files]' + '(l 1 -)-c[execute specified command string]:command string:_cmdstring:argv[0]:' + '(l)-D[display strings subject to language translation]' + '(l)'{'-E[','+E[do not '}'make functions and subshells inherit ERR traps]' + '(l)'{'-e[','+e[do not '}'exit immediately on non-zero return]' + '(l)'{'-f[','+f[do not '}'disable file globbing]' + '(l)'{'-H[','+H[do not '}'enable history substitution]' + '(l)'{'-h[','+h[do not '}'hash commands]' + '(l)-i[act as interactive shell]' + '(l)'{'-k[','+k[do not '}'act on variable assignments in command arguments]' + '(l)-l[act as login shell]' + '(l)'{'-m[','+m[do not '}'enable job control]' + '(l)'{'-n[','+n[do not '}'read (syntax-check) commands only]' + '(l)*'{'-O[','+O[un'}'set specified `shopt` option]: :->shopt-options' + '(l)*'{'-o[','+o[un'}'set specified `set` option]: :->set-options' + '(l)'{'-P[','+P[do not '}'resolve cd paths]' + '(l)'{'-p[','+p[do not '}'enable privileged mode]' + '(l)-r[act as restricted shell]' + '(l 1 -c)-s[read commands from standard input]' + '(l)'{'-T[','+T[do not '}'make functions and subshells inherit DEBUG and RETURN traps]' + '(l)'{'-t[','+t[do not '}'exit after executing one command]' + '(l)'{'-u[','+u[do not '}'treat unset variables as an error during parameter expansion]' + '(l)'{'-v[','+v[do not '}'print shell input lines as they are read]' + '(l)'{'-x[','+x[do not '}'print command trace]' + + o + '(-)1:script file:_files' + '(-)*:: :->args' +) + +_arguments -s -S -A '-*' : $args && ret=0 + +case $state in + args) + if [[ -n ${opt_args[(i)s--[cs]]} ]]; then + _files && ret=0 + else + _normal && ret=0 + fi + ;; + set-options) + tmp=( ${(f)"$( _call_program set-options $cmd -c '"shopt -o"' )"} ) + tmp=( ${tmp%%[[:space:]]*} ) + _values -w '`set` option' $tmp && ret=0 + ;; + shopt-options) + tmp=( ${(f)"$( _call_program shopt-options $cmd -c shopt )"} ) + tmp=( ${tmp%%[[:space:]]*} ) + _values -w '`shopt` option' $tmp && ret=0 + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_chroot b/Completion/Unix/Command/_chroot new file mode 100644 index 000000000..516992694 --- /dev/null +++ b/Completion/Unix/Command/_chroot @@ -0,0 +1,53 @@ +#compdef chroot gchroot + +local variant ret=1 +local -a context line state state_descr args +local -A opt_args + +_pick_variant -r variant gnu='Free Soft' unix --version + +variant+=-$OSTYPE + +case $variant in + gnu-*) + args=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' + '--groups=[specify supplemental group memberships]: :_sequence -s , _groups' + '--userspec=[specify user and group to run process as]: :->userspecs' + '--skip-chdir[do not change working directory to /]' + ) + ;; + *-openbsd*) + args=( + '-u+[specify user to run process as]: :_users' + '-g+[specify group to run process as, and supplemental group memberships]: :_sequence -s , _groups' + ) + ;; + *-(darwin|dragonfly|freebsd|netbsd)*) + args=( + '-u+[specify user to run process as]: :_users' + '-g+[specify group to run process as]: :_groups' + '-G+[specify supplemental group memberships]: :_sequence -s , _groups' + ) + ;; +esac + +args+=( '1:new root directory:_directories' '*:::command:_normal' ) + +_arguments -s -S : $args && ret=0 + +# @todo user:group specs are probably used often enough to justify making a type +# function for this (see also `chown`, `cpio`, `rsync`, ...) +[[ $state == userspecs ]] && +if compset -P '*:*:'; then + ret=1 +elif compset -P '*:'; then + _groups && ret=0 +elif compset -S ':*'; then + _users && ret=0 +else + _users -qS : && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_cksum b/Completion/Unix/Command/_cksum new file mode 100644 index 000000000..bb2f60ac7 --- /dev/null +++ b/Completion/Unix/Command/_cksum @@ -0,0 +1,112 @@ +#compdef cksum gcksum sum gsum md2 md4 md5 rmd160 sha1 sha256 sha384 sha512 sha512t256 skein256 skein512 skein1024 + +# This function covers mostly the BSD `cksum`, `sum`, and digest utilities. It +# also covers the GNU Coreutils `cksum` and `sum`. For the GNU digest utilities, +# see `_md5sum`. For the `shasum` Perl script, see `_shasum`. +# +# Notes: +# - We really don't do a very good job of handling option exclusivity here. In +# particular, OpenBSD treats -t and -x as exclusive of each other and most +# other options — but there are issues with other variants too (@todo) +# - Although only OpenBSD's documentation mentions it, -t can be supplied +# multiple times with all variants to run additional rounds of testing +# - All digest variants on a given platform share code, but not all variants are +# found on all platforms (e.g., Darwin only has `md5`). Some BSDs are actively +# purging legacy/insecure digest tools +# - The documentation for Dragonfly/FreeBSD `sum` says that it's 'identical to' +# `cksum`, but, as the synopsis confirms, it doesn't take any options +# - FreeBSD's -c is never useful, and Dragonfly's -b/-e are *almost* never +# useful, with multiple input files +# - NetBSD's -n isn't useful with `sum` and `cksum` unless a digest is specified +# with -a. Similarly, OpenBSD's -b isn't useful with `cksum` without -a +# - OpenBSD's -a option allows you to add a b/x suffix to each algorithm name; +# we don't handle that. Also, only one -a option can be used in conjunction +# with -c; we don't handle that either + +local -a args + +_pick_variant gnu='Free Soft' unix --version && { + args=( + '*: :_files' + '(: -)--help[display help information]' + '(: -)--version[display version information]' + ) + [[ $service == *cksum* ]] || args+=( + '(-s --sysv)-r[use BSD algorithm (1 KiB blocks)]' + '(-r -s --sysv)'{-s,--sysv}'[use System V algorithm (512 B blocks)]' + ) + _arguments -s -S : $args + return +} + +[[ $OSTYPE == (darwin|dragonfly|freebsd|openbsd)* && $service == sum ]] && { + _default + return +} + +[[ $OSTYPE == (darwin|dragonfly|freebsd)* && $service == cksum ]] && { + _arguments -s -S -A '-*' \ + '-o[use specified historic algorithm]:historic algorithm:(1 2 3)' \ + '*: :_files' + return +} + +case $OSTYPE in + darwin*|dragonfly*|freebsd*|netbsd*) + args+=( + '(-n -p -r)-q[output checksums only]' + ) + ;| # MATCH AGAIN + darwin*|dragonfly*|freebsd*|openbsd*) + args+=( + '(-p -q)-r[reverse output format]' + ) + ;| # MATCH AGAIN + netbsd*|openbsd*) + args+=( + '-c[verify checksums from input files]' + ) + ;| # MATCH AGAIN + dragonfly*) + args+=( + '-b+[begin processing files at specified offset]:begin offset (bytes)' + '-e+[end processing files at specified offset]:end offset (bytes)' + ) + ;; + freebsd*) + args+=( + '-c+[verify input against specified digest string]:digest string' + ) + ;; + netbsd*) + args+=( + '(-p -q)-n[reverse output format]' + '(-p)-w[warn on malformed checksum files]' + ) + [[ $service == (|ck)sum ]] && args+=( + '(-o)-a+[use specified algorithm]:algorithm:(crc md2 md4 md5 old1 old2 rmd160 sha1 sha256 sha384 sha512)' + '(-a)-o+[use specified historic algorithm]:historic algorithm:(1 2)' + ) + ;; + openbsd*) + args+=( + '-b[output in base64]' + '(-h)-C+[verify input files against checksums in specifed file]:checksum file:_files' + '(-C)-h+[output checksums to specified file]:checksum file:_files' + '(-n -r)-q[output checksum only, or suppress check success messages]' + ) + [[ $service == cksum ]] && args+=( + '*-a+[use specified algorithm(s)]:algorithm:_values -s , algorithm cksum md5 rmd160 sha1 sha224 sha256 sha384 sha512/256 sha512' + ) + ;; +esac + +args+=( + '-p[output stdin along with checksum]' + '*-s+[checksum specified string]:string' + '*-t[run built-in time trial(s)]' + '-x[run built-in tests]' + '*: :_files' +) + +_arguments -s -S -A '-*' : $args diff --git a/Completion/Unix/Command/_comm b/Completion/Unix/Command/_comm index d1d835f6a..f8c535a44 100644 --- a/Completion/Unix/Command/_comm +++ b/Completion/Unix/Command/_comm @@ -1,6 +1,6 @@ #compdef comm gcomm -local -a args +local -a args aopts=( -A '-*' ) args=( '-1[suppress lines unique to first file]' @@ -11,10 +11,13 @@ args=( ) if _pick_variant gnu=GNU unix --version; then + aopts=( ) args+=( '(--nocheck-order)--check-order[check input is correctly sorted]' "(--check-order)--nocheck-order[don't check input is correctly sorted]" - '--output-delimiter=:delimiter' + '--output-delimiter=[specify column delimiter]:delimiter' + '--total[display summary]' + '(-z --zero-terminated)'{-z,--zero-terminated}'[use NUL as line delimiter]' '(- : *)--version[display version information]' '(- : *)--help[display help information]' ) @@ -24,4 +27,4 @@ elif [[ $OSTYPE = (openbsd|netbsd)* ]]; then args+=( '-f[case insensitive comparison of lines]' ) fi -_arguments -s $args +_arguments -s -S $aopts : $args diff --git a/Completion/Unix/Command/_crontab b/Completion/Unix/Command/_crontab new file mode 100644 index 000000000..cda7549a1 --- /dev/null +++ b/Completion/Unix/Command/_crontab @@ -0,0 +1,68 @@ +#compdef crontab + +# Notes: +# - We assume a cronie-, dcron-, or Vixie-esque crontab +# - BusyBox crontab is forked from dcron +# - Generally only the super-user can use -c/-u; we aren't that restrictive +# - @todo As usual, BusyBox multi-call isn't handled + +local variant sluser +local -a args etargs ccargs clargs rcargs aopts + +_pick_variant -r variant \ + dcron='-c*(#i)dir' \ + cronie-selinux='(#i)selinux' \ + cronie='(#i)cluster' \ + unix --help +variant+=-$OSTYPE + +# On Solaris, instead of using -u, the user can be specified as an optional +# first operand with -e/-l/-r. We'll treat it as an optional *argument* to one +# of those options, though, since the logic is a bit simpler +if [[ $variant == *-solaris* ]]; then + sluser='::user whose crontab to work with:_users' +else + etargs+=( '(cl)-u+[specify user whose crontab to work with]: :_users' ) +fi + +case $variant in + dcron-*) + etargs+=( '-c+[specify crontab directory]:crontab directory:_directories' ) + ;; + cronie-selinux-*) + ccargs+=( '(-l cl nc rc)-s[append SELinux context (with -e)]' ) + ;& # FALL THROUGH + cronie-*) + etargs+=( '(: * -)-V[display version information]' ) + clargs+=( + '(: * -)-c[display cluster host]' + '(: * -)-n+[specify cluster host]: :_hosts' + ) + ;& # FALL THROUGH + *-linux*) + rcargs+=( '(cc cl nc)-i[prompt for confirmation (with -r)]' ) + ;; + *-freebsd*) + rcargs+=( '(cc cl nc)-f[bypass confirmation prompt (with -r)]' ) + ;; +esac + +(( $#etargs )) && args+=( + et $etargs ) # Misc. +(( $#clargs )) && args+=( + cl $clargs ) # Work with cluster +args+=( + + nc # Install new crontab + '(cc cl rc sl):crontab to install:_files' + + cc # Edit/display current crontab + "(-l cl nc rc)-e[edit current crontab]$sluser" + "(-e -s cl nc rc)-l[display current crontab]$sluser" + $ccargs + + rc # Remove current crontab + "(cc cl nc)-r[remove current crontab]$sluser" + $rcargs +) + +# Implementations that use GNU's getopt(3) probably support permutation; this +# should be accurate enough +[[ $OSTYPE == linux* ]] || aopts=( -A '-*' ) + +_arguments -s -S $aopts : $args diff --git a/Completion/Unix/Command/_dd b/Completion/Unix/Command/_dd index e51337f21..e5c5e63ce 100644 --- a/Completion/Unix/Command/_dd +++ b/Completion/Unix/Command/_dd @@ -1,17 +1,99 @@ #compdef dd gdd -_values -w 'option' \ - 'if[specify input file]:input file:_tilde_files' \ - 'of[specify output file]:output file:_tilde_files' \ - '(bs)ibs[input block size]:block size (bytes)' \ - '(bs)obs[output block size]:block size (bytes)' \ - '(ibs obs)bs[block size]:block size (bytes)' \ - 'cbs[conversion buffer size]:buffer size (bytes)' \ - 'skip[input blocks initially skipped]:blocks' \ - 'seek[output blocks initially skipped]:blocks' \ - 'files[specify number of input files to copy and concatenate]:number of files' \ - 'count[number of input blocks to copy]:blocks' \ - 'conv[specify conversions to apply]:conversion:_values -s , conversion - "(ebcdic ibm)ascii" "(ascii ibm)ebcdic" "(ascii ebcdic)ibm" - "(unblock)block" "(block)unblock" - "(ucase)lcase" "(lcase)ucase" swab noerror sync' +local -a vals conv flags +local variant + +_pick_variant -r variant gnu=GNU $OSTYPE --version + +vals=( + '(ibs obs)bs[block size]:block size (bytes)' + 'cbs[conversion buffer size]:buffer size (bytes)' + 'conv[specify conversions to apply]: :_values -s , conversion $conv' + 'count[number of input blocks to copy]:blocks' + '(bs)ibs[input block size]:block size (bytes)' + 'if[specify input file]:input file:_tilde_files' + '(bs)obs[output block size]:block size (bytes)' + 'of[specify output file]:output file:_tilde_files' + 'seek[output blocks initially skipped]:blocks' + 'skip[input blocks initially skipped]:blocks' +) +conv=( + '(ascii asciib oldascii ebcdic ebcdicb oldebcdic ibm ibmb oldibm)'{ascii,ebcdic,ibm} + '(unblock)block' '(block)unblock' + '(ucase)lcase' '(lcase)ucase' + swab sync noerror notrunc +) + +case $variant in + ^gnu) + vals+=( + 'files[specify number of input files to copy and concatenate]:number of files' + ) + ;| + (gnu|darwin|dragonfly|(free|net)bsd*) + conv+=( sparse ) + ;| + gnu|netbsd*) + vals+=( + '*iflag[specify read flags]:flag:_sequence compadd - $flags' + '*oflag[specify write flags]:flag:_sequence compadd - $flags' + ) + flags=( append direct directory dsync sync nonblock noctty nofollow ) + ;| + darwin*|dragonfly*|(free|net)bsd*) + vals+=( + 'oseek[output blocks initially skipped]:blocks' + ) + conv+=( + '(ascii oldascii ebcdic oldebcdic oldibm)'old{ascii,ebcdic,ibm} + ) + ;| + (darwin|dragonfly|freebsd|netbsd|solaris)*) + vals+=( + 'iseek[input blocks initially skipped]:blocks' + ) + ;| + (open|free)bsd*) + vals+=( + 'status[specify level of information to print to stderr]:level:(none noxfer)' + ) + conv+=( osync ) + ;| + + freebsd*) + vals+=( + 'fillchar[specify padding character]:character' + 'speed[limit copying speed]:speed (bytes/second)' + ) + conv+=( + '(pareven parnone parodd parset)'{pareven,parnone,parodd,parset} + ) + ;; + gnu) + vals+=( + 'status[specify level of information to print to stderr]:level:(none noxfer progress)' + ) + flags+=( fullblock noatime nocache count_bytes skip_bytes seek_bytes ) + conv+=( excl nocreat fdatasync fsync ) + ;; + netbsd*) + vals+=( + 'msgfmt[specify format for information summary]:format:(quiet posix human)' + 'progress[enable progress display]:enable:(1)' + ) + flags+=( + wronly rdwr creat trunc excl shlock exlock cloexec nosigpipe rsync alt_io async + ) + ;; + solaris*) + vals+=( + 'files[specify number of input files to copy and concatenate]:number of files' + 'oseek[output blocks initially skipped (via seek, not NUL-padding)]:blocks' + ) + conv+=( + '(ascii asciib ebcdic ebcdicb ibmb)'{ascii,ebcdic,ibm}b + ) + ;; +esac + +_values -w 'option' $vals diff --git a/Completion/Unix/Command/_df b/Completion/Unix/Command/_df index 2586f4358..a31145cd4 100644 --- a/Completion/Unix/Command/_df +++ b/Completion/Unix/Command/_df @@ -28,32 +28,63 @@ if _pick_variant gnu=GNU unix --version; then {-H,--si}'[human readable format, but use powers of 1000 not 1024]' {-i,--inodes}'[list inode information instead of block usage]' ) -elif [[ "$OSTYPE" == (darwin|freebsd|dragonfly)* ]]; then +elif [[ "$OSTYPE" == (darwin|dragonfly|freebsd|netbsd*|openbsd)* ]]; then args=( - '(-b -g -H -h -k -m)-b[use 512-byte blocks (default)]' - '(-b -g -H -h -k -m)-g[use 1024^3-byte blocks]' - '(-b -g -H -h -k -m)-H[human-readable output (base 10)]' - '(-b -g -H -h -k -m)-h[human-readable output (base 2)]' - '(-b -g -H -h -k -m)-k[use 1024-byte blocks]' - '(-b -g -H -h -k -m)-m[use 1024*1024-byte blocks]' - '-P[POSIX compliant output]' - '-a[show all mount points]' - '-c[display a grand total]' - '-i[include inode usage statistics (default)]' + '(-b -g -H -h -k -m --si)-h[human-readable output (base 2)]' + '(-b -g -H -h -k -m --si)-k[use 1024-byte blocks]' + '(-G -i -P)-P[POSIX compliant output]' + '(-G -i -P)-i[include inode usage statistics (default)]' '-l[only display locally-mounted file systems]' '-n[use previously obtained statistics]' '*:files:_umountable' ) spec='[only display file systems of specified types]:file system type:->fslist' case "$OSTYPE" in + (darwin*|dragonfly*|freebsd*|netbsd*) + args+=( + '-a[show all mount points]' + '(-b -g -H -h -k -m --si)-g[use 1024^3-byte blocks]' + '(-b -g -H -h -k -m --si)-m[use 1024*1024-byte blocks]' + ) + ;| + (darwin*|dragonfly*|freebsd*) + args+=( + '(-b -g -H -h -k -m --si)-b[use 512-byte blocks (default)]' + '(-b -g -H -h -k -m --si)-H[human-readable output (base 10)]' + ) + ;| + (darwin*|freebsd*) + args+=( + '-c[display a grand total]' + ) + ;| (darwin*) args+=( "-T+$spec" "!-t+$spec" # obsolete ) ;; - (freebsd*|dragonfly*) - args+=( "-t+$spec" '-T[include file system type]' ) + (dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + "-t+$spec" + ) + ;| + (dragonfly*|freebsd*) + args+=( + '-T[include file system type]' + ) + ;| + (freebsd*) + args+=( + '--libxo[generate output via libxo]' + '(-b -g -H -h -k -m --si)--si[human-readable output (base 10)]' + '-,[separate thousands]' + ) + ;; + (netbsd*) + args+=( + '(-G -i -P)-G[display all fields in statvfs]' + ) ;; esac else diff --git a/Completion/Unix/Command/_diff3 b/Completion/Unix/Command/_diff3 new file mode 100644 index 000000000..524507ce0 --- /dev/null +++ b/Completion/Unix/Command/_diff3 @@ -0,0 +1,46 @@ +#compdef diff3 + +local -a args ed +local ign + +if _pick_variant gnu=GNU unix; then + ed=( + '(-m --merge -A --show-all)'{-e,--ed}'[output ed script for incorporating changes]' + '(-m --merge -A --show-all)'{-E,--show-overlap}'[like -e, but bracket conflicts]' + '(-m --merge -A --show-all)'{-3,--easy-only}'[like -e, but incorporate only nonoverlapping changes]' + '(-m --merge -A --show-all)'{-x,--overlap-only}'[like -e, but incorporate only overlapping changes]' + '(-m --merge -A --show-all)-X[like -x, but bracket conflicts]' + ) + (( $#words > 2 )) && ign='!' + args=( + '(-A --show-all ed)'{-A,--show-all}'[output all changes, bracketing conflicts]' + "(-m --merge)-i[append 'w' and 'q' commands to ed scripts]" + '(-m --merge -i ed)'{-m,--merge}'[output merged file instead of ed script]' + '(-a --text)'{-a,--text}'[treat all files as text]' + '--strip-trailing-cr[strip trailing carriage return on input]' + '(-T --initial-tab)'{-T,--initial-tab}'[make tabs line up by prepending a tab]' + '--diff-program=[specify program to compare files]: : _command_names -e' + \*{-L+,--label=}'[use specified label instead of file name]:label' + "$ign(-)--help[display usage information]" + "$ign(-)"{-v,--version}'[display version information]' + ) +else + args=( -A "-*" ) + ed=( + '-e[output ed script for incorporating changes]' + '-E[like -e, but bracket conflicts]' + '-x[like -e, but incorporate only overlapping changes]' + '-X[like -x, but bracket conflicts]' + '-3[like -e, but incorporate only nonoverlapping changes]' + ) + if [[ $OSTYPE != solaris* ]]; then # likely the openbsd diff3 implementation + args+=( '-a[treat all files as text]' ) + fi +fi + +_arguments -s -S $args \ + '1: : _wanted files expl "first updated file (${${(As.:.)opt_args[-L]}[1]:-mine})" _files' \ + '2: : _wanted files expl "original file (${${(As.:.)opt_args[-L]}[2]:-old})" _files' \ + '3: : _wanted files expl "second updated file (${${(As.:.)opt_args[-L]}[3]:-their})" _files' \ + + '(ed)' $ed + diff --git a/Completion/Unix/Command/_dtruss b/Completion/Unix/Command/_dtruss new file mode 100644 index 000000000..bd1ae8bc5 --- /dev/null +++ b/Completion/Unix/Command/_dtruss @@ -0,0 +1,18 @@ +#compdef dtruss + +_arguments -s : \ + '-a[print all details]' \ + '-b+[specify dynamic variable buffer size]:buffer size (default 4m)' \ + '-c[print system call counts]' \ + '-d[print relative timestamps]' \ + '-e[print elapsed times]' \ + '-f[follow children as they are forked]' \ + '-l[force printing of pid/lwpid per line]' \ + "-L[don't print pid/lwpid per line]" \ + '(-p :)-n+[examine processes with the specified name]: : _process_names -a' \ + '-o[print on-cpu times]' \ + '-s[print stack backtraces]' \ + '(-n :)-p+[examine process with the specified pid]: : _pids' \ + '-t+[examine only the specified syscall]: : _sys_calls' \ + '1: : _command_names -e' \ + '*:: : _normal' diff --git a/Completion/Unix/Command/_du b/Completion/Unix/Command/_du index e812b635e..711f43471 100644 --- a/Completion/Unix/Command/_du +++ b/Completion/Unix/Command/_du @@ -6,7 +6,7 @@ if _pick_variant gnu=Free\ Soft unix --version /dummy/no-such-file; then _arguments -s \ '(-a --all -s --summarize)'{-a,--all}'[write counts for all files]' \ '--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)'{-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]' \ '(-H -D --dereference-args -L --dereference -P --no-dereference)'{-H,-D,--dereference-args}'[dereference arguments that are symlinks]' \ @@ -64,7 +64,7 @@ else '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]' \ - 'freebsd*' '(-h -k -m -g)-B[block size]:block size (bytes)' \ + 'freebsd*' '(-h -k -m -g)-B+[block size]:block size (bytes)' \ '(darwin|*bsd|dragonfly)*' '-c[display grand total]' \ 'freebsd*' '-l[count sizes many times if hard linked]' \ '(freebsd|netbsd)*' '-n[ignore files and directories with nodump flag set]' \ diff --git a/Completion/Unix/Command/_ed b/Completion/Unix/Command/_ed new file mode 100644 index 000000000..50d2710fc --- /dev/null +++ b/Completion/Unix/Command/_ed @@ -0,0 +1,38 @@ +#compdef ed + +local -a args + +args=( + '(-p --prompt)'{-p+,--prompt=}'[specify prompt]:prompt:' + '(-s --quiet --silent)'{-s,--quiet,--silent}'[suppress diagnostics]' +) + +if _pick_variant gnu=GNU unix --version; then + args+=( + '(-G --traditional)'{-G,--traditional}'[run in compatibility mode]' + '(- :)'{-h,--help}'[display help]' + '(-l --loose-exit-status)'{-l,--loose-exit-status}'[exit 0 even if a command fails]' + '(-r --restricted)'{-r,--restricted}'[run in restricted mode]' + '(- :)'{-V,--version}'[display version]' + '(-v --verbose)'{-v,--verbose}'[be verbose]' + ) +else + args=(-A '-*' ${args:#*\)--*}) + case $OSTYPE in + dragonfly*|freebsd*|netbsd*|solaris*) + args+=( + '-x[prompt for an encryption key]' + ) + ;| + netbsd*) + args+=( + '-E[enable extended regular expressions]' + '-S[disable ! command]' + ) + ;; + esac +fi + +_arguments -s -S \ + $args \ + ':file:_files' diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc index a552bb2db..5b97b8c30 100644 --- a/Completion/Unix/Command/_gcc +++ b/Completion/Unix/Command/_gcc @@ -339,17 +339,32 @@ h8/300) esac if [[ "$service" = clang* ]]; then - args=( - $args - -flto -emit-llvm + args+=( + "-flto=-[generate output files suitable for link time optimization]::style:(full thin)" + -emit-llvm "-Qunused-arguments[don't emit warning for unused driver arguments]" --analyze -fshow-column -fshow-source-location -fcaret-diagnostics -fdiagnostics-fixit-info -fdiagnostics-parseable-fixits -fdiagnostics-print-source-range-info -fprint-source-range-info -fdiagnostics-show-option -fmessage-length + "-nostdinc[Do not search standard system directories or compiler builtin directories for include files]" + "-nostdlibinc[Do not search standard system directories for include files]" + "-nobuiltininc[Do not search builtin directory for include files]" + ) +else + args+=( + '-flto=-[Enable link-time optimization]::jobs:' ) fi +local -a sanitizers + sanitizers=( + address alignment bool bounds enum float-cast-overflow float-divide-by-zero + integer-divide-by-zero memory nonnull-attribute null nullability-arg nullability-assign + nullability-return object-size pointer-overflow return unsigned-integer-overflow + returns-nonnull-attribute shift signed-integer-overflow unreachable vla-bound vptr + ) + local -a languages languages=( c c-header cpp-output @@ -367,7 +382,6 @@ languages=( # generic options (from --help) args+=( - -a -C -H -P -s '-###[print commands to run this compilation]' '-o:output file:_files -g "^*.(c|h|cc|C|cxx)(-.)"' '-x[Specify the language of the following input files]:input file language:('"$languages"')' @@ -379,6 +393,10 @@ args+=( '*-A-:define assertion:' '*-D-:define macro:' '*-U-:undefine macro:' + '-C[do not discard comments during preprocess]' + '-CC[do not discard comments, including macro expansion]' + '-P[inhibit generation of linkemakers during preprocess]' + '-H[print name of each header file used]' '-E[Preprocess only; do not compile, assemble or link]' '-S[Compile only; do not assemble or link]' '-c[Compile and assemble, but do not link]' @@ -399,7 +417,7 @@ args+=( '-print-file-name=-[Display the full path to library <library>]:library:->library' '-print-prog-name=-[Display the full path to compiler component <program>]:program:' '*-specs=-[Override built-in specs with the contents of <file>]:file:_files' - '-std=-[assume that the input sources are for specified standard]:standard:(c90 c89 c99 c11 gnu90 gnu89 gnu99 gnu11 c++98 c++03 gnu++98 gnu++03 c++11 gnu++11 c++1y gnu++1y c++14 gnu++14 c++1z gnu++1z c++17 gnu++17 c++2a gnu++2a)' + '-std=-[assume that the input sources are for specified standard]:standard:(c90 c89 iso9899\:1990 iso9899\:199409 c99 iso9899\:1999 c11 iso9899\:2011 gnu90 gnu89 gnu99 gnu11 c++98 c++03 gnu++98 gnu++03 c++11 gnu++11 c++1y gnu++1y c++14 gnu++14 c++1z gnu++1z c++17 iso9899\:2017 gnu++17 c++2a gnu++2a)' '*-include:include file:_files -g \*.h\(-.\)' '*-imacros:macro input file:_files -g \*.h\(-.\)' '*-idirafter:second include path directory:_files -/' @@ -950,7 +968,7 @@ args+=( args+=( '-nostartfiles[Do not use the standard system startup files when linking]' '-nodefaultlibs[Do not use the standard system libraries when linking]' - '-nostdlib[Do not use the standard system startup files or libraries when linking]' + '-nostdlib[Do not use standard system startup files or libraries when linking]' '-rdynamic[Pass the flag -export-dynamic to the ELF linker, on targets that support it]' '-s[Remove all symbol table and relocation information from the executable]' '-static[On systems that support dynamic linking, this prevents linking with the shared libraries]' @@ -1034,7 +1052,6 @@ args+=( '-flto-odr-type-merging[Merge C++ types using One Definition Rule]' '-flto-partition=-[Partition symbols and vars at linktime based on object files they originate from]:partitioning algorithm:(1to1 balanced max one none)' '-flto-report[Report various link-time optimization statistics]' - '-flto=-[Enable link-time optimization]::jobs:' '-fmax-errors=-[Maximum number of errors to report]:errors: ' '-fmem-report-wpa[Report on permanent memory allocation in WPA only]' '-fmem-report[Report on permanent memory allocation]' @@ -1061,7 +1078,7 @@ args+=( '-freciprocal-math[Same as -fassociative-math for expressions which include division]' '-frecord-gcc-switches[Record gcc command line switches in the object file]' '-free[Turn on Redundant Extensions Elimination pass]' - '-fsanitize=-[Enable AddressSanitizer, a memory error detector]:style:(address thread)' + "-fsanitize=-[Enable AddressSanitizer, a memory error detector]:style:($sanitizers)" '-fsched-stalled-insns-dep=-[Set dependence distance checking in premature scheduling of queued insns]:instructions: ' '-fsched-stalled-insns=-[Set number of queued insns that can be prematurely scheduled]:instructions: ' '-fsched-verbose=-[Set the verbosity level of the scheduler]:verbosity: ' diff --git a/Completion/Unix/Command/_gdb b/Completion/Unix/Command/_gdb index 510e6f1fa..18f797633 100644 --- a/Completion/Unix/Command/_gdb +++ b/Completion/Unix/Command/_gdb @@ -5,12 +5,12 @@ local cur="$words[CURRENT]" prev w list ret=1 expl [[ "$PREFIX" = --* ]] && _arguments -- '*=(CORE|SYM)FILE:core file:_files' \ '*=EXECFILE:executable:_files -g \*\(-\*\)' \ - '*=TTY:terminal device:_ttys' && return 0 + '*=TTY: :_ttys -o' && return 0 if compset -P '-(cd|directory)='; then _files -/ elif compset -P '-tty='; then - _wanted devices expl 'terminal device' _ttys + _ttys -o elif compset -P '-(exec|se)='; then _description files expl executable _files "$expl[@]" -g '*(-*)' diff --git a/Completion/Unix/Command/_ghostscript b/Completion/Unix/Command/_ghostscript new file mode 100644 index 000000000..2c6f40a35 --- /dev/null +++ b/Completion/Unix/Command/_ghostscript @@ -0,0 +1,121 @@ +#compdef gs ghostscript + +local -a specs names device + +device=( ${${path[1,CURRENT-1]}[(R)-sDEVICE=*]} ) + +if compset -N '-[-+@]'; then + if [[ CURRENT -eq 1 ]]; then + _pspdf + else + _message -e arguments 'userdict ARGUMENTS' + return 1 + fi +elif compset -P '@'; then + _files +else + local curcontext="$curcontext" state line expl ret=1 + typeset -A opt_args + + _x_arguments -C \ + '-q[quiet startup]' \ + '-g-[set device size]:device size (<width>x<height>):' \ + '-r-[set resolution]:resolution (<val> or <x>x<y>):' \ + '-I+[add to library file search path]:directory:_dir_list' \ + \*-{d,D}'-[define name with definition]:def:->dname' \ + \*-{s,S}'-[define name with value]:def:->sname' \ + '-u[undefine name, cancelling -d or -s]:name:->uname' \ + '-P[look first in the current directory for library files]' \ + '-c[specify postscript code]:*[-@]*:postscript (-f to end)' \ + '-o+[specify OutputFile and enable -dPATCH and -dNOPAUSE options]: :->outfile' \ + '(- *)-'{h,\?}'[display useful options and available devices]' \ + '!-f-:PostScript or PDF file:_pspdf' \ + '*:PostScript or PDF file:_pspdf' && ret=0 + + [[ $state = sname ]] && compset -P '(stdout|OutputFile)=' && state=outfile + case "$state" in + dname) + if [[ "$PREFIX" = *\=* ]]; then + _message -e definition-values 'systemdict definition value' + else + names=( ${${(f)"$($words[1] -q -o /dev/null -DNODISPLAY -c 'systemdict { type /booleantype eq { = } if } forall')"}:#*[a-z]*} ) + _wanted boolean-definitions expl 'systemdict boolean definition' compadd -M 'm:{a-z}={A-Z}' -a names && ret=0 + names=( FirstPage LastPage + $($words[1] -q -o /dev/null $device -DNODISPLAY -c 'currentpagedevice { type /integertype eq { = } if } forall') ) + _wanted integer-definitions expl 'currentpagedevice integer definition' compadd -S = -M 'm:{a-z}={A-Z}' -a names && ret=0 + fi + ;; + sname) + if compset -P 1 '*='; then + case "$IPREFIX" in + *DEVICE\=) + _wanted devices expl 'ghostscript device' \ + compadd - ${(0)"$($words[1] -q -o /dev/null -DNODISPLAY -c 'devicenames { dup length string cvs print (\0) print } forall')"} && ret=0 + ;; + *PAPERSIZE=) + names=( $($words[1] -q -o /dev/null -DNODISPLAY -c 'statusdict /.pagetypenames get { = } forall ') ) + _description paper-sizes expl 'paper size' + compadd "$expl[@]" -a names && ret=0 + ;; + *PDFSETTINGS=) + _description settings expl 'configuration' + compadd "$expl[@]" /screen /ebook /printer /prepress /default && ret=0 + ;; + *AutoRotatePages=) + _description settings expl 'orientation selection' + compadd "$expl[@]" /None /All /PageByPage && ret=0 + ;; + *CompatibilityLevel=) + _description pdf-levels expl 'PDF compatibility level' + compadd "$expl[@]" 1.{2,3,4} && ret=0 + ;; + *FONT=) # e.g. SUBSTFONT + _wanted fonts expl 'font' compadd - \ + $($words[1] -q -o /dev/null -DNODISPLAY -c '(*) { = } 256 string /Font resourceforall') && ret=0 + ;; + *) + _message -e values 'systemdict value' + return 1 + ;; + esac + else + _wanted definition-names expl 'systemdict name' compadd -S\= -M 'm:{a-z}={A-Z}' - \ + DEVICE OutputFile PAPERSIZE PDFSETTINGS CompatibilityLevel stdout COLORSCREEN \ + DITHERPPI InterpolateControl TextAlphaBits GraphicsAlphaBits PageList SUBSTFONT \ + && ret=0 + fi + ;; + uname) + _message -e definition-names 'systemdict definition name' + ;; + outfile) + if compset -P "*%"; then + specs=( + {d,i}':signed decimal number or with leading " numeric value of following character' + 'o:unsigned octal number' + 'u:unsigned decimal number' + {x,X}':unsigned hexadecimal number, letters capitalized as x' + '%:a literal percent sign' + '#:alternate form' + '0:zero pad to length' + '-:left adjust result' + '+:always place sign before number' + '.:precision' + ) + if ! compset -P '[0-9#.+-]##'; then + specs+=( + 'stdout:redirect to standard output' + 'stderr:redirect to standard error' + 'pipe%:redirect to a pipe' + ) + fi + _describe -t print-format-specifiers 'print format specifier' specs -S '' && ret=0 + else + _description files expl 'output file' + _files "$expl[@]" && ret=0 + fi + ;; + esac + + return ret +fi diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index f6cec8b60..eac0c8476 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -871,6 +871,7 @@ _git-fetch () { '(-n --no-tags -t --tags)'{-n,--no-tags}'[disable automatic tag following]' \ '(--all -m --multiple)'{-m,--multiple}'[fetch from multiple remotes]' \ '(-P --prune-tags)'{-P,--prune-tags}'[prune local tags no longer on remote and clobber changed tags]' \ + \*{-o+,--server-option=}'[send specified string to the server when using protocol version 2]:option' \ '--filter=[object filtering]:filter:_git_rev-list_filters' \ '*:: :->repository-or-group-or-refspec' && ret=0 @@ -959,9 +960,10 @@ _git-gc () { _arguments -S -s \ '--aggressive[more aggressively optimize]' \ '--auto[check whether housekeeping is required]' \ - '( --no-prune)--prune=[prune loose objects older than given date]: :__git_datetimes' \ + '( --no-prune)--prune=-[prune loose objects older than given date]::date [2 weeks ago]:__git_datetimes' \ '(--prune )--no-prune[do not prune any loose objects]' \ - '(-q --quiet)'{-q,--quiet}'[suppress progress reporting]' + '(-q --quiet)'{-q,--quiet}'[suppress progress reporting]' \ + '--keep-largest-pack[repack all other packs except the largest pack]' \ } (( $+functions[_git-grep] )) || @@ -1694,6 +1696,9 @@ _git-stash () { '(-m --message)'{-m,--message}'[specify stash description]' \ ':: :__git_modified_files' && ret=0 ;; + (--) + __git_modified_files + ;; (list) local -a log_options revision_options __git_setup_log_options @@ -1765,7 +1770,10 @@ _git-status () { '--ignored=-[show ignored files as well]:mode [traditional]:(traditional matching no)' \ '(-z --null --column --no-column)'{-z,--null}'[use NUL termination on output]' \ '(--no-column -z --null)--column=-[display in columns]::column.status option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \ - '(--column)--no-column[do not display in columns]' \ + "(--column)--no-column[don't display in columns]" \ + "(--no-renames -M --find-renames)--no-renames[don't detect renames]" \ + '(--no-renames -M --find-renames)-M[detect renames]' \ + '(--no-renames -M --find-renames)--find-renames=-[detect renames, optionally set similarity index]::similarity' \ '*: :__git_ignore_line_inside_arguments _files' } @@ -2152,16 +2160,18 @@ _git-config () { '(--global --system -f --file --blob)--local[use local config file]' \ '(--global --system --local --blob)'{-f+,--file=}'[use given config file]:config file:_files' \ '(--global --system --local -f --file)--blob=[read config from given blob object]:blob:__git_blobs' \ - '( --int --bool-or-int --path --expiry-date)--bool[setting is a boolean]' \ - '(--bool --bool-or-int --path --expiry-date)--int[setting is an integer]' \ - '(--bool --int --path --expiry-date)--bool-or-int[setting is an integer]' \ - '(--bool --int --bool-or-int --expiry-date)--path[setting is a path]' \ - '(--bool --int --bool-or-int --path )--expiry-date[setting is an expiry date]' \ + '(-t --type --bool --int --bool-or-int --path --expiry-date)'{-t+,--type=}'[ensure that incoming and outgoing values are canonicalize-able as the given type]:type:(bool int bool-or-int path expiry-date color)' \ + '(-t --type --int --bool-or-int --path --expiry-date)--bool[setting is a boolean]' \ + '(-t --type --bool --bool-or-int --path --expiry-date)--int[setting is an integer]' \ + '(-t --type --bool --int --path --expiry-date)--bool-or-int[setting is an integer]' \ + '(-t --type --bool --int --bool-or-int --expiry-date)--path[setting is a path]' \ + '(-t --type --bool --int --bool-or-int --path)--expiry-date[setting is an expiry date]' \ '(-z --null)'{-z,--null}'[end values with NUL and newline between key and value]' \ '(--get --get-all --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section -e --edit --get-color --get-colorbool)--name-only[show variable names only]' \ '(--includes)'--no-includes"[don't respect \"include.*\" directives]" \ '(--no-includes)'--includes'[respect "include.*" directives in config files when looking up values]' \ '(--global --system --local -f --file --blob --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section -e --edit --get-color --get-colorbool)--show-origin[show origin of config]' \ + '(2 --add -e --edit -l --list --name-only --rename-section --remove-section --replace-all --unset --unset-all)--default=[with --get, use specified default value when entry is missing]:default' \ $name_arg \ $value_arg \ '::value regex' \ @@ -3705,11 +3715,17 @@ _git-replace () { '(: * --raw -f --force)'{-l,--list}'[list replace refs]:pattern' \ {-d,--delete}'[delete existing replace refs]:*:replacement:__git_objects' \ '(* 2 --format)'{-e,--edit}'[edit existing object and replace it with the new one]' \ - '(--raw --format)'{-g,--graft}'[rewrite the parents of a commit]' + '(--raw --format)'{-g,--graft}'[rewrite the parents of a commit]' \ + '--convert-graft-file[convert existing graft file]' } # Ancillary Commands (Interrogators) +(( $+functions[_git-annotate] )) || +_git-annotate() { + _git-blame "$@" +} + (( $+functions[_git-blame] )) || _git-blame () { local curcontext=$curcontext state line ret=1 @@ -3741,6 +3757,8 @@ _git-blame () { '(-n --show-number)'{-n,--show-number}'[show the line number in the original commit]' \ '-s[suppress author name and timestamp]' \ '-w[ignore whitespace when finding lines]' \ + '(--color-by-age)--color-lines[color redundant metadata from previous line differently]' \ + '(--color-lines)--color-by-age[color lines by age]' \ '--indent-heuristic[use indent-based heuristic to improve diffs]' \ $revision_options \ ':: :__git_revisions' \ @@ -3828,10 +3846,11 @@ _git-get-tar-commit-id () { _git-help () { _arguments -S -s \ '( -g --guides -i --info -m --man -w --web)'{-a,--all}'[show all available commands]' \ - '(-a --all -g --guides -m --man -w --web)'{-i,--info}'[show all available commands]' \ - '(-a --all -g --guides -i --info -w --web)'{-m,--man}'[show all available commands]' \ - '(-a --all -g --guides -i --info -m --man )'{-w,--web}'[show all available commands]' \ + '(-a --all -g --guides -m --man -w --web)'{-i,--info}'[display manual for the command in info format]' \ + '(-a --all -g --guides -i --info -w --web)'{-m,--man}'[display manual for the command in man format]' \ + '(-a --all -g --guides -i --info -m --man )'{-w,--web}'[display manual for the command in HTML format]' \ '(-g --guides)'{-g,--guides}'[prints a list of useful guides on the standard output]' \ + '(-v --verbose)'{-v,--verbose}'[print command descriptions]' \ ': : _alternative commands:command:_git_commands "guides:git guides:(attributes glossary ignore modules revisions tutorial workflows)"' } @@ -4700,6 +4719,7 @@ _git-pack-objects () { $thin_opt \ '--shallow[create packs suitable for shallow fetches]' \ '--honor-pack-keep[ignore objects in local pack with .keep file]' \ + '--keep-pack=[ignore named pack]:pack' \ '--compression=-[specify compression level]: :__git_compression_levels' \ '--keep-true-parents[pack parents hidden by grafts]' \ '--use-bitmap-index[use a bitmap index if available to speed up counting objects]' \ @@ -5034,7 +5054,9 @@ _git-ls-remote () { "--refs[don't show peeled tags]" \ '--exit-code[exit with status 2 when no matching refs are found in the remote repository]' \ '--get-url[expand the URL of the given repository taking into account any "url.<base>.insteadOf" config setting]' \ + '*--sort=[specify field name to sort on]:field:__git_ref_sort_keys' \ '--symref[show underlying ref in addition to the object pointed by it]' \ + \*{-o+,--server-option=}'[send specified string to the server when using protocol version 2]:option' \ ': :__git_any_repositories' \ '*: :__git_references' } @@ -5615,7 +5637,7 @@ __git_describe_branch () { (( $+functions[__git_describe_commit] )) || __git_describe_commit () { - __git_describe_branch $1 $2 $3 -M 'r:|/=**' "${(@)argv[4,-1]}" + __git_describe_branch $1 $2 $3 -M 'r:|/=* r:|=*' "${(@)argv[4,-1]}" } # Completion Wrappers @@ -6404,7 +6426,7 @@ __git_heads () { (( $+functions[__git_heads_local] )) || __git_heads_local () { - local gitdir + local f gitdir declare -a heads heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)"' refs/heads 2>/dev/null)"}) @@ -6532,7 +6554,7 @@ __git_recent_commits () { expl=() _wanted commit-tags expl 'commit tag' compadd "$@" -a - tags && ret=0 expl=() - _wanted heads expl 'head' compadd "$@" -a - heads && ret=0 + _wanted heads expl 'head' compadd -M "r:|/=* r:|=*" "$@" -a - heads && ret=0 return $ret } @@ -6657,7 +6679,7 @@ __git_tags () { tags=(${${(f)"$(_call_program tagrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) __git_command_successful $pipestatus || return 1 - _wanted tags expl tag compadd -M 'r:|/=**' "$@" -a - tags + _wanted tags expl tag compadd -M 'r:|/=* r:|=*' "$@" -a - tags } (( $+functions[__git_commit_tags] )) || @@ -6680,7 +6702,7 @@ __git_tags_of_type () { tags=(${${(M)${(f)"$(_call_program ${(q)type}-tag-refs "git for-each-ref --format='%(*objecttype)%(objecttype) %(refname)' refs/tags 2>/dev/null")"}:#$type(tag|) *}#$type(tag|) refs/tags/}) __git_command_successful $pipestatus || return 1 - _wanted $type-tags expl "$type tag" compadd -M 'r:|/=**' "$@" -a - tags + _wanted $type-tags expl "$type tag" compadd -M 'r:|/=* r:|=*' "$@" -a - tags } # Reference Argument Types @@ -6703,7 +6725,7 @@ __git_references () { _git_refs_cache_pwd=$PWD fi - _wanted references expl 'reference' compadd -M 'r:|/=**' -a - _git_refs_cache + _wanted references expl 'reference' compadd -M 'r:|/=* r:|=*' -a - _git_refs_cache } # ### currently unused; are some callers of __git_references supposed to call this function? @@ -6717,7 +6739,7 @@ __git_local_references () { _git_local_refs_cache_pwd=$PWD fi - _wanted references expl 'reference' compadd -M 'r:|/=**' -a - _git_local_refs_cache + _wanted references expl 'reference' compadd -M 'r:|/=* r:|=*' -a - _git_local_refs_cache } (( $+functions[__git_remote_references] )) || @@ -6790,7 +6812,7 @@ __git_files () { local pref=$gitcdup$gitprefix$PREFIX # First allow ls-files to pattern-match in case of remote repository - files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\\\*}:-.} 2>/dev/null)"}) + files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\*}:-.} 2>/dev/null)"}) __git_command_successful $pipestatus || return # If ls-files succeeded but returned nothing, try again with no pattern @@ -7739,8 +7761,8 @@ _git() { '(: -)--man-path[print the manpath for the man pages for this version of Git and exit]' \ '(: -)--info-path[print the path where the info files are installed and exit]' \ '(: -)--html-path[display path to HTML documentation and exit]' \ - '(-p --paginate)'{-p,--paginate}'[pipe output into $PAGER]' \ - '--no-pager[do not pipe git output into a pager]' \ + '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe output into a pager]' \ + '(-p --paginate -P --no-pager)'{-P,--no-pager}"[don't pipe git output into a pager]" \ '--git-dir=-[path to repository]: :_directories' \ '--work-tree=-[path to working tree]: :_directories' \ '--namespace=-[set the Git namespace]: :_directories' \ @@ -7758,7 +7780,10 @@ _git() { curcontext=${curcontext%:*:*}:git-$words[1]: (( $+opt_args[--git-dir] )) && local -x GIT_DIR=$opt_args[--git-dir] if ! _call_function ret _git-$words[1]; then - if zstyle -T :completion:$curcontext: use-fallback; then + if [[ $words[1] = \!* ]]; then + words[1]=${words[1]##\!} + _normal && ret=0 + elif zstyle -T :completion:$curcontext: use-fallback; then _default && ret=0 else _message "unknown sub-command: $words[1]" diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg index 48a36eff2..b35693d1f 100644 --- a/Completion/Unix/Command/_gpg +++ b/Completion/Unix/Command/_gpg @@ -206,20 +206,68 @@ fi case "$state" in public-keys) - _wanted public-keys expl 'public key' \ - compadd ${${(Mo)$(_call_program public-keys $words[1] $needed --list-public-keys --list-options no-show-photos):%<*>}//(<|>)/} && return + local public_keys_lines=(${(f)"$(_call_program public-keys ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"}) + local -a uids emails + local i j parts current_uid + for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do + parts=("${(@s.:.)public_keys_lines[$i]}") + if [[ ${parts[1]} == "fpr" ]]; then + current_uid="${parts[10]}" + i=$((i + 1)) + parts=("${(@s.:.)public_keys_lines[$i]}") + while [[ ${parts[1]} == "uid" ]]; do + uids+=("${current_uid}") + emails+=("${parts[10]}") + i=$((i + 1)) + parts=("${(@s.:.)public_keys_lines[$i]}") + done + fi + done + _describe -t public-keys 'public key' emails uids ;; secret-keys) - _wanted secret-keys expl 'secret key' compadd \ - ${${(Mo)$(_call_program secret-keys $words[1] $needed --list-secret-keys --list-options no-show-photos):%<*>}//(<|>)/} && return + local secret_keys_lines=(${(f)"$(_call_program secret-keys ${(q)words[1]} ${(q)needed} --list-secret-keys --list-options no-show-photos --with-colons)"}) + local -a uids emails + local i j parts current_uid + for (( i = 1; i < ${#secret_keys_lines[@]}; ++i )); do + parts=("${(@s.:.)secret_keys_lines[$i]}") + if [[ ${parts[1]} == "fpr" ]]; then + current_uid="${parts[10]}" + i=$((i + 1)) + parts=("${(@s.:.)secret_keys_lines[$i]}") + while [[ ${parts[1]} == "uid" ]]; do + uids+=("${current_uid}") + emails+=("${parts[10]}") + i=$((i + 1)) + parts=("${(@s.:.)secret_keys_lines[$i]}") + done + fi + done + _describe -t secret-keys 'secret key' emails uids ;; ciphers) _wanted ciphers expl cipher compadd \ - ${${(s.,.)${(M)${(f)${"$(_call_program ciphers $words[1] $needed --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return + ${${(s.,.)${(M)${(f)${"$(_call_program ciphers ${(q)words[1]} ${(q)needed} --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return ;; (public-keyids) - _wanted public-keys expl 'public keyid' \ - compadd ${(M)${${(f)"$(_call_program public-keyids $words[1] $needed --list-public-keys --list-options no-show-photos)"}## #}:#[0-9A-F](#c40)} && return + local public_keys_lines=(${(f)"$(_call_program public-keyids ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"}) + local -a uids emails + local i j parts current_uid + for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do + parts=("${(@s.:.)public_keys_lines[$i]}") + if [[ ${parts[1]} == "fpr" ]]; then + current_uid="${parts[10]}" + i=$((i + 1)) + parts=("${(@s.:.)public_keys_lines[$i]}") + while [[ ${parts[1]} == "uid" ]]; do + uids+=("${current_uid}") + emails+=("${parts[10]}") + i=$((i + 1)) + parts=("${(@s.:.)public_keys_lines[$i]}") + done + fi + done + _describe -t public-keyids 'public key' emails uids ;; (option-list) _sequence _wanted options expl option \ diff --git a/Completion/Unix/Command/_grep b/Completion/Unix/Command/_grep index 5f45ce9a8..3bc8d3fe0 100644 --- a/Completion/Unix/Command/_grep +++ b/Completion/Unix/Command/_grep @@ -1,4 +1,4 @@ -#compdef grep egrep fgrep bsdgrep zgrep zegrep zfgrep ggrep gegrep gfgrep gzgrep gzegrep gzfgrep -value-,GREP_OPTIONS,-default- +#compdef grep egrep fgrep bsdgrep zgrep zegrep zfgrep ggrep gegrep gfgrep gzgrep gzegrep gzfgrep bzgrep bzegrep bzfgrep -value-,GREP_OPTIONS,-default- local arguments matchers command variant @@ -11,13 +11,15 @@ else arguments=( '(-e --regexp -f --file)1: :_guard "^-*" pattern' ) if [[ $service = z* ]]; then arguments+=( '*:files:_files -g "*.gz(-.)"' ) + elif [[ $service = bz* ]]; then + arguments+=( '*:files:_files -g "*.bz2(-.)"' ) else arguments+=( '*:files:_files' ) fi command="$words[1]" fi -if [[ $service != (|g)(|z)[ef]grep ]]; then +if [[ $service != (|g|z|gz|bz)[ef]grep ]]; then matchers='(--extended-regexp --fixed-strings --basic-regexp --perl-regexp -E -F -G -P)' arguments+=( $matchers{--extended-regexp,-E}'[use extended regular expression]' @@ -66,7 +68,7 @@ arguments+=( _pick_variant -r variant -c "$command" gnu=gnu gpl2=2.5.1 unix --version case $variant:$OSTYPE in (gnu:*|gpl2:freebsd*)) - [[ $service != (|g)(|z)[ef]grep ]] && arguments+=( + [[ $service != (|g|z|gz|bz)[ef]grep ]] && arguments+=( $matchers{--perl-regexp,-P}'[use perl regular expression]' ) ;| @@ -76,15 +78,19 @@ case $variant:$OSTYPE in '(-z --null-data)'{-z,--null-data}'[input data separated by 0 byte, not newline]' ) ;| - gpl2:freebsd*) + gpl2:(freebsd|darwin)*) arguments+=( '(--null --no-filename -h)--null[print 0 byte after each filename]' + '(-Z --decompress -J --bz2decompress)'{-J,--bz2decompress}"[decompress bzip2'ed input before searching]" + '(-Z --decompress -J --bz2decompress)'{-Z,--decompress}"[decompress gzip'ed input before searching]" ) ;| - gpl2:(freebsd|darwin)*) + gpl2:darwin*) arguments+=( - '(-Z --decompress -J --bz2decompress)'{-J,--bz2decompress}"[decompress bzip2'ed input before searching]" - '(-Z --decompress -J --bz2decompress)'{-Z,--decompress}"[decompress gzip'ed input before searching]" + '(-p -S)-O[follow symlinks on the command line]' + '(-O -S)-p[do not follow symlinks]' + '(-O -p)-S[follow all symlinks]' + '*--include-dir=[only search directories matching specified pattern]:directory pattern' ) ;| (gnu:*|gpl2:netbsd*)) diff --git a/Completion/Unix/Command/_gs b/Completion/Unix/Command/_gs deleted file mode 100644 index 98ba14912..000000000 --- a/Completion/Unix/Command/_gs +++ /dev/null @@ -1,57 +0,0 @@ -#compdef gs ghostscript - -if compset -N --; then - if [[ CURRENT -eq 1 ]]; then - _pspdf - else - _message -e arguments 'userdict ARGUMENTS' - return 1 - fi -else - local curcontext="$curcontext" state line expl ret=1 - typeset -A opt_args - - _x_arguments -C \ - '-q[quiet startup]' \ - '-g-[set device size]:device size (<width>x<height>):' \ - '-r-[set resolution]:resolution (<val> or <x>x<y>):' \ - '-I[add to library file search path]:directory:_dir_list' \ - \*-{d,D}'-[define name with definition]:def:->dname' \ - \*-{s,S}'-[define name with value]:def:->sname' \ - '*:PostScript or PDF file:_pspdf' && ret=0 - - case "$state" in - dname) - if [[ "$PREFIX" = *\=* ]]; then - _message -e definition-values 'systemdict definition value' - else - _wanted names expl 'systemdict definition name' \ - compadd -M 'm:{a-z}={A-Z}' - \ - DISKFONTS NOCACHE NOBIND NODISPLAY NOPAUSE PLATFONTS SAFER \ - WRITESYSTEMDICT && ret=0 - fi - ;; - sname) - if compset -P 1 '*='; then - case "$IPREFIX" in - *DEVICE\=) - _wanted devices expl 'ghostscript device' \ - compadd - "${(@)${=${$(_call_program devices gs -h)##* devices:}%%Search path:*}:#}" && ret=0 - ;; - *OutputFile\=) - _description files expl 'output file' - _files "$expl[@]" && ret=0 - ;; - *) - _message -e values 'systemdict value' - return 1 - esac - else - _wanted names expl 'systemdict name' \ - compadd -S\= -M 'm:{a-z}={A-Z}' - DEVICE OutputFile && ret=0 - fi - ;; - esac - - return ret -fi diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg index 8eaa457c8..4b88ce4ea 100644 --- a/Completion/Unix/Command/_hg +++ b/Completion/Unix/Command/_hg @@ -82,7 +82,7 @@ _hg() { if [[ -z "$cmd" ]] then - _arguments -s -w : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ ':mercurial command:_hg_commands' return fi @@ -119,7 +119,7 @@ _hg() { _hg_cmd_${cmd} else # complete unknown commands normally - _arguments -s -w : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '*:files:_hg_files' fi } @@ -282,6 +282,18 @@ _hg_config() { (( $#items )) && _describe -t config 'config item' items } +_hg_internal_merge_tools=( + \\:dump \\:fail \\:local \\:merge \\:merge-local \\:merge-other \\:merge3 + \\:other \\:prompt \\:tagmerge \\:union +) + +_hg_merge_tools() { + typeset -a external_tools + _describe -t internal_tools 'internal merge tools' _hg_internal_merge_tools + external_tools=(${(f)"$(_hg_cmd showconfig merge-tools | cut -d . -f 2)"}) + (( $#external_tools )) && _describe -t external_tools 'external merge tools' external_tools +} + _hg_addremove() { _alternative 'files:unknown files:_hg_unknown' \ 'files:missing files:_hg_missing' @@ -359,22 +371,22 @@ _hg_clone_dest() { # Common options _hg_global_opts=( - '(--repository -R)'{-R+,--repository=}'[repository root directory]:repository:_files -/' - '--cwd[change working directory]:new working directory:_files -/' - '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]' + '(--repository -R)'{-R+,--repository=}'[repository root directory or name of overlay bundle file]:repository:_files -/' + '--cwd=[change working directory]:new working directory:_files -/' + '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, automatically pick the first choice for all prompts]' '(--verbose -v)'{-v,--verbose}'[enable additional output]' '*--config[set/override config option]:defined config items:_hg_config' '(--quiet -q)'{-q,--quiet}'[suppress output]' '(--help -h)'{-h,--help}'[display help and exit]' - '--debug[debug mode]' + '--debug[enable debugging output]' '--debugger[start debugger]' - '--encoding[set the charset encoding (default: UTF8)]' - '--encodingmode[set the charset encoding mode (default: strict)]' - '--lsprof[print improved command execution profile]' - '--traceback[print traceback on exception]' + '--encoding=[set the charset encoding]:encoding' + '--encodingmode=[set the charset encoding mode]:encoding mode' + '--traceback[always print a traceback on exception]' '--time[time how long the command takes]' - '--profile[profile]' + '--profile[print command execution profile]' '--version[output version information and exit]' + '--hidden[consider hidden changesets]' ) _hg_pat_opts=( @@ -384,14 +396,19 @@ _hg_pat_opts=( _hg_diff_opts=( '(--text -a)'{-a,--text}'[treat all files as text]' '(--git -g)'{-g,--git}'[use git extended diff format]' - "--nodates[don't include dates in diff headers]") + '--nodates[omit dates from diff headers]' +) + +_hg_mergetool_opts=( + '(--tool -t)'{-t+,--tool=}'[specify merge tool]:merge tool:_hg_merge_tools' +) _hg_dryrun_opts=( '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]') -_hg_style_opts=( - '--style[display using template map file]:' - '--template[display with template]:') +_hg_template_opts=( + '--template[display with template]:template' +) _hg_commit_opts=( '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]' @@ -399,8 +416,14 @@ _hg_commit_opts=( '(-e --edit -m --message --logfile -l)'{-l+,--logfile=}'[read the commit message from <file>]:log file:_files') _hg_remote_opts=( - '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:' - '--remotecmd[specify hg command to run on the remote side]:') + '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:command' + '--remotecmd=[specify hg command to run on the remote side]:remote command' + '--insecure[do not verify server certificate (ignoring web.cacerts config)]' +) + +_hg_subrepos_opts=( + '(--subrepos -S)'{-S,--subrepos}'[recurse into subrepositories]' +) _hg_cmd() { _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \ @@ -408,51 +431,54 @@ _hg_cmd() { } _hg_cmd_add() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \ '*:unknown files:_hg_unknown' } _hg_cmd_addremove() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ - '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:' \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \ + '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \ '*:unknown or missing files:_hg_addremove' } _hg_cmd_annotate() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ '(--rev -r)'{-r+,--rev=}'[annotate the specified revision]:revision:_hg_tags' \ - '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \ + "--no-follow[don't follow copies and renames]" \ '(--text -a)'{-a,--text}'[treat all files as text]' \ - '(--user -u)'{-u,--user}'[list the author]' \ - '(--date -d)'{-d,--date}'[list the date]' \ + '(--user -u)'{-u,--user}'[list the author (long with -v)]' \ + '(--file -f)'{-f,--file}'[list the filename]' \ + '(--date -d)'{-d,--date}'[list the date (short with -q)]' \ '(--number -n)'{-n,--number}'[list the revision number (default)]' \ '(--changeset -c)'{-c,--changeset}'[list the changeset]' \ + '(--line-number -l)'{-l,--line-number}'[show line number at the first appearance]' \ '*:files:_hg_files' } _hg_cmd_archive() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ '--no-decode[do not pass files through decoders]' \ - '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:' \ + '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:prefix' \ '(--rev -r)'{-r+,--rev=}'[revision to distribute]:revision:_hg_tags' \ '(--type -t)'{-t+,--type=}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \ '*:destination:_files' } _hg_cmd_backout() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \ '--merge[merge with old dirstate parent after backout]' \ - '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \ + '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ '--parent[parent to choose when backing out merge]' \ - '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \ + '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ '(--message -m)'{-m+,--message=}'[specify commit message]:text' \ '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' } _hg_cmd_bisect() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(-)'{-r,--reset}'[reset bisect state]' \ + '(--extend -e)'{-e,--extend}'[extend the bisect range]' \ '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_tags \ '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_tags \ '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \ @@ -461,97 +487,115 @@ _hg_cmd_bisect() { } _hg_cmd_bookmarks() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--force -f)'{-f,--force}'[force]' \ - '(--rev -r)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \ - '(--delete -d)'{-d,--delete}'[delete a given bookmark]' \ - '(--rename -m)'{-m+,--rename=}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \ + '(--rev -r --delete -d --rename -m)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \ + '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \ + '(--rev -r --delete -d --rename -m)'{-m+,--rename=}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \ '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \ ':bookmark:_hg_bookmarks_internal' } _hg_cmd_branch() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \ '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]' } _hg_cmd_branches() { - _arguments -s : $_hg_global_opts \ - '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]' + _arguments -s -S : $_hg_global_opts \ + '(--closed -c)'{-c,--closed}'[show normal and closed branches]' } _hg_cmd_bundle() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ - '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \ - '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_tags' \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ + '(--force -f)'{-f,--force}'[run even when the destination is unrelated]' \ + '(2)*--base[a base changeset assumed to be available at the destination]:revision:_hg_tags' \ + '*'{-b+,--branch=}'[a specific branch you would like to bundle]:branch:_hg_branches_internal' \ + '*'{-r+,--rev=}'[a changeset intended to be added to the destination]:revision:_hg_tags' \ + '--all[bundle all changesets in the repository]' \ + '--type[bundle compression type to use (default: bzip2)]:bundle type' \ ':output file:_files' \ ':destination repository:_files -/' } _hg_cmd_cat() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ - '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:filespec:' \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ + '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ + '--decode[apply any matching decode filter]' \ '*:file:_hg_files' } _hg_cmd_clone() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \ - '(--rev -r)'{-r+,--rev=}'[a changeset you would like to have after cloning]:' \ + '(--rev -r)'{-r+,--rev=}'[include the specified changeset]:revision' \ '--uncompressed[use uncompressed transfer (fast over LAN)]' \ ':source repository:_hg_remote' \ ':destination:_hg_clone_dest' } _hg_cmd_commit() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \ '(--message -m)'{-m+,--message=}'[specify commit message]:text' \ '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' \ - '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \ - '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \ + '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ + '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ + '--amend[amend the parent of the working directory]' \ + '--close-branch[mark a branch head as closed]' \ + '(--interactive -i)'{-i,--interactive}'[use interactive mode]' \ + '(--secret -s)'{-s,--secret}'[use the secret phase for committing]' \ '*:file:_hg_committable' } _hg_cmd_copy() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \ '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ '*:file:_hg_files' } _hg_cmd_diff() { + local context state state_descr line ret=1 typeset -A opt_args - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \ + + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts $_hg_subrepos_opts \ '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \ '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \ '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \ '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \ '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \ - '*:file:->diff_files' + '*:file:->diff_files' && ret=0 if [[ $state == 'diff_files' ]] then if [[ -n $opt_args[-r] ]] then - _hg_files + _hg_files && ret=0 else - _hg_modified + _hg_modified && ret=0 fi fi + + return ret } _hg_cmd_export() { - _arguments -s : $_hg_global_opts $_hg_diff_opts \ - '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \ + _arguments -s -S : $_hg_global_opts $_hg_diff_opts \ + '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \ '--switch-parent[diff against the second parent]' \ '*:revision:_hg_tags' } +_hg_cmd_forget() { + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ + '*:file:_hg_files' +} + _hg_cmd_grep() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \ '--all[print all revisions with matches]' \ '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \ @@ -565,247 +609,296 @@ _hg_cmd_grep() { } _hg_cmd_heads() { - _arguments -s : $_hg_global_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_template_opts \ + '(--topo -t)'{-t,--topo}'[show topological heads only]' \ + '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \ '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_tags' } _hg_cmd_help() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ + '(--extension -e)'{-e,--extension}'[show only help for extensions]' \ + '(--command -c)'{-c,--command}'[show only help for commands]' \ + '(--keyword -k)'{-k,--keyword}'[show topics matching keyword]' \ '*:mercurial command:_hg_commands' } _hg_cmd_identify() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--rev -r)'{-r+,--rev=}'[identify the specified rev]:revision:_hg_tags' \ - '(--num -n)'{-n+,--num=}'[show local revision number]' \ - '(--id -i)'{-i+,--id=}'[show global revision id]' \ - '(--branch -b)'{-b+,--branch=}'[show branch]' \ - '(--tags -t)'{-t+,--tags=}'[show tags]' + '(--num -n)'{-n,--num}'[show local revision number]' \ + '(--id -i)'{-i,--id}'[show global revision id]' \ + '(--branch -b)'{-b,--branch}'[show branch]' \ + '(--tags -t)'{-t,--tags}'[show tags]' \ + '(--bookmarks -B)'{-B,--bookmarks}'[show bookmarks]' } _hg_cmd_import() { - _arguments -s : $_hg_global_opts \ - '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count:' \ + _arguments -s -S : $_hg_global_opts \ + '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count' \ '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text:' \ '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \ + '--bypass[apply patch without touching the working directory]' \ + '--no-commit[do not commit, just update the working directory]' \ + '--partial[commit even if some hunks fail]' \ + '--exact[abort if patch would apply lossily]' \ + '--import-branch[use any branch information in patch (implied by --exact)]' \ + '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ + '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ + '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \ '*:patch:_files' } _hg_cmd_incoming() { - _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_template_opts $_hg_subrepos_opts \ '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \ '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ '(--patch -p)'{-p,--patch}'[show patch]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \ + '*'{-r+,--rev=}'[a remote changeset intended to be added]:revision:_hg_tags' \ '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ '--bundle[file to store the bundles into]:bundle file:_files' \ ':source:_hg_remote' } _hg_cmd_init() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ ':dir:_files -/' } _hg_cmd_locate() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ '(--rev -r)'{-r+,--rev=}'[search repository as it stood at revision]:revision:_hg_tags' \ '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ - '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \ + '(--fullpath -f)'{-f,--fullpath}'[print complete paths from the filesystem root]' \ '*:search pattern:_hg_files' } _hg_cmd_log() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_template_opts \ '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \ '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \ '(--copies -C)'{-C,--copies}'[show copied files]' \ - '(--keyword -k)'{-k+,--keyword=}'[search for a keyword]:' \ - '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \ - '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \ + '*'{-k+,--keyword=}'[search for a keyword]:keyword' \ + '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \ + '*'{-r+,--rev=}'[show the specified revision or revset]:revision:_hg_revrange' \ '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \ '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \ '(--patch -p)'{-p,--patch}'[show patch]' \ - '(--prune -P)'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_tags' \ + '*'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_tags' \ '*:files:_hg_files' } _hg_cmd_manifest() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ + '--all[list files from all revisions]' \ ':revision:_hg_tags' } _hg_cmd_merge() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \ - '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \ + '(--rev -r 1)'{-r+,--rev=}'[revision to merge]:revision:_hg_mergerevs' \ '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \ ':revision:_hg_mergerevs' } _hg_cmd_outgoing() { - _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_template_opts $_hg_subrepos_opts \ '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \ '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ '(--patch -p)'{-p,--patch}'[show patch]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]' \ + '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \ '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ ':destination:_hg_remote' } _hg_cmd_parents() { - _arguments -s : $_hg_global_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_template_opts \ '(--rev -r)'{-r+,--rev=}'[show parents of the specified rev]:revision:_hg_tags' \ ':last modified file:_hg_files' } _hg_cmd_paths() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ ':path:_hg_paths' } +_hg_cmd_phase() { + _arguments -s -S : $_hg_global_opts \ + '(--public -p --draft -d --secret -s)'{-p,--public}'[set changeset phase to public]' \ + '(--public -p --draft -d --secret -s)'{-d,--draft}'[set changeset phase to draft]' \ + '(--public -p --draft -d --secret -s)'{-s,--secret}'[set changeset phase to secret]' \ + '(--force -f)'{-f,--force}'[allow to move boundary backward]' \ + '*'{-r+,--rev=}'[target revision]:revision:_hg_tags' \ + '*:revision:_hg_tags' +} + _hg_cmd_pull() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:' \ + '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision' \ ':source:_hg_remote' } _hg_cmd_push() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ '(--force -f)'{-f,--force}'[force push]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]:revision:_hg_tags' \ + '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \ '*'{-B,--bookmark=}'[bookmark to push]:bookmark:_hg_bookmarks_internal' \ '*'{-b,--branch=}'[branch to push]:branch:_hg_branches_internal' \ - '--insecure[do not verify server certificate]' \ '--new-branch[allow pushing a new branch]' \ ':destination:_hg_remote' } _hg_cmd_remove() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ - '(--after -A)'{-A,--after}'[record remove that has already occurred]' \ - '(--force -f)'{-f,--force}'[remove file even if modified]' \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ + '(--after -A)'{-A,--after}'[record delete for missing files]' \ + '(--force -f)'{-f,--force}'[forget added files, delete modified files]' \ '*:file:_hg_files' } _hg_cmd_rename() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \ '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ '*:file:_hg_files' } _hg_cmd_resolve() { - local context state line + local context state state_descr line ret=1 typeset -A opt_args - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ + '(--all -a)'{-a,--all}'[select all unresolved files]' \ + '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \ '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \ '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \ - '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \ - '*:file:_hg_unresolved' + '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[mark files as unresolved]:*:resolved files:_hg_resolved' \ + '*:file:_hg_unresolved' && ret=0 if [[ $state == 'resolve_files' ]] then _alternative 'files:resolved files:_hg_resolved' \ - 'files:unresolved files:_hg_unresolved' + 'files:unresolved files:_hg_unresolved' && ret=0 fi + + return ret } _hg_cmd_revert() { - local context state line + local context state state_descr line ret=1 typeset -A opt_args - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \ '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_tags' \ - '--no-backup[do not save backup copies of files]' \ - '*:file:->diff_files' + '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \ + '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \ + '*:file:->diff_files' && ret=0 if [[ $state == 'diff_files' ]] then if [[ -n $opt_args[-r] ]] then - _hg_files + _hg_files && ret=0 else typeset -a status_files _hg_status mard - _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files + _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files && ret=0 fi fi + + return ret } _hg_cmd_serve() { - _arguments -s : $_hg_global_opts \ - '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file]:log file:_files' \ - '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file]:log file:_files' \ + _arguments -s -S : $_hg_global_opts $_hg_subrepos_opts \ + '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file to write to]:log file:_files' \ + '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file to write to]:log file:_files' \ '(--daemon -d)'{-d,--daemon}'[run server in background]' \ - '(--port -p)'{-p+,--port=}'[listen port]:listen port:' \ - '(--address -a)'{-a+,--address=}'[interface address]:interface address:' \ - '(--name -n)'{-n+,--name=}'[name to show in web pages]:repository name:' \ - '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \ - '--style[web template style]:style' \ + '(--port -p)'{-p+,--port=}'[port to listen on (default: 8000)]:listen port' \ + '(--address -a)'{-a+,--address=}'[address to listen on (default: all interfaces)]:interface address' \ + '--prefix[prefix path to serve from (default: server root)]:prefix' \ + '(--name -n)'{-n+,--name=}'[name to show in web pages (default: working directory)]:repository name' \ + '--web-conf=[name of the hgweb config file]:config file:_files' \ + '--pid-file=[name of file to write process ID to]:pid file:_files' \ + '--cmdserver[for remote clients]' \ + '(--templates -t)'{-t+,--templates=}'[web template directory]:template dir:_files -/' \ + '--style=[web template style]:style' \ '--stdio[for remote clients]' \ - '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]' + '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]' \ + '--certificate=[SSL certificate file]:certificate file:_files' } _hg_cmd_showconfig() { - _arguments -s : $_hg_global_opts \ - '(--untrusted -u)'{-u+,--untrusted=}'[show untrusted configuration options]' \ + _arguments -s -S : $_hg_global_opts \ + '(--untrusted -u)'{-u,--untrusted}'[show untrusted configuration options]' \ + '(--edit -e)'{-e,--edit}'[edit user config]' \ + '(--local -l --global -g)'{-l,--local}'[edit repository config]' \ + '(--local -l --global -g)'{-g,--global}'[edit global config]' \ ':config item:_hg_config' } _hg_cmd_status() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ '(--all -A)'{-A,--all}'[show status of all files]' \ '(--modified -m)'{-m,--modified}'[show only modified files]' \ '(--added -a)'{-a,--added}'[show only added files]' \ '(--removed -r)'{-r,--removed}'[show only removed files]' \ '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \ '(--clean -c)'{-c,--clean}'[show only files without changes]' \ - '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \ + '(--unknown -u)'{-u,--unknown}'[show only unknown (not tracked) files]' \ '(--ignored -i)'{-i,--ignored}'[show ignored files]' \ '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \ '(--copies -C)'{-C,--copies}'[show source of copied files]' \ '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ - '--rev[show difference from revision]:revision:_hg_tags' \ + '*--rev=[show difference from revision]:revision:_hg_tags' \ + '--change=[list the changed files of a revision]:revision:_hg_tags' \ '*:files:_files' } +_hg_cmd_summary() { + _arguments -s -S : $_hg_global_opts \ + '--remote[check for push and pull]' +} + _hg_cmd_tag() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--local -l)'{-l,--local}'[make the tag local]' \ - '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message:' \ - '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \ - '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \ + '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message' \ + '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ + '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ '(--rev -r)'{-r+,--rev=}'[revision to tag]:revision:_hg_tags' \ + '(--force -f)'{-f,--force}'[force tag]' \ + '--remove[remove a tag]' \ ':tag name:' } _hg_cmd_tip() { - _arguments -s : $_hg_global_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_template_opts \ '(--patch -p)'{-p,--patch}'[show patch]' } _hg_cmd_unbundle() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \ - ':files:_files' + '*:files:_files' } _hg_cmd_update() { - _arguments -s : $_hg_global_opts \ - '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \ + _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ + '(--clean -C)'{-C,--clean}'[discard uncommitted changes (no backup)]' \ + '(--check -c)'{-c,--check}'[require clean working directory]' \ + '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ ':revision:_hg_tags' } # HGK _hg_cmd_view() { - _arguments -s : $_hg_global_opts \ - '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \ + _arguments -s -S : $_hg_global_opts \ + '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \ ':revision range:_hg_tags' } @@ -859,35 +952,35 @@ _hg_qseries_opts=( '(--summary -s)'{-s,--summary}'[print first line of patch header]') _hg_cmd_qapplied() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_qdelete() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--keep -k)'{-k,--keep}'[keep patch file]' \ '*'{-r+,--rev=}'[stop managing a revision]:applied patch:_hg_revrange' \ '*:unapplied patch:_hg_qdeletable' } _hg_cmd_qdiff() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ '*:pattern:_hg_files' } _hg_cmd_qfold() { - _arguments -s : $_hg_global_opts $_h_commit_opts \ + _arguments -s -S : $_hg_global_opts $_h_commit_opts \ '(--keep -k)'{-k,--keep}'[keep folded patch files]' \ '*:unapplied patch:_hg_qunapplied' } _hg_cmd_qgoto() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--force -f)'{-f,--force}'[overwrite any local changes]' \ ':patch:_hg_qseries' } _hg_cmd_qguard() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--list -l)'{-l,--list}'[list all patches and guards]' \ '(--none -n)'{-n,--none}'[drop all guards]' \ ':patch:_hg_qseries' \ @@ -895,12 +988,12 @@ _hg_cmd_qguard() { } _hg_cmd_qheader() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ ':patch:_hg_qseries' } _hg_cmd_qimport() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--existing -e)'{-e,--existing}'[import file in patch dir]' \ '(--name -n 2)'{-n+,--name=}'[patch file name]:name:' \ '(--force -f)'{-f,--force}'[overwrite existing files]' \ @@ -909,17 +1002,17 @@ _hg_cmd_qimport() { } _hg_cmd_qnew() { - _arguments -s : $_hg_global_opts $_hg_commit_opts \ + _arguments -s -S : $_hg_global_opts $_hg_commit_opts \ '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \ ':patch:' } _hg_cmd_qnext() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_qpop() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--all -a :)'{-a,--all}'[pop all patches]' \ '(--name -n)'{-n+,--name=}'[queue name to pop]:' \ '(--force -f)'{-f,--force}'[forget any local changes]' \ @@ -927,11 +1020,11 @@ _hg_cmd_qpop() { } _hg_cmd_qprev() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_qpush() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--all -a :)'{-a,--all}'[apply all patches]' \ '(--list -l)'{-l,--list}'[list patch name in commit text]' \ '(--merge -m)'{-m+,--merge=}'[merge from another queue]:' \ @@ -941,20 +1034,20 @@ _hg_cmd_qpush() { } _hg_cmd_qrefresh() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \ '(--git -g)'{-g,--git}'[use git extended diff format]' \ '(--short -s)'{-s,--short}'[short refresh]' \ '*:files:_hg_files' } _hg_cmd_qrename() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ ':patch:_hg_qseries' \ ':destination:' } _hg_cmd_qselect() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--none -n :)'{-n,--none}'[disable all guards]' \ '(--series -s :)'{-s,--series}'[list all guards in series file]' \ '--pop[pop to before first guarded applied patch]' \ @@ -963,24 +1056,26 @@ _hg_cmd_qselect() { } _hg_cmd_qseries() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts \ + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \ '(--missing -m)'{-m,--missing}'[print patches not in series]' } _hg_cmd_qunapplied() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_qtop() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_strip() { - _arguments -s : $_hg_global_opts \ - '(--force -f)'{-f,--force}'[force multi-head removal]' \ - '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \ - '(--nobackup -n)'{-n,--nobackup}'[no backups]' \ - ':revision:_hg_tags' + _arguments -s -S : $_hg_global_opts \ + '*'{-r+,--rev=}'[revision]:revision:_hg_tags' \ + '(--force -f)'{-f,--force}'[force removal of changesets, discard uncommitted changes (no backup)]' \ + '--no-backup[no backups]' \ + '(--keep -k)'{-k,--keep}'[do not modify working directory during strip]' \ + '*'{-B+,--bookmark=}'[remove revs only reachable from given bookmark]:bookmark:_hg_bookmarks_internal' \ + '*:revision:_hg_tags' } _hg "$@" diff --git a/Completion/Unix/Command/_hostname b/Completion/Unix/Command/_hostname new file mode 100644 index 000000000..40a3189ae --- /dev/null +++ b/Completion/Unix/Command/_hostname @@ -0,0 +1,76 @@ +#compdef hostname + +local variant=$OSTYPE ret=1 +local -a context line state state_descr args aopts=( -A '-*' ) +local -A opt_args + +# May be overridden below +args=( '(-4 -6 -d -f -i -r -s)1: :_guard "^-*" "host name"' ) + +# On badly behaved systems it may be dangerous to call `hostname --help` or +# similar, so for now we'll avoid _pick_variant and just trust this. In the +# future, we should replace this by a method that can safely detect Solaris, +# BusyBox, etc. (@todo) +[[ $OSTYPE == linux* ]] && +(( $+commands[nisdomainname] || $+commands[ypdomainname] )) && +variant+=-net-tools + +case $variant in + *-net-tools) + aopts=( ) + args=( + '(: * -)'{-h,--help}'[display help information]' + '(: * -)'{-V,--version}'[display version information]' + + '(g)' # Get + '(: gs s)'{-A,--all-fqdns}'[display FQDNs resolved from network interface addresses]' + '(: gs s)'{-d,--domain}'[display DNS domain only]' + '(: gs s)'{-f,--fqdn,--long}'[display host name with DNS domain (FQDN)]' + '(: gs s)'{-i,--ip-address}'[display IP addresses for host (via DNS resolution)]' + '(: gs s)'{-I,--all-ip-addresses}'[display IP addresses for host (via network interfaces)]' + '(: gs s)'{-s,--short}'[display short host name only]' + + '(gs)' # Get/set + '(g)'{-y,--yp,--nis}'[display NIS domain only]' + + s # Set + '(-b --boot g)'{-b,--boot}'[always set a host name]' + '(: -F --file g)'{-F+,--file=}'[read host name to set from specified file]: :_files' + + o + '(-F --file g)1: :->host-or-domain' + ) + ;; + darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + '(: -4 -6 -d -f)-s[display short host name only]' + ) + ;| # MATCH AGAIN + darwin*|freebsd*) + args+=( + '(: -d -s)-f[display host name with DNS domain (FQDN)]' + ) + ;| # MATCH AGAIN + freebsd*) + args+=( + '(: -f -s)-d[display DNS domain only]' + ) + ;; + dragonfly*) + args+=( + '(: -6 -r)-4[use first IPv4 address on interface (with -i)]' + '(: -4 -r)-6[use first IPv6 address on interface (with -i)]' + '(: -r)-i+[retrieve host name via specified interface]: :_net_interfaces' + '(: -4 -6 -i)-r+[retrieve host name via specified IP address]: :_bind_addresses' + ) + ;; +esac + +_arguments -s -S $aopts : $args && ret=0 + +[[ $state == host-or-domain ]] && { + [[ -prefix -* ]] || + if [[ -n ${opt_args[(i)*-(-y|--yp|--nis)]} ]]; then + _message -e nis-domains 'NIS domain' && ret=0 + else + _message -e host-names 'host name' && ret=0 + fi +} + +return ret diff --git a/Completion/Unix/Command/_ifconfig b/Completion/Unix/Command/_ifconfig index 0c81bce10..c5b5af8d4 100644 --- a/Completion/Unix/Command/_ifconfig +++ b/Completion/Unix/Command/_ifconfig @@ -25,11 +25,16 @@ case $OSTYPE in '(-l -C)-m[list supported media]' '(-l -C)-L[show address lifetime as time offset]' ) - opts=( $alias $debug + listopts=( + active caps chan countries mac mesh regdomain roam txparam txpower + scan sta wme + ) + opts=( $alias $debug $listopts anycast lladdr media {,-}mediaopt {,delete}tunnel create destroy {,un}plumb vlan {,-}vlandev metric prefixlen range phase ssid muid stationname channel authmode {,-}powersave powersavesleep wepmode - {,-}wep {,-}nwkey add delete ether {,-}link{0,1,2} + {,-}wep {,-}nwkey add delete ether {,-}link{0,1,2} list wme wmm + roam roam:rssi roam:rate roaming ) ;; irix5*) opts=( $debug ) ;; diff --git a/Completion/Unix/Command/_install b/Completion/Unix/Command/_install index f5056b5d0..80a1b0c00 100644 --- a/Completion/Unix/Command/_install +++ b/Completion/Unix/Command/_install @@ -11,7 +11,7 @@ common_args=( '(-C -c --compare)-c[copy files (default)]' '(-d --directory)'{-d,--directory}'[create directories]' '(-g --group)'{-g+,--group=}'[specify destination file group]: :_groups' - '(-m --mode)'{-m+,--mode=}'[specify destination file mode]: :_modes' + '(-m --mode)'{-m+,--mode=}'[specify destination file mode]: :_file_modes' '(-o --owner)'{-o+,--owner=}'[specify destination file owner]: :_users' '(-p --preserve-timestamps)'{-p,--preserve-timestamps}'[preserve modification times]' '(-s --strip)'{-s,--strip}'[strip binaries]' @@ -41,7 +41,7 @@ else args+=( ${common_args##((#s)|*\))(\*|)--*} '-B+[specify backup suffix for -b]:backup suffix' - '-f+[specify destination file flags]: :_flags' + '-f+[specify destination file flags]: :_file_flags' ) [[ $OSTYPE == dragonfly* ]] && args+=( '!-D+[no effect (compatibility with NetBSD)]: :_directories' diff --git a/Completion/Unix/Command/_jq b/Completion/Unix/Command/_jq index 55bb93c04..4ff05dab4 100644 --- a/Completion/Unix/Command/_jq +++ b/Completion/Unix/Command/_jq @@ -31,4 +31,4 @@ _arguments -S -s : \ '*--argjson[pre-set a variable to an object]: :_guard "|[A-Za-z][A-Za-z0-9]#" "variable name":value (JSON): ' \ '*--slurpfile[pre-set a variable to contents of a file]: :_guard "|[A-Za-z][A-Za-z0-9]#" "variable name":value (filename of file containing JSON):_files' \ "1: :_guard '|[^-]' filter" \ - "*:_files" + "*: :_files" diff --git a/Completion/Unix/Command/_killall b/Completion/Unix/Command/_killall index 375b1bf74..6fdb0f277 100644 --- a/Completion/Unix/Command/_killall +++ b/Completion/Unix/Command/_killall @@ -1,9 +1,77 @@ #compdef killall killall5 -if [[ $service = killall && "$OSTYPE" = (linux*|*bsd*|darwin*) ]]; then - _alternative \ - 'signals:: _signals -p' \ - 'processes-names:process:{ compadd "$expl[@]" ${${${${(f)"$(_call_program processes-names ps ${${EUID/(#s)0(#e)/xa}//[0-9]#/}ho command 2> /dev/null)"//[][\(\)]/}:#(ps|COMMAND|-*)}%%\ *}:t} }' -else +if [[ $service = killall5 || $OSTYPE != (linux|*bsd|dragonfly|darwin)* ]]; then _signals -p + return +fi + +typeset -a opts args +[[ $EUID = 0 || $_comp_priv_prefix[1] = sudo ]] && opts=( -a ) + +if _pick_variant psmisc=PSmisc unix --version; then + + local curcontext=$curcontext state state_descr line ret=1 + typeset -A opt_args + args=( + '(-e --exact)'{-e,--exact}'[require exact match for names longer than 15 chars]' + '(-I --ignore-case)'{-I,--ignore-case}'[do case insensitive process name match]' + '(-g --process-group)'{-g,--process-group}'[kill the process group to which the process belongs]' + '(-i --interactive)'{-i,--interactive}'[interactively ask for confirmation before killing]' + '(- : *)'{-l,--list}'[list all known signal names]' + '(-n --ns)'{-n+,--ns=}'[match against the PID namespace of the given PID]: : _pids' + '(-o --older-than)'{-o+,--older-than=}'[match only processes older than the specified time]:time:->time' + '(-q --quiet)'{-q,--quiet}'[do not complain if no processes were killed]' + '(-r --regexp)'{-r,--regexp}'[interpret process name as extended regular expression]' + '(1 -s --signal)'{-s+,--signal=}'[send the specified signal]: : _signals' + '(-u --user)'{-u+,--user=}'[kill only processes owned by specified user]: : _users' + '(-v --verbose)'{-v,--verbose}'[report if the signal was successfully sent]' + '(-w --wait)'{-w,--wait}'[wait for all killed processes to die]' + '(- : *)'{-V,--version}'[display version information]' + '(-y --younger-than)'{-y+,--younger-than=}'[match only processes younger than the specified time]:time:->time' + "1: : _alternative 'signals: :_signals -p' 'processes-names: :_process_names $opts'" + "*: :_process_names $opts" + ) + [[ $CURRENT = 2 || ( $CURRENT = 3 && $words[2] = (-Z|--context) ) ]] && \ + args+=( '(-Z --context)'{-Z+,--context=}'[specify SELinux security context]:regex pattern: ' ) + + _arguments -s -S -C : $args && ret=0 + + case $state in + (time) + local -a units=( 's:seconds' 'm:minutes' 'h:hours' 'd:days' + 'w:weeks' 'M:months' 'y:years' ) + if compset -P '[0-9]##(|.[0-9]#)'; then + _alternative 'float-numbers:: _message "float number"' \ + 'units:: _describe unit units' && ret=0 + else + _message 'float number and unit' && ret=0 + fi + ;; + esac + + return ret + +else # bsd and darwin + + if [[ $OSTYPE == (freebsd|dragonfly)* ]]; then + args=( '-j+[kill processes in specified jail]: :_jails -0' ) + opts+=( -t ) # long process names must be truncated + fi + args+=( + '-v[be more verbose about what will be done]' + '-e[use effective user ID for -u option]' + '(- : *)-help[give a help on command usage and exit]' + '(- : *)-l[list names of available signals and exit]' + '-m[interpret specified name as a regular expression]' + '-s[show only what will be done, but do not send any signal]' + '-d[print info about processes matched, but do not send any signal]' + '-u+[limit to processes belonging to specified user]: : _users' + '-t+[limit to processes running on specified tty]: :_ttys -od' + "-c+[with -u or -t, limit to processes matching specified name]: :_process_names $opts" + '-z[do not skip zombies]' + "*: :_process_names $opts" + + '(signal)' -$signals[2,-3] + ) + _arguments -s -S -A '-*' : $args + fi diff --git a/Completion/Unix/Command/_ldd b/Completion/Unix/Command/_ldd index 19b8a9105..1de1659a5 100644 --- a/Completion/Unix/Command/_ldd +++ b/Completion/Unix/Command/_ldd @@ -1,6 +1,6 @@ #compdef ldd -if _pick_variant gnu='(GNU|EGLIBC|Gentoo)' unix --version; then +if _pick_variant gnu='(Free Soft|GNU|EGLIBC|Gentoo)' unix --version; then args=( '(- *)--version[display version information]' '(- *)--help[display help information]' diff --git a/Completion/Unix/Command/_lldb b/Completion/Unix/Command/_lldb index 16e346cfb..0426f69f2 100644 --- a/Completion/Unix/Command/_lldb +++ b/Completion/Unix/Command/_lldb @@ -2,7 +2,8 @@ local curcontext=$curcontext state state_descr line expl ret=1 typeset -A opt_args -local -a args +typeset -a opts args +[[ $EUID = 0 || $_comp_priv_prefix[1] = sudo ]] && opts=( -a ) args=( '*'{-o+,--one-line=}'[run one-line lldb command after loading executable]:lldb command: ' @@ -29,7 +30,7 @@ args=( '(-c --core)'{-c+,--core=}'[specify core file to open]:core file:_files -g "*core*(-.)"' '*::executable and arguments:->exe_args' - name - '(-n --attach-name)'{-n+,--attach-name=}'[attach to the named process]:process name' + '(-n --attach-name)'{-n+,--attach-name=}"[attach to the named process]: :_process_names $opts" '(-w --wait-for)'{-w,--wait-for}'[wait for the specified process to launch]' - pid '(-p --attach-pid)'{-p+,--attach-pid=}'[attach to the specified process]:pid:_pids' diff --git a/Completion/Unix/Command/_lua b/Completion/Unix/Command/_lua new file mode 100644 index 000000000..7254d3819 --- /dev/null +++ b/Completion/Unix/Command/_lua @@ -0,0 +1,63 @@ +#compdef lua -P lua[0-9.-]## + +# Complete lua library names. We go out of our way here to support sub-modules +# (of the format foo.bar.baz), even though the way `lua -l` handles those isn't +# very nice, because it might be useful for informational purposes +(( $+functions[_lua_libraries] )) || +_lua_libraries() { + local p pre + local -a tmp tmp2 + + # Get Lua's library search path + tmp=( ${(s<;>)${(@f)"$( + _call_program library-path $words[1] -e '"print(package.path)"' + )"}} ) + # Support C modules, which aren't explicitly included in the above + tmp+=( ${(@)${(@M)tmp:#*'?.lua'}/%.lua/.so} ) + + for p in ${(@u)tmp}; do + # Don't recurse infinitely into the current directory; we'll just trust + # that all other paths are sensible + if [[ $p == './?'* ]]; then + tmp=( ${~${${(b)p}/'\?'/'*'}}(#qN) ) + else + tmp=( ${~${${(b)p}/'\?'/'**/*'}}(#qN) ) + fi + tmp2+=( ${(@)tmp##${p%%'?'*}} ) + done + + tmp=( ${(@)tmp2%%(/init.lua|.lua|.so)} ) + tmp=( ${(@u)${(@)tmp//\//.}} ) + + _wanted -x libraries expl 'Lua library' compadd -a "$@" - tmp +} + +_lua() { + local ret=1 + local -a context expl line state state_descr + local -A opt_args + + # Stacking not supported, no arguments are exclusive except `-` + _arguments -S -A '-*' : \ + '*-e+[execute specified command string]:command string' \ + '-E[ignore environment variables]' \ + '-i[enter interactive mode]' \ + '*-l+[specify library or module to require]: :_lua_libraries' \ + '-v[display version information]' \ + '(1 -)-[stop argument parsing and execute script on stdin]' \ + '1:Lua script:_files' \ + '*:: :->arg' \ + && ret=0 + + [[ $state == arg ]] && + if [[ $line[1] == - ]]; then + _description files expl 'script argument' + _files "${(@)expl}" && ret=0 + else + _normal && ret=0 + fi + + return ret +} + +_lua "$@" diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks new file mode 100644 index 000000000..363cedc8d --- /dev/null +++ b/Completion/Unix/Command/_luarocks @@ -0,0 +1,591 @@ +#compdef luarocks + +# Start of options' arguments' helpers +(( $+functions[__luarocks_command] )) || +__luarocks_command(){ + local -a commands=( + build:'build/compile a rock' + config:'query information about the LuaRocks configuration' + doc:'show documentation for an installed rock' + download:'download a specific rock file from a rocks server' + help:'help on commands' + install:'install a rock' + lint:'check syntax of a rockspec' + list:'list currently installed rocks' + make:'compile package in current directory using a rockspec' + new_version:'auto-write a rockspec for a new version of a rock' + pack:'create a rock, packing sources or binaries' + path:'return the currently configured package path' + purge:'remove all installed rocks from a tree' + remove:'uninstall a rock' + search:'query the LuaRocks servers' + show:'show information about an installed rock' + unpack:'unpack the contents of a rock' + upload:'upload a rockspec to the public rocks repository' + write_rockspec:'write a template for a rockspec file' + ) + _describe -t commands 'command' commands "$@" +} +local option_deps_modes='--deps-mode=[specify how to handle dependencies]:mode:__luarocks_deps_modes' +(( $+functions[__luarocks_deps_modes] )) || +__luarocks_deps_modes(){ + local modes=( + 'all:use all trees from the rocks_trees list for finding dependencies' + 'one:use only the current tree (possibly set with --tree)' + 'order:use trees based on order (use the current tree and all trees below it on the rocks_trees list)' + 'none:ignore dependencies altogether' + ) + _describe 'dependencies mode' modes +} +(( $+functions[__luarocks_rock_version] )) || +__luarocks_rock_version(){ + local i=2 + while [[ -n "${words[$i]}" ]]; do + if [[ ! "${words[$i]}" =~ '^-' ]]; then + case "$1" in + "external_or_local") + if [[ ! -f "${words[$i]}" ]]; then + _message -e "version for external rock ${words[$i]}" + return + else + _message -e "version for local rock ${words[$i]}" + fi + ;; + "installed") + # TODO: actually complete versions of installed rocks using the cache + # How does luarocks handles multiple versions of the same package? + # If anybody knows, please write something beautiful here + tree="$2" + if [[ -z "${tree}" ]]; then + _message -e "version for installed rock ${words[$i]}" + else + _message -e "version for installed rock ${words[$i]} on tree ${tree}" + fi + return + ;; + "new_version") + if [[ -f "${words[$i]}" ]]; then + _message -e "new version for rock ${words[$i]}" + return + fi + ;; + "new_rock") + _message -e "version for new rock ${words[$i]}" + return + ;; + esac + fi + i=$(( i + 1 )) + done +} +(( $+functions[__luarocks_lua_versions] )) || +__luarocks_lua_versions(){ + _values -s , 5.3 5.2 5.1 +} +(( $+functions[___luarocks_manually_store_cache_configs_paths] )) || +___luarocks_manually_store_cache_configs_paths(){ + user_config_path="$(_call_program user_config_path luarocks config --user-config)" + system_config_path="$(_call_program system_config_path luarocks config --system-config)" + { + print -r user_config_path=${(qq)user_config_path} + print -r system_config_path=${(qq)system_config_path} + } >! ${cache_dir}/luarocks_configs_paths +} +(( $+functions[___luarocks_manually_store_cache_configured_values] )) || +___luarocks_manually_store_cache_configured_values(){ + local default_trees=($(_call_program rock_trees luarocks config --rock-trees)) + # The following command usually gives somethins like this + # + # /home/me/.luarocks user + # /usr system + # + # We'll just use the 1st and 3rd elements in the array for the default trees + configured_user_tree="${default_trees[1]}" + configured_system_tree="${default_trees[3]}" + configured_lua_version="$(_call_program lua_ver luarocks config --lua-ver)" + { + print -r configured_lua_version=${(qq)configured_lua_version} + print -r configured_user_tree=${(qq)configured_user_tree} + print -r configured_system_tree=${(qq)configured_system_tree} + } >! ${cache_dir}/luarocks_configured_values +} +(( $+functions[___luarocks_installed_rocks_cache_policy] )) || +___luarocks_installed_rocks_cache_policy(){ + local cache_file="$1" + # Before checking the modification date of the manifests files vs the + # installed rocks cache files, we need to perform the following checks: + # - luarocks executable modification date vs modification date of cache file + # holding the default configuration files' locations + # ) if configuration files' locations were possibly changed, we need to: + # * set and cache the *possibly* new locations of the configuration files + # ) else: + # * retrieve from cache the configuration files' locations + # ) end if + # - configuration files' modification date vs modification date of cache file + # holding the values from `luarocks config --lua-ver` and `luarocks config + # --rock-trees` + # ) if the configuration files' locations were changed: + # * set and cache the values from the commands above + # ) else: + # ) if configuration files are newer: + # * set and cache the values from the commands above + # ) else: + # * retrive from cache the values of the commands above + # ) end if + # ) end if + + # Decide which directory to retrieve cache from, and ensure it exists + local cache_dir + zstyle -s ":completion:${curcontext}:" cache-path cache_dir + : ${cache_dir:=${ZDOTDIR:-$HOME}/.zcompcache} + if [[ ! -d "$cache_dir" ]]; then + [[ -e "$cache_dir" ]] && + _message "cache-dir ($cache_dir) isn't a directory\!" + fi + local where_luarocks="${commands[luarocks]}" + # luarocks_configured_values + local configured_lua_version configured_user_tree configured_system_tree + # luarocks_configs_paths + local user_config_path system_config_path + if [[ -e ${cache_dir}/luarocks_configs_paths ]]; then + if [[ ${where_luarocks} -nt ${cache_dir}/luarocks_configs_paths ]]; then + ___luarocks_manually_store_cache_configs_paths + else + . ${cache_dir}/luarocks_configs_paths + fi + else + ___luarocks_manually_store_cache_configs_paths + fi + if [[ -e ${cache_dir}/luarocks_configured_values ]]; then + if [[ ${user_config_path} -nt ${cache_dir}/luarocks_configured_values ]] || [[ ${system_config_path} -nt ${cache_dir}/luarocks_configured_values ]]; then + ___luarocks_manually_store_cache_configured_values + else + . ${cache_dir}/luarocks_configured_values + fi + else + ___luarocks_manually_store_cache_configured_values + fi + + local user_manifest_file="${configured_user_tree}/lib/luarocks/rocks-${configured_lua_version}/manifest" + local system_manifest_file="${configured_system_tree}/lib/luarocks/rocks-${configured_lua_version}/manifest" + local cache_status=1 + if [[ -f ${cache_file} ]]; then + if [[ -f ${user_manifest_file} ]]; then + if [[ ${user_manifest_file} -nt ${cache_file} ]]; then + cache_status=0 + fi + fi + if [[ -f ${system_manifest_file} ]]; then + if [[ ${system_manifest_file} -nt ${cache_file} ]]; then + cache_status=0 + fi + fi + fi + return cache_status +} +(( $+functions[__luarocks_installed_rocks] )) || +__luarocks_installed_rocks(){ + # This function optionally recieves one argument of the tree in which + # installed rocks are searched for. If this argument is used, the installed + # rocks which will be completed by this function will not use the cache which + # is valid only for installed rocks on default trees like /usr/lib/luarocks + # and ~/.luarocks + local tree="$1" + if [[ -z ${tree} ]]; then + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy ___luarocks_installed_rocks_cache_policy + fi + if _cache_invalid luarocks_installed_list; then + rocks_list=($(luarocks list --porcelain)) + _store_cache luarocks_installed_list rocks_list + else + _retrieve_cache luarocks_installed_list + fi + if [[ -z ${rocks_list} ]]; then + _message -r "no installed rocks" + return + fi + if _cache_invalid luarocks_installed_names; then + rocks_names=() + for i in {1.."${#rocks_list[@]}"..4}; do + rocks_names+=("${rocks_list[$i]}") + done + _store_cache luarocks_installed_names rocks_names + else + _retrieve_cache luarocks_installed_names + fi + if _cache_invalid luarocks_installed_versions; then + rocks_versions=() + for i in {2.."${#rocks_list[@]}"..4}; do + rocks_versions+=("${rocks_list[$i]}") + done + _store_cache luarocks_installed_versions rocks_versions + else + _retrieve_cache luarocks_installed_versions + fi + if _cache_invalid luarocks_installed_descriptions; then + rocks_descriptions=() + for i in {1.."${#rocks_names[@]}"}; do + name_version_description="$(luarocks show ${rocks_names[$i]} 2>/dev/null | head -2 | tail -1)" + total_length=${#name_version_description} + garbage_length="$((${#rocks_names[$i]} + ${#rocks_versions[$i]} + 5))" + description="${name_version_description[${garbage_length},${total_length}]}" + rocks_descriptions+=("${description}") + done + _store_cache luarocks_installed_descriptions rocks_descriptions + else + _retrieve_cache luarocks_installed_descriptions + fi + if _cache_invalid luarocks_installed_names_and_descriptions; then + rocks_names_and_descriptions=() + for i in {1.."${#rocks_names[@]}"}; do + name_and_description=${rocks_names[$i]}:${rocks_descriptions[$i]} + rocks_names_and_descriptions+=(${name_and_description}) + done + else + _store_cache luarocks_installed_names_and_descriptions rocks_names_and_descriptions + fi + else + rocks_list=($(luarocks --tree="${tree}" list --porcelain 2> /dev/null)) + if [[ -z ${rocks_list} ]]; then + _message "no installed rocks in the specified tree" + return + fi + rocks_names=() + for i in {1.."${#rocks_list[@]}"..4}; do + rocks_names+=("${rocks_list[$i]}") + done + rocks_versions=() + for i in {2.."${#rocks_list[@]}"..4}; do + rocks_versions+=("${rocks_list[$i]}") + done + rocks_descriptions=() + for i in {1.."${#rocks_names[@]}"}; do + name_version_description="$(luarocks show ${rocks_names[$i]} 2> /dev/null | head -2 | tail -1)" + total_length=${#name_version_description} + garbage_length="$((${#rocks_names[$i]} + ${#rocks_versions[$i]} + 5))" + description="${name_version_description[${garbage_length},${total_length}]}" + rocks_descriptions+=("${description}") + done + rocks_names_and_descriptions=() + for i in {1.."${#rocks_names[@]}"}; do + name_and_description=${rocks_names[$i]}:${rocks_descriptions[$i]} + rocks_names_and_descriptions+=(${name_and_description}) + done + fi + _describe 'installed rocks' rocks_names_and_descriptions +} +# Used to complete one or more of the followings: +# - .rockspec file +# - .src.rock file +# - external rock +(( $+functions[__luarocks_rock] )) || +__luarocks_rock(){ + local -a alts=() + while [[ $# -gt 0 ]]; do + arg="$1" + case "$arg" in + (rockspec) + alts+=('files:rock file:_files -g "*.rockspec(-.)"') + shift 1 + continue + ;; + (rockpack) + alts+=(':rock file:{_files -g "*.src.rock(-.)"}') + shift 1 + continue + ;; + (external) + alts+=(':external rock:') + shift 1 + continue + ;; + (installed) + tree="$2" + alts+=(":local rock:{__luarocks_installed_rocks ${tree}}") + if [[ -z "${tree}" ]]; then + shift + else + shift 2 + fi + continue + ;; + esac + shift + continue + done + _alternative ${alts[@]} +} +(( $+functions[__luarocks_git_tags] )) || +__luarocks_git_tags(){ + # Copied straight from definition of _git + local expl + declare -a tags + tags=(${${(f)"$(_call_program tagrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) + __git_command_successful $pipestatus || return 1 + _wanted tags expl tag compadd -M 'r:|/=**' "$@" -a - tags +} + +# End of options' arguments' helpers & Start of sub commands helpers + +# arguments: +# - must: .rockspec file / external rock +# - optional: version (only when chossing external rock) +local make_command_options=( + '--pack-binary-rock[produce a .rock file with the contents of compilation inside the current directory instead of installing it]' + '--keep[do not remove previously installed versions of the rock after building a new one]' + '--branch=[override the `source.branch` field in the loaded rockspec]:NAME:{_message "branch name"}' +) +local build_command_options=( + "${make_command_options[@]}" + '--only-deps[installs only the dependencies of the rock]' + $option_deps_modes +) +(( $+functions[_luarocks_build] )) || +_luarocks_build(){ + _arguments -A "-*" \ + "${build_command_options[@]}" \ + '1: :{__luarocks_rock "rockspec" "external"}' \ + '2:: :{__luarocks_rock_version "external_or_local"}' +} +# arguments: +# - must: option +local config_command_options=( + '--lua-incdir[path to Lua header files]' + '--lua-libdir[path to Lua library files]' + '--lua-ver[lua version (in major.minor format)]' + '--system-config[location of the system config file]' + '--user-config[location of the user config file]' + '--rock-trees[rocks trees in useFirst the user tree, then the system tree]' +) +(( $+functions[_luarocks_config] )) || +_luarocks_config(){ + _arguments "${config_command_options[@]}" +} +# arguments: +# - must: installed rock +local doc_command_options=( + '--home[open the home page of project]' + '--list[list documentation files only]' +) +(( $+functions[_luarocks_doc] )) || +_luarocks_doc(){ + _arguments \ + "${doc_command_options[@]}" \ + '1: :{__luarocks_rock "installed" '"${opt_args[--tree]}"'}' +} +# arguments: +# - must: external only rockspec +local download_command_options=( + '--all[download all files if there are multiple matches]' + '--source[download .src.rock if available]' + '--rockspec[download .rockspec if available]' + '--arch=[download rock for a specific architecture]:ARCH:' +) +(( $+functions[_luarocks_download] )) || +_luarocks_download(){ + _arguments -A "-*" \ + "${download_command_options[@]}" \ + '1: :{__luarocks_rock "external"}' \ + '2:: :{__luarocks_rock_version "external_or_local"}' +} +# arguments: +# must: luarocks sub command +(( $+functions[_luarocks_help] )) || +_luarocks_help(){ + _arguments '1: :__luarocks_command' +} +# arguments: +# - must: .rockspec file / external rock +# - optional: version +# NOTE: it receives the same argument as the build command and it accepts the same options as well +(( $+functions[_luarocks_install] )) || +_luarocks_install(){ + _luarocks_build +} +# arguments: +# - must: rockspec file (first and last) +(( $+functions[_luarocks_lint] )) || +_luarocks_lint(){ + _arguments '1:: :{__luarocks_rock "rockspec"}' +} +# arguments: +# NOTE: receives only options +local list_command_options=( + '--outdated[list only rocks for which there is a higher version available in the rocks server]' + '--porcelain[produce machine-friendly output]' +) +(( $+functions[_luarocks_list] )) || +_luarocks_list(){ + _arguments "${list_command_options[@]}" +} +# arguments: +# - optional: rockspec file +# NOTE: it's options were already described above. +(( $+functions[_luarocks_make] )) || +_luarocks_make(){ + _arguments '1:: :{__luarocks_rock "rockspec"}' +} +# arguments: +# - optional: .rockspec file / external rock +# - optional: version (unless a --tag was given) +# - optional: URL +local new_version_command_options=( + '--tag=[if no version is specified, this option'"'"'s argument is used instead]:tag:__luarocks_git_tags' +) +(( $+functions[_luarocks_new_version] )) || +_luarocks_new_version(){ + _arguments -A "-*" \ + "${new_version_command_options[@]}" \ + '1:: :{__luarocks_rock "external" "rockspec"}' \ + '2:: :{__luarocks_rock_version "external_or_local"}' \ + '3:: :_urls' +} +# arguments: +# - must: .rockspec file / external rock +# - optional: version +(( $+functions[_luarocks_pack] )) || +_luarocks_pack(){ + _luarocks_build +} +# arguments: +# NOTE: receives only options +local path_command_options=( + '--bin[adds the system path to the output]' + '--append[appends the paths to the existing paths]' + '--lr-path[exports the Lua path (not formatted as shell command)]' + '--lr-cpath[exports the Lua cpath (not formatted as shell command)]' + '--lr-bin[exports the system path (not formatted as shell command)]' +) +(( $+functions[_luarocks_path] )) || +_luarocks_path(){ + _arguments "${path_command_options[@]}" +} +# NOTE: receives only options yet --tree is mandatory +# NOTE: --force can be used only in conjunction with --old-versions +local option_force='--force[force removing old versions when]' +local purge_command_options=( + '--old-versions[keep the highest-numbered version of each rock and remove the other ones]' + $option_force +) +(( $+functions[_luarocks_purge] )) || +_luarocks_purge(){ + _arguments "${purge_command_options[@]}" +} +# arguments: +# - must: locally installed rock +# - optional: version +local option_force_fast='--force-fast[works like --force but doesn'"'"'t reports forced removals]' +local remove_command_options=( + $option_deps_modes + $option_force + $option_force_fast +) +(( $+functions[_luarocks_remove] )) || +_luarocks_remove(){ + _arguments -A "-*" \ + "${remove_command_options[@]}" \ + '1: :{__luarocks_rock "installed" '"${opt_args[--tree]}"'}' \ + '2:: :{__luarocks_rock_version "installed" '"${opt_args[--tree]}"'}' +} +# arguments: +# - must: string as a search query +local search_command_options=( + '--source[return only rockspecs and source rocks]' + '--binary[return only pure Lua and binary rocks (rocks that can be used with the "install" command without requiring a C toolchain)]' + '--all[list all contents of the server that are suitable to this platform, do not filter by name]' +) +(( $+functions[_luarocks_search] )) || +_luarocks_search(){ + _arguments \ + "${search_command_options[@]}" \ + '*:SEARCH QUERY:' +} +# arguments: +# - must: installed rock +local show_command_options=( + '--home[home page of project]' + '--modules[all modules provided by this package as used by require()]' + '--deps[packages this package depends on]' + '--rockspec[the full path of the rockspec file]' + '--mversion[the package version]' + '--rock-tree[local tree where rock is installed]' + '--rock-dir[data directory of the installed rock]' +) +(( $+functions[_luarocks_show] )) || +_luarocks_show(){ + _arguments \ + "${show_command_options[@]}" \ + "1: :{__luarocks_rock 'installed' "${opt_args[--tree]}"}" +} +# arguments: +# - must: rockpack file / external rock +# - optional: version (only when chossing external rock) +local unpack_command_options=( + '--force[unpack files even if the output directory already exists]' +) +(( $+functions[_luarocks_unpack] )) || +_luarocks_unpack(){ + _arguments \ + "${unpack_command_options[@]}" \ + '1: :{__luarocks_rock "rockpack" "external"}' +} +# arguments: +# - must: rockspec file +local upload_command_options=( + '--skip-pack[do not pack and send source rock]' + '--api-key=[give it an API key]:KEY:{_message "api key"}' + '--force[replace existing rockspec if the same revision of a module already exists]' +) +(( $+functions[_luarocks_upload] )) || +_luarocks_upload(){ + _arguments \ + "${upload_command_options[@]}" \ + '1: :{__luarocks_rock "rockspec"}' +} +# arguments: +# - optional: name +# - optional: version +# - optional: URL / PATH +# receives as an argument a name and a version with optionally a URL/PATH +local write_rockspec_command_options=( + '--output=[write the rockspec with the given filename]:FILE:_files' + '--license=[specify a license string]:license (e.g. "MIT/X11" or "GNU GPL v3")' + '--summary=[a short one-line description summary]:summary:{_message -e "short summary of the rock"}' + '--detailed=[a longer description string]:detailed_text:{_message -e "detailed description of the rock"}' + '--homepage=[project homepage]:URL:_urls' + '--lua-version=[supported Lua versions]:LUA_VER:__luarocks_lua_versions' + '--rockspec-format=[rockspec format version, such as "1.0" or "1.1"]:VER: ' + '--tag=[tag to use. Will attempt to extract version number from it]:tag:__git_tag' + '--lib=[comma separated list of C library files to link to]:library files' +) +(( $+functions[_luarocks_write_rockspec] )) || +_luarocks_write_rockspec(){ + _arguments -A "-*" \ + "${write_rockspec_command_options[@]}" \ + '1:: :{_message "new rock name"}' \ + '2:: :{__luarocks_rock_version "new_rock"}' \ + '3:: :_urls' +} + +# The real thing +_arguments -C \ + '(--server --only-server)--server=[fetch rocks/rockspecs from this server]:HOST:_hosts' \ + '(--server --only-server)--only-server=[fetch rocks/rockspecs from this server only]:HOST:_hosts' \ + '--only-sources=[restrict downloads to paths matching the given URL]:URL:_urls' \ + '--tree=[which tree to operate on]:TREE:{_files -/}' \ + '--local[use the tree in the user'"'"'s home directory]' \ + '--verbose[display verbose output of commands executed]' \ + '--timeout=[timeout on network operations]:SECONDS:{_message "timeout (seconds)"}' \ + '1: :__luarocks_command' \ + '*::arg:->args' + +case "$state" in + (args) + curcontext="${curcontext%:*:*}:luarocks-${words[1]}:" + if [[ $? != 1 ]]; then + _call_function ret _luarocks_${words[1]} + fi +esac diff --git a/Completion/Unix/Command/_lynx b/Completion/Unix/Command/_lynx index 6c4d57f6f..d25b03975 100644 --- a/Completion/Unix/Command/_lynx +++ b/Completion/Unix/Command/_lynx @@ -1,7 +1,5 @@ #compdef lynx -# Lynx Version 2.8.7rel.1 (05 Jul 2009) - local curcontext="$curcontext" state line ret=1 typeset -A opt_args @@ -26,7 +24,9 @@ _arguments -C \ '-cmd_log=[log keystroke commands to the given file]:keystroke log:_files' \ '-cmd_script=[read keystroke commands from the given file (see -cmd_log)]:keystroke log:_files' \ '-color[forces color mode on, if available]' \ - '-connect_timeout=[set the N-second connection timeout (18000)]:connection timeout (seconds):' \ + '-collapse_br_tags[toggle collapsing of BR tags (on)]' \ + '-connect_timeout=[set the N-second connection timeout]:connection timeout (seconds) [18000]' \ + '-convert_to=[convert input]:format:_mime_types' \ '-cookie_file=[specifies a file to use to read cookies]:cookie file:_files' \ '-cookie_save_file=[specifies a file to use to store cookies]:cookie file:_files' \ '-cookies[toggles handling of Set-Cookie headers (on)]' \ @@ -34,7 +34,8 @@ _arguments -C \ '-crawl[with -traversal, output each page to a file with -dump, format output as with -traversal, but to stdout]' \ '-curses_pads[uses curses pad feature to support left/right shifting (on)]' \ '-debug_partial[incremental display stages with MessageSecs delay (off)]' \ - '-delay=[set NNN-second delay at statusline message (0.000)]:delay (seconds):' \ + '-default_colors[use terminal default foreground/background colors (on)]' \ + '-delay=[set NNN-second delay at statusline message]:delay (seconds) [0.000]' \ "-display=[set the display variable for X exec'ed programs]:display:_x_display" \ '-display_charset=[charset for the terminal output]:character set:' \ "-dont_wrap_pre[inhibit wrapping of text in <pre> when -dump'ing and -crawl'ing, mark wrapped lines in interactive session (off)]" \ @@ -47,7 +48,7 @@ _arguments -C \ '-fileversions[include all versions of files in local VMS directory listings]' \ '-force_empty_hrefless_a[force HREF-less 'A' elements to be empty (close them as soon as they are seen) (off)]' \ '-force_html[forces the first document to be interpreted as HTML (off)]' \ - '-force_secure[toggles forms-based vs old-style options menu (on)]' \ + '-force_secure[toggle forcing of the secure flag for SSL cookies (off)]' \ '-forms_options[toggles forms-based vs old-style options menu (on)]' \ '-from[toggle transmission of From headers (on)]' \ '-ftp[disable ftp access (off)]' \ @@ -57,11 +58,13 @@ _arguments -C \ '-hiddenlinks=[hidden links: options are merge, listonly, or ignore]:option:(merge listonly ignore)' \ "-historical[toggles use of '>' or '-->' as terminator for comments (off)]" \ '-homepage=[set homepage separate from start page]:URL:->html' \ + '-html5_charsets[toggle use of HTML5 charset replacements]' \ '-image_links[toggles inclusion of links for all images (off)]' \ '-index=[set the default index file to URL]:URL:->html' \ '-ismap[toggles inclusion of ISMAP links when client-side MAPs are present (off)]' \ '-justify[do justification of text (off)]' \ '-link=[starting count for lnk#.dat files produced by -crawl (0)]:starting count:' \ + '-list_inline[with -dump, show links inline with text]' \ '-listonly[with -dump, forces it to show only the list of links (off)]' \ '-localhost[disable URLs that point to remote hosts (off)]' \ '-locexec[enable local program execution from local files only (if lynx was compiled with local execution enabled)]' \ @@ -91,6 +94,7 @@ _arguments -C \ '-nostatus[disable the miscellaneous information messages (off)]' \ '-notitle[disable the title at the top of each page (off)]' \ '-nounderline[disable underline video-attribute]' \ + "-nozap=[disable checks for the 'z' key]:duration:(all initially full)" \ '-number_fields[force numbering of links as well as form input fields (off)]' \ '-number_links[force numbering of links (off)]' \ '-partial[toggles display partial pages while downloading (on)]' \ @@ -105,7 +109,7 @@ _arguments -C \ '-pseudo_inlines[toggles pseudo-ALTs for inlines with no ALT string (on)]' \ '-raw[toggles default setting of 8-bit character translations or CJK mode for the startup character set (off)]' \ '-realm[restricts access to URLs in the starting realm (off)]' \ - '-read_timeout=[set the N-second read-timeout (18000)]:timeout (seconds):' \ + '-read_timeout=[set the N-second read-timeout]:timeout (seconds) [18000]' \ '-reload[flushes the cache on a proxy server (only the first document affected) (off)]' \ '-restrictions=[use -restrictions to see list]:options:->restrictions' \ '-resubmit_posts[toggles forced resubmissions (no-cache) of forms with method POST when the documents they returned are sought with the PREV_DOC command or from the History List (off)]' \ @@ -113,6 +117,9 @@ _arguments -C \ '-scrollbar[toggles showing scrollbar (off)]' \ '-scrollbar_arrow[toggles showing arrows at ends of the scrollbar (on)]' \ '-selective[require .www_browsable files to browse directories]' \ + '-session=[resume from specified file on startup and save session to it on exit]:session file:_files' \ + '-sessionin=[resume session from specified file on startup]:session file:_files' \ + '-sessionout=[save session to specified file on exit]:session file:_files' \ '-short_url[enables examination of beginning and end of long URL in status line (off)]' \ "-show_cfg[show 'LYNX.CFG' setting (off)]" \ '-show_cursor[toggles hiding of the cursor in the lower right corner (on)]' \ @@ -131,16 +138,18 @@ _arguments -C \ '-trace[turns on Lynx trace mode (off)]' \ '-trace_mask=[customize Lynx trace mode]:trace mask:(0 1 2 3 4 5 6 7)' \ '-traversal[traverse all http links derived from startfile]' \ + '-trim_blank_lines[toggle trimming of leading/trailing/collapsed-br blank lines (on)]' \ '-trim_input_fields[trim input text/textarea fields in forms (off)]' \ '-underline_links[toggles use of underline/bold attribute for links (off)]' \ '-underscore[toggles use of _underline_ format in dumps (off)]' \ + '-unique_urls[toggle use of unique-urls setting for -dump and -listonly options (off)]' \ '-use_mouse[turn on mouse support (off)]' \ '-useragent=[set alternate Lynx User-Agent header]:user-agent header:' \ '-validate[accept only http URLs (meant for validation) implies more restrictions than -anonymous, but goto is allowed for http and https (off)]' \ '-verbose[toggles [LINK\], [IMAGE\] and [INLINE\] comments with filenames of these images (on)]' \ '(- *)-version[print Lynx version information]' \ '-vikeys[enable vi-like key movement (off)]' \ - '-width=[screen width for formatting of dumps (default is 80)]:number of columns:' \ + '-width=[specify screen width for formatting of dumps]:number of columns [80]' \ '-with_backspaces[emit backspaces in output if -dumping or -crawling]' \ '-xhtml-parsing[enable XHTML 1.0 parsing (off)]' \ ':URL:->html' && ret=0 @@ -148,12 +157,12 @@ _arguments -C \ case "$state" in restrictions) _values -s ',' 'restriction' \ - \? all bookmark bookmark_exec change_exec_perms chdir default \ - dired_support disk_save dotfiles download editor exec exec_frozen \ + \? all bookmark bookmark_exec change_exec_perms chdir compileopts_info \ + default dired_support disk_save dotfiles download editor exec exec_frozen \ externals file_url goto inside_ftp inside_news inside_rlogin \ - inside_telnet jump lynx_cgi mail multibook news_post options_save \ - outside_ftp outside_news outside_rlogin outside_telnet print shell \ - suspend telnet_port useragent && return + inside_telnet jump lynxcfg_info lynxcfg_xinfo lynxcgi mail multibook \ + news_post options_save outside_ftp outside_news outside_rlogin \ + outside_telnet print shell suspend telnet_port useragent && return ;; html) _alternative 'files:file:_files -g "*.x#html#(-.)"' 'urls:URL:_urls' && return diff --git a/Completion/Unix/Command/_lz4 b/Completion/Unix/Command/_lz4 new file mode 100644 index 000000000..d69091d00 --- /dev/null +++ b/Completion/Unix/Command/_lz4 @@ -0,0 +1,103 @@ +#compdef lz4 lz4c lz4c32 lz4cat unlz4 + +# Notes: +# - All lz4 CLI tools take the same options — you can do `unlz4 --compress` if +# you want — and we complete accordingly. One can make a reasonable argument +# that we shouldn't, but...? +# - The only exceptions to the above are the legacy compression options (-c0, +# -hc, and so on) — only lz4c accepts these. Each of these options is +# interpreted separately otherwise (e.g., -c0 becomes equivalent to -c -0) +# - All these tools use a non-standard option-handling method that we don't +# fully support. For example, the tool will let you do things like `-b1e3i3` +# instead of `-b1 -e3 -i3` — we won't + +local ret=1 +local -a context line state state_descr expl args levels=( -{1..16} ) +local -A opt_args val_args + +args=( + + excl # Fully exclusive options + '(: -)'{-h,--help}'[display help information]' + '(: -)-H[display long help information]' + '(: -)'{-V,--version}'[display version information]' + + misc # Misc. arguments + '(-q -v --quiet --verbose)*'{-q,--quiet}'[reduce output verbosity]' + '(-q -v --quiet --verbose)*'{-v,--verbose}'[increase output verbosity]' + '*::: :->files' + + B # Benchmark/compress-mode options (not allowed with legacy format) + '(d t -l)*-B-[specify block property]: :->block-props' + '(d t -l --no-content-size)--content-size[record original uncompressed size]' + '(d t -l --no-frame-crc)--frame-crc[enable content checksum]' + '(d t -l --content-size)--no-content-size[do not record original uncompressed size]' + '(d t -l --frame-crc)--no-frame-crc[disable content checksum]' + '(d t -l --sparse)--no-sparse[disable sparse-file support]' + '(d t -l --no-sparse)--sparse[enable sparse-file support]' + + C # Compress/decompress-mode options + '(b t -c --stdout --to-stdout)'{-c,--stdout}'[write on standard output]' + '(b t -y)'{-f,--force}'[overwrite target without prompting, or cat on standard output]' + '(b t -k --keep --rm)'{-k,--keep}'[keep source file]' + '(b t -m -r --multiple)'{-m,--multiple}'[take multiple input files]' + '!(b -t -f -y --force)--no-force' + '(b t -m --multiple)-r[operate recursively on directories]' + '(b t -k --keep)--rm[remove source file]' + '!(b t -c --stdout)--to-stdout' + + b # Benchmark-mode options + "(C c d t)-b-[benchmark file using specified compression level]::compression level:(${(j< >)levels//-/})" + "(C c d t)-e-[specify upper compression level limit (with -b)]:compression level:(${(j< >)levels//-/})" + '(C c d t)-i-[specifiy minimum evaluation time (with -b)]:evaluation time (seconds)' + + c # Compress-mode options + "(b d t ${(j< >)levels} -c0 -c1 -c2 -hc)"${^levels} + '(B b d t -m -r --multiple)-l[compress using legacy (Linux kernel) format]' + '(b d t -z --compress)'{-z,--compress}'[compress file]' + + d # Decompress-mode options + '(B b c d t)'{-d,--decompress}'[decompress file]' + '!(B b c d t)--uncompress' + + t # Test-mode options + '(B C b c d t)'{-t,--test}'[test integrity of compressed file]' +) +[[ $service == lz4c ]] && args+=( + + l # Legacy compress-mode options (not to be confused with the legacy format) + "(b d t ${(j< >)levels} -c1 -c2 -hc)-c0[use fast compression (like -0)]" + "(b d t ${(j< >)levels} -c0 -c2 -hc)-c1[use high compression (like -9)]" + "(b d t ${(j< >)levels} -c0 -c1 -c2 -hc)"{-c2,-hc}'[use very high compression (like -12)]' + '(b t -f --force)-y[overwrite target without prompting]' +) + +_arguments -s -S : $args && ret=0 + +case $state in + block-props) + # The usage help indicates that the use of an explicit byte value (-B32 or + # greater) is only for benchmarking, and indeed when such a value is given + # the tool prints a message prefixed with 'bench:'... but there is nothing + # that actually restricts this to the benchmark mode, so...? + _values 'predefined block property or block size in bytes (32+)' \ + '4[set block size to 64 KiB]' \ + '5[set block size to 256 KiB]' \ + '6[set block size to 1 MiB]' \ + '7[set block size to 4 MiB]' \ + 'D[enable block dependency]' \ + 'X[enable block checksum]' \ + && ret=0 + ;; + files) + if + (( CURRENT == 1 )) || + [[ -n ${opt_args[(i)*-(-b|-m|-r|--multiple)]} ]] + then + if [[ -n ${opt_args[(i)*--r]} ]]; then + _description files expl 'input file or directory' + else + _description files expl 'input file' + fi + _files "${(@)expl}" && ret=0 + elif (( CURRENT == 2 )); then + _description files expl 'output file' + _files "${(@)expl}" && ret=0 + else + _message 'no more arguments' && ret=0 + fi + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 1761bba71..e23906373 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -177,7 +177,7 @@ _make() { '(- *)'{-h,--help}'[print help message and exit]' '(-i --ignore-errors)'{-i,--ignore-errors}'[ignore errors from recipes]' '*'{-I,--include-dir=}'[search DIRECTORY for included makefiles]:search path for included makefile:->dir' - '(-j --jobs)'{-j,--jobs=}'[allow N jobs at once; infinite jobs with no arg]:number of jobs' + '(-j --jobs)'{-j+,--jobs=}'[allow N jobs at once; infinite jobs with no arg]:number of jobs' '(-k --keep-going)'{-k,--keep-going}"[keep going when some targets can't be made]" '(-l --load-average --max-load)'{-l,--load-average=,--max-load}"[don't start multiple jobs unless load is below N]:load" '(-L --check-symlink-times)'{-L,--check-symlink-times}'[use the latest mtime between symlinks and target]' diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 67810e1dc..41ae85a1f 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -1,16 +1,174 @@ #compdef man apropos whatis +# Notes: +# - Solaris is seemingly the only OS that doesn't allow the `man n page` syntax; +# you must use `man -s n page` +# - We assume that Linux distributions are using either man-db or mandoc +# - @todo Would be nice to support completing the initial operand as a section +# name (on non-Solaris systems) +# - @todo We don't support the man-db syntax <name>.<section> (e.g., `ls.1`) +# - @todo We don't support the man-db feature of 'sub-pages' — that is, treating +# pairs of operands like `git diff` as `git-diff` +# - @todo Option exclusivity isn't super accurate +# - @todo Solaris man accepts a single hyphen as the first option to disable +# paging (like AIX's -c); we don't support that +# - @todo Linux apropos/whatis take options; we don't complete them yet + _man() { - local dirs expl mrd awk + local dirs expl mrd awk variant noinsert + local -a context line state state_descr args modes + local -aU sects + local -A opt_args val_args sect_descs - if (( $words[(I)-M] == (( $CURRENT - 1 )) )); then - _directories && return 0 - fi + if [[ $service == man ]]; then + # We'll treat all mandoc-based systems (Alpine, various Illumos distros, + # etc.) as OpenBSD + _pick_variant -r variant openbsd='-S subsection' $OSTYPE --- + + modes=( + -f -K -k -l -R -w -W + --apropos + --global-apropos + --local-file + --location + --location-cat + --recode + --whatis + --where + --where-cat + ) + [[ $variant == darwin* ]] && modes+=( -t ) - if [[ $service == man ]] && (( $words[(I)-l] + $words[(I)--local-file] )); then - _files || return 0 + args=( + "(${(j< >)modes})"{-f,--whatis}'[display short description (like whatis)]' + "(${(j< >)modes})"{-k,--apropos}'[search for keyword (like apropos)]' + '(-M --manpath)'{-M+,--manpath=}'[specify manual search path]:manual search path:_sequence -s\: _directories' + ) + if [[ $variant == (darwin|dragonfly|freebsd|linux)* ]]; then + args+=( + '(-a -S -s --all --sections)'{-a,--all}'[display all matching pages]' + '(-P --pager)'{-P+,--pager=}'[specify output pager]:pager:_path_commands' + # @todo Could enumerate these + '(-p --preprocessor)'{-p+,--preprocessor=}'[specify roff preprocessor sequence]:preprocessor sequence' + ) + else + args+=( '(-s)-a[display all matching pages]' ) + fi + [[ $variant == (aix|solaris)* ]] || args+=( + '(-C --config-file)'{-C+,--config-file=}'[specify configuration file]:configuration file:_files' + "(${(j< >)modes})"{-w,--path,--where}'[display file locations]' + ) + [[ $variant == (aix|netbsd|openbsd)* ]] || args+=( + # @todo FreeBSD allows this to be given multiple times + '(-d --debug)'{-d,--debug}'[display debugging information]' + ) + [[ $variant == (darwin|dragonfly|freebsd|linux|solaris|aix)* ]] && args+=( + '(-7 -H -t --ascii --html --troff)'{-t,--troff}'[format man page using troff]' + ) + [[ $variant == (darwin|linux)* ]] && args+=( + "(${(j< >)modes})"{-K,--global-apropos}'[search for keyword in all pages]' + '(-m --systems)'{-m+,--systems=}'[search manual of specified system]:operating system' + ) + [[ $variant == (darwin|dragonfly|freebsd)* ]] && args+=( + '(: -)-h[display help information]' + '(-a)-S+[specify manual sections to search]: :->sects' + ) + [[ $variant == (dragonfly|freebsd)* ]] && args+=( + # @todo Could enumerate these + '-m[search manual of specified architecture]:architecture' + '-o[use non-localized man pages]' + ) + [[ $variant == (netbsd|openbsd)* ]] && args+=( + '-c[disable paging]' + '-m[augment manual search path]:manual search path:_sequence -s\: _directories' + '(-a)-s+[specify manual section to search]: :->sects' + ) + [[ $variant == linux* ]] && args+=( + '(: -)'{-\?,--help}'[display help information]' + '(-7 -t -H -T -Z --ascii --html --troff --troff-device --ditroff)'{-7,--ascii}'[translate man pages for 7-bit terminal]' + '(-D --default)'{-D,--default}'[reset man to default options]' + # @todo Could enumerate these + '(-E --encoding)'{-E+,--encoding=}'[specify output encoding]:encoding' + '(-e --extension)'{-e+,--extension=}'[specify sub-extension]:sub-extension' + '(-H --html)'{-H-,--html=-}'[produce HTML output for specified browser]::Web browser:_path_commands' + '(-i -I --ignore-case --match-case)'{-i,--ignore-case}'[search case-insensitively]' + '(-i -I --ignore-case --match-case)'{-I,--match-case}'[search case-sensitively]' + '(-L --locale)'{-L+,--locale=}'[specify locale]:locale:_locales' + "(${(j< >)modes})"{-l+,--local-file=}'[format and display specified file]:*:::manual file:_files' + "!(${(j< >)modes})"{--location,--location-cat} + '--names-only[match only page names (with --regex or --wildcard)]' + '(--nh --no-hyphenation)'{--nh,--no-hyphenation}'[disable hyphenation]' + '(--nj --no-justification)'{--nj,--no-justification}'[disable justification]' + '--no-subpages[do not combine pairs of page names into single page name]' + # @todo Could enumerate these + "(${(j< >)modes})"{-R+,--recode=}'[output man page in specified encoding]:encoding' + '(-r --prompt)'{-r+,--prompt=}'[specify prompt for less]:less prompt' + '(-a --all --wildcard)--regex[treat page name as regular expression]' + '(-a -S -s --all --sections)'{-S+,-s+,--sections=}'[specify manual sections to search]: :->sects' + # @todo Could enumerate these + '(-T -t --troff --troff-device)'{-T-,--troff-device=-}'[specify roff output device]::roff output device' + '(-u --update)'{-u,--update}'[update database caches]' + '(: -)--usage[display brief usage information]' + '(: -)'{-V,--version}'[display version information]' + "(${(j< >)modes})"{-W,--where-cat}'[display cat file locations]' + '--warnings=[enable specified groff warnings]:groff warnings' + '(-a --all --regex)--wildcard[treat page name as shell glob]' + # @todo Could enumerate these + '(-X --gxditview)'{-X-,--gxditview=-}'[display output in gxditview using specified DPI]::resolution (DPI) [75]' + # @todo Post-process how? + '(-t --troff -Z --ditroff)'{-Z,--ditroff}'[post-process output for chosen device]' + ) + [[ $variant == darwin* ]] && args+=( + # We use _files here because browsers are usually in /Applications, which + # typically isn't in PATH + '-B+[specify browser to use for HTML files]:Web browser:_files' + '-c[reformat source man page]' + # @todo -d should be exclusive with this above + '(-d)-D[display man page along with debugging information]' + '(-D -F --preformat)'{-F,--preformat}'[format man page only (do not display)]' + '-H+[specify command to render HTML as text]:HTML pager:_path_commands' + # --help and --version are undocumented but functional + '(: -)--help[display help information]' + # -s is also undocumented; it's provided for compatibility with Solaris + '!(-S)-s+: :->sects' + '(: -)'{-v,--version}'[display version information]' + "(${(j< >)modes})-W[display file locations, one per line, with no other information]" + ) + [[ $variant == netbsd* ]] && args+=( + '-h[display only synopsis lines]' + '(: -)-p[display manual search path]' + '-S+[display only man pages with file names matching specified string]:search string' + ) + [[ $variant == openbsd* ]] && args+=( + "(${(j< >)modes})-l+[format and display specified file]:*:::manual file:_files" + # @todo Could enumerate these + '-S[search manual of specified architecture]:architecture' + ) + [[ $variant == solaris* ]] && args+=( + "(${(j< >)modes})-l[display file locations]" + '-r[format man page only (do not display)]' + '(-a)-s+[specify manual sections to search]: :->sects' + # @todo Does this in fact want a file path? + '-T+[format man page using specified macro package]:macro package:_files' + ) + [[ $variant == aix* ]] && args+=( + '-c[display man page using cat]' + '-F[display only first matching entry]' + '-m[only search paths specified by -M/MANPATH]' + '-r[search remotely]' + ) + + # Strip (most) long options from non-Linux platforms + if [[ $variant == darwin* ]]; then + args=( ${(M)args:#((#s)|*\))(\*|)(-[^-]|--(help|path|pref|vers))*} ) + elif [[ $variant != linux* ]]; then + args=( ${(M)args:#((#s)|*\))(\*|)-[^-]*} ) + fi fi + _arguments -s -S : $args '*::: :->man' && return 0 + [[ -n $state ]] || return 1 + if (( ! $#_manpath )); then local mp mp=( ${(s.:.)$(manpath 2>/dev/null)} ) @@ -25,12 +183,14 @@ _man() { (( $#_manpath )) || _manpath=( /usr/man(-/) /(opt|usr)/(pkg|dt|share|X11R6|local)/(cat|)man(-/) ) - integer index=$words[(I)-M] - if (( index )); then - local opt - opt=$words[index+1] - _manpath=($opt) - fi + # Override man path + [[ -n ${opt_args[-M]} ]] && + _manpath=( ${(s<:>)opt_args[-M]} ) + + # Augment man path + [[ $variant == (netbsd|openbsd)* ]] && + [[ -n ${opt_args[-m]} ]] && + _manpath+=( ${(s<:>)opt_args[-m]} ) # `sman' is the SGML manual directory for Solaris 7. # 1M is system administrator commands on SVR4 @@ -44,52 +204,190 @@ _man() { # $sect_dirname is from the filesystem, the "3" in "/usr/share/man/man3" # These are used by _man_pages local sect sect_dirname - if [[ $OSTYPE = solaris* ]]; then - sect=${${words[(R)-s*]#-s}:-$words[$words[(i)-s]+1]} - sect="${sect//,/|}" - elif [[ -n ${sect:=$words[$words[(i)-S]+1]} || -n ${sect:=$MANSECT} ]]; then - sect="${sect//:/|}" - sect="${sect//,/|}" - elif (( CURRENT > 2 )); then - case $words[2] in - (-a) sect='*';; - (-*) ;; - (*) sect=$words[2];; - esac + + # Take care: We can't use the sections from these options until we've finished + # completing them; otherwise (e.g.) -s1:<TAB> will give no results + if + [[ $service != man ]] || [[ $state == sects ]] || (( $+opt_args[-a] )) + then + sect='*' + elif + [[ $variant == (darwin|linux)* ]] && + [[ -n ${opt_args[(i)-S|-s|--sections]} ]] + then + noinsert=1 + sect=${opt_args[${opt_args[(i)-S|-s|--sections]}]//[:,]/|} + elif + [[ $variant == (netbsd|openbsd|solaris)* ]] && (( $+opt_args[-s] )) + then + noinsert=1 + sect=${opt_args[-s]//,/|} + elif [[ $variant == (dragonfly|freebsd)* ]] && (( $+opt_args[-S] )); then + noinsert=1 + sect=${opt_args[-S]//:/|} + # It's only a small help, but, per man-db, we can avoid treating an initial + # operand like `8139too` as a section name by ensuring that only the first + # character is a digit. This doesn't do much for stuff like `2to3`, but we can + # at least special-case a few common patterns for now + elif + (( CURRENT > 1 )) && + [[ $variant != solaris* ]] && + [[ ${${(Q)words[1]}##(2to3|7z)*} == ([0-9](|[^0-9[:punct:]]*)|[lnopx]) ]] + then + noinsert=1 + sect=$words[1] + elif [[ -n ${sect:=$MANSECT} ]]; then + sect=${sect//:/|} fi - if [[ $sect = (<->*|1M|l|n) || $sect = *\|* ]]; then + # Colons may have been escaped + sect=${(Q)sect} + + if [[ $sect = (<->*|[lnopx]) || $sect = *\|* ]]; then + sects=( ${(s.|.)sect} ) + + # Most man implementations support partial matching of a page's + # (sub-)section name — e.g., `3per` for `3perl`. The (sub-)section name may + # or may not correspond to the directory name (most systems combine + # sub-sections), but we'll assume that if it starts with a number and we're + # not on Solaris (which doesn't support this feature at all) that we can do + # a match against the leading number. This is irritating if you DO want the + # exact sub-section specified, but unfortunately there's no way to determine + # this programmatically — i guess we could add a style to control it () { - local -a sects=( ${(s.|.)sect} ) - if [[ $sect != (l|n) ]]; then - sects=( ${sects%%[^0-9]#} ) - fi - dirs=( $^_manpath/(sman|man|cat)${^sects}*/ ) - } - if [[ $sect == *\|* ]]; then sect="($sect)"; fi + for 1; do + if [[ $OSTYPE == solaris* || $1 != <->* ]]; then + dirs+=( $^_manpath/(sman|man|cat)$1(|.*)/ ) + else + dirs+=( $^_manpath/(sman|man|cat)${1%%[^0-9]#}*/ ) + fi + done + } $sects + + sect=${(j<|>)sects} + [[ $sect == *'|'* ]] && sect="($sect)" awk="\$2 == \"$sect\" {print \$1}" else + sect= dirs=( $^_manpath/(sman|man|cat)*/ ) awk='{print $1}' fi + + # Ignore directories with no pages inside + dirs=( ${^dirs}(#qFN) ) + # Solaris 11 and on have a man-index directory that doesn't contain manpages dirs=( ${dirs:#*/man-index/} ) - if [[ $OSTYPE = solaris* && ( $words[CURRENT] = -s* || $words[CURRENT-1] == -s ) ]]; then - [[ $words[CURRENT] = -s* ]] && compset -P '-s' - sects=( ${(o)${dirs##*(man|cat)}%/} ) - _wanted sections expl 'section' compadd -a sects - elif zstyle -t ":completion:${curcontext}:manuals" separate-sections; then - typeset -U sects - local ret=1 + sects=( ${(o)${${dirs##*(man|cat)}%.*}%/} ) - sects=( ${(o)${dirs##*(man|cat)}%/} ) + # If we've got this far, we can build our look-up table for descriptions of + # the more common sections. Unless otherwise labelled, the more specific ones + # come from Solaris or one of its variants + (( $#sects )) && () { + sect_descs=( + 0 'library headers' + 1 'general commands' + 1cups 'CUPS commands' + 1m 'maintenance commands' + 1openssl 'OpenSSL commands' + 2 'system calls' + 3 'library functions' + 3c 'C library functions' + 3curses 'curses library functions' + 3elf 'ELF library functions' + 3f 'Fortran library functions' + 3lua 'Lua features' # NetBSD + 3mail 'mailbox library functions' + 3openssl 'OpenSSL library functions' + 3pam 'PAM library functions' + 3pool 'pool configuration library functions' + 3proc 'process control library functions' + 3x11 'Xlib functions' + 3xcurses 'curses library functions [X/Open]' + 4 'devices and drivers' + 5 'file formats and conventions' + 3openssl 'OpenSSL configuration files' + 6 'games' + 7 'miscellanea' + 8 'maintenance commands and procedures' + 9 'kernel features' + 9lua 'Lua kernel bindings' # NetBSD + l 'local documentation' # AIX, etc. — TCL on some systems? + n 'new documentation' # AIX, etc. + o 'old documentation' # AIX, etc. + p 'public documentation' # AIX, etc. + x 'X11 features' + ) + + # Add POSIX variants + for 1 in ${(k)sect_descs}; do + [[ $1 == <-> ]] || continue + sect_descs+=( "${1}p" "${sect_descs[$1]} [POSIX]" ) + done + + # Add OS-specific stuff that's too risky for or overrides the general list + [[ $OSTYPE == darwin* ]] && sect_descs+=( n 'Tcl/Tk features' ) + [[ $OSTYPE == openbsd* ]] && sect_descs+=( 3p 'Perl features' ) + # @todo Oracle Solaris 11.4 adopts the BSD/Linux structure, making many of + # these inaccurate — this should be handled accordingly in the future. If + # OSTYPE isn't helpful (since other Solaris descendants may not follow + # suit), we could perhaps use the presence of SysV-style sections under + # _manpath as the determinant + [[ $OSTYPE == solaris* ]] && sect_descs+=( + 1t 'Tcl/Tk features' + 3m 'mathematical library functions' + 4 'file formats and conventions' + 5 'miscellanea' + 7 'special files' + 7d 'devices' + 7fs 'file systems' + 7i 'ioctl requests' + 7m 'STREAMS modules' + 7p 'protocols' + 9e 'driver entry points' + 9f 'driver functions' + 9p 'driver properties' + 9s 'driver data structures' + ) + } + + [[ $state == sects ]] && { + local s + local -a specs + + (( $#sects )) || { + _message -e sections 'manual section' + return 1 + } + + # Build specs from descriptions + for s in $sects; do + specs+=( "${s}:${(b)sect_descs[$s]}" ) + done + specs=( ${specs%:} ) + + if [[ $variant == (darwin|dragonfly|freebsd|linux)* ]]; then + _sequence -s : _describe -t sections 'manual section' specs + elif [[ $variant == solaris* ]]; then + _sequence -s , _describe -t sections 'manual section' specs + else + _describe -t sections 'manual section' specs + fi + return + } + + if zstyle -t ":completion:${curcontext}:manuals" separate-sections; then + local d ret=1 (( $#sects )) || return 1 _tags manuals.${^sects} while _tags; do for sect_dirname in $sects; do - _requested manuals.$sect_dirname expl "manual page, section $sect_dirname" _man_pages && + d=$sect_dirname + (( $+sect_descs[$d] )) && d+=" (${sect_descs[$d]})" + + _requested manuals.$sect_dirname expl "manual page, section $d" _man_pages && ret=0 done (( ret )) || return 0 @@ -113,14 +411,14 @@ _man_pages() { local pages sopt # What files corresponding to manual pages can end in. - local suf='.((?|<->*)(|.gz|.bz2|.Z|.lzma))' + local suf='.((?|<->*|ntcl)(|.gz|.bz2|.z|.Z|.lzma))' if [[ $PREFIX$SUFFIX = */* ]]; then # Easy way to test for versions of man that allow file names. # This can't be a normal man page reference. # Try to complete by glob first. if [[ -n $sect_dirname ]]; then - _path_files -g "*.*$sect_dirname*(|.gz|.bz2|.Z|.lzma)" "$expl[@]" + _path_files -g "*.*$sect_dirname*(|.gz|.bz2|.z|.Z|.lzma)" "$expl[@]" else _path_files -g "*$suf" "$expl[@]" && return _path_files "$expl[@]" @@ -129,7 +427,7 @@ _man_pages() { fi pages=( ${(M)dirs:#*$sect_dirname/} ) - pages=( ${^pages}/"*$sect${sect:+"*"}" ); + pages=( ${^pages}/"*${sect:+.$sect"*"}" ) pages=( ${^~pages}(N:t) ) (($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd)) @@ -138,8 +436,8 @@ _man_pages() { # beginning with .<->: that handles problem cases like files called # `POSIX.1.5'. - [[ $OSTYPE = solaris* ]] && sopt='-s ' - if ((CURRENT > 2)) || + [[ $variant = solaris* ]] && sopt='-s ' + if ((CURRENT > 1 || noinsert)) || ! zstyle -t ":completion:${curcontext}:manuals.$sect_dirname" insert-sections then compadd "$@" - ${pages%$~suf} diff --git a/Completion/Unix/Command/_md5sum b/Completion/Unix/Command/_md5sum index 073e6beba..8e93fbbac 100644 --- a/Completion/Unix/Command/_md5sum +++ b/Completion/Unix/Command/_md5sum @@ -1,15 +1,48 @@ -#compdef md5sum gmd5sum - -_arguments -S \ - '(-b --binary)'{-b,--binary}'[read in binary mode]' \ - '(-c --check)'{-c,--check}'[read MD5 sums from the FILEs and check them]' \ - '--tag[create a BSD-style checksum]' \ - '(-t --text)'{-t,--text}'[read in text mode]' \ - "--ignore-missing[don't fail or report status for missing files]" \ - '(-q --quiet)'{-q,--quiet}"[don't print OK for each successfully verified file]" \ - '--status[no output, status code shows success]' \ - '--strict[exit non-zero for improperly formatted checksum lines]' \ - '(-w --warn)'{-w,--warn}'[warn about improperly formatted checksum lines]' \ - '(-)--help[display help and exit]' \ - '(-)--version[output version information and exit]' \ - '*:files:_files' +#compdef md5sum gmd5sum b2sum gb2sum sha1sum gsha1sum sha224sum gsha224sum sha256sum gsha256sum sha384sum gsha384sum sha512sum gsha512sum + +# This function covers the various digest utilities (which are all essentially +# the same program) from GNU Coreutils. It does NOT cover GNU `cksum` and `sum`, +# nor the various BSD digest utilities like `md5` and `sha1` — see `_cksum` for +# all of those. See `_shasum` for the `shasum` Perl script. +# +# @todo Support BusyBox? + +local type +local -a args + +case $service in + *md5*) type=MD5 ;; + *b2*) type=BLAKE2 ;; + *sha*) type=SHA${service//[^0-9]/} ;; +esac + +# General options +args+=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' +) +# Summing options +args+=( + + sum + '(chk)--tag[create BSD-style checksums]' + '(chk -b -t --binary --text)'{-b,--binary}'[read in binary mode]' + '(chk -b -t --binary --text)'{-t,--text}'[read in text mode]' +) +# This is the only option that differs amongst all of these tools +[[ $service == *b2* ]] && args+=( + '(chk -l --length)'{-l+,--length=}'[specify digest length]:digest length (bits, multiples of 8)' +) +# Verification options +args+=( + + chk + '(sum -c --check)'{-c,--check}"[verify $type checksums from input files]" + "(sum)--ignore-missing[don't fail or report status for missing files]" + "(sum)--quiet[don't print OK for each verified file]" + '(sum -w --warn)--status[suppress all output]' + '(sum)--strict[exit non-zero for improperly formatted checksum lines]' + '(sum -w --status --warn)'{-w,--warn}'[warn about each improperly formatted checksum line]' +) +# Operands +args+=( '*: :_files' ) + +_arguments -s -S : $args diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc index 45d93550d..4f200c69e 100644 --- a/Completion/Unix/Command/_mpc +++ b/Completion/Unix/Command/_mpc @@ -37,6 +37,7 @@ _mpc_command() { disable:"disable an output" enable:"enable an output" toggleoutput:"toggle an output" + outputset:"set output attributes" idle:"wait until an event occurs" idleloop:"loop waiting for events" insert:"insert a song after the currently playing song in the playlist" @@ -73,6 +74,7 @@ _mpc_command() { stop:"stop the currently playing playlists" toggle:"toggles Play/Pause, plays if stopped" update:"scan music directory for updates" + rescan:"rescan music directory (including unchanged files)" version:"report version of MPD" volume:"set volume" status:"display MPD status" @@ -222,6 +224,16 @@ _mpc_toggleoutput() { _mpc_helper_outputs } +_mpc_outputset() { + if (( CURRENT == 2 )); then + _mpc_helper_outputs + else + _values -w -S = attribute \ + 'dop:setting:(1 0)' \ + 'allowed_formats:formats' + fi +} + _mpc_move() { if (( $#words <= 3 )); then _mpc_helper_songnumbers @@ -318,6 +330,10 @@ _mpc_update() { _mpc_helper_files } +_mpc_rescan() { + _mpc_helper_files +} + if [[ $service = *MPD_HOST* ]]; then _hosts return @@ -339,7 +355,7 @@ if [[ $state = formats ]]; then compset -P '([^%]|%[^%]#%)#' _wanted metadata expl 'metadata delimiter' compadd -p % -S % \ artist album albumartist comment composer date disc genre performer title \ - track time file position mtime mdate && ret=0 + track time file position id prio mtime mdate && ret=0 fi return ret diff --git a/Completion/Unix/Command/_netstat b/Completion/Unix/Command/_netstat new file mode 100644 index 000000000..c03aae9a2 --- /dev/null +++ b/Completion/Unix/Command/_netstat @@ -0,0 +1,337 @@ +#compdef netstat + +local Wopt Xopt nopt="[don't resolve addresses to names]" +local lopt='[show only listening sockets]' +local zopt='-z[reset statistic counters after displaying them]' +local popt='(-f)-p+[filter by protocol]:protocol:compadd -a plist' +local Iopt='(-i)-I+[show information about the specified interface]:interface:_net_interfaces' +local set sel +local -A sets +local -a Mopts families flist plist args sockets extend interval verbose +local -a {sel_,}{bpf,dhcp,groups,interfaces,masquerade,media,memory,multicast,pcb,queues,routing,statistics,wireless} + +case $OSTYPE in + linux-gnu) + families=( + '(-4 --inet)'{-4,--inet} + '(-6 --inet)'{-4,--inet6} + '(-A --protocol)'{-A+,--protocol=}':protocol:_sequence compadd - inet inet6 unix ipx ax25 netrom ddp bluetooth' + --unix -x --ip --tcpip --ax25 --x25 --rose --ash + --bluetooth --ipx --netrom --ddp --appletalk --econet --ec + ) + extend=( \*{-e,--extend}'[show additional information]' ) + verbose=( '(-v --verbose)'{-v,--verbose}'[show what is going on]' ) + args=( + '(-c --continuous)'{-c,--continuous}'[repeat information every second]' + '!(-n --numeric)'{-N,--symbolic} + '(-n --numeric)'{-n,--numeric}"$nopt" + --numeric-hosts --numeric-ports --numeric-users + '1: :_guard "[0-9]#" "repeat interval (seconds)"' + - '(help)' + '(- 1)'{-h,--help}'[display usage information]' + '(- 1)'{-V,--version}'[display version information]' + ) + sets=( + routing '(--route|-[^-]#r*)' + groups '(--groups|-[^-]#g*)' + interfaces '(--interfaces|-[^-]#[iI]*)' + statistics '(--statistics|-[^-]#s*)' + masquerade '(--masquerade|-[^-]#M*)' + ) + + sel_routing=( '(-r --route)'{-r,--route}'[display routing table]' ) + sel_interfaces=( + '(-I --interfaces)-i[display interface table]' + '(-i -I --interfaces)'{--interface=-,-I=-}'[display interface table]::interface:_net_interfaces' + ) + sel_groups=( '(-g --groups)'{-g,--groups}'[display multicast group memberships]' ) + sel_masquerade=( '(-M --masquerade)'{-M,--masquerade}'[display masqueraded connections]' ) + [[ -e /proc/net/ip_masquerade ]] || sel_masquerade=( \!${^sel_masquerade} ) + sel_statistics=( '(-s --statistics -c --continuous -n --numeric --numeric-hosts --numeric-ports --numeric-users)'{-s,--statistics}'[display networking statistics]' ) + + sockets=( + $families $verbose + --tcp -t --udp -u --udplite -U --sctp -S --raw -w + '(-2 --l2cap)'{-2,--l2cap} + '(-f --rfcomm)'{-f,--rfcomm} + '(-a --all -l --listening)'{-l,--listening}$lopt + '(-a --all -l --listening)'{-a,--all}'[show all sockets]' + --symbolic -N --extend -e + '(--timers -o)'{--timers,-o}'[show information on networking timers]' + '(--program -p)'{--program,-p}'[show process id and program name for sockets]' + '(--wide -W)'{--wide,-W}"[don't truncate IP addresses in output]" + '(-Z --context)'{-Z,--context}'[display SELinux security context for sockets]' + ) + routing=( + $families $extend $verbose + '-C[display routing cache instead of FIB]' + ) + interfaces=( + $extend $verbose + '(-a --all)'{-a,--all}'[show interfaces that are not up]' + ) + groups=() + masquerade=( $extend ) + statistics=( $families ) + ;; + solaris*|darwin*|dragonfly*|freebsd*) + families=( '(-p -4 -6)-f+[specify address family]:address family:compadd -a flist' ) + ;| + freebsd*) + families+=( + '(-6 -f)-4[show IPv4 only]' + '(-4 -f)-6[show IPv6 only]' + ) + ;| + (open|net)bsd*) + popt='(-f)-p+[filter by protocol]:protocol:compadd - ${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]#}' + families=( + '(-u)-f+[specify address family]:address family:_sequence compadd - -a flist' + '(-f)-u[limit reports to the unix address family]' # undocumented on NetBSD + ) + ;| + *) # everything except linux + sets=( + routing '-[^-]#r*' + groups '-[^-]#g*' + interfaces '-[^-]#[iIw]*' + memory '-[^-]#m*' + statistics '-[^-]#s*' + ) + flist=( inet inet6 unix ) + verbose=( '-v[verbose]' ) + sel_routing=( '-r[display routing table]' ) + sel_groups=( '-g[display multicast group memberships]' ) + sel_interfaces=( $Iopt '-i[display interface table]' ) + sel_statistics=( '*-s[display per protocol statistics]' ) + sockets=( $families -n$nopt '-a[show all sockets]' ) + routing=( -n$nopt ) + interfaces=( $families -n$nopt ) + statistics=( $families ) + ;| + (open|net)bsd*) + sets+=( pcb '-[^-]#P*' ) + sel_pcb=( '-P+[display contents of the protocol control block]:pcb' ) + routing+=( $verbose '(-L)-s[show routing statistics]' ) + groups+=( $families + '(-s)-l[display wider fields for the IPv6 multicast routing table]' + '(-l)-s[show multicast routing statistics]' + ) + interfaces+=( + '(-p)-s[show interface statistics]' + ) + ;| + darwin*|dragonfly*|(net|free|open)bsd*) + sockets+=( '-A[show address of a PCB associated with sockets]' ) + interfaces+=( + '-b[show the number of bytes in and out]' + '-d[show the number of dropped packets]' + '1: :_guard "[0-9]#" "repeat interval (seconds)"' + ) + routing=( $families ) + sel_memory=( '-m[display statistics recorded by the memory management routines]' ) + sel_interfaces+=( '(1 -a -f -i -p -s)-w+[display packet traffic at intervals]:interval (seconds)' ) + ;| + darwin*|dragonfly*|(net|free)bsd*) + interfaces+=( '-a[show multicast addresses currently in use]' ) + ;| + dragonfly*|(net|free|open)bsd*) + Mopts=( + '-M+[extract values from specified core]:core file:_files' + '-N+[extract name list from specified system image]:system image:_files' + ) + interfaces+=( + '-h[print all counters in human readable form]' + ) + sockets+=( $Mopts ) + ;| + darwin*|dragonfly*|freebsd*) + Wopt='-W+[avoid truncating fields even if it causes overflow]' + sockets+=( $Wopt + '-L[show size of listen queues]' + ) + groups+=( $Wopt ) + ;| + dragonfly*|netbsd*|freebsd*) + sockets+=( '(-n)-S[show network addresses as numbers but show ports symbolically]' ) + ;| + netbsd*|freebsd*) + sets+=( bpf '-[^-]#B*' ) + sel_bpf=( '-B[display statistics about bpf(4) peers]' ) + ;| + dragonfly*|freebsd*) + plist=( divert icmp igmp ip ipsec pim tcp udp icmp6 ip6 rip6 tcp udp pfkey ctrl data ) + sockets+=( $popt ) + statistics+=( $popt $zopt $Mopts ) + memory+=( $Mopts ) + routing+=( $Mopts $zopt + '(-A -a -f -l -n -W)*-s[show routing statistics]' + '-W[show path MTU for each route]' + ) + groups+=( $families $Mopts + '(-W)*-s[show multicast routing statistics; repeat to suppress those with zero counters]' + ) + ;| + + solaris2.<11->) + args=( '-T+[specify time format]:time format:((u\:seconds\ since\ epoch d\:standard\ date\ format))' ) + sockets=( '-u[list user, pid and program that created network endpoint]' ) + ;& + solaris*) + args=( -A '-*' $args ) + interval=( + '1: :_guard "[0-9]#" "repeat interval (seconds)"' + '2: :_guard "[0-9]#" "count"' + ) + sets+=( + dhcp '-[^-]#D*' + media '-[^-]#p*' + multicast '-[^-]#M*' + ) + sel_media=( '-p[display net to media tables]' ) + sel_memory=( '-m[display STREAMS memory statistics]' ) + sel_multicast=( '-M[display multicast routing tables]' ) + sel_dhcp=( '-D[display status of DHCP configured interfaces]' ) + sockets+=( + $verbose + '-R[show extended security attributes]' + '-P[specify protocol]:protocol:(ip ipv6 icmp icmpv6 igmp udp tcp rawip)' + ) + routing+=( $verbose + '*-f+[filter routing table]:rule:_values -S \: "filter rule" $flist + "af[specify address family]\:family\:(inet inet6 unix)" + "outif[specify output interface]\:interface\:_net_interfaces" + "dst[specify destination IP]\:IP address" + "flags[select routes tagged with flags]\:flags"' \ + '-a[show state of all routing tables]' + '-R[show extended security attributes]' + ) + groups+=( $families -n$nopt $verbose ) + interfaces+=( $interval + '-a[show state of all interfaces]' + ) + statistics+=( + '-P[specify protocol]:protocol:(ip ipv6 icmp icmpv6 igmp udp tcp rawip)' + ) + media=( -n$nopt $families ) + memory+=( $verbose $interval ) + multicast+=( + -n$nopt $families + '-s[show per protocol statistics]' + ) + dhcp=( $families $Iopt ) + ;; + darwin*) + sets+=( queues '-[^-]#q*' ) + sel_queues=( '*-q[display network interface send queue statistics]' ) + sel_memory=( \*$sel_memory ) + sockets+=( + '-l[show full IPv6 address]' + '-W[avoid truncating addresses]' + ) + routing+=( '-l[show mtu and use wider display]' ) + interfaces+=( + '(-x)-R[show reachability information]' + '-S[show interface link status and state]' + '(-R)-x[show extended reachability information]' + ) + queues=( $Iopt + '-c+[limit statistics to specified queue]:queue' + ) + groups+=( $families + '*-v[show link-layer memberships; repeat for timers and counters]' + ) + ;; + dragonfly*) + plist+=( carp ) + sockets+=( + '-P[show additional protocol-specific information]' + '-c+[access cpu specific route table]:cpu' + ) + interfaces+=( $zopt + '-B[show maximum buffer sizes instead of current buffer usage]' + '-t[show the contents of watchdog timers]' + '(-a -B -b -d -h -n -t -w)*-s[show protocol statistics; repeat to suppress those with zero counters]' + ) + routing+=( + '-A[show contents of internal Patricia tree structures]' + '-a[show protocol-cloned routes]' + ) + ;; + openbsd*) + sets+=( wireless '-W*' ) + sel_wireless=( '-W+[display per-interface IEEE 802.11 wireless statistics]:interface' ) + flist+=( local mpls ) + sockets+=( -l$lopt '-B[show buffer sizes for TCP sockets]' ) + routing+=( + '-F[only show routes with gateway in the same address family as the destination]' + '-T+[select an alternate routing table to query]:routing table' + ) + interfaces+=( + '-c+[show specified number of updates, then exit]:count' + '-q[only show interfaces that have seen packets]' + '-t[show current value of the watchdog timer function]' + ) + statistics+=( $popt ) + pcb+=( $Mopts $verbose ) + ;; + netbsd*) + popt='(-f)-p+[filter by protocol]:protocol:compadd - ${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]#}' + Xopt='-X[force use of sysctl(3) when retrieving information]' + flist+=( arp ns atalk mpls local ) + sets+=( queues '-[^-]#q*' ) + sel_queues=( '-q[display software interrupt queue details for all protocols]' ) + routing+=( $Xopt + "(-s)-L[don't show link-level routes]" + '-T[show MPLS tags for the routing tables]' + ) + bpf+=( $Xopt $Iopt + '-s[show bpf(4) statistics]' + ) + interfaces+=( $Xopt ) + memory+=( $Xopt) statistics+=( $Xopt ) + pcb+=( $Mopts $popt ) + ;; + freebsd<11->.*) + routing+=( '-F+[show specified routing table]:routing table' ) + bpf=( '-z[reset statistic counters after displaying them]' ) + statistics+=( $bpf[-1] ) + ;& + freebsd*) + flist+=( pfkey netgraph ng link ) + plist+=( sctp ipsec6 pfkey ) + + sets+=( netisr '-[^-]#Q*' ) + sel_netisr=( '-Q[display netisr(9) statistics]' ) + sockets+=( + '-R[show flowid and flowtype for each socket]' + '-T[show diagnostic information from the TCP control block]' + '-x[show socket buffer and TCP timer statistics]' + ) + interfaces+=( + $popt $Mopts $Iopt $Wopt + '-q+[exit after specified number of outputs]:number' + ) + bpf+=( $Iopt $zopt ) + ;; +esac + +# Ignore display specific options except the default (socket) display until a +# display has been selected. This is not strictly correct (options can be in +# any order) but makes the completion much more useful. Descriptions for +# options that select a specific display (option set) typically start with +# "display" to set them apart from other options. +sock='' +for set in ${(k)sets}; do + sel=sel_$set + if [[ -z $words[(r)$~sets[$set]] ]]; then + ign='!' + else + sock='!' + ign='' + fi + args+=( - "$set" ${(P)sel} ${ign}${(P)^set} ) +done +args+=( - sockets ${sock}${sockets} ) + +_arguments -s -S $args diff --git a/Completion/Unix/Command/_nginx b/Completion/Unix/Command/_nginx new file mode 100644 index 000000000..7d785c822 --- /dev/null +++ b/Completion/Unix/Command/_nginx @@ -0,0 +1,20 @@ +#compdef nginx + +local -ah signals=( + 'quit\:shut down gracefully (SIGQUIT)' + 'reload\:reload configuration (SIGHUP)' + 'reopen\:re-open log files (SIGUSR1)' + 'stop\:shut down quickly (SIGTERM)' +) + +_arguments -s -S : \ + '(: * -)'{-\?,-h}'[display help information]' \ + '(: * -)-v[display version information]' \ + '(: * -)-V[display version information and configure options]' \ + '-c+[specify configuration file]:configuration file:_files' \ + '-g+[specify global configuration directives]:configuration directives' \ + '-p+[specify prefix path]:prefix path:_directories' \ + '(-s)-q[suppress non-error messages (with -t/-T)]' \ + "(-q -t -T)-s+[send specified signal to master process]:signal:((${(j< >)${(@q-)signals}}))" \ + '(-s -T)-t[test configuration]' \ + '(-s -t)-T[test and dump configuration]' diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep index ec3f8bfd0..3b4d082a7 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -1,185 +1,177 @@ #compdef pgrep pkill -local curcontext="$curcontext" state line ret=1 expl +# 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 don't really need to keep pgopts and pkopts separate, but it seems like +# it should make things a bit easier to follow +# - @todo We could complete log-in classes given to -c +# - @todo We could complete routing tables given to -T + +local curcontext="$curcontext" state line ret=1 expl pgopts pkopts no typeset -A opt_args -typeset -a arguments - -arguments=('-P[parent process id]:parent process id:->ppid' - '-F[match only in process in pidfile]:files:_files' - '-g[match only in process group ids]:group:->pgid' - '-G[match only real group id]:group:_groups' - '-j[match only in processes inside jails]:jail id:_sequence _jails -0 -o jid' - '-J[match only in project ids]:project id:->projid' - '-M[extract the name list from the specified core]:files:_files' - '-N[extract the name list from the specified system]:files:_files' - '-s[match only session id]:session id:->sid' - '-t[match only controlled by terminal]:terminal device:_sequence _ttys -d' - '-T[match only in processes specified routing table in rtable]' - '-u[match only effective user id]:user:_users' - '-U[match only real user id]:user:_users' - '(-n)-o[oldest process]' - '(-o)-n[newest process]' - '-a[include process ancestors in the match list]' - '-c[print a count of matching processes]' - '-f[match against full command line]' - '-i[ignore case distinctions]' - '-I[confirmation before attempting to single each process]' - '-L[given pidfile must be locked]' - '-q[do not write anything to standard output]' - '-S[search also in system processes]' - '-v[negate matching]' - '-w[show thread ids instead of pids]' - '-x[match exactly]' - '-z[match only in zones]:zone:_zones') - -if [[ $service == 'pgrep' ]]; then - arguments+=('-d[output delimiter]:delimiter:compadd ${(s\:\:)IFS}' - '-l[list name in addition to id]') -fi - -local optchars -case "$OSTYPE" in +typeset -a arguments sig_arguments aopts + +# These arguments (a) are common to all variants (like -x), (b) are the most +# common amongst all variants (like -a), or (c) have a single unambiguous +# meaning amongst all variants (like --help). Many of them are filtered out or +# overridden below +arguments=( + '-a[include process ancestors in match list]' + '-c+[match only on specified login class]:login class' + '(-F --pidfile)'{-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]' + '-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' + '(-M)-N+[extract name list from specified system]:system file:_files' + '(-o -n --oldest --newest)'{-n,--newest}'[match newest process]' + '(-o -n --oldest --newest)'{-o,--oldest}'[match oldest process]' + '(-P --parent)'{-P+,--parent=}'[match only on specified parent process IDs]: :->ppid' + '(-l)-q[suppress normal output]' + '-S[search also in system processes (kernel threads)]' + '(-s --session)'{-s+,--session=}'[match only on specified process session IDs]: :->sid' + # _signals is OK here - we do it differently below + '(ss)--signal=[specify signal to send to process]: :_signals -s' + '-T+[match only on specified routing table]:routing table' + '(-t --terminal)'{-t+,--terminal=}'[match only on specified controlling terminals]: :_sequence _ttys -do' + '(-U --uid)'{-U+,--uid=}'[match only on specified real user IDs]: :_sequence _users' + '(-u --euid)'{-u+,--euid=}'[match only on specified effective user IDs]: :_sequence _users' + '(-v --inverse)'{-v,--inverse}'[negate matching]' + '(-x --exact)'{-x,--exact}'[match process name or command line (with -f) exactly]' + '--ns=[match only on same namespaces as specified PID]: :_pids' + '--nslist=[match only on specified namespaces (with --ns)]:namespace:(ipc mnt net pid user uts)' + '(: * -)'{-V,--version}'[display version information]' + '-z+[match only on specified zone IDs]:zone:_sequence _zones' +) +[[ $service == pgrep ]] && arguments+=( + '(-d --delimiter)'{-d+,--delimiter=}'[specify output delimiter]:delimiter:compadd ${(s<>)IFS}' + '(-q)-l[display process name (and arguments with -f)]' + '(-w --lightweight)'{-w,--lightweight}'[show all thread IDs instead of PID]' +) +[[ $service == pkill ]] && arguments+=( + '(-e --echo)'{-e,--echo}'[display signalled process]' + '-l[display kill command]' +) + +case $OSTYPE in linux*) - optchars="cflvxdnoPgsuUGtw" + # Note: We deliberately exclude -v but not --inverse from pkill + pgopts=acdFfGghLlnoPstUuVvwx- + pkopts=ceFfGghLnoPstUuVx- + arguments=( + ${arguments:#((#s)|*\))(\*|)-[acl]*} + '(-c --count)'{-c,--count}'[display count of matching processes]' + ) + [[ $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]' + ) ;; - freebsd*) - optchars="LSafilnoqvxFGMNPUdgjstu" + dragonfly*|freebsd*) + pgopts=acdFfGgijLlMNnoPqSstUuvx + pkopts=acFfGgIijLlMNnoPstUuvx ;; openbsd*) - optchars="flnoqvxdGgPsTtUu" + pgopts=dfGglnoPqsTtUuvx + pkopts=fGgIlnoPqsTtUuvx ;; darwin*) - optchars="LafilnoqvxFGPUdgtu" + pgopts=adFfGgiLlnoPqtUuvx + pkopts=aFfGgIiLlnoPtUuvx ;; solaris*) - optchars="flvxdnoPgsuUGJtTcz" - arguments=( ${arguments##-T*} ) - arguments=( ${arguments##-c*} ) - arguments+=( '-T[match only processes in task ids]:taskid:->task' ) - arguments+=( '-c[match only processes in contract ids]:taskid:->contract' ) + pgopts=cdfGglnoPsTtUuvxz + pkopts=cfGgnoPsTtUuvxz + arguments=( + ${arguments:#((#s)|*\))(\*|)-[cT]*} + '-c+[match only on specified contract IDs]: :->contract' + '-J+[match only on specified project IDs]: :->projid' + '-T+[match only on specified task IDs]: :->task' + ) ;; *) - optchars="flvxdnoPgsuUGt" + pgopts=dfGgilnPstUuvx + pkopts=fGgilnPstUuvx ;; esac -# Only keep relevant arguments according to $optchars. -arguments=( ${(M)arguments:#(|\*)(|\(*\))-[$optchars]*} - '*:process name:->pname') -if [[ $service == 'pkill' ]]; then - arguments+=('-'${^signals}'[signal]') + +if [[ $service == pgrep ]]; then + arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pgopts]*} ) +else + arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pkopts]*} ) + + # Signals on non-Linux systems can only be completed as the first argument + (( CURRENT != 2 )) && [[ $OSTYPE != linux* ]] && no='!' + + # This is used for exclusion with --signal + sig_arguments=( + '(ss)' ) + + # This is very similar to _signals, but i've avoided it here because it + # doesn't behave the way i want it to + sig_arguments+=( $no'(--signal)-'${^signals[2,-3]} ) + sig_arguments+=( '!(--signal)-'{0..$(( $#signals - 3 ))} ) + + # Complete the -SIG* variant if it's requested + if [[ $PREFIX$SUFFIX == -S* ]]; then + sig_arguments+=( '(--signal)-SIG'${^${(@)signals[2,-3]:#<->}} ) + else + sig_arguments+=( '!(--signal)-SIG'${^${(@)signals[2,-3]:#<->}} ) + fi fi -_arguments -C -s -w $arguments && ret=0 +arguments+=( $sig_arguments + o '*: :->pname' ) + +[[ $OSTYPE == linux* ]] || aopts+=( -A '*-' ) +_arguments -C -s -S $aopts : $arguments && ret=0 + +# complete comma-separated list of various IDs +# $1: tag, $2: description, $3: keyword for 'ps -o' +_pgrep_sequence () { + _sequence _wanted $1 expl "$2" \ + compadd - ${(un)$(_call_program $1 ps -A -o $3=)} +} case $state in (sid) if [[ $OSTYPE == openbsd* ]]; then - break - fi - - compset -P '*,' - - local -a used sid - used=(${(s:,:)IPREFIX}) - if [[ $OSTYPE == freebsd* ]]; then - sid=(${(uon)$(ps -ax -o sid=)}) + _message 'session ID' else - sid=(${(uon)$(ps -A -o sid=)}) + _pgrep_sequence session-ids 'session ID' sid fi - - _wanted sid expl 'session id' compadd -S ',' -q -F used $sid ;; - (ppid) - compset -P '*,' - - local -a used ppid - used=(${(s:,:)IPREFIX}) - if [[ $OSTYPE == (freebsd|openbsd|darwin)* ]]; then - ppid=(${(uon)$(ps -ax -o ppid=)}) - else - ppid=(${(uon)$(ps -A -o ppid=)}) - fi - - _wanted ppid expl 'parent process id' compadd -S ',' -q -F used $ppid + _pgrep_sequence ppids 'parent process ID' ppid ;; - (pgid) - compset -P '*,' - - local -a used pgid - used=(${(s:,:)IPREFIX}) - if [[ $OSTYPE == (freebsd|openbsd|darwin)* ]]; then - pgid=(${(uon)$(ps -ax -o pgid=)}) - else - pgid=(${(uon)$(ps -A -o pgid=)}) - fi - - _wanted pgid expl 'process group id' compadd -S ',' -q -F used $pgid + _pgrep_sequence pgids 'process group ID' pgid ;; - (projid) - compset -P '*,' - - local -a used projid - used=(${(s:,:)IPREFIX}) - projid=(${(uon)$(ps -A -o project=)}) - - _wanted projid expl 'project id' compadd -S ',' -q -F used $projid + _pgrep_sequence project-ids 'project ID' project ;; - (contract) - compset -P '*,' - - local -a used ctid - used=(${(s:,:)IPREFIX}) - ctid=(${(uon)$(ps -A -o ctid=)}) - - _wanted ctid expl 'contract id' compadd -S ',' -q -F used $ctid + _pgrep_sequence contract-ids 'contract ID' ctid ;; - (task) - compset -P '*,' - - local -a used taskid - used=(${(s:,:)IPREFIX}) - taskid=(${(uon)$(ps -A -o project=)}) - - _wanted taskid expl 'task id' compadd -S ',' -q -F used $taskid + _pgrep_sequence task-ids 'task ID' taskid ;; - (pname) local ispat="pattern matching " if (( ${+opt_args[-x]} )); then ispat="" fi - - local command if (( ${+opt_args[-f]} )); then - if [[ "$OSTYPE" == freebsd* ]] && (( ${+opt_args[-S]} )); then - command="$(ps -axH -o command=)" - elif [[ "$OSTYPE" == (freebsd|openbsd|darwin)* ]]; then - command="$(ps -ax -o command=)" - elif [[ "$OSTYPE" == solaris* ]]; then - command="$(ps -A -o args=)" - else - command="$(ps -A o cmd=)" - fi - _wanted pname expl $ispat'process command line' compadd ${(u)${(f)${command}}} + _wanted process-args expl $ispat'process command line' \ + compadd ${${(f)"$(_call_program process-args ps -A -o args=)"}% *} else - if [[ "$OSTYPE" == freebsd* ]] && (( ${+opt_args[-S]} )); then - command="$(ps -axcH -o command=)" - elif [[ "$OSTYPE" == (freebsd|openbsd|darwin)* ]]; then - command="$(ps -axc -o command=)" - elif [[ "$OSTYPE" == solaris* ]]; then - command="$(ps -A -o comm=)" - else - command="$(ps -A co cmd=)" - fi - _wanted pname expl $ispat'process name' compadd ${(u)${(f)${command}}} + _wanted processes-names expl $ispat'process name' _process_names -a -t fi ;; - esac && ret=0 return ret diff --git a/Completion/Unix/Command/_php b/Completion/Unix/Command/_php index d03f3395e..c4c4ab3e2 100644 --- a/Completion/Unix/Command/_php +++ b/Completion/Unix/Command/_php @@ -1,71 +1,177 @@ -#compdef php +#compdef php -P php[0-9.-] -# PHP 5.0.4 (cli) -# PHP 4.3.11 (cli) +# Notes: +# - We make no distinction between internal and user functions +# - We don't complete CGI options, which are rarely used interactively +# - Exclusivity on some of the miscellaneous options isn't very accurate +# - @todo Arguments to an -f script aren't completed accurately -- we need to +# massage words/CURRENT so that the -f arg becomes words[1], but if we just +# leave it at that the output will break if the script has any options of its +# own. We would want to complete script options only following `--`, as in +# `php -f /bin/foo -- -<TAB>` -local curcontext="$curcontext" line state expl -typeset -A opt_args +# Complete PHP class names +(( $+functions[_php_classes] )) || +_php_classes() { + local cmd + local -a tmp -local -a args -local exclusions php_suffix + cmd='foreach ( get_declared_classes() as $c ) { echo "$c\n"; }' + tmp=( ${(f)"$( _call_program classes $words[1] -r ${(q)cmd} )"} ) -zstyle -s ":completion:${curcontext}:" suffixes php_suffix '|' || php_suffix='php|phar' -local php_files=":PHP file:_files -g '*.($php_suffix)(-.)'" + _wanted -x classes expl 'PHP class' compadd -a "$@" - tmp +} + +# Complete PHP extensions/module names; use --zend for Zend extensions only +(( $+functions[_php_extensions] )) || +_php_extensions() { + local idx + local -a expl zend tmp + + zparseopts -a zend -D -E -- -zend + + # `php -m` lists all extensions under two sections called '[PHP Modules]' and + # '[Zend Modules]'. An extension can (but won't necessarily) exist under both + # of these at the same time + tmp=( ${(f)"$( _call_program extensions $words[1] -m )"} ) + idx=${tmp[(i)\[Zend Modules\]]} + + # Get only Zend extensions (for --rz) + if (( $#zend )); then + tmp=( ${(@)tmp[(idx+1),-1]} ) + # Get PHP extensions (for everything else) + else + tmp=( ${(@)tmp[2,(idx-1)]} ) + fi + + _wanted -x extensions expl 'PHP extension' compadd -a "$@" - tmp +} + +# Complete PHP function names +(( $+functions[_php_functions] )) || +_php_functions() { + local cmd + local -a expl tmp + + cmd=' + foreach ( get_defined_functions() as $a ) { + foreach ( $a as $f ) { + echo "$f\n"; + } + } + ' + tmp=( ${(f)"$( _call_program functions $words[1] -r ${(q)cmd} )"} ) + + _wanted -x functions expl 'PHP function' compadd -a "$@" - tmp +} + +_php() { + local curcontext=$curcontext php_suffix php_files ret=1 + local -a context expl line state state_descr args + local -A opt_args + + zstyle -s ":completion:${curcontext}:" suffixes php_suffix '|' || + php_suffix='php|php5|phar' + + php_files=":PHP file:_files -g '*.($php_suffix)(#q-.)'" -if _pick_variant php5=PHP\ 5 php4 --version; then - exclusions="-B --process-begin -R --process-code -F --process-file -E --process-end" args=( - '(-B --process-begin -f --file -r --run 1)'{-B,--process-begin}'[run specified PHP code before processing input lines]:PHP code:' - '(-R --process-code -F --process-file -f --file -r --run 1)'{-R,--process-code}'[run specified PHP code for every input line]:PHP code:' - '(-F --process-file -R --process-code -f --file -r --run 1)'{-F,--process-file}'[parse and execute specified file for every input line]'$php_files - '(-E --process-end -f --file -r --run 1)'{-E,--process-end}'[run specified PHP code after processing all input lines]:PHP code:' - '(-H --hide-args)'{-H,--hide-args}'[hide any passed arguments from external tools]' + + mc # Misc. options + '(-a --interactive)'{-a,--interactive}'[run interactively]' + '*'{-d+,--define=}'[define INI directive]: :->directive' + '(-e --profile-info)'{-e,--profile-info}'[generate extended information for debugger/profiler]' + '(-H --hide-args)'{-H,--hide-args}'[hide script name and arguments from external tools]' + '(fi im pb pf rf rn sc sv *)--ini[display configured INI paths]' + # Note: PHP does not automatically prepend extension_dir to extension file + # names (the way it does when parsing the INI file) at the command line + '*'{-z+,--zend-extension=}'[load specified Zend extension]:Zend extension:_files -g "*.so(|.*)(#q-.)"' + + + '(fi)' # File arguments + "(im pb pf rf sv)"{-f+,--file=}'[parse and/or execute specified file]'$php_files + '(-)1'$php_files + + + '(hv)' # Help/version options; kept separate by convention + '(- 1 *)'{-h,--help}'[display help information]' + '(- 1 *)'{-v,--version}'[display version information]' + '!(- 1 *)'{-\?,-\\\?,--usage} + + + '(im)' # Info/module options (exclusive with everything but -c/-n) + '(fi mc pb pf rf rn sc sv *)'{-i,--info}'[display configuration information (phpinfo())]' + '(fi mc pb pf rf rn sc sv *)'{-m,--modules}'[display installed extensions]' + + + '(in)' # php.ini set/disable options (unrelated to --ini!) + {-c+,--php-ini=}'[specify php.ini or containing directory]:INI file or directory:_files -g "*.ini(-.)"' + {-n,--no-php-ini}'[ignore php.ini]' + + + '(pb)' # Input-processing begin/end options + '(-B --process-begin fi im rf rn sc sv)'{-B+,--process-begin=}'[run specified PHP code before processing input lines]:PHP code:' + '(-E --process-end fi im rf rn sc sv)'{-E+,--process-end=}'[run specified PHP code after processing input lines]:PHP code:' + + + '(pf)' # Input-processing options + '(fi im rf rn sc sv)'{-R+,--process-code=}'[run specified PHP code for every input line]:PHP code:' + '(fi im rf rn sc sv)'{-F+,--process-file=}'[parse and execute specified file for every input line]'$php_files + + + '(rf)' # Reflection options + '(fi im rn pb pf sc sv *)'{--rc=,--rclass=}'[display information about specified class]: :_php_classes' + '(fi im rn pb pf sc sv *)'{--re=,--rextension=}'[display information about specified extension]: :_php_extensions' + '(fi im rn pb pf sc sv *)'{--rf=,--rfunction=}'[display information about specified function]: :_php_functions' + '(fi im rn pb pf sc sv *)'{--ri=,--rextinfo=}'[display configuration information about specified extension]: :_php_extensions' + '(fi im rn pb pf sc sv *)'{--rz=,--rzendextension=}'[display information about specified Zend extension]: :_php_extensions --zend' + + + '(rn)' # Run-script options + "(fi im pb pf rf sc sv)"{-r+,--run=}'[run specified PHP code]:PHP code:' + + + '(sc)' # Source-checking/formatting options + '(im pb pf rf rn sv *)'{-l,--syntax-check}'[check syntax only (lint)]' + '(im pb pf rf rn sv *)'{-s,--syntax-highlight}'[display HTML syntax-highlighted source]' + '!(im pb pf rf rn sv *)--syntax-highlighting' + '(im pb pf rf rn sv *)'{-w,--strip}'[display source stripped of comments and whitespace]' + + + sv # Built-in Web server options + '(-S --server fi im pb pf rf rn sc *)'{-S+,--server=}'[start Web server on specified address/port]: :->server' + '(-t --docroot fi im pb pf rf rn sc *)'{-t+,--docroot=}'[specify Web-server document root]:document root:_directories' + + + ar # Script-argument operands + '(-)*:: :->argument' ) -fi - -args+=( - '(-a --interactive)'{-a,--interactive}'[run interactively]' - '(-c --php-ini -n --no-php-ini)'{-c,--php-ini}'[look for php.ini file in the specified directory]:INI file or directory:_files -g "*.ini(-.)"' - '(-c --php-ini -n --no-php-ini)'{-n,--no-php-ini}'[no php.ini file will be used]' - '(-d --define)'{-d,--define}'[define INI entry]:configuration directive:->directive' - '(-e --profile-info)'{-e,--profile-info}'[generate extended information for debugger/profiler]' - "(-f --file -r --run $exclusions 1)"{-f,--file}'[parse specified file]'$php_files - '(- 1 *)'{-h,--help}'[display help information]' - '(- 1 *)'{-i,--info}'[PHP information]' - '(- *)'{-l,--syntax-check}'[syntax check only (lint)]' - '(- 1 *)'{-m,--modules}'[show compiled in modules]' - "(-r --run -f --file $exclusions -l --syntax-check -s --syntax-highlight -w --strip 1)"{-r,--run}'[run the specified PHP code without using script tags <?..?>]:PHP code:' - '(- 1 *)'{-s,--syntax-highlight}'[display colour syntax highlighted source]' - '(- 1 *)'{-v,--version}'[display version information]' - '(- *)'{-w,--strip}'[display source with stripped comments and whitespace]' - '(-z --zend-extension)'{-z,--zend-extension}'[load specified Zend extension]:extension file:->extension' - '(-)1'$php_files - '(-)*::script argument: _normal' -) - -_arguments -C -s -S "$args[@]" && return 0 - -case $state in - directive) - local -a directives suf - local code='foreach (ini_get_all() as $k => $v) { echo "$k\n"; }' - directives=( $(_call_program directives $words[1] -r ${(q)code} 2>/dev/null) ) - if compset -P 1 '*='; then - _default && return 0 - else - compset -S '=*' || suf=( -qS '=' ) - _wanted directives expl 'configuration directive' compadd "$suf[@]" -a directives && return 0 - fi - ;; - extension) - local -a paths - if [[ -r /etc/ld.so.conf ]]; then - paths=( ${(f)"$(</etc/ld.so.conf)"} ) - else - paths=(.) - fi - _wanted extensions expl 'zend extension' _files -W paths -g "*.so(|.*)(-.)" && return 0 - ;; -esac - -return 1 + + _arguments -C -s -S : $args && ret=0 + + case $state in + argument) + if [[ -n $opt_args[(i)(pb|pf|rn)-*] ]]; then + _description files expl 'script argument' + _files "${(@)expl}" && ret=0 + else + _normal && ret=0 + fi + ;; + directive) + local -a directives suf + local code='foreach (ini_get_all() as $k => $v) { echo "$k\n"; }' + directives=( ${(f)"$( + _call_program directives $words[1] -r ${(q)code} + )"} ) + if compset -P 1 '*='; then + _default && ret=0 + else + compset -S '=*' || suf=( -qS '=' ) + _wanted directives expl 'INI directive' \ + compadd "$suf[@]" -a directives && ret=0 + fi + ;; + server) + if compset -P '*:'; then + _wanted -2V port-numbers expl 'port number' \ + compadd 80 81 443 591 8000 8001 8008 8080 8443 && ret=0 + ret=0 + else + _wanted hosts expl 'local address' _bind_addresses -0bhK -qS: && ret=0 + fi + ;; + esac + + return ret +} + +_php "$@" diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps index a8208a365..72e711227 100644 --- a/Completion/Unix/Command/_ps +++ b/Completion/Unix/Command/_ps @@ -31,7 +31,7 @@ args=( '*-G+[select processes by real group]:group:_sequence -s , _groups' '*-g+[select processes by effective group or session]:group:_sequence -s , _groups' '*-s+[select processes by session leaders]:session leader:_sequence -s , _pids' - '*-t+[select processes by attached terminal]:tty:_sequence -s , _ttys -D' + '*-t+[select processes by attached terminal]:tty:_sequence -s , _ttys -Do' '*-u+[select processes by effective user]:user:_sequence -s , _users' '*-U+[select processes by real user]:user:_sequence -s , _users' '-o+[specify output format]:property:_sequence -s , _ps_props -' @@ -211,7 +211,7 @@ if (( CURRENT > 1 )) && [[ $OSTYPE != (solaris*|linux-gnu) || *J) _sequence _jails -0 && return ;; *[MNW]) _files && return ;; *t) - _wanted -C option-t-1 ttys expl tty _sequence -s , _ttys -D && return + _wanted -C option-t-1 ttys expl tty _sequence -s , _ttys -Do && return ;; *[pq]) _wanted -C "option-${words[CURRENT-1][-1]}-1" processes \ expl 'process ID' _sequence -s , _pids && return ;; diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf index 282431462..ce78baf27 100644 --- a/Completion/Unix/Command/_readelf +++ b/Completion/Unix/Command/_readelf @@ -7,6 +7,7 @@ _pick_variant -r variant elftoolchain=elftoolchain elfutils=elfutils binutils -- args=( '(-a --all)'{-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]' '(-S --section-headers --sections)'{-S,--section-headers,--sections}'[show sections header]' @@ -31,7 +32,6 @@ args=( case $variant in elftoolchain|binutils) args+=( - '(-g --section-groups)'{-g,--section-groups}'[show section groups]' '(-t --section-details)'{-t,--section-details}'[show section details]' '(-e --headers)'{-e,--headers}'[show file, program and sections headers]' '(-s --syms --symbols)'{-s,--syms,--symbols}'[show symbol table]' @@ -49,6 +49,7 @@ case $variant in ;; elfutils) args+=( + '--dwarf-skeleton=[find skeleton compile units (with -w)]:file:_files' '--elf-section[used specified section as ELF input data]::section' '(-e --exception)'{-e,--exception}'[show sections for exception handling]' '(-N --numeric-addresses)'{-N,--numeric-addresses}"[don't find symbol names for addresses in DWARF data]" diff --git a/Completion/Unix/Command/_readlink b/Completion/Unix/Command/_readlink new file mode 100644 index 000000000..36bd43752 --- /dev/null +++ b/Completion/Unix/Command/_readlink @@ -0,0 +1,48 @@ +#compdef readlink greadlink + +local variant ret=1 +local -a context line state state_descr args copts aopts=( -A '-*' ) +local -A opt_args + +# We can't use groups here because it would complicate the option filtering +copts=( -e -f -m --canonicalize --canonicalize-existing --canonicalize-missing ) + +args=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' + # Delimiter options + # (Note: GNU `readlink` won't let you use -n with multiple files) + '(-n -z --no-newline --zero)'{-n,--no-newline}'[suppress trailing newline]' + '(-n -z --no-newline --zero)'{-z,--zero}'[use NUL as output delimiter]' + # Verbosity options + '(-q -s -v --quiet --silent --verbose)'{-q,-s,--quiet,--silent}'[suppress most error messages]' + '(-q -s -v --quiet --silent --verbose)'{-v,--verbose}'[show error messages]' + # Canonicalisation options + "(${(j< >)copts})"{-e,--canonicalize-existing}'[canonicalize paths (all components must exist)]' + "(${(j< >)copts})"{-f,--canonicalize}'[canonicalize paths]' + "(${(j< >)copts})"{-m,--canonicalize-missing}'[canonicalize paths (components may be missing)]' +) + +# Filter out non-GNU options if applicable +if _pick_variant gnu='Free Soft' unix --version; then + aopts=( ) +else + case $OSTYPE in + darwin*) args=( ${(@M)args:#(|*\))-[n]\[*} ) ;; + netbsd*) args=( ${(@M)args:#(|*\))-[fnqsv]\[*} ) ;; + dragonfly*|*bsd*) args=( ${(@M)args:#(|*\))-[fn]\[*} ) ;; + *) args=( ) ;; + esac +fi + +_arguments -s -S $aopts : $args '*: :->files' && ret=0 + +# File arguments must be symlinks unless a canonicalisation option is given +[[ $state == files ]] && +if [[ ${opt_args[(i)(${~${(j<|>)copts}})]} ]]; then + _files && ret=0 +else + _files -g '*(@)' && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_rmdir b/Completion/Unix/Command/_rmdir new file mode 100644 index 000000000..0f5e16912 --- /dev/null +++ b/Completion/Unix/Command/_rmdir @@ -0,0 +1,23 @@ +#compdef rmdir grmdir + +local -a args + +args=( + '(-p --parents)'{-p,--parents}'[remove each component of the specified paths]' +) + +if _pick_variant gnu=GNU unix --version; then + args+=( + '--ignore-fail-on-non-empty[ignore failure if directory is non-empty]' + '(-v --verbose)'{-v,--verbose}'[be verbose]' + ) +else + args=(${args:#*\)--*}) + if [[ $OSTYPE == (dragonfly|freebsd)* ]]; then + args+=('-v[be verbose]') + fi +fi + +_arguments -s -S -A '-*' \ + $args \ + '*:directories:_directories' diff --git a/Completion/Unix/Command/_samba b/Completion/Unix/Command/_samba index faad69ba4..9a2fea9d6 100644 --- a/Completion/Unix/Command/_samba +++ b/Completion/Unix/Command/_samba @@ -1,93 +1,112 @@ #compdef smbcontrol smbclient nmblookup smbstatus -local expl msgs args +local curcontext="$curcontext" ret=1 +local -a state line expl msgs args ign + +(( CURRENT == 2 )) || ign='!' +args=( + '(-d --debuglevel)'{-d+,--debuglevel=}'[set debug level]:debug level (1..10) [1]' + '(-s --configfile)'{-s+,--configfile=}'[specify alternate smb.conf file]:config file:_files' + '(-l --log-basename)'{-l+,--log-basename=}'[specify base name for log files]:base name:_files' + '*--option=[set smb.conf option from command line]:option=value' + "${ign}(1 2 3 -)"{-\?,--help}'[display usage information]' + "${ign}(1 2 3 -)--usage[display brief usage information]" + "${ign}(1 2 3 - *)"{-V,--version}'[display version information]' +) case $service in smbcontrol) - case $CURRENT in - 3) - msgs=( debug ping profile debuglevel profilelevel ) - case $words[CURRENT-1] in - nmbd) msgs=( $msgs force-election ) ;; - smbd) msgs=( $msgs printer-notify ) ;; - -i) return 1 ;; - esac - _wanted message-type expl 'message types' compadd -a msgs - ;; - 4) - case $words[CURRENT-1] in - profile) - _wanted parameter expl 'parameter' compadd on off flush count - ;; - debug) _message -e levels 'debug level' ;; - ping) _message -e numbers 'number of ping messages' ;; - esac + _arguments -C -S $args \ + '(-t --timeout)'{-t+,--timeout=}'[set timeout]:timeout (seconds)' \ + ':destination:(all nmbd smbd winbindd)' \ + ':message type:->message-types' \ + ':parameter:->parameters' && ret=0 + + case $state in + message-types) + msgs=( ${${${${${(f)"$(_call_program message-types smbcontrol -\? 2>&1)"}[(r)<message-type*,-1]}[2,-1]#?}/ ##(#b)(?)/:$match:l}%:( |\(null\))} ) + _describe -t message-types 'message type' msgs -M 'r:|-=* r:|=*' && ret=0 ;; - *) - _arguments \ - '-i[run interactively]' \ - ':destination:(nmbd smbd)' + parameters) + case $line[2] in + profile) + _wanted parameter expl 'parameter' compadd on off flush count && ret=0 + ;; + debug) _message -e levels 'debug level' ;; + ping) _message -e numbers 'number of ping messages' ;; + esac ;; esac + return ret ;; smbclient) - args=( - '(-N -A)2:password' - '(2)-s+[specify location of smb.conf]:smb.conf location:_files' - '(2)-O+[specify socket options]:socket options' - '(2)-R+[specify name resolution order]:name resolution order:_values -s " " "name resolution order" lmhosts host wins bcast' - '(2 -L -D -T)-M+[send message]:host:_hosts' - '(2)-i+[specify NetBIOS scope]:scope' - '(2)-N[suppress password prompt]' - '(2)-n+[specify local NetBIOS name]:local machine name' - '(2)-d+[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' - '(2)-p+[specify tcp port]:tcp port' - '(2)-l+[specify base log filename]:base log filename' - '(2)-I+[specify IP address of server]:IP address' - '(2)-E[output messages to stderr]' - '(2)-U+[specify username]:username:_users' - '(2)-A+[specify file containing username/password]:file:_files' - '(2 -M -D -T)-L+[list services on server]:host:_hosts' - '(2)-t+[specify terminal code]:terminal code' - '(2)-b+[specify buffersize]:transmit/send buffer size (bytes)' - '(2)-W+[specify workgroup]:workgroup' - '(2 -M -L)-T+[specify tar options]:tar options' - '(2 -M -L)-D+[initial directory]:initial directory' - '(2)-c[specify commands]:command string' + args+=( + '(-N -A)2: :_guard "^-*" password' + '(2 -R --name-resolve)'{-R+,--name-resolve=}'[specify name resolution order]:name resolution order:_values -s " " "name resolution order" lmhosts host wins bcast' + '(2 -M --message -L --list -D --directory -T --tar)'{-M+,--message=}'[send message]:host:_hosts' + '(2 -I --ip-address)'{-I+,--ip-address=}'[specify IP address of server]:IP address' + '(2 -E --stderr)'{-E,--stderr}'[output messages to stderr]' + '(2 -M --message -D --directory -T --tar)'{-L+,--list=}'[list services on server]:host:_hosts' + '(-m --max-protocol)'{-m+,--max-protocol=}'[set the max protocol level]:level' + '(2 -T --tar -M --message -L --list)'{-T+,--tar=}'[specify tar options]:tar options' + '(2 -D --directory -M --message -L --list)'{-D+,--directory=}'[specify initial directory]:initial directory' + '(2 -c --command)'{-c,--command=}'[specify commands]:command string' + '(2 -b --send-buffer)'{-b+,--send-buffer=}'[change transmit/send buffer]:buffer size (bytes) [65520]' + '(-t --timeout)'{-t+,--timeout=}'[change the per-operation timeout]:timeout (seconds)' + '(2 -p --port)'{-p+,--port=}'[specify tcp port]:tcp port' + '(-g --grepable)'{-g,--grepable}'[produce grepable output]' + '(-B --browse)'{-B,--browse}'[browse SMB servers using DNS]' + '(2 -d --debuglevel)'{-d+,--debuglevel=}'[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' + '(2 -O --socket-options)'{-O+,--socket-options=}'[specify socket options]:socket options' + '(2 -n --netbiosname)'{-n+,--netbiosname=}'[specify local NetBIOS name]:local machine name' + '(2 -W --workgroup)'{-W+,--workgroup=}'[specify workgroup]:workgroup' + '(2 -i --scope)'{-i+,--scope=}'[specify NetBIOS scope]:scope' + '(2 -U --user)'{-U+,--user=}'[specify username]:username:_users' + '(2 -N --no-pass)'{-N,--no-pass}'[suppress password prompt]' + '(-k --kerberos)'{-k,--kerberos}'[use kerberos (active directory) authentication]' + '(2 -A --authentication-file)'{-A+,--authentication-file=}'[specify file containing username/password]:file:_files' + '(-S --signing)'{-S+,--signing=}'[set the client signing state]:state:(on off required)' + '(-P --machine-pass)'{-P,--machine-pass}'[use stored machine account password]' + '(-e --encrypt)'{-e,--encrypt}'[encrypt SMB transport]' + '(-C --use-ccache)'{-C,--use-ccache}'[use the winbind ccache for authentication]' + '--pw-nt-hash[the supplied password is the NT hash]' ) - if (( CURRENT == 2 )); then - args=( $args - '1:service name:_hosts -P // -S /' - '(-s -O -R -M -i -N -n -d -p -l -I -E -U -A -L -t -b -W -T -D -c)-h[display usage information]' - ) - fi - _arguments -s "$args[@]" + (( CURRENT == 2 )) && args+=( '1:service name:_hosts -P // -S /' ) + _arguments -s -S $args ;; nmblookup) - _arguments -s -A "-*" \ - '(-h)-R[set recursion desired in packet]' \ - '(-h)-M[search for a master browser]' \ - '(-h)-S[lookup node status as well]' \ - '(-h)-T[perform reverse DNS on IP addresses]' \ - '(-h)-r[use root port 137]' \ - '(-h)-A[query node status on IP address]' \ - '(-R -M -S -T -r -A -B -U -d -s -i *)-h[print help message]' \ - '(-h)-B+[specify broadcast address]:broadcast address' \ - '(-h)-U+[specify unicast address]:unicast address' \ - '(-h)-d+[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' \ - '(-h)-s+[specify location of smb.conf]:smb.conf location:_files' \ - '(-h)-i+[specify NetBIOS scope]:scope' \ - '(-h)*:NetBIOS name:_hosts' + _arguments -s -S $args \ + '(-B --broadcast)'{-B+,--broadcast=}'[specify broadcast address]:broadcast address' \ + '(-f --flags)'{-f,--flags}'[list NMB flags returned]' \ + '(-U --unicast)'{-U+,--unicast=}'[specify unicast address]:unicast address' \ + '(-M --master-browser)'{-M,--master-browser}'[search for a master browser]' \ + '(-R --recursion)'{-R,--recursion}'[set recursion desired in packet]' \ + '(-S --status)'{-S,--status}'[lookup node status as well]' \ + '(-T --translate)'{-T,--translate}'[perform reverse DNS on IP addresses]' \ + '(-r --root-port)'{-r,--root-port}'[use root port 137]' \ + '(-A --lookup-by-ip)'{-A,--lookup-by-ip}'[query node status on IP address]' \ + '(-d --debuglevel)'{-d+,--debuglevel=}'[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' \ + '(-O --socket-options)'{-O+,--socket-options=}'[specify socket options to use]:socket option' \ + '(-n --netbiosname)'{-n+,--netbiosname=}'[specify primary netbios name]:netbios name' \ + '(-W --workgroup)'{-W+,--workgroup=}'[specify workgroup name]:workgroup name' \ + '(-i --scope)'{-i+,--scope=}'[specify NetBIOS scope]:scope' \ + '(h)*:NetBIOS name:_hosts' ;; smbstatus) - args='(-b -d -L -p -S)' - _arguments -s \ - "$args-b[brief output]" \ - "$args-d[detailed output]" \ - "$args-L[list only locks]" \ - "$args-p[list smbd(8) processes]" \ - "$args-S[list only shares]" \ - '-s+[specify location of smb.conf]:smb.conf location:_files' \ - '-u+[specify user to restrict information to]:user:_users' - ;; + _arguments -s -S $args \ + {-b,--brief}'[brief output]' \ + '(-v --verbose)'(-v,--verbose)'[be verbose]' \ + '(-d --debuglevel)'{-d+,--debuglevel=}'[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' \ + '(-u --user)'{-u+,--user=}'[specify user to restrict information to]:user:_users' \ + '(-B --byterange)'{-B,--byterange}'[include byte range locks]' \ + '(-n --numeric)'{-n,--numeric}'[numeric uid/gid]' \ + '(-f --fast)'{-f,--fast}'[skip checks if processes still exist]' \ + + '(output)' \ + {-P,--profile}'[do profiling]' \ + {-R,--profile-rates}'[show call rates]' \ + {-L,--locks}'[list only locks]' \ + {-p,--processes}'[list smbd(8) processes]' \ + {-S,--shares}'[list only shares]' \ + {-N,--notify}'[list only notifies]' + ;; esac diff --git a/Completion/Unix/Command/_scons b/Completion/Unix/Command/_scons new file mode 100644 index 000000000..2c620cc1a --- /dev/null +++ b/Completion/Unix/Command/_scons @@ -0,0 +1,59 @@ +#compdef scons + +_arguments -s -S \ + '(-c --clean --remove)-'{c,-clean,-remove}'[remove specified targets and dependencies]' \ + '(-C --directory)-'{C,-directory=}'[change to specified directory first]:directory:_directories' \ + '--cache-debug=[print CacheDir debug info to file]:file:_files' \ + '(--cache-disable --no-cache)--'{cache-disable,no-cache}"[don't retrieve built targets from cache]" \ + '(--cache-force --cache-populate)--'{cache-force,cache-populate}'[copy already-built targets into cache]' \ + "--cache-readonly[don't update CacheDir with built targets]" \ + '--cache-show[print build actions for files from cache]' \ + '--config=[set Configure mode]:mode:(auto force cache)' \ + '(-u --up --search-up -U)-D[search up for SConstruct; build default targets]' \ + '--debug=[print debugging information]:type:( + count duplicate explain findlibs includes memoizer memory objects pdb prepare presub stacktrace time)' \ + '--diskcheck=[enable specific on-disk checks]:check:(all none match rcs sccs)' \ + '--duplicate=[set preferred file duplication methods]:file duplication methods:( + hard-soft-copy soft-hard-copy hard-copy soft-copy copy)' \ + '(-f --file --makefile --sconstruct)-'{f,-file=,-makefile=,-sconstruct=}'[specify SConstruct file]:file:_files' \ + '(-)-'{h,-help}'[display defined usage information]' \ + '(-)-'{H,-help-options}'[display usage information]' \ + '(-i -ignore-errors)-'{i,-ignore-errors}'[ignore errors from build actions]' \ + \*{-I,--include-dir=}'[add directory to search Python modules]:directories:_directories' \ + '(--implicit-deps-changed --implicit-deps-unchanged)--implicit-cache[cache scanned dependencies]' \ + '(--implicit-cache --implicit-deps-changed)--implicit-deps-changed[rescan dependencies]' \ + '(--implicit-cache --implicit-deps-unchanged)--implicit-deps-unchanged[ignore changes to scanned dependencies]' \ + '--interactive[start interactive mode]' \ + '(-j --jobs)-'{j,jobs=}'[specify no of jobs to run in parallel]' \ + '(-k --keep-going)-'{k,-keep-going}'[continue after an error]' \ + '--max-drift=[set the maximum clock drift]:drift (seconds)' \ + '--md5-chunksize=[set chunksize for MD5 signature computation]:size (kB)' \ + '(-n --just-print --dry-run --recon)-'{n,-just-print,-dry-run,-recon}"[print commands but don't run them]" \ + "--no-site-dir[don't use the usual site_scons directory]" \ + '--profile=[profile scons]:output file:_files' \ + '(-q --question)-'{q,question}'[query whether up-to-date]' \ + '-Q[suppress progress messages]' \ + '--random[build dependencies in random order]' \ + '(-s --silent --quiet)-'{s,-silent,-quiet}"[don't print commands]" \ + '--site-dir=[specify site_scons directory]:directory:_directories' \ + '--stack-size[set stacksize of threads]:size (kB)' \ + '--taskmastertrace=[trace node evaluation to file]:file' \ + '--tree=[print dependency tree]:format:(all derived prune status)' \ + '(-u --up --search-up -D -U)-'{u,-up,-search-up}'[search up for SConstruct; build current directory]' \ + '(-u --up --search-up -D)-U[search up for SConstruct; build Default targets]' \ + '(-)-'{v,-version}'[print version information]' \ + \*{--warn=,--warning=}'[enable or disable warnings]:type:( + all cache-write-error corrupt-sconsign dependency deprecated + deprecated-copy deprecated-source-signatures deprecated-target-signatures + duplicate-environment fortran-cxx-mix link misleading-keywords + missing-sconscript no-md5-module no-metaclass-support no-object-count + no-parallel-support python-version reserved-variable stack-size no-all + no-cache-write-error no-corrupt-sconsign no-dependency no-deprecated + no-deprecated-copy no-deprecated-source-signatures + no-deprecated-target-signatures no-duplicate-environment + no-fortran-cxx-mix no-link no-misleading-keywords no-missing-sconscript + no-no-md5-module no-no-metaclass-support no-no-object-count + no-no-parallel-support no-python-version no-reserved-variable + no-stack-size)' \ + \*{-Y,--repository}'[search specified repository for files]:repository:_files' \ + '*:target:_default' # Doesn't seem to be a simple way to get a list of targets diff --git a/Completion/Unix/Command/_sed b/Completion/Unix/Command/_sed index 15b92a634..f03278364 100644 --- a/Completion/Unix/Command/_sed +++ b/Completion/Unix/Command/_sed @@ -1,15 +1,60 @@ #compdef sed gsed psed s2p -local args inplace extended +local variant inplace extended ign sep separator +local -i nest=0 +local -a args aopts sedexpr cmds_none cmds_slash cmds_end substflags expl bsnl nl labels excl dedup +local -a step range negate mods +aopts=( -A '-*' ) +bsnl=( $'\\\n' ) +nl=$'\n' +compquote nl +cmds_none=( + '{:start group' + 'q:quit after printing pattern space' + 'h:copy pattern space to hold space' + '\::place label' + '#:comment' + '=:print current line number' + 'a:append text' + 'i:insert text' + 'r:append contents of file' + 'b:branch' + 't:branch if s command has been successful' + 'c:replace line with text' + 'l:list current line in visually unambiguous form' + 'w:write pattern space to file' +) +cmds_slash=( + 's:substitute regex' + 'y:transliterate characters' +) +cmds_end=( + 'd:delete pattern space' + 'D:delete up to the first newline in the pattern space' + 'g:copy hold space to pattern space' + 'G:append hold space to pattern space' + 'H:append pattern space to hold space' + 'n:read the next line of input into pattern space' + 'N:append the next line of input to the pattern space' + 'p:print the current pattern space' + 'P:print upto the first newline of the current pattern space' + 'x:exchange hold and pattern spaces' + '}:end group' +) +substflags=( + 'g:replace all matches to the regular expression' + 'p:print new pattern space if substitution made' + 'w:write result to named file if substitution made' +) args=( '(-n --quiet --silent)'{-n,--quiet,--silent}'[suppress automatic printing of pattern space]' - '(1)*'{-e,--expression=-}'[specify sed commands to run]:sed script' - '(1)*'{-f,--file=-}'[add contents of file to commands to run]:file:_files' - '(-e)1: :_guard "^-*" sed script' + '(1)*'{-e+,--expression=}'[specify sed commands to run]:sed script:_sed_expressions' + '(1)*'{-f+,--file=}'[add contents of file to commands to run]:file:_files' + '(-e)1:sed script:_sed_expressions' '*:input file:_files' ) -inplace='[edit files in-place, running scripts separately for each file]::suffix for backup' +inplace='[edit files in-place, running scripts separately for each file]:: :_guard "^(*[@/; ]*|?(#c6,)|-*)" "suffix for backup"' extended='[use extended regular expressions]' if [[ $service = (psed|s2p) ]]; then @@ -17,40 +62,193 @@ if [[ $service = (psed|s2p) ]]; then "${(@)args:#(|\(*\))(|\*)--*}" '-a[delay opening files listed with w function]' ) -elif _pick_variant gnu=GNU unix --version; then +elif _pick_variant -r variant gnu=GNU unix --version; then + aopts=( ) + (( $#words > 2 )) && ign='!' args+=( '--follow-symlinks[follow symlinks when processing in place]' - '(-i --in-place)'{-i-,--in-place=-}$inplace + '(-i --in-place -s --separate)'{-i-,--in-place=-}$inplace '(-c --copy)'{-c,--copy}'[copy instead of rename when shuffling files in in-place mode]' - '(-l --line-length)'{-l,--line-length=-}'[specify line-wrap length for the l command]' + '(-l --line-length)'{-l+,--line-length=}'[specify line-wrap length for the l command]' '(-r)--posix[disable GNU extensions]' '(-E -r --regexp-extended)'{-E,-r,--regexp-extended}$extended '(-s --separate)'{-s,--separate}'[consider files separately instead of as a combined stream]' '--sandbox[block commands that can affect the system (r/w/W/e)]' '(-u --unbuffered)'{-u,--unbuffered}'[disable data buffering]' '(-z --null-data)'{-z,--null-data}'[separate lines by NUL characters]' - '(- 1 :)--help[print program usage]' - '(- 1 :)--version[print program version]' + "${ign}(- 1 :)--help[print program usage]" + "${ign}(- 1 :)--version[print program version]" ) + if [[ -z ${words[(r)--posix]} ]]; then + cmds_none+=( + 'R:append a line from file' + 'T:branch if no s command has been successful' + 'W:write the first line of pattern space to file' + 'v:fail if GNU extensions not supported or older than specified version' + ) + cmds_end+=( + "e:execute a command and include it's output" + 'F:print the filename of the current input file' + 'Q:quit' + 'z:empty the pattern space' + ) + substflags+=( + 'e:execute pattern space as a command and replace with result' + {i,I}':case-insensitive regular expression matching' + {m,M}':multi-line matching' + ) + fi else args=( "${(@)args:#(|\(*\))(|\*)--*}" ) case $OSTYPE in openbsd*|freebsd*|netbsd*|darwin*|dragonfly*) args+=( - '(-r -E)'{-r,-E}$extended + '(-r -E)'-E$extended '-a[delay opening files listed with w function]' ) ;| - darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i'$inplace ) ;| + openbsd*|freebsd*|netbsd*|dragonfly*) args+=( '(-r -E)'-r$extended ) ;| + darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i+'$inplace ) ;| darwin*|freebsd*|netbsd*) args+=( '-l[make output line buffered]' ) ;| freebsd*) args+=( '-u[disable data buffering]' ) ;| freebsd*|netbsd*) args+=( - '-I[edit files in-place, treating all files as a single input stream]::suffix for backup' + '-I+[edit files in-place, treating all files as a single input stream]:: :_guard "^(*[@/; \\\]*|?(#c6,)|-*)" "suffix for backup"' ) ;; openbsd*) args+=( '-u[make output line buffered]' ) ;; esac fi -_arguments -s "$args[@]" +zstyle -s ":completion:${curcontext}:address-forms" list-separator separator || separator=-- +step=( "~ $separator step" ) +negate=( "! $separator negated" ) +range=( ", $separator range" ) +mods=( "I $separator case-insensitive" "M $separator multi-line" ) + +sedexpr=( + \( /$'*\0[ \t\n]#'/ \) # strip off any preceding arguments - handled by _arguments + \( + # Handle an optional address range + \( + \( + \( + '///' '/[^/]#//' ':regexes:regex:' # skip /pattern/ + \| + '/\\(?)/' -'sep=${match#?}' # handle \xpatternx + \( '/\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# '/?/' -'[[ $match = $sep ]]' ':regexes:regex:' + \) + $'/[ \t]#/' + \( \| '/[IM]##/' -'dedup=( ${(s..)match} )' ':address-forms:address form:compadd -S "" -d mods -F dedup I M' \) \# + \| + '/([0-9]##|$)[ \t]#/' # line number + \( + '/\~[ \t]#/' # addr1~N + '/[0-9]##[ \t]#/' ': _message -e steps "number - match where line number is a multiple"' + \| '//' ':address-forms:address form:compadd -S "" -d step \~' \) + \| + '/[]/' ': _guard "^([sy]|[^0-9$/\\\]*)" "address - line number or /pattern/"' + \) + \( # range end, also optional + '/[ \t]#,[ \t]#/' -'excl=( \\\# : )' # exclude comments and labels after ranges + \( + '///' '/[^/]#//' ':regexes:regex:' # handle /pattern/ + \| + '/\\(?)/' -'sep=${match#?}' # handle \xpatternx + \( '/\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# '/?/' -'[[ $match = $sep ]]' ':regexes:regex - 2:' + \| + '/+[ \t]#/' # addr1,+N + '/[0-9]##/' ': _message -e number "number of following lines"' + \| + '/\~[ \t]#/' # addr1,~N + '/[0-9]##/' ': _message -e number "following lines until line number is a multiple of specified number"' + \| + '/([0-9]##|$)/' # line number + \| + '/[]/' ': _message -e ranges "ending line - [+~]number, $ or /pattern/"' + \) + \| + '//' -'excl=( \\\# : )' ':address-forms:address form:compadd -S "" -d range ,' + \) + \( + '/!/' ':address-forms:address form:compadd -S "" -d negate !' + \| \) + \| // -'excl=( \{ )' \) # { ... } is only useful following a range so exclude { + + $'/[ \t]#/' -'(( nest )) || excl+=( \} )' # whitespace + exclude } without preceding { + \( # First commands, for which the pattern fully terminates them + '/e[ \t]#/' $'/((\\\n|\\[^\n]|[^\\\n])##\n|[\n;])/' ':commands:command:_cmdstring' # GNU extension + \| + $'/{[ ;\t\n]#/' -'((++nest,1))' # opening brace + \| + '/\#/' # comments + $'/[^\n]##\n[\n; \t]#/' ':comments:comment:' + \| + $'/[aci]/' # a, c and i commands + \( + $'/[ \t]#/' -'[[ $variant = gnu && $+opt_args[--posix] = 0 ]]' # GNU allows, e.g. 'c string' + \| + $'/[ \t]#/' $'/\\\n/' ':newlines:newline:compadd -Q -S "" "$bsnl"' + \) + $'/(\\\n|\\[^\n]|[^\\\n])##\n[\n; \t]#/' ':strings:string:' + \| + $'/[RrwW][ \t]#/' $'/[^\n]##\n[\n; \t]#/' ':files:file:_files -S ""' + \| # Now commands with shared termination handling + \( + # branches/labels, GNU sed allows an empty label + $'/[:btT][ \t]#/' $'/[^ \t\n;]#/' $'%[ \t\n;]%' -'labels+=( $match )' + ':labels:label: _wanted -x labels expl label compadd -S "" -a labels' + \| + '/l/' $'/[ \t]#<->/' ':width:width:' + \| + '/s(?)/' -'sep=${match#s}' # Substitutions + \( '/\\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# + '/?/' -'[[ $match = $sep ]]' ':regexes:source regex:' + \( '/\\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# + '/?/' -'[[ $match = $sep ]]' ':regexes:substitute string (back-references with & and \1 .. \9):' + \( # Substitution flags + $'/w[ \t]#/' $'/[^\n]##/' $'%\n%' ':files:file:_files -S ""' + \| + # pass existing flags, building exclusion list from them + $'/[gpiImM0-9]#/' -'excl=( ${(s..)${${${match/[iI]/iI}/[mM]/mM}}/e/ew} )' + \( + '//' -'[[ -z ${excl[(r)[0-9]]} ]]' # exclude if numbers already there + '//' '%[^egpiImM0-9]%' ': _message -e numbers "number - substitute nth match"' + \| + '//' '%[^egpiImM0-9]%' $':flags:flag: _describe -t flags flag substflags -S "" -F excl' + \) + \) + \| + '/y(?)/' -'sep=${match#y}' # Character transliterations + \( '/\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# '/?/' -'[[ $match = $sep ]]' ':source:source:' + \( '/\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# '/?/' -'[[ $match = $sep ]]' ':dest:dest:' + \| + '/[qQ]/' -'[[ $variant = gnu && $+opt_args[--posix] = 0 ]]' + $'/[\t ]#<->/' '%[^0-9]%' ':exit-codes:exit code:' + \| + '/[=dDFhHgGnNpPqQxz]/' # stand-alone commands that take no argument + \( $'/[ \t]#/' $'%[#\n;}]%' \| $'/[ \t]/' '/[]/' ': _message "no arguments"' \| \) + \| + $'/v[ \t]#/' $'/[^\n;}]#/' $'%[\n;}]%' ':versions:version:' + \| + $'/}[ \t]#/' -'((--nest,1))' # closing } + \| + /'[]'/ ':commands:command: _describe -t sed-commands "sed command" cmds_none -S "" -F excl -- cmds_slash -S / -- cmds_end -F excl -r \; -S $nl' + \) + $'/[ \t]#/' + \( $'/}[ \t]#/' -'((--nest,1))' \| \) # closing } is allowed by GNU sed without preceding ; or newline + \( + '/\#/' $'/[^\n]##\n[\n; \t]#/' ':comments:comment:' # line end comments + \| + # add in and auto-removable newline if command is terminated + $'/[;\n][ ;\t\n]#/' $':separators:separator:compadd -r ";" -S $nl ""' + \| + $'/{[ \t]#/' -'((++nest,1))' # opening {, keep count of nesting level + \) + \) + \) \# +) + +_regex_arguments _sed_expressions "$sedexpr[@]" + +_arguments -s -S $aopts : "$args[@]" diff --git a/Completion/Unix/Command/_sh b/Completion/Unix/Command/_sh index 2afb46621..39d299c58 100644 --- a/Completion/Unix/Command/_sh +++ b/Completion/Unix/Command/_sh @@ -1,4 +1,4 @@ -#compdef sh ksh bash csh tcsh rc +#compdef sh ash csh dash ksh ksh88 ksh93 mksh oksh pdksh rc tcsh yash if (( CURRENT == ${words[(i)-c]} + 1 )); then _cmdstring diff --git a/Completion/Unix/Command/_shasum b/Completion/Unix/Command/_shasum new file mode 100644 index 000000000..950a47763 --- /dev/null +++ b/Completion/Unix/Command/_shasum @@ -0,0 +1,24 @@ +#compdef shasum -P shasum(|5).* + +# This function covers the `shasum` script included with Perl (and notably the +# primary SHA digest tool on macOS). See `_md5sum` for the GNU digest utilities +# and `_cksum` for the BSD ones. +# +# @todo It's possible that someone could symlink this script to `sha1sum` or +# whatever; we might want to detect that some day. + +_arguments -s -S : \ + '(: -)'{-h,--help}'[display help information]' \ + '(: -)'{-v,--version}'[display version information]' \ + + '(sum)' \ + '(chk)'{-0,--01}'[read in BITS mode]' \ + '(chk)'{-b,--binary}'[read in binary mode]' \ + '(chk)'{-p,--portable}'[read in portable mode]' \ + '(chk)'{-t,--text}'[read in text mode]' \ + + 'chk' \ + '(sum)'{-c,--check}'[verify checksums from input files]' \ + '(sum -s -w --status --warn)'{-s,--status}'[suppress all output]' \ + '(sum -s -w --status --warn)'{-w,--warn}'[warn about each improperly formatted checksum line]' \ + + misc \ + '(-a --algorithm)'{-a+,--algorithm=}'[specify algorithm]:algorithm:(1 224 256 384 512 512224 512256)' \ + '*: :_files' diff --git a/Completion/Unix/Command/_shuf b/Completion/Unix/Command/_shuf new file mode 100644 index 000000000..83f42e6d3 --- /dev/null +++ b/Completion/Unix/Command/_shuf @@ -0,0 +1,28 @@ +#compdef shuf gshuf + +local ret=1 +local -a context line state state_descr +local -A opt_args + +_arguments -s -S : \ + '(: -)--help[display help information]' \ + '(: -)--version[display version information]' \ + '(-n --head-count)'{-n+,--head-count=}'[limit output to specified number of lines]:output line limit' \ + '(-o --output)'{-o+,--output=}'[write result to specified file]:output file:_files' \ + '--random-source=[use specified file as source of random bytes]: :_files' \ + '(-r --repeat)'{-r,--repeat}'[allow output lines to repeat]' \ + '(-z --zero-terminated)'{-z,--zero-terminated}'[use NUL as line delimiter]' \ + '(-i --input-range)*: :->operands' \ + + '(excl)' \ + {-e,--echo}'[treat operands as input lines]' \ + '(:)'{-i+,--input-range=}'[treat specified numbers as input lines]:number range (x-y)' \ +&& ret=0 + +[[ $state == operands ]] && +if [[ -n ${opt_args[(i)excl-(-e|--echo)]} ]]; then + _message 'input line' && ret=0 +else + _files && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_shutdown b/Completion/Unix/Command/_shutdown index 9726182a0..a237b14e0 100644 --- a/Completion/Unix/Command/_shutdown +++ b/Completion/Unix/Command/_shutdown @@ -27,8 +27,8 @@ case $OSTYPE in '*:warning message' ) ;| - *bsd*|dragonfly*|linux*) - args=( + *bsd*|dragonfly*) + args+=( '-p[turn off power after shutdown]' ) ;| @@ -42,6 +42,11 @@ case $OSTYPE in 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]' + ) ;; netbsd*) args+=( diff --git a/Completion/Unix/Command/_sqlite b/Completion/Unix/Command/_sqlite index 58f7a9116..4604fb40c 100644 --- a/Completion/Unix/Command/_sqlite +++ b/Completion/Unix/Command/_sqlite @@ -1,6 +1,6 @@ #compdef sqlite sqlite3 -local ret opt display_opt sqlite3 +local opt display_opt sqlite3 ign local -a options output_modes exclusive dashes [[ $service = sqlite3 ]] && sqlite3=true || unset sqlite3 @@ -31,16 +31,18 @@ for display_opt in $output_modes ; do options+=( "($exclusive)"$^dashes"-${opt}[set output mode to $display_opt]" ) done +(( $#words == 2 )) || ign='!' options+=( $^dashes'-separator[set output field separator]:output field separator [|]' $^dashes'-nullvalue[set text string for null values]:string' - '(- :)'$^dashes'-version[show SQLite version]' - '(- :)'$^dashes'-help[show help]' + "$ign(- :)"$^dashes'-version[show SQLite version]' + "$ign(- :)"$^dashes'-help[show help]' '1:SQLite database file:_files' - '(- :)2:SQL to run' + '(- :)2: :_guard "^-*" "SQL to run"' ) (( $+sqlite3 )) && options+=( + $^dashes'-A+[run .archive with arguments and exit]' $^dashes'-append[append the database to the end of the file]' $^dashes'-bail[stop after hitting an error]' $^dashes'-cmd[run specified command before reading stdin]:sqlite meta-command' @@ -53,6 +55,23 @@ options+=( $^dashes'-readonly[open the database read-only]' $^dashes'-stats[print memory stats before each finalize]' $^dashes'-vfs[use specified default VFS]:vfs:(unix-dotfile unix-excl unix-none unix-namedsem)' + $^dashes'-zip[open the file as a ZIP Archive]' ) +if [[ -n $words[(r)-A*] ]]; then + options=( -s -w : '(-A --A)'${^dashes}-A "(-f --file -a --append)"${(M)options:#1:*} + '(-v --verbose)'{-v,--verbose}'[print each filename as it is processed]' + '(1 -a --append -f --file)'{-f+,--file=}'[specify archive file]:archive file:_files' + '(1 -a --append -f --file)'{-a,--append=}'[operate on specified file opened using the apndvfs VFS]:archive file:_files' + '(-C --directory)'{-C+,--directory=}'[change to specified directory to read/extract files]:directory:_directories' + '(-n --dryrun)'{-n,--dryrun}'[show the SQL that would have occurred]' + '*:file:_files' + + '(commands)' \ + '(-c --create)'{-c,--create}'[create a new archive]' + '(-u --update)'{-u,--update}'[update or add files to an existing archive]' + '(-t --list)'{-t,--list}'[list contents of archive]' + '(-x --extract)'{-x,--extract}'[extract files from archive]' + ) +fi + _arguments $options diff --git a/Completion/Unix/Command/_stat b/Completion/Unix/Command/_stat new file mode 100644 index 000000000..2e84d6bf0 --- /dev/null +++ b/Completion/Unix/Command/_stat @@ -0,0 +1,96 @@ +#compdef stat gstat zstat + +# Notes: +# - @todo It would be nice to complete the -c/-f format strings some day +# - @todo It should be possible to complete NFS file handles on FreeBSD and +# Dragonfly by parsing the output of `lsof -N`, but it's not available by +# default — is there another way? + +local expl variant precmd ret=1 +local -a context line state state_descr args aopts=( -A '-*' ) +local -A opt_args + +if [[ $service == zstat ]] || [[ $precommands[-1] == builtin ]]; then + variant=zsh +else + [[ $precommands[-1] == command ]] && precmd=command + _pick_variant -c "${precmd:+$precmd }${words[1]}" -r variant \ + gnu='Free Soft' zsh='no files given' unix --version +fi + +case $OSTYPE-$variant in + *-zsh) + args=( + "(-H)-A[assign the results to array, don't print]:array variable:_parameters -g '*array*'" + - set1 + +device +inode +mode +nlink +uid +gid +rdev + +size +atime +mtime +ctime +blksize +block +link + "(-A)-H[assign the results to associative array, don't print]:associative array variable:_parameters -g '*association*'" + '(:)-f[stat the specified file descriptor]:file descriptor:_file_descriptors' + '(-s)-F[specify strftime(3) format string]: :_date_formats zsh' + '(-s)-g[show times in GMT/UTC]' + # Note that this has the *opposite* effect of other variants' -L option! + "-L[don't dereference symbolic links; use lstat(2)]" + '(-N)-n[always show names of files]' + '(-n)-N[never show names of files]' + '-o[print file modes in octal rather than decimal]' + '-r[print raw data]' + '-s[print mode, UID, GID, and times as strings]' + '(-T)-t[always show type names]' + '(-t)-T[never show type names]' + '*: :_files' + - set2 + '-l[list stat types]' + ) + ;; + *-gnu) + aopts=( ) + args=( + '*: :_files' + '(: * -)--help[display help information]' + '(: * -)--version[display version information]' + '(-L --dereference)'{-L,--dereference}'[dereference symbolic links]' + + '(d)' # Display options + {-c+,--format=}'[display per the specified format string]:format string' + {-f,--file-system}'[display file-system status instead of file status]' + '--printf=[display as with -c, but interpret backslash escapes like printf(3)]' + {-t,--terse}'[display in terse format]' + ) + ;; + darwin*|dragonfly*|*bsd*) + args=( + '*: :->files-or-handles' + '(-H)-L[dereference symbolic links]' + '-q[suppress error messages about lstat(2)/stat(2) failure]' + + '(d)' # Primary display options + '(-F)-f+[display per the specified format string]:format string' + '-l[display in `ls -lT` format]' + '(-F -t)-r[display in raw (numerical) format]' + '(-F -t)-s[display in shell variable-assignment format]' + '(-F)-x[display in verbose (Linux-style) format]' + + D # Secondary display options + '(-f -r -s -x)-F[append file type indicators (implies -l)]' + '-n[suppress terminating newlines]' + '(-r -s)-t+[specify strftime(3) format string]: :_date_formats' + ) + ;| # MATCH AGAIN + dragonfly*|freebsd*) + args+=( + + df + '(-L)-H[treat arguments as hexadecimal-formatted NFS file handles]' + ) + ;; +esac + +(( $#args )) || args=( '*: :_files' ) + +_arguments -s -S $aopts : $args && ret=0 + +[[ $state == files-or-handles ]] && +if [[ -n ${opt_args[(i)*--H]} ]]; then + _message -e nfs-handles 'NFS file handle' +else + _files && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index b7e10c06b..e16be7e59 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -26,7 +26,7 @@ _svn () { _arguments -C -A "-*" \ '(-)--help[print help information]' \ - '(- *)--version[print client version information]' \ + '(*)--version[print client version information]' \ '1: :->cmds' \ '*:: :->args' && ret=0 @@ -169,6 +169,9 @@ _svn () { '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"' ) ;; + (unshelve) + args+=( '1:shelf name:compadd - ${${(f)"$(_call_program shelves svn unshelve -q --list)"}%% *}' ) + ;; (*) case $usage in *(SRC|DST|TARGET|URL*PATH)*) diff --git a/Completion/Unix/Command/_tac b/Completion/Unix/Command/_tac new file mode 100644 index 000000000..7a15bffff --- /dev/null +++ b/Completion/Unix/Command/_tac @@ -0,0 +1,19 @@ +#compdef tac gtac + +local variant + +_pick_variant -r variant gnu='Free Soft' unix --version + +# NetBSD (at least) has its own bare-bones version of this tool +[[ $variant == gnu ]] || { + _default + return +} + +_arguments -s -S : \ + '(: -)--help[display help information]' \ + '(: -)--version[display version information]' \ + '(-b --before)'{-b,--before}'[attach separator before instead of after]' \ + '(-r --regex)'{-r,--regex}'[treat separator as regular expression (with -s)]' \ + '(-s --separator)'{-s+,--separator=}'[use specified separator instead of newline]:separator' \ + '*: :_files' diff --git a/Completion/Unix/Command/_tee b/Completion/Unix/Command/_tee new file mode 100644 index 000000000..66ef66e19 --- /dev/null +++ b/Completion/Unix/Command/_tee @@ -0,0 +1,32 @@ +#compdef tee gtee + +local ret=1 +local -a context line state state_descr args +local -A opt_args + +args=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' + '(-a --append)'{-a,--append}'[append to files instead of overwriting]' + '(-i --ignore-interrupts)'{-i,--ignore-interrupts}'[ignore interrupt signals]' + '(--output-error)-p[warn on errors writing to non-pipes]' + '(-p)--output-error=[specify write-error behavior]: :->errmodes' +) + +# Filter out non-GNU options if applicable +_pick_variant gnu='Free Soft' unix --version || +args=( ${(@M)args:#(|*\))-[ai]\[*} ) + +_arguments -s -S : $args '*: :_files' && ret=0 + +[[ $state == errmodes ]] && { + args=( + 'exit[exit on errors writing to any output]' + 'exit-nopipe[exit on errors writing to non-pipes]' + 'warn[warn on errors writing to any output]' + 'warn-nopipe[warn on errors writing to non-pipes]' + ) + _values 'error mode' $args && ret=0 +} + +return ret diff --git a/Completion/Unix/Command/_tiff b/Completion/Unix/Command/_tiff index 588476d5a..128aeb0c0 100644 --- a/Completion/Unix/Command/_tiff +++ b/Completion/Unix/Command/_tiff @@ -14,7 +14,7 @@ if [[ $# -ne 0 || $+_in_tiff -ne 0 ]]; then set -- "$expl[@]" fi _wanted files expl 'picture file' _path_files "$@" -g "$pat" - || - _files "$@" "$expl[@]" -g '*.(#i)tiff(-.)' + _files "$@" "$expl[@]" -g '*.(#i)tif(|f)(-.)' return fi @@ -26,87 +26,143 @@ typeset -A opt_args case "$service" in tiff2bw) _arguments -C \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-r[specify rows per strip]:rows per strip' \ - '-R[specify percentage of red channel]:percentage of red channel' \ - '-G[specify percentage of green channel]:percentage of green channel' \ - '-B[specify percentage of blue channel]:percentage of blue channel' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ + '-R+[specify percentage of red channel]:percentage' \ + '-G+[specify percentage of green channel]:percentage' \ + '-B+[specify percentage of blue channel]:percentage' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; +tiff2pdf) + _arguments -s \ + '-o+[specify output file]:output file:_files -g "*.(#i)pdf(-.)"' \ + '(-z -d)-j[compress with JPEG]' \ + '(-j -d)-z[compress with Zip/Deflate]' \ + '-q+[specify compression quality]:quality' \ + '-n[no compressed data passthrough]' \ + "(-z -j)-d[don't compress]" \ + '-i[invert colors]' \ + '-u+[set distance unit]:unit:((i\:inches m\:centimeters))' \ + '-x+[set x resolution]:resolution (dots per unit)' \ + '-y+[set y resolution]:resolution (dots per unit)' \ + '-w+[specify width in units]:width' \ + '-l+[specify length in units]:length' \ + '-r+[specify scope for resolution settings]:scope:((d\:images\ without\ resolution o\:all\ images))' \ + '-p+[specify paper size]:paper size:(letter legal A4)' \ + '-F[make the tiff fill the PDF page]' \ + '-f[set PDF "Fit Window" user preference]' \ + '-e+[specify date]:date (YYYYMMDDHHMMSS)' \ + '-c+[set document creator, overrides image software default]:creator' \ + '-a+[set document author, overrides image artist default]:author' \ + '-t+[set document title, overrides image document name default]:title' \ + '-s+[set document subject, overrides image image description default]:subject' \ + '-k+[set document keywords]:keywords' \ + '-b[set PDF "Interpolate" user preference]' \ + '(- :)-h[display usage information]' \ + ':input file:_files -g "*.(#i)tif(|f)(-.)"' + ;; tiff2ps) - _arguments \ - '-1[generate PostScript Level I output]' \ - '-2[generate PostScript Level II output]' \ + _arguments -s \ + '!(-2 -3 -8 -m)-1' \ + '(-3)-2[generate PostScript Level 2 output]' \ + '(-2)-3[generate PostScript Level 3 output]' \ + '-8[disable use of ASCII85 encoding with PostScript Level 2/3]' \ '-a[generate output for all IFDs]' \ - '-d[set initial TIFF directory]:initial TIFF directory' \ - '(-p)-e[generate Encapsulated PostScript]' \ - '-o[set initial TIFF directory (file offset)]:file offset' \ + '-b+[set the bottom margin]:margin (inches)' \ + '-c[center image]' \ + '-C+[set postscript document creator name]:creator' \ + '-d+[set initial TIFF directory]:initial TIFF directory' \ + '(-e)-D[print two pages per sheet (duplex)]' \ + '(-p -D -T)-e[generate Encapsulated PostScript]' \ + '-h+[set printed page height]:height (inches)' \ + '-w+[set printed page width]:width (inches)' \ + '(-W)-H+[split image if height is more than specified value]:limit (inches)' \ + '(-H)-W+[split image if width is more than specified value]:limit (inches)' \ + '-L+[specify overlap for split images]:overlap (inches)' \ + '-i+[enable/disable (Nz/0) pixel interpolation]:state [enabled]:((0\:disable 1\:enable))' \ + '-l+[set the left margin]:margin (inches)' \ + '-m[use "imagemask" operator instead of "image"]' \ + '-o+[set initial TIFF directory (file offset)]:file offset (bytes)' \ '(-e)-p[generate non-Encapsulated PostScript]' \ - '-h[set page height]:page height' \ - '-w[set page width]:page width' \ - '-8[disable use of ASCII85 encoding]' \ - '-D[print two pages per sheet]' \ - '-O[specify output file]:output file:_files -g "*.(#i)ps(-.)"' \ + '-O+[specify output file]:output file:_files -g "*.(#i)(|e)ps(-.)"' \ + '-P+[set PageOrientation DSC comment to Landscape or Portrait]:orientation:(L P)' \ + '-r+[rotate image]:rotation:(90 180 270 auto)' \ '-s[generate output for a single image]' \ - '-T[print pages for top edge binding]' \ + '-t+[set postscript document title]:title' \ + '(-e)-T[print pages for top edge binding]' \ + '(-y)-x[override resolution units as centimeters]' \ + '(-x)-y[override resolution units as inches]' \ + '-z[enable printing in the deadzone]' \ '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffcmp) - _arguments \ + _arguments -s \ '-l[list all differing bytes]' \ + '-z+[list specified number of bytes that differs between the files]:bytes' \ '-t[ignore differences in directories]' \ ':first input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' \ ':second input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffcp) - _arguments -C \ - '-B[write output in bin-endian byte order]' \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-o[set initial TIFF directory (file offset)]:file offset' \ - '-p[set sample packing]:sample packing:(contig separate)' \ + _arguments -C -s \ + '-a[append to output instead of overwriting]' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-o+[set initial TIFF directory (file offset)]:file offset' \ + '-p+[set sample packing]:sample packing:(contig separate)' \ '(-t)-s[write output in strips]' \ '(-s)-t[write output in tiles]' \ + '-x[force the merged tiff pages in sequence]' \ + '-8[write BigTIFF instead of default ClassicTIFF]' \ + '(-L)-B[write output in big-endian byte order instead of native ordering]' \ + '(-B)-L[write output in little-endian byte order instead of native ordering]' \ + '-M[disable use of memory-mapped files]' \ + '-C[disable strip chopping]' \ '-i[ignore read errors]' \ - '-r[specify rows per strip]:rows per strip' \ - '-w[specify output tile width]:output tile width' \ - '-l[specify output tile length]:output tile length' \ - '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \ - '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 + '-b+[specify bias (dark) monochrome image to be subtracted from all others]:file:_files' \ + '-,=-[specify substitute character for image indices]:character [,]' \ + '-r+[specify rows per strip]:rows per strip' \ + '-w+[specify output tile width]:output tile width' \ + '-l+[specify output tile length]:output tile length' \ + '-f+[specify fill order]:fill order:(lsb2msb msb2lsb)' \ + '*:TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffdither) _arguments -C \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \ - '-r[specify rows per strip]:rows per strip' \ - '-t[set threshold for dithering]:dither threshold value' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-f+[specify fill order]:fill order:(lsb2msb msb2lsb)' \ + '-r+[specify rows per strip]:rows per strip' \ + '-t+[set threshold for dithering]:dither threshold value [128]' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffdump) _arguments \ - '-o[set initial TIFF directory (file offset)]:file offset:' \ + '-o+[set initial TIFF directory (file offset)]:file offset' \ '-h[print numbers in hexadecimal]' \ + '-m+[change number of indirect items printed]:items [24]' \ '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffinfo) - _arguments \ + _arguments -s \ '-c[display colormap and color/gray response curves]' \ '-D[read and decompress data]' \ '-d[print decompressed data]' \ '-j[display JPEG-related tags]' \ - '-o[set initial TIFF directory (file offset)]:file offset' \ + '-o+[set initial TIFF directory (file offset)]:file offset' \ + '-r[read/display raw image data instead of decoded data]' \ '-s[display offsets and byte counts for all data strips]' \ '-i[ignore read errors]' \ - '-f[force fill order]:fill order:(lsb2msb msb2lsb)' \ + '-f+[force fill order]:fill order:(lsb2msb msb2lsb)' \ '-w[display raw data in words]' \ + '-z[enable strip chopping]' \ '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffmedian) _arguments -C \ - '-r[specify rows per strip]:rows per strip' \ - '-C[specify number of colormap entries]:number of colormap entries' \ - '-c[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ + '-C+[specify number of colormap entries]:number of colormap entries' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ '-f[use Floyd-Steinberg dithering]' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 @@ -117,52 +173,57 @@ tiffsplit) ':output file prefix' && ret=0 ;; fax2tiff) - _arguments \ + _arguments -s \ + '!(-1 -2 -3 -4)-'{1,3} \ '(-1 -4)-2[input is Group 3, 2d encoded]' \ - '(-2 -4)-1[input is Group 3, 1d encoded]' \ - '(-1 -2)-4[input is Group 4 encoded]' \ - '(-W)-B[0 in input is black]' \ - '(-B)-W[0 in input is white]' \ - '(-M)-L[input is lsb-to-msb]' \ - '(-L)-M[input is msb-to-lsb]' \ - '-R[specify resolution]:resolution (lines per inch)' \ - '-o[specify output file]:output file:_files -g "*.(#i)tif(|f)(-.)"' \ - '(-f)-c[generate `classic'"'"' TIFF format]' \ - '(-c)-f[generate TIFF Class F format]' \ + '(-1 -2 -A)-4[input is Group 4 encoded]' \ + '-U[input is uncompressed]' \ + '(-4)-A[input is EOL-aligned]' \ + '-B[0 in input means black]' \ + '-M[input is msb-to-lsb]' \ + '-R+[specify resolution]:resolution (lines per inch) [196]' \ + '-X+[specify input data width]:width [1728]' \ + '-o+[specify output file]:output file:_files -g "*.(#i)tif(|f)(-.)"' \ + '(-5 -p)-8[generate G4-encoded output]' \ + '-u[generate uncompressed output]' \ + '(-8)-5[generate 1d encoded output]' \ + "(-8)-p[don't align EOL codes]" \ + '-c[generate `classic'"'"' TIFF format]' \ '-m[output in msb-to-lsb order]' \ - "-p[don't align EOL codes]" \ - '-s[duplicate all rows]' \ + '-r+[specify rows per strip]:rows per strip' \ + '-s[stretch image by duplicating all rows]' \ '-v[verbose mode]' \ + '-z[generate LZW compressed output]' \ ':FAX input file:_files -g "*.(#i)(g[34]|fax)(-.)"' && ret=0 ;; gif2tiff) _arguments -C \ - '-r[specify rows per strip]:rows per strip' \ - '-c[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ ':input GIF file:_files -g "*.(#i)gif(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; ppm2tiff) _arguments -C \ - '-r[specify rows per strip]:rows per strip' \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-R[specify resolution]:resolution:' \ + '-r+[specify rows per strip]:rows per strip' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-R+[specify resolution]:resolution (dots/inch)' \ ':input GIF file:_files -g "*.(#i)ppm(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; ras2tiff) _arguments -C \ - '-r[specify rows per strip]:rows per strip' \ - '-c[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ ':input raster image file:_files -g "*.(#i)ras(|t)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; pal2rgb) _arguments -C \ - '-C[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \ - '-p[set sample packing]:sample packing:(contig separate)' \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-r[specify rows per strip]:rows per strip' \ + '-C+[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \ + '-p+[set sample packing]:sample packing:(contig separate)' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; @@ -179,7 +240,7 @@ if [[ -n "$state" ]]; then case "$scheme" in g3) - _values -s : 'FAX Group 3 options' \ + _values -s : 'FAX Group 3 option' \ '(2d)1d[use 1D-encoding]' \ '(1d)2d[use 2D-encoding]' \ 'fill[byte-align EOL codes]' && ret=0 @@ -188,8 +249,8 @@ if [[ -n "$state" ]]; then _message -e values "compression quality (0-100), or \`r' (output RGB)" ret=0 ;; - lzw|zip) - _values 'LZW and deflate options' \ + lzw|lzma|zip) + _values 'LZW and deflate option' \ '1[without differencing]' \ '2[with differencing]' && ret=0 ;; @@ -198,8 +259,8 @@ if [[ -n "$state" ]]; then _tags values while _tags; do while _next_label values expl 'compression scheme'; do - compadd "$expl[@]" - none g4 packbits && ret=0 - compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0 + compadd "$expl[@]" - none jbig g4 packbits sgilog && ret=0 + compadd "$expl[@]" -qS: - lzw zip lzma jpeg g3 && ret=0 done (( ret )) || return 0 done diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index 730959e84..ae3446a08 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -235,6 +235,7 @@ _tmux-choose-client() { _tmux-choose-tree() { [[ -n ${tmux_describe} ]] && print "put a window into tree choice mode" && return _arguments -s \ + '-G[include all sessions in any session groups in the tree rather than only the first]' \ '-N[start without the preview]' \ '-F+[specify format for each list item]:format:__tmux-formats' \ '-f+[filter items]:filter format:__tmux-formats' \ @@ -562,6 +563,8 @@ _tmux-paste-buffer() { _tmux-pipe-pane() { [[ -n ${tmux_describe} ]] && print "pipe output from a pane to a shell command" && return _arguments -s -A "-*" -S \ + '-I[write stdout from command to the pane as if it were typed]' \ + '-O[pipe output from the pane to the command (default unless -I used)]' \ '-o[only open a pipe if none is currently opened]' \ '-t+[specify target pane]:pane:__tmux-panes' \ ':shell command:_cmdstring' @@ -658,12 +661,13 @@ _tmux-save-buffer() { } _tmux-select-layout() { - [[ -n ${tmux_describe} ]] && print "choose a layout for a window" && return + [[ -n ${tmux_describe} ]] && print "choose a layout for a pane" && return _arguments -s -A "-*" -S \ + '-E[spread the current pane and any panes next to it out evenly]' \ '-n[behave like next-layout]' \ '-o[revert to previous layout]' \ '-p[behave like previous-layout]' \ - '-t+[specify a target window]:target window:__tmux-windows' \ + '-t+[specify a target pane]:target pane:__tmux-panes' \ ':layout:(even-horizontal even-vertical main-horizontal main-vertical tiled)' } diff --git a/Completion/Unix/Command/_uptime b/Completion/Unix/Command/_uptime new file mode 100644 index 000000000..58b4d991b --- /dev/null +++ b/Completion/Unix/Command/_uptime @@ -0,0 +1,26 @@ +#compdef uptime guptime + +local variant + +_pick_variant -r variant procps=procps gnu='Free Soft' unix --version + +case $variant in + procps) + _arguments -s -S : \ + '(: -)'{-h,--help}'[display help information]' \ + '(: -)'{-V,--version}'[display version information]' \ + + '(excl)' \ + {-p,--pretty}'[display uptime in pretty format]' \ + {-s,--since}'[display date/time of system boot]' + return + ;; + gnu) + _arguments -S : \ + '(: -)--help[display help information]' \ + '(: -)--version[display version information]' \ + '1:utmp/wtmp file:_files' + return + ;; + # *BSD, Darwin, Solaris, BusyBox + *) _message 'no more arguments'; return 1 ;; +esac diff --git a/Completion/Unix/Command/_user_admin b/Completion/Unix/Command/_user_admin index 7eeec7e9b..fe28c13f5 100644 --- a/Completion/Unix/Command/_user_admin +++ b/Completion/Unix/Command/_user_admin @@ -150,6 +150,7 @@ case ${service%???}:${(M)service%???}:$OSTYPE in *:*:linux*) args+=( '(-R --root)'{-R,--root=}'[specify directory to chroot into]:directory:_directories' + '(-P --prefix)'{-P,--prefix=}"[specify root directory to apply changes in but don't chroot]:directory:_directories" '(-D -U -L -p --password)'{-p+,--password=}'[specify encrypted password]:encrypted password' '(-)'{-h,--help}'[display help information]' ) diff --git a/Completion/Unix/Command/_vim b/Completion/Unix/Command/_vim index 042974338..8853fac30 100644 --- a/Completion/Unix/Command/_vim +++ b/Completion/Unix/Command/_vim @@ -41,7 +41,7 @@ arguments=( '-T[set terminal type]:::_terminals' '--not-a-term[skip warning for input/output not being a terminal]' '--ttyfail[exit if input or output is not a terminal]' - '-u[use given vimrc file instead of default .vimrc]::rc file:_files' + '-u[use given vimrc file instead of default .vimrc]:config:->config' "--noplugin[don't load plugin scripts]" '-o-[number of windows to open (default: one for each file)]::window count: ' '-O-[number of windows to vertically split open (default is one for each file)]::window count: ' @@ -71,7 +71,6 @@ arguments=( '--startuptime[write startup timing messages to given file]:log file:_files' '--socketid[run GVIM in another window]' '-i[use specified viminfo file]:viminfo file [~/.viminfo]:_files' - '--clean[defaults, no plugins, no viminfo]' '(- *)'{-h,--help}'[print help and exit]' '(- *)--version[print version information and exit]' '(* -q)-t[edit file where tag is defined]:tag:_complete_tag' @@ -90,7 +89,7 @@ arguments=( '--role[set unique role to identify main window]:role' '--socketid[open vim inside another GTK widget]:xid' '--echo-wid[echo window ID on stdout]' - '-U[use given gvimrc file instead of default .gvimrc]::rc file:_files' + '-U[use given gvimrc file instead of default .gvimrc]:gui config:->configgui' ) _arguments -C -S $arguments && ret=0 @@ -120,6 +119,23 @@ elif [[ $state = verbosity ]]; then fi (( ret )) || break done +elif [[ "$state" = config* ]]; then + _tags special files + local names=( + "NONE:'skip initialization from files and environment variables'" + "NORC:'same as NONE, but load plugins'" + ) + # gvim only supports -U NONE to skip GUI initialization. + [[ $state != configgui || $service != *g* ]] && names+=( + "DEFAULTS:'same as NONE, but loads defaults.vim'" + ) + while _tags; do + _requested special && _describe -V 'special' "(${(F)names})" && ret=0 + if _requested files expl 'rc file'; then + _files "$expl[@]" && ret=0 + fi + (( ret )) || break + done fi return ret diff --git a/Completion/Unix/Command/_vorbis b/Completion/Unix/Command/_vorbis index cb3e3f9d8..6c94469f9 100644 --- a/Completion/Unix/Command/_vorbis +++ b/Completion/Unix/Command/_vorbis @@ -1,90 +1,148 @@ -#compdef oggenc ogg123 ogginfo oggdec +#compdef oggenc ogg123 ogginfo oggdec vorbiscomment -local expl ret=1 +local curcontext="$curcontext" ret=1 +local -a alts expl state line suf case $service in oggenc) - _arguments -s \ - '(- *)'{-h,--help}'[show help]' \ - '(- *)'{-v,--version}'[display version information]' \ + _arguments -C -s -S \ + '(-Q --quiet)'{-Q,--quiet}'[produce no output to stderr]' \ + '(- *)'{-h,--help}'[display usage information]' \ + '(- *)'{-V,--version}'[display version information]' \ + '(-k --skeleton)'{-k,--skeleton}'[add an Ogg Skeleton bitstream]' \ '(-r --raw)'{-r,--raw}'[assume input data is raw, little-endian with no header information]' \ - '(-B --raw-bits)'{-B+,--raw-bits=}'[set raw mode input sample size in bits]:sample size:(8 16)' \ - '(-C --raw-chan)'{-C+,--raw-chan=}'[set raw mode input number of channels]:number of channels' \ - '(-R --raw-rate)'{-R+,--raw-rate=}'[set raw mode input sample rate]:sample rate:(44100 48000)' \ - '--raw-endianness[set raw mode endianness]:endianness:((0\:big\ endian 1\:little\ endian))' \ - '(-Q --quiet)'{-Q,--quiet}'[quiet mode]' \ + '(-B --raw-bits)'{-B+,--raw-bits=}'[set raw mode input sample size in bits]:sample size [16]:(8 16)' \ + '(-C --raw-chan)'{-C+,--raw-chan=}'[set raw mode input number of channels]:number of channels [2]' \ + '(-R --raw-rate)'{-R+,--raw-rate=}'[set raw mode input sample rate]:sample rate [44100]:(44100 48000)' \ + '--raw-endianness=[set raw mode endianness]:endianness [0]:((0\:big\ endian 1\:little\ endian))' \ '(-b --bitrate)'{-b+,--bitrate=}'[set encoding to the bitrate closest to that specified]:bitrate (kb/s)' \ + '--managed[enable the bitrate management engine]' \ '(-m --min-bitrate)'{-m+,--min-bitrate=}'[set minimum bitrate]:bitrate (kb/s)' \ '(-M --max-bitrate)'{-M+,--max-bitrate=}'[set maximum bitrate]:bitrate (kb/s)' \ - '--managed[turn off the normal VBR encoding]' \ + '*--advanced-encode-option=:option name:_values option + "lowpass_frequency[set the lowpass frequency]\:frequency (kHz)" + "impulse_noisetune[set a noise floor bias]\:bias (-15..0)" + "bitrate_hard_max[set the allowed bitrate maximum for the encoded file]\:bitrate (kb/s)" + "bitrate_hard_min[set the allowed bitrate minimum for the encoded file]\:bitrate (kb/s)" + "bit_reservoir_bits[set the total size of the bit reservoir]\:bits" + "bit_reservoir_bias[set the behavior bias of the bit reservoir]\:bias (0..1)" + "bitrate_average[set the average bitrate for the file]\:bitrate (kb/s)" + "bitrate_average_damping[set the reaction time for the average bitrate tracker]\:time (seconds)" + "disable_coupling[disable use of channel coupling for multichannel encoding]"' \ '(-q --quality)'{-q+,--quality=}'[set encoding quality]:quality:(0 1 2 3 4 5 6 7 8 9 10)' \ - '--resample[resample input to the given sample rate before encoding]:sample rate (Hz)' \ + '--resample=[resample input to the given sample rate before encoding]:sample rate (Hz)' \ '--downmix[down mix input from stereo to mono]' \ - '--advanced-encode-option:option name:_values option "bitrate_average_window[set the managed bitrate window]\:number (seconds)" "lowpass_frequency[set the lowpass frequency]\:frequency (kHz)"' \ - '(-s --serial)'{-s+,--serial=}'[force a specific serial number in the output stream]' \ + '--scale=[set input scaling factor]:scaling factor' \ + '(-s --serial)'{-s+,--serial=}'[force a specific serial number in the output stream]:serial number' \ "--discard-comments[don't copy comments from FLAC file to output Ogg Vorbis file]" \ + '--ignorelength[ignore the datalength in Wave headers]' \ '(-o --output)'{-o+,--output=}'[write the Ogg Vorbis stream to output_file]:files:->oggfiles' \ '(-n --names)'{-n+,--names=}'[specify pattern for producing filenames]:string' \ '(-X --name-remove)'{-X+,--name-remove=}'[remove specified characters from output filenames]:characters' \ '(-P --name-replace)'{-P+,--name-replace=}'[specify replacement characters for those removed]:characters' \ - '(-c --comment)'{-c+,--comment}'[add the string comment as an extra comment]:comment' \ - '(-a --artist)'{-a+,--artist}'[set the artist comment field in the comments to artist]:artist' \ - '(-G --genre)'{-G+,--genre}'[set the genre comment field in the comments to genre]:genre' \ - '(-d --date)'{-d+,--date}'[set the date comment field to the given value]:date' \ - '(-N --tracknum)'{-N+,--tracknum}'[set the track number comment field to the given value]:track number' \ - '(-t --title)'{-t+,--title}'[set the track title comment field to title]:title' \ - '(-l --album)'{-l+,--album}'[set the album comment field to album]' \ + '--utf8[interpret command-line parameters as already being UTF-8 encoded]' \ + \*{-c+,--comment=}'[add the string comment as an extra comment]:comment' \ + \*{-d+,--date=}'[set the date comment field to the given value]:date' \ + \*{-N+,--tracknum=}'[set the track number comment field to the given value]:track number' \ + \*{-t+,--title=}'[set the track title comment field to title]:title' \ + \*{-l+,--album=}'[set the album comment field to album]:album' \ + \*{-a+,--artist=}'[set the artist comment field in the comments to artist]:artist' \ + \*{-G+,--genre=}'[set the genre comment field in the comments to genre]:genre' \ + \*{-L+,--lyrics=}'[include lyrics from specified file]:lyrics file:_files -g "*.(srt|lrc)(-.)"' \ + \*{-Y+,--lyrics-language=}'[specify language for the lyrics]:language' \ '*:input file:_files -g "(#i)*.(flac|wav|aiff)(-.)"' && ret=0 ;; ogg123) - _arguments -C -s \ - '(- *)'{-h,--help}'[show help]' \ - '(- *)'{-V,--version}'[display version information]' \ - \*{-d+,--device}'[output device]:device:((null\:discard\ all\ data oss\:open\ sound\ system sun\:sun\ audio alsa\:advanced\ linux\ sound\ architecture irix\:IRIX\ audio arts\:aRts\ sound\ daemon esd\:enlightened\ sound\ daemon au\:sun\ audio\ file raw\:raw\ sample wav\:wav\ file))' \ + _arguments -C -s -S \ + \*{-d+,--device=}'[output device]:device:(aixs alsa arts au esd irix macosx nas null oss pulse raw roar sndio sun wav wmm)' \ \*{-f+,--files=}'[output filename for a previously specified file device]:output filename:_files -g "(#i)*.(wav|au|raw)(-.)"' \ - '(-k --skip)'{-k+,--skip}"[skip the first 'n' seconds (or to hh:mm:ss)]:seconds" \ - '(-K --end)'{-K+,--end}"[end at 'n' seconds (or hh:mm:ss)]:seconds" \ - '(-b --buffer)'{-b+,--buffer}'[size of input buffer]:kilobytes' \ - '(-p --prebuffer)'{-p+,--prebuffer}'[prebuffer percentage]:percent' \ - '(-q --quiet)*'{-v,--verbose}'[increase verbosity]' \ - '(-q --quiet -v --verbose)'{--quiet,-q}'[quiet mode]' \ - '(-x --nth)'{-x+,--nth}'[block decode intervall]:number' \ - '(-y --ntimes)'{-y+,--ntimes}'[block repeat count]:number' \ - '(-z --shuffle)'{-z,--shuffle}'[shuffle play]' \ - '(-l --delay)'{-l+,--delay=}'[set delay between two SIGINTs to quit]:delay (ms)' \ - '(-@ --list)'{-@+,--list}'[play all of the files from a playlist]:playlist:_files' \ - '--audio-buffer=[size of output audio buffer]:kilobytes' \ + '--audio-buffer=[specify size of output audio buffer]:size (kilobytes)' \ \*{-o,--device-option=}'[assign device option values]:device option:->devopts' \ - '*:sound file or directory:_files -g "(#i)*.(ogg|flac|spx)"' && ret=0 + '(-@ --list)'{-@+,--list=}'[play all of the files from a playlist]:playlist:_files' \ + '(-r --repeat)'{-r,--repeat}'[repeat playlist indefinitely]' \ + '(-R --remote)'{-R,--remote}'[use remote control interface]' \ + '(-z --shuffle -Z --random)'{-z,--shuffle}'[shuffle list of files before playing]' \ + '(-Z --random -z --shuffle -r --repeat)'{-Z,--random}'[play files randomly until interrupted]' \ + '(-b --buffer)'{-b+,--buffer=}'[specify size of input buffer (HTTP only)]:size (kilobytes)' \ + '(-p --prebuffer)'{-p+,--prebuffer=}'[delay playback until proportion of buffer filled (HTTP only)]:percent' \ + '(-k --skip)'{-k+,--skip=}"[skip up to specified time]:start time ([[hh\:]mm\:]ss[.d])" \ + '(-K --end)'{-K+,--end=}"[end after specified time]:end time ([[hh\:]mm\:]ss[.d])" \ + '(-x --nth)'{-x+,--nth=}"[play every 'n'th block]:number"\ + '(-y --ntimes)'{-y+,--ntimes=}"[repeat every 'n'th block]:number" \ + '(-l --delay)'{-l+,--delay=}'[set delay between two SIGINTs to quit]:delay (ms)' \ + '(- *)'{-h,--help}'[display usage information]' \ + '(-q --quiet -v --verbose)'{--quiet,-q}'[quiet mode]' \ + '(-q --quiet)*'{-v,--verbose}'[increase verbosity]' \ + '(- *)'{-V,--version}'[display version information]' \ + \*{-c-,--config=-}'[specify config options]: :_values option + "default_device\:device" + "shuffle\:value\:(0 1)" + "repeat\:value\:(0 1)"' \ + '*:sound file or directory:->urls-or-files' && ret=0 ;; ogginfo) - _arguments \ - '(- *)-h[show a help and usage message]' \ + _arguments -S \ + '(- *)-h[display usage information]' \ + '(- *)-V[display version information]' \ '(-)*-q[quiet mode]' \ '(-)-v[verbose mode]' \ - '*:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' && ret=0 + '(-h)*:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' && ret=0 ;; oggdec) - _arguments -s \ + _arguments -s -S \ '(-Q --quiet)'{-Q,--quiet}'[quiet mode]' \ - '(- *)'{-h,--help}'[print help information]' \ - '(- *)'{-v,--version}'[display version information]' \ + '(- *)'{-h,--help}'[display usage information]' \ + '(- *)'{-V,--version}'[display version information]' \ '(-b --bits)'{-b+,--bits=}'[bits per sample]:bits per sample:(8 16)' \ - '(-e --endian)'{-e+,--endian=}'[set endianness for 16-bit output]:endianness:((0\:\(default\)\ little-endian\ \(Intel\ byte\ order\) 1\:big-endian\ \(sane\ byte\ order\)))' \ - '(-R --raw)'{-R+,--raw=}'[output in raw format]' \ + '(-e --endianness)'{-e+,--endianness=}'[set endianness for 16-bit output]:endianness [0]:((0\:little-endian\ \(Intel\ byte\ order\) 1\:big-endian\ \(sane\ byte\ order\)))' \ + '(-s --sign)'{-s+,--sign=}'[set signedness for output]:signedness [1]:((0\:unsigned 1\:signed))' \ + '(-R --raw)'{-R,--raw}'[output in raw format]' \ '(-o --output)'{-o+,--output=}'[write output to specified filename]:output filename:_files' \ - '(-s --sign)'{-s+,--sign=}'[set signedness for output]:signedness:((0\:unsigned 1\:signed\ \(default\)))' \ '*:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' && ret=0 ;; + vorbiscomment) + _arguments -s -S \ + '(-l --list)*'{-t+,--tag=}'[specify a comment tag on the commandline]:tag=value' \ + '(-c --commentfile)'{-c+,--commentfile=}'[specify comment file]:file:_files' \ + '(-R --raw)'{-R,--raw}'[read and write comments in UTF-8]' \ + '(-e --escapes)'{-e,--escapes}'[use \\n-style escapes to allow multiline comments]' \ + '1:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' \ + '(-l --list)2:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' \ + + '(actions)' \ + '(2 -t --tag)'{-l,--list}'[list the comments (default)]' \ + {-a,--append}'[append comments]' \ + {-w,--write}'[write comments, replacing the existing ones]' \ + '(-)'{-h,--help}'[display usage information]' \ + '(-)'{-V,--version}'[display version information]' && ret=0 + ;; esac -if [[ $state = devopts ]]; then - if compset -P '*:'; then - _message -e value value - else - _wanted devopts expl 'device option' \ - compadd -S : - dsp dev card buf_size host byteorder && return - fi +if [[ -n $state ]]; then + case $state in + urls-or-files) + if [[ -prefix 1 (f|ht)tp(|s):// ]]; then + alts=( 'urls:URL of sound file:_urls -f -g "*.(#i)(ogg|flax|spx)(-.)"' ) + else + alts=( 'urls:URL of sound file:compadd -S "" ftp:// http:// https://' ) + fi + _alternative \ + 'files:sound file or directory:_files -g "(#i)*.(ogg|flac|spx)"' \ + $alts && ret=0 + ;; + devopts) + if compset -P 1 '*:'; then + _message -e value value + else + _description device-options expl 'device option' + if ! compset -S ':*'; then + compadd "$expl[@]" - debug verbose quiet && ret=0 + suf=( -qS : ) + fi + compadd $suf "$expl[@]" - matrix dev buffer_time period_time use_mmap \ + multi host buf_size dsp server sink byteorder id && ret=0 + fi + ;; + esac fi return ret diff --git a/Completion/Unix/Command/_vorbiscomment b/Completion/Unix/Command/_vorbiscomment deleted file mode 100644 index bd7459e04..000000000 --- a/Completion/Unix/Command/_vorbiscomment +++ /dev/null @@ -1,18 +0,0 @@ -#compdef vorbiscomment - -#Written by Jesse Weinstein <jessw@netwood.net>, Wed Jul 19 15:31:11 2006 -#Version 0.9 - could handle -t option slightly better -#Released under the MIT license (or any compatible free-content license) -#i.e. do whatever you like with it, but credit me. - -_arguments \ - '-h[help]' \ - '-q[quiet]' \ - '(-a -w -q -c -t 2)-l[list comments]' \ - '(-l)-a[append comments]' \ - '(-l)-w[overwrite comments]' \ - '(-l -c)-t[tag and value]:: ' \ - '(-l -t)-c[tag file]::_files' \ - '1:OGG file:_files -g "*.ogg(-.)"' \ - '(-l)2:output OGG file:_files -g "*.ogg(-.)"' \ - && return 0 diff --git a/Completion/Unix/Command/_vpnc b/Completion/Unix/Command/_vpnc new file mode 100644 index 000000000..9c4f4d41b --- /dev/null +++ b/Completion/Unix/Command/_vpnc @@ -0,0 +1,54 @@ +#compdef vpnc vpnc-connect + +local ign + +(( $#words > 2 )) && ign='!' +_arguments \ + "${ign}(- : *)--version[display version information]" \ + "${ign}(- : *)--"{,long-}'help[display usage information]' \ + '--gateway=[specify IP/name of IPSec gateway]: :_hosts' \ + '--id=[specify group name]: :_groups' \ + '--username=[specify username]: :_users' \ + '--domain=[specify domain name for authentication]: :_domains' \ + '--xauth-inter[enable interactive extended authentication]' \ + '--vendor=[specify IPSec gateway vendor]:vendor:(cisco netscreen)' \ + '--natt-mode=[specify NAT-Traversal method to use]:NAT-traversal method [natt]:(( + natt\:NAT-T\ as\ defined\ in\ RFC3947 + none\:disable\ use\ of\ any\ NAT-T\ method + force-natt\:always\ use\ NAT-T\ encapsulation\ even\ without\ presence\ of\ a\ NAT\ device + cisco-udp\:Cisco\ proprietary\ UDP\ encapsulation,\ commonly\ over\ port\ 10000 + ))' \ + '--script=[specify command executed using system() to configure the interface, routing and so on]: : _command_names -e' \ + '--dh=[specify the IKE DH group]:group:(dh1 dh2 dh5)' \ + '--pfs=[specify Diffie-Hellman group to use for PFS]:group:(nopfs dh1 dh2 dh5 server)' \ + '--enable-1des[enable weak single DES encryption]' \ + '--enable-no-encryption[use no encryption for data traffic (key exchange still encrypted)]' \ + '--application-version=[specify application version to report]:application version' \ + '--ifname=[specify visible name of the TUN/TAP interface]:interface name' \ + '--ifmode=[specify mode of TUN/TAP interface]:mode [tun]:(tun tap)' \ + '--ifmtu=[set MTU for TUN/TAP device]:MTU (0-65535) [0 - automatic]' \ + "--debug[show verbose debug messages]:debug information:(( + 0\:don\'t\ print\ debug\ information + 1\:print\ minimal\ debug\ information + 2\:show\ state\ machine\ and\ packet/payload\ type\ information + 3\:dump\ everything\ excluding\ authentication\ data + 99\:dump\ everything\ including\ authentication\ data\ \(e.g.\ passwords\) + ))" \ + "--no-detach[don't detach from the console after login]" \ + '--pid-file=[store the pid of background process in specified file]:pid file:_files' \ + '--local-addr=[specify local IP to use for ISAKMP/ESP/...]: :_hosts' \ + '--local-port=[specify local ISAKMP port number to use]:ISAKMP port number (0-65535) [500]' \ + '--udp-port=[specify local UDP port number to use]:udp port (0-65535) [10000]' \ + '--dpd-idle=[send DPD packet after not receiving anything for specified time]:timeout (seconds) [600]' \ + "--non-inter[don't ask anything, exit on missing options]" \ + '--auth-mode=[specify authentication mode]:authentication mode [psk]:(( + psk\:pre-shared\ key + cert\:server\ +\ client\ certificate + hybrid\:server\ certificate\ +\ xauth + ))' \ + '--ca-file=[specify CA-PEM-File]:CA-PEM file:_files -g "*.pem(-.)"' \ + '--ca-dir=[specify trusted CA-Directory]:CA directory:_files -/' \ + '--target-network=[specify target network]:network/netmask' \ + '--password-helper=[specify password helper executable]: : _command_names -e' \ + '--print-config[print configuration in form that can be used as vpnc.conf]' \ + '*:configuration [default]:compadd - /etc/vpnc/*.conf(N:t:r)' diff --git a/Completion/Unix/Command/_webbrowser b/Completion/Unix/Command/_webbrowser index 4192aff54..e4f5fe092 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 -_alternative 'files:file:_files' 'urls:URL:_urls' +_alternative 'files: :_files' 'urls: :_urls' diff --git a/Completion/Unix/Command/_wget b/Completion/Unix/Command/_wget index 1a7e2d0a3..2a4e722d8 100644 --- a/Completion/Unix/Command/_wget +++ b/Completion/Unix/Command/_wget @@ -22,6 +22,7 @@ _arguments -C -s \ '(--config)--no-config' '--rejected-log=:file:_files' \ '(--tries -t)'{--tries=,-t+}'[set number of retries]:number of retries' \ '--retry-connrefused[retry even if connection is refused]' \ + '--retry-on-http-error=[specify list of HTTP errors to retry]:http error' \ '(--output-document -O)'{--output-document=,-O+}'[specify file to write documents to]:output file:_files' \ '(--continue -c)'{--continue,-c}'[continue getting an existing file]' \ '--start-pos=:offset' '--show-progress' \ @@ -38,8 +39,7 @@ _arguments -C -s \ '(--wait -w)'{--wait=,-w+}'[specify wait between retrievals]:time (seconds)' \ '(--random-wait)--waitretry=:time (seconds)' \ '(--waitretry)--random-wait[random wait time between retrievals]' \ - '(--proxy -Y --no-proxy)'{--proxy=,-Y+}'[explicitly turn on proxy]' \ - '(--proxy -Y --no-proxy)--no-proxy[explicitly turn off proxy]' \ + '--no-proxy[explicitly turn off proxy]' \ '(--quota -Q)'{--quota=,-Q+}'[set retrieval quota]:number' \ '--bind-address=[specify address to bind to (hostname or IP)]:bind address:_bind_addresses' \ '--limit-rate=[specify limit to download rate]:download rate limit' \ @@ -48,7 +48,7 @@ _arguments -C -s \ '--ignore-case[ignore case when matching files/directories]' \ '(-4 --inet4-only -6 --inet6-only)'{-4,--inet4-only}'[connect only to IPv4 addresses]' \ '(-4 --inet4-only -6 --inet6-only)'{-6,--inet6-only}'[connect only to IPv6 addresses]' \ - '--prefer-family[connect first to addresses of specified family]:address family:(IPv6 IPv4 none)' \ + '--prefer-family=[connect first to addresses of specified family]:address family:(IPv6 IPv4 none)' \ '(--http-user --ftp-user)--user[set both ftp and http user]:user' \ '(--http-password --ftp-password)--password[set both ftp and http password]:password' \ '(--password --http-password --ftp-password)--ask-password:[prompt for passwords]' \ @@ -67,7 +67,7 @@ _arguments -C -s \ '(--user)--http-user=:user' \ '(--password --ask-password)--http-password=:password' \ '--no-cache[disallow server-cached data]' \ - '--default-page=[specify default page name, normally index.html]' \ + '--default-page=[specify default page name, normally index.html]:default page [index.html]' \ '(--adjust-extension -E)'{--adjust-extension,-E}'[save all HTML/CSS documents with proper extensions]' \ "--ignore-length[ignore \`Content-Length' header field]" \ '*--header=[send a custom HTTP header]:header:->header' \ @@ -93,7 +93,7 @@ _arguments -C -s \ "--auth-no-challenge[send basic HTTP authentication without first waiting for server's challenge]" \ '--secure-protocol=[choose secure protocol]:protocol:(SSLv2 SSLv3 TLSv1 TLSv1_1 TLSv1_2 PFS)' \ --https-only \ - "--no-check-certificate=[don't check the server certificate]" \ + "--no-check-certificate[don't check the server certificate]" \ '--certificate=[specify client certificate]:client certificate file:_files' \ '--certificate-type=[specify client certificate type]:certificate type:(PEM DER)' \ '--private-key=[specify private key file]:key file:_files' \ @@ -104,6 +104,7 @@ _arguments -C -s \ '--pinnedpubkey=:file:_files' \ '--random-file[specify file with random data for seeding generator]:file:_files' \ '--egd-file=[specify filename of EGD socket]:file:_files' \ + '--ciphers=[set the priority string (GnuTLS) or cipher list string (OpenSSL) directly]:string' \ '--no-hsts[disable HSTS]' \ '--hsts-file[specify path of HSTS database]:file:_files' \ '(--user)--ftp-user=:user' \ diff --git a/Completion/Unix/Command/_xxd b/Completion/Unix/Command/_xxd index 1b1613a64..0034be519 100644 --- a/Completion/Unix/Command/_xxd +++ b/Completion/Unix/Command/_xxd @@ -26,7 +26,7 @@ arguments=( '( -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,-endian}'[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 )'{-p,-postscript,-plain,-ps}'[read or write a plain hexdump (no line numbers or ASCII rendering)]' + '(-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 -E -EBCDIC -i -include -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]' @@ -34,7 +34,7 @@ arguments=( '(- :)'{-h,-help}'[display usage message]' '(- :)'{-v,-version}'[show program version]' '*'{-a,-autoskip}"[a single '*' replaces runs of NUL (toggleable)]" - + '(-C -capitalize)'{-C,-capitalize}'[capitalize variable names in C include file style]' {-c+,-cols}'[specify number of octets per line]: :_guard "[0-9a-fA-Fx]#" "number of octets per line"' {-g+,-groupsize}'[specify the number of octets per group]: :_guard "[0-9]#" "number of octets per group"' {-l+,-len}'[specify number of octets to output]: :_guard "[0-9]#" "number of octets to output"' diff --git a/Completion/Unix/Type/_bind_addresses b/Completion/Unix/Type/_bind_addresses index 3460b7959..d12727800 100644 --- a/Completion/Unix/Type/_bind_addresses +++ b/Completion/Unix/Type/_bind_addresses @@ -1,15 +1,50 @@ #autoload -local expl - -case $OSTYPE in - aix*) _hosts "$@" ;; - darwin*|freebsd*|dragonfly*) _hosts "$@" ;; - irix*) _hosts "$@" ;; - # Couldn't find anything special for linux except for /proc/net/dev - # Is there any proc file which gives the formatted ip? - linux*) ;& - *) - _wanted bind-addresses expl 'bind address' compadd "$@" - \ - ${${${(M)${(f)"$(ifconfig -a)"}:#*addr:*}##*addr:( |)}%%(/| )*} -esac +# Complete locally bound IP addresses +# +# Options: +# -0 Return also `0.0.0.0` and `::` +# -4 Return only IPv4 addresses +# -6 Return only IPv6 addresses +# -b Return IPv6 addresses in brackets (for use with port numbers) +# -h Return also `localhost` +# -L Exclude loop-back addresses (`127.0.0.0/8` and `::1`) +# -K Exclude link-local addresses (`169.254.0.0/16` and `fe80::/10`) + +local MATCH MBEGIN MEND +local -a expl tmp cmd=( ifconfig -a ) +local -A opts + +zparseopts -A opts -D -E -- 0 4 6 b h L K + +# A lot of Linux systems have ifconfig, but this is probably safer (and it's +# parsed the same way) +[[ $OSTYPE == linux* ]] && (( $+commands[ip] )) && cmd=( ip addr show ) + +tmp=( ${(f)"$( _call_program bind-addresses $cmd )"} ) +tmp=( ${(@M)tmp##(|[[:space:]]##)inet(|6)(|:)[[:space:]]*} ) +tmp=( ${(@)tmp#*inet(|6)(|:)[[:space:]]##} ) +tmp=( ${(@)tmp%%[^0-9A-Fa-f:.]*} ) + +# The order of operations here is significant +(( $+opts[-0] )) && tmp+=( 0.0.0.0 :: ) + +if (( $+opts[-6] )); then + tmp=( ${(@M)tmp:#*:*} ) +elif (( $+opts[-4] )); then + tmp=( ${(@)tmp:#*:*} ) +fi + +(( $+opts[-L] )) && { + tmp=( ${(@)tmp:#127.*} ) + tmp=( ${(@)tmp:#[0:]##:1} ) +} +(( $+opts[-K] )) && { + tmp=( ${(@)tmp:#169.254.*} ) + tmp=( ${(@)tmp:#(#i)fe[89ab]?:*} ) +} + +(( $+opts[-b] )) && tmp=( ${(@)tmp/(#m)*:*/\[$MATCH\]} ) +(( $+opts[-h] )) && tmp+=( localhost ) + +_wanted bind-addresses expl 'bind address' compadd -a "$@" - tmp diff --git a/Completion/Unix/Type/_directories b/Completion/Unix/Type/_directories index 456af3b6c..438181eec 100644 --- a/Completion/Unix/Type/_directories +++ b/Completion/Unix/Type/_directories @@ -1,4 +1,4 @@ -#compdef rmdir grmdir zf_rmdir dircmp -P -value-,*path,-default- +#compdef zf_rmdir dircmp -P -value-,*path,-default- local expl diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files index 2b0c5580a..5df22ea46 100644 --- a/Completion/Unix/Type/_files +++ b/Completion/Unix/Type/_files @@ -121,7 +121,7 @@ for def in "$pats[@]"; do done fi else - _path_files "$expl[@]" -g "$pat" "$opts[@]" && ret=0 + _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0 fi done (( ret )) || break diff --git a/Completion/Unix/Type/_object_files b/Completion/Unix/Type/_object_files index 595265116..6b931372f 100644 --- a/Completion/Unix/Type/_object_files +++ b/Completion/Unix/Type/_object_files @@ -9,4 +9,4 @@ __object_file() { $REPLY = (core*|*.core) ]] } -_files -g '*(-.e,__object_file,)' +_files -g '*(-.e,__object_file,)' "$@" "${(@)expl}" diff --git a/Completion/Unix/Type/_pdf b/Completion/Unix/Type/_pdf index 5fda42a12..60cee84ee 100644 --- a/Completion/Unix/Type/_pdf +++ b/Completion/Unix/Type/_pdf @@ -1,4 +1,4 @@ -#compdef pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext pdfopt pdffonts kpdf apvlv epdfview mupdf +#compdef pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext pdfopt pdffonts kpdf apvlv epdfview local expl ext='' diff --git a/Completion/Unix/Type/_process_names b/Completion/Unix/Type/_process_names new file mode 100644 index 000000000..4f184ccb7 --- /dev/null +++ b/Completion/Unix/Type/_process_names @@ -0,0 +1,44 @@ +#autoload +# +# complete names of running processes +# +# options: +# -a: include all processes (owned by others, no tty, etc.) +# -t: use truncated process names (e.g., those in /proc/PID/stat) +# (only on Linux and BSDs) +# +# this name has been used in _killall and documented in zshcompsys(1) +local tagname='processes-names' +typeset -a expl opts names all truncate + +zparseopts -E -D 'a=all' 't=truncate' +(( $#all )) && opts=( -A ) + +local hyphen='-' +# on Linux, use BSD-style option to include processes on other ttys +[[ $OSTYPE == linux* ]] && hyphen='' + +case $OSTYPE in + (linux*|freebsd*|openbsd*|netbsd*) + if (( $#truncate )); then + if [[ $OSTYPE == netbsd* ]]; then + opts+=(-co args=) + else + opts+=(${hyphen}o comm=) + fi + names=( ${${(f)"$(_call_program $tagname ps $opts 2>/dev/null)"}#-} ) + else + opts+=(${hyphen}o args=) + names=( ${(f)"$(_call_program $tagname ps $opts 2>/dev/null )"} ) + names=( ${${${${${names:#\[*]}%% *}%:}#-}:t} + ${${${(M)names:#\[*]}#\[}%]} ) + fi + ;; + (*) + # ignore -t option + opts+=(-o comm=) + names=( ${${${(f)"$(_call_program $tagname ps $opts 2>/dev/null)"}#-}:t} ) + ;; +esac + +_wanted $tagname expl 'process name' compadd "$@" -F '(ps)' -a - names diff --git a/Completion/Unix/Type/_pspdf b/Completion/Unix/Type/_pspdf index 5bb8650b1..1df3f860c 100644 --- a/Completion/Unix/Type/_pspdf +++ b/Completion/Unix/Type/_pspdf @@ -1,4 +1,4 @@ -#compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv pstoedit pstotgif zathura +#compdef gsbj gsdj gsdj500 gslj gslp gsnd ps2ascii ghostview mgv pstoedit pstotgif local expl ext diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files index a5fce9afd..267715a51 100644 --- a/Completion/Unix/Type/_remote_files +++ b/Completion/Unix/Type/_remote_files @@ -75,9 +75,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then remdispf=( ${(M)remdispf:#${~glob[2]}} ) fi - _tags files + _tags remote-files while _tags; do - while _next_label files expl ${suf:-remote directory}; do + while _next_label remote-files expl ${suf:-remote directory}; do [[ -n $suf ]] && compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*=|]} && ret=0 compadd ${suf:+-S/} -r "/ \t\n\-" "$args[@]" "$expl[@]" -d remdispd \ diff --git a/Completion/Unix/Type/_signals b/Completion/Unix/Type/_signals index df9a2f339..ffb01eba0 100644 --- a/Completion/Unix/Type/_signals +++ b/Completion/Unix/Type/_signals @@ -36,7 +36,7 @@ if [[ -z "$minus" ]] || fi if [[ -n "$pre" && $PREFIX = ${minus}S* ]]; then - sigs=( "${minus}SIG${(@)^signals[first,last]}" ) + sigs=( "${minus}SIG${(@)^${(@)signals[first,last]:#<->}}" ) (( $#disp )) && tmp=( "$tmp[@]" "${(@)signals[first,last]}" ) else sigs=() diff --git a/Completion/Unix/Type/_sys_calls b/Completion/Unix/Type/_sys_calls index bd9b34f70..dadf2b1a4 100644 --- a/Completion/Unix/Type/_sys_calls +++ b/Completion/Unix/Type/_sys_calls @@ -12,7 +12,7 @@ local -au syscalls zparseopts -D -K -E a=all n=none [[ $OSTYPE = linux* ]] && ifile=/usr/include/bits/syscall.h -syscalls=( ${${${(M)${(f)"$(<$ifile)"}:#?define[[:blank:]]##SYS_*}#*[[:blank:]]SYS_}%%[[:blank:]]*} ) 2>/dev/null +syscalls=( ${${${(M)${(f)"$(<$ifile)"}:#\#[[:blank:]]#define[[:blank:]]##SYS_*}#*[[:blank:]]SYS_}%%[[:blank:]]*} ) 2>/dev/null [[ -n $all ]] && syscalls+=( all ) [[ -n $none ]] && syscalls+=( none ) diff --git a/Completion/Unix/Type/_ttys b/Completion/Unix/Type/_ttys index 5e5598570..3c40466cb 100644 --- a/Completion/Unix/Type/_ttys +++ b/Completion/Unix/Type/_ttys @@ -4,16 +4,22 @@ # # -d strip /dev/ prefix from matches # -D matches allowed with or without /dev/ prefix +# -o only complete those ttys to which processes are attached local -a ttys expl pre -local stripdev optdev +local stripdev optdev open -zparseopts -D -K -E d=stripdev D=optdev +zparseopts -D -K -E d=stripdev D=optdev o=open -ttys=( /dev/tty?*(N) /dev/pts/^ptmx(N) ) -ttys=( ${ttys#/dev/} ) +if [[ -n $open ]]; then + ttys=( ${(u)${${(f)"$(_call_program open-ttys ps -Ao tty=)"}:#\?*}%% *} ) + _description open-ttys expl 'open tty' +else + ttys=( /dev/tty?*(N) /dev/pts/^ptmx(N) ) + ttys=( ${ttys#/dev/} ) + _description ttys expl 'tty' +fi [[ -z $stripdev ]] && pre=( -p /dev/ ) -_description ttys expl 'tty' [[ -n $optdev ]] && compadd "$@" "$expl[@]" -M 'r:|/=* r:|=*' -a ttys && return compadd "$@" "$expl[@]" "$pre[@]" -M 'r:|/=* r:|=*' -a ttys diff --git a/Completion/X/Command/_code b/Completion/X/Command/_code index 089050e26..b725b2a17 100644 --- a/Completion/X/Command/_code +++ b/Completion/X/Command/_code @@ -24,12 +24,14 @@ arguments=( '(-s --status)'{-s,--status}'[print process usage and diagnostics information]' '(-p --performance)'{-p,--performance}'[start with the "Developer: Startup Performance" command enabled]' '--prof-startup[run CPU profiler during startup]' - '--disable-extensions[disable all installed extensions]' + \*--disable-extension'[disable specified installed extension]' + '(--disable-extension --disable-extensions)--disable-extensions[disable all installed extensions]' '--inspect-extensions[allow debugging and profiling of extensions]' '--inspect-brk-extensions[allow debugging and profiling of extensions with the extension host being paused after start]' '--disable-gpu[disable GPU hardware acceleration]' '--upload-logs[uploads logs from current session to a secure endpoint]:confirm:(iConfirmLogsUpload)' '--max-memory=[specify max memory size for a window]:size (Mbytes)' + '--folder-uri[open specified URI as a folder, if there is an extension contributing a FileSystemProvider for that URI]' '*:filename:_files' ) diff --git a/Completion/X/Command/_geany b/Completion/X/Command/_geany new file mode 100644 index 000000000..c6a9ae113 --- /dev/null +++ b/Completion/X/Command/_geany @@ -0,0 +1,30 @@ +#compdef geany + +local ign + +(( $#words > 2 )) && ign='!' +_arguments -s -S \ + "${ign}(- *)"{-h,--help}'[display usage information]' \ + "${ign}(- *)--help-all[display all options]" \ + "${ign}(- *)--help-gtk[display GTK+ Options]" \ + '--column=[set initial column number for the first opened file]:column number' \ + '(-c --config)'{-c,--config=}'[use an alternate configuration directory]:configuration directory:_directories' \ + "${ign}(- *)--ft-names[print internal filetype names]" \ + {-g,--generate-tags}'[generate global tags file]:tags file:_files -g "*.tags(-.)":*:source file:_files' \ + '(-P --no-preprocessing)'{-P,--no-preprocessing}"[don't preprocess C/C++ files when generating tags]" \ + '(-i --new-instance --socket-file)'{-i,--new-instance}"[don't open files in a running instance, force opening a new instance]" \ + '(-i --new-instance)--socket-file=[use specified socket file to communicate with a Geany instance]:socket:_files -g "*(-=)"' \ + "${ign}(- *)--list-documents[return a list of open documents in a running Geany instance]" \ + '(-l --line)'{-l,--line=}'[set initial line number for the first opened file]:line number' \ + '(-m --no-msgwin)'{-m,--no-msgwin}"[don't show message window at startup]" \ + '(-n --no-ctags)'{-n,--no-ctags}"[don't load completion and call tip data]" \ + '(-p --no-plugins)'{-p,--no-plugins}"[don't load plugins]" \ + "${ign}(- *)--print-prefix[print Geany's installation prefix]" \ + '(-r --read-only)'{-r,--read-only}'[open all given files in read-only mode]' \ + '(-s --no-session)'{-s,--no-session}"[don't load the previous session's files]" \ + '(-t --no-terminal --vte-lib)'{-t,--no-terminal}"[don't load terminal support]" \ + '(-t --no-terminal)--vte-lib=[specify path and filename of VTE library]:libvte.so filename:_files -g "*.so(-.)"' \ + '(-v --verbose)'{-v,--verbose}'[be verbose]' \ + "${ign}(- *)"{-V,--version}'[display version information]' \ + '--display=[specify X display to use]:display:_x_display' \ + '(-g --generate-tags)*: :_files' diff --git a/Completion/X/Command/_mupdf b/Completion/X/Command/_mupdf new file mode 100644 index 000000000..8a3c76459 --- /dev/null +++ b/Completion/X/Command/_mupdf @@ -0,0 +1,53 @@ +#compdef mupdf + +local -a ext=( + cbt + cbz + tar + zip + epub + gproof + fb2 + htm + html + xhtml + xml + bmp + gif + hdp + j2k + jfif + jfif-tbnl + jp2 + jpe + jpeg + jpg + jpx + jxr + pam + pbm + pgm + png + pnm + ppm + tif + tiff + wdp + pdf + pclm + ai + svg + oxps + xps +) + +_arguments -S -s -A '-*' \ + '-p+[use specified password]:password:' \ + '-r+[specify initial zoom level]:resolution [72]:' \ + '-A+[specify anti-aliasing quality]:bits [8]:({0..8})' \ + '-C+[specify full-page tint:tint (RRGGBB) [FFFAF0]:' \ + '-W+[specify page width]:width:' \ + '-H+[specify page height]:height:' \ + '-S+[specify font size]:font size:' \ + '-U+[specify user style sheet]:CSS file:_files' \ + ': :_files -g "*(#i).(${(j:|:)ext})(-.)"' diff --git a/Completion/X/Command/_qiv b/Completion/X/Command/_qiv index d10407584..35ceec09a 100644 --- a/Completion/X/Command/_qiv +++ b/Completion/X/Command/_qiv @@ -5,7 +5,9 @@ _arguments -s \ '(- *)'{-v,--version}'[display version information]' \ '--display:display:_x_display' \ \*{-F,--file}'[read file names from file]:file:_files' \ + '(-B --browse)'{-B,--browse}'[scan directory of file for browsing]' \ '(-e --center)'{-e,--center}'[disable window centering]' \ + '(-C --cycle)'{-C,--cycle}"[don't cycle after last image]" \ '(-w --fixed_width -W --fixed_zoom)'{-w,--fixed_width}'[use window with specified width]:width' \ '(-w --fixed_width -W --fixed_zoom)'{-W,--fixed_zoom}'[use window with specified zoom factor]:zoom (percentage)' \ '(-x -y -z --root --root_t --root_s -f --file *)'{-x,--root}'[use image as the current desktop background, centered]:image file:_files' \ @@ -13,6 +15,7 @@ _arguments -s \ '(-x -y -z --root --root_t --root_s -f --file *)'{-z,--root_s}'[use image as the current desktop background, stretched]:image file:_files' \ '(-m --maxpect)'{-m,--maxpect}'[expand image to fit screen size]' \ '(-t --scale_down)'{-t,--scale_down}'[shrink images to fit screen size]' \ + "--trashbin[move files to user's trash bin instead of .qiv-trash when deleting]" \ '(-b --brightness)'{-b,--brightness}'[set brightness]:brightness (-32..32)' \ '(-c --contrast)'{-c,--contrast}'[set contrast]:contrast (-32..32)' \ '(-g --gamma)'{-g,--gamma}'[set gamma]:gamma (-32..32)' \ @@ -21,7 +24,7 @@ _arguments -s \ '(-i --no_statusbar -I --statusbar)'{-I,--statusbar}'[enable statusbar]' \ '(-p --transparency)'{-p,--transparency}'[enable transparency]' \ '(-a --do_grab)'{-a,--do_grab}'[grab the pointer in windowed mode]' \ - '(-G --disable_grab)'{-G,--disable_grab}'[disable pointer grabbing]' \ + '(-G --disable_grab)'{-G,--disable_grab}'[disable pointer grabbing in fullscreen mode]' \ '(-o --bg_color)'{-o,--bg_color}'[set root background color]:color:_x_color' \ '(-s --slide)'{-s,--slide}'[start slideshow immediately]' \ '(-r --random)'{-r,--random}'[shuffle images for slideshow]' \ @@ -31,6 +34,17 @@ _arguments -s \ '(-f --fullscreen)'{-f,--fullscreen}'[use fullscreen window on startup]' \ '(-P --ignore_path_sort)'{-P,--ignore_path_sort}'[sort images by just the filename]' \ '(-M --merged_case_sort)'{-M,--merged_case_sort}'[sort images case-insensitively]' \ - '(-N --numeric_sort)'{-N,--numeric_sort}'[numeric image sort]' \ + '(-K --mtime_sort)'{-K,--mtime_sort}'[sort images by their modification time]' \ + '(-N --numeric_sort -K --mtime_sort)'{-N,--numeric_sort}'[numeric image sort]' \ + '(-D --no_sort -N --numeric_sort -K --mtime_sort -M --merged_case_sort -P --ignore_path_sort)'{-D,--no_sort}"[don't apply any sorting to the images]" \ '(-T --watch)'{-T,--watch}'[reload the image if it changes]' \ - '*:image file:_files -g "*.(#i)(bmp|eim|gif|jp([eg]|eg)|pcx|png|p[pngb]m|tif(|f)|tga|x[pb]m)(-.)"' + '(-u --recursivedir)'{-u,--recursivedir}'[recursively include all files]' \ + '(-L --followlinks)'{-L,--followlinks}'[follow symlinks to directories]' \ + '(-A --select_dir)'{-A,--select_dir}'[store selected files in specified directory]:directory [.qiv-select]:_directories' \ + '(-l --autorotate)'{-l,--autorotate}"[don't autorotate JPEGs according to EXIF rotation tag]" \ + '(-q --rotate)'{-q,--rotate}'[rotate image]:angle:((1\:90 2\:180 3\:270))' \ + '(-X --xineramascreen)'{-X,--xineramascreen}'[specify preferred screen]:screen' \ + '(-Y --source_profile)'{-Y,--source_profile}'[specify colour profile file as source profile]:colour profile file:_files' \ + '(-Z --display_profile)'{-Z,--display_profile}'[specify colour profile file as display profile]:colour profile file:_files' \ + '--vikeys[enable movement with h/j/k/l]' \ + '*:image file:_files -g "*.(#i)(bmp|eim|gif|ico|jp([eg]|eg)|pcx|png|p[pngb]m|pjpeg|svg|tif(|f)|wmf|x[pb]m)(-.)"' diff --git a/Completion/X/Command/_zathura b/Completion/X/Command/_zathura new file mode 100644 index 000000000..141cadf63 --- /dev/null +++ b/Completion/X/Command/_zathura @@ -0,0 +1,48 @@ +#compdef zathura + +(( $+functions[_zathura_files] )) || +_zathura_files(){ + local -a plugins_files + local plugins_dir + for plugins_dir in \ + ${(Qv)opt_args[(i)-p|--plugins-dir]}(#qN) \ + {/usr/local,/usr,}/lib/zathura(#qN) + do + plugins_files=( $plugins_dir/*.so ) + (( $#plugins_files )) && break + done + if [[ -z "${plugins_files}" ]]; then + _files -g "*.pdf(-.)" + return + fi + local -a supported_filetypes + local pf + for pf in "${plugins_files[@]}"; do + if [[ $pf =~ "mupdf" ]]; then + supported_filetypes+="pdf" + supported_filetypes+="epub" + supported_filetypes+="xps" + elif [[ $pf =~ "poppler" ]]; then + supported_filetypes+="pdf" + else + supported_filetypes+="${${pf%.so}#${plugins_dir}/lib}" + fi + done + _files -g "*.(${(j.|.)supported_filetypes})(-.)" +} + +_arguments -s -S \ + {-e,--reparent=}'[specify xid of window to reparent to]:xid:_x_window' \ + {-c,--config-dir=}'[specify path to the config directory]:config directory:{_files -/}' \ + {-d,--data-dir=}'[specify path to the data directory]:data directory:{_files -/}' \ + {-p,--plugins-dir=}'[specify path to the directory containing plugins]:plugins directory:{_files -/}' \ + {-w,--password=}"[specify a password for the document]:password: " \ + {-P,--page=}'[open the document at the given page number]:page number: ' \ + {-l,--log-level=}'[set log level]:log level:(debug info warning error)' \ + {-x,--synctex-editor-command=}'[specify synctex editor command]:synctex editor command:_cmdstring' \ + '--synctex-forward=[jump to the given position]:synctex position: ' \ + '--synctex-pid=[specify pid of an instance having the correct file opened]:synctex pid:_pids' \ + '--fork[fork into background]' \ + '(- :)--version[display version string and exit]' \ + '(- :)--help[display help and exit]' \ + '*:file:_zathura_files' diff --git a/Completion/X/Command/_zeal b/Completion/X/Command/_zeal new file mode 100644 index 000000000..334331d40 --- /dev/null +++ b/Completion/X/Command/_zeal @@ -0,0 +1,43 @@ +#compdef zeal + +local curcontext="$curcontext" cfg docset setdir mbegin mend ret=1 +local -a state line expl suf docsets globbed match +local -A opt_args dsets + +_arguments -S \ + ':query:->queries' \ + + '(opt)' \ + {-h,--help}'[display help information]' \ + {-v,--version}'[display version information]' \ + {-f,--force}'[force the application to run]' && ret=0 + +if [[ -n $state ]]; then + cfg=${XDG_CONFIG_HOME:-~/.config}/Zeal/Zeal.conf + if [[ -r $cfg ]]; then + docsets=${${(M)${(f)"$(<$cfg)"}:#path=*}#path=} + else + docsets=${XDG_DATA_HOME:-~/.local/share}/Zeal/Zeal/docsets + fi + for docset in $docsets/*.docset/Contents/Info.plist(N); do + setdir=${docset:h:h:r:t:l:gs/+/p} + [[ $(<$docset) = *DocSetPlatformFamily\<[^\<]#\<string\>(#b)([^\<]#)* ]] || + match=( ${docset:h:h:r:t:l:gs/+/p} ) + dsets+=( $match[1] ${docset:h} ) + done + if compset -P 1 '*:'; then + globbed=( ${dsets[${IPREFIX%:}]}/Resources/docSet.dsidx(N[1]) ) + if (( $+commands[sqlite3] )) && [[ -e $globbed ]]; then + _description queries expl 'query' + compadd "$expl[@]" - ${(f)"$(_call_program queries + sqlite3 $globbed 'select name from searchIndex')"} && ret=0 + else + _message -e queries 'query' + fi + else + compset -S ':*' || suf=( -qS : ) + _description docsets expl 'docset' + compadd "$expl[@]" $suf -k dsets && ret=0 + fi +fi + +return ret diff --git a/Completion/Zsh/Command/_stat b/Completion/Zsh/Command/_stat deleted file mode 100644 index 73bbef471..000000000 --- a/Completion/Zsh/Command/_stat +++ /dev/null @@ -1,33 +0,0 @@ -#compdef stat zstat - -local expl ret=1 - -if [[ $service == zstat ]] || - (( ${+builtins[stat]} )) || - { (( ! ${+builtins} )) && [[ $(type -w stat) == '*: builtin' ]] } -then - _arguments -s -S : \ - '(-H)-A[assign the results to array, don'\''t print]:array variable:_parameters -g "*array*"' \ - - set1 \ - +device +inode +mode +nlink +uid +gid +rdev \ - +size +atime +mtime +ctime +blksize +block +link \ - '(-A)-H[assign the results to associative array, don'\''t print]:associative array variable:_parameters -g "*association*"' \ - '(:)-f[stat a file descriptor]:file descriptor:_file_descriptors' \ - '(-s)-F:strftime(3) format string:_date_formats zsh' \ - '(-s)-g[show times in GMT/UTC]' \ - '-L[don'\''t dereference symbolic links; use lstat(2)]' \ - '(-N)-n[always show names of files]' \ - '(-n)-N[never show names of files]' \ - '-o[print file modes in octal rather than decimal]' \ - '-r[print raw data]' \ - '-s[print mode,uid,gid and times as strings]' \ - '(-T)-t[always show type names]' \ - '(-t)-T[never show type names]' \ - '*:files to stat:_files' \ - - set2 \ - '-l[list stat types]' -else - # TODO: system-specific completion - # TODO: choose this codepath if 'command stat ...' or '=stat ...' is used - _files -fi diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index 14d5d371b..fb7189c77 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -55,9 +55,13 @@ case ${service} in ;; float) use="EFHghlprtux";; functions) - use="UkmTtuzMW" + use="UkmTtuzW" func=f - allargs[M]='(-k -t -T -u -U -z -M +M +k +t +z)-+M[define mathematical function]' + args=( + '(-k -t -T -u -U -W -x -z -M +M +k +t +W +z)-+M[define mathematical function]' + '(-k -m -t -T -u -U -W -x -z +M +k +t +W +z)-s[define mathematical function that takes a string argument]' + '(-M)-x+[specify spaces to use for indentation]:spaces' + ) ;; integer) use="Hghilprtux" @@ -89,8 +93,10 @@ if [[ "$state" = vars_eq ]]; then _wanted functions expl 'math function' compadd -F line - \ ${${${(f)"$(functions -M)"}##*-M }%% *} elif (( $+opt_args[-M] )); then - _arguments ':new math function:_functions' ':minimum arguments' \ - ':maximum arguments' ':shell function:_functions' + _arguments ':new math function:_functions' \ + ":minimum arguments${(k)opt_args[-s]:+:(1)}" \ + ":maximum arguments${(k)opt_args[-s]:+:(1)}" \ + ':shell function:_functions' elif (( $+opt_args[-w] )); then _wanted files expl 'zwc file' _files -g '*.zwc(-.)' elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which index c43704ae8..9b789c86b 100644 --- a/Completion/Zsh/Command/_which +++ b/Completion/Zsh/Command/_which @@ -1,6 +1,6 @@ #compdef which whence where type -local farg aarg cargs args state line curcontext="$curcontext" ret=1 +local farg aarg xarg cargs args state line curcontext="$curcontext" ret=1 cargs=( \ '(-v -c)-w[print command type]' \ @@ -11,6 +11,7 @@ cargs=( \ '*:commands:->command' ) farg='-f[output contents of functions]' aarg='-a[print all occurrences in path]' +xarg='-x+[specify spaces to use for indentation in function expansion]:spaces' case ${service} in whence) @@ -19,8 +20,8 @@ case ${service} in '(-v -w)-c[csh-like output]' \ "${cargs[@]}" "$farg" "$aarg" && ret=0 ;; - where) _arguments -C -s -A "-*" -S "${cargs[@]}" && ret=0;; - which) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" && 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;; esac diff --git a/Completion/Zsh/Command/_zed b/Completion/Zsh/Command/_zed index 211dae7df..6b68fadf0 100644 --- a/Completion/Zsh/Command/_zed +++ b/Completion/Zsh/Command/_zed @@ -5,5 +5,6 @@ case $service in (zed) _arguments -S : \ '(- 2):file:_files' \ '(1):shell function:_functions' \ + '(1)-x+[specify spaces to use for indentation in function expansion]:spaces' \ '(1)-f[edit function]';; esac diff --git a/Completion/Zsh/Type/_command_names b/Completion/Zsh/Type/_command_names index 940f341cb..f8188774d 100644 --- a/Completion/Zsh/Type/_command_names +++ b/Completion/Zsh/Type/_command_names @@ -31,7 +31,8 @@ else 'suffix-aliases:suffix alias:_suffix_alias_files' 'reserved-words:reserved word:compadd -Qk reswords' 'jobs:: _jobs -t' - 'parameters:: _parameters -g "^*readonly*" -qS= -r "\n\t\- =["' + 'parameters:: _parameters -g "^*(readonly|association)*" -qS= -r "\n\t\- =[+"' + 'parameters:: _parameters -g "*association*~*readonly*" -qS\[ -r "\n\t\- =[+"' ) fi diff --git a/Config/version.mk b/Config/version.mk index b703c2563..0bea45b5b 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.5.1 -VERSION_DATE='April 16, 2018' +VERSION=5.5.1-test-2 +VERSION_DATE='August 26, 2018' diff --git a/Doc/Makefile.in b/Doc/Makefile.in index 2752096e4..fded2e825 100644 --- a/Doc/Makefile.in +++ b/Doc/Makefile.in @@ -76,7 +76,7 @@ YODLSRC = zmacros.yo zman.yo ztexi.yo Zsh/arith.yo Zsh/builtins.yo \ Zsh/calsys.yo \ Zsh/compat.yo Zsh/compctl.yo Zsh/compsys.yo Zsh/compwid.yo Zsh/cond.yo \ Zsh/contrib.yo Zsh/exec.yo Zsh/expn.yo \ -Zsh/filelist.yo Zsh/files.yo Zsh/ftp_sites.yo \ +Zsh/filelist.yo Zsh/files.yo \ Zsh/func.yo Zsh/grammar.yo Zsh/manual.yo \ Zsh/index.yo Zsh/intro.yo Zsh/invoke.yo Zsh/jobs.yo Zsh/metafaq.yo \ Zsh/modules.yo Zsh/modlist.yo Zsh/modmenu.yo Zsh/manmodmenu.yo $(MODDOCSRC) \ @@ -185,7 +185,7 @@ zshall.1: zsh.yo $(YODL) -I$(sdir) -DZSHALL -w zman.yo version.yo zsh.yo | sed -e '1s/\\-/-/g' -e '/^\.'\''/d' > $$target \ ;; esac; \ -../META-FAQ: META-FAQ.yo Zsh/metafaq.yo Zsh/ftp_sites.yo +../META-FAQ: META-FAQ.yo Zsh/metafaq.yo case '$(YODL)' in :*) touch $(sdir_top)/META-FAQ ;; *) \ $(YODL) -I$(sdir) META-FAQ.yo | sed -e '/NEXTLINE/N' -e '/DELLINE/d' -e '/^SECTHEAD$$/{N;s/^SECTHEAD.//;h;s/./-/g;H;g;}' -e 's/ *$$//' -e '/comment(.*)/d' > $(sdir_top)/META-FAQ \ ;; esac @@ -211,7 +211,7 @@ $(MAN): zmacros.yo zman.yo zsh.1 zshall.1: Zsh/intro.yo Zsh/metafaq.yo Zsh/invoke.yo Zsh/files.yo \ Zsh/filelist.yo Zsh/filelist.yo Zsh/seealso.yo \ - Zsh/ftp_sites.yo Zsh/compat.yo Zsh/restricted.yo + Zsh/compat.yo Zsh/restricted.yo zshbuiltins.1: Zsh/builtins.yo diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index afe332544..65f596752 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -4279,8 +4279,8 @@ var(field)s for which the value is known). The matches generated will be taken from the value of the style. These should contain the possible values for the combinations in the appropriate -order (users, hosts, ports in the example above). The different fields -the values for the different fields are separated by colons. This +order (users, hosts, ports in the example above). +The values for the different fields are separated by colons. This can be altered with the option tt(-s) to tt(_combination) which specifies a pattern. Typically this is a character class, as for example `tt(-s "[:@]")' in the case of the tt(users-hosts) style. Each diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 35ce91575..0c2ba484c 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -847,22 +847,22 @@ In order to do that, you may use the tt(vcs_info) function. The following VCSs are supported, showing the abbreviated name by which they are referred to within the system: startsitem() -sitem(Bazaar (tt(bzr)))(uref(http://bazaar.canonical.com/)) +sitem(Bazaar (tt(bzr)))(uref(https://bazaar.canonical.com/)) sitem(Codeville (tt(cdv)))(uref(http://freecode.com/projects/codeville/)) -sitem(Concurrent Versioning System (tt(cvs)))(uref(http://www.nongnu.org/cvs/)) +sitem(Concurrent Versioning System (tt(cvs)))(uref(https://www.nongnu.org/cvs/)) sitem(Darcs (tt(darcs)))(uref(http://darcs.net/)) -sitem(Fossil (tt(fossil)))(uref(http://fossil-scm.org/)) -sitem(Git (tt(git)))(uref(http://git-scm.com/)) -sitem(GNU arch (tt(tla)))(uref(http://www.gnu.org/software/gnu-arch/)) -sitem(Mercurial (tt(hg)))(uref(http://mercurial.selenic.com/)) -sitem(Monotone (tt(mtn)))(uref(http://monotone.ca/)) -sitem(Perforce (tt(p4)))(uref(http://www.perforce.com/)) -sitem(Subversion (tt(svn)))(uref(http://subversion.apache.org/)) -sitem(SVK (tt(svk)))(uref(http://svk.bestpractical.com/)) +sitem(Fossil (tt(fossil)))(uref(https://fossil-scm.org/)) +sitem(Git (tt(git)))(uref(https://git-scm.com/)) +sitem(GNU arch (tt(tla)))(uref(https://www.gnu.org/software/gnu-arch/)) +sitem(Mercurial (tt(hg)))(uref(https://www.mercurial-scm.org/)) +sitem(Monotone (tt(mtn)))(uref(https://monotone.ca/)) +sitem(Perforce (tt(p4)))(uref(https://www.perforce.com/)) +sitem(Subversion (tt(svn)))(uref(https://subversion.apache.org/)) +sitem(SVK (tt(svk)))(uref(https://svk.bestpractical.com/)) endsitem() There is also support for the patch management system tt(quilt) -(uref(http://savannah.nongnu.org/projects/quilt)). See +(uref(https://savannah.nongnu.org/projects/quilt)). See ifzman(bf(Quilt Support))ifnzman(noderef(vcs_info Quilt Support)) below for details. diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo index 8b447e2c7..c79109700 100644 --- a/Doc/Zsh/expn.yo +++ b/Doc/Zsh/expn.yo @@ -2004,7 +2004,7 @@ The character is 7-bit, i.e. is a single-byte character without the top bit set. ) item(tt([:blank:]))( -The character is either space or tab +The character is a blank character ) item(tt([:cntrl:]))( The character is a control character diff --git a/Doc/Zsh/ftp_sites.yo b/Doc/Zsh/ftp_sites.yo deleted file mode 100644 index 804d975f3..000000000 --- a/Doc/Zsh/ftp_sites.yo +++ /dev/null @@ -1,15 +0,0 @@ -startitem() -item(Primary site)( -nofill(uref(ftp://ftp.zsh.org/pub/) -uref(http://www.zsh.org/pub/)) -) -item(Australia)( -nofill(uref(ftp://ftp.zsh.org/pub/) -uref(http://www.zsh.org/pub/) -uref(http://mirror.dejanseo.com.au/pub/zsh/)) -) -item(Hungary)( -nofill(uref(ftp://ftp.cs.elte.hu/pub/zsh/) -uref(http://www.cs.elte.hu/pub/zsh/)) -) -enditem() diff --git a/Doc/Zsh/intro.yo b/Doc/Zsh/intro.yo index 510a7bda5..a7a2f3248 100644 --- a/Doc/Zsh/intro.yo +++ b/Doc/Zsh/intro.yo @@ -38,8 +38,13 @@ sect(Description) )\ Zsh is a UNIX command interpreter (shell) usable as an interactive login shell and as a shell script command processor. Of the standard shells, -zsh most closely resembles bf(ksh) but includes many enhancements. Zsh -has command line editing, builtin spelling correction, programmable +zsh most closely resembles bf(ksh) but includes many enhancements. It +does not provide compatibility with POSIX or other shells in its +default operating mode: see +ifnzman(the section noderef(Compatibility))\ +ifzman(the section Compatibility below). + +Zsh has command line editing, builtin spelling correction, programmable command completion, shell functions (with autoloading), a history mechanism, and a host of other features. includefile(Zsh/metafaq.yo) diff --git a/Doc/Zsh/metafaq.yo b/Doc/Zsh/metafaq.yo index 6cb299ad1..c123a7cea 100644 --- a/Doc/Zsh/metafaq.yo +++ b/Doc/Zsh/metafaq.yo @@ -18,17 +18,17 @@ can be contacted at tt(<coordinator@zsh.org>), but matters relating to the code should generally go to the mailing list. texinode(Availability)(Mailing Lists)(Author)(Introduction) sect(Availability) -Zsh is available from the following anonymous FTP sites. These mirror -sites are kept frequently up to date. The sites marked with em((H)) may be -mirroring tt(ftp.cs.elte.hu) instead of the primary site. +Zsh is available from the following HTTP and anonymous FTP site. cindex(FTP sites for zsh) cindex(acquiring zsh by FTP) cindex(availability of zsh) -INCLUDEFILE(Zsh/ftp_sites.yo)\ +nofill(uref(ftp://ftp.zsh.org/pub/) +uref(https://www.zsh.org/pub/)) +) The up-to-date source code is available via Git from Sourceforge. See -uref(http://sourceforge.net/projects/zsh/) for details. A summary of +uref(https://sourceforge.net/projects/zsh/) for details. A summary of instructions for the archive can be found at uref(http://zsh.sourceforge.net/). @@ -75,7 +75,7 @@ maintained by Karsten Thygesen tt(<karthy@kom.auc.dk>). The mailing lists are archived; the archives can be accessed via the administrative addresses listed above. There is also a hypertext archive, maintained by Geoff Wing tt(<gcw@zsh.org>), available at -uref(http://www.zsh.org/mla/). +uref(https://www.zsh.org/mla/). texinode(The Zsh FAQ)(The Zsh Web Page)(Mailing Lists)(Introduction) sect(The Zsh FAQ) Zsh has a list of Frequently Asked Questions (FAQ), maintained by @@ -86,7 +86,7 @@ uref(http://www.zsh.org/FAQ/). The contact address for FAQ-related matters is tt(<faqmaster@zsh.org>). texinode(The Zsh Web Page)(The Zsh Userguide)(The Zsh FAQ)(Introduction) sect(The Zsh Web Page) -Zsh has a web page which is located at uref(http://www.zsh.org/). This is +Zsh has a web page which is located at uref(https://www.zsh.org/). This is maintained by Karsten Thygesen tt(<karthy@zsh.org>), of SunSITE Denmark. The contact address for web-related matters is tt(<webmaster@zsh.org>). texinode(The Zsh Userguide)(See Also)(The Zsh Web Page)(Introduction) @@ -98,7 +98,3 @@ cabbalistic, hierographic, or downright mystifying (for example, the word uref(http://zsh.sourceforge.net/Guide/). At the time of writing, chapters dealing with startup files and their contents and the new completion system were essentially complete. -sect(The Zsh Wiki) -A `wiki' website for zsh has been created at uref(http://www.zshwiki.org/). -This is a site which can be added to and modified directly by users without -any special permission. You can add your own zsh tips and configurations. diff --git a/Doc/Zsh/mod_mathfunc.yo b/Doc/Zsh/mod_mathfunc.yo index 8b72de3ab..428a5be47 100644 --- a/Doc/Zsh/mod_mathfunc.yo +++ b/Doc/Zsh/mod_mathfunc.yo @@ -24,9 +24,9 @@ The following functions take a single floating point argument: tt(acos), tt(acosh), tt(asin), tt(asinh), tt(atan), tt(atanh), tt(cbrt), tt(ceil), tt(cos), tt(cosh), tt(erf), tt(erfc), tt(exp), tt(expm1), tt(fabs), tt(floor), tt(gamma), tt(j0), tt(j1), tt(lgamma), tt(log), tt(log10), -tt(log1p), tt(logb), tt(sin), tt(sinh), tt(sqrt), tt(tan), tt(tanh), -tt(y0), tt(y1). The tt(atan) function can optionally take a second -argument, in which case it behaves like the C function tt(atan2). +tt(log1p), tt(log2), tt(logb), tt(sin), tt(sinh), tt(sqrt), tt(tan), +tt(tanh), tt(y0), tt(y1). The tt(atan) function can optionally take a +second argument, in which case it behaves like the C function tt(atan2). The tt(ilogb) function takes a single floating point argument, but returns an integer. diff --git a/Doc/Zsh/mod_stat.yo b/Doc/Zsh/mod_stat.yo index 96349061e..9caed1e45 100644 --- a/Doc/Zsh/mod_stat.yo +++ b/Doc/Zsh/mod_stat.yo @@ -114,7 +114,11 @@ named files; no list of file names is allowed in this case. ) item(tt(-F) var(fmt))( Supplies a tt(strftime) (see manref(strftime)(3)) string for the -formatting of the time elements. The tt(-s) option is implied. +formatting of the time elements. The format string supports all of the +zsh extensions described in +ifzman(the section EXPANSION OF PROMPT SEQUENCES in zmanref(zshmisc))\ +ifnzman(noderef(Prompt Expansion)). +The tt(-s) option is implied. ) item(tt(-g))( Show the time elements in the GMT time zone. The diff --git a/Doc/Zsh/mod_system.yo b/Doc/Zsh/mod_system.yo index 7f2009b43..a27bab47f 100644 --- a/Doc/Zsh/mod_system.yo +++ b/Doc/Zsh/mod_system.yo @@ -255,6 +255,11 @@ Returns the process ID of the parent of the current process, even in subshells. Compare tt($PPID), which returns the process ID of the parent of the main shell process. ) +item(tt(procsubstpid))( +Returns the process ID of the last process started for process +substitution, i.e. the tt(<LPAR())var(...)tt(RPAR()) and +tt(>LPAR())var(...)tt(RPAR()) expansions. +) enditem() ) enditem() diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo index 8331eabb7..15f6ed365 100644 --- a/Doc/Zsh/mod_zutil.yo +++ b/Doc/Zsh/mod_zutil.yo @@ -172,6 +172,7 @@ printed below each other. All strings without a colon are left unchanged and all strings with an empty var(right) string have the trailing colon removed. In both cases the lengths of the strings are not used to determine how the other strings are to be aligned. +A colon in the var(left) string can be escaped with a backslash. The resulting strings are stored in the var(array). ) findex(zregexparse) diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo index 3c8f2a094..909012c8e 100644 --- a/Doc/Zsh/prompt.yo +++ b/Doc/Zsh/prompt.yo @@ -198,11 +198,15 @@ endsitem() In addition, if the system supports the POSIX tt(gettimeofday) system call, tt(%.) provides decimal fractions of a second since the epoch with leading zeroes. By default three decimal places are provided, but a -number of digits up to 6 may be given following the tt(%); hence tt(%6.) -outputs microseconds. A typical example of this is the format -`tt(%D{%H:%M:%S.%.})'. +number of digits up to 9 may be given following the tt(%); hence tt(%6.) +outputs microseconds, and tt(%9.) outputs nanoseconds. (The latter +requires a nanosecond-precision tt(clock_gettime); systems lacking this +will return a value multiplied by the appropriate power of 10.) A typical +example of this is the format `tt(%D{%H:%M:%S.%.})'. -The GNU extension that a `tt(-)' between the tt(%) and the +The GNU extension tt(%N) is handled as a synonym for tt(%9.). + +Additionally, the GNU extension that a `tt(-)' between the tt(%) and the format character causes a leading zero or space to be stripped is handled directly by the shell for the format characters tt(d), tt(f), tt(H), tt(k), tt(l), tt(m), tt(M), tt(S) and tt(y); any other format diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index bd0252f6e..6ae4863c6 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -342,7 +342,7 @@ findex(vared) cindex(parameters, editing) cindex(editing parameters) redef(SPACES)(0)(tt(ifztexi(NOTRANS(@ @ @ @ @ @ ))ifnztexi( ))) -xitem(tt(vared )[ tt(-Aache) ] [ tt(-p) var(prompt) ] [ tt(-r) var(rprompt) ]) +xitem(tt(vared )[ tt(-Aacghe) ] [ tt(-p) var(prompt) ] [ tt(-r) var(rprompt) ]) xitem(SPACES()[ tt(-M) var(main-keymap) ] [ tt(-m) var(vicmd-keymap) ]) xitem(SPACES()[ tt(-i) var(init-widget) ] [ tt(-f) var(finish-widget) ]) item(SPACES()[ tt(-t) var(tty) ] var(name))( @@ -353,7 +353,9 @@ When the tt(-c) flag is given, the parameter is created if it doesn't already exist. The tt(-a) flag may be given with tt(-c) to create an array parameter, or the tt(-A) flag to create an associative array. If the type of an existing parameter does not match the type to be -created, the parameter is unset and recreated. +created, the parameter is unset and recreated. The tt(-g) flag may +be given to suppress warnings from the tt(WARN_CREATE_GLOBAL) +and tt(WARN_NESTED_VAR) options. If an array or array slice is being edited, separator characters as defined in tt($IFS) will be shown quoted with a backslash, as will backslashes @@ -1083,6 +1085,13 @@ wrappers of tt(bracketed-paste). See also tt(zle -f). tt(YANK_ACTIVE) is read-only. ) +vindex(ZLE_RECURSIVE) +item(tt(ZLE_RECURSIVE) (integer))( +Usually zero, but incremented inside any instance of +tt(recursive-edit). Hence indicates the current recursion level. + +tt(ZLE_RECURSIVE) is read-only. +) vindex(ZLE_STATE) item(tt(ZLE_STATE) (scalar))( Contains a set of space-separated words that describe the current tt(zle) diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo index 72ff7fa3d..12bd4eb3d 100644 --- a/Etc/FAQ.yo +++ b/Etc/FAQ.yo @@ -331,15 +331,11 @@ label(16) The coordinator of development is currently me; the alias email(coordinator@zsh.org) can be used to contact whoever is in the hot - seat. The following are known mirrors (kept frequently up to date); the - first is the official archive site, currently in Australia. All are - available by anonymous FTP. The major sites keep test versions in the + seat. url(https://www.zsh.org/)(https://www.zsh.org/) is the official + archive site, currently in Australia. Test versions are kept in the `testing' subdirectory: such up-to-the-minute development versions should only be retrieved if you actually plan to help test the latest version of - the shell. The following list also appears on the WWW at - url(http://www.zsh.org/)(http://www.zsh.org/) . - -includefile(../Doc/Zsh/ftp_sites.yo) + the shell. A Windows port was created by Amol Deshpandem based on 3.0.5 (which is now rather old). This has now been restored and can be found at diff --git a/Etc/completion-style-guide b/Etc/completion-style-guide index a6fc737a7..af7c46bfd 100644 --- a/Etc/completion-style-guide +++ b/Etc/completion-style-guide @@ -20,6 +20,26 @@ Coding style: * Please try not to use lines longer than 79 characters. Don't worry about breaking long `_arguments' or `_values' specs though. +* Never use alternative, unusual, or optional syntax in completion + functions (or any other shell code distributed with zsh). In other + words, do NOT use the following: + + # Short loops + for x in $y; myfunc $x + + # Alternative forms + if { [[ $x == $y ]] } { + myfunc $x + } + foreach x in $y { + myfunc $x + } + + # Weird tricks + () for 1 { + myfunc $1 + } $x + Descriptions: Descriptions should not have a trailing full stop and initial capital @@ -493,3 +513,20 @@ Misc. remarks completion function would contain the code for the default way to generate the matches. See the `_email_addresses', `_rpm' and `_nslookup' files for examples. +9) Be mindful of quoting/escaping edge cases. Notably: + * Elements of the `$words' array are derived verbatim from the user's + command-line input -- if they type an argument in quotes or escaped + by backslashes, that is how it appears in the array. + * Option-arguments are stored in `$opt_args` the same way. Further, + since multiple arguments to the same option are represented in a + colon-delimited fashion, backslashes and colons passed by the user + are escaped. For instance, the option-arguments parsed from + `-afoo -a "bar" -a 1:2:3' appear in `$opt_args[-a]` as + `foo:"bar":1\:2\:3'. + * The `_call_program` helper used by many completion functions is + implemented using `eval', so arguments to it must be quoted + accordingly. As mentioned above, most of the user's own input comes + pre-escaped, but you may run into problems passing file names or + data derived from another command's output to the helper. Consider + using some variation of the `q` expansion flag to deal with this: + `_call_program vals $words[1] ${(q-)myfile}' diff --git a/Functions/Chpwd/zsh_directory_name_cdr b/Functions/Chpwd/zsh_directory_name_cdr index c9be7db0c..cb72e4600 100644 --- a/Functions/Chpwd/zsh_directory_name_cdr +++ b/Functions/Chpwd/zsh_directory_name_cdr @@ -1,14 +1,13 @@ if [[ $1 = n ]]; then if [[ $2 = <-> ]]; then # Recent directory - typeset -ga reply autoload -Uz cdr cdr -r if [[ -n ${reply[$2]} ]]; then - reply=(${reply[$2]}) + typeset -ga reply=(${reply[$2]}) return 0 else - reply=() + typeset -ga reply=() return 1 fi fi diff --git a/Functions/Misc/zed b/Functions/Misc/zed index f571daf5e..9eb4b2d93 100644 --- a/Functions/Misc/zed +++ b/Functions/Misc/zed @@ -3,7 +3,7 @@ # # No other shell could do this. # Edit small files with the command line editor. -# Use ^X^W to save, ^C to abort. +# Use ^X^W to save (or ZZ in vicmd mode), ^C to abort. # Option -f: edit shell functions. (Also if called as fned.) setopt localoptions noksharrays @@ -60,6 +60,11 @@ __zed_pg_down() done } +if ! zle -la __zed_pg_up __zed_pg_down; then + zle -N __zed_pg_up + zle -N __zed_pg_down +fi + if (( bind )) || ! bindkey -M zed >&/dev/null; then # Make the zed keymap a copy of the current main. bindkey -N zed main @@ -67,6 +72,12 @@ if (( bind )) || ! bindkey -M zed >&/dev/null; then # zed we may want to set this temporally. bindkey -A main zed-normal-keymap + # Define a widget to use at startup, undo shouldn't clear initial buffer + __zed_init() { + UNDO_LIMIT_NO=$UNDO_CHANGE_NO + } + zle -N __zed_init + # Assign some default keys. # Depending on your stty's, you may be able to use ^J as accept-line, else: @@ -75,10 +86,16 @@ if (( bind )) || ! bindkey -M zed >&/dev/null; then bindkey -M zed '^x^w' accept-line bindkey -M zed '^M' self-insert-unmeta - zle -N __zed_pg_up - zle -N __zed_pg_down - [[ ${+terminfo} = 1 && -n "$terminfo[kpp]" ]] && bindkey -M zed "$terminfo[kpp]" __zed_pg_up - [[ ${+terminfo} = 1 && -n "$terminfo[knp]" ]] && bindkey -M zed "$terminfo[knp]" __zed_pg_down + [[ ${+terminfo} = 1 ]] && { + [[ -n "$terminfo[kpp]" ]] && bindkey -M zed "$terminfo[kpp]" __zed_pg_up + [[ -n "$terminfo[knp]" ]] && bindkey -M zed "$terminfo[knp]" __zed_pg_down + [[ -n "$terminfo[khome]" ]] && bindkey -M zed "$terminfo[khome]" beginning-of-line + [[ -n "$terminfo[kend]" ]] && bindkey -M zed "$terminfo[kend]" end-of-line + + # Fallback to well known code as terminfo might be wrong (often) sometimes + bindkey -M zed "^[[H" beginning-of-line + bindkey -M zed "^[[F" end-of-line + } # Make zed-set-file-name available. # Assume it's in fpath; there's no error at this point if it isn't @@ -89,6 +106,16 @@ if (( bind )) || ! bindkey -M zed-vicmd >&/dev/null; then bindkey -N zed-vicmd vicmd bindkey -M zed-vicmd "ZZ" accept-line + [[ ${+terminfo} = 1 ]] && { + [[ -n "$terminfo[kpp]" ]] && bindkey -M zed-vicmd "$terminfo[kpp]" __zed_pg_up + [[ -n "$terminfo[knp]" ]] && bindkey -M zed-vicmd "$terminfo[knp]" __zed_pg_down + [[ -n "$terminfo[khome]" ]] && bindkey -M zed-vicmd "$terminfo[khome]" vi-beginning-of-line + [[ -n "$terminfo[kend]" ]] && bindkey -M zed-vicmd "$terminfo[kend]" vi-end-of-line + + # Fallback to well known code as terminfo might be wrong (often) sometimes + bindkey -M zed-vicmd "^[[H" vi-beginning-of-line + bindkey -M zed-vicmd "^[[F" vi-end-of-line + } fi (( bind )) && return 0 @@ -105,11 +132,11 @@ if ((fun)) then var="${(q-)1} () { }" fi - vared -M zed -m zed-vicmd var && eval function "$var" + vared -M zed -m zed-vicmd -i __zed_init var && eval function "$var" else zed_file_name=$1 [[ -f $1 ]] && var="$(<$1)" - while vared -M zed -m zed-vicmd var + while vared -M zed -m zed-vicmd -i __zed_init var do { print -r -- "$var" >| $zed_file_name diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr index e8c8e81de..705db65a7 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr @@ -81,7 +81,7 @@ else bzrbase=${bzr_info[branch_root]} ;; esac - bzrbase="$(VCS_INFO_realpath ${bzrbase})" + bzrbase=${bzrbase:P} if [ -n "${bzr_info[checkout_of_branch]}" ] && \ zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-server" diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs index ed738b98f..e9d172052 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs @@ -9,7 +9,7 @@ cvsbase="." while [[ -d "${cvsbase}/../CVS" ]]; do cvsbase="${cvsbase}/.." done -cvsbase="$(VCS_INFO_realpath ${cvsbase})" +cvsbase=${cvsbase:P} cvsbranch=$(< ./CVS/Repository) rrn=${cvsbase:t} cvsbranch=${cvsbranch##${rrn}/} diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index f3dd95dcb..c3e62db3a 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -104,16 +104,15 @@ VCS_INFO_git_getbranch () { elif [[ -d "${gitdir}/.dotest-merge" ]] ; then gitbranch="$(< ${gitdir}/.dotest-merge/head-name)" + elif gitbranch="$(${(z)gitsymref} 2> /dev/null)" ; then + elif gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --all --exact-match HEAD 2>/dev/null)" ; then + elif gitbranch="$(${vcs_comm[cmd]} describe --contains HEAD 2>/dev/null)" ; then + ## Commented out because we don't know of a case in which 'describe --contains' fails and 'name-rev --tags' succeeds. + #elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --tags HEAD 2>/dev/null)" ; then + elif gitbranch="$(${vcs_comm[cmd]} name-rev --name-only --no-undefined --always HEAD 2>/dev/null)" ; then + elif gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." ; then else - gitbranch="$(${(z)gitsymref} 2> /dev/null)" - - if [[ $? -ne 0 ]] ; then - gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --all --exact-match HEAD 2>/dev/null)" - - if [[ $? -ne 0 ]] ; then - gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." - fi - fi + # Can't happen fi return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn index e1334f661..a773a727d 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn @@ -46,7 +46,7 @@ else done fi -svnbase="$(VCS_INFO_realpath ${svnbase})" +svnbase=${svnbase:P} rrn=${svnbase:t} zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r" diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla index f015e0cce..4e9cee8b9 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla @@ -5,7 +5,7 @@ setopt localoptions extendedglob NO_shwordsplit local tlabase tlabranch -tlabase="$(VCS_INFO_realpath ${vcs_comm[basedir]})" +tlabase=${vcs_comm[basedir]:P} rrn=${tlabase:t} # tree-id gives us something like 'foo@example.com/demo--1.0--patch-4', so: tlabranch=${${"$( ${vcs_comm[cmd]} tree-id )"}/*\//} diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect index 70b0fb6fa..b20c05c9c 100644 --- a/Functions/VCS_Info/VCS_INFO_bydir_detect +++ b/Functions/VCS_Info/VCS_INFO_bydir_detect @@ -4,11 +4,11 @@ setopt localoptions NO_shwordsplit local dirname=$1 -local basedir="." realbasedir file +local basedir="." file -realbasedir="$(VCS_INFO_realpath ${basedir})" -while [[ ${realbasedir} != '/' ]]; do - [[ -r ${realbasedir} ]] || return 1 +basedir=${basedir:P} +while [[ ${basedir} != '/' ]]; do + [[ -r ${basedir} ]] || return 1 if [[ -n ${vcs_comm[detect_need_file]} ]] ; then [[ -d ${basedir}/${dirname} ]] && { for file in ${(s: :)${vcs_comm[detect_need_file]}}; do @@ -19,10 +19,9 @@ while [[ ${realbasedir} != '/' ]]; do [[ -d ${basedir}/${dirname} ]] && break fi - basedir=${basedir}/.. - realbasedir="$(VCS_INFO_realpath ${basedir})" + basedir=${basedir:h} done -[[ ${realbasedir} == "/" ]] && return 1 -vcs_comm[basedir]=${realbasedir} +[[ ${basedir} == "/" ]] && return 1 +vcs_comm[basedir]=${basedir} return 0 diff --git a/Functions/VCS_Info/VCS_INFO_realpath b/Functions/VCS_Info/VCS_INFO_realpath deleted file mode 100644 index ce4a69402..000000000 --- a/Functions/VCS_Info/VCS_INFO_realpath +++ /dev/null @@ -1,7 +0,0 @@ -## vim:ft=zsh -## Written by Frank Terbeck <ft@bewatermyfriend.org> -## Distributed under the same BSD-ish license as zsh itself. - -setopt localoptions NO_shwordsplit chaselinks -# -q to avoid chpwd() invocations -( builtin cd -q $1 2>/dev/null && pwd; ) diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index 4e9ac6c6a..d67ae6bf5 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -26,7 +26,6 @@ static_functions=( VCS_INFO_nvcsformats VCS_INFO_patch2subject VCS_INFO_quilt - VCS_INFO_realpath VCS_INFO_reposub VCS_INFO_set @@ -2,197 +2,18 @@ ZSH ON SPECIFIC ARCHITECTURES ----------------------------- -These are the OSes that zsh has been tried on. If you succeed in getting -zsh to work on an OS not listed, let us know. The information in this -list may be out of date, as the developers do not have access to all -machines. In general, GNU/Linux distributions, Solaris and Cygwin are -reasonably well covered. Please let us have any recent information -on other systems. The information for systems not known to have been -tested recently is marked as `out of date'. +This file is to record difficulties in compiling and installing zsh on +specific architectures. -On all machines if you use gcc and upgrade your OS you must rebuild gcc -after the OS upgrade. A gcc left from a previous OS may seem to work -but compiling more complex programs may fail mysteriously. +The information in this list may be out of date, as the developers do +not have access to all machines. In general, GNU/Linux distributions +and BSD derivatives including MacOS are reasonably well covered. -The format of entries is thus: +At the time of writing (2018/05/30, version 5.5.1) zsh is believed to +compile on all up-to-date Unix-like operating systems. Please let us +know of any exceptions. + +The intended format of entries is thus: Vendor: OS & version (hardware type) [zsh version tried] information - -Machines --------- - -Apple: MacOS X/Darwin 10.x - Should build `out-of-the-box'. - - For dynamic loading to work on 10.1 and 10.2, you need to use the - dlcompat library. It can be downloaded from: - http://sourceforge.net/project/showfiles.php?group_id=17203 - - The zsh/zpty library is not working on 10.1 and 10.2, but is on - 10.3. This causes the tests starting `Y' in the Test directory to - fail, even though the features to be tested are working. - - Reported to compile with no problems on 10.4. - - Compiling with GCC on 10.9.1 (Mavericks) reportedly causes a crash - due to a libiconv problem. Compile with clang instead. - - Multibyte support works; you probably wish to set the - option COMBINING_CHARS, which is not enabled by default. - Problems have been noted when outputting multibyte characters - to the terminal from a "preexec" function. - -Red Hat Inc.: Cygwin - Should build `out-of-the-box'. The compilation directory should - be on a file system mounted as binary (the mount command shows - `binmode'). There are various issues with Cygwin versions before - 1.3.2 - you are adviced to update to the latest release. - - Process substitution using <(...), >(...), =(...) may be - problematic. Different versions of zsh and Cygwin have - a different mix of issues. - - Problems handling subprocesses have been reported with Cygwin - 1.7.5. It is not currently known how the problems split between - Cygwin and zsh. - - Some of the tests in the Test subdirectory are known to fail: - this is because the UNIX environment is not completely implemented. - - Cygwin allows mount without existing mount point (e.g. - "mount //server/path /usr/src" where /usr/src does not exist). - Path completion will fail inside these mounts; make sure that - every mount point really exists. - -FreeBSD: FreeBSD 2.2.7, 3.x, 4.x, ... 7 - Should build `out-of-the-box'. On FreeBSD 2.2, dynamic loading - does not work, but it does with 3.x and later. - -HP: HP-UX 9, 10.20, 11.x (PA-RISC, Itanium) - Should build `out-of-the-box'. - - Previous problems encountered on HP-UX 11.x: - - Some of the special keys on the keyboard (backspace, delete) - have been found to stop functioning. One suggested fix is - to alter the way the curses library is linked in the Makefile. - Replacing `-lcurses' with `-lHcurses -lcurses' in the libraries - is reported to fix this on 11.0, but is no longer necessary on - more recent versions of HP-UX 11, i.e. 11.11+. - - Typical gcc installations on HP-UX use HP's linker rather than - the GNU one. Configure will fail to set up dynamic linking in - this situation. The following should allow building of modules: - DLLD=/usr/ccs/bin/ld DLLDFLAGS=-b DLCFLAGS=-fpic ./configure ... - - Compiling with gcc 2.7.1 is known to fail with header file - conflicts. Use the HP ANSI C compiler. - -IBM: AIX 3.2, 4.x, 5.x - Should build `out-of-the-box'. - - Certain features will not work, in particular --enable-cap - and --enable-zsh-mem. (The feature enabled by --enable-cap - is apparently present, however. Help getting this to work - would be appreciated.) - - On 3.2, for 64-bit integer support you need to compile with gcc, as - the native compiler does not support ANSI simultaneously with - `long long'. On 4.1, there appeared to be problems using - --enable-dynamic (the default) with gcc (version was 2.7.2.3), - though native cc works. More information about this problem - would be appreciated. - - It was reported, that at least some 4.x versions have problem - with curses - variables boolcodes and some other are declared - in term.h but missing is libcurses.a. That makes native compiler - very unhappy (GCC 3.0 apparently does not mind). Zsh now defaults - to termcap on AIX; any info about this problem is appreciated. - -Linux: Linux 2.x, 3.x (various 32-bit and 64-bit processors) - Should build `out-of-the-box'. - - The following problems should not occur with recent - distributions. - - If you are using an early minor version of libc 5, then a bug - in the auto-configuration process may cause zsh to think that - your system doesn't support the lstat function. If the configure - process reports that there is no lstat, edit config.h and change - HAVE_LSTAT to 1. libc-5.2.18 or later does not have this problem. - - Some versions of glibc2 have a conflict with <asm/resource.h> - which causes a redefinition warning on RLIM_INFINITY. This - causes configure to decide that <sys/resource.h> is not present, - which can cause compilation errors in zsh's rlimit code. The - best solution is to edit config.h after running configure and - #define HAS_SYS_RESOURCE_H. - -NetBSD: NetBSD 1.x - Should build `out-of-the-box'. - -OpenBSD: OpenBSD 2.x, 3.x - Should build `out-of-the-box'. - -OpenIndiana: OpenIndiana 151a - Problems have been reported with awk when used to generate - prototype files for building zsh. Upgrading to gawk (GNU awk) - version 4.0.0 fixes this. - -Sun: Solaris 2.x, 8, 9, ... - It is recommended that the system library version of iconv() - be used rather than libiconv since there are incompatibilities - in the way codesets are named. - - The UCB versions of the routines for reading directories are not - usable (the struct definitions are incompatible with the ones - assumed by zsh). The symptom of this is that globbed filenames in - the compiled version of zsh will be missing the first two letters. - To avoid this, make sure you compile zsh without any reference - to /usr/ucblib in your LD_LIBRARY_PATH. You can easily do this - by just unsetting LD_LIBRARY_PATH before building zsh. - - Problems were once reported using --enable-largefile (the default) to - enable large file system and integer support on Solaris 2 with gcc - before 2.95.2. Recent versions of gcc appear to be unproblematic. - -Other machines --------------- - -Zsh has previously been compiled on the following machines, but the -developers do not have direct access to them and the reports may be out -of date. Some of these OSes are now very long in the tooth. We would -be glad to receive any reports of success or failure on these OSes --- -and, of course, any others not mentioned in this file. - -Apple/NeXT OpenStep 4.2 for i386. - Reported to work at least with gcc 2.8.1 and gawk 2.15 patchlevel - 6, but not with the bundled cc 2.7.2.1 and awk. - -Cray: Unicos (C90 and T90) - Should build `out-of-the-box'. - -Data General: DG/UX 5.4R3.10 MU01 (various AViiONs) - Should build `out-of-the-box'. - -DEC: Ultrix (Alpha or DECstation) -DEC: Mach 3.0 (DECstation 5000/25) -DEC: OSF/1 1.2, 1.3, 2.0, 3.x, DEC Unix 4.x (Alpha) - -HP/Compaq: Tru64 4.x, 5.x - -Next: NextStep 3.* - Should build `out-of-the-box', but the zsh malloc routines are - not recommended. - -SCO: UnixWare 2.1.3 - Builds `out-of-the-box'. - -SGI: IRIX 6.2, 6.3, 6.5 - -SIEMENS: SINIX - -SIEMENS: Reliant UNIX - -Sun: SunOS 4.1.x diff --git a/Misc/bash2zshprompt b/Misc/bash2zshprompt index 7fc11434e..8860a53d7 100644 --- a/Misc/bash2zshprompt +++ b/Misc/bash2zshprompt @@ -1,7 +1,6 @@ #!/usr/bin/perl -w # # exceedingly ugly hack to convert bashprompt themes to zshprompt themes -# (bashprompt is at http://bash.current.nu/) # # Adam Spiers <adam@spiers.net> @@ -4,7 +4,14 @@ CHANGES FROM PREVIOUS VERSIONS OF ZSH Note also the list of incompatibilities in the README file. -Changes from %.5 to 5.5.1 +Changes from 5.5.1 to 5.5.1-test-2 +---------------------------------- + +In shell patterns, [[:blank:]] now honours the locale instead of +matching exclusively on space and tab, like for the other POSIX +character classes or for extended regular expressions. + +Changes from 5.5 to 5.5.1 ------------------------- Apart from a fix for a configuration problem finding singal names from @@ -5,13 +5,12 @@ THE Z SHELL (ZSH) Version ------- -This is version 5.5.1 of the shell. This is a stable release. There +This is version 5.5.1-test-2 of the shell. This is a test release. There are some significant bug fixes and a few user visible additions since -5.4.2 and minor fixes since 5.5. All zsh installations are encouraged -to upgrade. +5.5.1. All zsh installations are encouraged to upgrade. Note in particular the changes highlighted under "Incompatibilities since -5.4.2" below. See NEWS for more information. +5.5.1" below. See NEWS for more information. Installing Zsh -------------- @@ -32,9 +31,17 @@ Zsh is a shell with lots of features. For a list of some of these, see the file FEATURES, and for the latest changes see NEWS. For more details, see the documentation. -Incompatibilities since 5.4.2 +Incompatibilities since 5.5.1 ----------------------------- +The completion helper _remote_files, typically used after a hostname +with scp-style completion, now uses remote-files instead of files as a +tag. This makes it easier to restrict completions with the tag-order +style. + +Incompatibilities between 5.4.2 and 5.5.1 +----------------------------------------- + 1) The default build-time maximum nested function depth has been decreased from 1000 to 500 based on user experience. However, it can now be changed at run time via the variable FUNCNEST. diff --git a/Src/Modules/clone.c b/Src/Modules/clone.c index 930429248..ef6275dcf 100644 --- a/Src/Modules/clone.c +++ b/Src/Modules/clone.c @@ -69,7 +69,7 @@ bin_clone(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) dup2(ttyfd,2); if (ttyfd > 2) close(ttyfd); - closem(0); + closem(FDT_UNUSED, 0); close(coprocin); close(coprocout); /* Acquire a controlling terminal */ diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c index 6e9047bc5..be378b347 100644 --- a/Src/Modules/datetime.c +++ b/Src/Modules/datetime.c @@ -180,66 +180,30 @@ getcurrentsecs(UNUSED(Param pm)) } static double -getcurrentrealtime(Param pm) +getcurrentrealtime(UNUSED(Param pm)) { -#ifdef HAVE_CLOCK_GETTIME struct timespec now; - - if (clock_gettime(CLOCK_REALTIME, &now) < 0) { - zwarn("%s: unable to retrieve time: %e", pm->node.nam, errno); - return (double)0.0; - } - + zgettime(&now); return (double)now.tv_sec + (double)now.tv_nsec * 1e-9; -#else - struct timeval now; - struct timezone dummy_tz; - - (void)pm; - gettimeofday(&now, &dummy_tz); - - return (double)now.tv_sec + (double)now.tv_usec * 1e-6; -#endif } static char ** -getcurrenttime(Param pm) +getcurrenttime(UNUSED(Param pm)) { char **arr; char buf[DIGBUFSIZE]; - -#ifdef HAVE_CLOCK_GETTIME struct timespec now; - if (clock_gettime(CLOCK_REALTIME, &now) < 0) { - zwarn("%s: unable to retrieve time: %e", pm->node.nam, errno); - return NULL; - } - - arr = (char **)zhalloc(3 * sizeof(*arr)); - sprintf(buf, "%ld", (long)now.tv_sec); - arr[0] = dupstring(buf); - sprintf(buf, "%ld", now.tv_nsec); - arr[1] = dupstring(buf); - arr[2] = NULL; - - return arr; -#else - struct timeval now; - struct timezone dummy_tz; - - (void)pm; - gettimeofday(&now, &dummy_tz); + zgettime(&now); arr = (char **)zhalloc(3 * sizeof(*arr)); sprintf(buf, "%ld", (long)now.tv_sec); arr[0] = dupstring(buf); - sprintf(buf, "%ld", (long)now.tv_usec * 1000); + sprintf(buf, "%ld", (long)now.tv_nsec); arr[1] = dupstring(buf); arr[2] = NULL; return arr; -#endif } static struct builtin bintab[] = { diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c index 5f776f407..ed702b912 100644 --- a/Src/Modules/db_gdbm.c +++ b/Src/Modules/db_gdbm.c @@ -359,7 +359,7 @@ gdbmsetfn(Param pm, char *val) } if (val) { - pm->u.str = ztrdup(val); + pm->u.str = val; pm->node.flags |= PM_UPTODATE; } @@ -732,6 +732,9 @@ static int remove_tied_name( const char *name ) { p++; } + if (*p) + zsfree(*p); + /* Copy x+1 to x */ while (*p) { *p=*(p+1); diff --git a/Src/Modules/mathfunc.c b/Src/Modules/mathfunc.c index a7e8b294c..fc2593dca 100644 --- a/Src/Modules/mathfunc.c +++ b/Src/Modules/mathfunc.c @@ -65,6 +65,7 @@ MF_LGAMMA, MF_LOG, MF_LOG10, MF_LOG1P, +MF_LOG2, MF_LOGB, MF_NEXTAFTER, MF_RINT, @@ -93,22 +94,6 @@ MS_RAND48 * conversion), atan2. */ -/* Flags for bounds. Note these must start at 1, not 0. */ - -enum { - BF_POS = 1, /* must be positive */ - BF_NONNEG = 2, /* must be non-negative */ - BF_FRAC = 3, /* must be -1 <= x <= 1 */ - BF_GE1 = 4, /* must be >= 1 */ - BF_FRACO = 5, /* must be in open range -1 < x < 1 */ - BF_INTPOS = 6, /* must be non-integer or positive */ - BF_GTRM1 = 7, /* must be > -1 */ - BF_NONZ = 8, /* must be nonzero */ - BF_POS2 = 9 /* second argument must be positive */ -}; - -#define BFLAG(x) ((x) << 8) - /* * Flags for type of function: unlike the above, these must * be individually bit-testable. @@ -121,18 +106,18 @@ enum { TF_NOASS = 8 /* don't assign result as double */ }; -#define TFLAG(x) ((x) << 16) +#define TFLAG(x) ((x) << 8) static struct mathfunc mftab[] = { - NUMMATHFUNC("abs", math_func, 1, 1, MF_ABS | BFLAG(BF_FRAC) | + NUMMATHFUNC("abs", math_func, 1, 1, MF_ABS | TFLAG(TF_NOCONV|TF_NOASS)), - NUMMATHFUNC("acos", math_func, 1, 1, MF_ACOS | BFLAG(BF_FRAC)), - NUMMATHFUNC("acosh", math_func, 1, 1, MF_ACOSH | BFLAG(BF_GE1)), - NUMMATHFUNC("asin", math_func, 1, 1, MF_ASIN | BFLAG(BF_FRAC)), + NUMMATHFUNC("acos", math_func, 1, 1, MF_ACOS), + NUMMATHFUNC("acosh", math_func, 1, 1, MF_ACOSH), + NUMMATHFUNC("asin", math_func, 1, 1, MF_ASIN), NUMMATHFUNC("asinh", math_func, 1, 1, MF_ASINH), NUMMATHFUNC("atan", math_func, 1, 2, MF_ATAN), - NUMMATHFUNC("atanh", math_func, 1, 1, MF_ATANH | BFLAG(BF_FRACO)), + NUMMATHFUNC("atanh", math_func, 1, 1, MF_ATANH), NUMMATHFUNC("cbrt", math_func, 1, 1, MF_CBRT), NUMMATHFUNC("ceil", math_func, 1, 1, MF_CEIL), NUMMATHFUNC("copysign", math_func, 2, 2, MF_COPYSIGN), @@ -146,20 +131,20 @@ static struct mathfunc mftab[] = { NUMMATHFUNC("float", math_func, 1, 1, MF_FLOAT), NUMMATHFUNC("floor", math_func, 1, 1, MF_FLOOR), NUMMATHFUNC("fmod", math_func, 2, 2, MF_FMOD), - NUMMATHFUNC("gamma", math_func, 1, 1, MF_GAMMA | BFLAG(BF_INTPOS)), + NUMMATHFUNC("gamma", math_func, 1, 1, MF_GAMMA), NUMMATHFUNC("hypot", math_func, 2, 2, MF_HYPOT), - NUMMATHFUNC("ilogb", math_func, 1, 1, MF_ILOGB | BFLAG(BF_NONZ) | - TFLAG(TF_NOASS)), + NUMMATHFUNC("ilogb", math_func, 1, 1, MF_ILOGB | TFLAG(TF_NOASS)), NUMMATHFUNC("int", math_func, 1, 1, MF_INT | TFLAG(TF_NOASS)), NUMMATHFUNC("j0", math_func, 1, 1, MF_J0), NUMMATHFUNC("j1", math_func, 1, 1, MF_J1), NUMMATHFUNC("jn", math_func, 2, 2, MF_JN | TFLAG(TF_INT1)), NUMMATHFUNC("ldexp", math_func, 2, 2, MF_LDEXP | TFLAG(TF_INT2)), - NUMMATHFUNC("lgamma", math_func, 1, 1, MF_LGAMMA | BFLAG(BF_INTPOS)), - NUMMATHFUNC("log", math_func, 1, 1, MF_LOG | BFLAG(BF_POS)), - NUMMATHFUNC("log10", math_func, 1, 1, MF_LOG10 | BFLAG(BF_POS)), - NUMMATHFUNC("log1p", math_func, 1, 1, MF_LOG1P | BFLAG(BF_GTRM1)), - NUMMATHFUNC("logb", math_func, 1, 1, MF_LOGB | BFLAG(BF_NONZ)), + NUMMATHFUNC("lgamma", math_func, 1, 1, MF_LGAMMA), + NUMMATHFUNC("log", math_func, 1, 1, MF_LOG), + NUMMATHFUNC("log10", math_func, 1, 1, MF_LOG10), + NUMMATHFUNC("log1p", math_func, 1, 1, MF_LOG1P), + NUMMATHFUNC("log2", math_func, 1, 1, MF_LOG2), + NUMMATHFUNC("logb", math_func, 1, 1, MF_LOGB), NUMMATHFUNC("nextafter", math_func, 2, 2, MF_NEXTAFTER), #ifdef HAVE_ERAND48 STRMATHFUNC("rand48", math_string, MS_RAND48), @@ -171,17 +156,17 @@ static struct mathfunc mftab[] = { #endif NUMMATHFUNC("sin", math_func, 1, 1, MF_SIN), NUMMATHFUNC("sinh", math_func, 1, 1, MF_SINH), - NUMMATHFUNC("sqrt", math_func, 1, 1, MF_SQRT | BFLAG(BF_NONNEG)), + NUMMATHFUNC("sqrt", math_func, 1, 1, MF_SQRT), NUMMATHFUNC("tan", math_func, 1, 1, MF_TAN), NUMMATHFUNC("tanh", math_func, 1, 1, MF_TANH), - NUMMATHFUNC("y0", math_func, 1, 1, MF_Y0 | BFLAG(BF_POS)), - NUMMATHFUNC("y1", math_func, 1, 1, MF_Y1 | BFLAG(BF_POS)), - NUMMATHFUNC("yn", math_func, 2, 2, MF_YN | BFLAG(BF_POS2) | TFLAG(TF_INT1)) + NUMMATHFUNC("y0", math_func, 1, 1, MF_Y0), + NUMMATHFUNC("y1", math_func, 1, 1, MF_Y1), + NUMMATHFUNC("yn", math_func, 2, 2, MF_YN | TFLAG(TF_INT1)) }; /**/ static mnumber -math_func(char *name, int argc, mnumber *argv, int id) +math_func(UNUSED(char *name), int argc, mnumber *argv, int id) { mnumber ret; double argd = 0, argd2 = 0, retd = 0; @@ -208,49 +193,6 @@ math_func(char *name, int argc, mnumber *argv, int id) if (errflag) return ret; - if (id & 0xff00) { - int rtst = 0; - - switch ((id >> 8) & 0xff) { - case BF_POS: - rtst = (argd <= 0.0); - break; - - case BF_NONNEG: - rtst = (argd < 0.0); - break; - - case BF_FRAC: - rtst = (fabs(argd) > 1.0); - break; - - case BF_GE1: - rtst = (argd < 1.0); - break; - - case BF_FRACO: - rtst = (fabs(argd) >= 1.0); - break; - - case BF_INTPOS: - rtst = (argd <= 0 && (double)(zlong)argd == argd); - break; - - case BF_GTRM1: - rtst = (argd <= -1); - break; - - case BF_POS2: - rtst = (argd2 <= 0.0); - break; - } - - if (rtst) { - zerr("math: argument to %s out of range", name); - return ret; - } - } - switch (id & 0xff) { case MF_ABS: ret.type = argv->type; @@ -398,6 +340,14 @@ math_func(char *name, int argc, mnumber *argv, int id) retd = log1p(argd); break; + case MF_LOG2: +#ifdef HAVE_LOG2 + retd = log2(argd); +#else + retd = log(argd) / log(2); +#endif + break; + case MF_LOGB: retd = logb(argd); break; diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index 10c47d214..783c36df3 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -2190,6 +2190,7 @@ static const struct gsu_array dirs_gsu = static const struct gsu_array historywords_gsu = { histwgetfn, arrsetfn, stdunsetfn }; +/* Make sure to update autofeatures in parameter.mdd if necessary */ static struct paramdef partab[] = { SPECIALPMDEF("aliases", 0, &pmraliases_gsu, getpmralias, scanpmraliases), diff --git a/Src/Modules/parameter.mdd b/Src/Modules/parameter.mdd index a91a5dc09..f71c17a72 100644 --- a/Src/Modules/parameter.mdd +++ b/Src/Modules/parameter.mdd @@ -2,6 +2,6 @@ name=zsh/parameter link=either load=yes -autofeatures="p:parameters p:commands p:functions p:dis_functions p:funcfiletrace p:funcsourcetrace p:funcstack p:functrace p:builtins p:dis_builtins p:reswords p:dis_reswords p:patchars p:dis_patchars p:options p:modules p:dirstack p:history p:historywords p:jobtexts p:jobdirs p:jobstates p:nameddirs p:userdirs p:aliases p:dis_aliases p:galiases p:dis_galiases p:saliases p:dis_saliases" +autofeatures="p:parameters p:commands p:functions p:dis_functions p:functions_source p:dis_functions_source p:funcfiletrace p:funcsourcetrace p:funcstack p:functrace p:builtins p:dis_builtins p:reswords p:dis_reswords p:patchars p:dis_patchars p:options p:modules p:dirstack p:history p:historywords p:jobtexts p:jobdirs p:jobstates p:nameddirs p:userdirs p:usergroups p:aliases p:dis_aliases p:galiases p:dis_galiases p:saliases p:dis_saliases" objects="parameter.o" diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c index 15ee34bc8..6289e003e 100644 --- a/Src/Modules/pcre.c +++ b/Src/Modules/pcre.c @@ -380,6 +380,7 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func)) if (ovec) zfree(ovec, ovecsize*sizeof(int)); + zsfree(plaintext); return return_value; } diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c index 66baa1292..50a6a9bb2 100644 --- a/Src/Modules/stat.c +++ b/Src/Modules/stat.c @@ -188,7 +188,7 @@ static char *timefmt; /**/ static void -stattimeprint(time_t tim, char *outbuf, int flags) +stattimeprint(time_t tim, long nsecs, char *outbuf, int flags) { if (flags & STF_RAW) { sprintf(outbuf, "%ld", (unsigned long)tim); @@ -199,7 +199,7 @@ stattimeprint(time_t tim, char *outbuf, int flags) char *oend = outbuf + strlen(outbuf); /* Where the heck does "40" come from? */ int len = ztrftime(oend, 40, timefmt, (flags & STF_GMT) ? gmtime(&tim) : - localtime(&tim), 0L); + localtime(&tim), nsecs); if (len > 0) metafy(oend, len, META_NOALLOC); if (flags & STF_RAW) @@ -291,15 +291,27 @@ statprint(struct stat *sbuf, char *outbuf, char *fname, int iwhich, int flags) break; case ST_ATIM: - stattimeprint(sbuf->st_atime, optr, flags); +#ifdef GET_ST_ATIME_NSEC + stattimeprint(sbuf->st_atime, GET_ST_ATIME_NSEC(*sbuf), optr, flags); +#else + stattimeprint(sbuf->st_atime, 0L, optr, flags); +#endif break; case ST_MTIM: - stattimeprint(sbuf->st_mtime, optr, flags); +#ifdef GET_ST_MTIME_NSEC + stattimeprint(sbuf->st_mtime, GET_ST_MTIME_NSEC(*sbuf), optr, flags); +#else + stattimeprint(sbuf->st_mtime, 0L, optr, flags); +#endif break; case ST_CTIM: - stattimeprint(sbuf->st_ctime, optr, flags); +#ifdef GET_ST_CTIME_NSEC + stattimeprint(sbuf->st_ctime, GET_ST_CTIME_NSEC(*sbuf), optr, flags); +#else + stattimeprint(sbuf->st_ctime, 0L, optr, flags); +#endif break; case ST_BLKSIZE: diff --git a/Src/Modules/system.c b/Src/Modules/system.c index 9fd4d2583..7a4f4ee13 100644 --- a/Src/Modules/system.c +++ b/Src/Modules/system.c @@ -772,6 +772,8 @@ fillpmsysparams(Param pm, const char *name) num = (int)getpid(); } else if (!strcmp(name, "ppid")) { num = (int)getppid(); + } else if (!strcmp(name, "procsubstpid")) { + num = (int)procsubstpid; } else { pm->u.str = dupstring(""); pm->node.flags |= PM_UNSET; @@ -805,6 +807,8 @@ scanpmsysparams(UNUSED(HashTable ht), ScanFunc func, int flags) func(&spm.node, flags); fillpmsysparams(&spm, "ppid"); func(&spm.node, flags); + fillpmsysparams(&spm, "procsubstpid"); + func(&spm.node, flags); } static struct mathfunc mftab[] = { diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c index 60a6e138a..af4009a3a 100644 --- a/Src/Modules/termcap.c +++ b/Src/Modules/termcap.c @@ -345,16 +345,7 @@ int boot_(UNUSED(Module m)) { #ifdef HAVE_TGETENT -# ifdef HAVE_SETUPTERM - int errret; - - /* - * Just because we can't set up the terminal doesn't - * mean the modules hasn't booted---TERM may change, - * and it should be handled dynamically---so ignore errors here. - */ - (void)setupterm((char *)0, 1, &errret); -# endif + zsetupterm(); #endif return 0; } @@ -363,6 +354,9 @@ boot_(UNUSED(Module m)) int cleanup_(Module m) { +#ifdef HAVE_TGETENT + zdeleteterm(); +#endif return setfeatureenables(m, &module_features, NULL); } diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c index bbd325899..4596b41d2 100644 --- a/Src/Modules/terminfo.c +++ b/Src/Modules/terminfo.c @@ -338,16 +338,7 @@ int boot_(UNUSED(Module m)) { #ifdef USE_TERMINFO_MODULE -# ifdef HAVE_SETUPTERM - int errret; - - /* - * Just because we can't set up the terminal doesn't - * mean the modules hasn't booted---TERM may change, - * and it should be handled dynamically---so ignore errors here. - */ - (void)setupterm((char *)0, 1, &errret); -# endif + zsetupterm(); #endif return 0; @@ -357,6 +348,9 @@ boot_(UNUSED(Module m)) int cleanup_(Module m) { +#ifdef USE_TERMINFO_MODULE + zdeleteterm(); +#endif return setfeatureenables(m, &module_features, NULL); } diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index 24f4b4200..4aaa1f072 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -362,7 +362,7 @@ static jmp_buf zfalrmbuf; /* The signal handler itself */ /**/ -static RETSIGTYPE +static void zfhandler(int sig) { if (sig == SIGALRM) { diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c index 1c93a1d02..2f83f7ce6 100644 --- a/Src/Modules/zpty.c +++ b/Src/Modules/zpty.c @@ -400,7 +400,7 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock) dup2(slave, 1); dup2(slave, 2); - closem(0); + closem(FDT_UNUSED, 0); close(slave); close(master); close(coprocin); diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 52b0c173f..8eca39447 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -1610,9 +1610,11 @@ set_comp_sep(void) inpush(dupstrspace(tmp), 0, NULL); zlemetaline = tmp; /* - * Length of temporary string, calculated above. + * tl is the length of temporary string, calculated above. + * It seems zlemetall need not include the 'x' added at the cursor. + * addedx is taken care of in function gotword() (lex.c). */ - zlemetall = tl; + zlemetall = tl - addedx; strinbeg(0); noaliases = 1; do { @@ -1638,7 +1640,7 @@ set_comp_sep(void) p[-1] = '\0'; } } - if (tok == ENDINPUT || tok == LEXERR) + if (tok == ENDINPUT) break; if (tokstr && *tokstr) { for (p = tokstr; dq && *p; p++) { @@ -1667,9 +1669,9 @@ set_comp_sep(void) if (!got && !lexflags) { DPUTS(!p, "no current word in substr"); got = 1; - cur = i; - swb = wb - 1 - dq - sq - dolq; - swe = we - 1 - dq - sq - dolq; + cur = countlinknodes(foo) - 1; /* cur is 0 offset */ + swb = wb - dq - sq - dolq; + swe = we - dq - sq - dolq; sqq = lsq; soffs = zlemetacs - swb - css; DPUTS2(p[soffs] != 'x', "expecting 'x' at offset %d of \"%s\"", @@ -1901,7 +1903,11 @@ set_comp_sep(void) p = compwords[i] = (char *) getdata(n); untokenize(p); } - compcurrent = cur + 1; + /* The current position shouldn't exceed the new word count */ + if ((compcurrent = cur + 1) > i) { + DPUTS2(1, "compcurrent=%d > number_of_words=%d", compcurrent, i); + compcurrent = i; + } compwords[i] = NULL; } instring = ois; @@ -3550,6 +3556,8 @@ freematches(Cmgroup g, int cm) } free(g->expls); } + if (g->widths) + free(g->widths); zsfree(g->name); free(g); diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c index be2b062b0..db70e7d7e 100644 --- a/Src/Zle/zle_main.c +++ b/Src/Zle/zle_main.c @@ -58,6 +58,11 @@ mod_export int incompctlfunc; /**/ mod_export int hascompmod; +/* Increment for each nested recursive-edit */ + +/**/ +mod_export int zle_recursive; + /* ZLRF_* flags passed to zleread() */ /**/ @@ -631,6 +636,8 @@ raw_getbyte(long do_keytmout, char *cptr) continue; } if (selret == 0) { + zlong save_lastval; + /* * Nothing ready and no error, so we timed out. */ @@ -648,6 +655,7 @@ raw_getbyte(long do_keytmout, char *cptr) break; case ZTM_FUNC: + save_lastval = lastval; while (firstnode(timedfns)) { Timedfn tfdat = (Timedfn)getdata(firstnode(timedfns)); /* @@ -661,6 +669,7 @@ raw_getbyte(long do_keytmout, char *cptr) break; tfdat->func(); } + lastval = save_lastval; /* Function may have messed up the display */ if (resetneeded) zrefresh(); @@ -800,6 +809,8 @@ raw_getbyte(long do_keytmout, char *cptr) } # endif } + /* If looping, need to recalculate timeout */ + calc_timeout(&tmout, do_keytmout); } # ifdef HAVE_POLL zfree(fds, sizeof(struct pollfd) * nfds); @@ -1648,6 +1659,7 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func)) Param pm = 0; int ifl; int type = PM_SCALAR, obreaks = breaks, haso = 0, oSHTTY = 0; + int warn_flags; char *p1, *p2, *main_keymapname, *vicmd_keymapname, *init, *finish; Keymap main_keymapsave = NULL, vicmd_keymapsave = NULL; FILE *oshout = NULL; @@ -1661,6 +1673,7 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func)) return 1; } + warn_flags = OPT_ISSET(ops, 'g') ? 0 : ASSPM_WARN; if (OPT_ISSET(ops,'A')) { if (OPT_ISSET(ops, 'a')) @@ -1841,11 +1854,11 @@ bin_vared(char *name, char **args, Options ops, UNUSED(int func)) a = spacesplit(t, 1, 0, 1); zsfree(t); if (PM_TYPE(pm->node.flags) == PM_ARRAY) - setaparam(args[0], a); + assignaparam(args[0], a, warn_flags); else sethparam(args[0], a); } else - setsparam(args[0], t); + assignsparam(args[0], t, warn_flags); unqueue_signals(); return 0; } @@ -1933,6 +1946,8 @@ recursiveedit(UNUSED(char **args)) int locerror; int q = queue_signal_level(); + ++zle_recursive; + /* zlecore() expects to be entered with signal queue disabled */ dont_queue_signals(); @@ -1942,6 +1957,8 @@ recursiveedit(UNUSED(char **args)) restore_queue_signals(q); + --zle_recursive; + locerror = errflag ? 1 : 0; errflag = done = eofsent = 0; @@ -2144,7 +2161,7 @@ zle_main_entry(int cmd, va_list ap) static struct builtin bintab[] = { BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaM:ldDANmrsLRp", NULL), - BUILTIN("vared", 0, bin_vared, 1, 1, 0, "aAcef:hi:M:m:p:r:t:", NULL), + BUILTIN("vared", 0, bin_vared, 1, 1, 0, "aAcef:ghi:M:m:p:r:t:", NULL), BUILTIN("zle", 0, bin_zle, 0, -1, 0, "aAcCDfFgGIKlLmMNrRTUw", NULL), }; diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c index f3112165a..9f4fb5ac2 100644 --- a/Src/Zle/zle_params.c +++ b/Src/Zle/zle_params.c @@ -93,6 +93,8 @@ static const struct gsu_integer numeric_gsu = { get_numeric, set_numeric, unset_numeric }; static const struct gsu_integer pending_gsu = { get_pending, NULL, zleunsetfn }; +static const struct gsu_integer recursive_gsu = +{ get_recursive, NULL, zleunsetfn }; static const struct gsu_integer region_active_gsu = { get_region_active, set_region_active, zleunsetfn }; static const struct gsu_integer undo_change_no_gsu = @@ -180,6 +182,7 @@ static struct zleparam { { "SUFFIX_START", PM_INTEGER, GSU(suffixstart_gsu), NULL }, { "SUFFIX_END", PM_INTEGER, GSU(suffixend_gsu), NULL }, { "SUFFIX_ACTIVE", PM_INTEGER | PM_READONLY, GSU(suffixactive_gsu), NULL }, + { "ZLE_RECURSIVE", PM_INTEGER | PM_READONLY, GSU(recursive_gsu), NULL }, { "ZLE_STATE", PM_SCALAR | PM_READONLY, GSU(zle_state_gsu), NULL }, { NULL, 0, NULL, NULL } }; @@ -528,6 +531,13 @@ get_pending(UNUSED(Param pm)) /**/ static zlong +get_recursive(UNUSED(Param pm)) +{ + return zle_recursive; +} + +/**/ +static zlong get_yankstart(UNUSED(Param pm)) { return yankb; @@ -819,7 +829,7 @@ get_registers(UNUSED(HashTable ht), const char *name) /**/ static void -set_registers(UNUSED(Param pm), HashTable ht) +set_registers(Param pm, HashTable ht) { int i; HashNode hn; diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c index 5601c1178..6b892b822 100644 --- a/Src/Zle/zle_thingy.c +++ b/Src/Zle/zle_thingy.c @@ -725,13 +725,13 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func)) remetafy = 0; while (*args && **args == '-') { + char skip_this_arg[2] = "x"; char *num; if (!args[0][1] || args[0][1] == '-') { args++; break; } while (*++(*args)) { - char skip_this_arg[2] = "x"; switch (**args) { case 'n': num = args[0][1] ? args[0]+1 : args[1]; diff --git a/Src/builtin.c b/Src/builtin.c index 73cfe7ad1..93fa9112c 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -3199,7 +3199,7 @@ bin_functions(char *name, char **argv, Options ops, int func) pflags |= PRINT_NAMEONLY; if (OPT_MINUS(ops,'M') || OPT_PLUS(ops,'M')) { - MathFunc p, q; + MathFunc p, q, prev; /* * Add/remove/list function as mathematical. */ @@ -3331,15 +3331,10 @@ bin_functions(char *name, char **argv, Options ops, int func) p->maxargs = maxargs; queue_signals(); - for (q = mathfuncs; q; q = q->next) { + for (q = mathfuncs, prev = NULL; q; prev = q, q = q->next) { if (!strcmp(q->name, funcname)) { - unqueue_signals(); - zwarnnam(name, "-M %s: function already exists", - funcname); - zsfree(p->name); - zsfree(p->module); - zfree(p, sizeof(struct mathfunc)); - return 1; + removemathfunc(prev, q); + break; } } @@ -5234,8 +5229,14 @@ bin_print(char *name, char **args, Options ops, int func) errflag &= ~ERRFLAG_ERROR; ret = 1; } - print_val(doubleval) - break; + /* force consistent form for Inf/NaN output */ + if (isnan(doubleval)) + count += fputs("nan", fout); + else if (isinf(doubleval)) + count += fputs((doubleval < 0.0) ? "-inf" : "inf", fout); + else + print_val(doubleval) + break; case 3: #ifdef ZSH_64_BIT_UTYPE *d++ = 'l'; @@ -5317,8 +5318,13 @@ bin_shift(char *name, char **argv, Options ops, UNUSED(int func)) /* optional argument can be either numeric or an array */ queue_signals(); - if (*argv && !getaparam(*argv)) + if (*argv && !getaparam(*argv)) { num = mathevali(*argv++); + if (errflag) { + unqueue_signals(); + return 1; + } + } if (num < 0) { unqueue_signals(); diff --git a/Src/compat.c b/Src/compat.c index a130d9264..7b5c4411c 100644 --- a/Src/compat.c +++ b/Src/compat.c @@ -94,6 +94,39 @@ gettimeofday(struct timeval *tv, struct timezone *tz) #endif +/* Provide clock time with nanoseconds */ + +/**/ +mod_export int +zgettime(struct timespec *ts) +{ + int ret = -1; + +#ifdef HAVE_CLOCK_GETTIME + struct timespec dts; + if (clock_gettime(CLOCK_REALTIME, &dts) < 0) { + zwarn("unable to retrieve time: %e", errno); + ret--; + } else { + ret++; + ts->tv_sec = (time_t) dts.tv_sec; + ts->tv_nsec = (long) dts.tv_nsec; + } +#endif + + if (ret) { + struct timeval dtv; + struct timezone dtz; + gettimeofday(&dtv, &dtz); + ret++; + ts->tv_sec = (time_t) dtv.tv_sec; + ts->tv_nsec = (long) dtv.tv_usec * 1000; + } + + return ret; +} + + /* compute the difference between two calendar times */ /**/ diff --git a/Src/exec.c b/Src/exec.c index 216057aa7..615a5086f 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -174,6 +174,11 @@ mod_export int zleactive; /**/ pid_t cmdoutpid; +/* pid of last process started by <(...), >(...) */ + +/**/ +mod_export pid_t procsubstpid; + /* exit status of process undergoing 'process substitution' */ /**/ @@ -698,7 +703,7 @@ execute(LinkList args, int flags, int defpath) * Note that we don't close fd's attached to process substitution * here, which should be visible to external processes. */ - closem(FDT_XTRACE); + closem(FDT_XTRACE, 0); #ifndef FD_CLOEXEC if (SHTTY != -1) { close(SHTTY); @@ -1878,8 +1883,6 @@ static void execpline2(Estate state, wordcode pcode, int how, int input, int output, int last1) { - pid_t pid; - int pipes[2]; struct execcmd_params eparams; if (breaks || retflag) @@ -1900,65 +1903,21 @@ execpline2(Estate state, wordcode pcode, } if (WC_PIPE_TYPE(pcode) == WC_PIPE_END) { execcmd_analyse(state, &eparams); - execcmd_exec(state, &eparams, input, output, how, last1 ? 1 : 2); + execcmd_exec(state, &eparams, input, output, how, last1 ? 1 : 2, -1); } else { + int pipes[2]; int old_list_pipe = list_pipe; - int subsh_close = -1; - Wordcode next = state->pc + (*state->pc), start_pc; + Wordcode next = state->pc + (*state->pc); - start_pc = ++state->pc; + ++state->pc; execcmd_analyse(state, &eparams); if (mpipe(pipes) < 0) { /* FIXME */ } - /* if we are doing "foo | bar" where foo is a current * - * shell command, do foo in a subshell and do the * - * rest of the pipeline in the current shell. */ - if ((eparams.type >= WC_CURSH || !eparams.args) - && (how & Z_SYNC)) { - int synch[2]; - struct timeval bgtime; - - if (pipe(synch) < 0) { - zerr("pipe failed: %e", errno); - lastval = 1; - errflag |= ERRFLAG_ERROR; - return; - } else if ((pid = zfork(&bgtime)) == -1) { - close(synch[0]); - close(synch[1]); - lastval = 1; - errflag |= ERRFLAG_ERROR; - return; - } else if (pid) { - char dummy, *text; - - text = getjobtext(state->prog, start_pc); - addproc(pid, text, 0, &bgtime); - close(synch[1]); - read_loop(synch[0], &dummy, 1); - close(synch[0]); - } else { - zclose(pipes[0]); - close(synch[0]); - entersubsh(((how & Z_ASYNC) ? ESUB_ASYNC : 0) - | ESUB_PGRP | ESUB_KEEPTRAP); - close(synch[1]); - if (sigtrapped[SIGEXIT]) - { - unsettrap(SIGEXIT); - } - execcmd_exec(state, &eparams, input, pipes[1], how, 1); - _exit(lastval); - } - } else { - /* otherwise just do the pipeline normally. */ - addfilelist(NULL, pipes[0]); - subsh_close = pipes[0]; - execcmd_exec(state, &eparams, input, pipes[1], how, 0); - } + addfilelist(NULL, pipes[0]); + execcmd_exec(state, &eparams, input, pipes[1], how, 0, pipes[0]); zclose(pipes[1]); state->pc = next; @@ -1969,8 +1928,6 @@ execpline2(Estate state, wordcode pcode, execpline2(state, *state->pc++, how, pipes[0], output, last1); list_pipe = old_list_pipe; cmdpop(); - if (subsh_close != pipes[0]) - zclose(pipes[0]); } } @@ -2707,6 +2664,85 @@ static void execcmd_getargs(LinkList preargs, LinkList args, int expand) } } +/**/ +static int +execcmd_fork(Estate state, int how, int type, Wordcode varspc, + LinkList *filelistp, char *text, int oautocont, + int close_if_forked) +{ + pid_t pid; + int synch[2], flags; + char dummy; + struct timeval bgtime; + + child_block(); + + if (pipe(synch) < 0) { + zerr("pipe failed: %e", errno); + return -1; + } else if ((pid = zfork(&bgtime)) == -1) { + close(synch[0]); + close(synch[1]); + lastval = 1; + errflag |= ERRFLAG_ERROR; + return -1; + } + if (pid) { + close(synch[1]); + read_loop(synch[0], &dummy, 1); + close(synch[0]); + if (how & Z_ASYNC) { + lastpid = (zlong) pid; + } else if (!jobtab[thisjob].stty_in_env && varspc) { + /* search for STTY=... */ + Wordcode p = varspc; + wordcode ac; + + while (wc_code(ac = *p) == WC_ASSIGN) { + if (!strcmp(ecrawstr(state->prog, p + 1, NULL), "STTY")) { + jobtab[thisjob].stty_in_env = 1; + break; + } + p += (WC_ASSIGN_TYPE(ac) == WC_ASSIGN_SCALAR ? + 3 : WC_ASSIGN_NUM(ac) + 2); + } + } + addproc(pid, text, 0, &bgtime); + if (oautocont >= 0) + opts[AUTOCONTINUE] = oautocont; + pipecleanfilelist(jobtab[thisjob].filelist, 1); + return pid; + } + + /* pid == 0 */ + close(synch[0]); + flags = ((how & Z_ASYNC) ? ESUB_ASYNC : 0) | ESUB_PGRP; + if ((type != WC_SUBSH) && !(how & Z_ASYNC)) + flags |= ESUB_KEEPTRAP; + if (type == WC_SUBSH && !(how & Z_ASYNC)) + flags |= ESUB_JOB_CONTROL; + *filelistp = jobtab[thisjob].filelist; + entersubsh(flags); + close(synch[1]); + zclose(close_if_forked); + + if (sigtrapped[SIGINT] & ZSIG_IGNORED) + holdintr(); + /* + * EXIT traps shouldn't be called even if we forked to run + * shell code as this isn't the main shell. + */ + sigtrapped[SIGEXIT] = 0; +#ifdef HAVE_NICE + /* Check if we should run background jobs at a lower priority. */ + if ((how & Z_ASYNC) && isset(BGNICE)) + if (nice(5) < 0) + zwarn("nice(5) failed: %e", errno); +#endif /* HAVE_NICE */ + + return 0; +} + /* * Execute a command at the lowest level of the hierarchy. */ @@ -2714,7 +2750,7 @@ static void execcmd_getargs(LinkList preargs, LinkList args, int expand) /**/ static void execcmd_exec(Estate state, Execcmd_params eparams, - int input, int output, int how, int last1) + int input, int output, int how, int last1, int close_if_forked) { HashNode hn = NULL; LinkList filelist = NULL; @@ -2724,7 +2760,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, char *text; int save[10]; int fil, dfil, is_cursh, do_exec = 0, redir_err = 0, i; - int nullexec = 0, magic_assign = 0, forked = 0; + int nullexec = 0, magic_assign = 0, forked = 0, old_lastval; int is_shfunc = 0, is_builtin = 0, is_exec = 0, use_defpath = 0; /* Various flags to the command. */ int cflags = 0, orig_cflags = 0, checked = 0, oautocont = -1; @@ -2749,6 +2785,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, * If assignment but no command get the status from variable * assignment. */ + old_lastval = lastval; if (!args && varspc) lastval = errflag ? errflag : cmdoutval; /* @@ -2791,6 +2828,29 @@ execcmd_exec(Estate state, Execcmd_params eparams, pushnode(args, dupstring("fg")); } + if ((how & Z_ASYNC) || output) { + /* + * If running in the background, or not the last command in a + * pipeline, we don't need any of the rest of this function to + * affect the state in the main shell, so fork immediately. + * + * In other cases we may need to process the command line + * a bit further before we make the decision. + */ + text = getjobtext(state->prog, eparams->beg); + switch (execcmd_fork(state, how, type, varspc, &filelist, + text, oautocont, close_if_forked)) { + case -1: + goto fatal; + case 0: + break; + default: + return; + } + last1 = forked = 1; + } else + text = NULL; + /* Check if it's a builtin needing automatic MAGIC_EQUALS_SUBST * * handling. Things like typeset need this. We can't detect the * * command if it contains some tokens (e.g. x=ex; ${x}port), so this * @@ -2799,7 +2859,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, if ((type == WC_SIMPLE || type == WC_TYPESET) && args) { /* * preargs contains args that have been expanded by prefork. - * Running execcmd_getargs() causes the any argument available + * Running execcmd_getargs() causes any argument available * in args to be exanded where necessary and transferred to * preargs. We call execcmd_getargs() every time we need to * analyse an argument not available in preargs, though there is @@ -2846,8 +2906,11 @@ execcmd_exec(Estate state, Execcmd_params eparams, is_builtin = 1; /* autoload the builtin if necessary */ - if (!(hn = resolvebuiltin(cmdarg, hn))) + if (!(hn = resolvebuiltin(cmdarg, hn))) { + if (forked) + _exit(lastval); return; + } if (type != WC_TYPESET) magic_assign = (hn->flags & BINF_MAGICEQUALS); break; @@ -3025,6 +3088,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, zerr("unknown exec flag -%c", *cmdopt); lastval = 1; errflag |= ERRFLAG_ERROR; + if (forked) + _exit(lastval); return; } } @@ -3074,6 +3139,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, esprefork = (magic_assign || (isset(MAGICEQUALSUBST) && type != WC_TYPESET)) ? PREFORK_TYPESET : 0; + if (args) { if (eparams->htok) prefork(args, esprefork, NULL); @@ -3117,6 +3183,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, zerr("redirection with no command"); lastval = 1; errflag |= ERRFLAG_ERROR; + if (forked) + _exit(lastval); return; } else if (!nullcmd || !*nullcmd || opts[SHNULLCMD]) { if (!args) @@ -3135,6 +3203,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, } } else if ((cflags & BINF_PREFIX) && (cflags & BINF_COMMAND)) { lastval = 0; + if (forked) + _exit(lastval); return; } else { /* @@ -3145,11 +3215,16 @@ execcmd_exec(Estate state, Execcmd_params eparams, if (badcshglob == 1) { zerr("no match"); lastval = 1; + if (forked) + _exit(lastval); return; } cmdoutval = use_cmdoutval ? lastval : 0; - if (varspc) + if (varspc) { + /* Make sure $? is still correct for assignment */ + lastval = old_lastval; addvars(state, varspc, 0); + } if (errflag) lastval = 1; else @@ -3158,12 +3233,16 @@ execcmd_exec(Estate state, Execcmd_params eparams, fputc('\n', xtrerr); fflush(xtrerr); } + if (forked) + _exit(lastval); return; } } else if (isset(RESTRICTED) && (cflags & BINF_EXEC) && do_exec) { zerrnam("exec", "%s: restricted", (char *) getdata(firstnode(args))); lastval = 1; + if (forked) + _exit(lastval); return; } @@ -3198,6 +3277,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, lastval = 1; if (oautocont >= 0) opts[AUTOCONTINUE] = oautocont; + if (forked) + _exit(lastval); return; } break; @@ -3206,8 +3287,11 @@ execcmd_exec(Estate state, Execcmd_params eparams, is_builtin = 1; /* autoload the builtin if necessary */ - if (!(hn = resolvebuiltin(cmdarg, hn))) + if (!(hn = resolvebuiltin(cmdarg, hn))) { + if (forked) + _exit(lastval); return; + } break; } cflags &= ~BINF_BUILTIN & ~BINF_COMMAND; @@ -3222,15 +3306,15 @@ execcmd_exec(Estate state, Execcmd_params eparams, lastval = 1; if (oautocont >= 0) opts[AUTOCONTINUE] = oautocont; + if (forked) + _exit(lastval); return; } /* Get the text associated with this command. */ - if ((how & Z_ASYNC) || + if (!text && (!sfcontext && (jobbing || (how & Z_TIMED)))) text = getjobtext(state->prog, eparams->beg); - else - text = NULL; /* * Set up special parameter $_ @@ -3301,6 +3385,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, lastval = 1; if (oautocont >= 0) opts[AUTOCONTINUE] = oautocont; + if (forked) + _exit(lastval); return; } } @@ -3329,6 +3415,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, lastval = 1; if (oautocont >= 0) opts[AUTOCONTINUE] = oautocont; + if (forked) + _exit(lastval); return; } @@ -3378,7 +3466,8 @@ execcmd_exec(Estate state, Execcmd_params eparams, /************************************************************************** * Do we need to fork? We need to fork if: * - * 1) The command is supposed to run in the background. (or) * + * 1) The command is supposed to run in the background. This * + * case is now handled above (forked = 1 here). (or) * * 2) There is no `exec' flag, and either: * * a) This is a builtin or shell function with output piped somewhere. * * b) This is an external command and we can't do a `fake exec'. * @@ -3397,99 +3486,45 @@ execcmd_exec(Estate state, Execcmd_params eparams, * current shell. * **************************************************************************/ - if ((how & Z_ASYNC) || - (!do_exec && - (((is_builtin || is_shfunc) && output) || - (!is_cursh && (last1 != 1 || nsigtrapped || havefiles() || - fdtable_flocks))))) { - - pid_t pid; - int synch[2], flags; - char dummy; - struct timeval bgtime; - - child_block(); - - if (pipe(synch) < 0) { - zerr("pipe failed: %e", errno); - goto fatal; - } else if ((pid = zfork(&bgtime)) == -1) { - close(synch[0]); - close(synch[1]); - lastval = 1; - errflag |= ERRFLAG_ERROR; - goto fatal; - } - if (pid) { - - close(synch[1]); - read_loop(synch[0], &dummy, 1); - close(synch[0]); - if (how & Z_ASYNC) { - lastpid = (zlong) pid; - } else if (!jobtab[thisjob].stty_in_env && varspc) { - /* search for STTY=... */ - Wordcode p = varspc; - wordcode ac; - - while (wc_code(ac = *p) == WC_ASSIGN) { - if (!strcmp(ecrawstr(state->prog, p + 1, NULL), "STTY")) { - jobtab[thisjob].stty_in_env = 1; - break; - } - p += (WC_ASSIGN_TYPE(ac) == WC_ASSIGN_SCALAR ? - 3 : WC_ASSIGN_NUM(ac) + 2); - } + if (!forked) { + if (!do_exec && + (((is_builtin || is_shfunc) && output) || + (!is_cursh && (last1 != 1 || nsigtrapped || havefiles() || + fdtable_flocks)))) { + switch (execcmd_fork(state, how, type, varspc, &filelist, + text, oautocont, close_if_forked)) { + case -1: + goto fatal; + case 0: + break; + default: + return; } - addproc(pid, text, 0, &bgtime); - if (oautocont >= 0) - opts[AUTOCONTINUE] = oautocont; - pipecleanfilelist(jobtab[thisjob].filelist, 1); - return; - } - /* pid == 0 */ - close(synch[0]); - flags = ((how & Z_ASYNC) ? ESUB_ASYNC : 0) | ESUB_PGRP; - if ((type != WC_SUBSH) && !(how & Z_ASYNC)) - flags |= ESUB_KEEPTRAP; - if (type == WC_SUBSH && !(how & Z_ASYNC)) - flags |= ESUB_JOB_CONTROL; - filelist = jobtab[thisjob].filelist; - entersubsh(flags); - close(synch[1]); - forked = 1; - if (sigtrapped[SIGINT] & ZSIG_IGNORED) - holdintr(); -#ifdef HAVE_NICE - /* Check if we should run background jobs at a lower priority. */ - if ((how & Z_ASYNC) && isset(BGNICE)) - if (nice(5) < 0) - zwarn("nice(5) failed: %e", errno); -#endif /* HAVE_NICE */ - - } else if (is_cursh) { - /* This is a current shell procedure that didn't need to fork. * - * This includes current shell procedures that are being exec'ed, * - * as well as null execs. */ - jobtab[thisjob].stat |= STAT_CURSH; - if (!jobtab[thisjob].procs) - jobtab[thisjob].stat |= STAT_NOPRINT; - if (is_builtin) - jobtab[thisjob].stat |= STAT_BUILTIN; - } else { - /* This is an exec (real or fake) for an external command. * - * Note that any form of exec means that the subshell is fake * - * (but we may be in a subshell already). */ - is_exec = 1; - /* - * If we are in a subshell environment anyway, say we're forked, - * even if we're actually not forked because we know the - * subshell is exiting. This ensures SHLVL reflects the current - * shell, and also optimises out any save/restore we'd need to - * do if we were returning to the main shell. - */ - if (type == WC_SUBSH) forked = 1; + } else if (is_cursh) { + /* This is a current shell procedure that didn't need to fork. * + * This includes current shell procedures that are being exec'ed, * + * as well as null execs. */ + jobtab[thisjob].stat |= STAT_CURSH; + if (!jobtab[thisjob].procs) + jobtab[thisjob].stat |= STAT_NOPRINT; + if (is_builtin) + jobtab[thisjob].stat |= STAT_BUILTIN; + } else { + /* This is an exec (real or fake) for an external command. * + * Note that any form of exec means that the subshell is fake * + * (but we may be in a subshell already). */ + is_exec = 1; + /* + * If we are in a subshell environment anyway, say we're forked, + * even if we're actually not forked because we know the + * subshell is exiting. This ensures SHLVL reflects the current + * shell, and also optimises out any save/restore we'd need to + * do if we were returning to the main shell. + */ + if (type == WC_SUBSH) + forked = 1; + } } if ((esglob = !(cflags & BINF_NOGLOB)) && args && eparams->htok) { @@ -3903,7 +3938,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, LinkList assigns = (LinkList)0; int postassigns = eparams->postassigns; if (forked) - closem(FDT_INTERNAL); + closem(FDT_INTERNAL, 0); if (postassigns) { Wordcode opc = state->pc; state->pc = eparams->assignspc; @@ -4089,7 +4124,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, if (errflag) _exit(1); } - closem(FDT_INTERNAL); + closem(FDT_INTERNAL, 0); if (coprocin != -1) { zclose(coprocin); coprocin = -1; @@ -4151,7 +4186,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, for (i = 0; i < 10; i++) if (fdtable[i] != FDT_UNUSED) close(i); - closem(FDT_UNUSED); + closem(FDT_UNUSED, 1); if (thisjob != -1) waitjobs(); _exit(lastval); @@ -4327,16 +4362,24 @@ fixfds(int *save) * * Close any that are marked as used if "how" is FDT_UNUSED, else * close any with the value "how". + * + * If "all" is zero, we'll skip cases where we need the file + * descriptor to be visible externally. */ /**/ mod_export void -closem(int how) +closem(int how, int all) { int i; for (i = 10; i <= max_zsh_fd; i++) if (fdtable[i] != FDT_UNUSED && + /* + * Process substitution needs to be visible to user; + * fd's are explicitly cleaned up by filelist handling. + */ + (all || fdtable[i] != FDT_PROC_SUBST) && (how == FDT_UNUSED || (fdtable[i] & FDT_TYPE_MASK) == how)) { if (i == SHTTY) SHTTY = -1; @@ -4375,7 +4418,9 @@ gethere(char **strp, int typ) while ((c = hgetc()) == '\t' && strip) ; for (;;) { - if (bptr == buf + bsiz) { + if (bptr >= buf + bsiz - 2) { + ptrdiff_t toff = t - buf; + ptrdiff_t bptroff = bptr - buf; char *newbuf = realloc(buf, 2 * bsiz); if (!newbuf) { /* out of memory */ @@ -4383,20 +4428,20 @@ gethere(char **strp, int typ) return NULL; } buf = newbuf; - t = buf + bsiz - (bptr - t); - bptr = buf + bsiz; + t = buf + toff; + bptr = buf + bptroff; bsiz *= 2; } - if (lexstop) + if (lexstop || c == '\n') break; - if (c == '\n') { - if (!qt && bptr > t && *(bptr - 1) == '\\') { - /* line continuation */ + if (!qt && c == '\\') { + *bptr++ = c; + c = hgetc(); + if (c == '\n') { bptr--; c = hgetc(); continue; - } else - break; + } } *bptr++ = c; c = hgetc(); @@ -4576,10 +4621,20 @@ readoutput(int in, int qt, int *readerror) char *buf, *ptr; int bsiz, c, cnt = 0; FILE *fin; + int q = queue_signal_level(); fin = fdopen(in, "r"); ret = newlinklist(); ptr = buf = (char *) hcalloc(bsiz = 64); + /* + * We need to be sensitive to SIGCHLD else we can be + * stuck forever with important processes unreaped. + * The case that triggered this was where the exiting + * process is group leader of the foreground process and we need + * to reclaim the terminal else ^C doesn't work. + */ + dont_queue_signals(); + child_unblock(); while ((c = fgetc(fin)) != EOF || errno == EINTR) { if (c == EOF) { errno = 0; @@ -4592,13 +4647,18 @@ readoutput(int in, int qt, int *readerror) cnt++; } if (++cnt >= bsiz) { - char *pp = (char *) hcalloc(bsiz *= 2); + char *pp; + queue_signals(); + pp = (char *) hcalloc(bsiz *= 2); + dont_queue_signals(); memcpy(pp, buf, cnt - 1); ptr = (buf = pp) + cnt - 1; } *ptr++ = c; } + child_block(); + restore_queue_signals(q); if (readerror) *readerror = ferror(fin) ? errno : 0; fclose(fin); @@ -4802,9 +4862,10 @@ getproc(char *cmd, char **eptr) return NULL; if (!out) addproc(pid, NULL, 1, &bgtime); + procsubstpid = pid; return pnam; } - closem(FDT_UNUSED); + closem(FDT_UNUSED, 0); fd = open(pnam, out ? O_WRONLY | O_NOCTTY : O_RDONLY | O_NOCTTY); if (fd == -1) { zerr("can't open %s: %e", pnam, errno); @@ -4819,7 +4880,7 @@ getproc(char *cmd, char **eptr) zerr("process substitution %s cannot be used here", cmd); return NULL; } - pnam = hcalloc(strlen(PATH_DEV_FD) + 6); + pnam = zhalloc(strlen(PATH_DEV_FD) + 1 + DIGBUFSIZE); if (!(prog = parsecmd(cmd, eptr))) return NULL; if (mpipe(pipes) < 0) @@ -4839,11 +4900,12 @@ getproc(char *cmd, char **eptr) { addproc(pid, NULL, 1, &bgtime); } + procsubstpid = pid; return pnam; } entersubsh(ESUB_ASYNC|ESUB_PGRP); redup(pipes[out], out); - closem(FDT_UNUSED); /* this closes pipes[!out] as well */ + closem(FDT_UNUSED, 0); /* this closes pipes[!out] as well */ #endif /* PATH_DEV_FD */ cmdpush(CS_CMDSUBST); @@ -4889,11 +4951,12 @@ getpipe(char *cmd, int nullexec) } if (!nullexec) addproc(pid, NULL, 1, &bgtime); + procsubstpid = pid; return pipes[!out]; } entersubsh(ESUB_PGRP); redup(pipes[out], out); - closem(FDT_UNUSED); /* this closes pipes[!out] as well */ + closem(FDT_UNUSED, 0); /* this closes pipes[!out] as well */ cmdpush(CS_CMDSUBST); execode(prog, 0, 1, out ? "outsubst" : "insubst"); cmdpop(); @@ -5736,7 +5799,19 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval) undoshfunc: --funcdepth; if (retflag) { + /* + * This function is forced to return. + */ retflag = 0; + /* + * The calling function isn't necessarily forced to return, + * but it should be made sensitive to ERR_EXIT and + * ERR_RETURN as the assumptions we made at the end of + * constructs within this function no longer apply. If + * there are cases where this is not true, they need adding + * to C03traps.ztst. + */ + this_noerrexit = 0; breaks = funcsave->breaks; } freearray(pparams); @@ -6124,6 +6199,7 @@ execsave(void) es->cmdoutpid = cmdoutpid; es->cmdoutval = cmdoutval; es->use_cmdoutval = use_cmdoutval; + es->procsubstpid = procsubstpid; es->trap_return = trap_return; es->trap_state = trap_state; es->trapisfunc = trapisfunc; @@ -6159,6 +6235,7 @@ execrestore(void) cmdoutpid = en->cmdoutpid; cmdoutval = en->cmdoutval; use_cmdoutval = en->use_cmdoutval; + procsubstpid = en->procsubstpid; trap_return = en->trap_return; trap_state = en->trap_state; trapisfunc = en->trapisfunc; diff --git a/Src/glob.c b/Src/glob.c index 66a95329f..ed2c90bd8 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -1455,13 +1455,15 @@ zglob(LinkList list, LinkNode np, int nountok) if ((pw = getpwnam(s + arglen))) data = pw->pw_uid; else { - zerr("unknown user"); + zerr("unknown username '%s'", s + arglen); data = 0; } *tt = sav; #else /* !USE_GETPWNAM */ sav = *tt; - zerr("unknown user"); + *tt = '\0'; + zerr("unable to resolve non-numeric username '%s'", s + arglen); + *tt = sav; data = 0; #endif /* !USE_GETPWNAM */ if (sav) diff --git a/Src/init.c b/Src/init.c index c5372665a..e9e6be9b4 100644 --- a/Src/init.c +++ b/Src/init.c @@ -459,7 +459,8 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp, /* -c command */ *cmdp = *argv; new_opts[INTERACTIVE] &= 1; - scriptname = scriptfilename = ztrdup("zsh"); + if (toplevel) + scriptname = scriptfilename = ztrdup("zsh"); } else if (**argv == 'o') { if (!*++*argv) argv++; diff --git a/Src/jobs.c b/Src/jobs.c index 330ee6b37..38b3d896b 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -1258,11 +1258,7 @@ pipecleanfilelist(LinkList filelist, int proc_subst_only) while (node) { Jobfile jf = (Jobfile)getdata(node); if (jf->is_fd && - (!proc_subst_only -#ifdef FDT_PROC_SUBST - || fdtable[jf->u.fd] == FDT_PROC_SUBST -#endif - )) { + (!proc_subst_only || fdtable[jf->u.fd] == FDT_PROC_SUBST)) { LinkNode next = nextnode(node); zclose(jf->u.fd); (void)remnode(filelist, node); diff --git a/Src/math.c b/Src/math.c index c3831602b..b08e05cb4 100644 --- a/Src/math.c +++ b/Src/math.c @@ -535,7 +535,7 @@ lexconstant(void) for (ptr2 = ptr; ptr2 < nptr; ptr2++) { if (*ptr2 == '_') { int len = nptr - ptr; - ptr = ztrdup(ptr); + ptr = dupstring(ptr); for (ptr2 = ptr; len; len--) { if (*ptr2 == '_') chuck(ptr2); @@ -578,6 +578,36 @@ int outputradix; /**/ int outputunderscore; +#ifndef HAVE_ISINF +/**/ +int +isinf(double x) +{ + if ((-1.0 < x) && (x < 1.0)) /* x is small, and thus finite */ + return (0); + else if ((x + x) == x) /* only true if x == Infinity */ + return (1); + else /* must be finite (normal or subnormal), or NaN */ + return (0); +} +#endif + +#if !defined(HAVE_ISNAN) +static double +store(double *x) +{ + return (*x); +} + +/**/ +int +isnan(double x) +{ + /* (x != x) should be sufficient, but some compilers incorrectly optimize it away */ + return (store(&x) != store(&x)); +} +#endif + /**/ static int zzlex(void) @@ -610,8 +640,19 @@ zzlex(void) } if (unary) { if (idigit(*ptr) || *ptr == '.') { - ptr--; - return lexconstant(); + int ctype = lexconstant(); + if (ctype == NUM) + { + if (yyval.type == MN_FLOAT) + { + yyval.u.d = -yyval.u.d; + } + else + { + yyval.u.l = -yyval.u.l; + } + } + return ctype; } else return UMINUS; } else @@ -785,11 +826,10 @@ zzlex(void) ptr++; break; } - case ' ': + case ' ': /* Fall through! */ case '\t': case '\n': break; - /* Fall through! */ default: if (idigit(*--ptr) || *ptr == '.') return lexconstant(); @@ -814,6 +854,20 @@ zzlex(void) p = ptr; ptr = ie; + if (ie - p == 3) { + if (strncasecmp(p, "NaN", 3) == 0) { + yyval.type = MN_FLOAT; + yyval.u.d = 0.0; + yyval.u.d /= yyval.u.d; + return NUM; + } + else if (strncasecmp(p, "Inf", 3) == 0) { + yyval.type = MN_FLOAT; + yyval.u.d = 0.0; + yyval.u.d = 1.0 / yyval.u.d; + return NUM; + } + } if (*ptr == '[' || (!cct && *ptr == '(')) { char op = *ptr, cp = ((*ptr == '[') ? ']' : ')'); int l; @@ -1068,9 +1122,9 @@ callmathfunc(char *o) static int notzero(mnumber a) { - if ((a.type & MN_INTEGER) ? a.u.l == 0 : a.u.d == 0.0) { - zerr("division by zero"); - return 0; + if ((a.type & MN_INTEGER) && a.u.l == 0) { + zerr("division by zero"); + return 0; } return 1; } diff --git a/Src/options.c b/Src/options.c index 590652ea9..600b649e4 100644 --- a/Src/options.c +++ b/Src/options.c @@ -769,15 +769,32 @@ dosetopt(int optno, int value, int force, char *new_opts) } else if(optno == PRIVILEGED && !value) { /* unsetting PRIVILEGED causes the shell to make itself unprivileged */ #ifdef HAVE_SETUID - setuid(getuid()); - setgid(getgid()); - if (setuid(getuid())) { - zwarn("failed to change user ID: %e", errno); - return -1; - } else if (setgid(getgid())) { + int ignore_err; + errno = 0; + /* + * Set the GID first as if we set the UID to non-privileged it + * might be impossible to restore the GID. + * + * Some OSes (possibly no longer around) have been known to + * fail silently the first time, so we attempt the change twice. + * If it fails we are guaranteed to pick this up the second + * time, so ignore the first time. + * + * Some versions of gcc make it hard to ignore the results the + * first time, hence the following. (These are probably not + * systems that require the doubled calls.) + */ + ignore_err = setgid(getgid()); + (void)ignore_err; + ignore_err = setuid(getuid()); + (void)ignore_err; + if (setgid(getgid())) { zwarn("failed to change group ID: %e", errno); return -1; - } + } else if (setuid(getuid())) { + zwarn("failed to change user ID: %e", errno); + return -1; + } #else zwarn("setuid not available"); return -1; diff --git a/Src/params.c b/Src/params.c index 36f5f0676..a1c299f60 100644 --- a/Src/params.c +++ b/Src/params.c @@ -36,6 +36,8 @@ #else #include "patchlevel.h" +#include <math.h> + /* If removed from the ChangeLog for some reason */ #ifndef ZSH_PATCHLEVEL #define ZSH_PATCHLEVEL "unknown" @@ -1425,7 +1427,7 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w, HashTable ht = v->pm->gsu.h->getfn(v->pm); if (!ht) { if (flags & SCANPM_CHECKING) - return isset(KSHARRAYS) ? 1 : 0; + return 0; ht = newparamtable(17, v->pm->node.nam); v->pm->gsu.h->setfn(v->pm, ht); } @@ -1513,7 +1515,7 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w, } } } else { - if (!v->isarr && !word) { + if (!v->isarr && !word && !quote_arg) { l = strlen(s); if (a2) { if (!l || *s != '*') { @@ -1532,9 +1534,23 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w, } } if (!keymatch) { - if (quote_arg) + if (quote_arg) { untokenize(s); - else + /* Scalar (e) needs implicit asterisk tokens */ + if (!v->isarr && !word) { + l = strlen(s); + d = (char *) hcalloc(l + 2); + if (a2) { + *d = Star; + strcpy(d + 1, s); + } else { + strcpy(d, s); + d[l] = Star; + d[l + 1] = '\0'; + } + s = d; + } + } else tokenize(s); remnulargs(s); pprog = patcompile(s, 0, NULL); @@ -5431,10 +5447,16 @@ convfloat(double dval, int digits, int flags, FILE *fout) ret = NULL; } else { VARARR(char, buf, 512 + digits); - sprintf(buf, fmt, digits, dval); - if (!strchr(buf, 'e') && !strchr(buf, '.')) - strcat(buf, "."); - ret = dupstring(buf); + if (isinf(dval)) + ret = dupstring((dval < 0.0) ? "-Inf" : "Inf"); + else if (isnan(dval)) + ret = dupstring("NaN"); + else { + sprintf(buf, fmt, digits, dval); + if (!strchr(buf, 'e') && !strchr(buf, '.')) + strcat(buf, "."); + ret = dupstring(buf); + } } #ifdef USE_LOCALE if (prev_locale) setlocale(LC_NUMERIC, prev_locale); diff --git a/Src/parse.c b/Src/parse.c index 47e5a246a..83383f10c 100644 --- a/Src/parse.c +++ b/Src/parse.c @@ -1510,8 +1510,10 @@ par_while(int *cmplx) if (tok != ZEND) YYERRORV(oecused); zshlex(); - } else + } else if (unset(SHORTLOOPS)) { YYERRORV(oecused); + } else + par_save_list1(cmplx); ecbuf[p] = WCB_WHILE(type, ecused - 1 - p); } diff --git a/Src/pattern.c b/Src/pattern.c index fc7c73739..737f5cdcb 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -3605,7 +3605,15 @@ mb_patmatchrange(char *range, wchar_t ch, int zmb_ind, wint_t *indptr, int *mtp) return 1; break; case PP_BLANK: - if (ch == L' ' || ch == L'\t') +#if !defined(HAVE_ISWBLANK) && !defined(iswblank) +/* + * iswblank() is GNU and C99. There's a remote chance that some + * systems still don't support it (but would support the other ones + * if MULTIBYTE_SUPPORT is enabled). + */ +#define iswblank(c) (c == L' ' || c == L'\t') +#endif + if (iswblank(ch)) return 1; break; case PP_CNTRL: @@ -3840,7 +3848,14 @@ patmatchrange(char *range, int ch, int *indptr, int *mtp) return 1; break; case PP_BLANK: - if (ch == ' ' || ch == '\t') +#if !defined(HAVE_ISBLANK) && !defined(isblank) +/* + * isblank() is GNU and C99. There's a remote chance that some + * systems still don't support it. + */ +#define isblank(c) (c == ' ' || c == '\t') +#endif + if (isblank(ch)) return 1; break; case PP_CNTRL: diff --git a/Src/prompt.c b/Src/prompt.c index 95da52559..959ed8e3d 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -273,8 +273,7 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) char *ss, *hostnam; int t0, arg, test, sep, j, numjobs, len; struct tm *tm; - struct timezone dummy_tz; - struct timeval tv; + struct timespec ts; time_t timet; Nameddir nd; @@ -664,8 +663,8 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) tmfmt = "%l:%M%p"; break; } - gettimeofday(&tv, &dummy_tz); - tm = localtime(&tv.tv_sec); + zgettime(&ts); + tm = localtime(&ts.tv_sec); /* * Hack because strftime won't say how * much space it actually needs. Try to add it @@ -675,7 +674,7 @@ putpromptchar(int doprint, int endchar, unsigned int *txtchangep) */ for(j = 0, t0 = strlen(tmfmt)*8; j < 3; j++, t0*=2) { addbufspc(t0); - if ((len = ztrftime(bv->bp, t0, tmfmt, tm, tv.tv_usec)) + if ((len = ztrftime(bv->bp, t0, tmfmt, tm, ts.tv_nsec)) >= 0) break; } diff --git a/Src/signals.c b/Src/signals.c index 94f379e72..20c6fdf4a 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -537,6 +537,21 @@ wait_for_processes(void) #else update_process(pn, status); #endif + if (WIFEXITED(status) && + pn->pid == jn->gleader && + killpg(pn->pid, 0) == -1) { + jn->gleader = 0; + if (!(jn->stat & STAT_NOSTTY)) { + /* + * This PID was in control of the terminal; + * reclaim terminal now it has exited. + * It's still possible some future forked + * process of this job will become group + * leader, however. + */ + attachtty(mypgrp); + } + } } update_job(jn); } else if (findproc(pid, &jn, &pn, 1)) { @@ -573,7 +588,7 @@ wait_for_processes(void) /* the signal handler */ /**/ -mod_export RETSIGTYPE +mod_export void zhandler(int sig) { sigset_t newmask, oldmask; @@ -778,9 +793,21 @@ killjb(Job jn, int sig) else return killpg(jn->gleader, sig); } - for (pn = jn->procs; pn; pn = pn->next) - if ((err = kill(pn->pid, sig)) == -1 && errno != ESRCH && sig != 0) - return -1; + for (pn = jn->procs; pn; pn = pn->next) { + /* + * Do not kill this job's process if it's already dead as its + * pid could have been reused by the system. + * As the PID doesn't exist don't return an error. + */ + if (pn->status == SP_RUNNING || WIFSTOPPED(pn->status)) { + /* + * kill -0 on a job is pointless. We still call kill() for each process + * in case the user cares about it but we ignore its outcome. + */ + if ((err = kill(pn->pid, sig)) == -1 && errno != ESRCH && sig != 0) + return -1; + } + } return err; } diff --git a/Src/signals.h b/Src/signals.h index 1904f4326..41ac88cce 100644 --- a/Src/signals.h +++ b/Src/signals.h @@ -27,7 +27,7 @@ * */ -#define SIGNAL_HANDTYPE RETSIGTYPE (*)_((int)) +#define SIGNAL_HANDTYPE void (*)_((int)) #ifndef HAVE_KILLPG # define killpg(pgrp,sig) kill(-(pgrp),sig) diff --git a/Src/subst.c b/Src/subst.c index a265a187e..c1021fbf3 100644 --- a/Src/subst.c +++ b/Src/subst.c @@ -3169,7 +3169,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags, zip = hmkarray(sval); } if (!isarr) { - aval = mkarray(val); + aval = hmkarray(val); isarr = 1; } if (zip) { diff --git a/Src/utils.c b/Src/utils.c index b41851700..075d27241 100644 --- a/Src/utils.c +++ b/Src/utils.c @@ -375,6 +375,43 @@ zerrmsg(FILE *file, const char *fmt, va_list ap) fflush(file); } +/* + * Wrapper for setupterm() and del_curterm(). + * These are called from terminfo.c and termcap.c. + */ +static int term_count; /* reference count of cur_term */ + +/**/ +mod_export void +zsetupterm(void) +{ +#ifdef HAVE_SETUPTERM + int errret; + + DPUTS(term_count < 0 || (term_count > 0 && !cur_term), + "inconsistent term_count and/or cur_term"); + /* + * Just because we can't set up the terminal doesn't + * mean the modules hasn't booted---TERM may change, + * and it should be handled dynamically---so ignore errors here. + */ + if (term_count++ == 0) + (void)setupterm((char *)0, 1, &errret); +#endif +} + +/**/ +mod_export void +zdeleteterm(void) +{ +#ifdef HAVE_SETUPTERM + DPUTS(term_count < 1 || !cur_term, + "inconsistent term_count and/or cur_term"); + if (--term_count == 0) + del_curterm(cur_term); +#endif +} + /* Output a single character, for the termcap routines. * * This is used instead of putchar since it can be a macro. */ @@ -3224,7 +3261,7 @@ ztrftimebuf(int *bufsizeptr, int decr) /**/ mod_export int -ztrftime(char *buf, int bufsize, char *fmt, struct tm *tm, long usec) +ztrftime(char *buf, int bufsize, char *fmt, struct tm *tm, long nsec) { int hr12; #ifdef HAVE_STRFTIME @@ -3299,15 +3336,15 @@ morefmt: case '.': if (ztrftimebuf(&bufsize, digs)) return -1; - if (digs > 6) - digs = 6; - if (digs < 6) { + if (digs > 9) + digs = 9; + if (digs < 9) { int trunc; - for (trunc = 5 - digs; trunc; trunc--) - usec /= 10; - usec = (usec + 5) / 10; + for (trunc = 8 - digs; trunc; trunc--) + nsec /= 10; + nsec = (nsec + 8) / 10; } - sprintf(buf, "%0*ld", digs, usec); + sprintf(buf, "%0*ld", digs, nsec); buf += digs; break; case '\0': @@ -3369,6 +3406,12 @@ morefmt: *buf++ = '0' + tm->tm_min / 10; *buf++ = '0' + tm->tm_min % 10; break; + case 'N': + if (ztrftimebuf(&bufsize, 9)) + return -1; + sprintf(buf, "%09ld", nsec); + buf += 9; + break; case 'S': if (tm->tm_sec > 9 || !strip) *buf++ = '0' + tm->tm_sec / 10; @@ -454,15 +454,14 @@ enum { * so the shell can still exec the last process. */ #define FDT_FLOCK_EXEC 6 -#ifdef PATH_DEV_FD /* * Entry used by a process substition. * This marker is not tested internally as we associated the file * descriptor with a job for closing. + * + * This is not used unless PATH_DEV_FD is defined. */ #define FDT_PROC_SUBST 7 -#endif - /* * Mask to get the basic FDT type. */ @@ -1096,6 +1095,7 @@ struct execstack { pid_t cmdoutpid; int cmdoutval; int use_cmdoutval; + pid_t procsubstpid; int trap_return; int trap_state; int trapisfunc; diff --git a/Src/zsh_system.h b/Src/zsh_system.h index 5339b496f..8289ee97c 100644 --- a/Src/zsh_system.h +++ b/Src/zsh_system.h @@ -250,6 +250,14 @@ struct timezone { }; #endif +/* Used to provide compatibility with clock_gettime() */ +#if !defined(HAVE_STRUCT_TIMESPEC) && !defined(ZSH_OOT_MODULE) +struct timespec { + time_t tv_sec; + long tv_nsec; +}; +#endif + /* There's more than one non-standard way to get at this data */ #if !defined(HAVE_STRUCT_DIRENT_D_INO) && defined(HAVE_STRUCT_DIRENT_D_STAT) # define d_ino d_stat.st_ino diff --git a/Test/A04redirect.ztst b/Test/A04redirect.ztst index b5b65cf5d..1e17dddd4 100644 --- a/Test/A04redirect.ztst +++ b/Test/A04redirect.ztst @@ -176,6 +176,30 @@ >tab\stripping >Last line + heretest() { + print First line + cat <<-HERE + $foo\\ + $foo + some\\ \ + stuff + to\ + test \\ + more backslash craziness\\\\\\\\\ + wild + HERE + print Last line + } + heretest +0:No line continuation in here-document on escaped backslash +>First line +>bar\ +>bar +>some\ stuff +>to test \ +>more backslash craziness\\\\ wild +>Last line + # # exec tests: perform these in subshells so if they fail the # shell won't exit. diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst index fd2b4177c..f89edb888 100644 --- a/Test/A06assign.ztst +++ b/Test/A06assign.ztst @@ -199,6 +199,41 @@ >a 1 2 3 >a 1 2 3 +# tests of array assignment using lastval ($?) + + true + array=( $? ) + print $array +0:Assign $? to array (true) +>0 + + false + array=( $? ) + print $array +0:Assign $? to array (false) +>1 + + true + typeset array=( $? ) + print $array +0:Assign $? to array with typeset (true) +>0 + + false + typeset array=( $? ) + print $array +0:Assign $? to array with typeset (false) +>1 + + array=( ) + true + array+=( $? ) + false + array+=( $? ) + print $array +0:Append $? to array (true+false) +>0 1 + # tests of var+=scalar s+=foo diff --git a/Test/B03print.ztst b/Test/B03print.ztst index c65568ad9..0ef3743ce 100644 --- a/Test/B03print.ztst +++ b/Test/B03print.ztst @@ -86,6 +86,17 @@ >123.45 678 >90.1 0 + nan=0 inf=1 Infinity=2 + printf '%.1f\n' -inf Infinity Inf nan NaN -Inf -0.0 +0:infinity constants +>-inf +>inf +>inf +>nan +>nan +>-inf +>-0.0 + print -f 'arg: %b\n' -C2 '\x41' '\x42' '\x43' 0:override -C when -f was given >arg: A diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst index 30409adf3..f1364ab36 100644 --- a/Test/C01arith.ztst +++ b/Test/C01arith.ztst @@ -302,6 +302,40 @@ ?(eval):1: bad math expression: operator expected at `2 ' # ` for emacs shell mode + in=1 info=2 Infinity=3 Inf=4 + print $(( in )) $(( info )) $(( Infinity )) $(( $Inf )) $(( inf )) $(( INF )) $(( Inf )) $(( iNF )) +0:Infinity parsing +>1 2 3 4 Inf Inf Inf Inf + + integer Inf + print $(( Inf[0] )) +1:Refer to Inf with an array subscript +?(eval):2: bad base syntax + + (( NaN = 1 )) +2:Assign to NaN +?(eval):1: bad math expression: lvalue required + + a='Inf' + (( b = 1e500 )) + print $((1e500)) $(($((1e500)))) $(( a )) $b $(( b )) $(( 3.0 / 0 )) +0:Overflow to infinity +>Inf Inf Inf Inf Inf Inf + + print $((1e500)) + print $(( $((1e500)) )) +0:Reinput infinity value into math context +>Inf +>Inf + + print $((1e500/1e500)) $((-1e500/1e500)) $(( 24. % 0 )) +0:NaN results +>NaN NaN NaN + + (( 3 / 0 )) +2:Integer division by zero +?(eval):1: division by zero + integer varassi print $(( varassi = 5.5 / 2.0 )) print $varassi @@ -433,3 +467,7 @@ >6 >4 ?(eval):6: bad math expression: lvalue required + + print $(( -2#101-16#f )) +0: Unary minus doesn't apply to base but to number as a whole. +>-20 diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index f22962550..dce263f94 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -680,6 +680,22 @@ F:Must be tested with a top-level script rather than source or function >Better >In .zshenv + unsetopt errreturn + fn2() { + if true; then + false + fi + } + fn1() { + setopt localoptions errreturn + fn2 + print $? + } + fn1 + print fn1 done +0:ERR_RETURN caused by function returning false from within shell construct +>fn1 done + fn2() { if false; then print Bad @@ -741,6 +757,7 @@ F:Must be tested with a top-level script rather than source or function 0:ERR_EXIT not triggered by status 1 at end of { } >OK + unsetopt err_exit err_return (setopt err_exit for x in y; do false diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst index 11f18dc71..56b7c294a 100644 --- a/Test/D01prompt.ztst +++ b/Test/D01prompt.ztst @@ -108,6 +108,14 @@ if (( $date2[7,8] != $date3[1,2] )); then print "Years do not agree in $date2, $date3" fi + # These are somewhat questionable, but... + ns=( ${="$(print -P '%D{%9.} %D{%N}')"} ) + if [[ $ns[1] != [0-9](#c9) ]] || [[ $ns[2] != [0-9](#c9) ]]; then + print "Nanosecond lengths/formats are not as expected in $ns[1], $ns[2]" + fi + if (( ($ns2[2] - $ns[1]) > 5000000 )); then + print "Nanoseconds differ too much in $ns[1], $ns[2]" + fi 0:Dates produced by prompt escapes mkdir foo diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst index ca8d56ff5..1ef55821b 100644 --- a/Test/D03procsubst.ztst +++ b/Test/D03procsubst.ztst @@ -149,3 +149,10 @@ fi 0:proc subst fd in forked subshell closed in parent (external command) >1 1 + + procfunc() { + cat <(cat "$@") + } + procfunc <(echo argument) +0:With /proc/self file descriptors must not be tidied up too early +>argument diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst index 3b187f492..e327a784c 100644 --- a/Test/D04parameter.ztst +++ b/Test/D04parameter.ztst @@ -2422,3 +2422,11 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888 >: # >: ` backtick >: word + + ( + setopt KSH_ARRAYS + typeset -A ksh_assoc + print ${+assoc[unset]} + ) +0:Use of parameter subst + to test element of hash with KSH_ARRAYS. +>0 diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst index f0a858b1c..3ea7fb7e4 100644 --- a/Test/D06subscript.ztst +++ b/Test/D06subscript.ztst @@ -273,3 +273,19 @@ print ${string[1,twoarg(1,4)]} 0:Commas inside parentheses do not confuse subscripts >abc + + string='foobarbaz foob?rbaz foob?rbaz' + print $string[(i)b?r] $string[(I)b?r] + print $string[(r)b?r] $string[(R)b?r] + print $string[(r)b?r,(R)b?r] + print $string[(ei)b?r] $string[(eI)b?r] + print $string[(er)b?r] $string[(eR)b?r] + print $string[(er)b?r,(eR)b?r] +0:Pattern handling with scalars +F:Regression test for workers/42297 +>4 24 +>b b +>barbaz foob?rbaz foob?r +>14 24 +>b b +>b?rbaz foob?r diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst index 092f9d1c7..1bd8c1900 100644 --- a/Test/V01zmodload.ztst +++ b/Test/V01zmodload.ztst @@ -182,6 +182,7 @@ >p:dis_aliases >p:dis_builtins >p:dis_functions +>p:dis_functions_source >p:dis_galiases >p:dis_patchars >p:dis_reswords @@ -190,6 +191,7 @@ >p:funcsourcetrace >p:funcstack >p:functions +>p:functions_source >p:functrace >p:galiases >p:history @@ -205,6 +207,7 @@ >p:reswords >p:saliases >p:userdirs +>p:usergroups if [[ $mods[(r)zsh/example] == zsh/example ]]; then zmodload -u zsh/example diff --git a/Test/V03mathfunc.ztst b/Test/V03mathfunc.ztst index 1edb7a279..9a297d69d 100644 --- a/Test/V03mathfunc.ztst +++ b/Test/V03mathfunc.ztst @@ -100,8 +100,8 @@ F:This test fails if your math library doesn't have erand48(). >1.50000 print $(( sqrt(-1) )) -1:Non-negative argument checking for square roots. -?(eval):1: math: argument to sqrt out of range +0:Non-negative argument checking for square roots. +>NaN # Simple test that the pseudorandom number generators are producing # something that could conceivably be pseudorandom numbers in a @@ -139,3 +139,9 @@ F:This test fails if your math library doesn't have erand48(). print $g, $l 0:Test Gamma function gamma and lgamma >1.00000, 0.00000 + + float -F 5 a b c + (( a = log2(0.5), b = log2(1.5), c = log2(99) )) + print -r - "$a, $b, $c" +0:log2 +>-1.00000, 0.58496, 6.62936 diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst index 65b860072..1e7ac76c6 100644 --- a/Test/W02jobs.ztst +++ b/Test/W02jobs.ztst @@ -13,6 +13,14 @@ zpty_input() { zpty -w zsh "${(F)@}" $'\n' } + zpty_line() { + local REPLY + integer i + for (( i = 0; i < ${1:-1}; ++i )); do + zpty -r zsh REPLY + print -r -- ${REPLY%%($'\r\n'|$'\n')} + done + } zpty_stop() { # exit twice in case of check_jobs zpty -w zsh $'exit\nexit\n' @@ -161,15 +169,17 @@ zpty_start zpty_input 'sleep 10 & sleep 9 & sleep 8 & sleep 7 &' - sleep 0.1 + zpty_line 4 zpty_input 'kill %4' + # Dunno why we need this when checking input... sleep 0.1 + zpty_line zpty_input 'kill -HUP %3' - sleep 0.1 + zpty_line zpty_input 'kill -INT %2' - sleep 0.1 + zpty_line zpty_input 'kill -KILL %1' - sleep 0.1 + zpty_line zpty_stop 0:various `kill` signals with multiple running jobs *>\[1] [0-9]## diff --git a/Test/ztst.zsh b/Test/ztst.zsh index 0b2679927..d835e0edb 100755 --- a/Test/ztst.zsh +++ b/Test/ztst.zsh @@ -315,22 +315,40 @@ ZTST_diff() { if (( diff_pat )); then local -a diff_lines1 diff_lines2 - integer failed i + integer failed i l + local p - diff_lines1=("${(f)$(<$argv[-2])}") - diff_lines2=("${(f)$(<$argv[-1])}") + diff_lines1=("${(f@)$(<$argv[-2])}") + diff_lines2=("${(f@)$(<$argv[-1])}") if (( ${#diff_lines1} != ${#diff_lines2} )); then failed=1 + print -r "Pattern match filead, line mismatch (${#diff_lines1}/${#diff_lines2}):" else for (( i = 1; i <= ${#diff_lines1}; i++ )); do if [[ ${diff_lines2[i]} != ${~diff_lines1[i]} ]]; then failed=1 + print -r "Pattern match failed, line $i:" break fi done fi if (( failed )); then - print -rl "Pattern match failed:" \<${^diff_lines1} \>${^diff_lines2} + 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_ret=1 fi else diff --git a/config.guess b/config.guess index dc84c68ef..883a6713b 100755 --- a/config.guess +++ b/config.guess @@ -1,14 +1,12 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -# Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2009-11-20' +timestamp='2018-05-19' # 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 2 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 @@ -17,26 +15,22 @@ timestamp='2009-11-20' # General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - - -# Originally written by Per Bothner. Please send patches (context -# diff format) to <config-patches@gnu.org> and include a ChangeLog -# entry. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). # -# This script attempts to guess a canonical system name similar to -# config.sub. If it succeeds, it prints the system name on stdout, and -# exits with 0. Otherwise, it exits with 1. +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to <config-patches@gnu.org>. + me=`echo "$0" | sed -e 's,.*/,,'` @@ -45,7 +39,7 @@ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -56,8 +50,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright 1992-2018 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." @@ -113,10 +106,10 @@ trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; -case $CC_FOR_BUILD,$HOST_CC,$CC in - ,,) echo "int x;" > $dummy.c ; +case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" ; for c in cc gcc c89 c99 ; do - if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; @@ -139,12 +132,40 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=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 + + eval "$set_cc_for_build" + cat <<-EOF > "$dummy.c" + #include <features.h> + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`" + + # 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 + 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 tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward @@ -154,21 +175,31 @@ 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=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + "/sbin/$sysctl" 2>/dev/null || \ + "/usr/sbin/$sysctl" 2>/dev/null || \ + echo unknown)` + case "$UNAME_MACHINE_ARCH" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + 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="$UNAME_MACHINE_ARCH"-unknown ;; esac # The Operating System including object format, if it has switched - # to ELF recently, or will in the future. - case "${UNAME_MACHINE_ARCH}" in + # to ELF recently (or will in the future) and ABI. + case "$UNAME_MACHINE_ARCH" in + earm*) + os=netbsdelf + ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build + eval "$set_cc_for_build" if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -180,7 +211,14 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in fi ;; *) - os=netbsd + os=netbsd + ;; + esac + # Determine ABI tags. + case "$UNAME_MACHINE_ARCH" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"` ;; esac # The OS release @@ -188,42 +226,62 @@ 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' ;; *) - release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. - echo "${machine}-${os}${release}" + echo "$machine-${os}${release}${abi-}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` - echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" + exit ;; + *:MidnightBSD:*:*) + echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE" exit ;; *:ekkoBSD:*:*) - echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE" exit ;; *:SolidBSD:*:*) - echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; macppc:MirBSD:*:*) - echo powerpc-unknown-mirbsd${UNAME_RELEASE} + echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; *:MirBSD:*:*) - echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE" + exit ;; + *:Sortix:*:*) + echo "$UNAME_MACHINE"-unknown-sortix exit ;; + *:Redox:*:*) + echo "$UNAME_MACHINE"-unknown-redox + exit ;; + mips:OSF1:*.*) + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on @@ -233,60 +291,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV4.5 (21064)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "LCA4 (21066/21068)") - UNAME_MACHINE="alpha" ;; + UNAME_MACHINE=alpha ;; "EV5 (21164)") - UNAME_MACHINE="alphaev5" ;; + UNAME_MACHINE=alphaev5 ;; "EV5.6 (21164A)") - UNAME_MACHINE="alphaev56" ;; + UNAME_MACHINE=alphaev56 ;; "EV5.6 (21164PC)") - UNAME_MACHINE="alphapca56" ;; + UNAME_MACHINE=alphapca56 ;; "EV5.7 (21164PC)") - UNAME_MACHINE="alphapca57" ;; + UNAME_MACHINE=alphapca57 ;; "EV6 (21264)") - UNAME_MACHINE="alphaev6" ;; + UNAME_MACHINE=alphaev6 ;; "EV6.7 (21264A)") - UNAME_MACHINE="alphaev67" ;; + UNAME_MACHINE=alphaev67 ;; "EV6.8CB (21264C)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8AL (21264B)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.8CX (21264D)") - UNAME_MACHINE="alphaev68" ;; + UNAME_MACHINE=alphaev68 ;; "EV6.9A (21264/EV69A)") - UNAME_MACHINE="alphaev69" ;; + UNAME_MACHINE=alphaev69 ;; "EV7 (21364)") - UNAME_MACHINE="alphaev7" ;; + UNAME_MACHINE=alphaev7 ;; "EV7.9 (21364A)") - UNAME_MACHINE="alphaev79" ;; + UNAME_MACHINE=alphaev79 ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # 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'` - exit ;; - Alpha\ *:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # Should we change UNAME_MACHINE based on the output of uname instead - # of the specific Alpha model? - echo alpha-pc-interix - exit ;; - 21064:Windows_NT:50:3) - echo alpha-dec-winnt3.5 - exit ;; + 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 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-amigaos + echo "$UNAME_MACHINE"-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) - echo ${UNAME_MACHINE}-unknown-morphos + echo "$UNAME_MACHINE"-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition @@ -295,12 +347,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo s390-ibm-zvmoe exit ;; *:OS400:*:*) - echo powerpc-ibm-os400 + echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) - echo arm-acorn-riscix${UNAME_RELEASE} + echo arm-acorn-riscix"$UNAME_RELEASE" exit ;; - arm:riscos:*:*|arm:RISCOS:*:*) + arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) @@ -325,38 +377,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) - echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; sun4H:SunOS:5.*:*) - echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) - echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`" exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) - echo i386-pc-auroraux${UNAME_RELEASE} + echo i386-pc-auroraux"$UNAME_RELEASE" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval $set_cc_for_build - SUN_ARCH="i386" + eval "$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 [ "$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 -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then - SUN_ARCH="x86_64" + SUN_ARCH=x86_64 fi fi - echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; 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/[^.]*//'` + echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in @@ -365,25 +417,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. - echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`" exit ;; sun3*:SunOS:*:*) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" exit ;; 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 + test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) - echo m68k-sun-sunos${UNAME_RELEASE} + echo m68k-sun-sunos"$UNAME_RELEASE" ;; sun4) - echo sparc-sun-sunos${UNAME_RELEASE} + echo sparc-sun-sunos"$UNAME_RELEASE" ;; esac exit ;; aushp:SunOS:*:*) - echo sparc-auspex-sunos${UNAME_RELEASE} + echo sparc-auspex-sunos"$UNAME_RELEASE" exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not @@ -394,44 +446,44 @@ 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} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} - exit ;; + echo m68k-atari-mint"$UNAME_RELEASE" + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) - echo m68k-atari-mint${UNAME_RELEASE} + echo m68k-atari-mint"$UNAME_RELEASE" exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) - echo m68k-milan-mint${UNAME_RELEASE} - exit ;; + echo m68k-milan-mint"$UNAME_RELEASE" + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) - echo m68k-hades-mint${UNAME_RELEASE} - exit ;; + echo m68k-hades-mint"$UNAME_RELEASE" + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) - echo m68k-unknown-mint${UNAME_RELEASE} - exit ;; + echo m68k-unknown-mint"$UNAME_RELEASE" + exit ;; m68k:machten:*:*) - echo m68k-apple-machten${UNAME_RELEASE} + echo m68k-apple-machten"$UNAME_RELEASE" exit ;; powerpc:machten:*:*) - echo powerpc-apple-machten${UNAME_RELEASE} + echo powerpc-apple-machten"$UNAME_RELEASE" exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) - echo mips-dec-ultrix${UNAME_RELEASE} + echo mips-dec-ultrix"$UNAME_RELEASE" exit ;; VAX*:ULTRIX*:*:*) - echo vax-dec-ultrix${UNAME_RELEASE} + echo vax-dec-ultrix"$UNAME_RELEASE" exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) - echo clipper-intergraph-clix${UNAME_RELEASE} + echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include <stdio.h> /* for printf() prototype */ int main (int argc, char *argv[]) { @@ -440,23 +492,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) - printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) - printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) - printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && - dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`$dummy $dummyarg` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && + 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} + echo mips-mips-riscos"$UNAME_RELEASE" exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax @@ -480,21 +532,21 @@ EOF echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) - # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] then - if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ - [ ${TARGET_BINARY_INTERFACE}x = x ] + if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ + [ "$TARGET_BINARY_INTERFACE"x = x ] then - echo m88k-dg-dgux${UNAME_RELEASE} + echo m88k-dg-dgux"$UNAME_RELEASE" else - echo m88k-dg-dguxbcs${UNAME_RELEASE} + echo m88k-dg-dguxbcs"$UNAME_RELEASE" fi else - echo i586-dg-dgux${UNAME_RELEASE} + echo i586-dg-dgux"$UNAME_RELEASE" fi - exit ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; @@ -509,7 +561,7 @@ EOF echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) - echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`" exit ;; ????????: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 @@ -521,14 +573,14 @@ EOF if [ -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} + echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV" exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include <sys/systemcfg.h> main() @@ -539,7 +591,7 @@ EOF exit(0); } EOF - if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` then echo "$SYSTEM_NAME" else @@ -551,28 +603,29 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *: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 + if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if [ -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} + echo "$IBM_ARCH"-ibm-aix"$IBM_REV" exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; - ibmrt:4.4BSD:*|romp-ibm:BSD:*) + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and - echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx @@ -587,67 +640,67 @@ EOF echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - case "${UNAME_MACHINE}" in - 9000/31? ) HP_ARCH=m68000 ;; - 9000/[34]?? ) HP_ARCH=m68k ;; + 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 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 - 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 - 32) HP_ARCH="hppa2.0n" ;; - 64) HP_ARCH="hppa2.0w" ;; - '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 - esac ;; - esac + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + 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 + 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 - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + if [ "$HP_ARCH" = "" ]; then + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" - #define _HPUX_SOURCE - #include <stdlib.h> - #include <unistd.h> + #define _HPUX_SOURCE + #include <stdlib.h> + #include <unistd.h> - int main () - { - #if defined(_SC_KERNEL_BITS) - long bits = sysconf(_SC_KERNEL_BITS); - #endif - long cpu = sysconf (_SC_CPU_VERSION); + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); - switch (cpu) - { - case CPU_PA_RISC1_0: puts ("hppa1.0"); break; - case CPU_PA_RISC1_1: puts ("hppa1.1"); break; - case CPU_PA_RISC2_0: - #if defined(_SC_KERNEL_BITS) - switch (bits) - { - case 64: puts ("hppa2.0w"); break; - case 32: puts ("hppa2.0n"); break; - default: puts ("hppa2.0"); break; - } break; - #else /* !defined(_SC_KERNEL_BITS) */ - puts ("hppa2.0"); break; - #endif - default: puts ("hppa1.0"); break; - } - exit (0); - } + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } EOF - (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac - if [ ${HP_ARCH} = "hppa2.0w" ] + if [ "$HP_ARCH" = hppa2.0w ] then - eval $set_cc_for_build + eval "$set_cc_for_build" # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler @@ -658,23 +711,23 @@ EOF # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then - HP_ARCH="hppa2.0w" + HP_ARCH=hppa2.0w else - HP_ARCH="hppa64" + HP_ARCH=hppa64 fi fi - echo ${HP_ARCH}-hp-hpux${HPUX_REV} + echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` - echo ia64-hp-hpux${HPUX_REV} + HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #include <unistd.h> int main () @@ -699,11 +752,11 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; - 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) @@ -712,7 +765,7 @@ EOF *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; - hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) @@ -720,9 +773,9 @@ EOF exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then - echo ${UNAME_MACHINE}-unknown-osf1mk + echo "$UNAME_MACHINE"-unknown-osf1mk else - echo ${UNAME_MACHINE}-unknown-osf1 + echo "$UNAME_MACHINE"-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) @@ -730,132 +783,126 @@ EOF exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit ;; + exit ;; CRAY*Y-MP:*:*:*) - echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) - echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) - echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) - echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) - echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) - echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/' exit ;; 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 ;; + 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 ;; 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}" + 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 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) - echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE" exit ;; sparc*:BSD/OS:*:*) - echo sparc-unknown-bsdi${UNAME_RELEASE} + echo sparc-unknown-bsdi"$UNAME_RELEASE" exit ;; *:BSD/OS:*:*) - echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; *:FreeBSD:*:*) - case ${UNAME_MACHINE} in - pc98) - echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=`/usr/bin/uname -p` + case "$UNAME_PROCESSOR" in amd64) - echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; - *) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; esac + echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; i*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin + echo "$UNAME_MACHINE"-pc-cygwin + exit ;; + *:MINGW64*:*) + echo "$UNAME_MACHINE"-pc-mingw64 exit ;; *:MINGW*:*) - echo ${UNAME_MACHINE}-pc-mingw32 + echo "$UNAME_MACHINE"-pc-mingw32 exit ;; - i*:windows32*:*) - # uname -m includes "-pc" on this system. - echo ${UNAME_MACHINE}-mingw32 + *:MSYS*:*) + echo "$UNAME_MACHINE"-pc-msys exit ;; i*:PW*:*) - echo ${UNAME_MACHINE}-pc-pw32 + echo "$UNAME_MACHINE"-pc-pw32 exit ;; *:Interix*:*) - case ${UNAME_MACHINE} in + case "$UNAME_MACHINE" in x86) - echo i586-pc-interix${UNAME_RELEASE} + echo i586-pc-interix"$UNAME_RELEASE" exit ;; authenticamd | genuineintel | EM64T) - echo x86_64-unknown-interix${UNAME_RELEASE} + echo x86_64-unknown-interix"$UNAME_RELEASE" exit ;; IA64) - echo ia64-unknown-interix${UNAME_RELEASE} + echo ia64-unknown-interix"$UNAME_RELEASE" exit ;; esac ;; - [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) - echo i${UNAME_MACHINE}-pc-mks - exit ;; - 8664:Windows_NT:*) - echo x86_64-pc-mks - exit ;; - i*:Windows_NT*:* | Pentium*:Windows_NT*:*) - # How do we know it's Interix rather than the generic POSIX subsystem? - # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we - # UNAME_MACHINE based on the output of uname instead of i386? - echo i586-pc-interix - exit ;; i*:UWIN*:*) - echo ${UNAME_MACHINE}-pc-uwin + echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; - p*:CYGWIN*:*) - echo powerpcle-unknown-cygwin - exit ;; prep*:SunOS:5.*:*) - echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`" exit ;; *:GNU:*:*) # the GNU system - echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`" exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland - echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC" exit ;; i*86:Minix:*:*) - echo ${UNAME_MACHINE}-pc-minix + echo "$UNAME_MACHINE"-pc-minix + exit ;; + aarch64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in @@ -866,56 +913,66 @@ EOF EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; - esac + esac objdump --private-headers /bin/sh | grep -q ld.so.1 - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + 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 ;; arm*:Linux:*:*) - eval $set_cc_for_build + eval "$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-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" else - echo ${UNAME_MACHINE}-unknown-linux-gnueabi + 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 + else + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf + fi fi exit ;; avr32*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; cris:Linux:*:*) - echo cris-axis-linux-gnu + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" exit ;; crisv32:Linux:*:*) - echo crisv32-axis-linux-gnu + echo "$UNAME_MACHINE"-axis-linux-"$LIBC" + exit ;; + e2k:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; frv:Linux:*:*) - echo frv-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + hexagon:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:Linux:*:*) - LIBC=gnu - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; ia64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + k1om:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m32r*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; m68*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c + eval "$set_cc_for_build" + sed 's/^ //' << EOF > "$dummy.c" #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el @@ -929,52 +986,70 @@ EOF #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`" + test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; } ;; - or32:Linux:*:*) - echo or32-unknown-linux-gnu + mips64el:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-"$LIBC" + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; padre:Linux:*:*) - echo sparc-unknown-linux-gnu + echo sparc-unknown-linux-"$LIBC" exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + echo hppa64-unknown-linux-"$LIBC" exit ;; 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-gnu ;; - PA8*) echo hppa2.0-unknown-linux-gnu ;; - *) echo hppa-unknown-linux-gnu ;; + PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;; + PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;; + *) echo hppa-unknown-linux-"$LIBC" ;; esac exit ;; ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + echo powerpc64-unknown-linux-"$LIBC" exit ;; ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu + echo powerpc-unknown-linux-"$LIBC" + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-"$LIBC" + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-"$LIBC" + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) - echo ${UNAME_MACHINE}-ibm-linux + echo "$UNAME_MACHINE"-ibm-linux-"$LIBC" exit ;; sh64*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sh*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; + tile*:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu + echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu + echo "$UNAME_MACHINE"-pc-linux-"$LIBC" exit ;; xtensa*:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. @@ -983,54 +1058,54 @@ EOF echo i386-sequent-sysv4 exit ;; 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, + # 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} + # Use sysv4.2uw... so that sysv4* matches it. + echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION" exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. - echo ${UNAME_MACHINE}-pc-os2-emx + echo "$UNAME_MACHINE"-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) - echo ${UNAME_MACHINE}-unknown-stop + echo "$UNAME_MACHINE"-unknown-stop exit ;; i*86:atheos:*:*) - echo ${UNAME_MACHINE}-unknown-atheos + echo "$UNAME_MACHINE"-unknown-atheos exit ;; i*86:syllable:*:*) - echo ${UNAME_MACHINE}-pc-syllable + echo "$UNAME_MACHINE"-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) - echo i386-unknown-lynxos${UNAME_RELEASE} + echo i386-unknown-lynxos"$UNAME_RELEASE" exit ;; i*86:*DOS:*:*) - echo ${UNAME_MACHINE}-pc-msdosdjgpp + echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; - i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) - UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + 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} + echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL" fi exit ;; i*86:*:5:[678]*) - # UnixWare 7.x, OpenUNIX and OpenServer 6. + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac - echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}" exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` - echo ${UNAME_MACHINE}-pc-isc$UNAME_REL + echo "$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 @@ -1040,20 +1115,20 @@ EOF && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 - echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL" else - echo ${UNAME_MACHINE}-pc-sysv32 + echo "$UNAME_MACHINE"-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: - # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i586. + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub - # prints for the "djgpp" host, or else GDB configury will decide that + # prints for the "djgpp" host, or else GDB configure will decide that # this is a cross-build. echo i586-pc-msdosdjgpp - exit ;; + exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; @@ -1062,9 +1137,9 @@ EOF exit ;; 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 + echo 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 + echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) @@ -1084,39 +1159,39 @@ EOF test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) - /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4; exit; } ;; + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + && { echo i486-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ - && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) - echo m68k-unknown-lynxos${UNAME_RELEASE} + echo m68k-unknown-lynxos"$UNAME_RELEASE" exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) - echo sparc-unknown-lynxos${UNAME_RELEASE} + echo sparc-unknown-lynxos"$UNAME_RELEASE" exit ;; rs6000:LynxOS:2.*:*) - echo rs6000-unknown-lynxos${UNAME_RELEASE} + echo rs6000-unknown-lynxos"$UNAME_RELEASE" exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) - echo powerpc-unknown-lynxos${UNAME_RELEASE} + echo powerpc-unknown-lynxos"$UNAME_RELEASE" exit ;; SM[BE]S:UNIX_SV:*:*) - echo mips-dde-sysv${UNAME_RELEASE} + echo mips-dde-sysv"$UNAME_RELEASE" exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 @@ -1127,15 +1202,15 @@ EOF *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` - echo ${UNAME_MACHINE}-sni-sysv4 + echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; - PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort - # says <Richard.M.Bartel@ccMail.Census.GOV> - echo i586-unisys-sysv4 - exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says <Richard.M.Bartel@ccMail.Census.GOV> + echo i586-unisys-sysv4 + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes <hewes@openmarket.com>. # How about differentiating between stratus architectures? -djm @@ -1147,25 +1222,25 @@ EOF exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. - echo ${UNAME_MACHINE}-stratus-vos + echo "$UNAME_MACHINE"-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) - echo m68k-apple-aux${UNAME_RELEASE} + echo m68k-apple-aux"$UNAME_RELEASE" exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then - echo mips-nec-sysv${UNAME_RELEASE} + echo mips-nec-sysv"$UNAME_RELEASE" else - echo mips-unknown-sysv${UNAME_RELEASE} + echo mips-unknown-sysv"$UNAME_RELEASE" fi - exit ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; @@ -1178,63 +1253,97 @@ EOF BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; SX-4:SUPER-UX:*:*) - echo sx4-nec-superux${UNAME_RELEASE} + echo sx4-nec-superux"$UNAME_RELEASE" exit ;; SX-5:SUPER-UX:*:*) - echo sx5-nec-superux${UNAME_RELEASE} + echo sx5-nec-superux"$UNAME_RELEASE" exit ;; SX-6:SUPER-UX:*:*) - echo sx6-nec-superux${UNAME_RELEASE} + echo sx6-nec-superux"$UNAME_RELEASE" exit ;; SX-7:SUPER-UX:*:*) - echo sx7-nec-superux${UNAME_RELEASE} + echo sx7-nec-superux"$UNAME_RELEASE" exit ;; SX-8:SUPER-UX:*:*) - echo sx8-nec-superux${UNAME_RELEASE} + echo sx8-nec-superux"$UNAME_RELEASE" exit ;; SX-8R:SUPER-UX:*:*) - echo sx8r-nec-superux${UNAME_RELEASE} + echo sx8r-nec-superux"$UNAME_RELEASE" + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux"$UNAME_RELEASE" exit ;; Power*:Rhapsody:*:*) - echo powerpc-apple-rhapsody${UNAME_RELEASE} + echo powerpc-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Rhapsody:*:*) - echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - case $UNAME_PROCESSOR in - i386) - eval $set_cc_for_build - if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then - if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ - grep IS_64BIT_ARCH >/dev/null - then - UNAME_PROCESSOR="x86_64" - fi - fi ;; - unknown) UNAME_PROCESSOR=powerpc ;; - esac - echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + eval "$set_cc_for_build" + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` - if test "$UNAME_PROCESSOR" = "x86"; then + if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi - echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE" exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; - NSE-?:NONSTOP_KERNEL:*:*) - echo nse-tandem-nsk${UNAME_RELEASE} + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk"$UNAME_RELEASE" exit ;; - NSR-?:NONSTOP_KERNEL:*:*) - echo nsr-tandem-nsk${UNAME_RELEASE} + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSV-*:NONSTOP_KERNEL:*:*) + echo nsv-tandem-nsk"$UNAME_RELEASE" + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk"$UNAME_RELEASE" exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux @@ -1243,18 +1352,18 @@ EOF echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) - echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE" exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. - if test "$cputype" = "386"; then + if test "$cputype" = 386; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi - echo ${UNAME_MACHINE}-unknown-plan9 + echo "$UNAME_MACHINE"-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 @@ -1275,14 +1384,14 @@ EOF echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) - echo mips-sei-seiux${UNAME_RELEASE} + echo mips-sei-seiux"$UNAME_RELEASE" exit ;; *:DragonFly:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" exit ;; *:*VMS:*:*) - UNAME_MACHINE=`(uname -p) 2>/dev/null` - case "${UNAME_MACHINE}" in + 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 ;; @@ -1291,182 +1400,48 @@ EOF echo i386-pc-xenix exit ;; i*86:skyos:*:*) - echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`" exit ;; i*86:rdos:*:*) - echo ${UNAME_MACHINE}-pc-rdos + echo "$UNAME_MACHINE"-pc-rdos exit ;; i*86:AROS:*:*) - echo ${UNAME_MACHINE}-pc-aros + echo "$UNAME_MACHINE"-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo "$UNAME_MACHINE"-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs exit ;; esac -#echo '(No uname command or uname output not recognized.)' 1>&2 -#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 - -eval $set_cc_for_build -cat >$dummy.c <<EOF -#ifdef _SEQUENT_ -# include <sys/types.h> -# include <sys/utsname.h> -#endif -main () -{ -#if defined (sony) -#if defined (MIPSEB) - /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, - I don't know.... */ - printf ("mips-sony-bsd\n"); exit (0); -#else -#include <sys/param.h> - printf ("m68k-sony-newsos%s\n", -#ifdef NEWSOS4 - "4" -#else - "" -#endif - ); exit (0); -#endif -#endif - -#if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix\n"); exit (0); -#endif - -#if defined (hp300) && !defined (hpux) - printf ("m68k-hp-bsd\n"); exit (0); -#endif +echo "$0: unable to guess system type" >&2 -#if defined (NeXT) -#if !defined (__ARCHITECTURE__) -#define __ARCHITECTURE__ "m68k" -#endif - int version; - version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; - if (version < 4) - printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); - else - printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); - exit (0); -#endif +case "$UNAME_MACHINE:$UNAME_SYSTEM" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <<EOF -#if defined (MULTIMAX) || defined (n16) -#if defined (UMAXV) - printf ("ns32k-encore-sysv\n"); exit (0); -#else -#if defined (CMU) - printf ("ns32k-encore-mach\n"); exit (0); -#else - printf ("ns32k-encore-bsd\n"); exit (0); -#endif -#endif -#endif - -#if defined (__386BSD__) - printf ("i386-pc-bsd\n"); exit (0); -#endif - -#if defined (sequent) -#if defined (i386) - printf ("i386-sequent-dynix\n"); exit (0); -#endif -#if defined (ns32000) - printf ("ns32k-sequent-dynix\n"); exit (0); -#endif -#endif - -#if defined (_SEQUENT_) - struct utsname un; - - uname(&un); - - if (strncmp(un.version, "V2", 2) == 0) { - printf ("i386-sequent-ptx2\n"); exit (0); - } - if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ - printf ("i386-sequent-ptx1\n"); exit (0); - } - printf ("i386-sequent-ptx\n"); exit (0); - -#endif - -#if defined (vax) -# if !defined (ultrix) -# include <sys/param.h> -# if defined (BSD) -# if BSD == 43 - printf ("vax-dec-bsd4.3\n"); exit (0); -# else -# if BSD == 199006 - printf ("vax-dec-bsd4.3reno\n"); exit (0); -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# endif -# else - printf ("vax-dec-bsd\n"); exit (0); -# endif -# else - printf ("vax-dec-ultrix\n"); exit (0); -# endif -#endif - -#if defined (alliant) && defined (i860) - printf ("i860-alliant-bsd\n"); exit (0); -#endif - - exit (1); -} +NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize +the system type. Please install a C compiler and try again. EOF - -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && - { echo "$SYSTEM_NAME"; exit; } - -# Apollos put the system type in the environment. - -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } - -# Convex versions that predate uname can use getsysinfo(1) - -if [ -x /usr/convex/getsysinfo ] -then - case `getsysinfo -f cpu_type` in - c1*) - echo c1-convex-bsd - exit ;; - c2*) - if getsysinfo -f scalar_acc - then echo c32-convex-bsd - else echo c2-convex-bsd - fi - exit ;; - c34*) - echo c34-convex-bsd - exit ;; - c38*) - echo c38-convex-bsd - exit ;; - c4*) - echo c4-convex-bsd - exit ;; - esac -fi + ;; +esac cat >&2 <<EOF -$0: unable to guess system type -This script, last modified $timestamp, has failed to recognize -the operating system you are using. It is advised that you -download the most up to date version of the config scripts from +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: - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess and - http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub -If the version you run ($0) is already up to date, please -send the following data and any information you think might be -pertinent to <config-patches@gnu.org> in order to provide the needed -information to handle your system. +If $0 has already been updated, send the following data and any +information you think might be pertinent to config-patches@gnu.org to +provide the necessary information to handle your system. config.guess timestamp = $timestamp @@ -1485,16 +1460,16 @@ hostinfo = `(hostinfo) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` -UNAME_MACHINE = ${UNAME_MACHINE} -UNAME_RELEASE = ${UNAME_RELEASE} -UNAME_SYSTEM = ${UNAME_SYSTEM} -UNAME_VERSION = ${UNAME_VERSION} +UNAME_MACHINE = "$UNAME_MACHINE" +UNAME_RELEASE = "$UNAME_RELEASE" +UNAME_SYSTEM = "$UNAME_SYSTEM" +UNAME_VERSION = "$UNAME_VERSION" EOF exit 1 # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/config.sub b/config.sub index 2a55a5075..d1f5b5490 100755 --- a/config.sub +++ b/config.sub @@ -1,38 +1,31 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 -# Free Software Foundation, Inc. +# Copyright 1992-2018 Free Software Foundation, Inc. -timestamp='2009-11-20' +timestamp='2018-05-24' -# This file is (in principle) common to ALL GNU software. -# The presence of a machine in this file suggests that SOME GNU software -# can handle that machine. It does not imply ALL GNU software can. -# -# 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 2 of the License, or +# 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 # (at your option) any later version. # -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA -# 02110-1301, USA. +# along with this program; if not, see <https://www.gnu.org/licenses/>. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). -# Please send patches to <config-patches@gnu.org>. Submit a context -# diff and a properly formatted GNU ChangeLog entry. +# Please send patches to <config-patches@gnu.org>. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. @@ -40,7 +33,7 @@ timestamp='2009-11-20' # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -60,12 +53,11 @@ timestamp='2009-11-20' me=`echo "$0" | sed -e 's,.*/,,'` usage="\ -Usage: $0 [OPTION] CPU-MFR-OPSYS - $0 [OPTION] ALIAS +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS Canonicalize a configuration name. -Operation modes: +Options: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit @@ -75,8 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright 1992-2018 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." @@ -103,7 +94,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. - echo $1 + echo "$1" exit ;; * ) @@ -119,123 +110,455 @@ case $# in exit 1;; esac -# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). -# Here we must recognize all the valid KERNEL-OS combinations. -maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` -case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os - basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` - ;; - *) - basic_machine=`echo $1 | sed 's/-[^-]*$//'` - if [ $basic_machine != $1 ] - then os=`echo $1 | sed 's/.*-/-/'` - else os=; fi - ;; -esac +# Split fields of configuration type +IFS="-" read -r field1 field2 field3 field4 <<EOF +$1 +EOF -### Let's recognize common machines as not being operating systems so -### that things like config.sub decstation-3100 work. We also -### recognize some manufacturers as not being operating systems, so we -### can provide default operating systems below. -case $os in - -sun*os*) - # Prevent following clause from handling this invalid input. - ;; - -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ - -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ - -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ - -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ - -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ - -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray | -microblaze) - os= - basic_machine=$1 - ;; - -bluegene*) - os=-cnk - ;; - -sim | -cisco | -oki | -wec | -winbond) - os= - basic_machine=$1 - ;; - -scout) - ;; - -wrs) - os=-vxworks - basic_machine=$1 - ;; - -chorusos*) - os=-chorusos - basic_machine=$1 - ;; - -chorusrdb) - os=-chorusrdb - basic_machine=$1 - ;; - -hiux*) - os=-hiuxwe2 - ;; - -sco6) - os=-sco5v6 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5) - os=-sco3.2v5 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco4) - os=-sco3.2v4 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2.[4-9]*) - os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco3.2v[4-9]*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco5v6*) - # Don't forget version if it is 3.2v4 or newer. - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -sco*) - os=-sco3.2v2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -udk*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -isc) - os=-isc2.2 - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -clix*) - basic_machine=clipper-intergraph - ;; - -isc*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` - ;; - -lynx*) - os=-lynxos +# Separate into logical components for further validation +case $1 in + *-*-*-*-*) + echo Invalid configuration \`"$1"\': more than four components >&2 + exit 1 ;; - -ptx*) - basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + *-*-*-*) + basic_machine=$field1-$field2 + os=$field3-$field4 ;; - -windowsnt*) - os=`echo $os | sed -e 's/windowsnt/winnt/'` + *-*-*) + # 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*) + basic_machine=$field1 + os=$maybe_os + ;; + android-linux) + basic_machine=$field1-unknown + os=linux-android + ;; + *) + basic_machine=$field1-$field2 + os=$field3 + ;; + esac ;; - -psos*) - os=-psos + *-*) + # Second component is usually, but not always the OS + case $field2 in + # Prevent following clause from handling this valid os + sun*os*) + basic_machine=$field1 + os=$field2 + ;; + # Manufacturers + dec* | mips* | sequent* | encore* | pc532* | sgi* | sony* \ + | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \ + | unicom* | ibm* | next | hp | isi* | apollo | altos* \ + | convergent* | ncr* | news | 32* | 3600* | 3100* | hitachi* \ + | c[123]* | convex* | sun | crds | omron* | dg | ultra | tti* \ + | harris | dolphin | highlevel | gould | cbm | ns | masscomp \ + | apple | axis | knuth | cray | microblaze* \ + | sim | cisco | oki | wec | wrs | winbond) + basic_machine=$field1-$field2 + os= + ;; + *) + basic_machine=$field1 + os=$field2 + ;; + esac ;; - -mint | -mint[0-9]*) - basic_machine=m68k-atari - os=-mint + *) + # Convert single-component short-hands not valid as part of + # multi-component configurations. + case $field1 in + 386bsd) + basic_machine=i386-pc + os=bsd + ;; + a29khif) + basic_machine=a29k-amd + os=udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=scout + ;; + am29k) + basic_machine=a29k-none + os=bsd + ;; + amdahl) + basic_machine=580-amdahl + os=sysv + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=bsd + ;; + aros) + basic_machine=i386-pc + os=aros + ;; + aux) + basic_machine=m68k-apple + os=aux + ;; + balance) + basic_machine=ns32k-sequent + os=dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=linux + ;; + cegcc) + basic_machine=arm-unknown + os=cegcc + ;; + cray) + basic_machine=j90-cray + os=unicos + ;; + craynv) + basic_machine=craynv-cray + os=unicosmp + ;; + delta88) + basic_machine=m88k-motorola + os=sysv3 + ;; + dicos) + basic_machine=i686-pc + os=dicos + ;; + djgpp) + basic_machine=i586-pc + os=msdosdjgpp + ;; + ebmon29k) + basic_machine=a29k-amd + os=ebmon + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=ose + ;; + gmicro) + basic_machine=tron-gmicro + os=sysv + ;; + go32) + basic_machine=i386-pc + os=go32 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=hms + ;; + harris) + basic_machine=m88k-harris + os=sysv3 + ;; + hp300bsd) + basic_machine=m68k-hp + os=bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=hpux + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=proelf + ;; + i386mach) + basic_machine=i386-mach + os=mach + ;; + vsta) + basic_machine=i386-unknown + os=vsta + ;; + isi68 | isi) + basic_machine=m68k-isi + os=sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=linux + ;; + magnum | m3230) + basic_machine=mips-mips + os=sysv + ;; + merlin) + basic_machine=ns32k-utek + os=sysv + ;; + mingw64) + basic_machine=x86_64-pc + os=mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=mingw32ce + ;; + monitor) + basic_machine=m68k-rom68k + os=coff + ;; + morphos) + basic_machine=powerpc-unknown + os=morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=moxiebox + ;; + msdos) + basic_machine=i386-pc + os=msdos + ;; + msys) + basic_machine=i686-pc + os=msys + ;; + mvs) + basic_machine=i370-ibm + os=mvs + ;; + nacl) + basic_machine=le32-unknown + os=nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=newsos + ;; + news1000) + basic_machine=m68030-sony + os=newsos + ;; + necv70) + basic_machine=v70-nec + os=sysv + ;; + nh3000) + basic_machine=m68k-harris + os=cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=cxux + ;; + nindy960) + basic_machine=i960-intel + os=nindy + ;; + mon960) + basic_machine=i960-intel + os=mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=nonstopux + ;; + os400) + basic_machine=powerpc-ibm + os=os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=ose + ;; + os68k) + basic_machine=m68k-none + os=os68k + ;; + paragon) + basic_machine=i860-intel + os=osf + ;; + parisc) + basic_machine=hppa-unknown + os=linux + ;; + pw32) + basic_machine=i586-unknown + os=pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=rdos + ;; + rdos32) + basic_machine=i386-pc + os=rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=coff + ;; + sa29200) + basic_machine=a29k-amd + os=udi + ;; + sei) + basic_machine=mips-sei + os=seiux + ;; + sps7) + basic_machine=m68k-bull + os=sysv2 + ;; + stratus) + basic_machine=i860-stratus + os=sysv4 + ;; + sun2os3) + basic_machine=m68000-sun + os=sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=solaris2 + ;; + sv1) + basic_machine=sv1-cray + os=unicos + ;; + symmetry) + basic_machine=i386-sequent + os=dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=unicos + ;; + t90) + basic_machine=t90-cray + os=unicos + ;; + toad1) + basic_machine=pdp10-xkl + os=tops20 + ;; + tpf) + basic_machine=s390x-ibm + os=tpf + ;; + udi29k) + basic_machine=a29k-amd + os=udi + ;; + ultra3) + basic_machine=a29k-nyu + os=sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=none + ;; + vaxv) + basic_machine=vax-dec + os=sysv + ;; + vms) + basic_machine=vax-dec + os=vms + ;; + vxworks960) + basic_machine=i960-wrs + os=vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=vxworks + ;; + xbox) + basic_machine=i686-pc + os=mingw32 + ;; + ymp) + basic_machine=ymp-cray + os=unicos + ;; + *) + basic_machine=$1 + os= + ;; + esac ;; esac @@ -245,20 +568,29 @@ case $basic_machine in # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ + | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ | bfin \ - | c4x | clipper \ + | c4x | c8051 | clipper | csky \ | d10v | d30v | dlx | dsp16xx \ - | fido | fr30 | frv \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ - | i370 | i860 | i960 | ia64 \ + | hexagon \ + | i370 | i860 | i960 | ia16 | ia64 \ | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep | metag \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -272,46 +604,83 @@ case $basic_machine in | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ - | nios | nios2 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ - | or32 \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ | pyramid \ - | rx \ + | riscv32 | riscv64 \ + | rl78 | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ - | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ - | v850 | v850e \ - | we32k \ - | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | wasm32 \ + | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12 | picochip) - # Motorola 68HC11/12. + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown - os=-none + os=${os:-none} ;; - m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65) + ;; + m9s12z | m68hcs12z | hcs12z | s12z) + basic_machine=s12z-unknown + os=${os:-none} ;; ms1) basic_machine=mt-unknown ;; + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=${os:-none} + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and @@ -319,33 +688,35 @@ case $basic_machine in i*86 | x86_64) basic_machine=$basic_machine-pc ;; - # Object if more than one company name word. - *-*-*) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 - exit 1 - ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ + | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ - | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ + | e2k-* | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ - | i*86-* | i860-* | i960-* | ia64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -359,33 +730,46 @@ case $basic_machine in | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ - | nios-* | nios2-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nfp-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ - | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ | pyramid-* \ - | romp-* | rs6000-* | rx-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ - | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ - | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ | tron-* \ | ubicom32-* \ - | v850-* | v850e-* | vax-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | wasm32-* \ | we32k-* \ - | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) @@ -396,129 +780,77 @@ case $basic_machine in ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. - 386bsd) - basic_machine=i386-unknown - os=-bsd - ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; - a29khif) - basic_machine=a29k-amd - os=-udi - ;; - abacus) + abacus) basic_machine=abacus-unknown ;; - adobe68k) - basic_machine=m68010-adobe - os=-scout - ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; - am29k) - basic_machine=a29k-none - os=-bsd - ;; amd64) basic_machine=x86_64-pc ;; amd64-*) - basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` - ;; - amdahl) - basic_machine=580-amdahl - os=-sysv + basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; amiga | amiga-*) basic_machine=m68k-unknown ;; - amigaos | amigados) - basic_machine=m68k-unknown - os=-amigaos - ;; - amigaunix | amix) - basic_machine=m68k-unknown - os=-sysv4 - ;; - apollo68) - basic_machine=m68k-apollo - os=-sysv - ;; - apollo68bsd) - basic_machine=m68k-apollo - os=-bsd - ;; - aros) - basic_machine=i386-pc - os=-aros - ;; - aux) - basic_machine=m68k-apple - os=-aux - ;; - balance) - basic_machine=ns32k-sequent - os=-dynix - ;; - blackfin) - basic_machine=bfin-unknown - os=-linux + asmjs) + basic_machine=asmjs-unknown ;; blackfin-*) - basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; bluegene*) basic_machine=powerpc-ibm - os=-cnk + os=cnk + ;; + c54x-*) + basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray - os=-unicos - ;; - cegcc) - basic_machine=arm-unknown - os=-cegcc + os=${os:-unicos} ;; convex-c1) basic_machine=c1-convex - os=-bsd + os=bsd ;; convex-c2) basic_machine=c2-convex - os=-bsd + os=bsd ;; convex-c32) basic_machine=c32-convex - os=-bsd + os=bsd ;; convex-c34) basic_machine=c34-convex - os=-bsd + os=bsd ;; convex-c38) basic_machine=c38-convex - os=-bsd - ;; - cray | j90) - basic_machine=j90-cray - os=-unicos + os=bsd ;; - craynv) - basic_machine=craynv-cray - os=-unicosmp - ;; - cr16) + cr16 | cr16-*) basic_machine=cr16-unknown - os=-elf + os=${os:-elf} ;; crds | unos) basic_machine=m68k-crds @@ -531,7 +863,7 @@ case $basic_machine in ;; crx) basic_machine=crx-unknown - os=-elf + os=${os:-elf} ;; da30 | da30-*) basic_machine=m68k-da30 @@ -541,50 +873,38 @@ case $basic_machine in ;; decsystem10* | dec10*) basic_machine=pdp10-dec - os=-tops10 + os=tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec - os=-tops20 + os=tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; - delta88) - basic_machine=m88k-motorola - os=-sysv3 - ;; - dicos) - basic_machine=i686-pc - os=-dicos - ;; - djgpp) - basic_machine=i586-pc - os=-msdosdjgpp - ;; dpx20 | dpx20-*) basic_machine=rs6000-bull - os=-bosx + os=${os:-bosx} ;; - dpx2* | dpx2*-bull) + dpx2*) basic_machine=m68k-bull - os=-sysv3 + os=sysv3 ;; - ebmon29k) - basic_machine=a29k-amd - os=-ebmon + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" ;; - elxsi) - basic_machine=elxsi-elxsi - os=-bsd + e500v[12]-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=$os"spe" ;; encore | umax | mmax) basic_machine=ns32k-encore ;; - es1800 | OSE68k | ose68k | ose | OSE) - basic_machine=m68k-ericsson - os=-ose + elxsi) + basic_machine=elxsi-elxsi + os=${os:-bsd} ;; fx2800) basic_machine=i860-alliant @@ -592,45 +912,13 @@ case $basic_machine in genix) basic_machine=ns32k-ns ;; - gmicro) - basic_machine=tron-gmicro - os=-sysv - ;; - go32) - basic_machine=i386-pc - os=-go32 - ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - h8300hms) - basic_machine=h8300-hitachi - os=-hms - ;; - h8300xray) - basic_machine=h8300-hitachi - os=-xray - ;; - h8500hms) - basic_machine=h8500-hitachi - os=-hms - ;; - harris) - basic_machine=m88k-harris - os=-sysv3 + os=hiuxwe2 ;; hp300-*) basic_machine=m68k-hp ;; - hp300bsd) - basic_machine=m68k-hp - os=-bsd - ;; - hp300hpux) - basic_machine=m68k-hp - os=-hpux - ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; @@ -660,222 +948,114 @@ case $basic_machine in hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; - hppa-next) - os=-nextstep3 - ;; - hppaosf) - basic_machine=hppa1.1-hp - os=-osf - ;; - hppro) - basic_machine=hppa1.1-hp - os=-proelf - ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; -# I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv32 + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv32 ;; i*86v4*) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv4 + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv4 ;; i*86v) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-sysv + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=sysv ;; i*86sol2) - basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` - os=-solaris2 - ;; - i386mach) - basic_machine=i386-mach - os=-mach + basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'` + os=solaris2 ;; - i386-vsta | vsta) - basic_machine=i386-unknown - os=-vsta + j90 | j90-cray) + basic_machine=j90-cray + os=${os:-unicos} ;; iris | iris4d) basic_machine=mips-sgi case $os in - -irix*) + irix*) ;; *) - os=-irix4 + os=irix4 ;; esac ;; - isi68 | isi) - basic_machine=m68k-isi - os=-sysv - ;; - m68knommu) - basic_machine=m68k-unknown - os=-linux + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'` ;; m68knommu-*) - basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; - m88k-omron*) - basic_machine=m88k-omron - ;; - magnum | m3230) - basic_machine=mips-mips - os=-sysv - ;; - merlin) - basic_machine=ns32k-utek - os=-sysv - ;; - microblaze) + microblaze*) basic_machine=microblaze-xilinx ;; - mingw32) - basic_machine=i386-pc - os=-mingw32 - ;; - mingw32ce) - basic_machine=arm-unknown - os=-mingw32ce - ;; miniframe) basic_machine=m68000-convergent ;; - *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari - os=-mint + os=mint ;; mips3*-*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'` ;; mips3*) - basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown - ;; - monitor) - basic_machine=m68k-rom68k - os=-coff - ;; - morphos) - basic_machine=powerpc-unknown - os=-morphos - ;; - msdos) - basic_machine=i386-pc - os=-msdos + basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown ;; ms1-*) - basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` - ;; - mvs) - basic_machine=i370-ibm - os=-mvs - ;; - ncr3000) - basic_machine=i486-ncr - os=-sysv4 - ;; - netbsd386) - basic_machine=i386-unknown - os=-netbsd - ;; - netwinder) - basic_machine=armv4l-rebel - os=-linux - ;; - news | news700 | news800 | news900) - basic_machine=m68k-sony - os=-newsos - ;; - news1000) - basic_machine=m68030-sony - os=-newsos + basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'` ;; news-3600 | risc-news) basic_machine=mips-sony - os=-newsos - ;; - necv70) - basic_machine=v70-nec - os=-sysv + os=newsos ;; - next | m*-next ) + next | m*-next) basic_machine=m68k-next case $os in - -nextstep* ) + nextstep* ) ;; - -ns2*) - os=-nextstep2 + ns2*) + os=nextstep2 ;; *) - os=-nextstep3 + os=nextstep3 ;; esac ;; - nh3000) - basic_machine=m68k-harris - os=-cxux - ;; - nh[45]000) - basic_machine=m88k-harris - os=-cxux - ;; - nindy960) - basic_machine=i960-intel - os=-nindy - ;; - mon960) - basic_machine=i960-intel - os=-mon960 - ;; - nonstopux) - basic_machine=mips-compaq - os=-nonstopux - ;; np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; + nsv-tandem) + basic_machine=nsv-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki - os=-proelf + os=proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; - os400) - basic_machine=powerpc-ibm - os=-os400 - ;; - OSE68000 | ose68000) - basic_machine=m68000-ericsson - os=-ose - ;; - os68k) - basic_machine=m68k-none - os=-os68k - ;; pa-hitachi) basic_machine=hppa1.1-hitachi - os=-hiuxwe2 - ;; - paragon) - basic_machine=i860-intel - os=-osf - ;; - parisc) - basic_machine=hppa-unknown - os=-linux + os=hiuxwe2 ;; parisc-*) - basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` - os=-linux + basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'` + os=linux ;; pbd) basic_machine=sparc-tti @@ -890,7 +1070,7 @@ case $basic_machine in basic_machine=i386-pc ;; pc98-*) - basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc @@ -905,57 +1085,46 @@ case $basic_machine in basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) - basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) - basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pentium4-*) - basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; - ppc) basic_machine=powerpc-unknown + ppc | ppcbe) basic_machine=powerpc-unknown ;; - ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppcle | powerpclittle | ppc-le | powerpc-little) + ppcle | powerpclittle) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) - basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; - ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; - ppc64le | powerpc64little | ppc64-le | powerpc64-little) + ppc64le | powerpc64little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) - basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; - pw32) - basic_machine=i586-unknown - os=-pw32 - ;; - rdos) - basic_machine=i386-pc - os=-rdos - ;; - rom68k) - basic_machine=m68k-rom68k - os=-coff - ;; rm[46]00) basic_machine=mips-siemens ;; @@ -968,10 +1137,6 @@ case $basic_machine in s390x | s390x-*) basic_machine=s390x-ibm ;; - sa29200) - basic_machine=a29k-amd - os=-udi - ;; sb1) basic_machine=mipsisa64sb1-unknown ;; @@ -980,32 +1145,17 @@ case $basic_machine in ;; sde) basic_machine=mipsisa32-sde - os=-elf - ;; - sei) - basic_machine=mips-sei - os=-seiux + os=${os:-elf} ;; sequent) basic_machine=i386-sequent ;; - sh) - basic_machine=sh-hitachi - os=-hms - ;; sh5el) basic_machine=sh5le-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparclite-wrs | simso-wrs) + simso-wrs) basic_machine=sparclite-wrs - os=-vxworks - ;; - sps7) - basic_machine=m68k-bull - os=-sysv2 + os=vxworks ;; spur) basic_machine=spur-unknown @@ -1013,41 +1163,12 @@ case $basic_machine in st2000) basic_machine=m68k-tandem ;; - stratus) - basic_machine=i860-stratus - os=-sysv4 + strongarm-* | thumb-*) + basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; - sun2os3) - basic_machine=m68000-sun - os=-sunos3 - ;; - sun2os4) - basic_machine=m68000-sun - os=-sunos4 - ;; - sun3os3) - basic_machine=m68k-sun - os=-sunos3 - ;; - sun3os4) - basic_machine=m68k-sun - os=-sunos4 - ;; - sun4os3) - basic_machine=sparc-sun - os=-sunos3 - ;; - sun4os4) - basic_machine=sparc-sun - os=-sunos4 - ;; - sun4sol2) - basic_machine=sparc-sun - os=-solaris2 - ;; sun3 | sun3-*) basic_machine=m68k-sun ;; @@ -1057,37 +1178,9 @@ case $basic_machine in sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; - sv1) - basic_machine=sv1-cray - os=-unicos - ;; - symmetry) - basic_machine=i386-sequent - os=-dynix - ;; - t3e) - basic_machine=alphaev5-cray - os=-unicos - ;; - t90) - basic_machine=t90-cray - os=-unicos - ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff - ;; tile*) - basic_machine=tile-unknown - os=-linux-gnu + basic_machine=$basic_machine-unknown + os=linux-gnu ;; tx39) basic_machine=mipstx39-unknown @@ -1095,82 +1188,32 @@ case $basic_machine in tx39el) basic_machine=mipstx39el-unknown ;; - toad1) - basic_machine=pdp10-xkl - os=-tops20 - ;; tower | tower-32) basic_machine=m68k-ncr ;; - tpf) - basic_machine=s390x-ibm - os=-tpf - ;; - udi29k) - basic_machine=a29k-amd - os=-udi - ;; - ultra3) - basic_machine=a29k-nyu - os=-sym1 - ;; - v810 | necv810) - basic_machine=v810-nec - os=-none - ;; - vaxv) - basic_machine=vax-dec - os=-sysv - ;; - vms) - basic_machine=vax-dec - os=-vms - ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; - vxworks960) - basic_machine=i960-wrs - os=-vxworks - ;; - vxworks68) - basic_machine=m68k-wrs - os=-vxworks - ;; - vxworks29k) - basic_machine=a29k-wrs - os=-vxworks - ;; w65*) basic_machine=w65-wdc - os=-none + os=none ;; w89k-*) basic_machine=hppa1.1-winbond - os=-proelf + os=proelf ;; - xbox) - basic_machine=i686-pc - os=-mingw32 + x64) + basic_machine=x86_64-pc ;; xps | xps100) basic_machine=xps100-honeywell ;; - ymp) - basic_machine=ymp-cray - os=-unicos - ;; - z8k-*-coff) - basic_machine=z8k-unknown - os=-sim - ;; - z80-*-coff) - basic_machine=z80-unknown - os=-sim + xscale-* | xscalee[bl]-*) + basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'` ;; none) basic_machine=none-none - os=-none + os=${os:-none} ;; # Here we handle the default manufacturer of certain CPU types. It is in @@ -1196,10 +1239,6 @@ case $basic_machine in vax) basic_machine=vax-dec ;; - pdp10) - # there are many clones, so DEC is not a safe bet - basic_machine=pdp10-unknown - ;; pdp11) basic_machine=pdp11-dec ;; @@ -1209,9 +1248,6 @@ case $basic_machine in sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) - basic_machine=sparc-sun - ;; cydra) basic_machine=cydra-cydrome ;; @@ -1231,7 +1267,7 @@ case $basic_machine in # Make sure to match an already-canonicalized machine name. ;; *) - echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2 exit 1 ;; esac @@ -1239,10 +1275,10 @@ esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) - basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` ;; *-commodore*) - basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` ;; *) ;; @@ -1250,197 +1286,246 @@ esac # Decode manufacturer-specific aliases for certain operating systems. -if [ x"$os" != x"" ] +if [ x$os != x ] then case $os in - # First match some system type aliases - # that might get confused with valid system types. - # -solaris* is a basic system type, with this one exception. - -auroraux) - os=-auroraux + # First match some system type aliases that might get confused + # with valid system types. + # solaris* is a basic system type, with this one exception. + auroraux) + os=auroraux ;; - -solaris1 | -solaris1.*) - os=`echo $os | sed -e 's|solaris1|sunos4|'` + bluegene*) + os=cnk ;; - -solaris) - os=-solaris2 + solaris1 | solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; - -svr4*) - os=-sysv4 + solaris) + os=solaris2 ;; - -unixware*) - os=-sysv4.2uw + unixware*) + os=sysv4.2uw ;; - -gnu/linux*) + gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; - # First accept the basic system types. + # es1800 is here to avoid being matched by es* (a different OS) + es1800*) + os=ose + ;; + # Some version numbers need modification + chorusos*) + os=chorusos + ;; + isc) + os=isc2.2 + ;; + sco6) + os=sco5v6 + ;; + sco5) + os=sco3.2v5 + ;; + sco4) + os=sco3.2v4 + ;; + sco3.2.[4-9]*) + 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) + # Don't match below + ;; + sco*) + os=sco3.2v2 + ;; + 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* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ - | -sym* | -kopensolaris* \ - | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* | -aros* \ - | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ - | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ - | -openbsd* | -solidbsd* \ - | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ - | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ - | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ - | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* | -cegcc* \ - | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ - | -uxpv* | -beos* | -mpeix* | -udk* \ - | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ - | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ - | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ - | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ - | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # 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* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | rtu* | xenix* \ + | knetbsd* | mirbsd* | netbsd* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* \ + | 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*) # Remember, each alternative MUST END IN *, to match a version number. ;; - -qnx*) + qnx*) case $basic_machine in x86-* | i*86-*) ;; *) - os=-nto$os + os=nto-$os ;; esac ;; - -nto-qnx*) + hiux*) + os=hiuxwe2 ;; - -nto*) - os=`echo $os | sed -e 's|nto|nto-qnx|'` + nto-qnx*) ;; - -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ - | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; - -mac*) - os=`echo $os | sed -e 's|mac|macos|'` + sim | xray | os68k* | v88r* \ + | windows* | osx | abug | netware* | os9* \ + | macos* | mpw* | magic* | mmixware* | mon960* | lnews*) ;; - -linux-dietlibc) - os=-linux-dietlibc + linux-dietlibc) + os=linux-dietlibc ;; - -linux*) + linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; - -sunos5*) - os=`echo $os | sed -e 's|sunos5|solaris2|'` + lynx*178) + os=lynxos178 + ;; + lynx*5) + os=lynxos5 + ;; + lynx*) + os=lynxos ;; - -sunos6*) - os=`echo $os | sed -e 's|sunos6|solaris3|'` + mac*) + os=`echo "$os" | sed -e 's|mac|macos|'` ;; - -opened*) - os=-openedition + opened*) + os=openedition ;; - -os400*) - os=-os400 + os400*) + os=os400 ;; - -wince*) - os=-wince + sunos5*) + os=`echo "$os" | sed -e 's|sunos5|solaris2|'` ;; - -osfrose*) - os=-osfrose + sunos6*) + os=`echo "$os" | sed -e 's|sunos6|solaris3|'` ;; - -osf*) - os=-osf + wince*) + os=wince ;; - -utek*) - os=-bsd + utek*) + os=bsd ;; - -dynix*) - os=-bsd + dynix*) + os=bsd ;; - -acis*) - os=-aos + acis*) + os=aos ;; - -atheos*) - os=-atheos + atheos*) + os=atheos ;; - -syllable*) - os=-syllable + syllable*) + os=syllable ;; - -386bsd) - os=-bsd + 386bsd) + os=bsd ;; - -ctix* | -uts*) - os=-sysv + ctix* | uts*) + os=sysv ;; - -nova*) - os=-rtmk-nova + nova*) + os=rtmk-nova ;; - -ns2 ) - os=-nextstep2 + ns2) + os=nextstep2 ;; - -nsk*) - os=-nsk + nsk*) + os=nsk ;; # Preserve the version number of sinix5. - -sinix5.*) + sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; - -sinix*) - os=-sysv4 + sinix*) + os=sysv4 ;; - -tpf*) - os=-tpf + tpf*) + os=tpf ;; - -triton*) - os=-sysv3 + triton*) + os=sysv3 ;; - -oss*) - os=-sysv3 + oss*) + os=sysv3 ;; - -svr4) - os=-sysv4 + svr4*) + os=sysv4 ;; - -svr3) - os=-sysv3 + svr3) + os=sysv3 ;; - -sysvr4) - os=-sysv4 + sysvr4) + os=sysv4 ;; - # This must come after -sysvr4. - -sysv*) + # This must come after sysvr4. + sysv*) ;; - -ose*) - os=-ose + ose*) + os=ose ;; - -es1800*) - os=-ose + *mint | mint[0-9]* | *MiNT | MiNT[0-9]*) + os=mint ;; - -xenix) - os=-xenix + zvmoe) + os=zvmoe ;; - -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) - os=-mint + dicos*) + os=dicos ;; - -aros*) - os=-aros + pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=eabi + ;; + *) + os=elf + ;; + esac ;; - -kaos*) - os=-kaos + nacl*) ;; - -zvmoe) - os=-zvmoe + ios) ;; - -dicos*) - os=-dicos + none) ;; - -none) + *-eabi) ;; *) - # Get rid of the `-' at the beginning of $os. - os=`echo $os | sed 's/[^-]*-//'` - echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2 exit 1 ;; esac @@ -1457,165 +1542,180 @@ else # system, and we'll never get to this point. case $basic_machine in - score-*) - os=-elf + score-*) + os=elf ;; - spu-*) - os=-elf + spu-*) + os=elf ;; *-acorn) - os=-riscix1.2 + os=riscix1.2 ;; arm*-rebel) - os=-linux + os=linux ;; arm*-semi) - os=-aout + os=aout + ;; + c4x-* | tic4x-*) + os=coff + ;; + c8051-*) + os=elf + ;; + clipper-intergraph) + os=clix ;; - c4x-* | tic4x-*) - os=-coff + hexagon-*) + os=elf + ;; + tic54x-*) + os=coff + ;; + tic55x-*) + os=coff + ;; + tic6x-*) + os=coff ;; # This must come before the *-dec entry. pdp10-*) - os=-tops20 + os=tops20 ;; pdp11-*) - os=-none + os=none ;; *-dec | vax-*) - os=-ultrix4.2 + os=ultrix4.2 ;; m68*-apollo) - os=-domain + os=domain ;; i386-sun) - os=-sunos4.0.2 + os=sunos4.0.2 ;; m68000-sun) - os=-sunos3 - # This also exists in the configure program, but was not the - # default. - # os=-sunos4 + os=sunos3 ;; m68*-cisco) - os=-aout + os=aout ;; - mep-*) - os=-elf + mep-*) + os=elf ;; mips*-cisco) - os=-elf + os=elf ;; mips*-*) - os=-elf + os=elf ;; or32-*) - os=-coff + os=coff ;; *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 + os=sysv3 ;; sparc-* | *-sun) - os=-sunos4.1.1 + os=sunos4.1.1 ;; - *-be) - os=-beos + pru-*) + os=elf ;; - *-haiku) - os=-haiku + *-be) + os=beos ;; *-ibm) - os=-aix + os=aix ;; - *-knuth) - os=-mmixware + *-knuth) + os=mmixware ;; *-wec) - os=-proelf + os=proelf ;; *-winbond) - os=-proelf + os=proelf ;; *-oki) - os=-proelf + os=proelf ;; *-hp) - os=-hpux + os=hpux ;; *-hitachi) - os=-hiux + os=hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) - os=-sysv + os=sysv ;; *-cbm) - os=-amigaos + os=amigaos ;; *-dg) - os=-dgux + os=dgux ;; *-dolphin) - os=-sysv3 + os=sysv3 ;; m68k-ccur) - os=-rtu + os=rtu ;; m88k-omron*) - os=-luna + os=luna ;; - *-next ) - os=-nextstep + *-next) + os=nextstep ;; *-sequent) - os=-ptx + os=ptx ;; *-crds) - os=-unos + os=unos ;; *-ns) - os=-genix + os=genix ;; i370-*) - os=-mvs - ;; - *-next) - os=-nextstep3 + os=mvs ;; *-gould) - os=-sysv + os=sysv ;; *-highlevel) - os=-bsd + os=bsd ;; *-encore) - os=-bsd + os=bsd ;; *-sgi) - os=-irix + os=irix ;; *-siemens) - os=-sysv4 + os=sysv4 ;; *-masscomp) - os=-rtu + os=rtu ;; f30[01]-fujitsu | f700-fujitsu) - os=-uxpv + os=uxpv ;; *-rom68k) - os=-coff + os=coff ;; *-*bug) - os=-coff + os=coff ;; *-apple) - os=-macos + os=macos ;; *-atari*) - os=-mint + os=mint + ;; + *-wrs) + os=vxworks ;; *) - os=-none + os=none ;; esac fi @@ -1626,79 +1726,82 @@ vendor=unknown case $basic_machine in *-unknown) case $os in - -riscix*) + riscix*) vendor=acorn ;; - -sunos*) + sunos*) 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 ;; - -mvs* | -opened*) + clix*) + vendor=intergraph + ;; + mvs* | opened*) vendor=ibm ;; - -os400*) + os400*) 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 - basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"` ;; esac -echo $basic_machine$os +echo "$basic_machine-$os" exit # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" diff --git a/configure.ac b/configure.ac index d15a6cda2..5e13c0f11 100644 --- a/configure.ac +++ b/configure.ac @@ -25,8 +25,9 @@ dnl Zsh Development Group have no obligation to provide maintenance, dnl support, updates, enhancements, or modifications. dnl -AC_INIT(Src/zsh.h) -AC_PREREQ(2.59c) +AC_INIT +AC_CONFIG_SRCDIR([Src/zsh.h]) +AC_PREREQ([2.69]) AC_CONFIG_HEADER(config.h) dnl What version of zsh are we building ? @@ -60,7 +61,7 @@ ifdef([zsh-debug],[undefine([zsh-debug])])dnl AH_TEMPLATE([DEBUG], [Define to 1 if you want to debug zsh.]) AC_ARG_ENABLE(zsh-debug, -AC_HELP_STRING([--enable-zsh-debug], [compile with debug code and debugger symbols]), +AS_HELP_STRING([--enable-zsh-debug],[compile with debug code and debugger symbols]), [if test x$enableval = xyes; then AC_DEFINE(DEBUG) fi]) @@ -70,7 +71,7 @@ ifdef([zsh-mem],[undefine([zsh-mem])])dnl AH_TEMPLATE([ZSH_MEM], [Define to 1 if you want to use zsh's own memory allocation routines]) AC_ARG_ENABLE(zsh-mem, -AC_HELP_STRING([--enable-zsh-mem], [compile with zsh memory allocation routines]), +AS_HELP_STRING([--enable-zsh-mem],[compile with zsh memory allocation routines]), [if test x$enableval = xyes; then AC_DEFINE(ZSH_MEM) fi]) @@ -80,7 +81,7 @@ ifdef([zsh-mem-debug],[undefine([zsh-mem-debug])])dnl AH_TEMPLATE([ZSH_MEM_DEBUG], [Define to 1 if you want to debug zsh memory allocation routines.]) AC_ARG_ENABLE(zsh-mem-debug, -AC_HELP_STRING([--enable-zsh-mem-debug], [debug zsh memory allocation routines]), +AS_HELP_STRING([--enable-zsh-mem-debug],[debug zsh memory allocation routines]), [if test x$enableval = xyes; then AC_DEFINE(ZSH_MEM_DEBUG) fi]) @@ -90,7 +91,7 @@ AH_TEMPLATE([ZSH_MEM_WARNING], [Define to 1 if you want to turn on warnings of memory allocation errors]) ifdef([zsh-mem-warning],[undefine([zsh-mem-warning])])dnl AC_ARG_ENABLE(zsh-mem-warning, -AC_HELP_STRING([--enable-zsh-mem-warning], [print warnings for errors in memory allocation]), +AS_HELP_STRING([--enable-zsh-mem-warning],[print warnings for errors in memory allocation]), [if test x$enableval = xyes; then AC_DEFINE(ZSH_MEM_WARNING) fi]) @@ -100,7 +101,7 @@ ifdef([zsh-secure-free],[undefine([zsh-secure-free])])dnl AH_TEMPLATE([ZSH_SECURE_FREE], [Define to 1 if you want to turn on memory checking for free().]) AC_ARG_ENABLE(zsh-secure-free, -AC_HELP_STRING([--enable-zsh-secure-free], [turn on error checking for free()]), +AS_HELP_STRING([--enable-zsh-secure-free],[turn on error checking for free()]), [if test x$enableval = xyes; then AC_DEFINE(ZSH_SECURE_FREE) fi]) @@ -111,8 +112,7 @@ ifdef([zsh-heap-debug],[undefine([zsh-heap-debug])])dnl AH_TEMPLATE([ZSH_HEAP_DEBUG], [Define to 1 if you want to turn on error checking for heap allocation.]) AC_ARG_ENABLE(zsh-heap-debug, -AC_HELP_STRING([--enable-zsh-heap-debug], -[turn on error checking for heap allocation]), +AS_HELP_STRING([--enable-zsh-heap-debug],[turn on error checking for heap allocation]), [if test x$enableval = xyes; then AC_DEFINE(ZSH_HEAP_DEBUG) fi]) @@ -122,8 +122,7 @@ ifdef([zsh-valgrind],[undefine([zsh-valgrind])])dnl AH_TEMPLATE([ZSH_VALGRIND], [Define to 1 if you want to add code for valgrind to debug heap memory.]) AC_ARG_ENABLE(zsh-valgrind, -AC_HELP_STRING([--enable-zsh-valgrind], -[turn on support for valgrind debugging of heap memory]), +AS_HELP_STRING([--enable-zsh-valgrind],[turn on support for valgrind debugging of heap memory]), [if test x$enableval = xyes; then AC_DEFINE(ZSH_VALGRIND) fi]) @@ -135,7 +134,7 @@ AH_TEMPLATE([ZSH_HASH_DEBUG], [Define to 1 if you want to get debugging information on internal hash tables. This turns on the `hashinfo' builtin.]) AC_ARG_ENABLE(zsh-hash-debug, -AC_HELP_STRING([--enable-zsh-hash-debug], [turn on debugging of internal hash tables]), +AS_HELP_STRING([--enable-zsh-hash-debug],[turn on debugging of internal hash tables]), [if test x$enableval = xyes; then AC_DEFINE(ZSH_HASH_DEBUG) fi]) @@ -145,7 +144,7 @@ ifdef([stack-allocation],[undefine([stack-allocation])])dnl AH_TEMPLATE([USE_STACK_ALLOCATION], [Define to 1 if you want to allocate stack memory e.g. with `alloca'.]) AC_ARG_ENABLE(stack-allocation, -AC_HELP_STRING([--enable-stack-allocation], [allocate stack memory e.g. with `alloca']), +AS_HELP_STRING([--enable-stack-allocation],[allocate stack memory e.g. with `alloca']), [if test x$enableval = xyes; then AC_DEFINE(USE_STACK_ALLOCATION) fi]) @@ -153,12 +152,12 @@ fi]) dnl Pathnames for global zsh scripts ifdef([etcdir],[undefine([etcdir])])dnl AC_ARG_ENABLE(etcdir, -AC_HELP_STRING([--enable-etcdir=DIR], [the default directory for global zsh scripts]), +AS_HELP_STRING([--enable-etcdir=DIR],[the default directory for global zsh scripts]), [etcdir="$enableval"], [etcdir=/etc]) ifdef([zshenv],[undefine([zshenv])])dnl AC_ARG_ENABLE(zshenv, -AC_HELP_STRING([--enable-zshenv=FILE], [the full pathname of the global zshenv script]), +AS_HELP_STRING([--enable-zshenv=FILE],[the full pathname of the global zshenv script]), [zshenv="$enableval"], [if test "x$etcdir" = xno; then zshenv=no @@ -174,7 +173,7 @@ fi ifdef([zshrc],[undefine([zshrc])])dnl AC_ARG_ENABLE(zshrc, -AC_HELP_STRING([--enable-zshrc=FILE], [the full pathname of the global zshrc script]), +AS_HELP_STRING([--enable-zshrc=FILE],[the full pathname of the global zshrc script]), [zshrc="$enableval"], [if test "x$etcdir" = xno; then zshrc=no @@ -190,7 +189,7 @@ fi ifdef([zprofile],[undefine([zprofile])])dnl AC_ARG_ENABLE(zprofile, -AC_HELP_STRING([--enable-zprofile=FILE], [the full pathname of the global zprofile script]), +AS_HELP_STRING([--enable-zprofile=FILE],[the full pathname of the global zprofile script]), [zprofile="$enableval"], [if test "x$etcdir" = xno; then zprofile=no @@ -206,7 +205,7 @@ fi ifdef([zlogin],[undefine([zlogin])])dnl AC_ARG_ENABLE(zlogin, -AC_HELP_STRING([--enable-zlogin=FILE], [the full pathname of the global zlogin script]), +AS_HELP_STRING([--enable-zlogin=FILE],[the full pathname of the global zlogin script]), [zlogin="$enableval"], [if test "x$etcdir" = xno; then zlogin=no @@ -222,7 +221,7 @@ fi ifdef([zlogout],[undefine([zlogout])])dnl AC_ARG_ENABLE(zlogout, -AC_HELP_STRING([--enable-zlogout=FILE], [the full pathname of the global zlogout script]), +AS_HELP_STRING([--enable-zlogout=FILE],[the full pathname of the global zlogout script]), [zlogout="$enableval"], [if test "x$etcdir" = xno; then zlogout=no @@ -246,7 +245,7 @@ AC_SUBST(zlogout)dnl dnl Do you want dynamically loaded binary modules. ifdef([dynamic],[undefine([dynamic])])dnl AC_ARG_ENABLE(dynamic, -AC_HELP_STRING([--disable-dynamic], [turn off dynamically loaded binary modules]), +AS_HELP_STRING([--disable-dynamic],[turn off dynamically loaded binary modules]), [dynamic="$enableval"], [dynamic=yes]) dnl Do you want to disable restricted on r* commands @@ -256,7 +255,7 @@ AH_TEMPLATE([RESTRICTED_R], when zsh is exec'd with basename that starts with r. By default this is defined.]) AC_ARG_ENABLE(restricted-r, -AC_HELP_STRING([--disable-restricted-r], [turn off r* invocation for restricted shell]), +AS_HELP_STRING([--disable-restricted-r],[turn off r* invocation for restricted shell]), [if test x$enableval = xyes; then AC_DEFINE(RESTRICTED_R) fi], @@ -267,7 +266,7 @@ dnl Do you want to disable use of locale functions AH_TEMPLATE([CONFIG_LOCALE], [Undefine if you don't want local features. By default this is defined.]) AC_ARG_ENABLE([locale], -AC_HELP_STRING([--disable-locale], [turn off locale features]), +AS_HELP_STRING([--disable-locale],[turn off locale features]), [if test x$enableval = xyes; then AC_DEFINE(CONFIG_LOCALE) fi], @@ -276,12 +275,12 @@ AC_DEFINE(CONFIG_LOCALE) dnl Do you want to compile as K&R C. AC_ARG_ENABLE(ansi2knr, -AC_HELP_STRING([--enable-ansi2knr], [translate source to K&R C before compiling]), +AS_HELP_STRING([--enable-ansi2knr],[translate source to K&R C before compiling]), [ansi2knr="$enableval"], [ansi2knr=default]) ifdef([runhelpdir],[undefine([runhelpdir])])dnl AC_ARG_ENABLE(runhelpdir, -AC_HELP_STRING([--enable-runhelpdir=DIR], [the directory in which to install run-help files]), +AS_HELP_STRING([--enable-runhelpdir=DIR],[the directory in which to install run-help files]), [if test x"$enableval" = xno; then runhelpdir= else @@ -298,7 +297,7 @@ fi ifdef([fndir],[undefine([fndir])])dnl AC_ARG_ENABLE(fndir, -AC_HELP_STRING([--enable-fndir=DIR], [the directory in which to install functions]), +AS_HELP_STRING([--enable-fndir=DIR],[the directory in which to install functions]), dnl ${VERSION} to be determined at compile time. [if test x$enableval = xyes; then fndir=${datadir}/${tzsh_name}/'${VERSION}'/functions @@ -308,7 +307,7 @@ fi], [fndir=${datadir}/${tzsh_name}/'${VERSION}'/functions]) ifdef([sitefndir],[undefine([sitefndir])])dnl AC_ARG_ENABLE(site-fndir, -AC_HELP_STRING([--enable-site-fndir=DIR], [same for site functions (not version specific)]), +AS_HELP_STRING([--enable-site-fndir=DIR],[same for site functions (not version specific)]), [if test x$enableval = xyes; then sitefndir=${datadir}/${tzsh_name}/site-functions else @@ -336,7 +335,7 @@ fi ifdef([function_subdirs],[undefine([function_subdirs])]) AC_ARG_ENABLE(function-subdirs, -AC_HELP_STRING([--enable-function-subdirs], [install functions in subdirectories])) +AS_HELP_STRING([--enable-function-subdirs],[install functions in subdirectories])) if test "x${enable_function_subdirs}" != x && test "x${enable_function_subdirs}" != xno; then @@ -347,7 +346,7 @@ fi ifdef([additionalfpath],[undefine([additionalfpath])])dnl AC_ARG_ENABLE(additional-fpath, -AC_HELP_STRING([--enable-additional-fpath=DIR], [add directories to default function path]), +AS_HELP_STRING([--enable-additional-fpath=DIR],[add directories to default function path]), [if test x$enableval = xyes; then additionalfpath="" else @@ -366,7 +365,7 @@ dnl Directories for scripts such as newuser. ifdef([scriptdir],[undefine([scriptdir])])dnl AC_ARG_ENABLE(scriptdir, -AC_HELP_STRING([--enable-scriptdir=DIR], [the directory in which to install scripts]), +AS_HELP_STRING([--enable-scriptdir=DIR],[the directory in which to install scripts]), dnl ${VERSION} to be determined at compile time. [if test x$enableval = xyes; then scriptdir=${datadir}/${tzsh_name}/'${VERSION}'/scripts @@ -376,7 +375,7 @@ fi], [scriptdir=${datadir}/${tzsh_name}/'${VERSION}'/scripts]) ifdef([sitescriptdir],[undefine([sitescriptdir])])dnl AC_ARG_ENABLE(site-scriptdir, -AC_HELP_STRING([--enable-site-scriptdir=DIR], [same for site scripts (not version specific)]), +AS_HELP_STRING([--enable-site-scriptdir=DIR],[same for site scripts (not version specific)]), [if test x$enableval = xyes; then sitescriptdir=${datadir}/${tzsh_name}/scripts else @@ -395,7 +394,7 @@ fi AH_TEMPLATE([CUSTOM_PATCHLEVEL], [Define to a custom value for the ZSH_PATCHLEVEL parameter]) AC_ARG_ENABLE(custom-patchlevel, -AC_HELP_STRING([--enable-custom-patchlevel], [set a custom ZSH_PATCHLEVEL value]), +AS_HELP_STRING([--enable-custom-patchlevel],[set a custom ZSH_PATCHLEVEL value]), [if test x$enableval != x && test x$enableval != xno; then AC_DEFINE_UNQUOTED([CUSTOM_PATCHLEVEL], ["$enableval"]) fi]) @@ -405,7 +404,7 @@ ifdef([maildir_support],[undefine([maildir_support])])dnl AH_TEMPLATE([MAILDIR_SUPPORT], [Define for Maildir support]) AC_ARG_ENABLE(maildir-support, -AC_HELP_STRING([--enable-maildir-support], [enable maildir support in MAIL and MAILPATH]), +AS_HELP_STRING([--enable-maildir-support],[enable maildir support in MAIL and MAILPATH]), [if test x$enableval = xyes; then AC_DEFINE(MAILDIR_SUPPORT) fi]) @@ -415,7 +414,7 @@ ifdef([max_function_depth],[undefine([max_function_depth])])dnl AH_TEMPLATE([MAX_FUNCTION_DEPTH], [Define for function depth limits]) AC_ARG_ENABLE(max-function-depth, -AC_HELP_STRING([--enable-max-function-depth=MAX], [limit function depth to MAX, default 500]), +AS_HELP_STRING([--enable-max-function-depth=MAX],[limit function depth to MAX, default 500]), [if test x$enableval = xyes; then AC_DEFINE(MAX_FUNCTION_DEPTH, 500) elif test x$enableval != xno; then @@ -428,7 +427,7 @@ ifdef([default_readnullcmd],[undefine([default_readnullcmd])])dnl AH_TEMPLATE([DEFAULT_READNULLCMD], [Define default pager used by readnullcmd]) AC_ARG_ENABLE(readnullcmd, -AC_HELP_STRING([--enable-readnullcmd=PAGER], [pager used when READNULLCMD is not set]), +AS_HELP_STRING([--enable-readnullcmd=PAGER],[pager used when READNULLCMD is not set]), [if test x$enableval = xyes; then AC_DEFINE(DEFAULT_READNULLCMD,"more") elif test x$enableval != xno; then @@ -439,16 +438,14 @@ fi], dnl Do you want to look for pcre support? AC_ARG_ENABLE(pcre, -AC_HELP_STRING([--enable-pcre], -[enable the search for the pcre library (may create run-time library dependencies)])) +AS_HELP_STRING([--enable-pcre],[enable the search for the pcre library (may create run-time library dependencies)])) dnl Do you want to look for capability support? AC_ARG_ENABLE(cap, -AC_HELP_STRING([--enable-cap], -[enable the search for POSIX capabilities (may require additional headers to be added by hand)])) +AS_HELP_STRING([--enable-cap],[enable the search for POSIX capabilities (may require additional headers to be added by hand)])) AC_ARG_ENABLE(gdbm, -AC_HELP_STRING([--disable-gdbm], [turn off search for gdbm library]), +AS_HELP_STRING([--disable-gdbm],[turn off search for gdbm library]), [gdbm="$enableval"], [gdbm=yes]) dnl ------------------ @@ -540,7 +537,6 @@ AC_SUBST(EXELDFLAGS)dnl AC_SUBST(LIBLDFLAGS)dnl AC_PROG_CPP dnl Figure out how to run C preprocessor. -AC_PROG_GCC_TRADITIONAL dnl Do we need -traditional flag for gcc. AC_C_CONST dnl Does compiler support `const'. dnl Default preprocessing on Mac OS X produces warnings @@ -578,9 +574,7 @@ AC_FUNC_ALLOCA dnl Check how to get `alloca'. dnl If the compiler supports union initialisation AC_CACHE_CHECK(if the compiler supports union initialisation, zsh_cv_c_have_union_init, -[AC_TRY_COMPILE([union{void *p;long l;}u={0};], [u.l=1;], - zsh_cv_c_have_union_init=yes, - zsh_cv_c_have_union_init=no)]) +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[union{void *p;long l;}u={0};]], [[u.l=1;]])],[zsh_cv_c_have_union_init=yes],[zsh_cv_c_have_union_init=no])]) AH_TEMPLATE([HAVE_UNION_INIT], [Define to 1 if the compiler can initialise a union.]) if test x$zsh_cv_c_have_union_init = xyes; then @@ -590,10 +584,7 @@ fi dnl Checking if compiler correctly cast signed to unsigned. AC_CACHE_CHECK(if signed to unsigned casting is broken, zsh_cv_c_broken_signed_to_unsigned_casting, -[AC_TRY_RUN([main(){return((int)(unsigned char)((char) -1) == 255);}], - zsh_cv_c_broken_signed_to_unsigned_casting=yes, - zsh_cv_c_broken_signed_to_unsigned_casting=no, - zsh_cv_c_broken_signed_to_unsigned_casting=no)]) +[AC_RUN_IFELSE([AC_LANG_SOURCE([[main(){return((int)(unsigned char)((char) -1) == 255);}]])],[zsh_cv_c_broken_signed_to_unsigned_casting=yes],[zsh_cv_c_broken_signed_to_unsigned_casting=no],[zsh_cv_c_broken_signed_to_unsigned_casting=no])]) AH_TEMPLATE([BROKEN_SIGNED_TO_UNSIGNED_CASTING], [Define to 1 if compiler incorrectly cast signed to unsigned.]) if test x$zsh_cv_c_broken_signed_to_unsigned_casting = xyes; then @@ -603,9 +594,7 @@ fi dnl Checking if the compiler supports variable-length arrays AC_CACHE_CHECK(if the compiler supports variable-length arrays, zsh_cv_c_variable_length_arrays, -[AC_TRY_COMPILE([int foo(), n;], [int i[foo()], a[n+1];], - zsh_cv_c_variable_length_arrays=yes, - zsh_cv_c_variable_length_arrays=no)]) +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int foo(), n;]], [[int i[foo()], a[n+1];]])],[zsh_cv_c_variable_length_arrays=yes],[zsh_cv_c_variable_length_arrays=no])]) AH_TEMPLATE([HAVE_VARIABLE_LENGTH_ARRAYS], [Define to 1 if compiler supports variable-length arrays]) if test x$zsh_cv_c_variable_length_arrays = xyes; then @@ -704,10 +693,8 @@ AH_TEMPLATE([TIME_H_SELECT_H_CONFLICTS], if test x$ac_cv_header_sys_time_h = xyes && test x$ac_cv_header_sys_select_h = xyes; then AC_CACHE_CHECK(for conflicts in sys/time.h and sys/select.h, zsh_cv_header_time_h_select_h_conflicts, - [AC_TRY_COMPILE([#include <sys/time.h> -#include <sys/select.h>], [int i;], - zsh_cv_header_time_h_select_h_conflicts=no, - zsh_cv_header_time_h_select_h_conflicts=yes)]) + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/time.h> +#include <sys/select.h>]], [[int i;]])],[zsh_cv_header_time_h_select_h_conflicts=no],[zsh_cv_header_time_h_select_h_conflicts=yes])]) if test x$zsh_cv_header_time_h_select_h_conflicts = xyes; then AC_DEFINE(TIME_H_SELECT_H_CONFLICTS) fi @@ -718,28 +705,22 @@ AH_TEMPLATE([GWINSZ_IN_SYS_IOCTL], if test x$ac_cv_header_termios_h = xyes; then AC_CACHE_CHECK(TIOCGWINSZ in termios.h, zsh_cv_header_termios_h_tiocgwinsz, - [AC_TRY_LINK([ + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif -#include <termios.h>], - [int x = TIOCGWINSZ;], - zsh_cv_header_termios_h_tiocgwinsz=yes, - zsh_cv_header_termios_h_tiocgwinsz=no)]) +#include <termios.h>]], [[int x = TIOCGWINSZ;]])],[zsh_cv_header_termios_h_tiocgwinsz=yes],[zsh_cv_header_termios_h_tiocgwinsz=no])]) else zsh_cv_header_termios_h_tiocgwinsz=no fi if test x$zsh_cv_header_termios_h_tiocgwinsz = xno; then AC_CACHE_CHECK(TIOCGWINSZ in sys/ioctl.h, zsh_cv_header_sys_ioctl_h_tiocgwinsz, - [AC_TRY_LINK([ + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_SYS_TYPES_H # include <sys/types.h> #endif -#include <sys/ioctl.h>], - [int x = TIOCGWINSZ;], - zsh_cv_header_sys_ioctl_h_tiocgwinsz=yes, - zsh_cv_header_sys_ioctl_h_tiocgwinsz=no)]) +#include <sys/ioctl.h>]], [[int x = TIOCGWINSZ;]])],[zsh_cv_header_sys_ioctl_h_tiocgwinsz=yes],[zsh_cv_header_sys_ioctl_h_tiocgwinsz=no])]) if test x$zsh_cv_header_sys_ioctl_h_tiocgwinsz = xyes; then AC_DEFINE(GWINSZ_IN_SYS_IOCTL) fi @@ -749,11 +730,8 @@ 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, -[AC_TRY_COMPILE([#include <sys/stream.h> -#include <sys/ptem.h>], -[struct winsize wsz], -ac_cv_winsize_in_ptem=yes, -ac_cv_winsize_in_ptem=no)]) +[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 AC_DEFINE(WINSIZE_IN_PTEM) fi @@ -791,7 +769,7 @@ dnl is ncurses or curses. dnl On pre-11.11 HPUX, Hcurses is reported to work better than curses. dnl Prefer ncurses to curses on all systems. tinfo isn't very common now. AC_ARG_WITH(term-lib, -AC_HELP_STRING([--with-term-lib=LIBS], [search space-separated LIBS for terminal handling]), +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]) @@ -838,11 +816,9 @@ 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_TRY_COMPILE([#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)) +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_DEFINE(HAVE_CURSES_H) fi]) @@ -909,9 +885,7 @@ AH_TEMPLATE([ICONV_FROM_LIBICONV], [Define to 1 if iconv() is linked from libiconv]) if test "x$ac_found_iconv" = xyes; then AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) - AC_TRY_LINK([#include <iconv.h>], - [int myversion = _libiconv_version], - AC_DEFINE(ICONV_FROM_LIBICONV), ) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iconv.h>]], [[int myversion = _libiconv_version]])],[AC_DEFINE(ICONV_FROM_LIBICONV)],[]) fi dnl Check if iconv uses const in prototype declaration @@ -945,23 +919,18 @@ dnl --------------------- dnl Checks for external variable ospeed in the termcap library. AC_CACHE_CHECK(if an include file defines ospeed, zsh_cv_decl_ospeed_include_defines, -[AC_TRY_LINK( -[#include <sys/types.h> +[AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> #if HAVE_TERMIOS_H #include <termios.h> #endif #if HAVE_TERMCAP_H #include <termcap.h> -#endif], [ospeed = 0;], -zsh_cv_decl_ospeed_include_defines=yes, -zsh_cv_decl_ospeed_include_defines=no)]) +#endif]], [[ospeed = 0;]])],[zsh_cv_decl_ospeed_include_defines=yes],[zsh_cv_decl_ospeed_include_defines=no])]) if test x$zsh_cv_decl_ospeed_include_defines = xno; then AC_CACHE_CHECK(if you must define ospeed, zsh_cv_decl_ospeed_must_define, - [AC_TRY_LINK( ,[extern short ospeed; ospeed = 0;], - zsh_cv_decl_ospeed_must_define=yes, - zsh_cv_decl_ospeed_must_define=no)]) + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern short ospeed; ospeed = 0;]])],[zsh_cv_decl_ospeed_must_define=yes],[zsh_cv_decl_ospeed_must_define=no])]) fi AH_TEMPLATE([HAVE_OSPEED], @@ -986,7 +955,6 @@ dnl -------------- dnl CHECK TYPEDEFS dnl -------------- -AC_TYPE_SIGNAL AC_TYPE_PID_T AC_TYPE_OFF_T AC_CHECK_TYPE(ino_t, unsigned long) @@ -1000,10 +968,7 @@ dnl ------------------------------------------------ dnl AC_CHECK_SIZEOF is no good, because we need the result here, dnl and that doesn't seem to define a shell parameter. AC_CACHE_CHECK(if long is 64 bits, zsh_cv_long_is_64_bit, -[AC_TRY_RUN([int main() { return sizeof(long) < 8; }], -zsh_cv_long_is_64_bit=yes, -zsh_cv_long_is_64_bit=no, -zsh_cv_long_is_64_bit=no)]) +[AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return sizeof(long) < 8; }]])],[zsh_cv_long_is_64_bit=yes],[zsh_cv_long_is_64_bit=no],[zsh_cv_long_is_64_bit=no])]) AH_TEMPLATE([ino_t], [Define to `unsigned long' if <sys/types.h> doesn't define.]) @@ -1028,27 +993,21 @@ if test x$zsh_cv_long_is_64_bit = xyes; then AC_DEFINE(LONG_IS_64_BIT) else AC_CACHE_CHECK(if off_t is 64 bit, zsh_cv_off_t_is_64_bit, - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <sys/types.h> main() { return sizeof(off_t) < 8; } -], - zsh_cv_off_t_is_64_bit=yes, - zsh_cv_off_t_is_64_bit=no, - zsh_cv_off_t_is_64_bit=no)]) +]])],[zsh_cv_off_t_is_64_bit=yes],[zsh_cv_off_t_is_64_bit=no],[zsh_cv_off_t_is_64_bit=no])]) if test x$zsh_cv_off_t_is_64_bit = xyes; then AC_DEFINE(OFF_T_IS_64_BIT) fi AC_CACHE_CHECK(if ino_t is 64 bit, zsh_cv_ino_t_is_64_bit, - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <sys/types.h> main() { return sizeof(ino_t) < 8; } -], - zsh_cv_ino_t_is_64_bit=yes, - zsh_cv_ino_t_is_64_bit=no, - zsh_cv_ino_t_is_64_bit=no)]) +]])],[zsh_cv_ino_t_is_64_bit=yes],[zsh_cv_ino_t_is_64_bit=no],[zsh_cv_ino_t_is_64_bit=no])]) if test x$zsh_cv_ino_t_is_64_bit = xyes; then AC_DEFINE(INO_T_IS_64_BIT) fi @@ -1103,8 +1062,7 @@ fi dnl We'll blithely assume (f)printf supports the same types as sprintf. AC_CACHE_CHECK(for %lld printf support, zsh_cv_printf_has_lld, -[AC_TRY_RUN( -[#include <stdio.h> +[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h> #include <string.h> int main(int argc, char **argv) { @@ -1116,10 +1074,7 @@ int main(int argc, char **argv) } return 1; } -], -zsh_cv_printf_has_lld=yes, -zsh_cv_printf_has_lld=no, -zsh_cv_printf_has_lld=no)]) +]])],[zsh_cv_printf_has_lld=yes],[zsh_cv_printf_has_lld=no],[zsh_cv_printf_has_lld=no])]) AH_TEMPLATE(PRINTF_HAS_LLD, [Define to 1 if printf and sprintf support %lld for long long.]) if test x$zsh_cv_printf_has_lld = xyes; then @@ -1130,11 +1085,9 @@ dnl Check for sigset_t. Currently I'm looking in dnl <sys/types.h> and <signal.h>. Others might need dnl to be added. AC_CACHE_CHECK(for sigset_t, zsh_cv_type_sigset_t, -[AC_TRY_COMPILE( -[#define _POSIX_C_SOURCE 200809L +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#define _POSIX_C_SOURCE 200809L #include <sys/types.h> -#include <signal.h>], [sigset_t tempsigset;], - zsh_cv_type_sigset_t=yes, zsh_cv_type_sigset_t=no)]) +#include <signal.h>]], [[sigset_t tempsigset;]])],[zsh_cv_type_sigset_t=yes],[zsh_cv_type_sigset_t=no])]) AH_TEMPLATE([sigset_t], [Define to `unsigned int' if <sys/types.h> or <signal.h> doesn't define]) if test x$zsh_cv_type_sigset_t = xno; then @@ -1160,6 +1113,14 @@ zsh_TYPE_EXISTS([ #endif ], struct timezone) +dnl Check for struct timespec since POSIX only gained it in 2008 +zsh_TYPE_EXISTS([ +#define _GNU_SOURCE 1 +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +#endif +], struct timespec) + dnl Check for utmp structures, for watch zsh_TYPE_EXISTS([ #ifdef HAVE_SYS_TYPES_H @@ -1271,9 +1232,7 @@ AH_TEMPLATE([USE_LOCAL_H_ERRNO], [Define to 1 if h_errno is not defined by the system.]) AC_CACHE_CHECK(if we need our own h_errno, zsh_cv_decl_h_errno_use_local, - [AC_TRY_LINK( ,[extern int h_errno; h_errno = 0;], - zsh_cv_decl_h_errno_use_local=no, - zsh_cv_decl_h_errno_use_local=yes)]) + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[extern int h_errno; h_errno = 0;]])],[zsh_cv_decl_h_errno_use_local=no],[zsh_cv_decl_h_errno_use_local=yes])]) if test x$zsh_cv_decl_h_errno_use_local = xyes; then AC_DEFINE(USE_LOCAL_H_ERRNO) @@ -1304,8 +1263,10 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \ memcpy memmove strstr strerror strtoul \ getrlimit getrusage \ setlocale \ + isblank iswblank \ uname \ signgam tgamma \ + log2 \ scalbn \ putenv getenv setenv unsetenv xw\ brk sbrk \ @@ -1317,6 +1278,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \ erand48 open_memstream \ posix_openpt \ wctomb iconv \ + isinf isnan \ grantpt unlockpt ptsname \ htons ntohs \ regcomp regexec regerror regfree \ @@ -1359,7 +1321,7 @@ AH_TEMPLATE([TGETENT_ACCEPTS_NULL], [Define to 1 if tgetent() accepts NULL as a buffer.]) AC_CACHE_CHECK(if tgetent accepts NULL, zsh_cv_func_tgetent_accepts_null, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ main() { char buf[4096]; @@ -1373,20 +1335,17 @@ main() } exit((r1 != r2) || r2 == -1); } -], - if test -f conftest.tgetent; then +]])],[if test -f conftest.tgetent; then zsh_cv_func_tgetent_accepts_null=yes else zsh_cv_func_tgetent_accepts_null=no - fi, - zsh_cv_func_tgetent_accepts_null=no, - zsh_cv_func_tgetent_accepts_null=no)]) + fi],[zsh_cv_func_tgetent_accepts_null=no],[zsh_cv_func_tgetent_accepts_null=no])]) if test x$zsh_cv_func_tgetent_accepts_null = xyes; then AC_DEFINE(TGETENT_ACCEPTS_NULL) fi AC_CACHE_CHECK(if tgetent returns 0 on success, zsh_cv_func_tgetent_zero_success, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ main() { char buf[4096]; @@ -1400,14 +1359,11 @@ main() } exit(r1 == r2); } -], - if test -f conftest.tgetent0; then +]])],[if test -f conftest.tgetent0; then zsh_cv_func_tgetent_zero_success=yes else zsh_cv_func_tgetent_zero_success=no - fi, - zsh_cv_func_tgetent_zero_success=no, - zsh_cv_func_tgetent_zero_success=no)]) + fi],[zsh_cv_func_tgetent_zero_success=no],[zsh_cv_func_tgetent_zero_success=no])]) AH_TEMPLATE([TGETENT_SUCCESS], [Define to what tgetent() returns on success (0 on HP-UX X/Open curses).]) if test x$zsh_cv_func_tgetent_zero_success = xyes; then @@ -1727,33 +1683,27 @@ if test x$zsh_cv_path_term_header != xnone; then fi AC_MSG_CHECKING(if boolcodes is available) - AC_TRY_LINK($term_includes, [char **test = boolcodes; puts(*test);], - AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes, boolcodes=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no]) AC_MSG_RESULT($boolcodes) AC_MSG_CHECKING(if numcodes is available) - AC_TRY_LINK($term_includes, [char **test = numcodes; puts(*test);], - AC_DEFINE(HAVE_NUMCODES) numcodes=yes, numcodes=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no]) AC_MSG_RESULT($numcodes) AC_MSG_CHECKING(if strcodes is available) - AC_TRY_LINK($term_includes, [char **test = strcodes; puts(*test);], - AC_DEFINE(HAVE_STRCODES) strcodes=yes, strcodes=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no]) AC_MSG_RESULT($strcodes) AC_MSG_CHECKING(if boolnames is available) - AC_TRY_LINK($term_includes, [char **test = boolnames; puts(*test);], - AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes, boolnames=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no]) AC_MSG_RESULT($boolnames) AC_MSG_CHECKING(if numnames is available) - AC_TRY_LINK($term_includes, [char **test = numnames; puts(*test);], - AC_DEFINE(HAVE_NUMNAMES) numnames=yes, numnames=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no]) AC_MSG_RESULT($numnames) AC_MSG_CHECKING(if strnames is available) - AC_TRY_LINK($term_includes, [char **test = strnames; puts(*test);], - AC_DEFINE(HAVE_STRNAMES) strnames=yes, strnames=no) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no]) AC_MSG_RESULT($strnames) dnl There are apparently defective terminal library headers on some @@ -1762,9 +1712,7 @@ if test x$zsh_cv_path_term_header != xnone; then tgoto_includes="$term_includes /* guaranteed to clash with any valid tgoto prototype */ extern void tgoto(int **stuff, float **more_stuff);" - AC_TRY_LINK($tgoto_includes, - [int *stuff; float *more_stuff; tgoto(&stuff, &more_stuff);], - AC_DEFINE(TGOTO_PROTO_MISSING) tgotoprotomissing=yes, tgotoprotomissing=no) + 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) else ZSH_TERM_H= @@ -1830,19 +1778,16 @@ AH_TEMPLATE([rlim_t], DEFAULT_RLIM_T=long AC_CACHE_CHECK(if rlim_t is longer than a long, zsh_cv_rlim_t_is_longer, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif #include <sys/resource.h> -main(){struct rlimit r;exit(sizeof(r.rlim_cur) <= sizeof(long));}], -zsh_cv_rlim_t_is_longer=yes, -zsh_cv_rlim_t_is_longer=no, -zsh_cv_rlim_t_is_longer=yes)]) +main(){struct rlimit r;exit(sizeof(r.rlim_cur) <= sizeof(long));}]])],[zsh_cv_rlim_t_is_longer=yes],[zsh_cv_rlim_t_is_longer=no],[zsh_cv_rlim_t_is_longer=yes])]) if test x$zsh_cv_rlim_t_is_longer = xyes; then AC_CACHE_CHECK(if rlim_t is a quad, zsh_cv_rlim_t_is_quad_t, - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -1854,10 +1799,7 @@ main() { r.rlim_cur = 0; sprintf(buf, "%qd", r.rlim_cur); exit(strcmp(buf, "0")); -}], - zsh_cv_rlim_t_is_quad_t=yes, - zsh_cv_rlim_t_is_quad_t=no, - zsh_cv_rlim_t_is_quad_t=no)]) +}]])],[zsh_cv_rlim_t_is_quad_t=yes],[zsh_cv_rlim_t_is_quad_t=no],[zsh_cv_rlim_t_is_quad_t=no])]) if test x$zsh_cv_rlim_t_is_quad_t = xyes; then AC_DEFINE(RLIM_T_IS_QUAD_T) DEFAULT_RLIM_T=quad_t @@ -1868,15 +1810,12 @@ main() { else AC_CACHE_CHECK(if the rlim_t is unsigned, zsh_cv_type_rlim_t_is_unsigned, - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif #include <sys/resource.h> - main(){struct rlimit r;r.rlim_cur=-1;exit(r.rlim_cur<0);}], - zsh_cv_type_rlim_t_is_unsigned=yes, - zsh_cv_type_rlim_t_is_unsigned=no, - zsh_cv_type_rlim_t_is_unsigned=no)]) + main(){struct rlimit r;r.rlim_cur=-1;exit(r.rlim_cur<0);}]])],[zsh_cv_type_rlim_t_is_unsigned=yes],[zsh_cv_type_rlim_t_is_unsigned=no],[zsh_cv_type_rlim_t_is_unsigned=no])]) if test x$zsh_cv_type_rlim_t_is_unsigned = xyes; then AC_DEFINE(RLIM_T_IS_UNSIGNED) DEFAULT_RLIM_T="unsigned $DEFAULT_RLIM_T" @@ -1884,15 +1823,12 @@ else fi AC_CACHE_CHECK(for rlim_t, zsh_cv_type_rlim_t, -[AC_TRY_COMPILE([ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/types.h> #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif -#include <sys/resource.h>], -[rlim_t l;], -zsh_cv_type_rlim_t=yes, -zsh_cv_type_rlim_t=no)]) +#include <sys/resource.h>]], [[rlim_t l;]])],[zsh_cv_type_rlim_t=yes],[zsh_cv_type_rlim_t=no])]) if test x$zsh_cv_type_rlim_t = xno; then AC_DEFINE_UNQUOTED(rlim_t, $DEFAULT_RLIM_T) fi @@ -1929,7 +1865,7 @@ AH_TEMPLATE([RLIMIT_VMEM_IS_RSS], [Define to 1 if RLIMIT_VMEM and RLIMIT_RSS both exist and are equal.]) AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_RSS are the same, zsh_cv_rlimit_vmem_is_rss, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <sys/types.h> #ifdef HAVE_SYS_TIME_H #include <sys/time.h> @@ -1942,10 +1878,7 @@ int ret = 1; if (RLIMIT_RSS == RLIMIT_VMEM) ret = 0; #endif return ret; -}], - zsh_cv_rlimit_vmem_is_rss=yes, - zsh_cv_rlimit_vmem_is_rss=no, - zsh_cv_rlimit_vmem_is_rss=no)]) +}]])],[zsh_cv_rlimit_vmem_is_rss=yes],[zsh_cv_rlimit_vmem_is_rss=no],[zsh_cv_rlimit_vmem_is_rss=no])]) if test x$zsh_cv_rlimit_vmem_is_rss = xyes; then AC_DEFINE(RLIMIT_VMEM_IS_RSS) @@ -1956,7 +1889,7 @@ AH_TEMPLATE([RLIMIT_VMEM_IS_AS], [Define to 1 if RLIMIT_VMEM and RLIMIT_AS both exist and are equal.]) AC_CACHE_CHECK(if RLIMIT_VMEM and RLIMIT_AS are the same, zsh_cv_rlimit_vmem_is_as, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <sys/types.h> #ifdef HAVE_SYS_TIME_H #include <sys/time.h> @@ -1969,10 +1902,7 @@ int ret = 1; if (RLIMIT_AS == RLIMIT_VMEM) ret = 0; #endif return ret; -}], - zsh_cv_rlimit_vmem_is_as=yes, - zsh_cv_rlimit_vmem_is_as=no, - zsh_cv_rlimit_vmem_is_as=no)]) +}]])],[zsh_cv_rlimit_vmem_is_as=yes],[zsh_cv_rlimit_vmem_is_as=no],[zsh_cv_rlimit_vmem_is_as=no])]) if test x$zsh_cv_rlimit_vmem_is_as = xyes; then AC_DEFINE(RLIMIT_VMEM_IS_AS) @@ -1983,7 +1913,7 @@ AH_TEMPLATE([RLIMIT_RSS_IS_AS], [Define to 1 if RLIMIT_RSS and RLIMIT_AS both exist and are equal.]) AC_CACHE_CHECK(if RLIMIT_RSS and RLIMIT_AS are the same, zsh_cv_rlimit_rss_is_as, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <sys/types.h> #ifdef HAVE_SYS_TIME_H #include <sys/time.h> @@ -1996,10 +1926,7 @@ int ret = 1; if (RLIMIT_AS == RLIMIT_RSS) ret = 0; #endif return ret; -}], - zsh_cv_rlimit_rss_is_as=yes, - zsh_cv_rlimit_rss_is_as=no, - zsh_cv_rlimit_rss_is_as=no)]) +}]])],[zsh_cv_rlimit_rss_is_as=yes],[zsh_cv_rlimit_rss_is_as=no],[zsh_cv_rlimit_rss_is_as=no])]) if test x$zsh_cv_rlimit_rss_is_as = xyes; then AC_DEFINE(RLIMIT_RSS_IS_AS) @@ -2106,7 +2033,7 @@ AH_TEMPLATE([GETCWD_CALLS_MALLOC], if test x$ac_cv_func_getcwd = xyes; then AC_CACHE_CHECK(whether getcwd calls malloc to allocate memory, zsh_cv_getcwd_malloc, - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <unistd.h> #include <string.h> int main() { @@ -2118,10 +2045,7 @@ int main() { } return 1; } -], - zsh_cv_getcwd_malloc=yes, - zsh_cv_getcwd_malloc=no, - zsh_cv_getcwd_malloc=no)]) +]])],[zsh_cv_getcwd_malloc=yes],[zsh_cv_getcwd_malloc=no],[zsh_cv_getcwd_malloc=no])]) if test x$zsh_cv_getcwd_malloc = xyes; then AC_DEFINE(GETCWD_CALLS_MALLOC) fi @@ -2174,9 +2098,8 @@ dnl brk/sbrk PROTOTYPES dnl ------------------- AC_CACHE_CHECK(for brk() prototype in <unistd.h>, zsh_cv_header_unistd_h_brk_proto, -[AC_TRY_COMPILE([#include <unistd.h> -double brk();], [int i;], -zsh_cv_header_unistd_h_brk_proto=no, zsh_cv_header_unistd_h_brk_proto=yes)]) +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h> +double brk();]], [[int i;]])],[zsh_cv_header_unistd_h_brk_proto=no],[zsh_cv_header_unistd_h_brk_proto=yes])]) AH_TEMPLATE([HAVE_BRK_PROTO], [Define to 1 if there is a prototype defined for brk() on your system.]) if test x$zsh_cv_header_unistd_h_brk_proto = xyes; then @@ -2185,9 +2108,8 @@ fi AC_CACHE_CHECK(for sbrk() prototype in <unistd.h>, zsh_cv_header_unistd_h_sbrk_proto, -[AC_TRY_COMPILE([#include <unistd.h> -double sbrk();], [int i;], -zsh_cv_header_unistd_h_sbrk_proto=no, zsh_cv_header_unistd_h_sbrk_proto=yes)]) +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h> +double sbrk();]], [[int i;]])],[zsh_cv_header_unistd_h_sbrk_proto=no],[zsh_cv_header_unistd_h_sbrk_proto=yes])]) AH_TEMPLATE([HAVE_SBRK_PROTO], [Define to 1 if there is a prototype defined for sbrk() on your system.]) if test x$zsh_cv_header_unistd_h_sbrk_proto = xyes; then @@ -2202,10 +2124,8 @@ AH_TEMPLATE([HAVE_MKNOD_PROTO], if test "$ac_cv_prog_cc_stdc" != no; then AC_CACHE_CHECK(for mknod prototype in <sys/stat.h>, zsh_cv_header_sys_stat_h_mknod_proto, - [AC_TRY_COMPILE([#include <sys/stat.h> - int mknod(double x);], [int i;], - zsh_cv_header_sys_stat_h_mknod_proto=no, - zsh_cv_header_sys_stat_h_mknod_proto=yes)]) + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stat.h> + int mknod(double x);]], [[int i;]])],[zsh_cv_header_sys_stat_h_mknod_proto=no],[zsh_cv_header_sys_stat_h_mknod_proto=yes])]) if test x$zsh_cv_header_sys_stat_h_mknod_proto = xyes; then AC_DEFINE(HAVE_MKNOD_PROTO) fi @@ -2216,24 +2136,20 @@ dnl presence and location of ioctl prototype dnl ---------------------------------------- AC_CACHE_CHECK(for ioctl prototype in <unistd.h> or <termios.h>, zsh_cv_header_unistd_h_termios_h_ioctl_proto, -[AC_TRY_COMPILE([ +[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #ifdef HAVE_UNISTD_H # include <unistd.h> #endif #ifdef HAVE_TERMIOS_H # include <termios.h> #endif -double ioctl();], [int i;], -zsh_cv_header_unistd_h_termios_h_ioctl_proto=no, -zsh_cv_header_unistd_h_termios_h_ioctl_proto=yes)]) +double ioctl();]], [[int i;]])],[zsh_cv_header_unistd_h_termios_h_ioctl_proto=no],[zsh_cv_header_unistd_h_termios_h_ioctl_proto=yes])]) if test x$zsh_cv_header_unistd_h_termios_h_ioctl_proto = xno; then AC_CACHE_CHECK(for ioctl prototype in <sys/ioctl.h>, zsh_cv_header_sys_ioctl_h_ioctl_proto, - [AC_TRY_COMPILE([#include <sys/ioctl.h> - double ioctl();], [int i;], - zsh_cv_header_sys_ioctl_h_ioctl_proto=no, - zsh_cv_header_sys_ioctl_h_ioctl_proto=yes)]) + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/ioctl.h> + double ioctl();]], [[int i;]])],[zsh_cv_header_sys_ioctl_h_ioctl_proto=no],[zsh_cv_header_sys_ioctl_h_ioctl_proto=yes])]) else zsh_cv_header_sys_ioctl_h_ioctl_proto=no fi @@ -2258,9 +2174,7 @@ AH_TEMPLATE([SELECT_IN_SYS_SOCKET_H], if test x$ac_cv_header_sys_select_h != xyes; then AC_CACHE_CHECK(for select() in <sys/socket.h>, zsh_cv_header_socket_h_select_proto, - [AC_TRY_COMPILE([#include <sys/socket.h>], [fd_set fd;], - zsh_cv_header_socket_h_select_proto=yes, - zsh_cv_header_socket_h_select_proto=no)]) + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/socket.h>]], [[fd_set fd;]])],[zsh_cv_header_socket_h_select_proto=yes],[zsh_cv_header_socket_h_select_proto=no])]) if test x$zsh_cv_header_socket_h_select_proto = xyes; then AC_DEFINE(SELECT_IN_SYS_SOCKET_H) fi @@ -2277,7 +2191,7 @@ zsh_cv_sys_fifo, [if test "$host_os" = cygwin; then zsh_cv_sys_fifo=yes else -AC_TRY_RUN([ +AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <fcntl.h> #include <signal.h> main() @@ -2304,10 +2218,7 @@ main() unlink("/tmp/fifo$$"); exit(ret); } -], - zsh_cv_sys_fifo=yes, - zsh_cv_sys_fifo=no, - zsh_cv_sys_fifo=yes) +]])],[zsh_cv_sys_fifo=yes],[zsh_cv_sys_fifo=no],[zsh_cv_sys_fifo=yes]) fi]) AH_TEMPLATE([HAVE_FIFOS], [Define to 1 if system has working FIFOs.]) @@ -2321,7 +2232,7 @@ dnl for instance, BeOS R4.51 doesn't support hard links yet dnl ----------- AC_CACHE_CHECK(if link() works, zsh_cv_sys_link, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <unistd.h> #include <fcntl.h> main() @@ -2339,10 +2250,7 @@ main() unlink(newfile); exit(ret<0); } -], - zsh_cv_sys_link=yes, - zsh_cv_sys_link=no, - zsh_cv_sys_link=yes)]) +]])],[zsh_cv_sys_link=yes],[zsh_cv_sys_link=no],[zsh_cv_sys_link=yes])]) AH_TEMPLATE([HAVE_LINK], [Define to 1 if system has working link().]) if test x$zsh_cv_sys_link = xyes; then @@ -2355,7 +2263,7 @@ dnl should set errno to ESRCH, but some like BeOS R4.51 set to EINVAL dnl ----------- AC_CACHE_CHECK(if kill(pid, 0) returns ESRCH correctly, zsh_cv_sys_killesrch, -[AC_TRY_RUN([ +[AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <unistd.h> #include <signal.h> #include <errno.h> @@ -2365,10 +2273,7 @@ main() while (pid && (kill(pid, 0) == 0 || errno != ESRCH)) pid >>= 1; exit(errno!=ESRCH); } -], - zsh_cv_sys_killesrch=yes, - zsh_cv_sys_killesrch=no, - zsh_cv_sys_killesrch=yes)]) +]])],[zsh_cv_sys_killesrch=yes],[zsh_cv_sys_killesrch=no],[zsh_cv_sys_killesrch=yes])]) AH_TEMPLATE([BROKEN_KILL_ESRCH], [Define to 1 if kill(pid, 0) doesn't return ESRCH, ie BeOS R4.51.]) if test x$zsh_cv_sys_killesrch = xno; then @@ -2384,7 +2289,7 @@ Define to 1 if sigsuspend() is broken, ie BeOS R4.51.]) if test x$signals_style = xPOSIX_SIGNALS; then AC_CACHE_CHECK(if POSIX sigsuspend() works, zsh_cv_sys_sigsuspend, - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <signal.h> #include <unistd.h> int child=0; @@ -2409,10 +2314,7 @@ main() { exit(child==0); } } -], - zsh_cv_sys_sigsuspend=yes, - zsh_cv_sys_sigsuspend=no, - zsh_cv_sys_sigsuspend=yes)]) +]])],[zsh_cv_sys_sigsuspend=yes],[zsh_cv_sys_sigsuspend=no],[zsh_cv_sys_sigsuspend=yes])]) if test x$zsh_cv_sys_sigsuspend = xno; then AC_DEFINE(BROKEN_POSIX_SIGSUSPEND) fi @@ -2425,11 +2327,11 @@ dnl ----------- AH_TEMPLATE([BROKEN_TCSETPGRP], [Define to 1 if tcsetpgrp() doesn't work, ie BeOS R4.51.]) AC_ARG_WITH(tcsetpgrp, -AC_HELP_STRING([--with-tcsetpgrp], [assumes that tcsetpgrp() exists and works correctly]),[ +AS_HELP_STRING([--with-tcsetpgrp],[assumes that tcsetpgrp() exists and works correctly]),[ case "x$withval" in xyes) zsh_working_tcsetpgrp=yes;; xno) zsh_working_tcsetpgrp=no;; - *) AC_ERROR([please use --with-tcsetpgrp=yes or --with-tcsetpgrp=no]);; + *) AC_MSG_ERROR(please use --with-tcsetpgrp=yes or --with-tcsetpgrp=no);; esac],[zsh_working_tcsetpgrp=check]) if test "x$ac_cv_func_tcsetpgrp" = xyes; then case "x$zsh_working_tcsetpgrp" in @@ -2437,7 +2339,7 @@ case "x$zsh_working_tcsetpgrp" in trap "" TTOU > /dev/null 2>&1 || : AC_CACHE_CHECK(if tcsetpgrp() actually works, zsh_cv_sys_tcsetpgrp, - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <sys/types.h> #include <unistd.h> #include <fcntl.h> @@ -2450,14 +2352,13 @@ main() { if (ret < 0) exit(1); exit(0); } -], - zsh_cv_sys_tcsetpgrp=yes, [ +]])],[zsh_cv_sys_tcsetpgrp=yes],[ case $? in 1) zsh_cv_sys_tcsetpgrp=no;; 2) zsh_cv_sys_tcsetpgrp=notty;; *) zsh_cv_sys_tcsetpgrp=error;; esac - ], zsh_cv_sys_tcsetpgrp=yes)]) + ],[zsh_cv_sys_tcsetpgrp=yes])]) case "x$zsh_cv_sys_tcsetpgrp" in xno) AC_DEFINE(BROKEN_TCSETPGRP);; xyes) :;; @@ -2483,7 +2384,7 @@ AH_TEMPLATE([GETPWNAM_FAKED], if test x$ac_cv_func_getpwnam = xyes; then AC_CACHE_CHECK(if getpwnam() is faked, zsh_cv_sys_getpwnam_faked, - [AC_TRY_RUN([ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <pwd.h> main() { struct passwd *pw1, *pw2; @@ -2495,10 +2396,7 @@ main() { pw2=getpwnam(buf); exit(pw1!=0 && pw2!=0 && !strcmp(name, pw2->pw_name)); } -], - zsh_cv_sys_getpwnam_faked=no, - zsh_cv_sys_getpwnam_faked=yes, - zsh_cv_sys_getpwnam_faked=no)]) +]])],[zsh_cv_sys_getpwnam_faked=no],[zsh_cv_sys_getpwnam_faked=yes],[zsh_cv_sys_getpwnam_faked=no])]) if test x$zsh_cv_sys_getpwnam_faked = xyes; then AC_DEFINE(GETPWNAM_FAKED) fi @@ -2542,13 +2440,11 @@ if test x$ac_cv_have_dev_ptmx = xyes -o x$ac_cv_func_posix_openpt = xyes && \ test x$ac_cv_func_ptsname = xyes; then AC_CACHE_CHECK([if /dev/ptmx is usable], ac_cv_use_dev_ptmx, - [AC_TRY_COMPILE([#ifdef __linux + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef __linux #define _GNU_SOURCE 1 #endif #include <stdlib.h> -int ptsname();], , - ac_cv_use_dev_ptmx=no, - ac_cv_use_dev_ptmx=yes)]) +int ptsname();]], [[]])],[ac_cv_use_dev_ptmx=no],[ac_cv_use_dev_ptmx=yes])]) if test x$ac_cv_use_dev_ptmx = xyes; then AC_DEFINE(USE_DEV_PTMX) fi @@ -2558,11 +2454,17 @@ dnl ----------------- dnl multibyte support dnl ----------------- AC_ARG_ENABLE(multibyte, -AC_HELP_STRING([--enable-multibyte], [support multibyte characters]), +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= +dnl +dnl Note that iswblank is not included and checked separately. +dnl As iswblank() was added to C long after the others, we still +dnl want to enabled unicode support even if iswblank is not available +dnl (we then just do the SPC+TAB approximation) +dnl for zfunc in iswalnum iswcntrl iswdigit iswgraph iswlower iswprint \ iswpunct iswspace iswupper iswxdigit mbrlen mbrtowc towupper towlower \ wcschr wcscpy wcslen wcsncmp wcsncpy wcrtomb wcwidth wmemchr wmemcmp \ @@ -2588,7 +2490,7 @@ dnl AH_TEMPLATE([ENABLE_UNICODE9], [Define to 1 if you want use unicode9 character widths.]) AC_ARG_ENABLE(unicode9, -AC_HELP_STRING([--enable-unicode9], [compile with unicode9 character widths]), +AS_HELP_STRING([--enable-unicode9],[compile with unicode9 character widths]), [if test x$enableval = xyes; then AC_DEFINE(ENABLE_UNICODE9) fi]) @@ -2655,10 +2557,7 @@ if test x$zsh_cv_c_unicode_support = xyes; then AC_CACHE_CHECK(if the wcwidth() and/or iswprint() functions are broken, zsh_cv_c_broken_wcwidth, - [AC_TRY_RUN([$locale_prog], - zsh_cv_c_broken_wcwidth=yes, - zsh_cv_c_broken_wcwidth=no, - zsh_cv_c_broken_wcwidth=no)]) + [AC_RUN_IFELSE([AC_LANG_SOURCE([[$locale_prog]])],[zsh_cv_c_broken_wcwidth=yes],[zsh_cv_c_broken_wcwidth=no],[zsh_cv_c_broken_wcwidth=no])]) if test x$zsh_cv_c_broken_wcwidth = xyes; then AC_DEFINE(ENABLE_UNICODE9) fi @@ -2687,10 +2586,7 @@ if test x$zsh_cv_c_unicode_support = xyes; then AC_CACHE_CHECK(if the isprint() function is broken, zsh_cv_c_broken_isprint, - [AC_TRY_RUN([$locale_prog], - zsh_cv_c_broken_isprint=yes, - zsh_cv_c_broken_isprint=no, - zsh_cv_c_broken_isprint=no)]) + [AC_RUN_IFELSE([AC_LANG_SOURCE([[$locale_prog]])],[zsh_cv_c_broken_isprint=yes],[zsh_cv_c_broken_isprint=no],[zsh_cv_c_broken_isprint=no])]) if test x$zsh_cv_c_broken_isprint = xyes; then AC_DEFINE(BROKEN_ISPRINT) fi @@ -2702,7 +2598,7 @@ dnl AH_TEMPLATE([LIBC_MUSL], [Define to 1 if musl is being used as the C library]) AC_ARG_ENABLE(libc-musl, -AC_HELP_STRING([--enable-libc-musl], [compile with musl as the C library]), +AS_HELP_STRING([--enable-libc-musl],[compile with musl as the C library]), [if test x$enableval = xyes; then AC_DEFINE(LIBC_MUSL) fi]) @@ -2711,7 +2607,7 @@ dnl dnl static user lookup dnl AC_ARG_ENABLE(dynamic-nss, - AC_HELP_STRING([--disable-dynamic-nss], [do not call + AS_HELP_STRING([--disable-dynamic-nss],[do not call functions that will require dynamic NSS modules]), [zsh_cv_c_dynamic_nss=$enableval], @@ -2814,7 +2710,7 @@ elif test "$host_os" = cygwin; then elif test "x$dynamic" = xyes; then AC_CACHE_CHECK(if your system uses ELF binaries, zsh_cv_sys_elf, - [AC_TRY_RUN([/* Test for whether ELF binaries are produced */ + [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Test for whether ELF binaries are produced */ #include <fcntl.h> #include <stdlib.h> main(argc, argv) @@ -2829,10 +2725,7 @@ char *argv[]; exit(0); /* succeed (yes, it's ELF) */ else exit(1); /* fail */ -}], - zsh_cv_sys_elf=yes, - zsh_cv_sys_elf=no, - zsh_cv_sys_elf=yes)]) +}]])],[zsh_cv_sys_elf=yes],[zsh_cv_sys_elf=no],[zsh_cv_sys_elf=yes])]) # We use [0-9]* in case statements, so need to change quoting changequote(, ) @@ -2961,18 +2854,17 @@ char *argv[]; AC_CACHE_CHECK(if we can use -rdynamic, zsh_cv_rdynamic_available, old_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -rdynamic" -AC_TRY_LINK([], [], [zsh_cv_rdynamic_available=yes -EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-rdynamic}"], -[zsh_cvs_rdynamic_available=no]) +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_CACHE_CHECK(if your dlsym() needs a leading underscore, zsh_cv_func_dlsym_needs_underscore, [echo failed >conftestval && cat >conftest.c <<EOM fred () { } EOM - AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest.c 1>&AC_FD_CC) && - AC_TRY_COMMAND($DLLD $LDFLAGS $DLLDFLAGS -o conftest.$DL_EXT conftest.o 1>&AC_FD_CC) && - AC_TRY_RUN([ + AC_TRY_COMMAND($CC -c $CFLAGS $CPPFLAGS $DLCFLAGS conftest.c 1>&AS_MESSAGE_LOG_FD) && + AC_TRY_COMMAND($DLLD $LDFLAGS $DLLDFLAGS -o conftest.$DL_EXT conftest.o 1>&AS_MESSAGE_LOG_FD) && + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <stdio.h> #ifdef HPUX10DYNAMIC #include <dl.h> @@ -3024,10 +2916,8 @@ main() else fprintf (f, "no") ; exit(0); -}], zsh_cv_func_dlsym_needs_underscore=`cat conftestval`, - zsh_cv_func_dlsym_needs_underscore=failed - dynamic=no, - zsh_cv_func_dlsym_needs_underscore=no)]) +}]])],[zsh_cv_func_dlsym_needs_underscore=`cat conftestval`],[zsh_cv_func_dlsym_needs_underscore=failed + dynamic=no],[zsh_cv_func_dlsym_needs_underscore=no])]) if test "x$zsh_cv_func_dlsym_needs_underscore" = xyes; then AC_DEFINE(DLSYM_NEEDS_UNDERSCORE) elif test "x$zsh_cv_func_dlsym_needs_underscore" != xno; then |