summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cvsignore16
-rw-r--r--.git-blame-ignore-revs28
-rw-r--r--.gitignore1
-rw-r--r--ChangeLog1075
-rw-r--r--Completion/.cvsignore2
-rw-r--r--Completion/BSD/Command/_bectl1
-rw-r--r--Completion/BSD/Command/_csup26
-rw-r--r--Completion/BSD/Command/_freebsd-update1
-rw-r--r--Completion/BSD/Command/_ipfw2
-rw-r--r--Completion/BSD/Command/_jail20
-rw-r--r--Completion/BSD/Command/_jls15
-rw-r--r--Completion/BSD/Command/_kdump2
-rw-r--r--Completion/BSD/Command/_ktrace2
-rw-r--r--Completion/BSD/Command/_mdo48
-rw-r--r--Completion/BSD/Command/_pfctl3
-rw-r--r--Completion/BSD/Command/_portaudit14
-rw-r--r--Completion/BSD/Command/_sockstat6
-rw-r--r--Completion/BSD/Type/_jails43
-rw-r--r--Completion/Base/Completer/_all_matches2
-rw-r--r--Completion/Base/Core/_description2
-rw-r--r--Completion/Base/Core/_main_complete2
-rw-r--r--Completion/Base/Core/_message2
-rw-r--r--Completion/Base/Utility/_arg_compile199
-rw-r--r--Completion/Base/Utility/_numbers16
-rw-r--r--Completion/Base/Utility/_phony51
-rw-r--r--Completion/Base/Utility/_values4
-rw-r--r--Completion/Cygwin/Command/_cygcheck2
-rw-r--r--Completion/Darwin/Command/_caffeinate4
-rw-r--r--Completion/Darwin/Command/_fink4
-rw-r--r--Completion/Debian/Command/_apt16
-rw-r--r--Completion/Debian/Command/_auto-apt31
-rw-r--r--Completion/Debian/Command/_dak2
-rw-r--r--Completion/Debian/Command/_debfoster11
-rw-r--r--Completion/Debian/Command/_dpkg_source28
-rw-r--r--Completion/Debian/Command/_git-buildpackage43
-rw-r--r--Completion/Debian/Command/_invoke-rc.d4
-rw-r--r--Completion/Debian/Command/_module-assistant3
-rw-r--r--Completion/Debian/Command/_update-alternatives6
-rw-r--r--Completion/Debian/Command/_update-rc.d16
-rw-r--r--Completion/Linux/Command/_acpi2
-rw-r--r--Completion/Linux/Command/_blkid4
-rw-r--r--Completion/Linux/Command/_btrfs12
-rw-r--r--Completion/Linux/Command/_chrt13
-rw-r--r--Completion/Linux/Command/_cryptsetup10
-rw-r--r--Completion/Linux/Command/_ethtool68
-rw-r--r--Completion/Linux/Command/_findmnt4
-rw-r--r--Completion/Linux/Command/_gpasswd2
-rw-r--r--Completion/Linux/Command/_ip (renamed from Completion/Unix/Command/_ip)119
-rw-r--r--Completion/Linux/Command/_ipset4
-rw-r--r--Completion/Linux/Command/_iptables6
-rw-r--r--Completion/Linux/Command/_kbd (renamed from Completion/Unix/Command/_loadkeys)0
-rw-r--r--Completion/Linux/Command/_kmod (renamed from Completion/Linux/Command/_modutils)30
-rw-r--r--Completion/Linux/Command/_ladspa (renamed from Completion/Linux/Command/_analyseplugin)0
-rw-r--r--Completion/Linux/Command/_losetup5
-rw-r--r--Completion/Linux/Command/_lsblk4
-rw-r--r--Completion/Linux/Command/_mdadm10
-rw-r--r--Completion/Linux/Command/_mondo54
-rw-r--r--Completion/Linux/Command/_namei15
-rw-r--r--Completion/Linux/Command/_opkg8
-rw-r--r--Completion/Linux/Command/_selinux5
-rw-r--r--Completion/Linux/Command/_ss12
-rw-r--r--Completion/Linux/Command/_strace20
-rw-r--r--Completion/Linux/Command/_tracepath3
-rw-r--r--Completion/Linux/Command/_valgrind45
-rw-r--r--Completion/Mandriva/Command/_rebootin29
-rw-r--r--Completion/Solaris/Command/_ipadm2
-rw-r--r--Completion/Solaris/Command/_pkgadd (renamed from Completion/Unix/Command/_pkgadd)4
-rw-r--r--Completion/Solaris/Command/_pkginfo (renamed from Completion/Unix/Command/_pkginfo)4
-rw-r--r--Completion/Solaris/Command/_pkgrm (renamed from Completion/Unix/Command/_pkgrm)4
-rw-r--r--Completion/Solaris/Type/_pkg_instances (renamed from Completion/Unix/Command/_pkg_instance)0
-rw-r--r--Completion/Unix/Command/_7zip209
-rw-r--r--Completion/Unix/Command/_aap50
-rw-r--r--Completion/Unix/Command/_abcde2
-rw-r--r--Completion/Unix/Command/_age24
-rw-r--r--Completion/Unix/Command/_ansible13
-rw-r--r--Completion/Unix/Command/_attr6
-rw-r--r--Completion/Unix/Command/_base6438
-rw-r--r--Completion/Unix/Command/_baz585
-rw-r--r--Completion/Unix/Command/_bittorrent100
-rw-r--r--Completion/Unix/Command/_cat86
-rw-r--r--Completion/Unix/Command/_cdrecord4
-rw-r--r--Completion/Unix/Command/_chdman195
-rw-r--r--Completion/Unix/Command/_chown14
-rw-r--r--Completion/Unix/Command/_clay42
-rw-r--r--Completion/Unix/Command/_column14
-rw-r--r--Completion/Unix/Command/_configure24
-rw-r--r--Completion/Unix/Command/_cpio9
-rw-r--r--Completion/Unix/Command/_cplay8
-rw-r--r--Completion/Unix/Command/_csplit4
-rw-r--r--Completion/Unix/Command/_darcs38
-rw-r--r--Completion/Unix/Command/_df2
-rw-r--r--Completion/Unix/Command/_diffstat1
-rw-r--r--Completion/Unix/Command/_dig8
-rw-r--r--Completion/Unix/Command/_drill2
-rw-r--r--Completion/Unix/Command/_du12
-rw-r--r--Completion/Unix/Command/_echo32
-rw-r--r--Completion/Unix/Command/_entr2
-rw-r--r--Completion/Unix/Command/_env4
-rw-r--r--Completion/Unix/Command/_ffmpeg1649
-rw-r--r--Completion/Unix/Command/_find14
-rw-r--r--Completion/Unix/Command/_fish78
-rw-r--r--Completion/Unix/Command/_flac4
-rw-r--r--Completion/Unix/Command/_fsh22
-rw-r--r--Completion/Unix/Command/_fuser5
-rw-r--r--Completion/Unix/Command/_gcc100
-rw-r--r--Completion/Unix/Command/_gcore2
-rw-r--r--Completion/Unix/Command/_ghostscript2
-rw-r--r--Completion/Unix/Command/_git443
-rw-r--r--Completion/Unix/Command/_gnutls3
-rw-r--r--Completion/Unix/Command/_gpg1
-rw-r--r--Completion/Unix/Command/_gphoto211
-rw-r--r--Completion/Unix/Command/_hardlink43
-rw-r--r--Completion/Unix/Command/_htop (renamed from Completion/Linux/Command/_htop)4
-rw-r--r--Completion/Unix/Command/_id4
-rw-r--r--Completion/Unix/Command/_imagemagick2
-rw-r--r--Completion/Unix/Command/_init_d23
-rw-r--r--Completion/Unix/Command/_initctl184
-rw-r--r--Completion/Unix/Command/_jq2
-rw-r--r--Completion/Unix/Command/_ldd11
-rw-r--r--Completion/Unix/Command/_less11
-rw-r--r--Completion/Unix/Command/_ln2
-rw-r--r--Completion/Unix/Command/_ls14
-rw-r--r--Completion/Unix/Command/_lsof2
-rw-r--r--Completion/Unix/Command/_lua2
-rw-r--r--Completion/Unix/Command/_man4
-rw-r--r--Completion/Unix/Command/_monotone43
-rw-r--r--Completion/Unix/Command/_moosic487
-rw-r--r--Completion/Unix/Command/_mount4
-rw-r--r--Completion/Unix/Command/_mpc4
-rw-r--r--Completion/Unix/Command/_mtr3
-rw-r--r--Completion/Unix/Command/_mv2
-rw-r--r--Completion/Unix/Command/_myrepos2
-rw-r--r--Completion/Unix/Command/_nano87
-rw-r--r--Completion/Unix/Command/_netstat2
-rw-r--r--Completion/Unix/Command/_ngrep2
-rw-r--r--Completion/Unix/Command/_nm8
-rw-r--r--Completion/Unix/Command/_nmap199
-rw-r--r--Completion/Unix/Command/_numfmt1
-rw-r--r--Completion/Unix/Command/_objdump9
-rw-r--r--Completion/Unix/Command/_opustools4
-rw-r--r--Completion/Unix/Command/_pandoc27
-rw-r--r--Completion/Unix/Command/_patchutils10
-rw-r--r--Completion/Unix/Command/_perl2
-rw-r--r--Completion/Unix/Command/_pgrep29
-rw-r--r--Completion/Unix/Command/_php2
-rw-r--r--Completion/Unix/Command/_pip1
-rw-r--r--Completion/Unix/Command/_pmap2
-rw-r--r--Completion/Unix/Command/_postfix2
-rw-r--r--Completion/Unix/Command/_postgresql4
-rw-r--r--Completion/Unix/Command/_ps76
-rw-r--r--Completion/Unix/Command/_pump24
-rw-r--r--Completion/Unix/Command/_pv6
-rw-r--r--Completion/Unix/Command/_rar13
-rw-r--r--Completion/Unix/Command/_readelf13
-rw-r--r--Completion/Unix/Command/_rm2
-rw-r--r--Completion/Unix/Command/_rmdir2
-rw-r--r--Completion/Unix/Command/_rsync8
-rw-r--r--Completion/Unix/Command/_ruby125
-rw-r--r--Completion/Unix/Command/_screen1
-rw-r--r--Completion/Unix/Command/_script3
-rw-r--r--Completion/Unix/Command/_sed2
-rw-r--r--Completion/Unix/Command/_service10
-rw-r--r--Completion/Unix/Command/_sh177
-rw-r--r--Completion/Unix/Command/_shutdown59
-rw-r--r--Completion/Unix/Command/_sleep25
-rw-r--r--Completion/Unix/Command/_sort1
-rw-r--r--Completion/Unix/Command/_sqlite4
-rw-r--r--Completion/Unix/Command/_ssh12
-rw-r--r--Completion/Unix/Command/_strings7
-rw-r--r--Completion/Unix/Command/_strip4
-rw-r--r--Completion/Unix/Command/_subversion4
-rw-r--r--Completion/Unix/Command/_sudo4
-rw-r--r--Completion/Unix/Command/_tcpdump3
-rw-r--r--Completion/Unix/Command/_tex2
-rw-r--r--Completion/Unix/Command/_texinfo17
-rw-r--r--Completion/Unix/Command/_tiff8
-rw-r--r--Completion/Unix/Command/_timeout6
-rw-r--r--Completion/Unix/Command/_tla631
-rw-r--r--Completion/Unix/Command/_tmux33
-rw-r--r--Completion/Unix/Command/_totd13
-rw-r--r--Completion/Unix/Command/_tree60
-rw-r--r--Completion/Unix/Command/_twidge77
-rw-r--r--Completion/Unix/Command/_w9
-rw-r--r--Completion/Unix/Command/_w3m10
-rw-r--r--Completion/Unix/Command/_wget4
-rw-r--r--Completion/Unix/Command/_xmlsoft16
-rw-r--r--Completion/Unix/Command/_xxd15
-rw-r--r--Completion/Unix/Command/_xz8
-rw-r--r--Completion/Unix/Command/_zdump26
-rw-r--r--Completion/Unix/Command/_zfs134
-rw-r--r--Completion/Unix/Command/_zip2
-rw-r--r--Completion/Unix/Command/_zstd2
-rw-r--r--Completion/Unix/Type/_arch_archives14
-rw-r--r--Completion/Unix/Type/_arch_namespace105
-rw-r--r--Completion/Unix/Type/_date_formats4
-rw-r--r--Completion/Unix/Type/_diff_options2
-rw-r--r--Completion/Unix/Type/_pspdf2
-rw-r--r--Completion/Unix/Type/_terminals37
-rw-r--r--Completion/X/Command/_acroread119
-rw-r--r--Completion/X/Command/_dcop119
-rw-r--r--Completion/X/Command/_mplayer2
-rw-r--r--Completion/X/Command/_nedit2
-rw-r--r--Completion/X/Command/_netscape93
-rw-r--r--Completion/X/Command/_papers18
-rw-r--r--Completion/X/Command/_pdftk17
-rw-r--r--Completion/X/Command/_xv2
-rw-r--r--Completion/Zsh/Command/_alias2
-rw-r--r--Completion/Zsh/Command/_bindkey2
-rw-r--r--Completion/Zsh/Command/_command2
-rw-r--r--Completion/Zsh/Command/_compadd2
-rw-r--r--Completion/Zsh/Command/_compinit9
-rw-r--r--Completion/Zsh/Command/_dirs2
-rw-r--r--Completion/Zsh/Command/_disable2
-rw-r--r--Completion/Zsh/Command/_emulate9
-rw-r--r--Completion/Zsh/Command/_enable2
-rw-r--r--Completion/Zsh/Command/_exec2
-rw-r--r--Completion/Zsh/Command/_fc2
-rw-r--r--Completion/Zsh/Command/_hash4
-rw-r--r--Completion/Zsh/Command/_jobs_builtin2
-rw-r--r--Completion/Zsh/Command/_kill2
-rw-r--r--Completion/Zsh/Command/_print2
-rw-r--r--Completion/Zsh/Command/_prompt2
-rw-r--r--Completion/Zsh/Command/_read2
-rw-r--r--Completion/Zsh/Command/_set4
-rw-r--r--Completion/Zsh/Command/_strftime2
-rw-r--r--Completion/Zsh/Command/_tcpsys2
-rw-r--r--Completion/Zsh/Command/_typeset2
-rw-r--r--Completion/Zsh/Command/_unhash2
-rw-r--r--Completion/Zsh/Command/_vared2
-rw-r--r--Completion/Zsh/Command/_which8
-rw-r--r--Completion/Zsh/Command/_zattr8
-rw-r--r--Completion/Zsh/Command/_zcompile2
-rw-r--r--Completion/Zsh/Command/_zed6
-rw-r--r--Completion/Zsh/Command/_zformat24
-rw-r--r--Completion/Zsh/Command/_zle8
-rw-r--r--Completion/Zsh/Command/_zmodload2
-rw-r--r--Completion/Zsh/Command/_zmv2
-rw-r--r--Completion/Zsh/Command/_zparseopts3
-rw-r--r--Completion/Zsh/Command/_zpty2
-rw-r--r--Completion/Zsh/Command/_zsocket2
-rw-r--r--Completion/Zsh/Command/_zstyle2
-rw-r--r--Completion/Zsh/Function/__arguments2
-rw-r--r--Completion/Zsh/Type/_history_modifiers1
-rw-r--r--Completion/Zsh/Type/_jobs_fg7
-rw-r--r--Completion/compdump2
-rw-r--r--Completion/compinit58
-rw-r--r--Completion/openSUSE/Command/_SUSEconfig14
-rw-r--r--Config/.cvsignore2
-rw-r--r--Config/version.mk4
-rw-r--r--Doc/.cvsignore20
-rw-r--r--Doc/Makefile.in8
-rw-r--r--Doc/Zsh/.cvsignore4
-rw-r--r--Doc/Zsh/arith.yo2
-rw-r--r--Doc/Zsh/builtins.yo38
-rw-r--r--Doc/Zsh/compat.yo5
-rw-r--r--Doc/Zsh/compsys.yo64
-rw-r--r--Doc/Zsh/compwid.yo12
-rw-r--r--Doc/Zsh/contrib.yo87
-rw-r--r--Doc/Zsh/expn.yo4
-rw-r--r--Doc/Zsh/grammar.yo1
-rw-r--r--Doc/Zsh/invoke.yo2
-rw-r--r--Doc/Zsh/manual.yo4
-rw-r--r--Doc/Zsh/mod_nearcolor.yo12
-rw-r--r--Doc/Zsh/mod_pcre.yo22
-rw-r--r--Doc/Zsh/mod_random.yo24
-rw-r--r--Doc/Zsh/mod_socket.yo7
-rw-r--r--Doc/Zsh/mod_tcp.yo31
-rw-r--r--Doc/Zsh/mod_watch.yo7
-rw-r--r--Doc/Zsh/mod_zpty.yo18
-rw-r--r--Doc/Zsh/mod_zutil.yo103
-rw-r--r--Doc/Zsh/options.yo27
-rw-r--r--Doc/Zsh/params.yo22
-rw-r--r--Doc/Zsh/restricted.yo84
-rw-r--r--Doc/Zsh/zle.yo9
-rw-r--r--Doc/help/.cvsignore1
-rw-r--r--Doc/intro.ms673
-rw-r--r--Doc/ztexi.yo6
-rw-r--r--Etc/.cvsignore4
-rw-r--r--Etc/CONTRIBUTORS2
-rw-r--r--Etc/creating-a-release.txt39
-rw-r--r--Functions/.cvsignore2
-rw-r--r--Functions/Misc/is-at-least87
-rw-r--r--Functions/Misc/regexp-replace125
-rwxr-xr-xFunctions/Misc/zgetopt181
-rw-r--r--Functions/Misc/zkbd10
-rw-r--r--Functions/Misc/zmv2
-rw-r--r--NEWS86
-rw-r--r--README51
-rw-r--r--Src/.cvsignore35
-rw-r--r--Src/Builtins/.cvsignore17
-rw-r--r--Src/Builtins/rlimits.c25
-rw-r--r--Src/Builtins/sched.c7
-rw-r--r--Src/Modules/.cvsignore18
-rw-r--r--Src/Modules/attr.c8
-rw-r--r--Src/Modules/attr.mdd2
-rw-r--r--Src/Modules/cap.c36
-rw-r--r--Src/Modules/cap.mdd2
-rw-r--r--Src/Modules/clone.c6
-rw-r--r--Src/Modules/curses.c139
-rw-r--r--Src/Modules/db_gdbm.c49
-rw-r--r--Src/Modules/db_gdbm.mdd4
-rw-r--r--Src/Modules/hlgroup.c4
-rw-r--r--Src/Modules/ksh93.c24
-rw-r--r--Src/Modules/langinfo.c13
-rw-r--r--Src/Modules/langinfo.mdd2
-rw-r--r--Src/Modules/nearcolor.c18
-rw-r--r--Src/Modules/parameter.c73
-rw-r--r--Src/Modules/pcre.c2
-rw-r--r--Src/Modules/pcre.mdd2
-rw-r--r--Src/Modules/random.c43
-rw-r--r--Src/Modules/random_real.c2
-rw-r--r--Src/Modules/regex.c2
-rw-r--r--Src/Modules/socket.c27
-rw-r--r--Src/Modules/stat.c9
-rw-r--r--Src/Modules/system.c10
-rw-r--r--Src/Modules/tcp.c48
-rw-r--r--Src/Modules/tcp.h5
-rw-r--r--Src/Modules/termcap.c41
-rw-r--r--Src/Modules/terminfo.c34
-rw-r--r--Src/Modules/watch.c26
-rw-r--r--Src/Modules/zftp.c35
-rw-r--r--Src/Modules/zpty.c56
-rw-r--r--Src/Modules/zselect.c4
-rw-r--r--Src/Modules/zutil.c355
-rw-r--r--Src/Zle/.cvsignore20
-rw-r--r--Src/Zle/compcore.c15
-rw-r--r--Src/Zle/compctl.c155
-rw-r--r--Src/Zle/complete.c34
-rw-r--r--Src/Zle/complist.c37
-rw-r--r--Src/Zle/compmatch.c10
-rw-r--r--Src/Zle/compresult.c16
-rw-r--r--Src/Zle/computil.c118
-rw-r--r--Src/Zle/termquery.c62
-rw-r--r--Src/Zle/zle_hist.c3
-rw-r--r--Src/Zle/zle_keymap.c7
-rw-r--r--Src/Zle/zle_main.c13
-rw-r--r--Src/Zle/zle_misc.c25
-rw-r--r--Src/Zle/zle_move.c4
-rw-r--r--Src/Zle/zle_params.c26
-rw-r--r--Src/Zle/zle_refresh.c110
-rw-r--r--Src/Zle/zle_thingy.c29
-rw-r--r--Src/Zle/zle_tricky.c44
-rw-r--r--Src/Zle/zle_utils.c37
-rw-r--r--Src/Zle/zle_vi.c15
-rw-r--r--Src/Zle/zle_word.c2
-rw-r--r--Src/builtin.c222
-rw-r--r--Src/exec.c298
-rw-r--r--Src/glob.c41
-rw-r--r--Src/hist.c4
-rw-r--r--Src/init.c63
-rw-r--r--Src/jobs.c89
-rw-r--r--Src/lex.c2
-rw-r--r--Src/loop.c6
-rw-r--r--Src/math.c16
-rw-r--r--Src/mkmakemod.sh5
-rw-r--r--Src/module.c26
-rw-r--r--Src/options.c63
-rw-r--r--Src/params.c522
-rw-r--r--Src/parse.c24
-rw-r--r--Src/pattern.c17
-rw-r--r--Src/prompt.c4
-rw-r--r--Src/signals.c2
-rw-r--r--Src/sort.c5
-rw-r--r--Src/subst.c39
-rw-r--r--Src/utils.c31
-rw-r--r--Src/zsh.h10
-rw-r--r--Src/zsh.mdd2
-rw-r--r--Test/.cvsignore3
-rw-r--r--Test/A01grammar.ztst6
-rw-r--r--Test/A02alias.ztst32
-rw-r--r--Test/A05execution.ztst9
-rw-r--r--Test/A06assign.ztst33
-rw-r--r--Test/A09zwc.ztst39
-rw-r--r--Test/B02typeset.ztst2
-rw-r--r--Test/B06fc.ztst13
-rw-r--r--Test/B08shift.ztst18
-rw-r--r--Test/B10getopts.ztst65
-rw-r--r--Test/B11kill.ztst39
-rw-r--r--Test/B12limit.ztst25
-rw-r--r--Test/C02cond.ztst19
-rw-r--r--Test/C03traps.ztst75
-rw-r--r--Test/D03procsubst.ztst9
-rw-r--r--Test/D04parameter.ztst254
-rw-r--r--Test/D06subscript.ztst15
-rw-r--r--Test/D07multibyte.ztst29
-rw-r--r--Test/E01options.ztst42
-rw-r--r--Test/K01nameref.ztst1060
-rw-r--r--Test/V01zmodload.ztst11
-rw-r--r--Test/V06parameter.ztst19
-rw-r--r--Test/V09datetime.ztst4
-rw-r--r--Test/V11db_gdbm.ztst49
-rw-r--r--Test/V12zparseopts.ztst134
-rw-r--r--Test/V13zformat.ztst248
-rw-r--r--Test/V15nearcolor.ztst100
-rw-r--r--Test/W01history.ztst106
-rw-r--r--Test/W02jobs.ztst141
-rw-r--r--Test/W03jobparameters.ztst7
-rw-r--r--Test/X06termquery.ztst1
-rw-r--r--Test/Y01completion.ztst34
-rw-r--r--Test/Y03arguments.ztst140
-rw-r--r--Test/Y04regexargs.ztst111
-rw-r--r--Test/Y05describe.ztst105
-rw-r--r--Test/Y06values.ztst246
-rw-r--r--Test/Z01is-at-least.ztst27
-rw-r--r--Test/Z04zgetopt.ztst222
-rw-r--r--Test/comptest37
-rw-r--r--Test/runtests.zsh46
-rwxr-xr-xTest/ztst.zsh72
-rwxr-xr-xUtil/zsh-merge-changelog125
-rw-r--r--aczsh.m42
-rwxr-xr-xconfig.guess1283
-rwxr-xr-xconfig.sub1438
-rw-r--r--configure.ac228
413 files changed, 13636 insertions, 8203 deletions
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index 95cdc587b..000000000
--- a/.cvsignore
+++ /dev/null
@@ -1,16 +0,0 @@
-Makefile
-META-FAQ
-config.cache
-config.h
-config.h.in
-config.log
-config.modules
-config.modules.sh
-config.status
-configure
-cscope.out
-stamp-h
-stamp-h.in
-autom4te.cache
-*.swp
-.git
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 000000000..7a4bb5650
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,28 @@
+# commits to be ignored by git blame. use as follows:
+#
+# git config blame.ignoreRevsFile .git-blame-ignore-revs
+#
+# .git-blame-ignore-revs is the conventional file name for this purpose, so you
+# may prefer to use it globally instead. this is possible in git 2.53+:
+#
+# git config --global blame.ignoreRevsFile ':(optional).git-blame-ignore-revs'
+#
+# in general, only trivial, non-functionality-affecting commits (e.g. typo and
+# white-space fixes) should be added to this list
+#
+# please add in ascending chronological order
+
+# unposted: Fix inconsistent white space in change log
+92b0e885d6273315602668eb50f25310020fee13
+# unposted: fix indentation (whitespace-only change)
+6c6200520afa0409c5c310cd421f33353c44c61d
+# 45101: Adjust white space
+1a8c69e26fc7e64e1b5e2837d7754a910b6a0c26
+# Clean up error-message white space
+4ce66857b71b40a0661df3780ff557f2b0f4cb13
+# 46139: _git: Remove hanging whitespaces
+d839833e4e00ee320a353846eaa235ab952181f0
+# 49435: Remove trailing whitespaces in expn.yo
+02f75cf38699b99340c1d2c8f5a9d9aaf81432e7
+# 54806: reformat interactive tests for readability (whitespace only)
+4d1193772b093e23c533e86cb11448d36f38c8c2
diff --git a/.gitignore b/.gitignore
index ec2f56642..b8922ef6f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -155,3 +155,4 @@ Src/Zle/zle_widget.h
Test/*.tmp
/.project
+.DS_Store
diff --git a/ChangeLog b/ChangeLog
index c532eeb4e..e220499de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,1080 @@
+2026-07-03 Oliver Kiddle <opk@zsh.org>
+
+ * unposted: Completion/X/Command/_mplayer, Completion/X/Command/_xv:
+ complete more media file types
+
+ * unposted (c.f. 54878): Completion/Unix/Command/_age: import
+ ZSH-licenced age completion from zsh-completions (by Hydrargyrum)
+
+ * 54899: Completion/Linux/Command/_namei: new completion
+
+2026-07-03 dana <dana@dana.is>
+
+ * 54891: Completion/Solaris/Command/_pkgadd,
+ Completion/Solaris/Command/_pkginfo,
+ Completion/Solaris/Command/_pkgrm,
+ Completion/Solaris/Type/_pkg_instances: move/rename
+ _pkg_instance -> _pkg_instances
+
+ * 54891: Completion/Linux/Command/_ip,
+ Completion/Linux/Command/_kbd, Completion/Linux/Command/_kmod,
+ Completion/Linux/Command/_ladspa,
+ Completion/Solaris/Command/_pkgadd,
+ Completion/Solaris/Command/_pkginfo,
+ Completion/Solaris/Command/_pkgrm,
+ Completion/Unix/Command/_htop: move/rename several functions
+
+ * 54891: Completion/BSD/Command/_csup,
+ Completion/BSD/Command/_portaudit,
+ Completion/Base/Utility/_arg_compile,
+ Completion/Debian/Command/_auto-apt,
+ Completion/Debian/Command/_git-buildpackage,
+ Completion/Linux/Command/_mondo,
+ Completion/Mandriva/Command/_rebootin,
+ Completion/Unix/Command/_aap, Completion/Unix/Command/_baz,
+ Completion/Unix/Command/_bittorrent,
+ Completion/Unix/Command/_clay, Completion/Unix/Command/_cplay,
+ Completion/Unix/Command/_fsh, Completion/Unix/Command/_initctl,
+ Completion/Unix/Command/_monotone,
+ Completion/Unix/Command/_moosic, Completion/Unix/Command/_pump,
+ Completion/Unix/Command/_tla, Completion/Unix/Command/_totd,
+ Completion/Unix/Command/_twidge,
+ Completion/Unix/Type/_arch_archives,
+ Completion/Unix/Type/_arch_namespace,
+ Completion/X/Command/_acroread, Completion/X/Command/_dcop,
+ Completion/X/Command/_netscape,
+ Completion/openSUSE/Command/_SUSEconfig: remove obsolete
+ functions
+
+ * 54889: Src/Zle/computil.c, Test/Y03arguments.ztst:
+ comparguments: always parse optargs as optargs
+
+ * 54876: Src/Zle/computil.c, Test/Y03arguments.ztst:
+ comparguments: search more thoroughly for foreign-set options
+
+ * unposted: Completion/Unix/Command/_ping: revert previous
+ _arguments fix
+
+ * unposted: Completion/BSD/Command/_pfctl,
+ Completion/Debian/Command/_module-assistant,
+ Completion/Unix/Command/_ping, Completion/Unix/Command/_tiff,
+ Completion/Unix/Command/_zfs: fix ambiguous arg specs
+
+ * unposted: Completion/Unix/Command/_pip: remove -b
+
+2026-07-02 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+
+ * 54893: Functions/Misc/is-at-least, Test/Z01is-at-least.ztst:
+ fix/simplify is-at-least
+
+2026-07-01 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+
+ * unposted: Completion/Unix/Command/_attr: $list was removed
+ in 54528
+
+2026-07-01 dana <dana@dana.is>
+
+ * unposted: Completion/Zsh/Command/_zformat: add _zformat
+
+ * unposted: README: document ::= changes
+
+ * unposted: .git-blame-ignore-revs: add 4d1193772b (54806) to
+ ignore-revs
+
+ * unposted: Completion/X/Command/_sioyek: remove _sioyek
+
+ * Štěpán Němec: 54871: Doc/Zsh/compwid.yo: add index markup for
+ the Completion Condition Codes
+
+ * Štěpán Němec: 54870: Doc/Zsh/builtins.yo, Doc/Zsh/compsys.yo,
+ Doc/Zsh/options.yo, Doc/intro.ms, Etc/CONTRIBUTORS: Fix some
+ doc typos
+
+ * Štěpán Němec: 54869: Doc/Zsh/compsys.yo: move 'expl' index
+ annotation to (more) proper place(s)
+
+ * Štěpán Němec: 54868: Completion/Unix/Command/_perl: fix -c
+ option description
+
+2026-07-01 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+
+ * 54648: Test/K01nameref.ztst: set $module_path in child zsh
+
+ * 54847 + 54849: Test/V15nearcolor.ztst: skip only 88 or 256
+ color tests if corresponding terminal is not available
+
+2026-06-30 dana <dana@dana.is>
+
+ * unposted: Completion/Unix/Command/_nano: fix syntaxes tag
+
+2026-06-29 dana <dana@dana.is>
+
+ * 54863: Completion/Unix/Command/_configure,
+ Completion/Unix/Command/_ffmpeg, Completion/Unix/Command/_git,
+ Completion/Unix/Command/_php,
+ Completion/Unix/Command/_postgresql: compadd -q -> -r
+
+2026-06-28 dana <dana@dana.is>
+
+ * unposted: Completion/Base/Utility/_numbers: fix compadd -q
+ spec
+
+ * unposted: Completion/Unix/Command/_configure: auto-remove =
+ after variable name
+
+2026-06-23 dana <dana@dana.is>
+
+ * 54830 (tweaked): Completion/Unix/Command/_ffmpeg: improve
+ _ffmpeg
+
+ * 54831: Src/Zle/computil.c, Test/Y03arguments.ztst:
+ comparguments: treat empty description as if missing
+
+ * 54818: Doc/Zsh/compsys.yo: clarify _arguments {...} action
+ behaviour
+
+ * 54823: Doc/Zsh/expn.yo: clarify ::= behaviour
+
+2026-06-23 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
+
+ * 54838: Test/D04parameter.ztst: avoid hang up if FIFO is used
+ for process substitution
+
+2026-06-22 Bart Schaefer <schaefer@zsh.org>
+
+ * Philippe: 54805: Test/comptest: capture any DPUTS output during
+ completion tests
+
+ * Philippe: 54806: Test/A02alias.ztst, Test/B06fc.ztst,
+ Test/D04parameter.ztst, Test/K01nameref.ztst,
+ Test/W01history.ztst: Null prompts in interactive tests to avoid
+ unnecessary stderr; reformat for readability
+
+ * Philippe: 54792: Src/params.c, Test/K01nameref.ztst: prevent
+ named references from being entered as named directories
+
+2026-06-23 Oliver Kiddle <opk@zsh.org>
+
+ * Felipe Contreras: 47546: Src/builtin.c: trivial cleanup
+
+ * 54844: Completion/Unix/Command/_configure,
+ Completion/Unix/Command/_gcc: complete variable assignments
+ with configure
+
+ * 54828: Completion/Unix/Command/_shutdown: handle time arguments
+
+2026-06-21 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54822: Src/subst.c, Test/D04parameter.ztst: the ::= fix in
+ 54674 was incomplete
+
+2026-06-20 dana <dana@dana.is>
+
+ * Nuke: 54790 (tweaked): Completion/Unix/Command/_ffmpeg:
+ update for modern ffmpeg
+
+ * Holger Hoffstätte: github #174: Completion/Unix/Command/_gcc:
+ _gcc: coroutines-ts was merged in 2020
+
+ * 54808: .git-blame-ignore-revs: add .git-blame-ignore-revs
+
+ * 54773: Src/params.c, Test/D06subscript.ztst: make out-of-range
+ (w) subscript index work like others
+
+ * 54768: Completion/Base/Core/_description,
+ Completion/Base/Core/_main_complete,
+ Completion/Base/Core/_message,
+ Completion/Base/Utility/_numbers,
+ Completion/Debian/Command/_git-buildpackage,
+ Completion/Linux/Command/_valgrind,
+ Completion/Unix/Command/_csplit,
+ Completion/Unix/Command/_gcore, Completion/Unix/Command/_mpc,
+ Completion/Unix/Command/_nano,
+ Completion/Unix/Command/_opustools,
+ Completion/Unix/Type/_date_formats, Test/Y01completion.ztst,
+ Test/Y03arguments.ztst, Test/Y05describe.ztst,
+ Test/Y06values.ztst: use `zformat -q` for formatting
+
+ * 54767: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c,
+ Test/V13zformat.ztst: zformat: replace -qn by spec quoting
+ indicator syntax
+
+ * 54763: Completion/Unix/Command/_sh: support more shells +
+ options
+
+2026-06-19 Oliver Kiddle <opk@zsh.org>
+
+ * 54800, 54807: Completion/...: completion options update
+
+2026-06-18 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54801: Src/Zle/compctl.c, Src/Zle/complete.c: fix two more
+ warnings from 54710
+
+2026-06-16 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54788: Completion/Unix/Command/_shutdown: fix shutdown
+ completion when not using systemd
+
+ * 54784: configure.ac: cache the last few checks in configure.ac
+
+ * 54776: Src/Modules/system.c, Src/Modules/zftp.c,
+ Src/Zle/complete.c, Src/exec.c, Src/glob.c: fix warnings from
+ 54710
+
+ * 54771: Src/Zle/compcore.c, Test/Y01completion.ztst: fix a bug
+ in nosort deduplication
+
+2026-06-15 dana <dana@dana.is>
+
+ * unposted: Completion/Unix/Command/_ansible: remove duplicate
+ option
+
+ * 54764: Src/utils.c: zerrmsg: handle null pointers with %s/%l
+
+2026-06-14 Mikael Magnusson <mikachu@gmail.com>
+
+ * unposted: Completion/Unix/Command/_zip: fix return code in _zip
+
+2026-06-14 Oliver Kiddle <opk@zsh.org>
+
+ * unposted: config.guess, config.sub: update to 2026-05-17
+
+ * unposted: Completion/Unix/Command/_tcpdump: remove dead code
+
+ * unposted: Completion/Unix/Command/_cdrecord: use _tilde_files
+
+ * 54665: Doc/Zsh/compsys.yo, Completion/Base/Utility/_phony,
+ Completion/Darwin/Command/_fink, Completion/Solaris/Command/_ipadm,
+ Completion/Unix/Command/_abcde, Completion/Unix/Command/_postfix,
+ Completion/Unix/Command/_shutdown, Completion/Unix/Command/_sleep,
+ Completion/Unix/Command/_ssh, Completion/Unix/Command/_zfs:
+ new utility function for mixing in extra values
+
+2026-06-14 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54762: Src/jobs.c, Test/W02jobs.ztst: make curjob and prevjob
+ work better
+
+ * unposted: Doc/Zsh/mod_zpty.yo: add some usage notes to zpty
+ -d and -t
+
+ * 54753: Src/Modules/zpty.c, Test/W02jobs.ztst: zpty: register
+ pty fd as FDT_MODULE so it isn't closed when forking
+
+ * 54751: Test/W02jobs.ztst: make the W02 test not take a full
+ minute on linux
+
+ * 54721: Doc/Zsh/expn.yo, Doc/intro.ms, Functions/Misc/zmv,
+ Src/Modules/zpty.c, Src/Modules/zutil.c, Src/Zle/compctl.c,
+ Src/Zle/computil.c, Src/Zle/zle_main.c, Src/Zle/zle_refresh.c,
+ Src/builtin.c, Src/glob.c, Src/hist.c, Src/jobs.c,
+ Src/math.c, Src/module.c, Src/parse.c, Test/B02typeset.ztst,
+ Test/B10getopts.ztst, Test/B11kill.ztst, Test/D04parameter.ztst,
+ Test/K01nameref.ztst, Test/V13zformat.ztst: illegal -> invalid,
+ invalid option -> bad option
+
+ * 54715: Src/Zle/compctl.c: compctl: print multibyte errors
+ correctly (phew)
+
+ * 54714: Src/Modules/zutil.c, Src/glob.c, Src/utils.c, Src/zsh.h:
+ add MB_NICECHAR and use it
+
+ * 54713: Src/Modules/zutil.c: fix multibyte error reporting
+ in zparseopts
+
+ * 54712: Src/subst.c: handle the Pound token in error message
+
+ * 54711: Src/builtin.c: print invalid option to getopts correctly
+
+ * 54710: Src/Builtins/rlimits.c, Src/Builtins/sched.c,
+ Src/Modules/stat.c, Src/Modules/system.c, Src/Modules/zftp.c,
+ Src/Zle/complete.c, Src/Zle/zle_thingy.c, Src/builtin.c,
+ Src/exec.c, Src/glob.c, Src/math.c, Src/options.c,
+ Test/B12limit.ztst: handle multibyte arguments in error messages
+
+2026-06-10 dana <dana@dana.is>
+
+ * 54677: Test/runtests.zsh, Test/ztst.zsh: improve readability
+
+ * unposted: Src/jobs.c, Test/B11kill.ztst: kill: fix -l
+ argument error, add tests
+
+2026-06-09 Bart Schaefer <schaefer@zsh.org>
+
+ * Philippe: 54731: Src/Modules/db_gdbm.c, Test/V11db_gdbm.ztst:
+ Adapt gdbm code to named references
+
+ * Philippe: 54727: Src/params.c, Test/K01nameref.ztst: Implement
+ references to positional parameters
+
+ * Philippe: 54722: Src/builtin.c, Src/params.c, Src/params.c: Fix
+ nameref issues in builtin "unset"
+
+2026-06-10 Mikael Magnusson <mikachu@gmail.com>
+
+ * Stephane Chazelas: 54695: Doc/Zsh/contrib.yo,
+ Functions/Misc/regexp-replace: regexp-replace and ^, word boundary
+ or look-behind operators (and more).
+
+ * 54707: Src/builtin.c: fix autoload +X nonexist leaving funcdef
+ at dummy
+
+ * 54705: Src/Modules/ksh93.c: ksh93: fix use after free of
+ .sh.edchar
+
+ * 54704 + 54728: Src/Modules/ksh93.c: remove obsolete workaround
+ in ksh93 module
+
+ * 54696: Src/glob.c: unset REPLY before e:: and oe:: so things
+ don't break if it had acquired a weird type
+
+ * 54693: Src/exec.c: show ARGV0 and - precommand more clearly
+ in xtrace output
+
+ * 54692: Src/subst.c: untokenize string sent to matheval for
+ (#) flag
+
+ * 54691: Src/subst.c, Test/D04parameter.ztst: fix :W and :w
+ duplicating input
+
+ * 54688: Src/pattern.c, Test/D07multibyte.ztst: handle Stéphane
+ correctly
+
+ * 54687: Src/Zle/compcore.c, Src/Zle/compctl.c,
+ Src/Zle/compmatch.c, Src/Zle/compresult.c, Src/Zle/zle_tricky.c:
+ fix brace completion
+
+ * 54686: Src/Zle/zle_utils.c: count lines in showmsg more
+ correctly
+
+ * 54683: Src/Zle/zle_refresh.c: fix for ctrl-r with combining
+ characters or nonprintable wide chars
+
+ * 54674: Src/subst.c, Test/D04parameter.ztst: ::= didn't respect
+ parameter flags
+
+2026-06-08 dana <dana@dana.is>
+
+ * unposted: NEWS: document COLUMNS+LINES change from w/54676
+
+ * 54676: Doc/Zsh/params.yo, Src/init.c, Src/params.c,
+ Src/utils.c, Test/D04parameter.ztst: preserve COLUMNS + LINES
+ from the environment
+
+ * unposted: NEWS: fix 5.9 changes header
+
+ * 54659: Completion/Zsh/Command/_alias,
+ Completion/Zsh/Command/_bindkey,
+ Completion/Zsh/Command/_command,
+ Completion/Zsh/Command/_compadd, Completion/Zsh/Command/_dirs,
+ Completion/Zsh/Command/_disable,
+ Completion/Zsh/Command/_emulate,
+ Completion/Zsh/Command/_enable, Completion/Zsh/Command/_exec,
+ Completion/Zsh/Command/_fc, Completion/Zsh/Command/_hash,
+ Completion/Zsh/Command/_jobs_builtin,
+ Completion/Zsh/Command/_kill, Completion/Zsh/Command/_print,
+ Completion/Zsh/Command/_prompt, Completion/Zsh/Command/_read,
+ Completion/Zsh/Command/_set, Completion/Zsh/Command/_strftime,
+ Completion/Zsh/Command/_tcpsys,
+ Completion/Zsh/Command/_typeset,
+ Completion/Zsh/Command/_unhash, Completion/Zsh/Command/_vared,
+ Completion/Zsh/Command/_which, Completion/Zsh/Command/_zattr,
+ Completion/Zsh/Command/_zcompile, Completion/Zsh/Command/_zed,
+ Completion/Zsh/Command/_zle, Completion/Zsh/Command/_zmodload,
+ Completion/Zsh/Command/_zmv,
+ Completion/Zsh/Command/_zparseopts,
+ Completion/Zsh/Command/_zpty, Completion/Zsh/Command/_zsocket,
+ Completion/Zsh/Function/__arguments, Doc/Zsh/compsys.yo,
+ Src/Zle/computil.c, Test/Y03arguments.ztst: comparguments:
+ support zsh-style '-' terminator with -S -S
+
+ * unposted: Functions/Misc/zgetopt: try funcstack for function
+ name
+
+2026-06-08 Bart Schaefer <schaefer@zsh.org>
+
+ * Philippe Altherr: 54718: Src/builtin.c, Src/params.c, Src/zsh.h
+ Test/K01nameref.ztst: Remove support for named references to
+ subscripted variables
+
+ * Philippe Altherr: 54475: Src/Modules/watch.c, Src/Modules/zftp.c,
+ Src/builtin.c, Src/init.c, Src/module.c, Src/params.c, Src/utils.c:
+ Don't perform dereferencing when looking up certain special parameters
+
+ * Philippe Altherr: 54700: Src/params.c, Test/A06assign.ztst:
+ Refine string and array slice assignments (no user-visible change)
+
+ * Mikel Ward: 54294: Src/jobs.c, Test/A05execution.ztst,
+ Test/W02jobs.ztst: Fix %- (prevjob) picking wrong job after resuming
+
+ * Philippe Altherr: 54278: Src/params.c, Test/K01nameref.ztst:
+ Detect invalid variable names in reference initializers
+
+ * Philippe Altherr: 54277: Src/params.c: reference loops are detected
+ at create time, remove loop tagging
+
+2026-06-08 Mikael Magnusson <mikachu@gmail.com>
+
+ * unposted: Src/Modules/ksh93.c: fix NULL termination in ksh93
+
+2026-06-07 Mikael Magnusson <mikachu@gmail.com>
+
+ * unposted: Completion/Zsh/Type/_history_modifiers: add :S from
+ 51816 to completion
+
+ * 54672: Src/Zle/zle_tricky.c: use bangchar instead of this
+ hardcoded !
+
+ * 54671: Src/glob.c, Test/D04parameter.ztst: fix anchored pattern
+ with --disable-multibyte
+
+ * 54670: configure.ac: don't cache the user saying
+ --disable-multibyte as meaning multibyte support was detected
+ broken
+
+ * 54668: aczsh.m4, configure.ac: various configure.ac cleanups
+
+ * 54669: Src/Modules/cap.c, Src/Modules/cap.mdd,
+ Src/Modules/db_gdbm.c, Src/Modules/db_gdbm.mdd,
+ Src/Modules/pcre.mdd, Src/mkmakemod.sh, configure.ac: add
+ --disable-link-all-libs configure option
+
+2026-06-06 dana <dana@dana.is>
+
+ * unposted: NEWS: better document hlgroups, termquery, etc
+
+ * unposted: Doc/Zsh/mod_watch.yo: mention support for %H in
+ WATCHFMT (w/52646)
+
+2026-06-04 dana <dana@dana.is>
+
+ * 54660: Completion/compinit: improve argument parsing
+
+ * unposted: Completion/compdump: guard arguments to mv
+
+ * unposted: README, Test/E01options.ztst: add regression test,
+ update README for w/54328
+
+ * Philippe Altherr: 54328: Doc/Zsh/options.yo, Src/params.c,
+ Src/utils.c: Only ever turn global parameters into named
+ directories
+
+ * unposted: Test/A06assign.ztst: add regression test for w/54340
+
+ * Philippe Altherr: 54340: Src/params.c: Remove partial
+ duplication of strsetfn and arrsetfn
+
+2026-06-04 Mikael Magnusson <mikachu@gmail.com>
+
+ * Moritz Bunkus: 49676: Completion/Unix/Command/_ansible:
+ re-read cached hosts & groups on directory change
+
+ * Roman Perepelitsa: 44874: Src/Zle/zle_refresh.c: fix a memory
+ leak and potential heap corruption when rotating lines
+
+ * 54624: Src/Zle/complete.c: parse_class would underallocate if
+ posix character classes are used
+
+ * 54620: Src/exec.c: fix check for when to hash commands
+
+ * 54617: Src/Modules/parameter.c, Src/zsh.h,
+ Test/V06parameter.ztst: fix lookup in $commands array when
+ hashlistall is unset
+
+2026-06-04 Oliver Kiddle <opk@zsh.org>
+
+ * unposted: Src/zsh.h: remove further remnant of restricted mode
+
+ * Shohei YOSHIDA: 54663: Completion/Unix/Command/_ruby:
+ update JIT flags
+
+2026-06-01 dana <dana@dana.is>
+
+ * 54644: Src/init.c, Src/zsh.mdd, Test/E01options.ztst: init:
+ add patchlevel to --version output
+
+ * Wesley Schwengle: 49374: Src/init.c: Show patchlevel in
+ version string
+
+ * 54645: Test/A01grammar.ztst, Test/D03procsubst.ztst,
+ Test/V09datetime.ztst: fix some failures with
+ alpine/busybox/musl
+
+2026-05-30 dana <dana@dana.is>
+
+ * unposted: Completion/Unix/Command/_imagemagick: support .heic
+ extension
+
+ * unposted: Completion/Unix/Type/_diff_options: assume diff
+ under netbsd is gnu-like
+
+2026-05-29 dana <dana@dana.is>
+
+ * 54625: .cvsignore, Completion/.cvsignore, Config/.cvsignore,
+ Doc/.cvsignore, Doc/Zsh/.cvsignore, Doc/help/.cvsignore,
+ Etc/.cvsignore, Functions/.cvsignore, Src/.cvsignore,
+ Src/Builtins/.cvsignore, Src/Modules/.cvsignore,
+ Src/Zle/.cvsignore, Test/.cvsignore: remove .cvsignore
+
+2026-05-27 dana <dana@dana.is>
+
+ * 54603 (tweaked): Doc/Zsh/params.yo, Src/exec.c, Src/math.c,
+ Test/D04parameter.ztst: zsh_eval_context: add math context
+
+ * unposted: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c,
+ Test/V13zformat.ztst: zformat: pass through %) with -q
+
+ * 54602: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c,
+ Test/V13zformat.ztst: zformat: add -qQ options to auto-escape %s
+
+ * unposted: Config/version.mk: bump to 5.9.999.3-test
+
+ * unposted: Etc/creating-a-release.txt: document new version
+ sequence
+
+ * unposted: NEWS: mention _as_if (w/53174)
+
+2026-05-26 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54613: configure.ac: restrict mdd search to Src/ since that's
+ where they are
+
+2026-05-26 Oliver Kiddle <opk@zsh.org>
+
+ * 54589: Src/Modules/socket.c, Src/Modules/zftp.c,
+ Src/Modules/zpty.c, Src/Zle/compcore.c, Src/Zle/compctl.c,
+ Src/Zle/complist.c, Src/Zle/compmatch.c, Src/Zle/compresult.c,
+ Src/Zle/computil.c, Src/Zle/zle_keymap.c, Src/Zle/zle_tricky.c,
+ Src/builtin.c, Src/exec.c, Src/glob.c, Src/init.c, Src/params.c,
+ Src/prompt.c, Src/sort.c, Src/subst.c: remove dead code
+ identified by scan-build
+
+2026-05-25 dana <dana@dana.is>
+
+ * Josh Triplett: unposted: Completion/Debian/Command/_dak,
+ Completion/Debian/Command/_debfoster: completion/debian: Update
+ for new programming language sections
+
+2026-05-26 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54615: Src/exec.c: fix ambiguous dangling from 54595
+
+2026-05-25 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54609: Src/Zle/compresult.c: fix accept-and-hold completion
+ for words with leading quotes
+
+ * 54609 + 54606: Src/Zle/complist.c: additional fixes for
+ interactive menu selection
+
+ * 54601: Src/Zle/complist.c: fix complist interactive mode
+ overwriting buffer
+
+ * 54600: Src/builtin.c: fix metafy stuff in add_autoload_function
+
+ * 54599: Src/exec.c: use correct buf size in cancd
+
+ * 54598: Src/exec.c: fix getfpfunc metafication
+
+ * 54597: Src/exec.c: hashcmd could reject valid paths to hash
+ if they had metafied characters
+
+ * 54596: Src/utils.c: pathprog used a signed char as a buffer size
+
+ * 54595: Src/exec.c: overflow check in isreallycom
+
+ * 54594: Src/exec.c: fix two very similar coverity issues
+
+ * 54593: Src/Zle/compmatch.c: fix two edge cases in join_strs
+
+ * 54592: Src/Zle/computil.c, Src/module.c: fix two dead
+ assignments reported 15 years ago by clang
+
+2026-05-23 dana <dana@dana.is>
+
+ * unposted: Src/builtin.c, Test/B08shift.ztst: shift: improve
+ count error message
+
+ * 54591: Src/Modules/termcap.c, Src/Modules/terminfo.c,
+ Src/jobs.c: fix new compiler warnings
+
+ * unposted: NEWS, README: update for w/54580, w/54584, w/54585
+
+ * unposted: Completion/Zsh/Type/_jobs_fg: complete disown -a
+
+ * 54585: Doc/Zsh/builtins.yo, Src/builtin.c, Src/jobs.c,
+ Test/W02jobs.ztst: disown: add -a option
+
+ * 54584: Src/jobs.c, Test/W02jobs.ztst,
+ Test/W03jobparameters.ztst: jobs: update curjob in sub-shells
+
+2026-05-22 dana <dana@dana.is>
+
+ * unposted: NEWS: update for w/52326 and w/52594
+
+2026-05-22 Mikael Magnusson <mikachu@gmail.com>
+
+ * unposted: Src/Modules/curses.c: fix missing return keyword
+ in 54552
+
+2026-05-21 dana <dana@dana.is>
+
+ * unposted: Src/parse.c, Test/A09zwc.ztst, Test/B14zwc.ztst:
+ add error message and improve tests for w/54571
+
+ * Michael Ridgway: 54571: Src/parse.c, Test/B14zwc.ztst: bound
+ h->npats in .zwc loader
+
+ * unposted: Test/D07multibyte.ztst: add regression test for
+ w/54583
+
+ * LY: 54583: Src/loop.c: loop.c: stop destructive unmetafy in
+ selectlist()
+
+ * 54580: Src/Modules/zutil.c, Test/V13zformat.ztst: zformat:
+ better handle literal % in format string
+
+ * 54579: Doc/Zsh/mod_zutil.yo: clarify zformat -F ternary
+ behaviour
+
+ * 54574: Completion/Base/Utility/_numbers: align descriptions
+
+2026-05-18 dana <dana@dana.is>
+
+ * Michael Kuhn: github #160 (tweaked):
+ Completion/X/Command/_papers: New Papers completion
+
+2026-05-18 Oliver Kiddle <opk@zsh.org>
+
+ * github #172: gi1242: Completion/X/Command/_sioyek: Completion
+ for "sioyek" (PDF viewer)
+
+ * unposted: Completion/Unix/Command/_init_d: complete network
+ interfaces for the netif service given new workings for jails
+
+ * Nick Price: github #166: Completion/Unix/Command/_init_d,
+ Completion/BSD/Command/_jail, Completion/BSD/Type/_jails:
+ complete names of non-running FreeBSD jails
+
+ * 54578: Completion/Base/Utility/_numbers: relacement for 52373
+ without breaking use of the format style with a unit-suffixes tag
+
+ * 54577: Completion/Unix/Command/_env: restore environment variable
+ completion to env
+
+ * 54576: Completion/Unix/Command/_git: adapt git config completon
+ to new sub-commands
+
+2026-05-16 dana <dana@dana.is>
+
+ * unposted: Util/zsh-merge-changelog: zsh-merge-changelog: find
+ even more context
+
+ * github #169: Completion/Unix/Command/_darcs: remove _darcs
+
+ * github #169: Completion/Unix/Command/_darcs: update _darcs
+ from up-stream
+
+ * sph: github #161 (tweaked): Doc/Zsh/contrib.yo,
+ Functions/Misc/zkbd: allow zkbd to generate config in a custom
+ directory
+
+ * Michael Baikov: github #170 (tweaked): Doc/Zsh/compwid.yo:
+ Clarify the documentation about -d flag in compadd
+
+2026-05-16 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54525: Src/init.c: interrupt during redirect to fifo doesn't
+ run precmd
+
+ * 54569: Src/Zle/complist.c, Src/Zle/termquery.c,
+ Src/Zle/zle_hist.c, Src/Zle/zle_keymap.c, Src/Zle/zle_main.c,
+ Src/Zle/zle_misc.c, Src/Zle/zle_move.c, Src/Zle/zle_params.c,
+ Src/Zle/zle_refresh.c, Src/Zle/zle_thingy.c, Src/Zle/zle_tricky.c,
+ Src/Zle/zle_utils.c, Src/Zle/zle_vi.c, Src/Zle/zle_word.c: zle:
+ various issues
+
+ * 54568: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c: zformat:
+ fix some misparse and overrun issues
+
+ * 54567: Src/Modules/zselect.c: zselect: don't pass fd>=FD_SETSIZE
+ to FD_SET
+
+ * 54566: Src/Modules/zpty.c: zpty: fix some issues
+
+ * 54565: Src/Modules/watch.c: watch: increase a quite tight
+ bound on format length
+
+ * 54564: Src/Modules/termcap.c, Src/Modules/terminfo.c: termcap,
+ terminfo: reset u, fix metafy confusion
+
+ * 54563: Src/Modules/stat.c, Src/Modules/system.c: stat, system:
+ minor fixes
+
+ * 54562: Doc/Zsh/mod_random.yo, Src/Modules/random.c,
+ Src/Modules/random_real.c: random: Fix some bugs in the random
+ module
+
+ * 54561: Src/Modules/regex.c: regex: regfree on pattern where
+ regcomp failed could be undefined behavior
+
+ * 54560: Src/Modules/parameter.c: parameter: Fix some issues in
+ the parameter module
+
+ * 54559: Src/Modules/nearcolor.c: nearcolor was missing the
+ third grayscale entry in 88 color mode
+
+ * 54558: Src/Modules/ksh93.c: ksh93: .sh.match handling with
+ KSHARRAYS set was totally broken
+
+ * 54557: Src/Modules/langinfo.c: langinfo: fix some metafy
+ confusion
+
+ * 54556: Src/Modules/langinfo.mdd: langinfo.mdd check was
+ always true
+
+ * 54555: Src/Modules/hlgroup.c: fix in 52783 was incomplete,
+ add same check in scangroup()
+
+ * 54554: Src/Modules/curses.c: curses: use setcchar in zccmd_bg
+ if available
+
+ * 54553: Src/Modules/curses.c: curses: free subwindows before
+ parents or they don't get freed at all
+
+ * 54552: Src/Modules/curses.c: curses: fix a few issues
+
+ * 54551: Src/Modules/clone.c: clone: minor style issue
+
+ * 54550: Src/Modules/cap.c: cap: fix leaks
+
+ * 54549: Src/Modules/attr.c, Src/Modules/attr.mdd: attr: various
+ minor issues
+
+ * 54546: Src/hist.c: Remove incorrect array access that was also
+ never used
+
+ * 54545: Src/Modules/system.c, Src/Zle/compresult.c, Src/glob.c,
+ Src/subst.c, Src/utils.c: A few very minor things coverity
+ complained about
+
+ * 54544: Src/Modules/zpty.c: Coverity CID 439086 fix potential
+ leak of prog in ptyread()
+
+ * 54543: Src/Zle/termquery.c: Coverity CID 1692315 memcpy of
+ uninitialized member winsize
+
+ * 54542: Src/Modules/zutil.c: Coverity CID 1692320 fix leak
+ of match1
+
+ * 54541: Src/utils.c: Coverity CID 1255748 check return value
+ from stat()
+
+ * 54540: Src/jobs.c: Coverity CID 1637388 avoid clobbering sig
+
+ * 54539: Src/parse.c: Coverity CID 1692314 avoid overflowing
+ version field in dump header
+
+ * 54538: Src/exec.c: Coverity CID 1637382 bsiz can overflow when
+ reading a large heredoc
+
+ * 54537: Src/exec.c: Coverity CID 1372427 buffer overrun in
+ zexecve()
+
+ * 54536: Src/exec.c: Coverity CID 1255827 Fix leak of prog
+ in loadautofn()
+
+ * 54535: Src/builtin.c: Coverity CID 1500747 0-initialize ti
+
+ * 54548: Src/Modules/zftp.c: zftp: fix some mistakes
+
+ * 54533: Completion/Unix/Command/_gcc: _gcc: fix some funny
+ autogenerated artifacts and other typos
+
+ * 54532: Completion/Unix/Command/_ansible,
+ Completion/Unix/Command/_df, Completion/Unix/Command/_ffmpeg,
+ Completion/Unix/Command/_find, Completion/Unix/Command/_ip,
+ Completion/Unix/Command/_lsof, Completion/Unix/Command/_mount,
+ Completion/Unix/Command/_netstat, Completion/Unix/Command/_rsync,
+ Completion/Unix/Command/_sed, Completion/Unix/Command/_sort,
+ Completion/Unix/Command/_subversion,
+ Completion/Unix/Command/_sudo, Completion/Unix/Command/_tmux,
+ Completion/Unix/Command/_wget, Completion/Zsh/Command/_zstyle:
+ completers: various small fixes
+
+ * 54531: Completion/BSD/Command/_kdump,
+ Completion/BSD/Command/_ktrace, Completion/Linux/Command/_ipset,
+ Completion/Linux/Command/_iptables,
+ Completion/Unix/Command/_darcs, Completion/Unix/Command/_ln,
+ Completion/Unix/Command/_mv, Completion/Unix/Command/_rm,
+ Completion/Unix/Command/_rmdir: completers: remove spurious ;
+ in "case $foo; in"
+
+ * 54530: Completion/Base/Completer/_all_matches,
+ Doc/Zsh/compsys.yo: Fix typo in default value for avoid-completer
+
+2026-05-15 dana <dana@dana.is>
+
+ * 54325: Doc/Zsh/params.yo: swap eval contexts for <(...) and
+ >(...)
+
+ * Charles Blake + dana: 54425+54429+54449: Completion/compinit:
+ compdef -[kK]: avoid forking
+
+ * unposted: Util/zsh-merge-changelog: find more context
+
+2026-05-14 Oliver Kiddle <opk@zsh.org>
+
+ * 54527: Src/Zle/zle_misc.c: don't start a vi change from emacs mode
+
+ * 54528: Completion/Linux/Command/_valgrind,
+ Completion/Linux/Command/_selinux, Completion/Linux/Command/_strace,
+ Completion/Unix/Command/_ansible, Completion/Unix/Command/_attr,
+ Completion/Unix/Command/_diffstat, Completion/Unix/Command/_dig,
+ Completion/Unix/Command/_entr, Completion/Unix/Command/_git,
+ Completion/Unix/Command/_gphoto2, Completion/Unix/Command/_ip,
+ Completion/Unix/Command/_jq, Completion/Unix/Command/_mtr,
+ Completion/Unix/Command/_pandoc, Completion/Unix/Command/_pv,
+ Completion/Unix/Command/_sqlite, Completion/X/Command/_pdftk:
+ completion option updates and minor cleanups
+
+ * 54526: Completion/BSD/Command/_ipfw, Completion/BSD/Command/_mdo,
+ Completion/BSD/Command/_jls, Completion/BSD/Command/_jail,
+ Completion/BSD/Command/_pfctl, Completion/BSD/Command/_sockstat,
+ Completion/Unix/Command/_column, Completion/Unix/Command/_id,
+ Completion/Unix/Command/_ls, Completion/Unix/Command/_ps,
+ Completion/Unix/Command/_service, Completion/Unix/Command/_timeout,
+ Completion/Unix/Command/_zdump, Completion/Unix/Command/_zfs,
+ Completion/Unix/Type/_date_formats:
+ update completions for FreeBSD 14.4 and 15.0
+
+2026-05-11 dana <dana@dana.is>
+
+ * 54518: Util/zsh-merge-changelog: add git merge driver
+
+ * 54504: Doc/Zsh/manual.yo, Doc/Zsh/zle.yo, Doc/intro.ms: fix
+ more warnings
+
+ * 54501: Completion/Unix/Command/_chdman,
+ Completion/Unix/Command/_fish, Completion/Unix/Command/_nano:
+ add chdman, fish, nano
+
+ * 54500: Completion/Unix/Command/_chown,
+ Completion/Unix/Command/_cpio: support user:group syntax only
+
+2026-05-11 Mikael Magnusson <mikachu@gmail.com>
+
+ * 54479: Src/exec.c: Fix use-after-free when handling TRAPEXIT
+
+ * 54480: Src/Zle/zle_vi.c: Wrong memcmp variant used in
+ getvirange()
+
+ * 54483: Src/Zle/zle_hist.c, Src/Zle/zle_misc.c,
+ Src/Zle/zle_params.c, Src/Zle/zle_utils.c, Src/Zle/zle_vi.c:
+ Make sure zleline is null-terminated
+
+ * 54481: Src/Zle/zle_misc.c: Move variable into scope where
+ it's used
+
+ * 54490: Src/Zle/termquery.c: Fix buffer overflow and wrong
+ behavior in url_encode
+
+ * 54491: Src/Zle/termquery.c: Don't read COLORVAR out of bounds
+
+ * 54492: Src/Zle/termquery.c: is* classification functions take
+ unsigned char
+
+ * 54493: Src/Modules/socket.c: socket: fix some issues with
+ socket name
+
+ * 54494: Doc/Zsh/mod_socket.yo, Src/Modules/socket.c: Add zsocket
+ -s to shutdown() a socket fd
+
+ * 54495: Doc/Zsh/mod_tcp.yo, Src/Modules/tcp.c, Src/Modules/tcp.h:
+ Add ztcp -s to shutdown() a tcp fd
+
+ * 54499: Doc/Zsh/manual.yo, Doc/ztexi.yo: Add missing detailmenu
+ texi markup
+
+2026-05-10 Oliver Kiddle <opk@zsh.org>
+
+ * unposted: Completion/Linux/Command/_selinux: complete files
+ after semanage fcontext -e
+
+ * 54506: Src/Zle/termquery.c: fix checking of dash following
+ the prefix in terminal extensions
+
+ * 54486: Doc/Zsh/zle.yo, Src/Zle/termquery.c: fix reading
+ outside string issue reported by valgrind
+
+ * 54445: Completion/Unix/Type/_terminals: parse termcap
+ and full terminfo source formats to support more systems
+
+2026-05-09 Bart Schaefer <schaefer@zsh.org>
+
+ * Philippe Altherr: 54374: Src/exec.c Test/C03traps.ztst: Run
+ ZERR trap on zsh errors as well as external command errors
+
+2026-05-06 dana <dana@dana.is>
+
+ * 54484: Test/C02cond.ztst: fix -nt test on low-resolution file
+ systems
+
+ * 54471: Doc/Zsh/builtins.yo, Doc/Zsh/options.yo, NEWS, README,
+ Src/builtin.c, Test/B10getopts.ztst: getopts: don't look for +o
+ with posix_builtins, add -p
+
+ * 54454: Completion/Base/Utility/_values: auto-remove argument
+ separator
+
+ * 54451: README, Src/Zle/computil.c, Test/Y06values.ztst:
+ compvalues: support leading '!' in spec, handle escaping better
+
+2026-05-04 dana <dana@dana.is>
+
+ * 54450: Doc/Zsh/compsys.yo: improve _describe documentation
+
+ * 54448: Completion/Linux/Command/_btrfs,
+ Completion/Unix/Command/_base64, Completion/Unix/Command/_tree,
+ Completion/Zsh/Command/_emulate: update base64, btrfs, emulate,
+ tree
+
+2026-05-03 dana <dana@dana.is>
+
+ * unposted: Test/Y01completion.ztst: Y01: fix test broken by
+ _echo
+
+ * unposted: Completion/Darwin/Command/_caffeinate,
+ Completion/Linux/Command/_mdadm, Completion/Unix/Command/_man:
+ add missing + to some short-option specs
+
+ * unposted: Completion/Unix/Command/_echo: add _echo
+
+2026-05-03 Mikael Magnusson <mikachu@gmail.com>
+
+ * unposted: Completion/Cygwin/Command/_cygcheck,
+ Completion/Linux/Command/_acpi, Completion/Unix/Command/_myrepos,
+ Completion/Unix/Command/_tex: remove the 'this' from 'show this
+ help and exit' in completers
+
+2026-05-02 dana <dana@dana.is>
+
+ * 54437 (tweaked): Src/lex.c, Test/D04parameter.ztst: lex: fix
+ <-> in parameter flags
+
+ * 54424: Doc/Zsh/params.yo, NEWS, Test/D04parameter.ztst:
+ ZSH_EXEPATH: improve documentation, add test
+
+ * 54423 (tweaked): Completion/Zsh/Command/_compinit,
+ Completion/compinit, Doc/Zsh/compsys.yo: compinit: improve and
+ document -w
+
+ * unposted: Test/Y05describe.ztst: add basic tests for _describe
+
+ * unposted: Test/Z04zgetopt.ztst: zgetopt: make sure zsh/zutil
+ loads
+
+2026-05-02 Mikael Magnusson <mikachu@gmail.com>
+
+ * unposted: Completion/Unix/Command/_mpc: fix typo for -h flag
+
+2026-04-30 Oliver Kiddle <opk@zsh.org>
+
+ * Ryan Rotter: 54218: Completion/Unix/Command/_ip: add some
+ missing flags
+
+ * Philippe Altherr: 54383: Src/Modules/watch.c, Src/module.c,
+ Test/V01zmodload.ztst: Fix WATCH/watch tying
+
+ * Christopher Bock: github #168: Completion/Debian/Command/_apt:
+ add apt history commands
+
+ * unposted: Completion/X/Command/_nedit: nedit-client is
+ also commonly used as as the name for nc
+
+ * unposted: Completion/Unix/Command/_ghostscript,
+ Completion/Unix/Type/_pspdf: ghostscript completion does a
+ better job of handling gsnd
+
+ * unposted: Completion/Unix/Command/_lua: complete also for
+ FreeBSD's flua
+
+ * unposted: Test/Y04regexargs.ztst: minimal tests of
+ _regex_arguments
+
+ * unposted: Completion/Unix/Command/_sudo: fix for approximate
+ completion/correction
+
+ * 54404: Src/Zle/termquery.c, Test/X06termquery.ztst: skip
+ the RGB terminal query on older versions of the Apple terminal
+ which fail to consume the sequence
+
+2026-04-29 dana <dana@dana.is>
+
+ * unposted: Completion/Linux/Command/_opkg: guard zparseopts
+ long-option specs
+
+ * 54376: Doc/Zsh/mod_zutil.yo, NEWS, README,
+ Src/Modules/zutil.c, Test/V12zparseopts.ztst: zparseopts: use
+ standard option parsing
+
+ * 54381: Doc/Zsh/mod_zutil.yo, README, Src/Modules/zutil.c,
+ Test/V12zparseopts.ztst: zparseopts -M: use last as-given
+ option name in arrays
+
+ * 54395: Doc/Zsh/contrib.yo, Functions/Misc/zgetopt, NEWS,
+ Test/Z04zgetopt.ztst: contrib: add zgetopt (again)
+
+ * unposted: Completion/Zsh/Command/_compinit: add _compinit
+
+2026-04-28 dana <dana@dana.is>
+
+ * 54394: Completion/Unix/Command/_7zip: add _7zip
+
+ * Matt Koscica: github #167: Completion/Unix/Command/_tmux:
+ include new options added between 3.4 and next-3.7
+
+2026-04-28 Mikael Magnusson <mikachu@gmail.com>
+
+ * Philippe Altherr: 54342: Src/params.c, Test/A06assign.ztst:
+ Fix handling of reversed slices of scalar values
+
+ * 54402: Src/Modules/pcre.c: Fix crash in pcre_callout with
+ numerical callout 0
+
+ * 54403: Doc/Zsh/mod_pcre.yo: Add some more details on pcre
+ callouts
+
+ * 54406: Doc/Zsh/arith.yo, Doc/Zsh/mod_pcre.yo: Fix my yodl code
+ and another instance in arith.yo
+
+2026-04-19 dana <dana@dana.is>
+
+ * 54362: Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c,
+ Test/V12zparseopts.ztst: zparseopts: support empty optspec
+
+ * 54361 (tweaked): Completion/Zsh/Command/_zparseopts,
+ Doc/Zsh/mod_zutil.yo, Src/Modules/zutil.c,
+ Test/V12zparseopts.ztst: zparseopts: print friendlier usage
+ errors, add -n option
+
+2026-04-14 Oliver Kiddle <opk@zsh.org>
+
+ * 54181, 54331: Completion/Zsh/Command/_set,
+ Doc/Makefile.in, Doc/Zsh/builtins.yo, Doc/Zsh/compat.yo,
+ Doc/Zsh/grammar.yo, Doc/Zsh/invoke.yo, Doc/Zsh/manual.yo,
+ Doc/Zsh/options.yo, Doc/Zsh/restricted.yo, README,
+ Src/Modules/db_gdbm.c, Src/Modules/parameter.c, Src/builtin.c,
+ Src/exec.c, Src/init.c, Src/jobs.c, Src/options.c, Src/params.c,
+ Src/signals.c, Test/E01options.ztst, configure.ac:
+ remove support for restricted shell
+
2026-04-13 dana <dana@dana.is>
+ * dana + Jun T: 54329 + 54339: Doc/Makefile.in, Doc/intro.ms:
+ replace pdfroff by `groff -Tpdf`
+
* 54318: Doc/Zsh/arith.yo, Doc/Zsh/mod_mathfunc.yo,
Functions/Misc/zmathfuncdef, NEWS, Src/Modules/mathfunc.c,
Test/V03mathfunc.ztst: mathfunc: add isnan() and isinf(). also
diff --git a/Completion/.cvsignore b/Completion/.cvsignore
deleted file mode 100644
index 89ff7b089..000000000
--- a/Completion/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-*.swp
diff --git a/Completion/BSD/Command/_bectl b/Completion/BSD/Command/_bectl
index 484fa0159..8bbcdf628 100644
--- a/Completion/BSD/Command/_bectl
+++ b/Completion/BSD/Command/_bectl
@@ -43,6 +43,7 @@ if [[ $state = args ]]; then
args+=(
'-r[create recursive boot environment]'
'-e+[clone specified boot environment]: :->boot-environs'
+ '-E[create new empty boot environment]'
)
;;
destroy)
diff --git a/Completion/BSD/Command/_csup b/Completion/BSD/Command/_csup
deleted file mode 100644
index 69e13f3d1..000000000
--- a/Completion/BSD/Command/_csup
+++ /dev/null
@@ -1,26 +0,0 @@
-#compdef csup
-
-_arguments -s \
- '-1[disable automatic retries]' \
- '-4[force usage of IPv4 addresses]' \
- '-6[force usage of IPv6 addresses]' \
- '-A[local address to bind to when connecting to the server]:local address:_hosts' \
- '-b[base directory]:base directory:_files -/' \
- '-c[subdirectory of base for information about collections]:collections directory:_files -/' \
- '-d[maximum number of deleted files]:maximum number of deleted files:' \
- '-h[server host]:server host:_hosts' \
- '-i[include only files and directories matching]:file pattern:' \
- '-k[keep temporary copies of failed updates]' \
- '-l[lock file]:lock file:_files' \
- '-L[verbosity level]:verbosity level:(0 1 2)' \
- '-L0[verbosity level 0]' \
- '-L1[verbosity level 1]' \
- '-L2[verbosity level 2]' \
- '-p[server port]:port:_ports' \
- '-r[maximum number of retries]:maximum number of retries:' \
- '-s[suppress status checks]' \
- '-v[print version information]' \
- '(-Z)-z[enable compression]' \
- '(-z)-Z[disable compression]' \
- ':csup file:_files' \
- ':destination directory:_files -/'
diff --git a/Completion/BSD/Command/_freebsd-update b/Completion/BSD/Command/_freebsd-update
index af37641e4..0d1f008ac 100644
--- a/Completion/BSD/Command/_freebsd-update
+++ b/Completion/BSD/Command/_freebsd-update
@@ -22,5 +22,6 @@ _arguments \
'-r[specify the new release]:new release' \
'-s[fetch files from the specified server or server pool]:server:_hosts' \
'-t[mail output of cron command, if any, to address]:address' \
+ '-v[set output verbosity]:level [stats]:(stats nostats debug)' \
'--currently-running[assume specified release as current]:release' \
'*:command:_values -S " " -w "commands" $flags[@]'
diff --git a/Completion/BSD/Command/_ipfw b/Completion/BSD/Command/_ipfw
index b910aa34d..78dac206a 100644
--- a/Completion/BSD/Command/_ipfw
+++ b/Completion/BSD/Command/_ipfw
@@ -284,7 +284,7 @@ actions=(
\| $'/port_range[ \t\0]/'
'/[0-9]#-/' ': _message -e ports lower'
$word ': _message -e ports upper'
- \| $word ':parameters:config parameter:$ca ip if log deny_in same_ports unreg_only unreg_cgn reset reverse proxy_only skip_global redirect_port redirect_addr redirect_proto port_range'
+ \| $word ':parameters:config parameter:$ca ip if log deny_in same_ports unreg_only unreg_cgn udp_eim reset reverse proxy_only skip_global redirect_port redirect_addr redirect_proto port_range'
\) \#
\| $'/show[ \t\0]/' $word ':actions:action:(config log)'
\| '/[]/' ':commands:command:$ca config show' \)
diff --git a/Completion/BSD/Command/_jail b/Completion/BSD/Command/_jail
index 26d0a6a87..c3ccc5379 100644
--- a/Completion/BSD/Command/_jail
+++ b/Completion/BSD/Command/_jail
@@ -1,7 +1,7 @@
#compdef jail
local curcontext="$curcontext" ret=1
-local -a state state_descr line jails running alts suf
+local -a state state_descr line alts suf
local -A opt_args
_arguments -C -s \
@@ -32,19 +32,21 @@ if [[ -n $state ]]; then
*) _message -e values 'value' ;;
esac
elif compset -P name= || [[ $#line = 1 ]]; then
- if (( $+opt_args[-r] || $+opt_args[-m] )); then
- alts=( 'jails:jail:_jails' )
+ if (( $+opt_args[-r] || $+opt_args[-R] || $+opt_args[-m] )); then
+ alts=( 'jails:: _jails' )
elif (( $+opt_args[-c] )); then
- running=( ${${(f)"$(_call_program jails jls name)"}/ /:} )
- jails=( ${${(M)${(f)"$(<${opt_args[-f]:-/etc/jail.conf})"}:#[a-z]# #\{#(#e)}%% *} )
- alts=( "jails:jail:compadd - ${jails:|running}" )
+ if (( $+opt_args[-f] )); then
+ alts=( "jails:: _jails -c -f ${(q-)opt_args[-f]}" )
+ else
+ alts=( 'jails:: _jails -c' )
+ fi
fi
fi
- if [[ -z $IPREFIX ]]; then
+ if [[ -z $IPREFIX ]] && (( ! $+opt_args[-r] && ! $+opt_args[-R] )); then
compset -S '=*' || suf=( -qS = )
alts+=(
- 'parameters:parameter:compadd -r "\n\t\- =" - persist allow.{set_hostname,sysvipc,raw_sockets,chflags,mount{,.devfs,.fdescfs,.nullfs,.procfs,.linprocfs,.linsysfs,.tmpfs,.zfs},quotas,socket_af} mount.{devfs,fdescfs,procfs}'
- 'parameters:parameter:compadd $suf - jid name path ip{4,6}{,.addr{,sel}} vnet host.hostname host securelevel devfs_ruleset children.{max,cur} enforce_statfs cpuset.id osrelease osreldate command exec.{{,pre,post}{start,stop},clean,jail_user,system{,_jail}_user,timeout,consolelog,fib} stop.timeout {vnet.,}interface ip_hostname mount{,.fstab} depend'
+ 'parameters:parameter:compadd -r "\n\t\- =" - persist allow.{set_hostname,sysvipc,raw_sockets,chflags,mount{,.devfs,.fdescfs,.fusefs,.nullfs,.procfs,.linprocfs,.linsysfs,.tmpfs,.zfs},vmm,quotas,read_msgbuf,socket_af,mlock,nfsd,reserved_ports,unprivileged_{parent_tampering,proc_debug},suser,extattr,adjtime,settime,routing,setaudit} linux linux.{osrelease,oss_version} mount.{devfs,fdescfs,procfs}'
+ 'parameters:parameter:compadd $suf - jid name path ip{4,6}{,.addr,saddrsel} vnet host.hostname host securelevel devfs_ruleset children.{max,cur} enforce_statfs cpuset.id osrelease osreldate meta env command exec.{{,pre,post}{start,stop},clean,jail_user,system{,_jail}_user,timeout,consolelog,fib} stop.timeout {vnet.,}interface ip_hostname mount{,.fstab} depend zfs.dataset'
)
fi
(( $#alts )) && _alternative $alts && ret=0
diff --git a/Completion/BSD/Command/_jls b/Completion/BSD/Command/_jls
index a6f8a7eb6..f9ae10253 100644
--- a/Completion/BSD/Command/_jls
+++ b/Completion/BSD/Command/_jls
@@ -4,13 +4,14 @@ local curcontext=$curcontext state state_descr line
typeset -A opt_args
_arguments -C -s -w -A '-*' : \
- '-d[include diying jails]' \
- '-h[print header line]' \
- "-N[print jail's name instead of numeric ID]" \
- '-n[print parameters in ``name=value'\'\'' format]' \
- '-q[quote parameter value when it contains whitespace, quotes or empty string]' \
- '-s[print parameters suitable for passing to jail(8)]' \
- '-v[print a multiple-line summary per jail]' \
+ "(-h -N -n -q -s -v *)-c[only check for the jail's existence]" \
+ '-d[include dying jails]' \
+ '(-c)-h[print header line]' \
+ "(-c)-N[print jail's name instead of numeric ID]" \
+ '(-c)-n[print parameters in ``name=value'\'\'' format]' \
+ '(-c)-q[quote parameter value when it contains whitespace, quotes or empty string]' \
+ '(-c)-s[print parameters suitable for passing to jail(8)]' \
+ '(-c)-v[print a multiple-line summary per jail]' \
'-j[the jid or name of the jail to list]:jail:_jails' \
'*: :->parameters'
diff --git a/Completion/BSD/Command/_kdump b/Completion/BSD/Command/_kdump
index e5c7c4cce..45fe77137 100644
--- a/Completion/BSD/Command/_kdump
+++ b/Completion/BSD/Command/_kdump
@@ -37,7 +37,7 @@ local args=(
'-t[select which tracepoints to display]: :_ktrace_points'
)
-case $OSTYPE; in
+case $OSTYPE in
freebsd*|netbsd*)
args+=(
'(-R -T)-E[display elapsed timestamps]'
diff --git a/Completion/BSD/Command/_ktrace b/Completion/BSD/Command/_ktrace
index 9613ba2bf..99dc23d1a 100644
--- a/Completion/BSD/Command/_ktrace
+++ b/Completion/BSD/Command/_ktrace
@@ -13,7 +13,7 @@ local args=(
'*:: : _normal -p ktrace'
)
-case $OSTYPE; in
+case $OSTYPE in
openbsd*)
args+=(
'-B[process relocations immediately]'
diff --git a/Completion/BSD/Command/_mdo b/Completion/BSD/Command/_mdo
new file mode 100644
index 000000000..9bb5224e8
--- /dev/null
+++ b/Completion/BSD/Command/_mdo
@@ -0,0 +1,48 @@
+#compdef mdo
+
+local environ e cmd cpp sep
+local -a _comp_priv_prefix suf reset
+local curcontext="$curcontext" state line expl
+local -A opt_args
+
+zstyle -a ":completion:${curcontext}:" environ environ
+
+for e in "${environ[@]}"
+do local -x "$e"
+done
+
+cmd="$words[1]"
+cpp='_comp_priv_prefix=( $cmd ${(kv)opt_args} )'
+_arguments -s -S -A '-*' : \
+ '(- *)-h[display usage information]' \
+ '--euid=[override effective user]:user:_users' \
+ '--egid=[override effective group]:group:_groups' \
+ '-G+[set supplementary groups]:group:_sequence _groups' \
+ '-g+[set primary group]:group:_groups' \
+ '-i[keep current primary and supplementary groups]' \
+ '(-u -i)-k[use current credentials as baseline]' \
+ '--ruid=[override real user]:user:_users' \
+ '--rgid=[override real group]:group:_groups' \
+ '-s+[incrementally modify the supplementary groups set]: :->group-mods' \
+ '--svuid=[override saved user]:user:_users' \
+ '--svgid=[override saved group]:group:_groups' \
+ '-u+[run command as specified user]: :_users' \
+ "(-)1: :{ $cpp; _command_names -e }" \
+ "*:: :{ $cpp; _normal }" && return
+
+if [[ $state = group-mods ]]; then
+ line=(
+ $opt_args[-g] ${(s.,.)opt_args[-G]}
+ ${${(s.,.)${(M)PREFIX##*,}}#[-+@]}
+ ${${(s.,.)${(M)SUFFIX%%,*}}#[-+@]}
+ )
+ compset -P '*,' || reset=( @ )
+ compset -S ',*' || suf=( -qS, )
+ if ! compset -P '[-+@]'; then
+ zstyle -s ":completion:${curcontext}:modifiers" list-separator sep || sep=--
+ _wanted modifiers expl 'group modifier' compadd -S "" -d \
+ "(-\ $sep\ exclude +\ $sep\ include @\ $sep\ reset)" - - + $reset
+ else
+ _wanted groups expl group _groups $suf -F line
+ fi
+fi
diff --git a/Completion/BSD/Command/_pfctl b/Completion/BSD/Command/_pfctl
index 8063eb504..a664b6dd7 100644
--- a/Completion/BSD/Command/_pfctl
+++ b/Completion/BSD/Command/_pfctl
@@ -94,11 +94,12 @@ case $OSTYPE in
args+=(
'-M[kill matching states in the opposite direction]'
'-P[display ports numerically]'
+ "-S[don't perform domain name resolution]"
)
;;
esac
-_arguments -s $args \
+_arguments -s : $args \
'-a[apply flags -f, -F, and -s only to the rules in the specified anchor]:anchor' \
'-F+[flush the filter parameters specified by modifier]:modifier:(($pfctl_flush_modifiers))' \
'-D+[define macro to be set to value]:macro' \
diff --git a/Completion/BSD/Command/_portaudit b/Completion/BSD/Command/_portaudit
deleted file mode 100644
index 788248d7f..000000000
--- a/Completion/BSD/Command/_portaudit
+++ /dev/null
@@ -1,14 +0,0 @@
-#compdef portaudit
-
-_arguments -s \
- '-a[vulnerability report for all installed packages]' \
- '-C[vulnerability report for the port in the current working directory]' \
- '-d[print creation date of the database]' \
- '-F[fetch the current database]' \
- '-q[quiet mode]' \
- '-V[show portaudit version number]' \
- '-v[verbose mode]' \
- '-X[download a fresh database from least days old]:days:' \
- '-f[check the packages listed in file]:file:_files' \
- '-r[restrict listed vulnerabilities with eregex pattern]:eregex:' \
- ':pkg-name:'
diff --git a/Completion/BSD/Command/_sockstat b/Completion/BSD/Command/_sockstat
index 953072429..a5c29e116 100644
--- a/Completion/BSD/Command/_sockstat
+++ b/Completion/BSD/Command/_sockstat
@@ -31,10 +31,16 @@ case $OSTYPE in
;|
freebsd<14->.*)
args+=(
+ '-b[show TCP black box logging socket state]'
'-I[show local address of socket to which the current socket is spliced]'
'-f[show the FIB number of each socket]'
)
;|
+ freebsd<15->.*)
+ args+=(
+ '-A[show address of associated protocol control block (PCB)]'
+ )
+ ;|
freebsd*)
for proto in ${${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]*}}; do
case $proto in
diff --git a/Completion/BSD/Type/_jails b/Completion/BSD/Type/_jails
index 89e34ba4f..7b990b585 100644
--- a/Completion/BSD/Type/_jails
+++ b/Completion/BSD/Type/_jails
@@ -3,15 +3,52 @@
# Options:
#
# -0 include jid 0 as a match for the host system
+# -c complete configured jails that aren't currently running
+# -f file override config file (default: sysrc -n jail_conf)
# -o param jail parameter to complete instead of jid -
# e.g. name, path, ip4.addr, host.hostname
-local addhost host param desc=1
-local -a jails args expl
-zparseopts -D -K -E 0=addhost o:=param
+local addhost host param desc=1 configured
+local -a jails args expl fopt match mbegin mend
+zparseopts -D -K -E 0=addhost c=configured f:=fopt o:=param
param=${param[2]:-name}
jails=( ${${(f)"$(_call_program jails jls $param name)"}/ /:} )
+
+if [[ -n $configured ]]; then
+ local jail_conf line f include_pat content
+ local -a conf_files cjails running_names raw
+ include_pat="(#b)[[:space:]]#.include[[:space:]]##[\"']([^\"']##)[\"']*"
+
+ if (( $#fopt )); then
+ jail_conf=${fopt[2]}
+ else
+ jail_conf=$(_call_program paths sysrc -n jail_conf)
+ fi
+
+ # Follow .include directives (accepts both "..." and '...' paths)
+ if [[ -r $jail_conf ]]; then
+ while IFS= read -r line; do
+ [[ $line = ${~include_pat} ]] && conf_files+=( ${~match[1]}(N) )
+ done < $jail_conf
+ conf_files+=( $jail_conf )
+ fi
+
+ # Extract jail block names: lines matching "name {" (optionally indented).
+ # Collapse "name\n{" forms to "name {" first so the same pattern catches both.
+ for f in ${(u)conf_files}; do
+ [[ -r $f ]] || continue
+ content=$(< $f)
+ content=${content//$'\n'[[:space:]]#\{/' {'}
+ raw=( ${(M)${(f)content}:#[[:space:]]#[^#[:space:]]##[[:space:]]#\{*} )
+ cjails+=( ${${raw##[[:space:]]#}%%[[:space:]]#\{*} )
+ done
+
+ # Replace jails with configured-minus-running; exclude wildcard blocks
+ running_names=( ${jails%:*} )
+ jails=( ${(u)${cjails:#\*}:|running_names} )
+fi
+
case $param in
jid) host=0 ;;
name)
diff --git a/Completion/Base/Completer/_all_matches b/Completion/Base/Completer/_all_matches
index 59a6d8060..5f6841551 100644
--- a/Completion/Base/Completer/_all_matches
+++ b/Completion/Base/Completer/_all_matches
@@ -28,7 +28,7 @@ _all_matches_end() {
local not
zstyle -s "$_all_matches_context" avoid-completer not ||
- not=( _expand _old_list _correct _approximate )
+ not=( _expand _oldlist _correct _approximate )
if [[ "$compstate[nmatches]" -gt 1 && $not[(I)(|_)$_completer] -eq 0 ]]; then
local expl
diff --git a/Completion/Base/Core/_description b/Completion/Base/Core/_description
index 368b41ee2..586b1590d 100644
--- a/Completion/Base/Core/_description
+++ b/Completion/Base/Core/_description
@@ -86,7 +86,7 @@ elif [[ -n "$format" ]]; then
[[ -n $match[3] ]] && argv+=( o:$match[3] )
fi
- zformat -F format "$format" "d:$1" "${(@)argv[2,-1]}"
+ zformat -Fq format "$format" "d:$1" "${(@)argv[2,-1]}"
fi
if [[ -n "$gname" ]]; then
diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index 408a66ee3..11b7972de 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -366,7 +366,7 @@ elif [[ nm -eq 0 && -z "$_comp_mesg" &&
esac
_setup warnings
- zformat -f mesg "$format" "d:$str" "D:${(F)${(@)_lastdescr:#}}"
+ zformat -fq mesg "$format" "d:$str" "D:${(F)${(@)_lastdescr:#}}"
compadd -x "$mesg"
fi
diff --git a/Completion/Base/Core/_message b/Completion/Base/Core/_message
index dbeed4a88..b80aa4237 100644
--- a/Completion/Base/Core/_message
+++ b/Completion/Base/Core/_message
@@ -39,7 +39,7 @@ else
fi
if [[ -n "$format$raw" ]]; then
- [[ -z "$raw" ]] && zformat -F format "$format" "d:$1" "${(@)argv[2,-1]}"
+ [[ -z "$raw" ]] && zformat -Fq format "$format" "d:$1" "${(@)argv[2,-1]}"
builtin compadd "$gopt[@]" -x "$format"
_comp_mesg=yes
fi
diff --git a/Completion/Base/Utility/_arg_compile b/Completion/Base/Utility/_arg_compile
deleted file mode 100644
index e37c869ee..000000000
--- a/Completion/Base/Utility/_arg_compile
+++ /dev/null
@@ -1,199 +0,0 @@
-#autoload
-
-# A simple compiler for _arguments descriptions. The first argument of
-# _arg_compile is the name of an array parameter in which the parse is
-# returned. The remaining arguments form a series of `phrases'. Each
-# `phrase' begins with one of the keywords "argument", "option", or "help"
-# and consists of a series of keywords and/or values. The syntax is as
-# free-form as possible, but "argument" phrases generally must appear in
-# the same relative position as the corresponding argument on the command
-# line to be completed, and there are some restrictions on ordering of
-# keywords and values within each phrase.
-#
-# Anything appearing before the first phrase or after the last is passed
-# through verbatim. (See TODO.) If more detailed mixing of compiled and
-# uncompiled fragments is necessary, use two or more calls, either with
-# different array names or by passing the output of each previous call
-# through the next.
-#
-# In the documentation below, brackets [ ] indicate optional elements and
-# braces { } indicate elements that may be repeated zero or more times.
-# Except as noted, bracketed or braced elements may appear in any order
-# relative to each other, but tokens within each element are ordered.
-#
-# argument [POS] [means MSG] [action ACT]
-#
-# POS may be an integer N for the Nth argument or "*" for all, and
-# must appear first if it appears at all.
-# MSG is a string to be displayed above the matches in a listing.
-# ACT is (currently) as described in the compsys manual.
-#
-# option OPT [follow HOW] [explain STR] {unless XOR} \
-# {[means MSG] [action ACT]} [through PAT [means MSG] [action ACT]]
-#
-# OPT is the option, prefixed with "*" if it may appear more than once.
-# HOW refers to a following argument, and may be one of:
-# "close" must appear in the same word (synonyms "join" or "-")
-# "next" the argument must appear in the next word (aka "split")
-# "loose" the argument may appear in the same or the next word ("+")
-# "assign" as loose, but must follow an "=" in the same word ("=")
-# HOW should be suffixed with a colon if the following argument is
-# _not_ required to appear.
-# STR is to be displayed based on style `description'
-# XOR is another option in combination with which OPT may not appear.
-# It may be ":" to disable non-option completions when OPT is present.
-# MSG is a string to be displayed above the matches in a listing.
-# ACT is (currently) as described in the compsys manual.
-# PAT is either "*" for "all remaining words on the line" or a pattern
-# that, if matched, marks the end of the arguments of this option.
-# The "through PAT ..." description must be the last.
-# PAT may be suffixed with one colon to narrow the $words array to
-# the remainder of the command line, or with two colons to narrow
-# to the words before (not including) the next that matches PAT.
-#
-# help PAT [means MSG] action ACT
-#
-# ACT is applied to any option output by --help that matches PAT.
-# Do not use "help" with commands that do not support --help.
-# PAT may be suffixed with a colon if the following argument is
-# _not_ required to appear (this is usually inferred from --help).
-# MSG is a string to be displayed above the matches in a listing.
-
-# EXAMPLE:
-# This is from _gprof in the standard distribution. Note that because of
-# the brace expansion trick used in the "function name" case, no attempt
-# is made to use `phrase' form; that part gets passed through unchanged.
-# It could simply be moved to the _arguments call ahead of "$args[@]".
-#
-# _arg_compile args -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \
-# -{A,C,e,E,f,F,J,n,N,O,p,P,q,Q,Z}:'function name:->funcs' \
-# option -I means directory action _dir_list \
-# option -d follow close means "debug level" \
-# option -k means "function names" action '->pair' \
-# option -m means "minimum execution count" \
-# argument means executable action '_files -g \*\(-\*\)' \
-# argument means "profile file" action '_files -g gmon.\*' \
-# help '*=name*' means "function name" action '->funcs' \
-# help '*=dirs*' means "directory" action _dir_list
-# _arguments "$args[@]"
-
-# TODO:
-# Verbose forms of various actions, e.g. (but not exactly)
-# "state foo" becomes "->foo"
-# "completion X explain Y ..." becomes "((X\:Y ...))"
-# etc.
-# Represent leading "*" in OPT some other way.
-# Represent trailing colons in HOW and PAT some other way.
-# Stricter syntax checking on HOW, sanity checks on XOR.
-# Something less obscure than "unless :" would be nice.
-# Warning or other syntax check for stuff after the last phrase.
-
-emulate -L zsh
-local -h argspec dspec helpspec prelude xor
-local -h -A amap dmap safe
-
-[[ -n "$1" ]] || return 1
-[[ ${(tP)${1}} = *-local ]] && { print -R NAME CONFLICT: $1 1>&2; return 1 }
-safe[reply]="$1"; shift
-
-# First consume and save anything before the argument phrases
-
-helpspec=()
-prelude=()
-
-while (($#))
-do
- case $1 in
- (argument|help|option) break;;
- (*) prelude=("$prelude[@]" "$1"); shift;;
- esac
-done
-
-# Consume all the argument phrases and build the argspec array
-
-while (($#))
-do
- amap=()
- dspec=()
- case $1 in
-
- # argument [POS] [means MSG] [action ACT]
- (argument)
- shift
- while (($#))
- do
- case $1 in
- (<1->|\*) amap[position]="$1"; shift;;
- (means|action) amap[$1]="$2"; shift 2;;
- (argument|option|help) break;;
- (*) print -R SYNTAX ERROR at "$@" 1>&2; return 1;;
- esac
- done
- if (( $#amap ))
- then
- argspec=("$argspec[@]" "${amap[position]}:${amap[means]}:${amap[action]}")
- fi;;
-
- # option OPT [follow HOW] [explain STR] {unless XOR} \
- # {[through PAT] [means MSG] [action ACT]}
- (option)
- amap[option]="$2"; shift 2
- dmap=()
- xor=()
- while (( $# ))
- do
- (( ${+amap[$1]} || ${+dmap[through]} )) && break;
- case $1 in
- (follow)
- amap[follow]="${2:s/join/-/:s/close/-/:s/next//:s/split//:s/loose/+/:s/assign/=/:s/none//}"
- shift 2;;
- (explain) amap[explain]="[$2]" ; shift 2;;
- (unless) xor=("$xor[@]" "${(@)=2}"); shift 2;;
- (through|means|action)
- while (( $# ))
- do
- (( ${+dmap[$1]} )) && break 2
- case $1 in
- (through|means|action) dmap[$1]=":${2}"; shift 2;;
- (argument|option|help|follow|explain|unless) break;;
- (*) print -R SYNTAX ERROR at "$@" 1>&2; return 1;;
- esac
- done;;
- (argument|option|help) break;;
- (*) print -R SYNTAX ERROR at "$@" 1>&2; return 1;;
- esac
- if (( $#dmap ))
- then
- dspec=("$dspec[@]" "${dmap[through]}${dmap[means]:-:}${dmap[action]:-:}")
- fi
- done
- if (( $#amap ))
- then
- argspec=("$argspec[@]" "${xor:+($xor)}${amap[option]}${amap[follow]}${amap[explain]}${dspec}")
- fi;;
-
- # help PAT [means MSG] action ACT
- (help)
- amap[pattern]="$2"; shift 2
- while (($#))
- do
- (( ${+amap[$1]} )) && break;
- case $1 in
- (means|action) amap[$1]="$2"; shift 2;;
- (argument|option|help) break;;
- (*) print -R SYNTAX ERROR at "$@" 1>&2; return 1;;
- esac
- done
- if (( $#amap ))
- then
- helpspec=("$helpspec[@]" "${amap[pattern]}:${amap[means]}:${amap[action]}")
- fi;;
- (*) break;;
- esac
-done
-
-eval $safe[reply]'=( "${prelude[@]}" "${argspec[@]}" ${helpspec:+"-- ${helpspec[@]}"} "$@" )'
-
-# print -R _arguments "${prelude[@]:q}" "${argspec[@]:q}" ${helpspec:+"-- ${helpspec[@]:q}"} "$@:q"
-
-return 0
diff --git a/Completion/Base/Utility/_numbers b/Completion/Base/Utility/_numbers
index 069fc75a4..82edc07bd 100644
--- a/Completion/Base/Utility/_numbers
+++ b/Completion/Base/Utility/_numbers
@@ -37,13 +37,14 @@
# _description is called with the x token set to make the completed
# list of suffixes available to the normal format style
-local desc tag range suffixes suffix suffixfmt pat='<->' partial=''
+local MATCH MBEGIN MEND
+local desc tag range suffixes suffix suffixfmt pad pat='<->' partial=''
local -a expl formats
local -a default max min keep tags units
local -i i
local -A opts
-zparseopts -K -D -A opts M+:=keep q:=keep s+:=keep S+:=keep J+: V+: 1 2 o+: n F: x+: X+: \
+zparseopts -K -D -A opts M+:=keep q+=keep s+:=keep S+:=keep J+: V+: 1 2 o+: n F: x+: X+: \
t:=tags u:=units l:=min m:=max d:=default f=type e=type N=type
desc="${1:-number}" tag="${tags[2]:-numbers}"
@@ -56,7 +57,9 @@ desc="${1:-number}" tag="${tags[2]:-numbers}"
if (( $#argv )) && compset -P "$pat"; then
zstyle -s ":completion:${curcontext}:units" list-separator sep || sep=--
_description -V units expl unit
- disp=( ${${argv#:}/:/ $sep } )
+ pad=${#${(O)${${argv%%:*}//?/.}}[1]} # length of longest suffix
+ disp=( ${${argv#:}/(#m)[^:]##/${(pr<$pad>< >)MATCH}} ) # pad suffixes
+ disp=( ${disp/:/ $sep } )
compadd -M 'r:|/=* r:|=*' -d disp "$keep[@]" "$expl[@]" - ${${argv#:}%%:*}
return
elif [[ -prefix $~pat || $PREFIX = $~partial ]]; then
@@ -70,12 +73,13 @@ elif [[ -prefix $~pat || $PREFIX = $~partial ]]; then
zstyle -s ":completion:${curcontext}:unit-suffixes" format suffixfmt || \
suffixfmt='%(d.%U.)%x%(d.%u.)%(r..|)'
for ((i=0;i<$#;i++)); do
- zformat -f suffix "$suffixfmt" "x:${${argv[i+1]#:}%%:*}" \
+ zformat -fq suffix "$suffixfmt" "x:${${argv[i+1]#:}%%:*}" \
"X:${${argv[i+1]#:}#*:}" "d:${#${argv[i+1]}[1]#:}" \
i:i r:$(( $# - i - 1))
- suffixes+="${suffix//\%/%%}"
+ suffixes+=$suffix
done
- [[ -n $suffixes ]] && formats+=( x:$suffixes )
+ # don't quote %x so we can pass formatting through
+ [[ -n $suffixes ]] && formats+=( %%x:$suffixes )
_comp_mesg=yes
_description -x $tag expl "$desc" $formats
diff --git a/Completion/Base/Utility/_phony b/Completion/Base/Utility/_phony
new file mode 100644
index 000000000..1d53a2ecf
--- /dev/null
+++ b/Completion/Base/Utility/_phony
@@ -0,0 +1,51 @@
+#autoload
+
+# Mix literal matches in with those produced by another function.
+# This is useful where certain phony values, like "all", "any" or
+# "none" are permitted alongside the real matches.
+
+# _phony [compadd options] [word] [words... --] [ _function [args] ]
+# -a, -k, -l and -d options are the same as for compadd but are not
+# passed on to the child function
+# -E is only used once (last)
+# -A and -O results merged as if compadd was used once only
+
+local curcontext="$curcontext" minus
+local -i minus strip nm skip ret=1
+local -a phony opts cont amerge omerge phony_amat phony_omat last
+
+zparseopts -D -a opts a=phony k=phony d:=phony l=phony \
+ n F: p: i: P: I: e f s: S: q r: R: M+: J+: V+: 1 2 o+: X+: x+: D: \
+ A+:=amerge O+:=omerge \
+ E:=last
+
+if (( $argv[(I)--] )); then
+ (( strip = $argv[(i)--] ))
+ phony+=( "${(@)argv[1,strip-1]}" )
+ shift $strip
+else
+ phony+=( "$argv[1]" )
+ shift
+fi
+
+if (( ! $# )); then # no function passed
+ opts=( ${opts:/-X/-x} )
+ skip=1
+else
+ (( minus = argv[(ib:2:)-] ))
+ (( minus > $# )) && minus=2 && argv[1]+=( - )
+ argv[minus]=( "$opts[@]" ${=amerge:+-A phony_amat} ${=omerge:+-O phony_omat} "$last[@]" )
+fi
+
+compadd "$opts[@]" "$amerge[@]" "$omerge[@]" "$phony[@]" && ret=0
+nm=$compstate[nmatches]
+if (( skip )) || "$@" || [[ -n "$_comp_mesg" ]]; then
+ [[ ret -eq 0 && compstate[nmatches] -eq nm && -z "$PREFIX$SUFFIX" ]] &&
+ compstate[insert]=''
+ ret=0
+fi
+
+(( $+amerge[2] )) && set -A ${amerge[2]} "${(@P)amerge[2]}" "$phony_amat[@]"
+(( $+omerge[2] )) && set -A ${omerge[2]} "${(@P)omerge[2]}" "$phony_omat[@]"
+
+return ret
diff --git a/Completion/Base/Utility/_values b/Completion/Base/Utility/_values
index 5ed79e890..a8a14c73f 100644
--- a/Completion/Base/Utility/_values
+++ b/Completion/Base/Utility/_values
@@ -59,8 +59,8 @@ if compvalues -i "$keep[@]" "$@"; then
_describe "$descr" \
noargs "$sep[@]" -M 'r:|[_-]=* r:|=*' -- \
- args -S "${argsep}" -M 'r:|[_-]=* r:|=*' -- \
- opts -qS "${argsep}" -r "${argsep}${sep[2]} \\t\\n\\-" -M 'r:|[_-]=* r:|=*'
+ args -S "${argsep}" -r "${argsep}${sep[2]}" -M 'r:|[_-]=* r:|=*' -- \
+ opts -S "${argsep}" -r "${argsep}${sep[2]} \\t\\n\\-" -M 'r:|[_-]=* r:|=*'
curcontext="$oldcontext"
diff --git a/Completion/Cygwin/Command/_cygcheck b/Completion/Cygwin/Command/_cygcheck
index e0d7532e2..018c891a5 100644
--- a/Completion/Cygwin/Command/_cygcheck
+++ b/Completion/Cygwin/Command/_cygcheck
@@ -18,7 +18,7 @@ _arguments -C -s -S \
'(* -)'{-l,--list-package}'[list contents of the specified package (or all packages if none given)]:*:package:->package' \
'(* -)'{-p,--package-query}'[search for the specified regexp in the entire cygwin.com package repository (requires internet connectivity)]:regexp:' \
'(-V --version -k --keycheck -f --find-package -l --list-package -p --package-query -c --check-setup -d --dump-only -v --verbose)'{-v,--verbose}'[produce more verbose output]' \
- '(-V --version -k --keycheck -f --find-package -l --list-package -p --package-query -c --check-setup -d --dump-only -h --help)'{-h,--help}'[annotate output with explanatory comments when given with another command, otherwise print this help]' \
+ '(-V --version -k --keycheck -f --find-package -l --list-package -p --package-query -c --check-setup -d --dump-only -h --help)'{-h,--help}'[annotate output with explanatory comments when given with another command, otherwise print generic help]' \
'(* -)'{-V,--version}'[print the version of cygcheck and exit]' \
'(-)*:program: _command_names -e' && return
diff --git a/Completion/Darwin/Command/_caffeinate b/Completion/Darwin/Command/_caffeinate
index 9e361a5bd..f7d67695b 100644
--- a/Completion/Darwin/Command/_caffeinate
+++ b/Completion/Darwin/Command/_caffeinate
@@ -6,7 +6,7 @@ _arguments -s -S : \
'-m[prevent disk idle sleep]' \
'-s[prevent system sleep (AC power only)]' \
'-u[declare that user is active]' \
- '(:)-t[specify assertion timeout value]:timeout (seconds)' \
- '(:)-w[wait for specified PID]: :_pids' \
+ '(:)-t+[specify assertion timeout value]:timeout (seconds)' \
+ '(:)-w+[wait for specified PID]: :_pids' \
'(-)1: : _command_names -e' \
'(-)*::command argument'
diff --git a/Completion/Darwin/Command/_fink b/Completion/Darwin/Command/_fink
index 04a067ec1..258e4ecee 100644
--- a/Completion/Darwin/Command/_fink
+++ b/Completion/Darwin/Command/_fink
@@ -123,7 +123,7 @@ _fink(){
'(-s --section)'{-s=,--section=}'[sections]:section name' \
'(-m --maintainer)'{-m=,--maintainer=}'[maintainer]:maintainer name' \
--tree='[tree]:tree name' \
- '(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \
+ '(-w --width)'{-w=,--width=}'[width of display]:number:_phony auto' \
'(1 : -)'{-h,--help}'[display help text]' \
'1: :->pkgs' && return 0
@@ -134,7 +134,7 @@ _fink(){
apropos)
_arguments \
'(-t --tab)'{-t,--tab}'[output the list with tabs as field delimiter]' \
- '(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \
+ '(-w --width)'{-w=,--width=}'[width of display]:number:_phony auto' \
'(1 : -)'{-h,--help}'[display help text]' \
'1: :->pkgs' && return
diff --git a/Completion/Debian/Command/_apt b/Completion/Debian/Command/_apt
index 19c2dfc8c..01d8282d1 100644
--- a/Completion/Debian/Command/_apt
+++ b/Completion/Debian/Command/_apt
@@ -468,7 +468,9 @@ _apt-cmd () {
/$'full-upgrade\0'/ \| \
/$'dist-upgrade\0'/ \| \
/$'edit-sources\0'/ /$'[^\0]#\0'/ ': ::_apt_sources' \# \| \
- /"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install reinstall download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autopurge autoremove purge why why-not'
+ /$'history-list\0'/ \| \
+ /$'(history-(info|redo|undo|rollback))\0'/ /$'[^\0]#\0'/ ': ::_apt_history_ids' \# \| \
+ /"[]"/ ':argument-1::compadd "$expl_action[@]" list search showsrc show depends rdepends policy update install reinstall download source build-dep remove upgrade full-upgrade dist-upgrade edit-sources autoclean changelog autopurge autoremove purge why why-not history-list history-info history-redo history-undo history-rollback'
_apt-cmd () {
local expl_action expl_packages subcmd
@@ -490,12 +492,15 @@ _apt-get () {
-d,--download-only:bool \
-f,--fix-broken:bool \
-h,--help:bool \
+ --assume-no:bool \
+ -a,--host-architecture:bool \
+ -P,--build-profiles:bool \
-m,--ignore-missing,--fix-missing:bool \
-o,--option:arbitem \
-q,--quiet,--silent:intlevel \
-s,--simulate,--just-print,--dry-run,--recon,--no-act:bool \
-t,--target-release,--default-release:release \
- -u,--show-upgraded:bool \
+ --no-show-upgraded:bool \
-v,--version:bool \
-y,--yes,--assume-yes:bool \
--allow-change-held-packages:bool \
@@ -513,6 +518,7 @@ _apt-get () {
--no-download:bool \
--no-install-recommends:bool \
--no-remove:bool \
+ --install-suggests:bool \
--no-upgrade:bool \
--only-source:bool \
--only-upgrade:bool \
@@ -793,4 +799,10 @@ _apt_snapshot_dates() {
_wanted list expl 'wayback date (yyyymmdd[ThhmmssZ])' compadd -- $dates
}
+_apt_history_ids() {
+ local -a expl historyids
+ historyids=( ${${${(f)"$(_call_program history-ids apt history-list)"}:#ID*}%% *} )
+ _wanted history-ids expl 'history id' compadd -o numeric,reverse -a historyids
+}
+
_apt "$@"
diff --git a/Completion/Debian/Command/_auto-apt b/Completion/Debian/Command/_auto-apt
deleted file mode 100644
index 2e6dccbc1..000000000
--- a/Completion/Debian/Command/_auto-apt
+++ /dev/null
@@ -1,31 +0,0 @@
-#compdef auto-apt
-
-local expl prev="$words[CURRENT-1]"
-
-# if there is a command in arguments ?
-if [[ -n $words[(r)(run|update|update-local|merge|del|check|list|search|debuilt|status)] ]] ; then
-
- # yes, add completion for command arguments and command options
- if [[ -n $words[(r)(update|update-local|merge)] && "$words[CURRENT]" = -* ]] ; then
- _wanted option expl 'option' compadd - "-a" && return;
- fi
-
- if [[ -n $words[(r)(check|list|search)] && "$words[CURRENT]" = -* ]] ; then
- _wanted option expl 'option' compadd - "-v" "-f" && return;
- fi
-
- case $prev in
- run) _wanted command expl 'command' _files -g '*(/,*)' && return ;;
- del) _wanted package expl 'package' _deb_packages avail && return ;;
- esac
-else
- _arguments \
- '-a:distribution:_values -s , distribution main contrib non-free non-US none' \
- '-p:hook:_values -s , hook exec open access stat none' \
- '-D:dbfile:_files' \
- '-F:filedb:_files' \
- -h -s -y -q -i -X -x -L \
- '*:command:(run update update-local merge del check list search debuild status)' && return
-fi
-
-return 1
diff --git a/Completion/Debian/Command/_dak b/Completion/Debian/Command/_dak
index 9976c7371..0c1d82f84 100644
--- a/Completion/Debian/Command/_dak
+++ b/Completion/Debian/Command/_dak
@@ -37,7 +37,7 @@ case $cmd in
'(-n --no-action)'{-n,--no-action}'[do not do anything]'
'(-s --suite)'{-s,--suite=}':suite:_values -s , "suite list" oldstable stable testing unstable experimental'
':package:_deb_packages avail'
- ':section:(admin base comm contrib/admin contrib/comm contrib/devel contrib/doc contrib/games contrib/graphics contrib/interpreters contrib/kde contrib/libdevel contrib/libs contrib/mail contrib/math contrib/misc contrib/net contrib/otherosfs contrib/perl contrib/python contrib/science contrib/sound contrib/tex contrib/text contrib/utils contrib/web contrib/x11 devel doc editors electronics embedded games gnome graphics hamradio interpreters kde libdevel libs mail math misc net news non-free/admin non-free/base non-free/comm non-free/devel non-free/doc non-free/editors non-free/electronics non-free/games non-free/graphics non-free/hamradio non-free/libdevel non-free/libs non-free/mail non-free/math non-free/misc non-free/net non-free/news non-free/otherosfs non-free/python non-free/science non-free/sound non-free/tex non-free/text non-free/utils non-free/web non-free/x11 oldlibs otherosfs perl python science shells sound tex text utils web x11)'
+ ':section:({,contrib/,non-free/}{admin,cli-mono,comm,database,debug,devel,doc,editors,education,electronics,embedded,fonts,games,gnome,gnu-r,gnustep,graphics,hamradio,haskell,httpd,interpreters,introspection,java,javascript,kde,kernel,libdevel,libs,lisp,localization,mail,math,metapackages,misc,net,news,ocaml,oldlibs,otherosfs,perl,php,python,ruby,rust,science,shells,sound,tex,text,utils,vcs,video,web,x11,xfce,zope})'
':priority:(extra important optional required standard)'
)
;;
diff --git a/Completion/Debian/Command/_debfoster b/Completion/Debian/Command/_debfoster
index 08a1078e2..3e2231d73 100644
--- a/Completion/Debian/Command/_debfoster
+++ b/Completion/Debian/Command/_debfoster
@@ -44,10 +44,13 @@ if [[ -n "$state" ]]; then
;;
*(#i)(no|)keepsections*)
_wanted values expl 'section' compadd \
- x11 web utils text tex sound shells science \
- otherosfs oldlibs news net misc math mail libs \
- interpreters hamradio graphics games electronics \
- editors doc devel comm base admin && ret=0
+ zope xfce x11 web video vcs utils text tex sound shells \
+ science rust ruby python php perl otherosfs oldlibs ocaml \
+ news net misc metapackages math mail localization lisp libs \
+ libdevel kernel kde javascript java introspection \
+ interpreters httpd haskell hamradio graphics gnustep gnu-r \
+ gnome games fonts embedded electronics education editors doc \
+ devel debug database comm cli-mono admin && ret=0
;;
*(#i)guessdepends*)
_wanted values expl 'name extension' \
diff --git a/Completion/Debian/Command/_dpkg_source b/Completion/Debian/Command/_dpkg_source
index eabe8bc33..379ad39a7 100644
--- a/Completion/Debian/Command/_dpkg_source
+++ b/Completion/Debian/Command/_dpkg_source
@@ -1,16 +1,32 @@
#compdef dpkg-source
_arguments \
- '-x[specify source file]:Debian source file:_files -g "*.dsc(-.)"' \
- '-b[specify source directory]:Debian source directory:_files -/' \
+ '(-x --extract)'{-x,--extract}'[specify source file]:Debian source file:_files -g "*.dsc(-.)"::output directory:_directories' \
+ '(-b --build)'{-b,--build}'[specify source directory]:Debian source directory:_files -/' \
+ '--print-format[print the format to be used for the source package]: :_directories' \
+ '--before-build[run the corresponding source package format hook]: :_directories' \
+ '--after-build[run the corresponding source package format hook]: :_directories' \
+ '--commit[store upstream changes in a new patch]: :_directories::patch name' \
'-c-[control file]:control file:_files' \
'-l-[changelog file]:changelog file:_files' \
'-F-[changelog format]:changelog format:' \
+ '--format=[set the format to be used for the source package]:format' \
'-V-[set substitutions variable]:expression:' \
'-T-[alternate variable file]:varlistfile:' \
'-D-[override dsc field]:expression:' \
'-U-[remove a field]:field:' \
- '-i-[ignore files in diff]:filter:' \
+ '(-i --diff-ignore)'{-i-,--diff-ignore=}'[filter out files to ignore diffs of]:regex' \
+ '--extend-diff-ignore=:regex' \
+ '(-I --tar-ignore)'{-I-,--tar-ignore=}'[filter out files when building tarballs]:regex' \
+ '(-Z --compression)'{-Z-,--compression=}'[select compression to use]:compression [xz]:(bzip2 gzip lzma xz)' \
+ '(-z --compression-level)'{-z-,--compression-level=}'[compression level to use]:level [9]' \
+ "--no-copy[don't copy .orig tarballs]" \
+ "--no-check[don't check signature and checksums before unpacking]" \
+ "--no-overwrite-dir[don't overwrite directory on extraction]" \
+ "--require-valid-signature[abort if the package doesn't have a valid signature]" \
+ '--require-strong-checksums[abort if the package contains no strong checksums]' \
+ '--ignore-bad-version[allow bad source package versions]' \
+ '--threads-max=[set maximum number of threads for compressors]:threads' \
'-sa[autoselect orig source]' \
'-sk[use packaged orig source - unpack and keep]' \
'-sp[use packaged orig source - unpack and remove]' \
@@ -19,10 +35,14 @@ _arguments \
'-ss[trust packed and unpacked source are the same]' \
'-sn[no diff, do main tarfile only]' \
'-sA[autoselect orig source with overwrite]' \
+ '--abort-on-upstream-changes' \
'-sK[use packaged orig source - unpack and keep with overwrite]' \
'-sP[use packaged orig source - unpack and remove with overwrite]' \
'-sU[use unpackaged orig source - unpack and keep with overwrite]' \
'-sR[use unpackaged orig source - unpack and remove with overwrite]' \
'-sp[leave original source packed in cwd]' \
'-su[unpack original source tree too]' \
- '-h[help]'
+ "--skip-debianization[don't apply debian diff to upstream sources]" \
+ '(-)'{-\?,--help}'[display help information]' \
+ '-q[quiet mode]' \
+ '--version[display version information]'
diff --git a/Completion/Debian/Command/_git-buildpackage b/Completion/Debian/Command/_git-buildpackage
deleted file mode 100644
index 81bf7dac9..000000000
--- a/Completion/Debian/Command/_git-buildpackage
+++ /dev/null
@@ -1,43 +0,0 @@
-#compdef git-buildpackage
-#description build Debian packages from a git repository
-
-_arguments \
- '--version[show program version number and exit]' \
- '--help[show help message and exit]' \
- '--git-ignore-new[build with uncommitted changes in the source tree]' \
- '--git-no-ignore-new[negates --git-ignore-new]' \
- '--git-verbose[verbose command execution]' \
- '--git-tag[create a tag after a successful build]' \
- '--git-tag-only[do not build, only tag and run the posttag hook]' \
- '--git-retag[do not fail if the tag already exists]' \
- '--git-sign-tags[sign tags]' \
- '--git-no-sign-tags[negates --git-sign-tags]' \
- '--git-keyid=-[GPG keyid to sign tags with]:GPG key:' \
- '--git-debian-tag=-[format string for debian tags]:format string [debian/%%(version)s]' \
- '--git-upstream-tag=-[format string for upstream tags]:format string [upstream/%%(version)s]' \
- '--git-pristine-tar[use pristine-tar to create .orig.tar.gz]' \
- '--git-no-pristine-tar[negates --git-pristine-tar]' \
- '--git-force-create[force creation of orig.tar.gz]' \
- '--git-no-create-orig[do not create orig.tar.gz]' \
- '--git-tarball-dir=-[location to look for external tarballs]:tarball directory:_files -/' \
- '--git-compression=-[compression type]:compression type [auto]:(auto gzip bzip2 lzma xz)' \
- '--git-compression-level=-[set compression level]:level:(1 2 3 4 5 6 7 8 9)' \
- '--git-upstream-branch=-[upstream branch]::' \
- '--git-debian-branch=-[branch the Debian package is being developed on]::' \
- '--git-ignore-branch[build although debian-branch != current branch]' \
- '--git-no-ignore-branch[negates --git-ignore-branch]' \
- '--git-builder=-[command to build the Debian package]:command:' \
- '--git-cleaner=-[command to clean the working copy]:command:' \
- '--git-prebuild=-[command to run before a build]:command:' \
- '--git-postbuild=-[hook run after a successful build]:command:' \
- '--git-posttag=-[hook run after a successful tag operation]:command:' \
- '--git-pbuilder[invoke git-pbuilder for building]' \
- '--git-no-pbuilder[negates --git-pbuilder]' \
- '--git-dist=-[build for this distribution when using git-pbuilder]:distribution:' \
- '--git-arch=-[build for this architecture when using git-pbuilder]:architecture:' \
- '--git-export-dir=-[before building the package export the source into this directory]:directory:_files -/' \
- '--git-export=-[export treeish object instead of HEAD]:treeish:' \
- '--git-dont-purge[retain exported package build directory]' \
- '--git-overlay[extract orig tarball when using export-dir option]' \
- '--git-no-overlay[negates --git-overlay]' \
- '*:other options:_dpkg-buildpackage'
diff --git a/Completion/Debian/Command/_invoke-rc.d b/Completion/Debian/Command/_invoke-rc.d
index cd8df28c1..74ee1e828 100644
--- a/Completion/Debian/Command/_invoke-rc.d
+++ b/Completion/Debian/Command/_invoke-rc.d
@@ -1,11 +1,13 @@
#compdef invoke-rc.d
_arguments \
+ '(- 1 2)--help[display help information]' \
'--quiet[quiet mode, no error messages are generated]' \
'--force[run the initscript regardless of policy and subsystem]' \
'--try-anyway[run the initscript even if a non-fatal error is found]' \
'--disclose-deny[return 101 instead of 0 if action is denied]' \
'--query[return one of status codes 100-106, does not run the script]' \
'--no-fallback[ignore any fallback action requests by the policy layer]' \
+ '--skip-systemd-native[exit before doing anything if a systemd environment is detected]' \
'1:service:_services' \
- '2:command:(start stop force-stop restart reload force-reload status)'
+ '2:command:(start stop force-stop restart try-restart reload force-reload status)'
diff --git a/Completion/Debian/Command/_module-assistant b/Completion/Debian/Command/_module-assistant
index b2c1e56ee..27c06bc5b 100644
--- a/Completion/Debian/Command/_module-assistant
+++ b/Completion/Debian/Command/_module-assistant
@@ -20,7 +20,7 @@ _module_assistant_commands=(
'purge[clear cache and remove all binary packages of source package]'
)
-_arguments -A \
+_arguments -s -S : \
'(-h --help)'{-h,--help}'[print help screen]' \
'(-v --verbose)'{-v,--verbose}'[be verbose, show full paths, etc.]' \
'(-q --quiet)'{-q,--quiet}'[the opposite of verbose]' \
@@ -34,4 +34,3 @@ _arguments -A \
'(-t --text-mode)'{-t,--text-mode}'[no progress bars]' \
'1:list of commands:_values -s , subcommands "${_module_assistant_commands[@]}"' \
'*:package: compadd /usr/src/modass/var_cache_modass/*.avail_version(N:t:r) /var/cache/modass/*.avail_version(N:t:r)'
-
diff --git a/Completion/Debian/Command/_update-alternatives b/Completion/Debian/Command/_update-alternatives
index 31128dd82..0ddb8748d 100644
--- a/Completion/Debian/Command/_update-alternatives
+++ b/Completion/Debian/Command/_update-alternatives
@@ -14,8 +14,10 @@ _arguments -C \
'--test' \
'--help' \
'--version' \
- '--altdir:altdir:_files -/' \
- '--admindir:admindir:_files -/' \
+ '--altdir:alternatives directory [/etc/alternatives]:_files -/' \
+ "--admindir:administrative directory [$alterdir]:_files -/" \
+ '--instdir:installation directory:_files -/' \
+ '--root:root directory:_files -/' \
'--log:log file:_files -/' \
'--force' \
'--skip-auto' \
diff --git a/Completion/Debian/Command/_update-rc.d b/Completion/Debian/Command/_update-rc.d
index 68b81dc72..d1941a384 100644
--- a/Completion/Debian/Command/_update-rc.d
+++ b/Completion/Debian/Command/_update-rc.d
@@ -3,26 +3,18 @@
local curcontext="$curcontext" state line expl
_arguments -C \
- '-n[show actions without performing them]' \
'-f[force removal of symlinks]' \
'1:service:_services' \
- '2:command:(remove defaults start stop)' \
+ '2:command:(remove defaults defaults-disabled disable enable)' \
'*::args:->args' && return
case $words[2] in
- defaults)
- _message -e number 'sequence number'
+ disable|enable)
+ _wanted runlevels expl runlevel S 2 3 4 5 && return
;;
- remove)
+ *)
_message 'no more arguments'
;;
- st*)
- case ${words[CURRENT-1]} in
- .) _wanted commands expl commands compadd start stop && return ;;
- start|stop) _message -e number 'sequence number' ;;
- *) _message -e runlevels run\ level ;;
- esac
- ;;
esac
return 1
diff --git a/Completion/Linux/Command/_acpi b/Completion/Linux/Command/_acpi
index 850687506..5ebf1447c 100644
--- a/Completion/Linux/Command/_acpi
+++ b/Completion/Linux/Command/_acpi
@@ -14,5 +14,5 @@ _arguments -s \
'(-c --celsius -f --fahrenheit -k --kelvin)'{-f,--fahrenheit}'[use Fahrenheit as the temperature scale]' \
'(-c --celsius -f --fahrenheit -k --kelvin)'{-k,--kelvin}'[use Kelvin as the temperature scale]' \
'(-d --directory)'{-d,--directory}'[path to ACPI info (/proc/acpi)]:directory:_files -/' \
- '(-h --help)'{-h,--help}'[display this help and exit]' \
+ '(-h --help)'{-h,--help}'[display help and exit]' \
'(-v --version)'{-v,--version}'[output version information and exit]'
diff --git a/Completion/Linux/Command/_blkid b/Completion/Linux/Command/_blkid
index e31250d37..29392c4e5 100644
--- a/Completion/Linux/Command/_blkid
+++ b/Completion/Linux/Command/_blkid
@@ -19,10 +19,10 @@ _arguments \
'(-l --list-one)'{-l,--list-one}'[look up only first device with token specified by -t]' \
'(-n --match-types)'{-n+,--match-types=}'[filter by filesystem type]: :_sequence _file_systems' \
'(-O --offset)'{-O+,--offset=}'[probe at the given offset]: :_numbers -M "m\:{a-zA-Z}={A-Za-z}" offset {K,M,G,T,P,E,Z,Y}{,B,iB}' \
- '(-o --output)'{-o+,--output=}'[specify output format]:format [full]:(full value list device udev export)' \
+ '(-o --output)'{-o+,--output=}'[specify output format]:format [full]:(full value list device udev export json)' \
'(-p --probe)'{-p,--probe}'[probe low-level superblocks]' \
\*{-s+,--match-tag=}'[show specified tag(s)]:tag:(none LABEL UUID UUID_SUB TYPE PARTLABEL PARTUUID SEC_TYPE PTUUID PTTYPE ALIGNMENT_OFFSET MINIMUM_IO_SIZE OPTIMAL_IO_SIZE PHYSICAL_SECTOR_SIZE LOGICAL_SECTOR_SIZE)' \
- '(-S --size)'{-S+,--size=}'[overwrite device size]: :_numbers -M "m\:{a-zA-Z}={A-Za-z}" size {K,M,G,T,P,E,Z,Y}{,B,iB}' \
+ '(-S --size)'{-S+,--size=}'[override device size]: :_numbers -M "m\:{a-zA-Z}={A-Za-z}" size {K,M,G,T,P,E,Z,Y}{,B,iB}' \
'(-t --match-token)'{-t+,--match-token=}'[find device with a specific token]:token' \
'(-u --usages)'{-u+,--usages=}'[filter by usage]:usage:_sequence compadd - {no,}{filesystem,raid,crypto,other}' \
'*:device:_files -g "*(-%)"'
diff --git a/Completion/Linux/Command/_btrfs b/Completion/Linux/Command/_btrfs
index d8b97a200..539416321 100644
--- a/Completion/Linux/Command/_btrfs
+++ b/Completion/Linux/Command/_btrfs
@@ -155,9 +155,9 @@ while (( $#state )); do
'-c-[compress files while defragmenting]::compression algorithm:(zlib lzo zstd)'
'-r[defragment files recursively]'
'-f[flush after defragmenting]'
- '-s[start position]: :_numbers -u bytes -d "beginning of file" offset K M G T P E'
- '-l[defragment limited number of bytes]: :_numbers -u bytes length K M G T P E'
- '-t[defragment only extents up to a certain size]: :_numbers -u bytes -d 32M "maximum extent size" K M G T P E'
+ '-s+[start position]: :_numbers -u bytes -d "beginning of file" offset K M G T P E'
+ '-l+[defragment limited number of bytes]: :_numbers -u bytes length K M G T P E'
+ '-t+[defragment only extents up to a certain size]: :_numbers -u bytes -d 32M "maximum extent size" K M G T P E'
'*:file:_files'
)
;;
@@ -213,8 +213,8 @@ while (( $#state )); do
'-d[print separate statistics for each device]'
'-r[read only mode]'
'-R[raw print mode]'
- '-c[set ioprio class]:class:(( 0\:none 1\:realtime 2\:best-effort 3\:idle))'
- '-n[set ioprio classdata]:classdata:(0 1 2 3 4 5 6 7)'
+ '-c+[set ioprio class]:class:(( 0\:none 1\:realtime 2\:best-effort 3\:idle))'
+ '-n+[set ioprio classdata]:classdata:(0 1 2 3 4 5 6 7)'
'1:path or device:_files'
)
[[ ${${(P)group}[cmd]} == start ]] && args+=(
@@ -246,7 +246,7 @@ while (( $#state )); do
property:get) args+=( '2:property:(ro label compression)' );&
property:list)
args+=(
- '-t[specify object type]:object type:(subvol filesystem inode device)'
+ '-t+[specify object type]:object type:(subvol filesystem inode device)'
'1: : _guard "^-*" object'
)
;;
diff --git a/Completion/Linux/Command/_chrt b/Completion/Linux/Command/_chrt
index 5431b0799..3e550bf60 100644
--- a/Completion/Linux/Command/_chrt
+++ b/Completion/Linux/Command/_chrt
@@ -8,21 +8,22 @@ _arguments -C -s -S -A "-*" \
'(H -a --all-tasks)'{-a,--all-tasks}'[operate on all tasks (threads) for a given pid]' \
'(H)'{-v,--verbose}'[display status information]' \
'(H)'{-p,--pid}'[interpret args as process ID]' \
- '(H -R --reset-on-fork -b --batch -d --deadline -i --idle -o --other)'{-R,--reset-on-fork}'[set SCHED_RESET_ON_FORK for FIFO or RR]' \
+ '(H -R --reset-on-fork -b --batch -d --deadline -e --ext -i --idle -o --other)'{-R,--reset-on-fork}'[set SCHED_RESET_ON_FORK for FIFO or RR]' \
+ '(H -T --sched-runtime -f --fifo -e --ext -i --idle -r --rr)'{-T,--sched-runtime}'[runtime parameter for DEADLINE]' \
'(H)*::command or priority:->cmd_or_prio' \
+ 'H' \
'(* -)'{-m,--max}'[show minimum and maximum valid priorities, then exit]' \
'(* -)'{-h,--help}'[display usage information]' \
'(* -)'{-V,--version}'[output version information]' \
+ 'dline' \
- '(H -T --sched-runtime -b --batch -f --fifo -i --idle -o --other -r --rr)'{-T,--sched-runtime}'[runtime parameter for DEADLINE]' \
- '(H -P --sched-period -b --batch -f --fifo -i --idle -o --other -r --rr)'{-P,--sched-period}'[period parameter for DEADLINE]' \
- '(H -D --sched-deadline -b --batch -f --fifo -i --idle -o --other -r --rr)'{-D,--sched-deadline}'[deadline parameter for DEADLINE]' \
+ '(H -P --sched-period -b --batch -f --fifo -e --ext -i --idle -o --other -r --rr)'{-P,--sched-period}'[period parameter for DEADLINE]' \
+ '(H -D --sched-deadline -b --batch -f --fifo -e --ext -i --idle -o --other -r --rr)'{-D,--sched-deadline}'[deadline parameter for DEADLINE]' \
+ '(policy)' \
'(H dline -R --reset-on-fork)'{-b,--batch}'[set scheduling policy to SCHED_BATCH]' \
'(H -R --reset-on-fork)'{-d,--deadline}'[set scheduling policy to SCHED_DEADLINE]' \
- '(H dline)'{-f,--fifo}'[set scheduling policy to SCHED_FIFO]' \
- '(H dline -R --reset-on-fork)'{-i,--idle}'[set scheduling policy to SCHED_IDLE]' \
+ '(H dline -T --sched-runtime)'{-e,--ext}'[set scheduling policy to SCHED_EXT (BPF program-defined scheduling)]' \
+ '(H dline -T --sched-runtime)'{-f,--fifo}'[set scheduling policy to SCHED_FIFO]' \
+ '(H dline -R --reset-on-fork -T --sched-runtime)'{-i,--idle}'[set scheduling policy to SCHED_IDLE]' \
'(H dline -R --reset-on-fork)'{-o,--other}'[set scheduling policy to SCHED_OTHER]' \
'(H dline)'{-r,--rr}'[set scheduling policy to SCHED_RR (default)]' && ret=0
diff --git a/Completion/Linux/Command/_cryptsetup b/Completion/Linux/Command/_cryptsetup
index 897eb94f9..2654ca844 100644
--- a/Completion/Linux/Command/_cryptsetup
+++ b/Completion/Linux/Command/_cryptsetup
@@ -45,6 +45,7 @@ _arguments -s \
'--dump-volume-key[dump volume key instead of keyslots info]' \
'--external-tokens-path=[specify path to directory with external token handlers (plugins)]:path:_directories' \
'--force-offline-reencrypt[force offline LUKS2 reencryption and bypass active device detection]' \
+ '--force-no-keyslots[force dangerous reencryption operation erasing all remaining keyslots]' \
'--header=[device or file with separated LUKS header]:file:_files' \
'--hw-opal[use HW OPAL encryption together with SW encryption]' \
'--hw-opal-factory-reset[wipe WHOLE OPAL disk on luksErase]' \
@@ -52,8 +53,12 @@ _arguments -s \
'--keep-key[do not change volume key]' \
'--link-vk-to-keyring=[set keyring where to link volume key]:string' \
'--new-keyfile=[read the key for a new slot from a file]:file:_files' \
+ '--new-key-description=[specify keyring new key description]:description' \
+ '--new-key-size=[specify size of the new encryption key]:size (bits)' \
'--new-key-slot=[specify slot number for new key]:slot [first free]' \
'--new-token-id=[token number]:number [any]' \
+ '--new-volume-key-file=[use new volume key from file]: :_files' \
+ '--new-volume-key-keyring=[use specified keyring key as new volume key]:key' \
'--progress-json[print progress data in json format]' \
"--test-args[don't run action, just validate all command line parameters]" \
'--volume-key-file=[use the volume key from file]:file:_files' \
@@ -76,6 +81,7 @@ _arguments -s \
'--force-password[disable password quality check (if enabled)]' \
'--perf-same_cpu_crypt[use dm-crypt same_cpu_crypt performance compatibility option]' \
'--perf-submit_from_crypt_cpus[use dm-crypt submit_from_crypt_cpus performance compatibility option]' \
+ '--perf-high_priority[set dm-crypt workqueues and writer thread to high priority]' \
'--perf-no_read_workqueue[bypass dm-crypt workqueue and process read requests synchronously]' \
'--perf-no_write_workqueue[bypass dm-crypt workqueue and process write requests synchronously]' \
'--deferred[device removal is deferred until the last user closes it]' \
@@ -88,12 +94,14 @@ _arguments -s \
'--disable-locks[disable locking of on-disk metadata]' \
'--disable-keyring[disable loading volume keys via kernel keyring]' \
'(-I --integrity)'{-I+,--integrity=}'[specify data integrity algorithm (LUKS2 only)]:algorithm' \
+ '--integrity-inline[use inline mode (use HW integrity field)]' \
+ '--integrity-key-size=[specify size of the data integrity key]:size (bits)' \
'--integrity-no-journal[disable journal for integrity device]' \
"--integrity-no-wipe[don't wipe device after format]" \
'--integrity-legacy-padding[use inefficient legacy padding (old kernels)]' \
"--token-only[don't ask for passphrase if activation by token fails]" \
'--token-id=[specify token number]:number [any]' \
- '--key-description=[specify key description]:description' \
+ '--key-description=[specify keyring key description]:description' \
'--sector-size=[specify encryption sector size]:size [512 bytes]' \
'--iv-large-sectors[use IV counted in sector size (not in 512 bytes)]' \
'--persistent[set activation flags persistent for device]' \
diff --git a/Completion/Linux/Command/_ethtool b/Completion/Linux/Command/_ethtool
index 8cff24e96..f1f67a357 100644
--- a/Completion/Linux/Command/_ethtool
+++ b/Completion/Linux/Command/_ethtool
@@ -6,14 +6,24 @@ local -A opt_args
_arguments -C -A "-*" \
'--debug[turn on debugging messages]:mask:((1\:parser\ information))' \
- '--json[output results in JSON]' \
+ '(-j --json)'{-j,--json}'[output results in JSON]' \
'(-I --include-statistics)'{-I,--include-statistics}'[include command-related statistics in the output]' \
- '(cmds)'{-Q,--per-queue}'[apply per-queue command]: :(queue_mask):queue mask' \
+ '(cmds cmdp)'{-Q,--per-queue}'[apply per-queue command]: :(queue_mask):queue mask' \
+ '(cmds cmdc)--phy=[target a PHY within the interface]:phy' \
"1:interface:_net_interfaces" \
'*:: :->args' \
+ '(cmdc)' \
- '(cmds)'{-c,--show-coalesce}'[query the specified ethernet device for coalescing information]' \
- '(cmds)'{-C,--coalesce}'[change the coalescing settings of the specified ethernet device]' \
+ '(cmdp cmds)'{-c,--show-coalesce}'[query the specified ethernet device for coalescing information]' \
+ '(cmdp cmds)'{-C,--coalesce}'[change the coalescing settings of the specified ethernet device]' \
+ + '(cmdp)' \
+ '(cmds cmdc)--cable-test[perform cable test and report the results]' \
+ '(cmds cmdc)--cable-test-tdr[perform cable test and report Time Domain Reflectometer data]' \
+ '(cmds cmdc)--get-plca-cfg[get PLCA configuration]' \
+ '(cmds cmdc)--set-plca-cfg[set PLCA configuration]' \
+ '(cmds cmdc)--get-plca-status[get PLCA status information]' \
+ '(cmds cmdc)--show-pse[show settings for power sourcing equipment]' \
+ '(cmds cmdc)--set-pse[set power sourcing equipment settings]' \
+ '(cmds cmdc)--show-mse[show Mean Square Error (MSE) diagnostics]' \
+ '(cmds)' \
'(1)'{-h,--help}'[display help information]' \
'(1)--version[display version information]' \
@@ -36,6 +46,8 @@ _arguments -C -A "-*" \
{-n,--show-nfc,-u,--show-ntuple}'[retrieve receive network flow classification options or rules]' \
{-N,--config-nfc,-U,--config-ntuple}'[configure receive network flow classification options or rules]' \
{-T,--show-time-stamping}"[show device's time stamping capabilities]" \
+ '--get-hwtimestamp-cfg[get selected hardware time stamping]' \
+ '--set-hwtimestamp-cfg[select hardware time stamping]' \
{-x,--show-rxfh-indir,--show-rxfh}'[show Rx flow hash indirection table and/or RSS hash key]' \
{-X,--set-rxfh-indir,--rxfh}'[set Rx flow hash indirection table and/or RSS hash key]' \
{-f,--flash}'[flash firmware image from the specified file]' \
@@ -56,24 +68,20 @@ _arguments -C -A "-*" \
'--reset[reset hardware components]' \
'--show-fec[query device for forward error correction support]' \
'--set-fec[configure forward error correction for device]' \
- '--cable-test[perform cable test and report the results]' \
- '--cable-test-tdr[perform cable test and report Time Domain Reflectometer data]' \
'--show-tunnels[show tunnel-related device capabilities and state]' \
'--show-module[show transceiver module settings]' \
'--set-module[set transceiver module settings]' \
- '--get-plca-cfg[get PLCA configuration]' \
- '--set-plca-cfg[set PLCA configuration]' \
- '--get-plca-status[get PLCA status information]' \
'--show-mm[show MAC merge layer state]' \
'--set-mm[set MAC merge layer parameters]' \
- '--show-pse[show settings for power sourcing equipment]' \
- '--set-pse[set power sourcing equipment settings]' \
+ '--flash-module-firmware[flash transceiver module firmware]' \
+ '--show-phys[list PHYs]' \
'--monitor[listen to netlink notifications and displays them]::command:(
--all -s --change -k --show-features --show-offload -K
--features --offload --show-priv-flags --set-priv-flags -g --show-ring
-G --set-ring -l --show-channels -L --set-channels -c --show-coalesce
-C --coalesce -a --show-pause -A --pause --show-eee --set-eee
--cable-test --cable-test-tdr --show-module --set-module
+ --get-plca-cfg --set-plca-cfg --pse-event
)' && return
if [[ -n $state ]]; then
@@ -97,17 +105,18 @@ if [[ -n $state ]]; then
rx-frames-low|tx-usecs-low|tx-frames-low|pkt-rate-high|rx-usecs-high) ;&
rx-frames-high|tx-usecs-high|tx-frames-high|sample-interval|dmac) ;&
tx-aggr-max-bytes|tx-aggr-max-frame|tx-aggr-time-usec) ;&
- rx-mini|rx-jumbo|rx-buf-len|cqe-size|tx-push-buf-len) ;&
+ rx-mini|rx-jumbo|rx-buf-len|cqe-size|tx-push-buf-len|hds-thresh) ;&
offset|length|magic|value|phyad|proto|tos|tclass|l4proto|src-port) ;&
dst-port|spi|l4data|vlan-etype|vlan|user-def|action|vf|queue|loc) ;&
+ index) ;&
page|bank|i2c|first|last|step|pair|lanes) ;&
rx-copybreak|tx-copybreak|tx-buf-size|pfc-prevention-tout) ;&
other|combined|tx-timer|count|msecs) ;&
node-id|node-cnt|to-tmr|burst-cnt|burst-tmr) ;&
- tx-min-frag-size)
+ tx-min-frag-size|c33-pse-avail-pw-limit|prio)
_message -e numbers 'number'
;;
- podl-pse-admin-control)
+ (podl-pse|c33-pse)-admin-control)
_wanted values expl 'value' compadd enable disable
;;
speed)
@@ -168,6 +177,12 @@ if [[ -n $state ]]; then
src|src-ip|dst|dst-ip|dst-mac)
_message -e addresses address
;;
+ qualifier)
+ _wanted qualifiers expl qualifier compadd precise approx
+ ;;
+ rx-filter)
+ _message -e values value
+ ;;
m)
_message -e masks mask
;;
@@ -178,7 +193,7 @@ if [[ -n $state ]]; then
_message -e functions 'hash function'
;;
xfrm)
- _wanted transformations expl transformation compadd symmetric-xor none
+ _wanted transformations expl transformation compadd symmetric-xor symmetric-or-xor none
;;
flags)
_message -e masks mask
@@ -192,6 +207,9 @@ if [[ -n $state ]]; then
tcp-data-split)
_wanted states expl state compadd auto on off
;;
+ pass)
+ _message -e passwords password
+ ;;
*)
case ${${(Mk)opt_args:#cmd?*}[1]#cmd?-} in
-a|--show-pause)
@@ -215,7 +233,8 @@ if [[ -n $state ]]; then
'rx-mini[change number of ring entries for the RX Mini ring]' \
'rx-jumbo[change number of ring entries for the RX Jumbo ring]' \
'tx[change number of ring entries for the TX ring]' \
- rx-buf-len tcp-data-split cqe-size tx-push rx-push tx-push-buf-len
+ rx-buf-len tcp-data-split cqe-size tx-push rx-push tx-push-buf-len \
+ hds-thresh
;;
-d|--register-dump)
_values -S ' ' -w 'option' \
@@ -303,6 +322,12 @@ if [[ -n $state ]]; then
queue context loc
fi
;;
+ -T|--show-time-stamping)
+ _wanted options expl option compadd index qualifier
+ ;;
+ --set-hwtimestamp-cfg)
+ _wanted options expl option compadd index qualifier tx rx-filter
+ ;;
-x|--show-rxfh-indir|--show-rxfh)
_wanted options expl option compadd -F line - context
;;
@@ -381,6 +406,17 @@ if [[ -n $state ]]; then
_wanted options expl tunable compadd enable node-id node-cnt \
to-tmr burst-cnt burst-tmr
;;
+ --set-mm)
+ _wanted options expl option compadd verify-enabled verify-time \
+ tx-enabled pmac-enabled tx-min-frag-size
+ ;;
+ --set-pse)
+ _wanted options expl option compadd {podl-pse,c33-pse}-admin-control \
+ c33-pse-avail-pw-limit prio
+ ;;
+ --flash-module-firmware)
+ _wanted options expl option compadd file pass
+ ;;
esac
;;
esac
diff --git a/Completion/Linux/Command/_findmnt b/Completion/Linux/Command/_findmnt
index 6155d4dc1..b9cb04dc7 100644
--- a/Completion/Linux/Command/_findmnt
+++ b/Completion/Linux/Command/_findmnt
@@ -19,6 +19,7 @@ _arguments -s -C \
'(H -e --evaluate)'{-e,--evaluate}'[convert LABEL/UUID/PARTLABEL/PARTUUID to the device name]' \
'(H -F --tab-file)*'{-F+,--tab-file=}'[search in the specified tab file]:tab file:_files' \
'(H -f --first-only)'{-f,--first-only}'[print the first matching filesystem only]' \
+ '(H)--hyperlink=-[print paths as hyperlinks]::when:(always never auto)' \
'(H -i --invert)'{-i,--invert}'[invert the sense of matching]' \
'(H -M --mountpoint :)'{-M+,--mountpoint=}'[specify the mountpoint]: :->targets' \
'(H -n --noheadings)'{-n,--noheadings}'[do not print a header line]' \
@@ -52,7 +53,8 @@ _arguments -s -C \
'(H)'{-P,--pairs}'[use key="value" output format]' \
'(H)'{-r,--raw}'[use raw output format]' \
+ '(S)' \
- '(H)'{-k,--kernel}'[search in /proc/self/mountinfo (default)]' \
+ '(H)-k[search in /proc/self/mountinfo (default)]' \
+ '(H)--kernel=-[search in /proc/self/mountinfo (default)]::method:(mountinfo listmount)' \
'(H)'{-m,--mtab}'[search in /etc/mtab]' \
'(H)'{-N+,--task=}'[search /proc/<pid>/mountinfo]: :_pids' \
'(H)'{-s,--fstab}'[search in /etc/fstab]' \
diff --git a/Completion/Linux/Command/_gpasswd b/Completion/Linux/Command/_gpasswd
index d5d16ebba..24fe361b0 100644
--- a/Completion/Linux/Command/_gpasswd
+++ b/Completion/Linux/Command/_gpasswd
@@ -5,7 +5,7 @@ _arguments -s \
'(-d --delete -a --add)'{-d,--delete}'[remove user from group]: : _users' \
'(-)'{-h,--help}'[display help]' \
'(-Q --root)'{-Q,--root}'[specify directory to chroot into]: : _files -/' \
- '(-r --delete-password)'{-r,--delete-password}'[remove the group password]' \
+ '(-r --remove-password)'{-r,--remove-password}'[remove the group password]' \
'(-R --restrict)'{-R,--restrict}'[restrict access to GROUP to its members]' \
'(-M --members -A --administrators)'{-M,--members}'[set the list of members of GROUP]: :_sequence _users' \
'(-A --administrators -M --members)'{-A,--administrators}'[set the list of admins for GROUP]: :_sequence _users' \
diff --git a/Completion/Unix/Command/_ip b/Completion/Linux/Command/_ip
index 9a7cbd821..d63ddedab 100644
--- a/Completion/Unix/Command/_ip
+++ b/Completion/Linux/Command/_ip
@@ -21,12 +21,12 @@ local -a subcmd_string
subcmd_string=(/$'[^\0]#\0'/ ':string:arbitrary string:( )')
local -a subcmd_number
-subcmd_number=(/$'[0-9]##\0'/ ':number:decimal number:( )')
+subcmd_number=(/$'[0-9]##\0'/ ': _message -e numbers "decimal number"')
local xp='[[:xdigit:]][[:xdigit:]]'
local -a subcmd_lladdr
subcmd_lladdr=(/"${xp}:${xp}:${xp}:${xp}:${xp}:${xp}"$'\0'/
-':lladdress:link layer (MAC) address:( )')
+ ': _message -e lladdresses "link layer (MAC) address"')
local -a subcmd_ipaddr
subcmd_ipaddr=(
@@ -57,7 +57,7 @@ _regex_words scope "IP address scope" \
subcmd_scope=("$reply[@]")
local -a subcmd_nud
-_regex_words nud "Neighbour Unreachability Detection state" \
+_regex_words nud "neighbour unreachability detection state" \
'permanent:valid forever' \
'noarp:valid, not validated, removed if expired' \
'reachable:valid until reachability timeout' \
@@ -65,7 +65,7 @@ _regex_words nud "Neighbour Unreachability Detection state" \
subcmd_nud=("$reply[@]")
local -a subcmd_rttype
-_regex_words route-type "Route type" \
+_regex_words route-type "route type" \
'unicast:real point-to-point route' \
'unreachable:generate Host Unreachable messages' \
'blackhole:silently discard' \
@@ -85,12 +85,12 @@ local -a subcmd_route
subcmd_route=("(" $subcmd_rttype "|" ")" $subcmd_ipaddr)
local -a subcmd_tos
-_regex_words tos "type of service" \
+_regex_words tos "service type" \
'lowdelay:low latency' \
'throughput:high bulk throughput' \
'reliability:high reliability'
subcmd_tos=("(" "$reply[@]" "|"
- /$'(|0x)[[:xdigit:]]##\0'/ ":hex-number:8-bit hex number:( )" ")")
+ /$'(|0x)[[:xdigit:]]##\0'/ ":hex-numbers:8-bit hex number:( )" ")")
local -a subcmd_lockmtu
subcmd_lockmtu=("(" /$'lock\0'/ ":lock:lock:(lock)" "|" ")" $subcmd_number )
@@ -123,7 +123,7 @@ local -a subcmd_rtrealm subcmd_rtrealms
_regex_words -t / rtrealm 'routing realm' \
'cosmos:everywhere'
subcmd_rtrealms=("(" "$reply[@]" "|" /$'[0-9]##/'/
- ':number:decimal number:( )' ")")
+ ':numbers:decimal number:( )' ")")
_regex_words rtrealm 'routing realm' \
'cosmos:everywhere'
@@ -160,22 +160,46 @@ _regex_words tunnelmode 'tunnel mode' \
'gre:Generic Route Encapsulation - IPv4/IPv6 in IPv4 tunnel'
subcmd_tunnelmode=("$reply[@]")
-local -a subcmd_files
-subcmd_files=(/$'[^\0]##\0'/ ':file:file name:_files')
+local -a subcmd_linktype
+subcmd_linktype=(/$'[^\0]##\0'/ ':link-types:link type:(bridge bond dummy hsr ifb ipoib macvlan macvtap vcan veth vlan vxlan ip6tnl ipip sit gre gretap ip6gre ip6gretap vti nlmon ipvlan lowpan geneve macsec vrf)')
+local -a subcmd_files
+subcmd_files=(/$'[^\0]##\0'/ ':files:file:_files')
#
# The ip top-level commands. First link
#
+
+local -a link_common_cmds
+link_common_cmds=(
+ 'txq*ueuelen:specify length of transmit queue:$subcmd_number' \
+ 'ad*dress:specify unicast link layer (MAC) address:$subcmd_lladdr' \
+ 'br*oadcast:specify broadcast link layer (MAC) address:$subcmd_lladdr' \
+ 'm*tu:specify maximum transmit unit:$subcmd_number'
+)
+local -a link_add_cmds
+_regex_words \
+ link-add-commands 'link add command' $link_common_cmds \
+ 'link:specify device:$subcmd_dev' \
+ 'name:specify name' \
+ 'type:specify type:$subcmd_linktype' \
+ 'numtxqueues:specify number of transmit queues:$subcmd_number' \
+ 'numrxqueues:specify number of receive queues:$subcmd_number' \
+ 'index:specify desired index' \
+ 'group:multicast IP address to join:$subcmd_lladdr'
+link_add_cmds=( "$reply[@]" "#" )
+
local -a link_set_cmds
_regex_words \
- link-set-commands 'link set commands' \
+ link-set-commands 'link set command' \
'dev:specify device:$subcmd_dev' \
'u*p:change state to up' \
'do*wn:change state to down' \
'ar*p:change ARP flag on device:$subcmd_onoff' \
'mu*lticast:change MULTICAST flag on device:$subcmd_onoff' \
+ 'allmulticast:change allmulticast flag on device:$subcmd_onoff' \
'pr*omisc:set promiscuous mode:$subcmd_onoff' \
+ 'protodown:change the PROTODOWN state on the device:$subcmd_onoff' \
'dy*namic:change DYNAMIC flag on device:$subcmd_onoff' \
'n*ame:change name of device:$subcmd_string' \
'txq*ueuelen:specify length of transmit queue:$subcmd_number' \
@@ -189,7 +213,7 @@ _regex_words \
link_set_cmds=("(" $subcmd_dev "|" ")" "$reply[@]" "#" )
local -a link_show_cmds
-_regex_words link-show-commands 'link show commands' \
+_regex_words link-show-commands 'link show command' \
'dev:specify device:$subcmd_dev' \
'up:limit display to running devices'
link_show_cmds=("(" $subcmd_dev "|" ")" "$reply[@]" "#" )
@@ -197,15 +221,16 @@ link_show_cmds=("(" $subcmd_dev "|" ")" "$reply[@]" "#" )
local -a link_cmds
_regex_words \
link-commands "link command" \
+ 'a*dd:add virtual link:$link_add_cmds' \
'h*elp:show help for command' \
'se*t:change device attributes:$link_set_cmds' \
'sh*ow:display device attributes:$link_show_cmds'
link_cmds=("$reply[@]")
-
#
# addr
#
+
local -a addr_add_cmds
# TODO: broadcast can take + or =
_regex_words addr-add-commands "addr add/remove/change/replace commands" \
@@ -214,7 +239,12 @@ _regex_words addr-add-commands "addr add/remove/change/replace commands" \
'p*eer:specify peer IP address (point-to-point):$subcmd_ipaddr' \
'b*roadcast:specify broadcast IP address:$subcmd_ipaddr' \
'la*bel:specify tag for device:$subcmd_string' \
- 's*cope:specify scope for address:$subcmd_scope'
+ 's*cope:specify scope for address:$subcmd_scope' \
+ 'valid_lft:specify valid lifetime of this address' \
+ 'preferred_lft:specify valid lifetime of this address' \
+ 'home:designate this address as the "home address" (IPv6)' \
+ 'mngtmpaddr:manage temporary addresses created from this one as template on behalf of Privacy Extensions'
+
# can complete IP address with no keyword
addr_add_cmds=("(" $subcmd_ipaddr "|" ")" "$reply[@]" "#" )
@@ -225,9 +255,10 @@ local -a addr_show_cmds
# TODO: broadcast can take + or =
_regex_words addr-show-commands "addr show commands" \
'dev:specify device:$subcmd_dev' \
+ 'up:limit display to running devices' \
's*cope:specify scope for address:$subcmd_scope' \
't*o:limit to given IP address/prefix:$subcmd_ipaddr' \
- 'la*bel:list tags matching glob patter:$subcmd_string' \
+ 'la*bel:list tags matching glob pattern:$subcmd_string' \
'dynamic:list addresses from stateless configuration (IPv6)' \
'permanent:list non-dynamic addresses (IPv6)' \
'tentative:list addresses failing duplicate address detection (IPv6)' \
@@ -275,12 +306,13 @@ _regex_words \
'a*dd: add an address labels:$addrlabel_add_cmds' \
'd*el: delete an address labels:$addrlabel_del_cmds' \
'l*ist: list address labels' \
- 'f*lush: flush adderss labels'
+ 'f*lush: flush address labels'
addrlabel_cmds=("$reply[@]")
#
# neigh
#
+
local -a neigh_add_cmds
_regex_words neigh-add-commands "neighbour add command" \
't*o:add new neighbour IP address:$subcmd_ipaddr' \
@@ -320,6 +352,7 @@ neigh_cmds=("$reply[@]")
#
# route
#
+
local -a route_add_cmds
_regex_words route-add-commands "route add/change/replace command" \
'to:route destination prefix:$subcmd_route' \
@@ -392,13 +425,13 @@ _regex_words \
'g*et:get a single network route:$route_get_cmds'
route_cmds=("$reply[@]")
-
#
# rule
#
+
local -a rule_add_cmds
_regex_words rule-add-commands 'ip rule add/delete commands' \
- 'ty*xpe:type of rule:$subcmd_ruletypes' \
+ 'ty*pe:type of rule:$subcmd_ruletypes' \
'fr*om:select source prefix:$subcmd_ipaddr' \
'to:select destination prefix:$subcmd_ipaddr' \
'iif:select input interface (device):$subcmd_dev' \
@@ -422,10 +455,10 @@ _regex_words \
's*how:list routing rules'
rule_cmds=("$reply[@]")
-
#
# tunnel
#
+
local -a tunnel_add_cmds
_regex_words tunnel-add-commands 'tunnel add/change/delete commands' \
'na*me:select tunnel device name:$subcmd_dev' \
@@ -460,10 +493,10 @@ _regex_words \
's*how:list IP tunnels'
tunnel_cmds=("$reply[@]")
-
#
# maddr
#
+
local -a maddr_add_cmds
_regex_words maddr-add-commands "maddr add/delete command" \
'a*ddress:select link layer (MAC) address:$subcmd_lladdr' \
@@ -485,10 +518,10 @@ _regex_words \
's*how:list multicast addresses:$maddr_show_cmds'
maddr_cmds=("$reply[@]")
-
#
# mroute
#
+
local -a mroute_show_cmds
_regex_words mroute-show-commands "mroute show command" \
'to:select destination prefix:$subcmd_ipaddr' \
@@ -503,10 +536,10 @@ _regex_words \
's*how:list multicast routing cache entries:$mroute_show_cmds'
mroute_cmds=("$reply[@]")
-
#
# monitor
#
+
local -a monitor_cmds
_regex_words \
monitor-commands "monitor command" \
@@ -518,7 +551,6 @@ _regex_words \
'file:read rtmon-generated log:$subcmd_files'
monitor_cmds=("$reply[@]")
-
#
# Global argument handling
#
@@ -530,20 +562,18 @@ args=(
/$'[^\0]#\0'/
)
-# TODO:
-# -b*atch <FILENAME>
-# -force (for batch mode)
-# -l*oops <COUNT>
-# -n*etns <NETNS>
-# -rc, -rcvbuf<SIZE>
-_regex_words options "ip options" \
- '-h*uman:output statistics with human readable values' \
+_regex_words options "ip option" \
+ '-V*ersion:display version information' \
+ '-h*uman-readable:output statistics with human readable values' \
+ '-b*atch:read commands from specified file:$subcmd_files' \
+ '-force:do not terminate on errors in batch mode' \
'-i*ec:print human readable rates in IEC units (ie. 1K = 1024)' \
'-s*tatistics:output statistics' \
'-d*etails:output more detailed information' \
'-c*olor:color output' \
'-br*ief:brief output' \
'-a*ll:executes specified command over all objects' \
+ '-l*oops:specify maximum loops ip address flush logic will attempt:$subcmd_number' \
'-f*amily:select protocol family:$subcmd_family' \
'-4:IPv4' \
'-6:IPv6' \
@@ -553,9 +583,19 @@ _regex_words options "ip options" \
'-M:family MPLS' \
'-0:link protocol, no networking' \
'-o*neline:output one record per line' \
+ '-j*son:output results in JSON' \
+ '-p*retty:pretty print JSON' \
+ '-r*esolve:use system resolver for DNS names' \
+ '-n*etns:switch to specified network namespace:$subcmd_string' \
+ '-N*umeric:print numbers instead of converting to text forms' \
+ '-a*ll:execute specified command over all objects' \
+ '-c*olor:use color output' \
'-t*imestamp:display current time when using monitor option' \
- '-ts*hort:display current time in shorter format when using monitor option' \
- '-r*esolve:use system resolver for DNS names'
+ '-ts*hort:like -timestamp, but use shorter format' \
+ '-rc*vbuf:set the netlink socket receive buffer size:$subcmd_number' \
+ '-iec:print human readable rates in IEC units' \
+ '-j*son:output results in JSON format' \
+ '-echo:request the kernel to send applied changes back'
args+=("$reply[@]" "#")
_regex_words \
@@ -566,10 +606,23 @@ _regex_words \
'r*oute:manage routing table:$route_cmds' \
'ru*le:manage routing policy database:$rule_cmds' \
'n*eigh:manage neighbour/ARP tables:$neigh_cmds' \
+ 'nt*able:manage the neighbor cache operation' \
't*unnel:configure tunnel:$tunnel_cmds' \
+ 'net*ns:manage network namespaces' \
+ 'l2*tp:tunnel ethernet over IP (L2TPv3)' \
+ 'f*ou:UDP receive port configuration' \
+ 'mac*sec:MACsec device configuration' \
+ 'tcp_metrics:manage TCP metrics' \
+ 'token:manage tokenized interface identifiers' \
+ 'netc*onf:network configuration monitoring' \
+ ila ioam mptcp nexthop vrf sr stats \
'm*addr:manage multicast addresses:$maddr_cmds' \
'mr*oute:manage multicast routing cache:$mroute_cmds' \
- 'mo*nitor:monitor state:$monitor_cmds'
+ 'mru*le:multicast routing policy database' \
+ 'mo*nitor:monitor state:$monitor_cmds' \
+ 'tunt*ap:manage TUN/TAP devices' \
+ 'x*frm:manage IPSec policies' \
+ 'help'
args+=("$reply[@]")
_regex_arguments _ip "${args[@]}"
diff --git a/Completion/Linux/Command/_ipset b/Completion/Linux/Command/_ipset
index a40480904..1f29c63ec 100644
--- a/Completion/Linux/Command/_ipset
+++ b/Completion/Linux/Command/_ipset
@@ -45,9 +45,9 @@ hash=( '--hashsize[the initial hash size aligned to a power of 2]:hashsize [1024
'--resize[ratio of increasing hash size after unsuccessful <probes> of double-hashing, altering discouraged]:percent'
)
-case $words[offset+2]; in
+case $words[offset+2] in
-N|--create)
- case $words[offset+4]; in
+ case $words[offset+4] in
bitmap\:ip)
args=( $from_to
'--netmask[store network addresses instead of IP addresses]:CIDR'
diff --git a/Completion/Linux/Command/_iptables b/Completion/Linux/Command/_iptables
index 0a901f0f2..2ac13b481 100644
--- a/Completion/Linux/Command/_iptables
+++ b/Completion/Linux/Command/_iptables
@@ -29,7 +29,7 @@ ropts=(
)
prev=( ${words[1,CURRENT-1]} )
-case ${prev[${prev[(I)-p|--proto|--protocol]}+1]}; in
+case ${prev[${prev[(I)-p|--proto|--protocol]}+1]} in
tcp)
args=(
'--tcp-flags[match based on TCP flags in a packet]: :->tcp-flags: :->tcp-flags'
@@ -46,7 +46,7 @@ case ${prev[${prev[(I)-p|--proto|--protocol]}+1]}; in
icmp) args=( '--icmp-type[match specified ICMP type]:*^!:ICMP type:->icmp-types' ) ;;
esac
-case ${prev[${prev[(I)-j|--jump]}+1]}; in
+case ${prev[${prev[(I)-j|--jump]}+1]} in
DNAT) args+=( '(--to --to-destination)'{--to,--to-destination}':address' ) ;;
DSCP)
args+=(
@@ -91,7 +91,7 @@ typeset -U args
while
(( i=words[(ib.i.)-m|--match]+1 ))
(( i<CURRENT )); do
- case ${words[i]}; in
+ case ${words[i]} in
addrtype)
args+=(
'--src-type[match if the source address is of given type]:type:->address-types'
diff --git a/Completion/Unix/Command/_loadkeys b/Completion/Linux/Command/_kbd
index d0a87b6f6..d0a87b6f6 100644
--- a/Completion/Unix/Command/_loadkeys
+++ b/Completion/Linux/Command/_kbd
diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_kmod
index f19784dff..4e87c4767 100644
--- a/Completion/Linux/Command/_modutils
+++ b/Completion/Linux/Command/_kmod
@@ -38,11 +38,15 @@ _modutils() {
)
case "$service" in
- lsmod) _arguments -s "$args[@]" && return ;;
+ lsmod)
+ _arguments -s "$args[@]" \
+ '(-s --syslog)'{-s,--syslog}'[report via syslog instead of stderr]' \
+ '(-v --verbose)'{-v,--verbose}'[enable more messages]' && return
+ ;;
modinfo)
_arguments -s -C "$args[@]" \
- '(-)'{-k+,--set-version=}'[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \
+ '(-)'{-k+,--set-version=}'[use modules from a different kernel version]:kernel_version:compadd $modules_dir/*(/\:t)' \
{-b+,--basedir=}'[use specified directory as filesystem root]:path:_directories' \
'1:module file:->all-modules' \
+ '(field)' \
@@ -59,13 +63,14 @@ _modutils() {
ign='-h --help -V --version -c --showconfig --show-config'
_arguments -s -C "$args[@]" \
"(-a --all $ign)"{-a,--all}'[load all matching modules]' \
- "(-n --show $ign)"{-n,--show}"[don't actually perform action]" \
"(-q --quiet $ign)"{-q,--quiet}"[don't complain about insmod failures]" \
"(-s --syslog $ign)"{-s,--syslog}'[report via syslog instead of stderr]' \
"(-v --verbose $ign)"{-v,--verbose}'[print all commands as executed]' \
'(-C --config)'{-C+,--config=}'[specify config file]:config file:_files' \
"(-r --remove -a --all $ign)"{-r,--remove}'[remove module (stacks)]' \
- '--remove-dependencies[also remove modules depending on it]' \
+ '!--remove-dependencies' \
+ '--remove-holders[also remove module holders]' \
+ '(-w --wait)'{-w+,--wait=}"[wait for module's refcount to become 0 so it can be removed (with -r)]:delay (msecs)" \
'(* -R --resolve-alias)'{-R,--resolve-alias}'[only lookup and print alias and exit]' \
'--first-time[fail if module already inserted or removed]' \
"(-a --all $ign)"{'-i[ignore install/remove commands in config file]','--ignore-install[ignore install commands in config file]','--ignore-remove[ignore remove commands in config file]'} \
@@ -76,8 +81,8 @@ _modutils() {
'(-D --show-depends)'{-D,--show-depends}'[only print module dependencies and exit]' \
'(-)'{-c,--showconfig,--show-config}'[show current configuration]' \
--{show,dump}'-modversions[dump module symbol version and exit]' \
- {-d+,--dirname=}'[use specified directory as filesystem root]:path:_directories' \
- {-S+,--set-version=}'[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \
+ '(-d --dirname)'{-d+,--dirname=}'[use specified directory as filesystem root]:path:_directories' \
+ '(-S --set-version)'{-S+,--set-version=}'[use modules from a different kernel version]:kernel_version:($(echo $modules_dir/*(/\:t)))' \
'--show-exports[only print module exported symbol versions and exit]' \
'(-n --dry-run --show)'{-n,--dry-run,--show}"[don't execute operations, just print]" \
"(-c $ign)1:modules:->loadable-modules" \
@@ -87,17 +92,20 @@ _modutils() {
;;
rmmod)
- _arguments -s -C "$args[@]" \
+ _arguments -s "$args[@]" \
'(-f --force)'{-f,--force}'[allow modules that are in use to be removed]' \
'(-s --syslog)'{-s,--syslog}'[send errors to syslog]' \
'(-v --verbose)'{-v,--verbose}'[be verbose]' \
- '*:loaded module:->loaded-modules' && ret=0
+ '*:loaded module:->loaded-modules' && return
;;
insmod)
- _arguments "$args[@]" \
- '1:module file:_files' \
- '*:module parameters' && ret=0
+ _arguments -s "$args[@]" \
+ '(-f --force)'{-f,--force}'[forces a module load (dangerous)]' \
+ '(-s --syslog)'{-s,--syslog}'[report via syslog instead of stderr]' \
+ '(-v --verbose)'{-v,--verbose}'[enable more messages]' \
+ '1:module file:_files -g "*.ko(|.gz|.xz|.zst)(-.)"' \
+ '*:module option' && return
;;
esac
diff --git a/Completion/Linux/Command/_analyseplugin b/Completion/Linux/Command/_ladspa
index f7f36db50..f7f36db50 100644
--- a/Completion/Linux/Command/_analyseplugin
+++ b/Completion/Linux/Command/_ladspa
diff --git a/Completion/Linux/Command/_losetup b/Completion/Linux/Command/_losetup
index affbc58f3..aab9adbcd 100644
--- a/Completion/Linux/Command/_losetup
+++ b/Completion/Linux/Command/_losetup
@@ -8,7 +8,7 @@ fi
local device offset
-device='1:device:_files -g "/dev/loop<->"'
+device=':device:_files -g "/dev/loop<->"'
offset=( {-o,--offset}'+[specify data start is offset]:offset (bytes)' )
_arguments -s -S \
@@ -28,7 +28,8 @@ _arguments -s -S \
{-c,--set-capacity}'[reread the size of the file associated with the loop device]' \
- 'detach' \
'(-)'{--detach,-d}'[detach from specified loop device]' \
- "$device" \
+ '(-)--remove[remove one or more devices]:device' \
+ "*$device" \
- '(detach-all)' \
{-D,--detach-all}'[detach all associated loop devices]' \
- 'create' \
diff --git a/Completion/Linux/Command/_lsblk b/Completion/Linux/Command/_lsblk
index c8b30eb5e..c2c67c9a6 100644
--- a/Completion/Linux/Command/_lsblk
+++ b/Completion/Linux/Command/_lsblk
@@ -13,16 +13,18 @@ _arguments -C -s -S \
'(H)*--ct-filter=[restrict the next counter]:expression' \
'(H)*--ct=[define a custom counter]:name\:param\:func' \
'(H -a --all)'{-a,--all}'[print all devices]' \
- '(H -b --bytes)'{-b,--bytes}'[print size in bytes rather than in human readable format]' \
+ '(H -b --bytes)'{-b,--bytes}'[print size in bytes instead of a human readable format]' \
'(H -d --nodeps)'{-d,--nodeps}"[don't print slaves or holders]" \
'(H -I --include)*'{-e,--exclude}'[exclude devices by major number]:major device number:->majorlist' \
'(H -e --exclude)*'{-I+,--include=}'[show only devices with specified major numbers]:major device number:->majorlist' \
+ '(H)--hyperlink=-[print paths as hyperlinks]::when:(always never auto)' \
'(H -n --noheadings -y --shell)'{-n,--noheadings}"[don't print headings]" \
'(H -p --paths)'{-p,--paths}'[print complete device path]' \
'(H -s --inverse)'{-s,--inverse}'[reverse dependency order]' \
'(H -w --width)'{-w+,--width=}'[specify output width]:width' \
'(H -x --sort)'{-x+,--sort=}'[sort output by specified column]:column:->columns' \
'(H -y --shell -n --noheadings)'{-y,--shell}'[use column names usable as shell variable identifiers]' \
+ '--properties-by=[specify methods used to gather data]:method [file,udev,blkid]:_sequence compadd - udev blkid file none' \
'(H)--sysroot=[use specified directory as system root]:directory:_directories' \
'*:device:_files -g "*(-%b)" -P / -W /' \
+ fields \
diff --git a/Completion/Linux/Command/_mdadm b/Completion/Linux/Command/_mdadm
index 5b73ef4be..89c3ac036 100644
--- a/Completion/Linux/Command/_mdadm
+++ b/Completion/Linux/Command/_mdadm
@@ -71,14 +71,14 @@ _layouts () {
if (( $+words[(r)-(A|-assemble)] )); then
args=(
'(--bitmap)'--bitmap='[bitmap file to use with the array]::bitmap file:_files'
- '(--uuid -u)'{--uuid=,-u}'[UUID of array to assemble]:UUID'
- '(--super-minor -m)'{--super-minor=,-m}'[minor number to look for in super-block]:minor number'
- '(--name -N)'{--name=,-N}'[array name to look for in super-block]:array name'
- '(--config -c)'{--config=,-c}'[config file]::config file:_files'
+ '(--uuid -u)'{--uuid=,-u+}'[UUID of array to assemble]:UUID'
+ '(--super-minor -m)'{--super-minor=,-m+}'[minor number to look for in super-block]:minor number'
+ '(--name -N)'{--name=,-N+}'[array name to look for in super-block]:array name'
+ '(--config -c)'{--config=,-c+}'[config file]::config file:_files'
'(--scan -s)'{--scan,-s}'[scan config file for missing information]'
'(--run -R)'{--run,-R}'[try to start the array even if not enough devices for a full array are present]'
'(--force -f)'{--force,-f}'[assemble the array even if some superblocks appear out-of-date]'
- '(--update -U)'{--update=,-U}'[update superblock]::update the superblock:(sparc2.2 summaries uuid resync byteorder super-minor)'
+ '(--update -U)'{--update=,-U+}'[update superblock]::update the superblock:(sparc2.2 summaries uuid resync byteorder super-minor)'
)
fi
diff --git a/Completion/Linux/Command/_mondo b/Completion/Linux/Command/_mondo
deleted file mode 100644
index 047a04129..000000000
--- a/Completion/Linux/Command/_mondo
+++ /dev/null
@@ -1,54 +0,0 @@
-#compdef mondoarchive
-
-local curcontext="$curcontext" state line expl ret=1
-typeset -A opt_args
-
-_arguments -C \
- '(-V)-O[create backup]' \
- '(-O)-V[verify backup]' \
- '(-c -C -i -n -w)-c[use CD-R as backup media]:CD-R burn speed' \
- '(-c -C -i -n -w)-C[use CD-R as streaming device (experimental)]:CD-R burn speed' \
- '(-c -C -i -n -w)-i[use ISO image as backup media]' \
- '(-c -C -i -n -w)-n[use NFS mountpoint as backup media]:NFS mountpoint' \
- '(-c -C -i -n -w)-w[use CD-RW as backup media]:CD-RW burn speed' \
- '-D[differential backup]' \
- '-E[exclude path(s) from backup]:paths to exclude from backup:->quoted_path' \
- '-I[path(s) to backup]:paths to include in backup:->quoted_path' \
- '-d[backup device]:backup device' \
- '-g[run in fullscreen mode]' \
- '-k[path to kernel]:path to kernel:->kernel_or_magic' \
- '-m[manual eject]' \
- '-s[media size]:media size]' \
- '-x[non-linux partition]:non-linux partition:_files -g "*(%b)"' \
- '(-1 -2 -3 -4 -5 -6 -7 -8 -9)-'{1,2,3,4,5,6,7,8,9}'[compression level]' \
- '-A[post ISO-creation command]:pre ISO-creation command' \
- '-B[pre iSO-creation command]:post ISO-creation command' \
- '-F[do not create floppy]' \
- '-H[create autorestore image]' \
- '-L[use lzo instead of bzip2]' \
- '-P[post-nuke tarball]:post-nuke tarball:_files -g "*.(#i)(tar.gz|tgz)(-.)"' \
- '-S[scratch directory]:scratch directory:_files -/' \
- '-T[temporary directory]:temporary directory:_files -/' \
- '-f[device with MBR]:device with MBR:_files -g "*(%b)"' \
- '-l[bootloader type]:bootloader type:(GRUB LILO)' && ret=0
-
-case $state in
- quoted_path)
- local suf="/ \t\n"
- [[ -n $compstate[quote] ]] && { suf="$compstate[quote]$suf"; compset -q; }
- _files -r $suf && ret=0
- ;;
- kernel_or_magic)
- _tags kernel magic
- while _tags; do
- _requested magic expl "keyword" \
- compadd -- FAILSAFE && ret=0
- _requested kernel expl "path to kernel image" \
- _files && ret=0
-
- (( ret )) || break
- done
- ;;
-esac
-
-return ret
diff --git a/Completion/Linux/Command/_namei b/Completion/Linux/Command/_namei
new file mode 100644
index 000000000..6f3533eec
--- /dev/null
+++ b/Completion/Linux/Command/_namei
@@ -0,0 +1,15 @@
+#compdef namei
+
+local ign
+
+(( $#words > 2 )) && ign='!(* -)'
+_arguments -s -S \
+ '(-x --mountpoints)'{-x,--mountpoints}"[mark mount point directories with a 'D']" \
+ '(-m --modes -l --long)'{-m,--modes}'[show the permission bits of each file]' \
+ '(-o --owners -l --long)'{-o,--owners}'[show owner and group of each file]' \
+ '(-l --long -m --modes -o --owners -v --vertical)'{-l,--long}'[use long listing format (-m -o -v)]' \
+ '(-n --nosymlinks)'{-n,--nosymlinks}"[don't follow symlinks]" \
+ '(-v --vertical -l --long)'{-v,--vertical}'[align modes and owners vertically]' \
+ "$ign"{-h,--help}'[display usage information]' \
+ "$ign"{-V,--version}'[display version information]' \
+ '*: :_files'
diff --git a/Completion/Linux/Command/_opkg b/Completion/Linux/Command/_opkg
index ddaefe1eb..f726a3e32 100644
--- a/Completion/Linux/Command/_opkg
+++ b/Completion/Linux/Command/_opkg
@@ -181,7 +181,7 @@ _opkg_dest_path() {
_opkg_pkg_all() {
local -a upd copts
- zparseopts -a upd -D -E -update
+ zparseopts -a upd -D -E - -update
copts=( "$@" )
{ (( ! $#_opkg_cache_pkg_all )) || _cache_invalid opkg-pkg-all } &&
@@ -207,7 +207,7 @@ _opkg_pkg_all() {
_opkg_pkg_inst() {
local -a upd copts
- zparseopts -a upd -D -E -update
+ zparseopts -a upd -D -E - -update
copts=( "$@" )
{ (( ! $#_opkg_cache_pkg_inst )) || _cache_invalid opkg-pkg-inst } &&
@@ -233,7 +233,7 @@ _opkg_pkg_inst() {
_opkg_pkg_new() {
local -a upd copts
- zparseopts -a upd -D -E -update
+ zparseopts -a upd -D -E - -update
copts=( "$@" )
{ (( ! $#_opkg_cache_pkg_new )) || _cache_invalid opkg-pkg-new } &&
@@ -257,7 +257,7 @@ _opkg_pkg_new() {
_opkg_pkg_upgr() {
local -a upd copts
- zparseopts -a upd -D -E -update
+ zparseopts -a upd -D -E - -update
copts=( "$@" )
{ (( ! $#_opkg_cache_pkg_upgr )) || _cache_invalid opkg-pkg-upgr } &&
diff --git a/Completion/Linux/Command/_selinux b/Completion/Linux/Command/_selinux
index 22d78db7d..1b2c25468 100644
--- a/Completion/Linux/Command/_selinux
+++ b/Completion/Linux/Command/_selinux
@@ -148,6 +148,7 @@ case $service in
'(-o --output -M --module-package)'{-o+,--output=}'[append output to file]:file:_files'
'(-D --dontaudit)'{-D,--dontaudit}'[generate policy with dontaudit rules]'
'(-R --reference)'{-R,--reference}'[use installed macros in generated policy]'
+ '(-C --cil)'{-C,--cil}'[generate CIL output]'
'!(-R --reference -N --noreference)'{-N,--noreference}
'(-v --verbose)'{-v,--verbose}'[explain generated output]'
'(-e --explain)'{-e,--explain}'[fully explain generated output]'
@@ -196,7 +197,7 @@ case $service in
args+=(
"${ign}(-)"{-V,--version}'[show policy versions created by this program]'
'-m[build a policy module instead of a base module]'
- '-c+[build a policy module targeting a modular policy version]:version (4-21)'
+ '-c+[build a policy module targeting a modular policy version]:version (4-22)'
)
;;
@@ -548,7 +549,7 @@ case $service in
;;
fcontext)
args+=(
- '(-e --equal)'{-e+,--equal=}'[substitute target path with sourcepath when generating default label]:equal'
+ '(-e --equal)'{-e+,--equal=}'[substitute target path with source path when generating default label]:equivalent path:_files'
'(-f --ftype)'{-f+,--ftype=}'[specify file type]:file type:((
f\:regular\ file
d\:directory
diff --git a/Completion/Linux/Command/_ss b/Completion/Linux/Command/_ss
index 2a1cfcb78..ac21c3bcb 100644
--- a/Completion/Linux/Command/_ss
+++ b/Completion/Linux/Command/_ss
@@ -13,23 +13,29 @@ _arguments -C -s \
"($info -r --resolve)"{-r,--resolve}'[resolve host addresses]' \
"($info -a --all -l --listening)"{-a,--all}'[display all sockets]' \
"($info -l --listening -a --all)"{-l,--listening}'[display listening sockets]' \
+ "($info -B --bound-inactive)"{-B,--bound-inactive}'[display TCP bound but inactive sockets]' \
"($info -o --options -e --extended)"{-o,--options}'[show timer information]' \
"($info -e --extended -o --options)"{-e,--extended}'[show detailed information]' \
"($info -m --memory)"{-m,--memory}'[show socket memory usage]' \
"($info -p --processes)"{-p,--processes}'[show process using each socket]' \
+ "($info -T --threads)"{-T,--threads}'[show thread using socket]' \
"($info -i --info)"{-i,--info}'[show internal TCP information]' \
"($info)--tipcinfo[show internal tipc socket information]" \
"($info -s --summary)"{-s,--summary}'[print summary statistics]' \
"($info)--tos[show tos and priority information]" \
+ "($info)--cgroup[show cgroup information]" \
"($info -b --bpf)"{-b,--bpf}'[show bpf filter socket information]' \
+ "($info)--bpf-maps[show all BPF socket-local storage maps]" \
+ "($info)--bpf-map-id=[show a BPF socket-local storage map]:map ID" \
"($info -E --events)"{-E,--events}'[continually display sockets as they are destroyed]' \
- "($info -Z --context)"{-Z,--context}'[display process SELinux security contexts]' \
- "($info -z --contexts)"{-z,--contexts}'[display process and socket SELinux security contexts]' \
+ "($info -Z --context)"{-Z,--context}'[display task SELinux security contexts]' \
+ "($info -z --contexts)"{-z,--contexts}'[display task and socket SELinux security contexts]' \
"($info -N --net)"{-N,--net}'[switch to specified network namespace]:network namespace' \
"($info -4 --ipv4 -6 --ipv6)"{-4,--ipv4}'[display only IP version 4 sockets]' \
"($info -4 --ipv4 -6 --ipv6)"{-6,--ipv6}'[display only IP version 6 sockets]' \
"($info -0 --packet)"{-0,--packet}'[display PACKET sockets]' \
"($info -t --tcp)"{-t,--tcp}'[display TCP sockets]' \
+ "($info -M --mptcp)"{-M,--mptcp}'[display only MPTCP sockets]' \
"($info -S --sctp)"{-S,--sctp}'[display SCTP sockets]' \
"($info -u --udp)"{-u,--udp}'[display UDP sockets]' \
"($info -d --dccp)"{-d,--dccp}'[display DCCP sockets]' \
@@ -41,7 +47,9 @@ _arguments -C -s \
"($info -f --family)"{-f+,--family=}'[display sockets of specified type]:family:(inet inet6 link unix netlink vsock tipc xdp help)' \
"($info -K --kill)"{-K,--kill}'[forcibly close sockets, display what was closed]' \
"($info -H --no-header)"{-H,--no-header}'[suppress header line]' \
+ "($info -Q --no-queues)"{-Q,--no-queues}'[suppress sending and receiving queue columns]' \
"($info -O --oneline)"{-O,--oneline}"[print socket's data on a single line]" \
+ "($info)--inet-sockopt[show various inet socket options]" \
"($info -A --query --socket)"{-A+,--query=,--socket=}'[specify socket tables to show]: :_values -s , socket\ table all inet tcp udp raw unix packet netlink unix_dgram unix_stream unix_seqpacket packet_raw packet_dgram vsock_stream vsock_dgram tipc' \
"($info -D)"{-D+,--diag=}'[dump raw info to file]:file:_files' \
"($info -F)"{-F+,--filter=}'[read filter information from a file]:file:_files' \
diff --git a/Completion/Linux/Command/_strace b/Completion/Linux/Command/_strace
index 37e14b6d6..149a1dddb 100644
--- a/Completion/Linux/Command/_strace
+++ b/Completion/Linux/Command/_strace
@@ -23,9 +23,13 @@ _arguments -C -s \
'(-z -Z --successful-only --failed-only)'{-z,--successful-only}'[trace only system calls that return success]' \
'(-z -Z --successful-only --failed-only)'{-Z,--failed-only}'[trace only system calls that return an error]' \
'(-a --columns)'{-a+,--columns=}'[align return values in a specific column]:column number [40]' \
+ '--color=[control use of color]:color [auto]:(never always auto)' \
'(-i --instruction-pointer -c --summary-only)'{-i,--instruction-pointer}'[print instruction pointer at time of syscall]' \
- '(-c --summary-only -k --stack-traces)'{-k,--stack-traces}'[obtain stack trace between each syscall]' \
+ '(-c --summary-only)*-k[obtain stack trace between each syscall]' \
+ '(-c --summary-only -k)--stack-trace=-[obtain stack trace between each syscall]::symbol' \
+ '(-c --summary-only)--stack-trace-frame-limit=[specify limit on stack trace frames to print]:frames [256]' \
'(-n --syscall-number)'{-n,--syscall-number}'[print syscall number]' \
+ '(-N --arg-names)'{-N,--arg-names}'[print syscall argument names]' \
'(-o --output)'{-o+,--output=}'[send trace output to the specified file]:output file:->file-pipe' \
'(-A --output-append-mode)'{-A,--output-append-mode}'[open the file provided with the -o option in append mode]' \
'--output-separately[output to separate files for child processes (by appending pid to file names)]' \
@@ -51,11 +55,12 @@ _arguments -C -s \
'(-X --const-print-style)'{-X+,--const-print-style=}'[set the format for printing of named constants and flags]:format:(raw abbrev verbose)' \
'(-c --summary-only -yy --decode-fds)-y[print paths associated with file descriptor arguments]' \
'(-c --summary-only -y --decode-fds)-yy[print protocol specific information associated with socket file descriptors]' \
- '(-c --summary-only -y -yy)--decode-fds=-[print information associated with file descriptors]::information [none]:_sequence compadd - none all path socket dev pidfd signalfd' \
+ '(-c --summary-only -y -yy)--decode-fds=-[print information associated with file descriptors]::information [none]:_sequence compadd - none all path socket dev eventfd pidfd signalfd' \
'(-c --summary-only -Y)--decode-pids=[print information associated with process IDs]:information [none]:_sequence compadd - none comm pidns' \
'!(-c --summary-only -Y --decode-pids)--pidns-translation' \
'(-c --summary-only --decode-pids)-Y[print command names for PIDs]' \
- '(-c --summary-only -C --summary -i --instruction-pointer -k --stack-traces -r --relative-timestamps -ff -t -tt -ttt --absolute-timestamps -T --syscall-times -y -yy --decode-fds)'{-c,--summary-only}'[count time, calls, and errors for each system call and report a summary]' \
+ '--always-show-pid' \
+ '(-c --summary-only -C --summary -i --instruction-pointer -k --stack-trace --stack-trace-frame-limit -r --relative-timestamps -ff -t -tt -ttt --absolute-timestamps -T --syscall-times -y -yy --decode-fds)'{-c,--summary-only}'[count time, calls, and errors for each system call and report a summary]' \
'(-c --summary-only -C --summary)'{-C,--summary}'[count time, calls, and errors for each system call and report a summary in addition to regular output]' \
'(-O --summary-syscall-overhead)'{-O+,--summary-syscall-overhead=}'[specify overhead for tracing system calls]:overhead (microseconds)' \
'(-S --summary-sort-by)'{-S+,--summary-sort-by=}'[sort the output of the histogram (-c option) by the specified criterion]:sort criterion [time]:(time min-time max-time avg-time calls errors name nothing)' \
@@ -66,6 +71,11 @@ _arguments -C -s \
'(-d --debug)'{-d,--debug}'[show debug output of strace itself on standard error]' \
'(- 1 *)'{-h,--help}'[display help information]' \
'--seccomp-bpf[enable seccomp-bpf filtering]' \
+ '--secontext=[print SELinux contexts]: : _values -s, format
+ "(none mismatch full)all[equivalent to full,mismatch]"
+ "(all none)full[print the full context instead of the type only]"
+ "(all none)mismatch[print expected context when actual is not matching]"
+ "(all none mismatch full)none[equivalent to not specifying the option at all]"' \
'--tips=-[show strace tips, tricks, and tweaks before exit]:tip [id\:random,format\:compact]' \
'(- 1 *)'{-V,--version}'[display version information]' \
'(-):command name: _command_names -e' \
@@ -87,7 +97,9 @@ case $state in
'status[trace system calls with given return status]:status:->status' \
'quiet[suppress various information messages]:message [none]:_sequence compadd - none attach exit path-resolution personality thread-execve superseded' \
'kvm[print the exit reason of kvm vcpu]: :(vcpu)' \
- 'decode-fds[print information associated with file descriptors]:information [none]:_sequence compadd - none all path socket dev pidfd signalfd' \
+ 'namespace=new[print namespace IDs that the tracee enters]' \
+ 'decode-fds[print information associated with file descriptors]:information [none]:_sequence compadd - none all path socket dev eventfd pidfd signalfd' \
+ 'secontext' \
'decode-pids[print information associated with process IDs]:information [none]:_sequence compadd - none comm pidns' && ret=0
if [[ $state = status ]]; then
_values -s , 'return status [all]' \
diff --git a/Completion/Linux/Command/_tracepath b/Completion/Linux/Command/_tracepath
index f0f777d96..68a3d6ee6 100644
--- a/Completion/Linux/Command/_tracepath
+++ b/Completion/Linux/Command/_tracepath
@@ -1,9 +1,12 @@
#compdef tracepath tracepath6
_arguments -s -S \
+ '(-6)-4[use IPv4]' \
+ '(-4)-6[use IPv6]' \
'-n[print IP addresses numerically]' \
'-b[print both host names and IP addresses]' \
'-l+[set the initial packet length]:length (bytes)' \
'-m+[set maximum hops]:maximum [30]' \
'-p+[set initial destination port to use]:port:_ports' \
+ '-V[display version information]' \
':destination:_hosts'
diff --git a/Completion/Linux/Command/_valgrind b/Completion/Linux/Command/_valgrind
index 6bf0e4450..638b29cf5 100644
--- a/Completion/Linux/Command/_valgrind
+++ b/Completion/Linux/Command/_valgrind
@@ -2,7 +2,7 @@
local curcontext="$curcontext" state line
local -a cmd common_{own_malloc,read_varinfo,report_errors,partial}
-local -a args args_{addrcheck,drd,memcheck,cachegrind,helgrind,lackey,massif,none,exp_{bbv,dhat,sgcheck}}
+local -a args args_{{addr,mem}check,drd,{cache,call,hel}grind,lackey,massif,none,exp_{bbv,dhat,sgcheck}}
cmd=(
'1: : _command_names -e'
@@ -20,7 +20,7 @@ common_own_malloc=(
'--alignment=-[set minimum alignment of heap allocations]:number [16]'
'--redzone-size=-[set minimum size of redzones added before/after heap blocks]:size (bytes) [16]'
'--xtree-memory=-[profile heap memory in an xtree [none]:(none allocs full)'
- '--xtree-memory-file=-[specify xtree memory report file]:file [xtmemory.kcg.%%p]:_files'
+ '--xtree-memory-file=-[specify xtree memory report file]:file [xtmemory.kcg.%p]:_files'
)
common_read_varinfo=(
@@ -67,7 +67,7 @@ args_addrcheck=(
'(--show-leak-kinds)--show-reachable=-[show reachable blocks in leak check]:enable:(yes no)'
'(--show-leak-kinds)--show-possibly-lost=-:enable:(yes no)'
'--xtree-leak=-[output leak result in xtree format]:enable [no]:(yes no)'
- '--xtree-leak-file=-[specify xtree leak report file]:file [xtleak.kcg.%%p]:_files'
+ '--xtree-leak-file=-[specify xtree leak report file]:file [xtleak.kcg.%p]:_files'
'--undef-value-errors=-[check for undefined value errors]:enable [yes]:(yes no)'
'--track-origins=-[show origins of undefined values]:enable [no]:(yes no)'
$common_partial
@@ -124,7 +124,39 @@ args_cachegrind=(
'--LL=-[set LL cache manually]:size,assoc,line_size'
'--cache-sim=-[collect cache stats]:enable [yes]:(yes no)'
'--branch-sim=-[collect branch prediction stats]:enable [no]:(yes no)'
- '--cachegrind-out-file=-[specify output file name]:file name [cachegrind.out.%%p]:_files'
+ '--cachegrind-out-file=-[specify output file name]:file name [cachegrind.out.%p]:_files'
+)
+
+args_callgrind=(
+ '--callgrind-out-file=-[specify output file name]:file name [callgrind.out.%p]:_files'
+ '--dump-line=-[perform event counting at source line granularity]:enable [yes]:(yes no)'
+ '--dump-instr=-[perform event counting at instruction granularity]:enable [no]:(yes no)'
+ '--compress-strings=-[identify file and function names by numbers]:enable [yes]:(yes no)'
+ '--compress-pos=-[compress positions in profile dump]:enable [yes]:(yes no)'
+ '--compress-dumps=-[concatenate all dumps into same file]:enable [no]:(yes no)'
+ '--dump-every-bb=-[specify dump period in basic blocks]:blocks [0, never]'
+ '*--dump-before=-[dump when entering specified function]:function'
+ '*--zero-before=-[zero all costs when entering specified function]:function'
+ '*--dump-after=-[dump when leaving specified function]:function'
+ '--instr-atstart=-[do instrumentation at callgrind start]:enable [yes]:(yes no)'
+ '--collect-atstart=-[collect at process/thread start]:enable [yes]:(yes no)'
+ '*--toggle-collect=-[toggle collection on enter/leave specified function]:function'
+ '--collect-jumps=-[collect jumps]:enable [no]:(yes no)'
+ '--collect-bus=-[collect global bus events]:enable [no]:(yes no)'
+ '--collect-systime=-[collect system call time info]:enable [no]:(no yes msec usec nsec)'
+ '--separate-threads=-[separate data per thread]:enable [no]:(yes no)'
+ '--separate-callers=-[separate functions by call chain length]:length [0]'
+ '--separate-recs=-[separate function recursions up to level]:level [2]'
+ '--skip-plt=-[ignore calls to/from PLT sections]:enable [yes]:(yes no)'
+ '--skip-direct-rec=-[ignore direct recursio]:enable [yes]:(yes no)'
+ '*--fn-skip=-[ignore calls to/from specified function]:function'
+ '--branch-sim=-[collect branch prediction stats]:enable [no]:(yes no)'
+ '--cache-sim=-[collect cache stats]:enable [no]:(yes no)'
+ '--simulate-wb=-[count write-back events]:enable [no]:(yes no)'
+ '--simulate-hwpref=-[simulate hardware prefetch]:enable [no]:(yes no)'
+ '--cacheuse=-[collect cache block use]:enable [no]:(yes no)'
+ '--I1=-[set I1 cache manually]:size,assoc,line_size'
+ '--D1=-[set D1 cache manually]:size,assoc,line_size'
)
args_helgrind=(
@@ -170,7 +202,7 @@ args_massif=(
))"
'--detailed-freq=-[every Nth snapshot should be detailed]:snapshot interval [10]'
'--max-snapshots=-[specofy maximum number of snapshots recorded]:maximum [100]'
- '--massif-out-file=-[specify output file name]:filename [massif.out.%%p]:_files'
+ '--massif-out-file=-[specify output file name]:filename [massif.out.%p]:_files'
)
args_exp_bbv=(
@@ -217,7 +249,8 @@ _arguments -C ${(P)args} $cmd \
'--vgdb=-[activate gdbserver]:enable [yes]:(yes no full)' \
'--vgdb-error=-[invoke gdbserver after specified number of errors]:errors [999999999]:errors' \
'--vgdb-stop-at=-[invoke gdbserver for given events]:event:_sequence compadd - startup exit abexit valgrindabexit all none' \
- '--track-fds=-[track open file descriptors]:enable [no]:(yes no all)' \
+ '--track-fds=-[track open file descriptors]:enable [no]:(yes no all bad)' \
+ '--modify-fds=-[modify newly open file descriptors]:enable:(yes no high)' \
'--time-stamp=-[add timestamps to log messages]:enable:(yes no)' \
'--log-fd=-[log messages to specified file descriptor]:file descriptor:_file_descriptors' \
'--log-file=-[log messages to specified file with pid appended]:file:_files' \
diff --git a/Completion/Mandriva/Command/_rebootin b/Completion/Mandriva/Command/_rebootin
deleted file mode 100644
index 284ff08f1..000000000
--- a/Completion/Mandriva/Command/_rebootin
+++ /dev/null
@@ -1,29 +0,0 @@
-#compdef rebootin
-
-local context state line expl
-typeset -A opt_args
-local loader=${$(_call_program -p entries detectloader -q):-GRUB}
-
-_arguments -s \
- '-n[no immediate reboot just set the flags for next reboot]' \
- '-f[create a /fastboot file to reboot in fastboot mode]' \
- '*::arguments:->loader_entry'
-
-case $state in
- loader_entry)
- case $loader in
- GRUB)
- if [ -r /boot/grub/menu.lst ]; then
- _wanted -C $context entries expl entry \
- compadd ${${(M)${(f)"$(</boot/grub/menu.lst)"}##title *}#title }
- fi
- ;;
- LILO)
- if [ -r /etc/lilo.conf ]; then
- _wanted -C $context entries expl entry \
- compadd $(awk -F= '{ if ($0 ~ /label=/) print $2 }' /etc/lilo.conf)
- fi
- ;;
- esac
- ;;
-esac
diff --git a/Completion/Solaris/Command/_ipadm b/Completion/Solaris/Command/_ipadm
index c59fc8108..c3ddd26ec 100644
--- a/Completion/Solaris/Command/_ipadm
+++ b/Completion/Solaris/Command/_ipadm
@@ -274,7 +274,7 @@ _ipadm() {
("dhcp:"*)
_arguments -A "-*" \
- '(-w --wait)'{-w,--wait}'[Seconds to wait for completion]:number or "forever":{if [[ -prefix [0-9]## ]]; then _message -e "number of seconds"; else _wanted forever expl "number or \"forever\"" compadd forever; fi}' \
+ '(-w --wait)'{-w,--wait}'[time to wait for completion]:time (seconds):_phony forever' \
'-h[Request a specific hostname]:hostname:' \
':address object name:_ipadm_addrobjs_or_ifs'
;;
diff --git a/Completion/Unix/Command/_pkgadd b/Completion/Solaris/Command/_pkgadd
index 7adc18a2a..09e6a06d0 100644
--- a/Completion/Unix/Command/_pkgadd
+++ b/Completion/Solaris/Command/_pkgadd
@@ -23,10 +23,10 @@ _pkgadd() {
'-R[root path]:root path:_files -/' \
'-r[response file]:response file:_files' \
'-V[alternate vfstab file]:vfstab file:_files' \
- '*:package instance:_pkg_instance --_opts uninstalled:-d' \
+ '*:package instance:_pkg_instances --_opts uninstalled:-d' \
- set2 \
'-s[spool package]:spool directory:_files -/' \
- '*:package instance:_pkg_instance --_opts uninstalled:-d'
+ '*:package instance:_pkg_instances --_opts uninstalled:-d'
}
_pkgadd "$@"
diff --git a/Completion/Unix/Command/_pkginfo b/Completion/Solaris/Command/_pkginfo
index eca9e057e..26a5a866b 100644
--- a/Completion/Unix/Command/_pkginfo
+++ b/Completion/Solaris/Command/_pkginfo
@@ -12,7 +12,7 @@ _arguments -s \
'(-p)-i[select completely installed packages]' \
'(-i)-p[select partially installed packages]' \
'-R[root path]:root path:_files -/' \
- '*:package instance:_pkg_instance --_opts installed:set1--R' \
+ '*:package instance:_pkg_instances --_opts installed:set1--R' \
- set2 \
'-d[device]:device file:_files' \
- '*:package instance:_pkg_instance --_opts uninstalled:set2--d'
+ '*:package instance:_pkg_instances --_opts uninstalled:set2--d'
diff --git a/Completion/Unix/Command/_pkgrm b/Completion/Solaris/Command/_pkgrm
index 1191a2d1f..19fbc4409 100644
--- a/Completion/Unix/Command/_pkgrm
+++ b/Completion/Solaris/Command/_pkgrm
@@ -10,7 +10,7 @@ _arguments -s \
"-M[don't use vfstab file]" \
'-R[root path]:root path:_files -/' \
'-V[alternate vfstab file]:vfstab file:_files' \
- '*:package instance:_pkg_instance --_opts installed:set1--R' \
+ '*:package instance:_pkg_instances --_opts installed:set1--R' \
- set2 \
'-s[spool package]:spool directory:_files -/' \
- '*:package instance:_pkg_instance --_opts spooled:set2--s'
+ '*:package instance:_pkg_instances --_opts spooled:set2--s'
diff --git a/Completion/Unix/Command/_pkg_instance b/Completion/Solaris/Type/_pkg_instances
index 3f4c49219..3f4c49219 100644
--- a/Completion/Unix/Command/_pkg_instance
+++ b/Completion/Solaris/Type/_pkg_instances
diff --git a/Completion/Unix/Command/_7zip b/Completion/Unix/Command/_7zip
new file mode 100644
index 000000000..6867d353c
--- /dev/null
+++ b/Completion/Unix/Command/_7zip
@@ -0,0 +1,209 @@
+#compdef 7z 7za 7zr 7zz
+
+# this covers both the official 7-zip and the now deprecated p7zip (but not the
+# p7zip command, which is a gzip-like wrapper)
+#
+# notes:
+# - seemingly all 7zip commands, options, and option arguments are
+# case-insensitive. we only partially support this
+# - most options only work with certain commands. the html documentation lists
+# which ones, but it was so consistently wrong or contradictory that i gave up
+# on trying to separate them. do not blindly trust the documentation on this
+
+local ret=1
+local -a context line state state_descr args
+local -A opt_args
+
+args=(
+ '*-ai-[specify archives to include]: :->file-refs'
+ "(2)-an[don't take archive name on command line (with -ai)]"
+ '-ao-[specify overwrite mode]:overwrite mode:((
+ a\:"overwrite existing files without prompt"
+ s\:"skip extracting files that already exist"
+ t\:"auto-rename existing files"
+ u\:"auto-rename extracting files"
+ ))'
+ '*-ax-[specify archives to exclude]: :->file-refs'
+ '-bb-[specify output log level]::log level:((
+ 0\:"disable log"
+ 1\:"show names of processed files"
+ 2\:"show names of additional files processed internally"
+ 3\:"show information about additional operations"
+ ))'
+ '-bd[disable progress indicator]'
+ '*-bs-[specify output stream]: :->output-streams'
+ '-bt[show execution time statistics]'
+ '*-i-[specify files to include]: :->file-refs'
+ '*-m-[specify compression method parameter]:method parameter' # @todo complete these
+ '-o-[specify output directory]:output directory:_files -/'
+ '-p-[specify password]:password'
+ "-r-[recurse into subdirectories (or specify)]::recursion method:((
+ -\:\"don't recurse into subdirectories\"
+ 0\:'recurse into subdirectories only for wildcard names'
+ ))"
+ '-sa-[specify archive naming mode]:archive naming mode:((
+ a\:"always add archive type extension"
+ e\:"use file name exactly as given"
+ s\:"add archive type extension only if file name has no extension"
+ ))'
+ '-scc-[specify charset for console input/output]: :->charsets-io'
+ '-scrc-[specify hash function]: :->hash-functions'
+ '-scs-[specify charset for list files]: :->charsets-listfile'
+ '-sdel[delete files after adding to archive]'
+ '-seml-[send archive by e-mail (specify behaviour)]::e-mail behaviour:((
+ .\:"delete archive after attaching to e-mail"
+ ))'
+ '-sfx-[create SFX archive]:: :->sfx-modules'
+ '-si-[compress data from stdin (specify file name)]::file name in archive:_files'
+ '-slt[show technical information]'
+ '-snc[extract as alternate stream if : in file name]'
+ '-snh[store hard links as links (tar and WIM only)]'
+ '-sni[store NTFS security information (WIM only)]'
+ '-snl[store symbolic links as links (tar and WIM only)]'
+ "-sns-[store NTFS alternate streams (or specify) (WIM only)]::alternate-streams behaviour:((
+ -\:\"don't store NTFS alternate streams\"
+ ))"
+ "-snt-[replace trailing dots and spaces in file names (or specify)]::trailing-character behaviour:((
+ -\:\"don't replace trailing dots and spaces in file names\"
+ ))"
+ '-so[write data to stdout]'
+ '-spd[disable wildcard matching for file names]'
+ '-spe[eliminate duplication of root folder]'
+ '-spf-[use fully qualified (absolute) file paths (or specify)]::absolute-file-path behaviour::((
+ 2\:"use full path without leading slash or drive letter"
+ ))'
+ '-ssc-[enable case-sensitive mode (or specify)]::case-sensitive mode:((
+ -\:"disable case-sensitive mode"
+ ))'
+ '-sse[stop archive creation if unable to open input file]'
+ "-ssp[don't change access time of source files]"
+ '-ssw[compress files open for writing by other programs]'
+ '-stl[set archive time stamp from most recently modified file]'
+ '-stm-[specify CPU thread affinity mask]:affinity mask (hexadecimal)'
+ '-stx-[exclude specified archive type]: :->archive-types'
+ '-t-[specify archive type]: :->archive-types'
+ '-u-[specify update options]:update options' # @todo complete these
+ '-v-[create volume of specified size]: :_numbers -u bytes "volume size" b k m g'
+ '-w-[use temporary work directory (or specify)]::work directory:_files -/'
+ '*-x-[specify files to exclude]: :->file-refs'
+ '-y[assume yes to all queries]'
+ '1:command:((
+ a\:"add files to archive"
+ b\:"benchmark"
+ d\:"delete files from archive"
+ e\:"extract files from archive (without full paths)"
+ h\:"calculate hash values for files"
+ i\:"show information about supported formats"
+ l\:"list contents of archive"
+ rn\:"rename files in archive"
+ t\:"test integrity of archive"
+ u\:"update files in archive"
+ x\:"extract files (with full paths)"
+ ))'
+ '(-an)2:archive file:_files'
+ '*: :_files' # @todo complete more specifically, handle list files
+)
+
+_arguments -S : $args && ret=0
+
+case $state in
+ archive-types)
+ local -a formats=( "${(@f)"$( _call_program 7z-info $words[1] i )"}" )
+ formats=( "${(@)formats[(r)*Formats:*,-1]}" )
+ formats=( ${formats[2,(r)]} )
+
+ # 'C' appears in fourth column if compression is supported
+ [[ ${(L)words[(rn:2:)^-*]} == (a|d|rn|u) ]] &&
+ formats=( ${(M)formats:#???C*} )
+
+ # new (?) format
+ if [[ -n ${(M)formats:#*....*} ]]; then
+ formats=( ${formats/#?(#c28)/} )
+ # old/p7zip format
+ else
+ formats=( ${formats/#?(#c17)/} )
+ fi
+ formats=( ${formats%%[[:space:]]*} )
+
+ (( $#formats )) || formats=( 7z bzip2 gzip tar xz zip )
+ formats=( ${formats//:/\\:} )
+
+ # @todo also complete the various -t* and -t# modes
+ _describe \
+ -t formats \
+ 'archive type' \
+ formats \
+ -M 'm:{a-z}={A-Z}' \
+ && ret=0
+ ;;
+
+ charsets-io)
+ _describe \
+ -t charsets \
+ 'character set' \
+ '( UTF-8 WIN DOS )' \
+ -M 'm:{a-z}={A-Z}' \
+ && ret=0
+ ;;
+
+ charsets-listfile)
+ _describe \
+ -t charsets \
+ 'character set (or Windows code-page number)' \
+ '( UTF-8 UTF-16LE UTF-16BE WIN DOS )' \
+ -M 'm:{a-z}={A-Z}' \
+ && ret=0
+ ;;
+
+ file-refs)
+ # @todo complete this properly
+ if compset -P 1 '*[@!]'; then
+ _files && ret=0
+ else
+ _describe -t file-refs 'file-ref type' '(
+ "@:list file"
+ "!:file name or wildcard"
+ )' && ret=0
+ fi
+ ;;
+
+ hash-functions)
+ local -a hashers=( "${(@f)"$( _call_program 7z-info $words[1] i )"}" )
+ hashers=( "${(@)hashers[(r)*Hashers:*,-1]}" )
+ hashers=( ${hashers[2,(r)]} )
+ hashers=( ${hashers##*[[:space:]]} )
+ (( $#hashers )) || hashers=( CRC32 CRC64 SHA1 SHA256 BLAKE2sp )
+ hashers+=( \* )
+ hashers=( ${hashers//:/\\:} )
+ _describe -t hashers 'hash function' hashers -M 'm:{a-z}={A-Z}' && ret=0
+ ;;
+
+ output-streams)
+ if compset -P '?'; then
+ _describe -t stream-dests 'output stream destination' '(
+ 0:disabled
+ 1:stdout
+ 2:stderr
+ )' && ret=0
+ else
+ _describe -t stream-types 'output stream type' '(
+ "e:error messages"
+ "o:standard output messages"
+ "p:progress information"
+ )' && ret=0
+ fi
+ ;;
+
+ sfx-modules)
+ # sfx modules should be in the same directory as the 7zip executable. on
+ # some systems they live in some lib directory so we look there too
+ local -aU sfxes=(
+ ${${(Q)words[1]}:c:h}/*.sfx(#q.N:t)
+ ${${(Q)words[1]}:c:P:h}/*.sfx(#q.N:t)
+ {,/opt,/usr}{,/local}/lib/7zip/*.sfx(#q.N:t)
+ )
+ _describe -t sfx-modules 'SFX modules' sfxes && ret=0
+ ;;
+esac
+
+return ret
diff --git a/Completion/Unix/Command/_aap b/Completion/Unix/Command/_aap
deleted file mode 100644
index 38e50f1fc..000000000
--- a/Completion/Unix/Command/_aap
+++ /dev/null
@@ -1,50 +0,0 @@
-#compdef aap
-
-# A-A-P recipe executive version 1.076; released 2005 May 30 12:47:03 GMT
-
-local curcontext="$curcontext" state line ret=1
-typeset -A opt_args
-
-_arguments -C -s -S \
- '(- *)'{-V,--version}'[print version information and exit]' \
- '(- *)'{-h,--help}'[print help information and exit]' \
- '(-s --silent -v --verbose)'{-v,--verbose}'[print more information]' \
- '(-v --verbose -s --silent)'{-s,--silent}'[print less information]' \
- '(-d --debug)'{-d,--debug=}'[debug the specified items]:flags:' \
- '--profile=[profile A-A-P execution and write results in specified file]:output file:_files' \
- '(-n --nobuild)'{-n,--nobuild}'[print the build commands but do not execute them]' \
- '--changed=[consider specified file changed]:changed file:_files' \
- '(-t --touch)'{-t,--touch}'[update target signatures, do not build]' \
- '(-F --force)'{-F,--force}'[force rebuilding]' \
- '(-C --contents)'{-C,--contents}'[only build when file contents changed]' \
- \*{-c,--command=}'[execute a command after reading the recipe]:aap command:' \
- '(-k --continue)'{-k,--continue}'[continue building after an error]' \
- '(-S --stop)'{-S,--stop}'[stop building at first error (default)]' \
- '(-N --nofetch-recipe -R --fetch-recipe)'{-R,--fetch-recipe}'[fetch recipe file and child recipes]' \
- '(-R --fetch-recipe -N --nofetch-recipe)'{-N,--nofetch-recipe}'[do not fetch recipes for "fetch" target]' \
- '(-a --nocache)'{-a,--nocache}"[always download files, don't use the cache]" \
- '(-l --local)'{-l,--local}'[do not recurse into subdirectories]' \
- '(-j --jobs)'{-j,--jobs=}'[maximum number of parallel jobs]:number of jobs:' \
- '(-f --recipe -u --search-up --up)'{-u,--search-up,--up}'[search directory tree upwards for main.aap recipe]' \
- \*{-I,--include=}'[directory to search for included recipes]:include directory:_files -/' \
- '(-u --search-up --up -f --recipe)'{-f,--recipe=}'[recipe file to be executed]:recipe file:_files -g \*.aap\(-.\)' \
- '--install=[install specified package]:package name:' \
- '--[end of options, targets and assignments follow]' \
- '*:aap target:->target' && ret=0
-
-if [[ "$state" = target ]]; then
- local targets recipe
- if [[ -n $opt_args[(I)(-u|--search-up|--up)] ]]; then
- recipe=( (../)#main.aap(N[-1]) )
- else
- recipe=${(v)opt_args[(I)(-f|--recipe)]:-main.aap}
- fi
- if [[ -f $recipe ]]; then
- targets=( ${${(f)"$(_call_program targets $words[1] -f $recipe comment 2>/dev/null)"}/(#b)target (*):[[:blank:]]##(*)/$match[1]:${match[2]:l}} comment )
- _describe -t targets 'aap target' targets && ret=0
- else
- _message -e targets 'aap target'
- fi
-fi
-
-return ret
diff --git a/Completion/Unix/Command/_abcde b/Completion/Unix/Command/_abcde
index 6b09d87b5..be18d7f05 100644
--- a/Completion/Unix/Command/_abcde
+++ b/Completion/Unix/Command/_abcde
@@ -34,7 +34,7 @@ _arguments -s -S -A "-*" \
'(- :)-v[show the version and exit]' \
'-V[be more verbose]' \
'-x[eject the CD when all tracks have been read]' \
- '-X+[use an alternative "cue2discid" implementation]:cue2discid:_command_names -e' \
+ '-X+[use an alternative "cue2discid" implementation]:cue2discid:_phony builtin _command_names -e' \
'-w+[add a comment to the tracks ripped from the CD]:comment' \
"-W+[concatenate CD's]:cd-number" \
'-z[debug mode]' \
diff --git a/Completion/Unix/Command/_age b/Completion/Unix/Command/_age
new file mode 100644
index 000000000..487933d92
--- /dev/null
+++ b/Completion/Unix/Command/_age
@@ -0,0 +1,24 @@
+#compdef age age-keygen
+
+case $service in
+ age)
+ _arguments -S -A '-?*' \
+ '(- :)'{-h,--help}'[display usage information]' \
+ '!(-d --decrypt)'{-e,--encrypt} \
+ '(-e --encrypt -d --decrypt -a --armor -p --passphrase -r --recipient -R --recipients-file)'{-d,--decrypt}'[decrypt the input to the output]' \
+ '(-o --output)'{-o,--output=}'[write result to given file]:output file:_files' \
+ '(-a --armor -d --decrypt)'{-a,--armor}'[encrypt to PEM encoded format]' \
+ '(-p --passphrase -d --decrypt)'{-p,--passphrase}'[encrypt with passphrase]' \
+ '(-d --decrypt)'\*{-r,--recipient=}'[encrypt to specified recipient]:recipient' \
+ '(-d --decrypt)'\*{-R,--recipients-file=}'[encrypt to recipients listed in specified file]:recipients file:_files' \
+ \*{-i,--identity=}'[use given identify file]:identity:_files' \
+ ':input:_files'
+ ;;
+ age-keygen)
+ _arguments -S -A '-?*' \
+ '-pq[generate post-quantum hybrid ML-KEM-768 + X25519 key pair]' \
+ '(-o --output)'{-o,--output}'[write the result to the given file]:file:_files' \
+ '-y[convert an identity file to a recipients file]' \
+ ':input:_files'
+ ;;
+esac
diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible
index ab0cdee6c..d87bf49c2 100644
--- a/Completion/Unix/Command/_ansible
+++ b/Completion/Unix/Command/_ansible
@@ -50,11 +50,12 @@ case $service in
args+=(
'(-J --ask-vault-pass --ask-vault-password)'{-J,--ask-vault-pass{,word}}'[ask for vault password]'
\*{-e+,--extra-vars=}'[set additional variables]:key=value, YAML/JSON or @file:->extra-vars'
+ '--flush-cache[clear fact cache for every host in inventory]'
'*--vault-id=[specify vault identity to use]:vault identity'
--vault-pass{,word}-file='[specify vault password file]:vault password file:_files'
\*{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files"
"hosts\:host\: _sequence _hosts"'
- '!(-i --inventory)--inventory-file=:inventory file:_files'
+ '!*--inventory-file=:inventory file:_files'
'(-l --limit --host --graph)'{-l+,--limit=}'[further limit hosts to an additional pattern]:host subset:->hosts'
)
;|
@@ -65,8 +66,8 @@ case $service in
;|
ansible-playbook|ansible-pull)
args+=(
- \*{-t,--tags}'[only run plays and tasks tagged with these values]:tag:->tags'
- "*--skip-tags[only run plays and tasks whose tags don't match]"
+ \*{-t,--tags=}'[only run plays and tasks tagged with these values]:tag:->tags'
+ "*--skip-tags=[only run plays and tasks whose tags don't match]:tag:->tags"
)
;|
ansible-playbook|ansible-console)
@@ -142,7 +143,6 @@ case $service in
;;
ansible-playbook)
args+=(
- '--flush-cache[clear the fact cache for every host in inventory]'
'--force-handlers[run handlers even if a task fails]'
'--list-tags[list all available tags]'
'--list-tasks[list all tasks that would be executed]'
@@ -207,10 +207,15 @@ case $state in
else
local -a inventory
typeset -ga _ansible_hosts _ansible_groups
+ typeset -g _ansible_inventory_last_cwd
+ if [[ $PWD != $_ansible_inventory_last_cwd ]]; then
+ unset _ansible_hosts _ansible_groups
+ fi
if (( !$#_ansible_hosts || !$#_ansible_groups )); then
inventory=( ${(f)"$(_call_program groups ansible-inventory --graph)"} )
_ansible_hosts=( ${${(M)inventory%--[^:]#}#--} )
_ansible_groups=( ${${${(M)inventory%@*:}%:}#@} )
+ _ansible_inventory_last_cwd=$PWD
fi
if [[ $state = hosts ]]; then
suf=( -qS: )
diff --git a/Completion/Unix/Command/_attr b/Completion/Unix/Command/_attr
index efa7c5c4f..208c46db6 100644
--- a/Completion/Unix/Command/_attr
+++ b/Completion/Unix/Command/_attr
@@ -2,11 +2,9 @@
case $service in
attr)
- local -a list
- [[ $OSTYPE = irix* ]] &&
- list=( '(-g -s -r -V)-l[list extended attributes associated with file]' )
- _arguments -s -S "$list[@]" \
+ _arguments -s -S \
'(-l -r -s -V)-g[get extended attribute for file]:attribute name' \
+ '(-g -s -r -V)-l[list extended attributes associated with file]' \
'(-l -g -s -q -V)-r[remove given attribute from file]:attribute name' \
'(-l -g -r)-s[set named attribute for file]:attribute name' \
'(-r)-q[quiet output]' \
diff --git a/Completion/Unix/Command/_base64 b/Completion/Unix/Command/_base64
index bbf100acb..6309d8022 100644
--- a/Completion/Unix/Command/_base64
+++ b/Completion/Unix/Command/_base64
@@ -8,7 +8,12 @@
local variant type=base${service//[^2346]/}
_pick_variant -r variant \
- gnu='(Free Soft|uutils)' fourmilab=fourmi darwin=-D unix --version
+ gnu='(Free Soft|uutils)' freebsd=FreeBSD netbsd='<wrap>' fourmilab=fourmi unix --version
+
+# as of macOS 13, Apple's base64 is based on FreeBSD's, and it reports that way,
+# but it's moderately customised so that it supports roughly the same options as
+# the base64 shell script they provided previously
+[[ $variant == (freebsd|unix) && $OSTYPE == darwin* ]] && variant=darwin
case $variant in
gnu)
@@ -27,17 +32,42 @@ case $variant in
darwin)
_arguments -s -S : \
'(: -)'{-h,--help}'[display help information]' \
+ '(: -)--version[display version information]' \
+ '(dec)' \
- '(enc)'{-D,--decode}"[decode input from $type]" \
+ '(enc)'{-d,-D,--decode}"[decode input from $type]" \
+ '(enc)' \
- '(dec)'{-b+,--break=}'[wrap encoded lines at specified number of columns]:number of columns' \
+ '(dec)'{-b+,-w+,--break=,--wrap=}'[wrap encoded lines at specified number of columns]:number of columns' \
+ '!(dec)--breaks=:number of columns' \
+ '(out)' \
{-o+,--output=}'[specify output file]:output file:_files' \
+ '(in)' \
- {-i+,--input=}'[specify input file]:input file:_files' \
+ {-i+,--input=}'[specify input file]:input file:_files'
+ return
+ ;;
+ freebsd)
+ _arguments -s -S -A '-*' : \
+ '(: -)--help[display help information]' \
+ '(: -)--version[display version information]' \
+ + dec \
+ '(enc -d --decode)'{-d,--decode}"[decode input from $type]" \
+ '!(enc)'{-i,--ignore-garbage} \
+ + '(enc)' \
+ '(dec)'{-w+,--wrap=}'[wrap encoded lines at specified number of columns]:number of columns' \
+ + in \
'1:input file:_files'
return
;;
+ netbsd)
+ _arguments -s -S -A '-*' : \
+ + dec \
+ '(enc -d -D)'{-d,-D}"[decode input from $type]" \
+ '(enc)-i[ignore irrelevant characters when decoding]' \
+ + '(enc)' \
+ '(dec)'{-b+,-w+}'[wrap encoded lines at specified number of columns]:number of columns' \
+ + in \
+ '*:input file:_files'
+ return
+ ;;
fourmilab)
_arguments -s -S : \
'(: -)--copyright[display copyright information]' \
diff --git a/Completion/Unix/Command/_baz b/Completion/Unix/Command/_baz
deleted file mode 100644
index 0acdc4639..000000000
--- a/Completion/Unix/Command/_baz
+++ /dev/null
@@ -1,585 +0,0 @@
-#compdef baz
-
-autoload -z is-at-least
-local BAZ=$words[1]
-local baz_version
-local hide_short
-
-# ask the user which version of baz this is
-if ! zstyle -s ":completion:${curcontext}:" baz-version baz_version; then
- # ask baz instead
- baz_version="${${$($BAZ --version)#baz Bazaar version }%% \(thelove@canonical.com*}"
-fi
-
-# test whether to hide short options from completion
-if zstyle -s ":completion:${curcontext}:" hide-shortopts hide_short; then
- case $hide_short in
- true|yes|on|1) hide_short='!' ;;
- *) hide_short='' ;;
- esac
-fi
-
-# completion functions
-(( $+functions[_baz_archives] )) ||
-_baz_archives () { _arch_archives baz "$@" }
-
-(( $+functions[_baz_categories] )) ||
-_baz_categories () { _arch_namespace baz 1 "$argv[@]" }
-
-(( $+functions[_baz_branches] )) ||
-_baz_branches () { _arch_namespace baz 2 "$argv[@]" }
-
-(( $+functions[_baz_versions] )) ||
-_baz_versions () { _arch_namespace baz 3 "$argv[@]" }
-
-(( $+functions[_baz_revisions] )) ||
-_baz_revisions () { _arch_namespace baz 4 "$argv[@]" }
-
-(( $+functions[_baz_local_revisions] )) ||
-_baz_local_revisions () {
- local expl1 expl2 tree_version=`$BAZ tree-version`
- _description -V applied-patches expl1 "patch from this version"
- _description -V other-patches expl2 "patch from other versions"
- compadd "$expl1[@]" `$BAZ logs`
- compadd "$expl2[@]" `$BAZ logs --full $($BAZ log-versions | grep -v $tree_version)`
- # This is incredibly slow.
- # Should complete based on -A, -R, -d
-}
-
-(( $+functions[_baz_config] )) ||
-_baz_config () {
- local configdir root ret=1 n expl
-
- n=$opt_args[(i)(-d|--dir)]
- [[ -n "$n" ]] && configdir=$opt_args[$n]
- root="$(_call_program baz $BAZ tree-root ${configdir} 2>&1)"
- if (( $? )); then
- if [[ -d "configs" ]]; then
- root=.
- else
- _message -e messages "Error: $root"
- return $ret
- fi
- fi
-
- if [[ -d "$root/configs" ]]; then
- configdir=("$root/configs")
- _description files expl 'config file'
- _files -W configdir "$expl[@]" && ret=0
- else
- _message -e messages "No configs/ directory in tree whose root is $root"
- fi
- return $ret
-}
-
-(( $+functions[_baz_limit] )) ||
-_baz_limit () { #presently only does push-mirror style limits
- [[ $words[$CURRENT] == *@* ]] && return 1
-
- local expl archive
- archive=${words[(r)*@*]:-$($BAZ my-default-archive 2> /dev/null)}
- if [ $archive ]; then
-
- if [[ $PREFIX != *--* ]]; then
- _description -V categories expl "categories in $archive"
- compadd -q -S -- "$expl[@]" `$BAZ category $archive`
- else
- _baz_namespace_branches 3
- fi
- fi
-}
-
-(( $+functions[_baz_tree_or_rev] )) ||
-_baz_tree_or_rev () {
- _alternative 'trees:tree:_files -/' 'revisions:revision:_baz_revisions'
-}
-
-(( $+functions[_baz_libraries] )) ||
-_baz_libraries () {
- local libraries expl
- libraries=($(_call_program baz $BAZ my-revision-library))
- _description -V libraries expl "revision library"
- compadd "$expl[@]" -a libraries
-}
-
-(( $+functions[_baz_my_revision_library] )) ||
-_baz_my_revision_library () {
- if [[ -n $words[(r)-d] ]] || [[ -n $words[(r)--delete] ]]; then
- _baz_libraries
- else
- _files -/
- fi
-}
-
-(( $+functions[_baz_log_versions] )) ||
-_baz_log_versions () {
- local logs expl
- logs=($(_call_program baz $BAZ log-versions))
- _description -V versions expl "log version"
- compadd "$expl[@]" -a logs
-}
-
-# command argument definitions
-# commands with different versions
-
-local cmd_register_archive cmd_archives cmd_ls_archives cmd_redo
-local cmd_redo_changes cmd_what_changed cmd_categories
-local cmd_branches cmd_versions cmd_cacherev cmd_logs cmd_log_versions
-local cmd_log_ls cmd_update cmd_join_branch cmd_replay cmd_deltapatch
-local cmd_delta_patch cmd_apply_delta cmd_sync_tree cmd_make_sync_tree
-local cmd_delta cmd_revdelta cmd_library_categories cmd_library_branches
-local cmd_library_versions cmd_library_revisions
-local cmd_status cmd_diff
-
-cmd_log_ls=('*:version:_baz_log_versions')
-cmd_log_versions=()
-# the options should only complete items that are in the tree
-
-cmd_register_archive=('::archive:_baz_archives' ':location:_files -/')
-cmd_archives=('::regex:')
-cmd_redo=('::changeset:_files -/')
-cmd_status=('::dir:_files -/')
-cmd_diff=('::revision:_baz_revisions'
- # ':separator:(--)' '*::limit:_files'
- #don't understand the limit usage
-)
-cmd_categories=('::archive:_baz_archives')
-cmd_branches=('::category:_baz_categories')
-cmd_versions=('::branch:_baz_branches')
-cmd_cacherev=('::revision:_baz_revisions')
-#should only complete non-cached revisions
-
-cmd_logs=($cmd_log_ls)
-cmd_update=('::revision:_baz_revisions')
-cmd_join_branch=(':revision:_baz_revisions')
-#should only complete continuation revisions
-
-cmd_replay=('*::revision:_baz_revisions')
-cmd_deltapatch=(':FROM:_baz_tree_or_rev' ':TO:_baz_tree_or_rev')
-cmd_sync_tree=(':revision:_baz_revisions')
-cmd_delta=(':FROM:_baz_tree_or_rev' ':TO:_baz_tree_or_rev' '::DEST:_files -/')
-cmd_library_categories=('::archive:_baz_archives --library')
-cmd_library_branches=('::category:_baz_categories --library')
-cmd_library_versions=('::branch:_baz_branches --library')
-cmd_library_revisions=('::version:_baz_versions --library')
-
-cmd_ls_archives=($cmd_archives)
-cmd_redo_changes=($cmd_redo)
-cmd_what_changed=($cmd_changes)
-cmd_delta_patch=($cmd_deltapatch)
-cmd_apply_delta=($cmd_deltapatch)
-cmd_make_sync_tree=($cmd_sync_tree)
-cmd_revdelta=($cmd_delta)
-
-# commands the same in all versions
-
-local cmd_help
-cmd_help=()
-
-local cmd_my_id
-cmd_my_id=('::id-string:')
-
-local cmd_my_default_archive
-cmd_my_default_archive=('::archive:_baz_archives')
-
-local cmd_whereis_archive
-cmd_whereis_archive=(':archive:_baz_archives')
-
-local cmd_init_tree
-cmd_init_tree=('::version:_baz_versions')
-
-local cmd_tree_id
-cmd_tree_id=('::directory:_files -/')
-
-local cmd_tree_root
-cmd_tree_root=('::directory:_files -/')
-
-local cmd_tree_version
-cmd_tree_version=(':version:_baz_versions')
-
-local cmd_build_config cmd_buildcfg
-cmd_build_config=(':config:_baz_config')
-cmd_buildcfg=($cmd_build_config)
-
-local cmd_cat_config cmd_catcfg cmd_cfgcat
-cmd_cat_config=(':config:_baz_config')
-cmd_catcfg=($cmd_cat_config)
-cmd_cfgcat=($cmd_cat_config)
-
-local cmd_undo cmd_undo_changes
-cmd_undo=('::revision:_baz_revisions')
-cmd_undo_changes=($cmd_undo)
-
-local cmd_file_diffs
-cmd_file_diffs=(':file:_files' '::revision:_baz_revisions')
-
-local cmd_file_find
-cmd_file_find=(':file:_files' '::revision:_baz_revisions')
-
-local cmd_inventory cmd_srcfind
-cmd_inventory=('::separator:(--)' '*:directory:_files -/')
-cmd_srcfind=($cmd_inventory)
-
-local cmd_lint
-cmd_lint=('::directory:_files -/')
-
-local cmd_id cmd_invtag
-cmd_id=('*:file:_files')
-cmd_invtag=($cmd_id)
-
-local cmd_id_tagging_method cmd_tagging_method methods
-cmd_id_tagging_method=('::tagging method:(($methods))')
-methods=(
- 'names:use naming conventions only'
- 'implicit:use naming conventions but permit for inventory tags'
- 'tagline:use naming conventions but permit for inventory tags'
- 'explicit:require explicit designation of source'
-)
-cmd_tagging_method=($cmd_id_tagging_method)
-
-local cmd_add cmd_add_id cmd_add_tag
-cmd_add=('*:file to add:_files')
-cmd_add_id=($cmd_add)
-cmd_add_tag=($cmd_add)
-
-local cmd_delete cmd_delete_id cmd_delete_tag
-cmd_delete=('*:file to delete:_files')
-cmd_delete_id=($cmd_delete)
-cmd_delete_tag=($cmd_delete)
-
-local cmd_move cmd_move_id cmd_move_tag
-cmd_move_id=(':old name:_files' ':new name:_files')
-cmd_move_id=($cmd_move)
-cmd_move_tag=($cmd_move)
-#would be nice not to offer dirs for newname if oldname is a file, and
-#vice versa
-
-local cmd_mv
-cmd_mv=('*:file:_files')
-# not really right, but close enough
-
-local cmd_default_id cmd_explicit_default cmd_default_tag
-cmd_default_id=('::TAG-PREFIX:')
-cmd_explicit_default=($cmd_default_id)
-cmd_default_tag=($cmd_default_id)
-
-local cmd_tagging_defaults cmd_id_tagging_defaults
-cmd_tagging_defaults=()
-cmd_id_tagging_defaults=($cmd_tagging_defaults)
-
-local cmd_changeset cmd_mkpatch
-cmd_changeset=(
- ':ORIG:_files -/'
- ':MOD:_files -/'
- ':DEST:_files -/'
- '*:file:_files'
-)
-cmd_mkpatch=("$cmd_changeset[@]")
-
-local cmd_dopatch cmd_do_changeset cmd_apply_changeset
-cmd_dopatch=(':changeset:_files -/' ':target:_files -/')
-cmd_do_changeset=($cmd_dopatch)
-cmd_apply_changeset=($cmd_dopatch)
-
-local cmd_show_changeset
-cmd_show_changeset=('::changeset:_files -/')
-
-local cmd_make_archive
-cmd_make_archive=('::name:' ':location:_files -/')
-
-local cmd_archive_setup
-cmd_archive_setup=('*:version:_baz_branches --trailing-dashes')
-
-local cmd_make_category
-cmd_make_category=(':category:_baz_archives -S /')
-
-local cmd_make_branch
-cmd_make_branch=(':branch:_baz_categories --trailing-dashes')
-
-local cmd_make_version
-cmd_make_version=(':version:_baz_branches --trailing-dashes')
-
-local cmd_import cmd_imprev
-cmd_import=('::version:_baz_versions')
-cmd_imprev=($cmd_import)
-
-local cmd_commit cmd_cmtrev
-cmd_commit=('*:file:_files')
-cmd_cmtrev=($cmd_commit)
-
-local cmd_get cmd_getrev
-cmd_get=(':revision:_baz_revisions' '::directory:_files -/')
-cmd_getrev=($cmd_get)
-
-local cmd_get_patch cmd_get_changeset
-cmd_get_patch=(':revision:_baz_revisions' '::dir:_files -/')
-cmd_get_changeset=($cmd_get_patch)
-
-local cmd_lock_revision
-cmd_lock_revision=(':revision:_baz_revisions')
-
-local cmd_push_mirror cmd_archive_mirror
-cmd_push_mirror=(
- '::FROM or MINE:_baz_archives'
- '::TO:_baz_archives'
- '::LIMIT:_baz_limit'
-)
-cmd_archive_mirror=($cmd_push_mirror)
-
-local cmd_revisions
-cmd_revisions=('::version:_baz_versions')
-
-local cmd_ancestry
-cmd_ancestry=('::revision:_baz_revisions')
-
-local cmd_ancestry_graph
-cmd_ancestry_graph=('::revision:_baz_revisions')
-
-local cmd_cat_archive_log
-cmd_cat_archive_log=(':revision:_baz_revisions')
-
-local cmd_cachedrevs
-cmd_cachedrevs=(':version:_baz_versions')
-
-local cmd_uncacherev
-cmd_uncacherev=(':revision:_baz_revisions' '::dir:_files -/')
-
-local cmd_archive_meta_info
-cmd_archive_meta_info=(':item-name:((name\:foo mirror\:bar))')
-
-local cmd_archive_snapshot
-cmd_archive_snapshot=(':dir:_files -/' '::limit:_baz_revisions')
-
-local cmd_archive_version
-cmd_archive_version=()
-
-local cmd_archive_fixup
-cmd_archive_fixup=()
-
-local cmd_make_log
-cmd_make_log=('::version:_baz_versions')
-
-local cmd_add_log cmd_add_log_version
-cmd_add_log=(':version:_baz_versions')
-cmd_add_log_version=($cmd_add_log)
-
-local cmd_remove_log cmd_remove_log_version
-cmd_remove_log=(':version:_baz_log_versions')
-cmd_remove_log_version=($cmd_remove_log)
-
-local cmd_abrowse
-cmd_abrowse=('::LIMIT:_baz_revisions')
-
-local cmd_cat_log
-cmd_cat_log=(':revision-spec:_baz_local_revisions')
-
-local cmd_changelog
-cmd_changelog=('::version:_baz_versions')
-
-local cmd_log_for_merge
-cmd_log_for_merge=('::version:_baz_versions')
-
-local cmd_merges
-cmd_merges=(':INTO:_baz_revisions' '::FROM:_baz_revisions')
-
-local cmd_new_merges
-cmd_new_merges=('::version:_baz_versions')
-
-local cmd_branch
-cmd_branch=(':SOURCE-REVISION:_baz_revisions' ':TAG-VERSION:_baz_versions')
-
-local cmd_merge
-cmd_merge=(':FROM:_baz_revisions')
-
-local cmd_missing cmd_whats_missing
-cmd_missing=('::revision:_baz_revisions')
-cmd_whats_missing=($cmd_missing)
-
-local cmd_pristines cmd_ls_pristines
-cmd_pristines=('::limit:_baz_revisions')
-cmd_ls_pristines=($cmd_pristines)
-
-local cmd_lock_pristine
-cmd_lock_pristine=(':revision:_baz_revisions')
-
-local cmd_add_pristine
-cmd_add_pristine=(':revision:_baz_revisions')
-
-local cmd_find_pristine
-cmd_find_pristine=(':revision:_baz_revisions')
-
-local cmd_my_revision_library
-cmd_my_revision_library=(':library:_baz_my_revision_library')
-
-local cmd_library_find
-cmd_library_find=(':revision:_baz_revisions --library')
-
-local cmd_library_add
-cmd_library_add=(':revision:_baz_revisions --exclude-library-revisions')
-
-local cmd_library_remove
-cmd_library_remove=(':revision:_baz_revisions --library')
-
-local cmd_library_archives
-cmd_library_archives=()
-
-local cmd_library_log
-cmd_library_log=(':revision:_baz_revisions --library')
-
-local cmd_library_file
-cmd_library_file=(':file:_files' ':revision:_baz_revisions --library')
-
-local cmd_grab
-cmd_grab=(':location:_files')
-
-local cmd_parse_package_name
-cmd_parse_package_name=(':name:')
-
-local cmd_valid_package_name
-cmd_valid_package_name=(':name:')
-
-local cmd_library_config
-cmd_library_config=(':library:_baz_libraries')
-
-local cmd_rbrowse
-cmd_rbrowse=('::regular expression:')
-
-local cmd_rm
-cmd_rm=('*:file:_files')
-
-local cmd_escape
-cmd_escape=(':string:')
-
-local cmd_switch
-cmd_switch=(':revision:_baz_revisions')
-
-#mutually exclusive options
-
-local -A excludes
-excludes=(
-# This first line means that if --output was given, don't complete
-# --no-output or --keep. The converse is not true.
---output '--no-output --keep'
---no-output --output
-
---silent ' --quiet --report --verbose --debug'
---quiet '--silent --report --verbose --debug'
---report '--silent --quiet --verbose --debug'
---verbose '--silent --quiet --report --debug'
---debug '--silent --quiet --report --verbose '
-
---sparse --non-sparse
---non-sparse --sparse
-
---files ' --directories --both'
---directories '--files --both'
---both '--files --directories '
-
---mirror --mirror-from
---mirror-from --mirror
-
---no-cached --cached-tags
---cached-tags --no-cached
-
---non-greedy --greedy
---greedy --non-greedy
-)
-
-_baz_main () {
- typeset -A opt_args
- local arguments
- if (( CURRENT > 2 )); then
- local cmd=${words[2]}
- local var_cmd=cmd_${cmd//-/_}
- curcontext="${curcontext%:*:*}:baz-$cmd:"
- (( CURRENT-- ))
- shift words
-
- arguments=()
- local input
- input=(${${(M)${(f)"$($BAZ $cmd -h)"}:# *}# })
-
- local i j=1
- local short long arg desc action
- short=()
- long=()
- arg=()
- desc=()
- action=()
- for (( i=1 ; i <= ${#input} ; i++ )); do
- [[ "$input[i]" != *[^\ ]* ]] && continue # stupid blank lines
- short[j]="${${${input[i]}[1,2]}#--}"
- long[j]="${${input[i]#-?, }%% *}"
-
- arg[j]="${${${input[i]%% *}##* }##-*}"
- [[ $long[j] == --archive ]] && arg[j]=ARCHIVE # baz doesn't mention this
-
- desc[j]="${input[i]##* }"
- if [[ "$input[i+1]" == \ *[^\ ]* ]]; then # description continues
- (( i++ ))
- desc[j]="$desc[j] ${input[i]##* }"
- fi
- [[ "$short[j]" == -[hHV] ]] && continue
- desc[j]="${${desc[j]//\[/\\[}//\]/\\]}" # escape brackets
-
- case $arg[j] in
- DIR|PATCH-DIR|DEST|OUTPUT|PATH)
- action[j]='_files -/' ;;
- FILES|FILE|SNAP-FILE)
- action[j]='_files' ;;
- MASTER|MASTER-SOURCE|ARCHIVE)
- action[j]='_baz_archives' ;;
- CATEGORY)
- action[j]='_baz_categories' ;;
- BRANCH)
- action[j]='_baz_branches' ;;
- VERSION)
- action[j]='_baz_versions' ;;
- CFG)
- action[j]='_baz_configs' ;;
- LIB)
- action[j]='_baz_libraries' ;;
-# PATCH,FILE) # not sure how to complete this
-# action[j]='_baz_patch_file' ;;
- *)
- action[j]='' ;;
- esac
-
- (( j++ ))
-
- done
-
- local excluded k
- for (( i = 1 ; i < j ; i++ )); do
- excluded=($short[i] $long[i])
- foreach opt (${=excludes[$long[i]]})
- k=$long[(i)$opt]
- excluded=($excluded $short[k] $long[k])
- #excludes matching short options too :-)
- end
-
-
- # generate arguments to _arguments ;-)
- # make long and short options mutually exclusive
- [ $short[i] ] && arguments=("$arguments[@]"
- "${hide_short}(${excluded})${short[i]}[${desc[i]}]${arg[i]:+:$arg[i]:$action[i]}")
- [ $long[i] ] && arguments=("$arguments[@]"
- "(${excluded})${long[i]}[${desc[i]}]${arg[i]:+:$arg[i]:$action[i]}")
- done
-
- arguments=("$arguments[@]" "${(@P)var_cmd-*:FILE:_files}")
- else
- local help
- local -U cmds
- help=(${(f)"$($BAZ help)"})
- cmds=(${${${${(M)help:#* :*}/ #: #/:}%% ##}## #})
- arguments=(':command:(($cmds))')
- fi
- _arguments -S -A '-*' \
- {"${hide_short}(: -)-V",'(: -)--version'}'[display version]' \
- {"${hide_short}(: -)-h",'(: -)--help'}'[display help]' \
- '(: -)-H[display verbose help]' \
- "$arguments[@]"
-}
-
-_baz_main "$@"
diff --git a/Completion/Unix/Command/_bittorrent b/Completion/Unix/Command/_bittorrent
deleted file mode 100644
index 1fbab35ef..000000000
--- a/Completion/Unix/Command/_bittorrent
+++ /dev/null
@@ -1,100 +0,0 @@
-#compdef btdownloadcurses btdownloadheadless btdownloadgui btlaunchmany btlaunchmanycurses bttrack btshowmetainfo btreannounce btmakemetafile btrename
-
-# Bittorrent completion commands. Originally written by Jussi
-# Pakkanen, 2004. Most of the command descriptions are from the Debian
-# project's man pages.
-
-# Modified by R.Ramkumar, 2006 to conform to zsh completion standards and
-# enhance completion for certain options.
-
-case $service in
-
-# Start with the clients.
-
- btdownloadcurses)
- ;&
- btdownloadheadless)
- ;&
- btdownloadgui)
- ;&
- btlaunchmany)
- ;&
- btlaunchmanycurses)
- _arguments -s -S \
- '(--responsefile)--responsefile+[specify file for server response]:file:_files'\
- "--url+[specify URL of torrent file]:URL:_urls"\
- '(-i --ip)'{-i+,--ip+}'[specify ip address to report as]:ip address'\
- "--bind+[specify ip to bind to instead of default]:ip:_bind_addresses"\
- "--minport+[specify minimum port to listen to]:port:"\
- "--maxport+[specify maximum port to listen to]:port:"\
- "--saveas+[specify file to save to]:file:_files -/"\
- "--max_uploads+[specify maximum amount of uploads]:uploads:"\
- "--max_upload_rate+[specify maximum upload rate]:rate (kb):"\
- "--keepalive_interval+[specify pause between keepalives]:time (s):"\
- "--download_slice_size+[specify bytes to query per request]:size (b):"\
- "--request_backlog+[specify number of requests to keep in a single pipe]:requests:"\
- "--max_message_length+[specify maximum length of prefix encoding]:size (b):"\
- "--timeout+[specify timeout before closing sockets on receiving nothing]:timeout (s):"\
- "--timeout_check_interval+[specify interval to check for connection time]:time interval (s):"\
- "--max_slice_length+[specify maximum size of requests accepted from peers]:size (b):"\
- "--max_rate_recalculate_interval+[specify length of pauses leading to reduced rate]:time (s):"\
- "--max_rate_period+[specify maximum time taken to guess the current rate estimate]:time (s):"\
- "--upload_rate_fudge+[specify time equivalent of writing to kernel TCP buffer]:time (s):"\
- "--display_interval+[specify time between updates to displayed information]:time (s):"\
- "--rerequest_interval+[specify time between requests for more peers]:time (s)"\
- "--min_peers+[specify peers needed before stopping or delaying requests for peers]:peers:"\
- "--http_timeout+[specify timeout for http connections]:timeout (s):"\
- "--snub_time+[specify timeout to decide that connection is semi-permanently choked]:timeout (s):"\
- "--spew+[display diagnostic info to stdout]:enable:(0 1)"\
- "--check_hashes+[check hashes on disk]:enable:(0 1)"\
- "--max_initiate+[specify peers needed before stopping initiating new connections]:peers:"\
- "--report_hash_failures+[report hash failures to user]:enable:(0 1)"\
- "--rarest_first_priority_cutoff+[specify peers which need to have a piece before other partials take priority over rarest first]:peers:"\
- ':torrent file:_files -g "*.torrent(-.)"'
- return
- ;;
-
-# Next up are the torrent file manipulation programs.
-
- btshowmetainfo)
- _files -g "*.torrent(-.)" && return
- ;;
-
- btrename)
- _files -g '*.torrent(-.)' && return
- ;;
-
- btmakemetafile)
- _arguments -s -S \
- '--piece_size_pow2+[specify power of 2 to set the piece size to]:power:' \
- "--comment+[specify human-readable comment to put in .torrent]:comment:"\
- "--target+[specify target file for the torrent]:file:_files"\
- ':file:_files'
- return
- ;;
-
- btreannounce)
- _files -g '*.torrent(-.)' && return
- ;;
-
-# Lastly the tracker.
-
- bttrack)
- _arguments -s -S \
- "--port+[specify port to listen on]:port number:" \
- "--dfile+[specify file to store recent downloader info]:file:_files" \
- "--bind+[specify ip to bind to]:bind address:_bind_addresses" \
- "--socket_timeout+[specify timeout for closing connections]:timeout (s):"\
- "--save_dfile_interval+[specify interval between saving dfile]:time (s):"\
- "--timeout_downloaders_interval+[timeout for expiring downloaders]:time (s):" \
- "--reannounce_interval+[specify interval downloaders should wait between reannouncements]:time (s):" \
- "--response_size+[specify peers to send in an info message]:peers:" \
- "--timeout_check_interval+[specify connection timeout]:timeout (s):"\
- "--nat_check=[check back and ban downloaders behind NAT]:enable:(0 1)" \
- "--min_time_between_log_flushes+[specify minimum time between log flushes]:time (s):" \
- "--allowed_dir+[specify directory having downloadable torrents]:directory:_files -/" \
- "--parse_allowed_interval+[specify interval between reloading allowed_dir]:time (min):" \
- "--show_names+[display names from allowed dir]:enable:(0 1)"
- return
- ;;
-esac
diff --git a/Completion/Unix/Command/_cat b/Completion/Unix/Command/_cat
index 78c35653c..d15c5f93c 100644
--- a/Completion/Unix/Command/_cat
+++ b/Completion/Unix/Command/_cat
@@ -1,65 +1,73 @@
#compdef cat gcat
+local ign
local -a args
if _pick_variant gnu='(GNU|uutils)' unix --version; then
+ (( $#words > 2 )) && ign='!(- : *)'
args=(
'(-A --show-all)'{-A,--show-all}'[equivalent to -vET]'
'(-b --number-nonblank -n --number)'{-b,--number-nonblank}'[number nonempty output lines, overrides -n]'
'-e[equivalent to -vE]'
- '(-E --show-ends)'{-E,--show-ends}'[display $ at end of each line]'
+ '(-E --show-ends)'{-E,--show-ends}'[display $ or ^M$ at end of each line]'
'(-n --number)'{-n,--number}'[number all output lines]'
'(-s --squeeze-blank)'{-s,--squeeze-blank}'[suppress repeated empty output lines]'
'-t[equivalent to -vT]'
'(-T --show-tabs)'{-T,--show-tabs}'[display TAB characters as ^I]'
'-u[ignored]'
'(-v --show-nonprinting)'{-v,--show-nonprinting}'[use ^ and M- notation, except for LFD and TAB]'
- '(- : *)--help[display help and exit]'
- '(- : *)--version[output version information and exit]'
+ "$ign--help[display help and exit]"
+ "$ign--version[display version information]"
'*: :_files'
)
-
-elif [[ "$OSTYPE" == (*bsd|dragonfly|darwin)* ]]; then
- args=(
- -A "-*"
+else
+ # POSIX requires just '-u'
+ args=( -A "-?*"
'(-n)-b[number non-blank output lines]'
'(-v)-e[display $ at the end of each line (implies -v)]'
- '-n[number all output lines]'
- '-s[squeeze multiple blank lines into one]'
- '(-v)-t[display tab as ^I (implies -v)]'
- '-u[do not buffer output]'
'-v[display non-printing chars as ^X or M-a]'
- '*: :_files'
- )
- [[ $OSTYPE = (free|net)bsd* ]] && args+=(
- '-l[set a lock on the stdout file descriptor]'
- )
- [[ $OSTYPE = netbsd* ]] && args+=(
- '-B+[read with buffer of specified size]:size (bytes)'
- '-f[only attempt to display regular files]'
- )
- [[ $OSTYPE = darwin* ]] && args+=(
- '-l[set an exclusive advisory lock on standard output]'
- )
-elif [[ $OSTYPE = solaris* ]]; then
- args=(
- -A "-*"
- '(-b)-n[number all output lines]'
- '(-n)-b[number non-blank output lines]'
- "-u[don't buffer output]"
- '-s[be silent about non-existent files]'
- '-v[display non-printing chars as ^X or M-a]'
- '-e[display $ at the end of each line (requires -v)]'
- '-t[display tab as ^I and formfeeds and ^L (requires -v)]'
- '*: :_files'
- )
-else
- # POSIX requires '-u', and most OSes may support '-n'
- args=(
'-n[number all output lines]'
- '-u[do not buffer output]'
+ "-u[don't buffer output]"
'*: :_files'
)
+ case $OSTYPE in
+ (*bsd|dragonfly|darwin)*)
+ args+=(
+ '-s[squeeze multiple blank lines into one]'
+ '(-v)-t[display tab as ^I (implies -v)]'
+ )
+ ;|
+ (free|net)bsd*)
+ args+=(
+ '-l[set a lock on the stdout file descriptor]'
+ )
+ ;|
+ aix*|solaris*)
+ args+=(
+ '(-q)-s[be silent about non-existent files]'
+ '-t[display tab as ^I and formfeeds and ^L (requires -v)]'
+ )
+ ;|
+
+ aix*)
+ args+=(
+ '(-s)-q[be silent about non-existent files]'
+ '(-r -S)'{-r,-S}'[condense consecutive blank lines to one line]'
+ '-Z[dump encrypted files in encrypted format]'
+ )
+ ;;
+ netbsd*)
+ args+=(
+ '-B+[read with buffer of specified size]:size (bytes)'
+ '-f[only attempt to display regular files]'
+ )
+ ;;
+ darwin*)
+ args+=(
+ '-l[set an exclusive advisory lock on standard output]'
+ )
+ ;;
+ esac
fi
_arguments -s -S $args
diff --git a/Completion/Unix/Command/_cdrecord b/Completion/Unix/Command/_cdrecord
index 602cd5e8e..e429d7bfa 100644
--- a/Completion/Unix/Command/_cdrecord
+++ b/Completion/Unix/Command/_cdrecord
@@ -80,8 +80,8 @@ if [[ -n $state ]]; then
'mcn[set media catalog number for this CD]:text' \
'isrc[set isrc number for the next track]:text' \
'index[set the index list for the next track]:list' \
- 'textfile[set the file with CD-Text data]:name:_files -g "*.inf(-.)"' \
- 'cuefile[set the file with CDRWIN CUE data]:name:_files -g "*.cue(-.)"' && ret=0
+ 'textfile[set the file with CD-Text data]:name:_tilde_files -g "*.inf(-.)"' \
+ 'cuefile[set the file with CDRWIN CUE data]:name:_tilde_files -g "*.cue(-.)"' && ret=0
fi
_requested files expl track _files && ret=0
(( ret )) || break
diff --git a/Completion/Unix/Command/_chdman b/Completion/Unix/Command/_chdman
new file mode 100644
index 000000000..c1fea7d42
--- /dev/null
+++ b/Completion/Unix/Command/_chdman
@@ -0,0 +1,195 @@
+#compdef chdman
+
+local ret=1 words1=$words[1]
+local -a opts args context state state_descr line expl
+local -a create_common_opts extract_common_opts ld_common_opts
+local -a meta_common_opts input_bytes_hunks_opts
+local -A opt_args
+
+opts=(
+ '(--input -i)'{--input,-i}'[specify input file]:input file:_files'
+ '(--inputparent -ip)'{--inputparent,-ip}'[specify parent file for input CHD]:input parent file:_files'
+ '(--output -o)'{--output,-o}'[specify output file]:output file:_files'
+ '(--outputbin -ob)'{--outputbin,-ob}'[specify output file for binary data]:output binary file:_files'
+ '(--splitbin -sb)'{--splitbin,-sb}'[output one binary file per track]'
+ '(--force -f)'{--force,-f}'[overwrite existing file]' # note same short option as --fix
+ '(--outputparent -op)'{--outputparent,-op}'[specify parent file for output CHD]:output parent file:_files'
+ '(--inputstartbyte -isb)'{--inputstartbyte,-isb}'[specify starting byte offset within input]: :\
+ _numbers -u bytes "start byte" k m g'
+ '(--inputstarthunk -ish)'{--inputstarthunk,-ish}'[specify starting hunk offset within input]: :\
+ _numbers -u hunks "start hunk" k m g'
+ '(--inputstartframe -isf)'{--inputstartframe,-isf}'[specify starting frame within input]: :\
+ _numbers -u frames "start frame" k m g'
+ '(--inputbytes -ib)'{--inputbytes,-ib}'[specify effective length of input in bytes]: :\
+ _numbers -u bytes "input length" k m g'
+ '(--inputhunks -ih)'{--inputhunks,-ih}'[specify effective length of input in hunks]: :\
+ _numbers -u hunks "input length" k m g'
+ '(--inputframes -if)'{--inputframes,-if}'[specify effective length of input in frames]: :\
+ _numbers -u frames "input length" k m g'
+ '(--hunksize -hs)'{--hunksize,-hs}'[specify size of each hunk in bytes]: :\
+ _numbers -u bytes -l 16 -m $((1024*1024)) "hunk size" k m g'
+ '(--unitsize -us)'{--unitsize,-us}'[specify size of each unit in bytes]: :\
+ _numbers -u bytes "unit size" k m g'
+ '(--compression -c)'{--compression,-c}'[specify compression codecs to use]: :->codecs'
+ '(--ident -id)'{--ident,-id}'[specify ident file to provide CHS information]:ident file:_files'
+ '(--chs -chs)'{--chs,-chs}'[specify CHS information directly]:cylinders,heads,sectors:'
+ '(--sectorsize -ss)'{--sectorsize,-ss}'[specfiy size of each hard disk sector]: :\
+ _numbers -u bytes "sector size" k m g'
+ '(--tag -t)'{--tag,-t}'[specify metadata tag]:4-character metadata tag:'
+ '(--index -ix)'{--index,-ix}'[specify indexed instance of metadata tag]:index:'
+ '(--valuetext -vt)'{--valuetext,-vt}'[specify metadata value as text]:metadata value:'
+ '(--valuefile -vf)'{--valuefile,-vf}'[specify file containing metadata value]:metadata value file:_files'
+ '(--numprocessors -np)'{--numprocessors,-np}'[specify max number of processors to use during compression]: :\
+ _numbers -u processors -l1 "processor limit"'
+ '(--nochecksum -nocs)'{--nochecksum,-nocs}'[excluded added metadata from SHA-1]'
+ '(--fix -f)'{--fix,-f}'[fix SHA-1 if incorrect]' # note same short option as --force
+ '(--verbose -v)'{--verbose,-v}'[output additional information]'
+ '(--size -s)'{--size,-s}'[specify size of output file]: :\
+ _numbers -u bytes "output file size" k m g'
+ '(--template -tp)'{--template,-tp}'[specify hard disk template]: :->templates'
+)
+create_common_opts=(
+ ${(M)opts:#(|*\))--(output|outputparent|force|input|hunksize|compression|numprocessors)\[*}
+ ${(M)opts:#(|*\))-(o|op|f|i|hs|c|np)\[*~*-f*fix*}
+)
+extract_common_opts=(
+ ${(M)opts:#(|*\))--(output|force|input|inputparent)\[*}
+ ${(M)opts:#(|*\))-(o|f|i|ip)\[*~*-f*fix*}
+)
+ld_common_opts=(
+ ${(M)opts:#(|*\))--(inputstartframe|inputframes)\[*}
+ ${(M)opts:#(|*\))-(isf|if)\[*}
+)
+meta_common_opts=(
+ ${(M)opts:#(|*\))--(input|tag|index)\[*}
+ ${(M)opts:#(|*\))-(i|t|ix)\[*}
+)
+input_bytes_hunks_opts=(
+ ${(M)opts:#(|*\))--(inputstartbyte|inputstarthunk|inputbytes|inputhunks)\[*}
+ ${(M)opts:#(|*\))-(isb|ish|ib|ih)\[*}
+)
+
+if (( CURRENT < 3 )); then
+ args=( ': :->commands' )
+else
+ case $words[2] in
+ help) args=( ': :->commands' ) ;;
+ info) args=(
+ ${(M)opts:#(|*\))--(input|verbose)\[*}
+ ${(M)opts:#(|*\))-(i|v)\[*}
+ ) ;;
+ verify) args=(
+ ${(M)opts:#(|*\))--(input|inputparent)\[*}
+ ${(M)opts:#(|*\))-(i|ip)\[*}
+ ) ;;
+ createraw|createdvd) args=(
+ $create_common_opts
+ $input_bytes_hunks_opts
+ ${(M)opts:#(|*\))--(unitsize)\[*}
+ ${(M)opts:#(|*\))-(us)\[*}
+ ) ;;
+ createhd) args=(
+ $create_common_opts
+ $input_bytes_hunks_opts
+ ${(M)opts:#(|*\))--(unitsize|chs|sectorsize|template|ident)\[*}
+ ${(M)opts:#(|*\))-(us|chs|ss|tp|id)\[*}
+ ) ;;
+ createcd) args=( $create_common_opts ) ;;
+ createld) args=( $create_common_opts $ld_common_opts ) ;;
+ extractraw|extractdvd|extracthd) args=(
+ $extract_common_opts
+ $input_bytes_hunks_opts
+ ) ;;
+ extractcd) args=(
+ $extract_common_opts
+ ${(M)opts:#(|*\))--(outputbin)\[*}
+ ${(M)opts:#(|*\))-(ob)\[*}
+ ) ;;
+ extractld) args=( $extract_common_opts $ld_common_opts ) ;;
+ copy) args=(
+ $create_common_opts
+ $input_bytes_hunks_opts
+ ${(M)opts:#(|*\))--(inputparent)\[*}
+ ${(M)opts:#(|*\))-(ip)\[*}
+ ) ;;
+ addmeta) args=(
+ $meta_common_opts
+ ${(M)opts:#(|*\))--(valuetext|valuefile|nochecksum)\[*}
+ ${(M)opts:#(|*\))-(vt|vf|nocs)\[*}
+ ) ;;
+ delmeta) args=( $meta_common_opts ) ;;
+ dumpmeta) args=(
+ $meta_common_opts
+ ${(M)opts:#(|*\))--(output|force)\[*}
+ ${(M)opts:#(|*\))-(o|f)\[*~*-f*fix*}
+ ) ;;
+ esac
+ shift words
+ (( CURRENT-- ))
+fi
+
+_arguments : $args && ret=0
+
+case $state in
+ commands)
+ _describe -t commands command '(
+ "help:display usage information"
+ "info:display CHD information"
+ "verify:verify CHD integrity"
+ "createraw:create raw CHD"
+ "createhd:create hard disk CHD"
+ "createcd:create CD CHD"
+ "createdvd:create DVD CHD"
+ "createld:create LaserDisc CHD"
+ "extractraw:extract raw file from CHD"
+ "extracthd:extract hard disk file from CHD"
+ "extractcd:extract CD file from CHD"
+ "extractdvd:extract DVD file from CHD"
+ "extractld:extract LaserDisc AVI from CHD"
+ "copy:copy data from one CHD to another"
+ "addmeta:add metadata to CHD"
+ "delmeta:remove metadata from CHD"
+ "dumpmeta:dump metadata from CHD"
+ "listtemplates:list hard disk templates"
+ )' && ret=0
+ ;;
+
+ codecs)
+ local -a codecs
+
+ case $words[1] in # was $words[2]
+ *ld) codecs=(
+ 'avhu[A/V Huffman]'
+ ) ;;
+ *cd) codecs=(
+ 'cdfl[CD FLAC]' 'cdlz[CD LZMA]' 'cdzl[CD Deflate]' 'cdzs[CD Zstandard]'
+ ) ;;
+ *) codecs=(
+ 'flac[FLAC]' 'huff[Huffman]' 'lzma[LZMA]' 'zlib[Deflate]' 'zstd[Zstandard]'
+ ) ;;
+ esac
+
+ _alternative \
+ 'codecs-none:no codec:(( none\:uncompressed ))' \
+ "codecs: :_values -s, 'compression codec' ${(j< >)${(@q+)codecs}}" \
+ && ret=0
+ ;;
+
+ templates)
+ local -a tpls tmp=( ${(f)"$(
+ _call_program templates $words1 listtemplates
+ )"} )
+ tmp=( ${(@)${(@)tmp//[[:space:]]##/ }# } )
+ tmp=( ${(@M)tmp:#<-> *} )
+
+ for 1 in $tmp; do
+ tmp=( ${(z)1} )
+ # id : mfg model (c,h,s)
+ tpls+=( "${tmp[1]}:$tmp[2] $tmp[3] (${(j<,>)${(@)tmp[4,6]}})" )
+ done
+
+ _describe -2V -t templates 'hard disk template' tpls && ret=0
+ ;;
+esac
+
+return ret
diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown
index dae0de86c..36db9c4d2 100644
--- a/Completion/Unix/Command/_chown
+++ b/Completion/Unix/Command/_chown
@@ -74,19 +74,13 @@ _arguments -C -s -S -0 $aopts "$args[@]" '*: :->files' && ret=0
case $state in
owner)
- if [[ $service = chgrp ]] || compset -P '*[:.]'; then
+ if [[ $service = chgrp ]] || compset -P '*:'; then
if (( EGID && $+commands[groups] && ! $+_comp_priv_prefix )); then # except for sudo
_wanted groups expl 'group' compadd -- $(groups) && return 0
fi
_groups && ret=0
else
- if compset -S '[.:]*'; then
- suf=()
- elif [[ $OSTYPE = irix* ]]; then
- suf=( -qS '.' )
- else
- suf=( -qS ':' )
- fi
+ compset -S ':*' || suf=( -qS: )
_users "$suf[@]" && ret=0
fi
;;
@@ -102,9 +96,9 @@ case $state in
if [[ $service = chgrp ]]; then
grp=${line[1]}
else
- usr=${line[1]%%[.:]*}
+ usr=${line[1]%%:*}
usr=${${(M)usr:#[0-9]#}:-${userdirs[$usr]:+.$usr.}}
- grp=${${(M)line[1]%%[.:]*}#?}
+ grp=${${(M)line[1]%%:*}#?}
fi
[[ -n $grp ]] && grp="${${(M)grp:#[0-9]#}:-.$grp.}"
req=( ${usr:+\^u$usr} ${grp:+\^g$grp} )
diff --git a/Completion/Unix/Command/_clay b/Completion/Unix/Command/_clay
deleted file mode 100644
index 581338b8b..000000000
--- a/Completion/Unix/Command/_clay
+++ /dev/null
@@ -1,42 +0,0 @@
-#compdef clay
-
-# Completion for the Clay Programming Language
-# http://claylabs.com/clay/
-
-_arguments -C \
- "-o:specify output file:_files" \
- "-target:set target platform for code generation" \
- "-shared[create a dynamically linkable library]" \
- "-emit-llvm[emit llvm code]" \
- "-S[emit assembler code]" \
- "-c[emit object code]" \
- "-D-:set flag value" \
- "-O-:set optimization level:(0 1 2 3)" \
- "-g[keep debug symbol information]" \
- "-exceptions[enable exception handling]" \
- "-no-exceptions[disable exception handling]" \
- "-inline[inline procedures marked 'forceinline']" \
- "-no-inline[ignore 'inline' and 'forceinline' keyword]" \
- "-import-externals[include externals from imported modules]" \
- "-no-import-externals[don't include externals from imported modules]" \
- "-pic[generate position independent code]" \
- "-abort[abort on error (to get stacktrace in gdb)]" \
- "-run[execute the program without writing to disk]" \
- "-timing[show timing information]" \
- "-full-match-errors[show universal patterns in match failure errors]" \
- "-log-match:log overload matching behavior for calls" \
- "-arch:build for Darwin architecture <arch>" \
- "-F-:add <dir> to framework search path:_files -/" \
- "-framework:link with framework <name>" \
- "-L:add <dir> to library search path:_files -/" \
- "-Wl,-:pass flags to linker" \
- "-l-:link with library <lib>" \
- "-I+:add <path> to clay module search path:_files -/" \
- "-deps[keep track of the dependencies of the currently]" \
- "-no-deps[don't generate dependencies file]" \
- "-o-deps:write the dependencies to this file" \
- "-e:compile and run <source> (implies -run)" \
- "-M-:import <module>.*; for -e" \
- "-v[display version info]" \
- ":program file:_files -g '*.clay(-.)'"
-
diff --git a/Completion/Unix/Command/_column b/Completion/Unix/Command/_column
index 687d7620f..d9f397f23 100644
--- a/Completion/Unix/Command/_column
+++ b/Completion/Unix/Command/_column
@@ -18,6 +18,12 @@ _pick_variant -r variant \
--version
case $variant in
+ freebsd*)
+ args=(
+ '-l+[specify maximum number of input columns]:columns'
+ )
+ ;|
+
util-linux)
aopts=()
args=(
@@ -26,10 +32,11 @@ case $variant in
+ fill
'(info table text json -x --fillrows)'{-x,--fillrows}'[print across before down]'
+ table
- '(info fill -t --table)'{-t,--table}'[create a table]'
+ '(info fill -t --table -S --use-spaces)'{-t,--table}'[create a table]'
'(info fill -o --output-separator)'{-o+,--output-separator=}'[specify column separator for table output]:separator [two spaces]'
- '(info fill -s --separator)'{-s+,--separator=}'[specify column delimiters in input data]:delimiters'
+ '(info fill -s --input-separator --separator)'{-s+,--input-separator=,--separator=}'[specify column delimiters in input data]:delimiters'
'(info fill -O --table-order)'{-O+,--table-order=}'[specify order of output columns]: :->columns'
+ '(info)--table-colorscheme=[specify color scheme name]:name [column]'
'(info fill -N --table-columns)*'{-C+,--table-column=}'[specify column properties]: :_values -s, -S= property
"name[column name]\:name"
"trunc[truncate text in the columns when necessary]"
@@ -48,13 +55,16 @@ case $variant in
'(info fill json -d --table-noheadings)'{-d,--table-noheadings}"[don't print header]"
'(info fill json -E --table-noextreme)'{-E+,--table-noextreme}"[specify columns where length can be ignored]: :->columns"
'(info fill json -e --table-header-repeat)'{-e,--table-header-repeat}'[repeat header for each page]'
+ '(info fill json -K --table-header-as-columns)'{-K,--table-header-as-columns}'[use first row as table header]'
'(info fill json -H --table-hide)'{-H+,--table-hide=}"[don't print specified columns]: :->columns"
'(info fill json -R --table-right)'{-R+,--table-right=}'[right align text in these columns]: :->columns'
'(info fill json -T --table-truncate)'{-T+,--table-truncate=}'[truncate text in the columns when necessary]: :->columns'
'(info fill json -W --table-wrap)'{-W+,--table-wrap=}'[wrap text in the columns when necessary]: :->columns'
+ '(info fill json)--wrap-separator=[wrap at specified separator]:string'
'(info fill json -r --tree)'{-r+,--tree=}'[specify column to format tree-like]: :->columns'
'(info fill json -i --tree-id)'{-i+,--tree-id=}'[specify column containing ID for child-parent relations]: :->columns'
'(info fill json -p --tree-parent)'{-p+,--tree-parent=}'[specify column containing reference to parent]: :->columns'
+ '(info table json -S --use-spaces)'{-S+,--use-spaces=}'[minimal whitespace between columns (no tabs)]:spaces'
+ json
'(info fill text -n --table-name -c --output-width)'{-n+,--table-name=}'[specify table name for JSON output]:name'
'(info fill text -J --json -c --output-width)'{-J,--json}'[use JSON output format for table]'
diff --git a/Completion/Unix/Command/_configure b/Completion/Unix/Command/_configure
index 3b22b53db..9911b78ec 100644
--- a/Completion/Unix/Command/_configure
+++ b/Completion/Unix/Command/_configure
@@ -1,6 +1,11 @@
#compdef configure config.status
-_arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \
+local ret=1
+local -a expl suf
+
+[[ -prefix - ]] ||
+ ! zstyle -T ":completion:${curcontext}:options" prefix-needed &&
+ _arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \
-s '((#s)--disable- --enable-
(#s)--enable- --disable-
(#s)--with- --without-
@@ -8,4 +13,19 @@ _arguments -- -i '(--(disable|enable)-FEATURE* --(with|without)-PACKAGE*)' \
'*=(E|)PREFIX*:prefix directory:_files -/' \
'*=PROGRAM*:program:_command_names -e' \
'*=NAME*executable*:program:_command_names -e' \
- '*=NAME*:file:_files'
+ '*=NAME*:file:_files' && ret=0
+
+if [[ ! -prefix - ]]; then
+ if [[ "$PREFIX" = *\=* ]]; then
+ compstate[parameter]="${PREFIX%%\=*}"
+ compset -P 1 '*='
+ _value && ret=0
+ else
+ compset -S '=*' || suf=( -r = -S = )
+ _wanted -x variables expl variable compadd $suf \
+ CC CFLAGS CPP CPPFLAGS CXX CXXFLAGS DEFS ERLCFLAGS FCFLAGS \
+ FFLAGS GOFLAGS LDFLAGS LIBS OBJCFLAGS OBJCXXFLAGS && ret=0
+ fi
+fi
+
+return ret
diff --git a/Completion/Unix/Command/_cpio b/Completion/Unix/Command/_cpio
index 20f8c712d..6db4994d8 100644
--- a/Completion/Unix/Command/_cpio
+++ b/Completion/Unix/Command/_cpio
@@ -120,13 +120,12 @@ if [[ $state = afile ]]; then
'users:user name:_users -qS@' && ret=0
fi
elif [[ $state = user ]]; then
- if compset -P '*[:.]'; then
+ if compset -P '*:'; then
_groups && ret=0
else
- local suf=.
- [[ $OSTYPE = (solaris|hpux)* ]] && suf=:
- compset -S '.*' && unset suf
- _users -S "$suf" -q && ret=0
+ local suf
+ compset -S ':*' || suf=( -qS: )
+ _users $suf && ret=0
fi
fi
diff --git a/Completion/Unix/Command/_cplay b/Completion/Unix/Command/_cplay
deleted file mode 100644
index f1755c1a1..000000000
--- a/Completion/Unix/Command/_cplay
+++ /dev/null
@@ -1,8 +0,0 @@
-#compdef cplay
-
-_arguments -s \
- '-n[enable restricted mode]' \
- '-r[toggle playlist repeat mode]' \
- '-R[toggle playlist random mode]' \
- '-v[toggle PCM and MASTER volume control]' \
- '*:playlist or directory or audio file:_files -g "*.(mp3|mp2|ogg|669|amf|ams|dsm|far|it|med|mod|mt2|mtm|okt|s3m|stm|ult|gdm|xm|m3u|pls|spx|wav|au)(-.)"'
diff --git a/Completion/Unix/Command/_csplit b/Completion/Unix/Command/_csplit
index b0ba1d7f4..eb354bd83 100644
--- a/Completion/Unix/Command/_csplit
+++ b/Completion/Unix/Command/_csplit
@@ -17,7 +17,7 @@ specs=(
if _pick_variant gnu='(GNU|uutils)' unix --version; then
# GNU coreutils 8.32
specs+=(
- '(hv -b --suffix-format -n --digits)'{-b+,--suffix-format=}'[specify format for numbers in output file names]:format [%%02d]: '
+ '(hv -b --suffix-format -n --digits)'{-b+,--suffix-format=}'[specify format for numbers in output file names]:format [%02d]: '
'(hv)--suppress-matched[suppress the lines matching the pattern]'
'(hv -z --elide-empty)'{-z,--elide-empty-files}'[remove empty output files]'
+ hv
@@ -44,7 +44,7 @@ case $state in
elif compset -P '[0-9]*'; then
_message 'line number' && ret=0
elif [[ ${words[CURRENT]} != -* ]] then
- _message "line_number, '/regex/[offset]', '%%regex%%[offset]', or '{count}'" && ret=0
+ _message "line_number, '/regex/[offset]', '%regex%[offset]', or '{count}'" && ret=0
fi
esac
diff --git a/Completion/Unix/Command/_darcs b/Completion/Unix/Command/_darcs
deleted file mode 100644
index 74734711d..000000000
--- a/Completion/Unix/Command/_darcs
+++ /dev/null
@@ -1,38 +0,0 @@
-#compdef darcs
-## Darcs completion snippet for zsh.
-##
-## Copyright (C) 2009 Nicolas Pouillard
-##
-## This program 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
-## (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.
-
-local expl
-
-if (($CURRENT == 2)); then
- # We're completing the first word after "darcs" -- the command.
- _wanted command expl 'darcs command' \
- compadd -- $( darcs --commands )
-else
- case "${words[$CURRENT]}"; in
- # If it looks like an URL...
- ht*|ft*)
- _arguments '*:URL:_urls'
- ;;
- # If it looks like an explicit path...
- /*|./*|\~*|../*)
- _arguments '*:file:_files'
- ;;
- # Otherwise, let's ask darcs for all possible options
- *)
- _wanted args expl 'arg for darcs command' \
- compadd -- $( darcs ${words[2]} --list-option )
- ;;
- esac
-fi
diff --git a/Completion/Unix/Command/_df b/Completion/Unix/Command/_df
index dae833dfa..ebfe96186 100644
--- a/Completion/Unix/Command/_df
+++ b/Completion/Unix/Command/_df
@@ -88,7 +88,7 @@ elif [[ "$OSTYPE" == (darwin|dragonfly|freebsd|netbsd*|openbsd)* ]]; then
'(-P -G -N)-f[display only the available free]'
'(-G -i -P)-G[display all fields in statvfs]'
'(-G -P)-N[suppress the header line normally output]'
- '-W[print widge name instead of the device]'
+ '-W[print wedge name instead of the device]'
)
;;
esac
diff --git a/Completion/Unix/Command/_diffstat b/Completion/Unix/Command/_diffstat
index 9e7bf779b..068ec4c1e 100644
--- a/Completion/Unix/Command/_diffstat
+++ b/Completion/Unix/Command/_diffstat
@@ -17,6 +17,7 @@ _arguments -s -S \
'-n+[specify minimum width for filenames]:width [auto]' \
'-N+[specify maximum width for filenames]:width [auto]' \
'-o+[redirect standard output to specified file]:output file:_files' \
+ '-O[inspect only files listed in diff for -S/-D options]' \
'-p+[specify number of path separators to strip]:path components [common]' \
'-q[suppress "0 files changed" message for empty diffs]' \
'-r+[specify rounding for histogram]:rounding:((0\:none 1\:simple 2\:simple+adjustment))' \
diff --git a/Completion/Unix/Command/_dig b/Completion/Unix/Command/_dig
index 440c5de90..893f187d6 100644
--- a/Completion/Unix/Command/_dig
+++ b/Completion/Unix/Command/_dig
@@ -17,15 +17,16 @@ local -a alts args
'*+'{no,}'badcookie[retry BADCOOKIE responses]'
'*+'{no,}'cdflag[set the CD (checking disabled) bit in the query]'
'*+'{no,}'class[display the CLASS whening printing the record]'
+ '*+'{no,}'coflag[set compact denial of existence ok flag in query]'
'*+'{no,}'cookie[add a COOKIE option to the request]'
'*+'{no,}'crypto[display cryptographic fields in DNSSEC records]'
'*+'{no,}'dns64prefix[get the DNS64 prefixes from ipv4only.arpa]'
- '*+edns=-[specify EDNS version for query]:version (0-255)'
+ '*+edns=-[specify EDNS version for query]:version (0-255) [0]'
'*+noedns[clear EDNS version to be sent]'
- '*+ednsflags=-[set EDNS flags bits]:flags'
+ '*+ednsflags=-[set undefined EDNS flags bits]:flags'
'*+'{no,}'ednsnegotiation[set EDNS version negotiation]'
'*+ednsopt=-[specify EDNS option]:code point'
- '*+noedns[clear EDNS options to be sent]'
+ '*+noednsopt[clear EDNS options to be sent]'
'*+'{no,}'expandaaaa[expand AAAA records]'
'*+'{no,}'expire[send an EDNS Expire option]'
'*+'{no,}'header-only[send query without a question section]'
@@ -45,6 +46,7 @@ local -a alts args
'*+'{no,}'cmd[print initial comment in output]'
'*+'{no,}'short[print terse output]'
'*+'{no,}'showbadcookie[show BADCOOKIE message]'
+ '*+'{no,}'showbadvers[show BADVERS message]'
'*+'{no,}'identify[print IP and port of responder]'
'*+'{no,}'comments[print comment lines in output]'
'*+'{no,}'stats[print statistics]'
diff --git a/Completion/Unix/Command/_drill b/Completion/Unix/Command/_drill
index 68fa7917b..6ce634874 100644
--- a/Completion/Unix/Command/_drill
+++ b/Completion/Unix/Command/_drill
@@ -20,7 +20,7 @@ _arguments -s -S -C \
'(-4)-6[stay on ipv6]' \
'-a[fallback to EDNS0 and TCP if the answer is truncated]' \
'-b+[specify buffer size (defaults to 512 b)]:size (bytes) [512]' \
- '-c+[use specified file for rescursive nameserver configuration]:file [/etc/resolv.conf]:_files' \
+ '-c+[use specified file for recursive nameserver configuration]:file [/etc/resolv.conf]:_files' \
'-k+[specify a file that contains a trusted DNSSEC key]:file:_files' \
'*-o+[set/unset header bits]:mnemonic (uppercase sets, lower unsets):_sequence compadd - QR qr AA aa TC tc RD rd CD cd RA ra AD ad' \
'-p+[use specified remote port number]:port:_ports' \
diff --git a/Completion/Unix/Command/_du b/Completion/Unix/Command/_du
index 038811eb8..be2cbdfce 100644
--- a/Completion/Unix/Command/_du
+++ b/Completion/Unix/Command/_du
@@ -5,7 +5,7 @@ if _pick_variant gnu='(Free Soft|uutils)' unix --version /dummy/no-such-file; th
_arguments -s \
'(-a --all -s --summarize)'{-a,--all}'[write counts for all files]' \
- '--apparent-size[print apparent sizes rather than disc usage]' \
+ '(-A --apparent-size)'{-A,--apparent-size}'[print apparent sizes rather than disc usage]' \
'(-B --block-size -k)'{-B+,--block-size=}'[specify block size]:size (bytes)' \
'(-B --block-size -k --apparent-size -b --bytes)'{-b,--bytes}'[equivalent to --apparent-size --block-size=1]' \
'(-c --total)'{-c,--total}'[produce a grand total]' \
@@ -56,22 +56,22 @@ else
local xdev='[skip directories on different filesystems]'
for pattern arg in \
'(freebsd|darwin)*' '-A[apparent size instead of usage]' \
- '(darwin*|*bsd*|dragonfly*|solaris2.<10->)' '(-H -L -P)-H[follow symlinks on the command line]' \
+ '(aix*|darwin*|*bsd*|dragonfly*|solaris2.<10->)' '(-H -L -P)-H[follow symlinks on the command line]' \
'(darwin|*bsd|dragonfly)*' '(-H -L -P)-P[do not follow symlinks (default)]' \
'(darwin|dragonfly|freebsd)*' '*-I+[ignore files/directories matching specified mask]:mask' \
'(darwin|*bsd|dragonfly)*' '(-a -s -d)-d+[display entry for directories up to specified depth]:depth' \
'(darwin*|*bsd*|dragonfly*|solaris2.<10->)' '(-k -m -g -B)-h[human readable output]' \
'netbsd*' '-i[output inode usage instead of blocks]' \
- '(darwin*|freebsd*|netbsd*|solaris2.<11->)' '(-h -k -g -B)-m[use block size of 1M-byte]' \
- '(darwin|freebsd<8->.|netbsd)*' '(-h -k -m -B)-g[use block size of 1G-byte]' \
+ '(aix*|darwin*|freebsd*|netbsd*|solaris2.<11->)' '(-h -k -g -B)-m[use block size of 1M-byte]' \
+ '(aix|darwin|freebsd<8->.|netbsd)*' '(-h -k -m -B)-g[use block size of 1G-byte]' \
'(freebsd|darwin)*' '(-h -k -m -g)-B+[block size]:block size (bytes)' \
'(darwin|*bsd|dragonfly)*' '-c[display grand total]' \
- '(freebsd|darwin)*' '-l[count sizes many times if hard linked]' \
+ '(aix|freebsd|darwin)*' '-l[count sizes many times if hard linked]' \
'(freebsd|netbsd)*' '-n[ignore files and directories with nodump flag set]' \
'solaris*' "(-a)-o[don't add child directories' usage to parent's total]" \
'(freebsd|darwin)*' '-t+[report only entries for which size exceeds threshold]:threshold' \
'solaris*' "-d$xdev" \
- '(darwin|*bsd|dragonfly|solaris)*' "-x$xdev"
+ '(aix|darwin|*bsd|dragonfly|solaris)*' "-x$xdev"
do
[[ $OSTYPE = $~pattern ]] && args+=( $arg )
done
diff --git a/Completion/Unix/Command/_echo b/Completion/Unix/Command/_echo
new file mode 100644
index 000000000..e835847c2
--- /dev/null
+++ b/Completion/Unix/Command/_echo
@@ -0,0 +1,32 @@
+#compdef echo gecho
+
+local variant
+local -a args
+
+_pick_variant -r variant -b zsh gnu='Free Soft' $OSTYPE --version
+
+args=(
+ # these are only interpreted as options when they're the only arg
+ + gnu-hv
+ '(-)--help[display help information]'
+ '(-)--version[display version information]'
+ + other
+ '(gnu-hv -E)-e[interpret escape sequences]'
+ "(gnu-hv -e)-E[don't interpret escape sequences]"
+ "(gnu-hv)-n[don't output trailing newline]"
+)
+
+case $variant in
+ gnu) ;; # pass
+ zsh|openbsd*)
+ args=( ${args:#(|\(*\))--*} )
+ ;;
+ darwin*|dragonfly*|netbsd*|freebsd*)
+ args=( ${args:#(|\(*\))(--|-[eE]\[)*} )
+ ;;
+ *)
+ args=( )
+ ;;
+esac
+
+_arguments -s -A '' : $args '*:string:_default'
diff --git a/Completion/Unix/Command/_entr b/Completion/Unix/Command/_entr
index 438ab179a..ebd66ab72 100644
--- a/Completion/Unix/Command/_entr
+++ b/Completion/Unix/Command/_entr
@@ -11,7 +11,9 @@ _arguments -s -S \
'-p[postpone first execution of the utility]' \
'(-a)-r[reload a persistent child process]' \
'(*)-s[evaluate the first argument using interpreter specified by $SHELL]' \
+ '*-x[format custom exit status messages using a persistent awk(1) process]' \
'-z[exit after the utility completes]' \
+ '(- *)-h[display usage information]' \
'(-): :->command' \
'*::arguments:_normal' && ret=0
diff --git a/Completion/Unix/Command/_env b/Completion/Unix/Command/_env
index b9094339e..6173394e0 100644
--- a/Completion/Unix/Command/_env
+++ b/Completion/Unix/Command/_env
@@ -69,7 +69,9 @@ if [[ -n $state ]]; then
shift words
(( CURRENT-- ))
done
- _normal -p env && ret=0
+ _alternative \
+ 'parameters:environment variable:_parameters -g "*export*" -qS=' \
+ 'normal:: _normal -p env' && ret=0
;;
user-class)
if compset -P 1 '*/'; then
diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg
index e5afdac4f..33eb9c5f6 100644
--- a/Completion/Unix/Command/_ffmpeg
+++ b/Completion/Unix/Command/_ffmpeg
@@ -1,200 +1,1525 @@
#compdef ffmpeg
-local curcontext="$curcontext" state line expl
-typeset -A opt_args
+# notes:
+# - stream/file options modify the input/output file argument that follows, so
+# ideally their arguments would be limited accordingly (e.g. -c would only
+# show encoders before an output file). but it seemed like being too 'smart'
+# about this could be very confusing/annoying. so we don't do that
-(( $+functions[_ffmpeg_presets] )) || _ffmpeg_presets() {
- local presets
- presets=(~/.ffmpeg/*.ffpreset(:t:r) "$FFMPEG_DATADIR"/*.ffpreset(:t:r))
- _wanted ffmpeg-presets expl 'preset' compadd -a presets
+# complete numeric argument
+(( $+functions[_ffmpeg_numbers] )) ||
+_ffmpeg_numbers() {
+ # most numeric args support these suffixes, even when it's nonsensical, e.g.
+ # -framerate 1KiB specifies 8192 fps. and most options that only accept
+ # integer args nonetheless need -f here because of this
+ _numbers -f "$@" {K,M,G}{,i}{,B}
}
-(( $+functions[_ffmpeg_acodecs] )) || _ffmpeg_acodecs() {
- local acodecs
- acodecs=(copy ${${(M)${(f)"$(_call_program audio-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]A[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
- _wanted ffmpeg-audio-codecs expl 'force audio codec (''copy'' to copy stream)' compadd -a acodecs
+# `compadd -R` helper for _ffmpeg_flags
+(( $+functions[_ffmpeg_flags_remf] )) ||
+_ffmpeg_flags_remf() {
+ [[ $1 == 0 ]] || return
+ # swallow last char of inserted match if it was typed again
+ [[ $LBUFFER[-1] == $KEYS ]] && LBUFFER=${LBUFFER%?}
}
-(( $+functions[_ffmpeg_vcodecs] )) || _ffmpeg_vcodecs() {
- local vcodecs
- vcodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]V[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
- _wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a vcodecs
+# complete flag argument (flag1+flag2-flag3)
+# $1 ... => flag
+(( $+functions[_ffmpeg_flags] )) ||
+_ffmpeg_flags() {
+ local ret=1 tag=${curtag:-flags}
+ local -a expl ca_opts ca_x_opts flags
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ M+:=ca_opts {x+:,X+:}=ca_x_opts 1 2 F: J: n o: q r: R: s: S: V: \
+ || return
+
+ flags=( ${@:#${PREFIX//:/\\:}(|:*)} )
+
+ compset -S '[+-]*'
+ compset -P '*[+-]'
+
+ _describe -t $tag flag flags "${(@)ca_opts}" "${(@)ca_x_opts}" -S '' && ret=0
+
+ [[ $IPREFIX$PREFIX == *[+-] ]] || {
+ compset -P '*'
+ _wanted operators expl operator \
+ compadd "${(@)ca_opts}" -R _ffmpeg_flags_remf -S '' - + - && ret=0
+ }
+
+ return ret
}
-(( $+functions[_ffmpeg_scodecs] )) || _ffmpeg_scodecs() {
- local scodecs
- scodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]S[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]})
- _wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a scodecs
+# helper to get stream type char from stream specifier in previous word. this
+# isn't quite accurate, but probably fine for most purposes
+# $1 => param to assign to
+(( $+functions[_ffmpeg_prev_ss_type] )) ||
+_ffmpeg_prev_ss_type() {
+ [[ $1 == (-|--) ]] && shift
+ case ${9::=${(Q)words[CURRENT-1]}} in
+ -[adsv]codec|-[av]f)
+ : ${(P)1::=${(U)9[2]}}
+ ;;
+ -(c|codec):(|*:*:)[adstvV](|:*)) ;&
+ -filter:(|*:*:)[avV](|:*))
+ 8=${(M)9##*:[adstvV](:|)}
+ 8=${${8%:}##*:}
+ : ${(P)1::=${(U)8}}
+ ;;
+ *) return 1 ;;
+ esac
}
-(( $+functions[_ffmpeg_formats] )) || _ffmpeg_formats() {
- local formats
- formats=(${(ou)${=${(s:,:)${${(M)${(f)"$(_call_program formats $words[1] -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}})
- _wanted ffmpeg-formats expl 'force format' compadd -a formats
+# complete stream specifier, usually after a colon-option like -c:
+(( $+functions[_ffmpeg_stream_specs] )) ||
+_ffmpeg_stream_specs() {
+ # does it make sense to allow e.g. -c:a:a:... ?
+ if compset -P '([adstvV]|g:([^i:]*|i:*)|(p|disp):*):'; then
+ _ffmpeg_stream_specs
+ elif compset -P 'g:(\#|\\\#|i:)'; then
+ _message 'group ID'
+ elif compset -P g:; then
+ _message 'group specifier'
+ elif compset -P p:; then
+ _message 'program ID'
+ elif compset -P '(\#|\\\#|i:)'; then
+ _message 'stream ID'
+ elif compset -P m:; then
+ _message 'metadata tag key[:value]'
+ elif compset -P disp:; then
+ _sequence -s+ _ffmpeg_dispositions -I
+ else
+ local ret=1
+ local -a ca_opts
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:}=ca_opts J: V: x: X: \
+ || return
+
+ _describe -t stream-specifier-types 'stream-type specifier' '(
+ a:"audio"
+ d:"data"
+ s:"subtitle"
+ t:"attachment"
+ v:"video (all)"
+ V:"video (not images)"
+ )' -qS: "${(@)ca_opts}" && ret=0
+ _describe -t stream-specifier-others 'other stream specifier' \
+ '(
+ g:"group index or ID"
+ i:"stream ID"
+ p:"program ID"
+ m:"metadata tag"
+ disp:"dispositions"
+ )' -r: -S: "${(@)ca_opts}" \
+ -- \
+ '(
+ u:"usable configuration"
+ )' "${(@)ca_opts}" && ret=0
+
+ return ret
+ fi
}
-(( $+functions[_ffmpeg_pix_fmts] )) || _ffmpeg_pix_fmts() {
- local pix_fmts
- _wanted ffmpeg-pix-fmts expl 'pixel format' compadd "$@" - \
- ${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *}
+# complete metadata specifier
+(( $+functions[_ffmpeg_metadata_specs] )) ||
+_ffmpeg_metadata_specs() {
+ if compset -P s:; then
+ _ffmpeg_stream_specs
+ elif compset -P c:; then
+ _message 'chapter index'
+ elif compset -P p:; then
+ _message 'program index'
+ else
+ _describe -t metadata-specs 'metadata specifier' \
+ '(
+ c:"per-chapter metadata"
+ p:"per-program metadata"
+ s:"per-stream metadata"
+ )' -r: -S: \
+ -- \
+ '(
+ g:"global metadata"
+ )'
+ fi
}
-(( $+functions[_ffmpeg_bsfs] )) || _ffmpeg_bsfs() {
- local bsfs
- bsfs=(${${(f)"$(_call_program bsfs $words[1] -bsfs 2>/dev/null)"}:#*:})
- _wanted ffmpeg-bsfs expl 'set bitstream filter' compadd -a bsfs
+# complete preset name
+(( $+functions[_ffmpeg_presets] )) ||
+_ffmpeg_presets() {
+ local -a presets=(
+ ~/.ffmpeg
+ $FFMPEG_DATADIR
+ ${${${${(Q)words[1]}:c}%/bin/*}:-/usr}/share/ffmpeg
+ )
+ presets=( $^presets/*.ffpreset(N:t:r) )
+ _wanted presets expl preset compadd "$@" -a presets
}
-typeset -A _ffmpeg_flags
+# complete codec or encoder/decoder (-codec et al accept either)
+# -D => decoders, -E => encoders, -T => type (audio, video, etc)
+(( $+functions[_ffmpeg_codecs] )) ||
+_ffmpeg_codecs() {
+ local ret=1 de=DE de_desc=encoder/decoder type=ADSTV type_desc
+ local -a ca_opts codecs encdecs
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,x+:,X+:}=ca_opts J: V: \
+ D E T: \
+ || return
+
+ case ${(L)opth[-T]} in
+ a|aud*) type=A ;;
+ d|dat*) type=D ;;
+ s|sub*) type=S ;;
+ t|att*) type=T ;;
+ v|vid*) type=V ;;
+ *) _ffmpeg_prev_ss_type type ;;
+ esac
+ case $type in
+ A) type_desc=audio ;;
+ D) type_desc=data ;;
+ S) type_desc=subtitle ;;
+ T) type_desc=attachment ;;
+ V) type_desc=video ;;
+ esac
+
+ if (( ${+opth[-D]} )); then
+ de=D de_desc=decoder
+ elif (( ${+opth[-E]} )); then
+ de=E de_desc=encoder
+ fi
+
+ codecs=( ${(f)"$( _call_program codecs $words[1] -codecs )"} )
+ codecs=( ${(M)codecs:# [ADILSTV. ](#c6) [^=]* *} )
+ [[ $de == *D* ]] || codecs=( ${codecs:# D?*} )
+ [[ $de == *E* ]] || codecs=( ${codecs:# ?E*} )
+ codecs=( ${(M)codecs:# ??[$type]??? *} )
+ codecs=( ${codecs# ?????? } )
+
+ # -decoders and -encoders don't include data/attachment
+ [[ $type == *[ASV]* ]] && {
+ [[ $de == *D* ]] &&
+ encdecs+=( ${(f)"$( _call_program decoders $words[1] -decoders )"} )
+ [[ $de == *E* ]] &&
+ encdecs+=( ${(f)"$( _call_program encoders $words[1] -encoders )"} )
+
+ encdecs=( ${(M)encdecs:# [$type][ABDFSVX. ](#c5) [^=]* *} )
+ encdecs=( ${encdecs# ?????? } )
+ }
+
+ if zstyle -t ":completion:$curcontext:$tag" verbose; then
+ codecs=( ${codecs%%[[:space:]]##\((decoders#|encoders#):*} )
+ codecs=( ${${(@)codecs//:/\\:}/[[:space:]]##/:} )
+ # _describe doesn't remove duplicates when there are descriptions
+ encdecs=( ${(u)encdecs} )
+ encdecs=( ${${(@)encdecs//:/\\:}/[[:space:]]##/:} )
+ else
+ codecs=( ${codecs%%[[:space:]]*} )
+ encdecs=( ${encdecs%%[[:space:]]*} )
+ fi
-(( $+functions[_ffmpeg_flag_options] )) || _ffmpeg_flag_options() {
- local expl
- _wanted options expl 'flag' compadd -S '' -- {-,+}${^flag_options}
+ _describe -t codecs "${type_desc:+$type_desc }codec" \
+ codecs "${(@)ca_opts}" && ret=0
+ _describe -t encoders-decoders "${type_desc:+$type_desc }$de_desc" \
+ encdecs "${(@)ca_opts}" && ret=0
+ [[ $de == *E* && ${(Q)words[CURRENT-1]} == -(c|[adsv]#codec)(|:*) ]] &&
+ _describe -t codecs-special 'copy option' '( copy:"copy stream" )' && ret=0
+
+ return ret
}
-(( $+functions[_ffmpeg_more_flag_options] )) || _ffmpeg_more_flag_options() {
- compset -p $1 && _ffmpeg_flag_options
+# complete format/muxer/demuxer/device
+# -D => demuxer, -E => muxer, -v => device
+(( $+functions[_ffmpeg_formats] )) ||
+_ffmpeg_formats() {
+ local dde=dDE tag=formats desc=format
+ local -a ca_opts tmp formats
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \
+ D E v \
+ || return
+
+ if (( ${+opth[-D]} )); then
+ dde=D tag=demuxers desc=demuxer
+ elif (( ${+opth[-E]} )); then
+ dde=E tag=muxers desc=muxer
+ elif (( ${+opth[-v]} )); then
+ dde=d tag=devices desc=device
+ fi
+
+ tmp=( ${(f)"$( _call_program formats $words[1] -formats )"} )
+ tmp=( ${(M)tmp:# [dDE. ](#c3) [^=]* *} )
+ [[ $dde == *D* ]] && formats+=( ${(M)tmp:# D?? *} )
+ [[ $dde == *E* ]] && formats+=( ${(M)tmp:# ?E? *} )
+ [[ $dde == *d* ]] && formats+=( ${(M)tmp:# ??d *} )
+ formats=( ${formats# ??? } )
+
+ # some formats have multiple descriptions, e.g. 'matroska:Matroska' and
+ # 'matroska:Matroska / WebM'. ideally we would merge these together somehow
+ if zstyle -t ":completion:$curcontext:$tag" verbose; then
+ local f d
+ tmp=( ${${(@)formats//:/\\:}/[[:space:]]##/:} )
+ formats=( )
+ for f in $tmp; do
+ d=${f#*:} f=${f%%:*}
+ formats+=( ${^${(@s<,>)f}}:$d )
+ done
+ formats=( ${(u)formats} )
+
+ else
+ formats=( ${(@s<,>)${(@)formats%%[[:space:]]*}} )
+ fi
+
+ _describe -t $tag $desc formats "${(@)ca_opts}"
}
-(( $+functions[_ffmpeg_new_flag_options] )) || _ffmpeg_new_flag_options() {
- compset -P '*' && _ffmpeg_flag_options
+# complete bitstream filter
+# -I => single bsf
+(( $+functions[_ffmpeg_bsfs] )) ||
+_ffmpeg_bsfs() {
+ local tag=bsfs desc='bitstream filter'
+ local -a ca_opts expl bsfs
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \
+ I \
+ || return
+
+ bsfs=( ${(f)"$( _call_program $tag $words[1] -bsfs )"} )
+ bsfs=( ${bsfs##[[:space:]]##} )
+ bsfs=( ${bsfs:#*:} )
+
+ if (( ${+opth[-I]} )); then
+ _describe -t $tag $desc bsfs "${(@)ca_opts}"
+ else
+ _wanted $tag expl '' _values -s, -S= $desc \
+ $^bsfs':bsf option (opt1=val1\:opt2=val2\:...):'
+ fi
}
-(( $+functions[_ffmpeg_flags] )) || _ffmpeg_flags() {
- local -a flag_options
- eval "flag_options=(\${=_ffmpeg_flags[$1]})"
+# complete pixel format / hwaccel output format
+# -H => hwaccel formats only
+(( $+functions[_ffmpeg_pix_fmts] )) ||
+_ffmpeg_pix_fmts() {
+ local tag=pixel-formats desc='pixel format'
+ local -a ca_opts pixfmts
+ local -A opth
- local match mbegin mend
- integer ret=1
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \
+ H \
+ || return
- if [[ $PREFIX = (#b)(*)[-+]([^-+]#) ]]; then
- if [[ -n ${flag_options[(R)$match[2]]} ]]; then
- _ffmpeg_new_flag_options && ret=0
- fi
- if [[ -n ${flag_options[(R)$match[2]?*]} ]]; then
- _ffmpeg_more_flag_options ${#match[1]} && ret=0
- fi
- else
- _ffmpeg_flag_options && ret=0
- fi
+ pixfmts=( ${(f)"$( _call_program $tag $words[1] -pix_fmts )"} )
+ pixfmts=( ${(M)pixfmts:#[BHIOP. ](#c5) [^=]* *} )
- return ret
+ (( ${+opth[-H]} )) && {
+ tag=hwaccel-formats desc='output format'
+ pixfmts=( ${(M)pixfmts:#??H?? *} )
+ }
+
+ pixfmts=( ${pixfmts#????? *} )
+ pixfmts=( ${pixfmts%%[[:space:]]*} )
+
+ (( ${+opth[-H]} )) || {
+ compset -P + || pixfmts+=( + )
+ }
+
+ _describe -t $tag $desc pixfmts "${(@)ca_opts}"
}
-(( $+functions[_ffmpeg_register_lastopt_values] )) || _ffmpeg_register_lastopt_values() {
- if (( lastopt_takesargs )); then
- lastopt+=":$lastopt_description:"
- if (( $#lastopt_values )); then
- if [[ $lastopt_type == flags ]]; then
- lastopt="*$lastopt"
- flagtype=${${lastopt%%:*}#-}
- lastopt+="->$flagtype"
- _ffmpeg_flags[$flagtype]="${lastopt_values[*]}"
- else
- lastopt+="(${lastopt_values[*]})"
- fi
- fi
- fi
- _ffmpeg_argspecs+=$lastopt
+# complete filter
+(( $+functions[_ffmpeg_filters] )) ||
+_ffmpeg_filters() {
+ local MATCH MBEGIN MEND x y z tag=filters desc=filter type=AV
+ local -a ca_opts tmp filters
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \
+ T: \
+ || return
+
+ case ${(L)opth[-T]} in
+ a|aud*) type=A ;;
+ v|vid*) type=V ;;
+ *) _ffmpeg_prev_ss_type type ;;
+ esac
+ case $type in
+ A) tag=audio-$tag desc="audio $desc" ;;
+ V) tag=video-$tag desc="video $desc" ;;
+ esac
+
+ tmp=( ${(f)"$( _call_program filters $words[1] -filters )"} )
+ tmp=( ${(M)tmp:#*-\>*} )
+ tmp=( ${tmp# ?? } )
+ tmp=( ${tmp/[ ]##/$'\t'} )
+ tmp=( ${tmp/[ ]##/$'\t'} )
+
+ for x y z in "${(@ps<\t>)tmp}"; do
+ [[ ${y//[N$type]/} == $y ]] ||
+ filters+=( $x:${z//:/\\:} )
+ done
+
+ if zstyle -t ":completion:$curcontext:$tag" verbose; then
+ # undo sentence case/punctuation
+ filters=( ${filters%.} )
+ filters=( ${filters/(#m):[A-Z][a-z]/${(L)MATCH}} )
+ else
+ filters=( ${filters%%:*} )
+ fi
+
+ _describe -t $tag $desc filters "${(@)ca_opts}"
+}
+
+# complete filtergraph spec
+(( $+functions[_ffmpeg_filtergraphs] )) ||
+_ffmpeg_filtergraphs() {
+ # [link][link] fltr@id=val:key=val:val, fltr@id [link]; fltr=val; ...
+ compset -P '*[];,]'
+ compset -P '[[:space:]]##'
+ compset -S '[;,[]*'
+ compset -S '[[:space:]]##'
+
+ if compset -P '*\['; then
+ _message 'link label'
+ elif compset -P '*='; then
+ _message 'filter arguments ([key=]val:[key=]val:...)'
+ elif compset -P '*@'; then
+ _message 'filter ID'
+ else
+ _ffmpeg_filters -r$'@=,[; \t\n\-' -S,
+ fi
+}
+
+# complete protocol
+(( $+functions[_ffmpeg_protocols] )) ||
+_ffmpeg_protocols() {
+ local tag=protocols desc=protocol
+ local -a protocols
+
+ protocols=( ${(f)"$( _call_program $tag $words[1] -protocols )"} )
+ protocols=( ${protocols:#*:*} )
+ protocols=( ${protocols##[[:space:]]##} )
+
+ _describe -t $tag $desc protocols "$@"
+}
+
+# complete standard or custom channel layout
+(( $+functions[_ffmpeg_layouts] )) ||
+_ffmpeg_layouts() {
+ local ret=1
+ local -a tmp names layouts
+
+ tmp=( ${(f)"$( _call_program layouts $words[1] -layouts )"} )
+ tmp=( ${tmp##[[:space:]]##} )
+
+ names=( ${tmp[1,(R)*(#i)layouts*:*]} )
+ names=( ${names:#(#i)*(NAME[[:space:]]##D|(channel|layout)*:)*} )
+ names=( ${^${names/[[:space:]]##/\[}}\] )
+ names=( $^names':custom name' )
+
+ layouts=( ${tmp[(R)*(#i)layouts*:*,-1]} )
+ layouts=( ${layouts:#(#i)*(NAME[[:space:]]##D|layouts*:)*} )
+ layouts=( ${layouts//:/\\:} )
+ layouts=( ${layouts/[[:space:]]##/:} )
+
+ [[ $PREFIX == *[@+]* ]] || {
+ _describe -t channel-layouts 'standard channel layout' layouts && ret=0
+ }
+ _values -s+ -S@ 'channel name' $names && ret=0
+
+ return ret
}
-local -a _ffmpeg_argspecs
-{
- local lastopt REPLY
- local lastopt_description
- local lastopt_takesargs
- local lastopt_type
- local -a lastopt_values
+# complete sample format
+(( $+functions[_ffmpeg_sample_fmts] )) ||
+_ffmpeg_sample_fmts() {
+ local tag=sample-formats desc='sample format'
+ local -a sample_fmts
+
+ sample_fmts=( ${(f)"$( _call_program $tag $words[1] -sample_fmts )"} )
+ sample_fmts=( ${sample_fmts:#*(:|name[[:space:]]##desc)*} )
+ sample_fmts=( ${sample_fmts##[[:space:]]##} )
+ sample_fmts=( ${sample_fmts%%[[:space:]]*} )
+
+ _describe -t $tag $desc sample_fmts "$@"
+}
+
+# complete hardware acceleration method
+# -T => types only
+(( $+functions[_ffmpeg_hwaccels] )) ||
+_ffmpeg_hwaccels() {
+ local tag=hwaccels desc='hardware acceleration method'
+ local -a ca_opts hwaccels
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \
+ T \
+ || return
+
+ hwaccels=( ${(f)"$( _call_program $tag $words[1] -hwaccels )"} )
+ hwaccels=( ${hwaccels##[[:space:]]##} )
+ hwaccels=( ${hwaccels:#*:*} )
+
+ (( ${+opth[-T]} )) || hwaccels+=( none auto )
+
+ _describe -t $tag $desc hwaccels "${(@)ca_opts}"
+}
+
+# complete hardware devices
+(( $+functions[_ffmpeg_hw_devices] )) ||
+_ffmpeg_hw_devices() {
+ local i tag=hardware-devices desc='hardware device'
+ local -a ca_opts devices
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,x+:,X+:}=ca_opts J: V: \
+ || return
+
+ for (( i = 2; i <= CURRENT; i++ )); do
+ [[ ${(Q)words[i]} == -init_hw_device ]] || continue
+ devices+=( ${${${(Q)words[i+1]}#*=}%@*} )
+ (( i++ ))
+ done
+
+ # exclude name in current arg
+ [[ ${(Q)words[CURRENT-1]} == -init_hw_device ]] &&
+ [[ ${i::=$IPREFIX$PREFIX} == *=* ]] &&
+ devices=( ${devices:#${${i%%[@:,]*}#*=}} )
- _call_program options $words[1] -h 2>/dev/null | while IFS=$'\n' read -r; do
- if [[ $REPLY == -* ]]; then
- [[ -n $lastopt ]] && _ffmpeg_register_lastopt_values
- lastopt=${REPLY%%[[:space:]]*}
- lastopt_description=${REPLY##-[^[:space:]]##[[:space:]]##}
- if [[ $lastopt_description == (#b)'<'(?##)'>'* ]]; then
- lastopt_type=$match[1]
- lastopt_description=${lastopt_description##<[^[:space:]]##>[[:space:]]##[^[:space:]]##[[:space:]]#}
- if [[ -z $lastopt_description ]]; then
- lastopt_description=$lastopt
- fi
- lastopt_description=${lastopt_description//:/\\:}
- elif [[ $lastopt_description == [^[:space:]]##[[:space:]][[:space:]]* ]]; then
- local example=${lastopt_description%% *}
- example=${example//:/\\:}
- lastopt_description=${lastopt_description##[^[:space:]]##[[:space:]]##}
- lastopt_description=${lastopt_description//:/\\:}
- if [[ $example == filename ]]; then
- lastopt_takesargs=0
- lastopt+=":${lastopt_description}:_files"
- elif [[ $lastopt == -[asv]pre ]]; then
- lastopt_takesargs=0
- lastopt="*$lastopt"
- lastopt+=": :_ffmpeg_presets"
- elif [[ $lastopt == -acodec ]]; then
- lastopt_takesargs=0
- lastopt+=": :_ffmpeg_acodecs"
- elif [[ $lastopt == -vcodec ]]; then
- lastopt_takesargs=0
- lastopt+=": :_ffmpeg_vcodecs"
- elif [[ $lastopt == -scodec ]]; then
- lastopt_takesargs=0
- lastopt+=": :_ffmpeg_scodecs"
- elif [[ $lastopt == -f ]]; then
- lastopt_takesargs=0
- lastopt="*$lastopt"
- lastopt+=": :_ffmpeg_formats"
- elif [[ $lastopt == -pix_fmt ]]; then
- lastopt_takesargs=0
- lastopt="*$lastopt"
- lastopt+=":set pixel format:_ffmpeg_pix_fmts"
- elif [[ $example == bitstream_filter ]]; then
- lastopt_takesargs=0
- lastopt+=": :_ffmpeg_bsfs"
- else
- lastopt_takesargs=1
- lastopt_description+=" ($example)"
- fi
- else
- lastopt_takesargs=0
- if [[ $lastopt == -vfilters ]]; then
- lastopt+=": :->vfilters"
- fi
- fi
- lastopt_values=()
- elif [[ $REPLY == ' '* ]]; then
- REPLY=${REPLY##[[:space:]]##}
- REPLY=${REPLY%%[[:space:]]##*}
- lastopt_takesargs=1
- lastopt_values+=$REPLY
- fi
+ _alternative -O ca_opts \
+ "$tag:$desc:( ${(j< >)${(@q+)devices}} )" \
+ "$tag:$desc:_ffmpeg_hwaccels -T"
+}
+
+# complete hardware devices init spec
+(( $+functions[_ffmpeg_hw_device_inits] )) ||
+_ffmpeg_hw_device_inits() {
+ local -a expl
+ if compset -P '*,*=' && [[ $PREFIX != *,* ]]; then
+ _wanted values expl 'device parameter value' _files -qS,
+ elif compset -P '*,'; then
+ _message 'device parameter (key=val)'
+ elif compset -P '*@'; then
+ _ffmpeg_hw_devices
+ elif compset -P '*:'; then
+ _wanted devices expl device _files -qS,
+ elif compset -P '*='; then
+ _message 'hardware device name'
+ else
+ _ffmpeg_hwaccels -T -qS=
+ fi
+}
+
+# complete input/output devices
+(( $+functions[_ffmpeg_devices] )) ||
+_ffmpeg_devices() {
+ local de=DE tag=devices desc=device
+ local -a ca_opts tmp devices
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \
+ D E \
+ || return
+
+ if (( ${+opth[-D]} )); then
+ de=D tag=input-$tag desc="input $desc"
+ elif (( ${+opth[-E]} )); then
+ de=E tag=output-$tag desc="output $desc"
+ fi
+
+ tmp=( ${(f)"$( _call_program devices $words[1] -devices )"} )
+ tmp=( ${(M)tmp:# [DE. ](#c2) [^=]* *} )
+
+ [[ $de == *D* ]] && devices+=( ${(M)tmp:# D? *} )
+ [[ $de == *E* ]] && devices+=( ${(M)tmp:# ?E *} )
+ devices=( ${devices# ?? } )
+
+ if zstyle -t ":completion:$curcontext:$tag" verbose; then
+ local f d
+ tmp=( ${${(@)devices//:/\\:}/[[:space:]]##/:} )
+ devices=( )
+ for f in $tmp; do
+ d=${f#*:} f=${f%%:*}
+ devices+=( ${^${(@s<,>)f}}:$d )
done
- [[ -n $lastopt ]] && _ffmpeg_register_lastopt_values
+ devices=( ${(u)devices} )
+
+ else
+ devices=( ${(@s<,>)${(@)devices%%[[:space:]]*}} )
+ fi
+
+ _describe -t $tag $desc devices "${(@)ca_opts}"
+}
+
+# complete disposition flags
+# -I => single disposition
+(( $+functions[_ffmpeg_dispositions] )) ||
+_ffmpeg_dispositions() {
+ local tag=dispositions desc='disposition flag'
+ local -a ca_opts expl dispositions
+ local -A opth
+
+ zparseopts -A opth -D -F - \
+ {1+,2+,F+:,J+:,M+:,n+,o+:,q+,r+:,R+:,s+:,S+:,V+:,x+:,X+:}=ca_opts \
+ I \
+ || return
+
+ dispositions=( ${(f)"$( _call_program $tag $words[1] -dispositions )"} )
+ dispositions=( ${dispositions:#*:*} )
+ dispositions=( ${dispositions##[[:space:]]##} )
+
+ if (( ${+opth[-I]} )); then
+ _describe -t $tag $desc dispositions "${(@)ca_opts}"
+ else
+ _wanted $tag expl $desc _ffmpeg_flags "${(@)ca_opts}" - $dispositions
+ fi
+}
+
+# complete stats format spec
+(( $+functions[_ffmpeg_stats_fmt_specs] )) ||
+_ffmpeg_stats_fmt_specs() {
+ local bs
+
+ compset -S '[{[[:space:]]*'
+ compset -P '*[}[[:space:]]'
+
+ [[ -n $compstate[quote] ]] || bs=\\
+
+ argv=( -r'}\-' -S"$bs}" "$@" )
+ compset -P '*{' || argv=( -P"$bs{" "$@" )
+
+ _describe -t stats-format-spec-directives 'stats format spec directive' '(
+ fidx:"index of output file"
+ sidx:"index of output stream in file"
+ n:"frame number"
+ ni:"input frame number"
+ tb:"time base for time stamps of frame/packet"
+ tbi:"timebase for ptsi"
+ pts:"presentation time stamp of frame/packet"
+ ptsi:"presentation time stamp of input frame (ni)"
+ t:"presentation time of frame/packet"
+ ti:"presentation time of input frame (ni)"
+ dts:"decoding time stamp of packet"
+ dt:"decoding time of frame/packet (dts*tb)"
+ sn:"number of audio samples sent to encoder"
+ samp:"number of audio samples in frame"
+ size:"size of packet (bytes)"
+ br:"current bit rate (bps)"
+ abr:"average bit rate of whole stream (bps)"
+ key:"K if packet contains key frame, N otherwise"
+ )' "$@"
+}
+
+# complete vsync method / frame-rate mode
+(( $+functions[_ffmpeg_fps_modes] )) ||
+_ffmpeg_fps_modes() {
+ _describe -t fps-modes 'frame-rate mode [auto]' '(
+ passthrough:"pass through frames unmodified"
+ cfr:"duplicate or drop frames to achieve constant frame rate"
+ vfr:"pass through or drop frames to achieve variable frame rate"
+ auto:"choose cfr or vfr based on muxer capabilities"
+ )' "$@"
+}
+
+# complete video-size abbreviation
+(( $+functions[_ffmpeg_video_sizes] )) ||
+_ffmpeg_video_sizes() {
+ _describe -t video-sizes 'video size abbreviation (or WxH)' '(
+ ntsc:720x480 pal:720x576 qntsc:352x240 qpal:352x288
+ sntsc:640x480 spal:768x576 film:352x240 ntsc-film:352x240
+ sqcif:128x96 qcif:176x144 cif:352x288 4cif:704x576
+ 16cif:1408x1152 qqvga:160x120 qvga:320x240 vga:640x480
+ svga:800x600 xga:1024x768 uxga:1600x1200 qxga:2048x1536
+ sxga:1280x1024 qsxga:2560x2048 hsxga:5120x4096 wvga:852x480
+ wxga:1366x768 wsxga:1600x1024 wuxga:1920x1200 woxga:2560x1600
+ wqsxga:3200x2048 wquxga:3840x2400 whsxga:6400x4096
+ whuxga:7680x4800 cga:320x200 ega:640x350 hd480:852x480
+ hd720:1280x720 hd1080:1920x1080 2k:2048x1080 2kflat:1998x1080
+ 2kscope:2048x858 4k:4096x2160 4kflat:3996x2160
+ 4kscope:4096x1716 nhd:640x360 hqvga:240x160 wqvga:400x240
+ fwqvga:432x240 hvga:480x320 qhd:960x540 2kdci:2048x1080
+ 4kdci:4096x2160 uhd2160:3840x2160 uhd4320:7680x4320
+ )' "$@"
}
-_arguments -C -S \
- "${_ffmpeg_argspecs[@]}" \
- '*:output file:_files' \
- && return
+# complete map data source
+(( $+functions[_ffmpeg_map_sources] )) ||
+_ffmpeg_map_sources() {
+ compset -P -
+
+ if compset -P '*:view:'; then
+ _message 'view ID'
+ elif compset -P '*:vidx:'; then
+ _message 'view index'
+ elif compset -P '*:vpos:'; then
+ _describe -t view-positions 'view position' '(left right)'
+ elif compset -P 1 '*:'; then
+ local ret=1
+ # this isn't quite right
+ compset -P '<->:' ||
+ compset -P '[astvV](:(?|[\\#]##[^:]##))#:' ||
+ compset -P 'g:(i:|)[\\#]#[^:]##:' ||
+ compset -P 'p:[^:]##(|:(?|[\\#]##[^:]##))#:' ||
+ compset -P '([\\#]##|i:)[^:]##:' ||
+ compset -P 'm:[^:]##:' || # how can this have a value here?
+ compset -P 'disp:[^:]##:' ||
+ compset -P u:
+ _ffmpeg_stream_specs -qS: && ret=0
+ _describe -t view-specifiers 'view specifier' '(
+ view:"view ID"
+ vidx:"view index"
+ vpos:"view position"
+ )' -qS: && ret=0
+ return ret
+ else
+ _message \
+ 'map source ([-]input_file_id[:stream_specifier][:view_specifier][:?])'
+ fi
+}
+
+# complete program spec
+(( $+functions[_ffmpeg_program_specs] )) ||
+_ffmpeg_program_specs() {
+ local x
+ local -a kvs keys=(
+ 'title:program title'
+ 'program_num:program number'
+ 'st:stream index'
+ )
+ for x in $keys; do
+ kvs+=( "${x%%:*}[${${x#*:}%%:*}]:${x#*:}" )
+ done
+
+ # it doesn't seem like these need to be given in order
+ compset -P '*:'
+ _values -s: -S= 'program specifier (key=val:key=val:...)' $kvs
+}
+
+# complete stream-group spec
+(( $+functions[_ffmpeg_stream_group_specs] )) ||
+_ffmpeg_stream_group_specs() {
+ local x
+ local -a kvs keys=(
+ 'map:input-group mapping'
+ 'type:stream-group type:( iamf_audio_element iamf_mix_presentation )'
+ 'st:stream index'
+ 'stg:stream group'
+ 'id:stream-group ID'
+ )
+ for x in $keys; do
+ kvs+=( "${x%%:*}[${${x#*:}%%:*}]:${x#*:}" )
+ done
+
+ # @todo we should complete these. it's annoying because some use ':' for their
+ # own values
+ compset -P '*,' && {
+ _message 'type option'
+ return
+ }
+
+ # it doesn't seem like these need to be given in order. except maybe the type
+ # options?
+ compset -P '*:'
+ _values -s: -S= 'stream-group specifier (key=val:key=val:...)' $kvs
+}
+
+# complete key-frame force condition
+(( $+functions[_ffmpeg_kf_force_conds] )) ||
+_ffmpeg_kf_force_conds() {
+ if compset -P expr:; then
+ _message expression
+ elif compset -P '*[0-9,]*'; then
+ _message 'time stamps (time[,time...])'
+ else
+ _describe -t kf-force-conditions 'when to force key frame (or time stamps)' \
+ '(
+ source:"when source frame is marked as key frame"
+ scd_metadata:"when frame has metadata entry lavfi.scd.time"
+ )' \
+ -- \
+ '( expr:"when evaluated expression is non-zero" )' -r: -S:
+ fi
+}
+
+# complete log-level flag
+(( $+functions[_ffmpeg_loglevels] )) ||
+_ffmpeg_loglevels() {
+ local -a levels=(
+ quiet panic fatal error warning info verbose debug trace
+ )
+ compset -P "(|*+)(${(j<|>)${(@b)levels}})" && return
+ _alternative \
+ "levels:logging level:_ffmpeg_flags - ${(j< >)${(@q+)levels}}" \
+ 'flags: :_ffmpeg_flags - repeat level time datetime'
+}
+
+# complete date spec
+(( $+functions[_ffmpeg_dates] )) ||
+_ffmpeg_dates() {
+ _message -e dates \
+ 'date ([(YYYY-MM-DD|YYYYMMDD)[T|t| ]]((HH:MM:SS[.m]]])|(HHMMSS[.m]]]))[Z]) (or now)'
+}
+
+# complete duration spec
+(( $+functions[_ffmpeg_durations] )) ||
+_ffmpeg_durations() {
+ _message -e durations 'duration ([-][HH:]MM:SS[.m] or [-]S+[.m][s|ms|us])'
+}
+
+# complete compare functions
+(( $+functions[_ffmpeg_cmp_functions] )) ||
+_ffmpeg_cmp_functions() {
+ _describe -t compare-functions 'compare function' '(
+ sad sse satd dct psnr bit rd zero vsad vsse nsse w53 w97 dctmax
+ chroma msad
+ )' "$@"
+}
+
+# complete frame discard methods
+(( $+functions[_ffmpeg_discard_methods] )) ||
+_ffmpeg_discard_methods() {
+ _describe -t discard-methods 'frame discard method' '(
+ none:"no frames"
+ default:"useless frames"
+ noref:"non-reference frames"
+ bidir:"bi-directional frames"
+ nointra:"all except I frames"
+ nokey:"all except key frames"
+ all:"all frames"
+ )' "$@"
+}
+
+# complete -help topic
+(( $+functions[_ffmpeg_help_topics] )) ||
+_ffmpeg_help_topics() {
+ if compset -P decoder=; then
+ _ffmpeg_codecs -D
+ elif compset -P encoder=; then
+ _ffmpeg_codecs -E
+ elif compset -P demuxer=; then
+ _ffmpeg_formats -D
+ elif compset -P muxer=; then
+ _ffmpeg_formats -E
+ elif compset -P filter=; then
+ _ffmpeg_filters
+ elif compset -P bsf=; then
+ _ffmpeg_bsfs -I
+ elif compset -P protocol=; then
+ _ffmpeg_protocols
+ else
+ _describe -t help-topics 'help topic' \
+ '(
+ long:"basic and advanced tool options"
+ full:"all options"
+ )' \
+ -- \
+ '(
+ decoder:"specified decoder"
+ encoder:"specified encoder"
+ demuxer:"specified demuxer"
+ muxer:"specified muxer"
+ filter:"specified filter"
+ bsf:"specified bitstream filter"
+ protocol:"specified protocol"
+ )' -r= -S=
+ fi
+}
+
+local MATCH MBEGIN MEND x y z no
+local -a ss_opts ms_opts basic_opts expert_opts gen_avo_opts opts tmp
+
+# names of options that support optional :stream_specifier form
+ss_opts=(
+ ac apad apply_cropping ar aspect autorotate autoscale b
+ bits_per_raw_sample bsf c canvas_size ch_layout channel_layout
+ chroma_intra_matrix codec copyinkf copypriorss discard
+ display_hflip display_rotation display_vflip disposition
+ drop_changed dump_attachment enc_time_base filter filter_script
+ fix_sub_duration fix_sub_duration_heartbeat force_fps
+ force_key_frames fps_mode fpsmax frames guess_layout_max hwaccel
+ hwaccel_device hwaccel_output_format inter_matrix intra_matrix
+ itsscale max_muxing_queue_size muxing_queue_data_threshold pass
+ passlogfile pix_fmt pre q qscale r rc_override reinit_filter s
+ sample_fmt stats_enc_post stats_enc_post_fmt stats_enc_pre
+ stats_enc_pre_fmt stats_mux_pre stats_mux_pre_fmt tag threads
+ time_base top
+)
+
+# names of options that support optional :metadata_specifier form
+ms_opts=( metadata map_metadata )
+
+# option specs are grouped and ordered per `ffmpeg -help full` output. the
+# separate arrays probably aren't necessary, but i was keeping track of it
+# anyway, and maybe it'll be useful in the future
+
+# note: in order for the replacements below to work reliably, all specs must
+# have descriptions ('-o[desc]'), and colons must not be omitted after optarg
+# descriptions: '-o[desc]:argdesc:', NOT '-o[desc]:argdesc'
+
+# basic information/capability options
+basic_opts+=(
+ '(- : *)'{-L,-license}'[display licence information]'
+ '(- : *)'{-h,-help,--help}'[display help information]:: :_ffmpeg_help_topics'
+ '!(- : *)-?[]:: :_ffmpeg_help_topics' # annoying
+ '(- : *)-version[display version information]'
+ '(- : *)-muxers[display available muxers]'
+ '(- : *)-demuxers[display available demuxers]'
+ '(- : *)-devices[display available devices]'
+ '(- : *)-decoders[display available decoders]'
+ '(- : *)-encoders[display available encoders]'
+ '(- : *)-filters[display available filters]'
+ '(- : *)-pix_fmts[display available pixel formats]'
+ '(- : *)-layouts[display channel names and standard channel layouts]'
+ '(- : *)-sample_fmts[display available sample formats]'
+)
+# advanced information/capability options
+expert_opts+=(
+ '(- : *)-buildconf[display build configuration]'
+ '(- : *)-formats[display available formats]'
+ '(- : *)-codecs[display available codecs]'
+ '(- : *)-bsfs[display available bitstream filters]'
+ '(- : *)-protocols[display available protocols]'
+ '(- : *)-dispositions[display stream dispositions]'
+ '(- : *)-colors[display recognised colours]'
+ '(- : *)-sources[display input sources (specify device)]:: :{
+ compset -S ",*"
+ if compset -P "*,"; then
+ _message "input device option (opt1=val1,opt2=val2,...)"
+ else
+ _ffmpeg_devices -D -qS,
+ fi
+ }'
+ '(- : *)-sinks[display output sinks (specify device)]:: :{
+ compset -S ",*"
+ if compset -P "*,"; then
+ _message "output device option (opt1=val1,opt2=val2,...)"
+ else
+ _ffmpeg_devices -E -qS,
+ fi
+ }'
+ '(- : *)-hwaccels[display available hardware-acceleration methods]'
+)
+# basic global options
+basic_opts+=(
+ '(-v -loglevel)'{-v,-loglevel}'[set logging level]: :_ffmpeg_loglevels'
+ '(-n)-y[overwrite output files without asking]'
+ '(-y)-n[never overwrite output files]'
+ '-print_graphs[print execution graph data to stderr]'
+ '-print_graphs_file[write execution graph data to specified file]:execution graph file:_files'
+ '-print_graphs_format[specify execution graph format]:execution graph format:(
+ default compact csv flat ini json xml mermaid mermaidhtml
+ )'
+ '-stats[print encoding progress and statistics]'
+)
+# advanced global options
+expert_opts+=(
+ '-report[generate report]'
+ '-max_alloc[specify heap allocation size limit]: :\
+ _ffmpeg_numbers -u bytes "max heap allocation block size"
+ '
+ # we could check these against $MACHTYPE but i don't think it matters
+ '-cpuflags[specify CPU flags]:CPU flag:_ffmpeg_flags - \
+ mmx mmxext \
+ sse sse2 sse2slow sse3 sse3slow ssse3 sse4.1 sse4.2 \
+ atom \
+ avx avx2 \
+ xop \
+ fma3 fma4 \
+ 3dnow 3dnowext \
+ bmi1 bmi2 \
+ cmov \
+ pentium2 pentium3 pentium4 k6 k62 athlon athlonxp k8 \
+ armv5te armv6 armv6t2 vfp vfpv3 neon setend \
+ armv8 vfp neon \
+ altivec
+ '
+ '-cpucount[specify CPU count]: :_ffmpeg_numbers "CPU count"'
+ '-hide_banner[suppress banner]'
+ '(-copy_unknown)-ignore_unknown[ignore unknown stream types]'
+ '(-ignore_unknown)-copy_unknown[copy unknown stream types]'
+ '-recast_media[allow forcing decoder of different media type]'
+ '-benchmark[show benchmark information at end of encode]'
+ '-benchmark_all[show benchmark information during encode]'
+ '-progress[write progress information to specified URL]: :{
+ if compset -P pipe\:; then
+ _describe "file descriptor" "(0 1 2)"
+ else
+ _alternative "urls\: \:_urls" "files\: \:_files"
+ fi
+ }'
+ '-stdin[enable interaction on standard input]'
+ '-timelimit[specify max run time]: :\
+ _ffmpeg_numbers -u seconds "max CPU user time"
+ '
+ '-dump[dump each input packet to stderr]'
+ '-hex[also dump payload (with -dump)]'
+ '-frame_drop_threshold[specify frame-drop threshold]: :\
+ _ffmpeg_numbers -u frames -N -d-1.1 "frame-drop threshold"
+ '
+ '-copyts[copy timestamps]'
+ '-start_at_zero[shift input timestamps to start at 0 (with -copyts)]'
+ '-copytb[specify how to set encoder time base when copying stream]:mode:((
+ -1\:"decide automatically"
+ 0\:"use decoder time base"
+ 1\:"use demuxer time base"
+ ))'
+ '-dts_delta_threshold[specify timestamp discontinuity delta threshold]: :\
+ _ffmpeg_numbers -u seconds -d10 "timestamp discontinuity delta threshold"
+ '
+ '-dts_error_threshold[specify timestamp error delta threshold]: :\
+ _ffmpeg_numbers -u seconds -d108000 "timestamp error delta threshold"
+ '
+ '-xerror[exit on error]'
+ '-abort_on[abort on specified condition flags]:condition flag:\
+ _ffmpeg_flags - empty_output empty_output_stream
+ '
+ '-filter_threads[specify number of threads used for each filter pipeline]: :\
+ _ffmpeg_numbers threads
+ '
+ '-filter_buffered_frames[specify max buffered frames in a filtergraph]: :\
+ _ffmpeg_numbers -d0 "max buffered frames"
+ '
+ '*'{-filter_complex,-lavfi}'[define specified complex filtergraph]: :_ffmpeg_filtergraphs'
+ '-filter_complex_threads[specify number of threads used for each complex filtergraph]: :\
+ _ffmpeg_numbers threads
+ '
+ '!*-filter_complex_script[]:-filter_complex script:_files' # deprecated
+ '-auto_conversion_filters[enable automatic conversion filters globally]'
+ '-stats_period[specify progress/statistics update interval]: :\
+ _ffmpeg_numbers -u seconds -d0.5 "update interval"
+ '
+ '-debug_ts[print timestamp/latency information]'
+ '-max_error_rate[specify max decoding error ratio]: :\
+ _ffmpeg_numbers -l0 -m1 -d0.67 "max decoding error ratio"
+ '
+ '-sdp_file[write sdp information to specified file]:sdp file:_files'
+ '*-init_hw_device[initialise specified hardware device]: :_ffmpeg_hw_device_inits'
+ '-filter_hw_device[specify hardware device for filtering]: :_ffmpeg_hw_devices'
+ '!-adrift_threshold[]:threshold:' # deprecated
+ '!-qphist[]' # deprecated
+ # deprecated in favour of -fps_mode, but still used in documentation, so no !
+ '-vsync[specify video sync method globally]: :_ffmpeg_fps_modes'
+)
+# basic per-file options (input and output)
+basic_opts+=(
+ '*-f[force specified container format]: :_ffmpeg_formats'
+ '*-t[stop after specified duration]: :_ffmpeg_durations'
+ '*-to[stop at specified time]: :_ffmpeg_durations'
+ '*-ss[start at specified time]: :_ffmpeg_durations'
+)
+# advanced per-file options (input and output)
+expert_opts+=(
+ '*-bitexact[enable bitexact mode]'
+ '*-thread_queue_size[specified max queued packets for demuxer]: :\
+ _ffmpeg_numbers "max queued packets"
+ '
+)
+# advanced per-file options (input only)
+expert_opts+=(
+ '*-sseof[start at specified time relative to EOF]: :_ffmpeg_durations'
+ '*-seek_timestamp[seek by timestamp (with -ss/-sseof)]'
+ '*-accurate_seek[enable accurate seeking (with -ss/-sseof)]'
+ '*-isync[specify input index for sync reference]: :\
+ _ffmpeg_numbers -N -d-1 "input index"
+ '
+ '*-itsoffset[specify input time offset]: :_ffmpeg_durations'
+ '*-re[read input at native frame rate (like -readrate 1)]'
+ '*-readrate[specify input read speed limit]: :\
+ _ffmpeg_numbers -u seconds -l0 -d0 "max input read duration per 1s of wall time"
+ '
+ '*-readrate_initial_burst[specify initial read burst time (with -readrate)]: :\
+ _ffmpeg_numbers -u seconds "initial read burst time"
+ '
+ '*-readrate_catchup[specify catch-up read speed limit if blocked (with -readrate)]: :\
+ _ffmpeg_numbers -u seconds "max input read duration per 1s of wall time"
+ '
+ '*-dump_attachment[extract matching attachment into specified file]:attachment output file:_files'
+ '*-stream_loop[specify number of times to loop input stream]: :\
+ _ffmpeg_numbers -N -d0 "input-stream loops"
+ '
+ '*-find_stream_info[decode streams to fill missing info with heuristics]'
+)
+# basic per-file options (output only)
+basic_opts+=(
+ '*-metadata[add specified metadata to output]:metadata key=value:'
+)
+# advanced per-file options (output only)
+expert_opts+=(
+ '*-map[specify stream mapping from input to output]: :_ffmpeg_map_sources'
+ '*-map_metadata[set metadata mapping from input to output]: :{
+ if compset -P 1 "*\:"; then
+ _ffmpeg_metadata_specs
+ else
+ _message "input file index[\:metadata specifier]"
+ fi
+ }'
+ '*-map_chapters[specify chapter mapping from input to output]: :\
+ _ffmpeg_numbers -N "input index"
+ '
+ '*-fs[specify output file size limit]: :\
+ _ffmpeg_numbers -u bytes "output file size limit"
+ '
+ '*-timestamp[specify recording timestamp]: :_ffmpeg_dates'
+ '*-program[add program with specified streams]: :_ffmpeg_program_specs'
+ '*-stream_group[add stream group with specified streams]: :_ffmpeg_stream_group_specs'
+ '*-dframes[specify max data frames to output (-like -frames\:d)]: :\
+ _ffmpeg_numbers "max data frames"
+ '
+ '*-target[specify target file type]:file type:(
+ {film-,ntsc-,pal-,}{vcd,svcd,dvd,dv,dv50}
+ )'
+ '*-shortest[finish encoding when shortest output stream ends]'
+ '*-shortest_buf_duration[specify buffer duration for -shortest]: :\
+ _ffmpeg_numbers -u seconds -d10 "max duration of buffered frames"
+ '
+ '*'{-q,-qscale}'[specify VBR quality]: :\
+ _ffmpeg_numbers "quality scale value"
+ '
+ # this is codec-specific, but here are some we know about
+ '*-profile[specify codec profile]:codec profile:(
+ # avcodeccontext
+ unknown main10
+ # dnxhd
+ dnxhd dnxhr_444 dnxhr_hqx dnxhr_hq dnxhr_sq dnxhr_lb
+ # prores
+ auto proxy lt standard hq 4444 4444xq
+ # x264
+ baseline main high high10 high422 high444
+ # h264 videotoolbox
+ baseline constrained_baseline main high constrained_high extended
+ # hevc videotoolbox
+ main main10 main42210 rext
+ # prores videotoolbox
+ auto proxy lt standard hq 4444 xq
+ )'
+ '*-attach[add attachment]:file to attach:_files'
+ '*-muxdelay[specify max demux-decode delay]: :\
+ _ffmpeg_numbers -u seconds "max demux-decode delay"
+ '
+ '*-muxpreload[specify initial demux-decode delay]: :\
+ _ffmpeg_numbers -u seconds "demux-decode delay"
+ '
+ '*-fpre[set options from specified preset file]:preset file:_files' \
+)
+# basic per-stream options
+basic_opts+=(
+ '*'{-c,-codec}'[specify encoder or decoder]: :_ffmpeg_codecs'
+ '*-filter[apply specified filtergraph]: :_ffmpeg_filtergraphs'
+)
+# advanced per-stream options
+expert_opts+=(
+ '*-pre[specify preset]: :_ffmpeg_presets'
+ '*-itsscale[specify input timestamp scale]: :_ffmpeg_numbers scale'
+ '*-copyinkf[copy initial non-key frames]'
+ '*-copypriorss[copy or discard frames before start time]'
+ '*-frames[specify max frames to output]: :\
+ _ffmpeg_numbers "max frames"
+ '
+ # there are hundreds of these so i'm not sure it makes sense to complete them
+ '*-tag[force specified codec tag/fourcc]:codec fourcc:'
+ '!*-filter_script[]:-filter script:_files' # deprecated
+ '*-reinit_filter[specify whether to re-initialise filtergraph on input parameter change]:re-initialise mode:((
+ 0\:disabled
+ 1\:enabled
+ ))'
+ '*-drop_changed[specify whether to drop frame on input parameter change]:drop mode:((
+ 0\:disabled
+ 1\:enabled
+ ))'
+ '*-discard[specify frames to discard]: :_ffmpeg_discard_methods'
+ '*-disposition[specify disposition flags]: :_ffmpeg_dispositions'
+ '*-bits_per_raw_sample[specify bits per raw sample]: :\
+ _ffmpeg_numbers "bits per raw sample"
+ '
+ '*-stats_enc_pre[write pre-encoding frame stats to specified file]:stats file:_files'
+ '*-stats_enc_post[write post-encoding frame stats to specified file]:stats file:_files'
+ '*-stats_mux_pre[write pre-muxing frame stats to specified file]:stats file:_files'
+ '*-stats_enc_pre_fmt[specify format for -stats_enc_pre]: :_ffmpeg_stats_fmt_specs'
+ '*-stats_enc_post_fmt[specify format for -stats_enc_post]: :_ffmpeg_stats_fmt_specs'
+ '*-stats_mux_pre_fmt[specify format for -stats_mux_pre]: :_ffmpeg_stats_fmt_specs'
+ '*-time_base[specify time base for output stream]:time base (num\:den or float):'
+ '*-enc_time_base[specify time base for encoder]:encoder time base (or num\:den or float):((
+ 0\:"assign default value according to media type"
+ demux\:"use time base from demuxer"
+ filter\:"use time base from filtergraph"
+ ))'
+ '*-bsf[specify bitstream filters]: :_ffmpeg_bsfs'
+ '*-max_muxing_queue_size[specify max packets in muxing queue]: :\
+ _ffmpeg_numbers "max packets in muxing queue"
+ '
+ '*-muxing_queue_data_threshold[specify minimum threshold for -max_muxing_queue_size]: :\
+ _ffmpeg_numbers -u bytes -d50M "minimum threshold for muxing queue size"
+ '
+)
+# basic video options
+basic_opts+=(
+ '*-r[specify frame rate]: :\
+ _ffmpeg_numbers -u "Hz, fraction, or abbreviation" "frame rate"
+ '
+ '*-aspect[specify aspect ratio]: :\
+ _ffmpeg_numbers -u "float or num:den" "aspect ratio"
+ '
+ '*-vn[disable video]'
+ '*-vcodec[force specified video codec (like -c\:v)]: :_ffmpeg_codecs -Tv'
+ '*-vf[apply specified filtergraph to video (like -filter\:v)]: :_ffmpeg_filtergraphs'
+ # this is actually not a video option, it has to be used like -b:a or -b:v.
+ # but this is where it's listed in the help output
+ '*-b[specify bit rate]: :_ffmpeg_numbers -u bps "bit rate"'
+ # this isn't in the help output for some reason
+ '*-s[specify video frame size]: :_ffmpeg_video_sizes'
+)
+# advanced video options
+expert_opts+=(
+ '*-vframes[specify max video frames to output (like -frames\:v)]: :\
+ _ffmpeg_numbers "max video frames"
+ '
+ '*-fpsmax[specify max video frame rate]: :\
+ _ffmpeg_numbers -u "Hz, fraction, or abbreviation" "frame rate"
+ '
+ '*-pix_fmt[specify pixel format]: :_ffmpeg_pix_fmts'
+ '*-display_rotation[specify video rotation]: :\
+ _ffmpeg_numbers -u degrees "anti-clockwise video rotation"
+ '
+ '*-display_hflip[flip video horizontally]'
+ '*-display_vflip[flip video vertically]'
+ '*-rc_override[specify rate-control override]:rate control (beg,end,quant):'
+ '*-timecode[specify timecode]:timecode (hh\:mm\:ss[\:;.]ff)'
+ '*-pass[specify pass number for two-pass video encoding]:pass:(1 2)'
+ '*-passlogfile[specify two-pass log-file prefix]:log-file prefix [ffmpeg2pass]:'
+ '*-intra_matrix[specify intra quantisation matrix]:intra quantisation matrix:'
+ '*-inter_matrix[specify inter quantisation matrix]:inter quantisation matrix:'
+ '*-chroma_intra_matrix[specify chroma intra quantisation matrix]:intra quantisation matrix:'
+ '*-vtag[force specified video codec tag/fourcc (like -tag\:v)]:video codec fourcc:'
+ '*-fps_mode[specify frame-rate mode]: :_ffmpeg_fps_modes'
+ '*-force_fps[force selected frame rate]'
+ '*-streamid[specify stream identifier]:output-stream-index\:new-value:'
+ '*-force_key_frames[force key frames at specified timestamps]: :_ffmpeg_kf_force_conds'
+ '*-hwaccel[specify hardware acceleration for decoding]: :_ffmpeg_hwaccels'
+ '*-hwaccel_device[specify hardware-acceleration device (with -hwaccel)]: :_ffmpeg_hw_devices'
+ '*-hwaccel_output_format[specify hardware-acceleration output format (with -hwaccel)]: :_ffmpeg_pix_fmts -H'
+ '*-autorotate[automatically rotate video]'
+ '*-autoscale[automatically scale video]'
+ '*-apply_cropping[automatically crop video using specified method]:crop method [all]:((
+ none\:"don'\''t apply cropping"
+ all\:"apply codec- and container-level cropping"
+ codec\:"apply codec-level cropping"
+ container\:"apply container-level cropping"
+ ))'
+ '*-fix_sub_duration_heartbeat[set stream as heartbeat stream (with -fix_sub_duration)]'
+ '*-vpre[specify video preset]: :_ffmpeg_presets'
+ '!*-top[]:top:' # deprecated
+)
+# basic audio options
+basic_opts+=(
+ '*-aq[specify audio VBR quality (like -q\:a)]: :\
+ _ffmpeg_numbers "quality scale value"
+ '
+ '*-ar[specify audio sampling rate]: :\
+ _ffmpeg_numbers -u Hz "audio sampling rate"
+ '
+ '*-ac[specify number of audio channels]: :\
+ _ffmpeg_numbers "audio channels"
+ '
+ '*-an[disable audio]'
+ '*-acodec[force specified audio codec (like -c\:a)]: :_ffmpeg_codecs -Ta'
+ '*-ab[specify audio bit rate]: :_ffmpeg_numbers -u bps "audio bit rate"'
+ '*-af[apply specified filtergraph to audio (like -filter\:a)]: :_ffmpeg_filtergraphs'
+)
+# advanced audio options
+expert_opts+=(
+ '*-aframes[specify max audio frames to output (like -frames\:a)]: :\
+ _ffmpeg_numbers "max audio frames"
+ '
+ '*-apad[pad audio stream with specified parameters (like -af apad) (with -shortest)]:apad filter parameters ([key=]val\:[key=]val\:...):'
+ '*-atag[force specified audio codec tag/fourcc (like -tag\:a)]:audio codec fourcc:'
+ '*-sample_fmt[specify audio sample format]: :_ffmpeg_sample_fmts'
+ '*'{-channel_layout,-ch_layout}'[specify audio channel layout]: :_ffmpeg_layouts'
+ '*-guess_layout_max[specify max channels for guessing channel layout]: :\
+ _ffmpeg_numbers "max audio channels"
+ '
+ '*-apre[specify audio preset]: :_ffmpeg_presets'
+)
+# basic subtitle options
+basic_opts+=(
+ '*-sn[disable subtitles]'
+ '*-scodec[force specified subtitle codec (like -c\:s)]: :_ffmpeg_codecs -Ts'
+)
+# advanced subtitle options
+expert_opts+=(
+ '*-stag[force specified subtitle codec tag/fourcc (like -tag\:s)]:subtitle codec fourcc:'
+ '*-fix_sub_duration[fix subtitle durations]'
+ '*-canvas_size[specify size of canvas for rendering subtitles]: :_ffmpeg_video_sizes'
+ '*-spre[specify subtitle preset]: :_ffmpeg_presets'
+)
+# basic data-stream options
+basic_opts+=(
+ '*-dcodec[force specified data codec (like -c\:d)]: :_ffmpeg_codecs -Td'
+ '*-dn[disable data]'
+)
+# generic codec AVOptions. my assumption is that these are rarely used, so i
+# haven't put much effort into them
+gen_avo_opts+=(
+ '!*-bt[]: :_ffmpeg_numbers -u bps "bit-rate tolerance"'
+ '!*-flags[]: :_ffmpeg_flags - \
+ unaligned mv4qpel loop gray psnr ildct low_delay global_header \
+ bitexact aic ilme cgop output_corrupt
+ '
+ '!*-flags2[]: :_ffmpeg_flags - \
+ fast noout ignorecrop local_header chunks showall export_mvs \
+ skip_manual ass_ro_flush_noop icc_profiles
+ '
+ '!*-export_side_data[]: :_ffmpeg_flags - \
+ mvs prft venc_params film_grain enhancements
+ '
+ '*-g[specify GOP (group of pictures) length]: :\
+ _ffmpeg_numbers -u frames "GOP length"
+ '
+ '*-cutoff[specify audio cut-off frequency]: :\
+ _ffmpeg_numbers -u Hz "cut-off frequency"
+ '
+ '*-frame_size[specify audio frame size]: :\
+ _ffmpeg_numbers -u samples/channel "frame size"
+ '
+ '!*-qcomp[]:float:'
+ '!*-qblur[]:float:'
+ '!*-qmin[]:int:'
+ '!*-qmax[]:int:'
+ '!*-qdiff[]:int:'
+ '!*-bf[]:int:'
+ '!*-b_qfactor[]:float:'
+ '!*-bug[]: :_ffmpeg_flags - \
+ autodetect xvid_ilace ump4 no_padding amv qpel_chroma std_qpel \
+ qpel_chroma2 direct_blocksize edge hpel_chroma dc_clip ms trunc \
+ iedge
+ '
+ '*-strict[specify how strictly to follow standards]:strictness level:(
+ very strict normal unofficial experimental
+ )'
+ '!*-b_qoffset[]:float:'
+ '!*-err_detect[]: :_ffmpeg_flags - \
+ crccheck bitstream buffer explode ignore_err careful compliant
+ aggressive
+ '
+ '!*-maxrate[]:int64:'
+ '!*-minrate[]:int64:'
+ '!*-bufsize[]:int:'
+ '!*-i_qfactor[]:float:'
+ '!*-i_qoffset[]:float:'
+ '!*-lumi_mask[]:float:'
+ '!*-tcplx_mask[]:float:'
+ '!*-scplx_mask[]:float:'
+ '!*-p_mask[]:float:'
+ '!*-dark_mask[]:float:'
+ '!*-dct[]:algorithm:(auto fastint int mmx altivec faan neon)'
+ '!*-idct[]:algorithm:(
+ auto int simple simplemmx arm altivec simplearm simplearmv5te
+ simplearmv6 simpleneon xvid xvidmmx faani simpleauto
+ )'
+ '!*-ec[]: :_ffmpeg_flags - guess_mvs deblock favor_inter'
+ '!*-sar[]:rational:'
+ '!*-debug[]: :_ffmpeg_flags - \
+ pict rc bitstream mb_type qp dct_coeff green_metadata skip \
+ startcode er mmco bugs buffers thread_ops nomc
+ '
+ '!*-dia_size[]:int:'
+ '!*-last_pred[]:int:'
+ '!*-pre_dia_size[]:int:'
+ '!*-subq[]:int:'
+ '!*-me_range[]:int:'
+ '!*-global_quality[]:int:'
+ '!*-mdb[]:macroblock decision algorithm [simple]:(simple bits rd)'
+ '!*-rc_init_occupancy[]:int:'
+ '*-threads[specify number of threads to use]: :\
+ _ffmpeg_numbers -d1 "threads (or auto)"
+ '
+ '!*-dc[]:int:'
+ '!*-nssew[]:int:'
+ '!*-skip_top[]:int:'
+ '!*-skip_bottom[]:int:'
+ '!*-level[]:int:'
+ '!*-lowres[]:int:'
+ '!*-cmp[]: :_ffmpeg_cmp_functions'
+ '!*-subcmp[]: :_ffmpeg_cmp_functions'
+ '!*-mbcmp[]: :_ffmpeg_cmp_functions'
+ '!*-ildctcmp[]: :_ffmpeg_cmp_functions'
+ '!*-precmp[]: :_ffmpeg_cmp_functions'
+ '!*-mblmin[]:int:'
+ '!*-mblmax[]:int:'
+ '!*-skip_loop_filter[]: :_ffmpeg_discard_methods'
+ '!*-skip_idct[]: :_ffmpeg_discard_methods'
+ '!*-skip_frame[]: :_ffmpeg_discard_methods'
+ '!*-bidir_refine[]:int:'
+ '!*-keyint_min[]:int:'
+ '!*-refs[]:int:'
+ '!*-trellis[]:int:'
+ '!*-mv0_threshold[]:int:'
+ '!*-compression_level[]:int:'
+ '!*-rc_max_vbv_use[]:float:'
+ '!*-rc_min_vbv_use[]:float:'
+ '!*-color_primaries[]:colour primary [unknown]:(
+ bt709 unknown bt470m bt470bg smpte170m smpte240m film bt2020
+ smpte428 smpte428_1 smpte431 smpte432 jedec-p22 ebu3213
+ unspecified
+ )'
+ '!*-color_trc[]:colour transfer characteristic [unknown]:(
+ bt709 unknown gamma22 gamma28 smpte170m smpte240m linear log100
+ log316 iec61966-2-4 bt1361e iec61966-2-1 bt2020-10 bt2020-12
+ smpte2084 smpte428 arib-std-b67 unspecified log log_sqrt
+ iec61966_2_4 bt1361 iec61966_2_1 bt2020_10bit bt2020_12bit
+ smpte428_1
+ )'
+ '!*-colorspace[]:colour space [unknown]:(
+ rgb bt709 unknown fcc bt470bg smpte170m smpte240m ycgco bt2020nc
+ bt2020c smpte2085 chroma-derived-nc chroma-derived-c ictcp ipt-c2
+ unspecified ycocg ycgco-re ycgco-ro bt2020_ncl bt2020_cl
+ )'
+ '!*-color_range[]:colour range [unknown]:(
+ unknown tv pc unspecified mpeg jpeg limited full
+ )'
+ '!*-chroma_sample_location[]:sample location [unknown]:(
+ unknown left center topleft top bottomleft bottom unspecified
+ )'
+ '!*-alpha_mode[]:alpha mode [unknown]:(
+ unknown unspecified premultiplied straight
+ )'
+ '!*-slices[]:int:'
+ '!*-thread_type[]:thread-type flag [slice+frame]:_ffmpeg_flags - slice frame'
+ '!*-audio_service_type[]:audio service type [ma]:(ma ef vi hi di co em vo ka)'
+ '!*-request_sample_fmt[]: :_ffmpeg_sample_fmts'
+ '!*-sub_charenc[specify subtitle character encoding]:subtitle character encoding:'
+ '!*-sub_charenc_mode[]:subtitle character encoding mode flag [0]:\
+ _ffmpeg_flags - do_nothing auto pre_decoder ignore
+ '
+ '!*-skip_alpha[]'
+ '!*-field_order[]:field order [0]:(progressive tt bb tb bt)'
+ '!*-dump_separator[specify information dump field separator]:field separator:'
+ '!*-codec_whitelist[]: :_sequence -s, _ffmpeg_codecs -D'
+ '!*-max_pixels[]:int64:'
+ '!*-max_samples[]:int64:'
+ '!*-hwaccel_flags[]:hardware-acceleration flag [ignore_level]:\
+ _ffmpeg_flags - \
+ ignore_level allow_high_depth allow_profile_mismatch \
+ unsafe_output
+ '
+ '!*-extra_hw_frames[]:int:'
+ '!*-discard_damaged_percentage[]:int:'
+ '!*-side_data_prefer_packet[]: : _values -s, "side data type" \
+ replaygain displaymatrix spherical stereo3d audio_service_type \
+ mastering_display_metadata content_light_level icc_profile exif
+ '
+)
+# generic format AVOptions. see above
+gen_avo_opts+=(
+ '!*-avioflags[]: :_ffmpeg_flags - direct'
+ '!*-probesize[]:int64:'
+ '!*-formatprobesize[]:int:'
+ '!*-packetsize[]:int:'
+ '!*-fflags[]: :_ffmpeg_flags - \
+ flush_packets ignidx genpts nofillin noparse igndts \
+ discardcorrupt sortdts fastseek nobuffer bitexact autobsf
+ '
+ '!*-seek2any[]'
+ '!*-analyzeduration[]:int64:'
+ '!*-cryptokey[]:binary:'
+ '!*-indexmem[]:int:'
+ '!*-rtbufsize[]:int:'
+ '!*-fdebug[]: :_ffmpeg_flags - ts'
+ '!*-max_delay[]:int:'
+ '!*-start_time_realtime[]:int64:'
+ '!*-fsprobesize[]:int:'
+ '!*-audio_preload[]:int:'
+ '!*-chunk_duration[]:int:'
+ '!*-chunk_size[]:int:'
+ '!*'{-f_err_detect,-err_detect}'[]: :_ffmpeg_flags - \
+ crccheck bitstream buffer explode ignore_err careful compliant \
+ aggressive
+ ' # -f_err_detect is deprecated
+ '!*-use_wallclock_as_timestamps[]'
+ '!*-skip_initial_bytes[]:int64:'
+ '!*-correct_ts_overflow[]'
+ '!*-flush_packets[]:int:'
+ '!*-metadata_header_padding[]:int:'
+ '!*-output_ts_offset[]: :_ffmpeg_durations'
+ '!*-max_interleave_delta[]:int64:'
+ # deprecated. see -strict
+ '!*-f_strict[]:strictness level:(very strict normal unofficial experimental)'
+ '!*-max_ts_probe[]:int:'
+ '!*-avoid_negative_ts[]:time-stamp shift method:(
+ auto disabled make_non_negative make_zero
+ )'
+ '!*-format_whitelist[]: :_sequence -s, _ffmpeg_formats -D'
+ '!*-protocol_whitelist[]: :_sequence -s, _ffmpeg_protocols'
+ '!*-protocol_blacklist[]: :_sequence -s, _ffmpeg_protocols'
+ '!*-max_streams[]:int:'
+ '!*-skip_estimate_duration_from_pts[]'
+ '!*-max_probe_packets[]:int:'
+ '!*-duration_probesize[]:int64:'
+)
+# and... this
+basic_opts+=(
+ '*-i[input file or URL]:input file:_files'
+)
+
+# previous iterations of this function only completed basic options. not sure if
+# that's specifically desirable, but we can support it
+opts=( $basic_opts )
+if zstyle -t ":completion:$curcontext:$curtag" basic; then
+ opts+=( ${expert_opts/#(#m)[^!]/!$MATCH} ${gen_avo_opts/#(#m)[^!]/!$MATCH} )
+else
+ opts+=( $expert_opts $gen_avo_opts )
+fi
+
+# --help looks annoying in the list
+[[ -n $words[(r)--*] ]] || opts=( ${opts:#(|\(*\))\*#--*} )
+
+# support -no variants of boolean options
+[[ $PREFIX == -no* ]] &&
+for x in ${opts:#*\]:*}; do
+ [[ $x == \([' *:-']##\)* ]] && continue # skip -version etc
+ # skip some others that are stupid
+ [[ $x == (|\(*\))-(hide_banner|n|y)\[* ]] && continue
+ # turn '-foo[do bar]' into "-nofoo[don't do bar]"
+ [[ $x == \(* ]] && x=${x/\)-/\)-no} || x=${x/-/-no}
+ x=${x/\[/\[don\'t }
+ opts+=( $x )
+done
-[[ "$state" == "vfilters" ]] &&
- _values -s , -S = 'video filter' \
- 'aspect:set aspect ratio (rational number X\:Y or decimal number):' \
- 'crop:crop input video (x\:y\:width\:height):' \
- 'format: :_sequence -s : _ffmpeg_pix_fmts' \
- 'noformat: :_sequence -s : _ffmpeg_pix_fmts' \
- 'null' \
- 'pad:add pads to the input image (width\:height\:x\:y\:color_string):' \
- 'pixelaspect:set pixel aspect ratio (rational number X\:Y or decimal number):' \
- 'scale:scale input video (width\:height):' \
- 'slicify:output slice height ("random" or a number of pixels):' \
- 'unsharp:luma_x\:luma_y\:luma_amount\:chroma_x\:chroma_y\:chroma_amount:' \
- 'vflip' \
- 'buffer' \
- 'nullsrc' \
- 'nullsink' \
- && return
+# support optional stream/metadata spec, e.g. -codec:a or -metadata:s:a
+[[ $words[CURRENT] == -/#*:* || $words[CURRENT-1] == -/#*:* ]] &&
+for x y in ss_opts _ffmpeg_stream_specs ms_opts _ffmpeg_metadata_specs; do
+ for z in ${(P)x}; do
+ [[ $words[CURRENT] == -/#$z:* || $words[CURRENT-1] == -/#$z:* ]] || continue
+ tmp=( ${(M)opts:#(|\(*\))\*#-$z\[*} )
+ opts=( ${opts:#$tmp} )
+ # turn '-c:x:y' into '-c\:-: :_ffmpeg_stream_specs:x:y'
+ tmp=( ${tmp/\[/\\:-\[} )
+ tmp=( ${tmp/%(#m):([^:]|\\:)##(|:([^:]|\\:)#)/: :$y$MATCH} )
+ opts+=( $tmp )
+ break
+ done
+done
-[[ -n $state && -n $_ffmpeg_flags[$state] ]] &&
- _ffmpeg_flags $state && return
+# support -/ variant (-/filter:v filter.script) of options with args
+[[ $words[CURRENT] == -/* || $words[CURRENT-1] == -/?* ]] &&
+for (( x = 1; x <= $#opts; x++ )); do
+ [[ $opts[x] == *\]:* ]] || continue
+ [[ $opts[x] == \([' *:-']##\)* ]] && continue # skip -help etc
+ y=${${${${opts[x]#\!}#\(*\)}#\*}%%(\\:|)(-|)\[*} # option name for desc
+ # turn '-c:x:y' into '-/c:...:_files'
+ [[ $opts[x] == \(* ]] && opts[x]=${opts[x]/\)-/\)-/} || opts[x]=${opts[x]/-/-/}
+ opts[x]=${opts[x]/%:([^:]|\\:)##(|:([^:]|\\:)#)/:$y argument value file:_files}
+done
-return 1
+_arguments -S : $opts '*:output file:_files'
diff --git a/Completion/Unix/Command/_find b/Completion/Unix/Command/_find
index 4908cabbc..2afb46e34 100644
--- a/Completion/Unix/Command/_find
+++ b/Completion/Unix/Command/_find
@@ -12,17 +12,21 @@ case $variant in
'*-local'
)
;|
- solaris*|darwin*)
+ solaris*|darwin*|freebsd<15->.*)
args+=( '*-xattr' )
;|
solaris2.<10->|freebsd*|darwin*)
args+=( '*-acl' )
;|
- solaris2.<11->|freebsd*|dragonfly*|darwin*|openbsd*|gnu)
+ aix*|solaris2.<11->|freebsd*|dragonfly*|darwin*|openbsd*|gnu)
args+=(
'*-amin:access time (minutes)'
'*-cmin:inode change time (minutes)'
'*-mmin:modification time (minutes)'
+ )
+ ;|
+ solaris2.<11->|freebsd*|dragonfly*|darwin*|openbsd*|gnu)
+ args+=(
'*-iname:name pattern to match (case insensitive)'
'*-print0'
)
@@ -36,7 +40,7 @@ case $variant in
darwin*|freebsd*|gnu)
args+=(
'*-Bmin:birth time (minutes)'
- '*-Bnewer:file to compare (birth time):_files'
+ '!*-Bnewer:reference file:_files'
'*-newer'{a,B,c,m}{a,B,c,m}'[if [aBcm\]time is newer than [aBcm\]time of given file]:reference file:_files'
'*-newerat[if access time is newer than given timestamp]:timestamp: '
'*-newerBt[if birth time is newer than given timestamp]:timestamp: '
@@ -98,7 +102,7 @@ case $variant in
)
;|
freebsd*|dragonfly*) args+=( '*-sparse' ) ;|
- darwin*) args+=( '*-xattrname:name' ) ;|
+ darwin*|freebsd<15->.*) args+=( '*-xattrname:name' ) ;|
gnu)
args+=(
'(- *)-help' '(-)--help'
@@ -162,7 +166,7 @@ if [[ $state = times ]]; then
zstyle -s ":completion:${curcontext}:senses" list-separator sep || sep=--
default=" [default exactly]"
disp=( "+ $sep before (older files)" "- $sep since (newer files)" )
- smatch=( - + )
+ smatch=( + - )
else
disp=( before exactly since )
smatch=( + '' - )
diff --git a/Completion/Unix/Command/_fish b/Completion/Unix/Command/_fish
new file mode 100644
index 000000000..08541bc83
--- /dev/null
+++ b/Completion/Unix/Command/_fish
@@ -0,0 +1,78 @@
+#compdef fish
+
+local MATCH MBEGIN MEND ret=1
+local -a args context line state state_descr
+local -A opt_args
+
+args=(
+ # unlike most shells, fish's -c is a normal option-with-optarg which can be
+ # interleaved with other options and can even be given multiple times.
+ # obviously we can't complete command strings reliably here but we'll try
+ '(1)*'{-c+,--command=}'[execute specified command string]: :_cmdstring'
+ '*'{-C+,--init-command=}'[execute specified command before other input]: :_cmdstring'
+ '(-d --debug)'{-d+,--debug=}'[enable debug output for specified categories]: :->debug'
+ '(-o --debug-output)'{-o+,--debug-output=}'[specify debug output file]:debug output file:_files'
+ '(-f --features)'{-f+,--features=}'[enable specified feature flags]: :->feature'
+ '(-i --interactive)'{-i,--interactive}'[act as interactive shell]'
+ '(-l --login)'{-l,--login}'[act as login shell]'
+ '(-N --no-config)'{-N,--no-config}'[do not read configuration files]'
+ '(-n --no-execute)'{-n,--no-execute}'[check syntax only (do not execute commands)]'
+ '(-p --profile)'{-p+,--profile=}'[specify profile output file]:profile output file:_files'
+ '--profile-startup=[specify start-up profile output file]:profile output file:_files'
+ '(-P --private)'{-P,--private}'[enable private mode (no history)]'
+ '--print-rusage-self[output getrusage() stats on exit]'
+ '(- : *)--print-debug-categories[display debug categories]'
+ '(- : *)'{-v,--version}'[display version information]'
+ '(- : *)'{-h,--help}'[display usage information]'
+ '(-)1:script file:_files'
+ '(-)*:argument:_files'
+)
+
+_arguments -s -S -A '-*' : $args && ret=0
+
+case $state in
+ debug)
+ local -a tmp=( ${(f)"$(
+ _call_program debug-categories $words[1] --print-debug-categories
+ )"} )
+ tmp=( ${${tmp/[[:space:]]##/\[}/%/\]} )
+ tmp=( ${tmp/(#m)\[[A-Z][^A-Z]/${(L)MATCH}} )
+ tmp=( ${tmp/.\]/\]} )
+ _values -s, 'debug category' $tmp && ret=0
+ ;;
+
+ feature)
+ local name def ver desc
+ local -a flags_on flags_off versions flags tmp
+
+ while IFS=$'\t ' read -r name def ver desc; do
+ desc=${${desc/#(#m)[A-Z][^A-Z]/${(L)MATCH}}//(#m)[]\\]/\\$MATCH}
+ if [[ $def == on ]]; then
+ flags_on+=( $name"[$desc ($ver, defaults on)]" )
+ else
+ flags_off+=( $name"[$desc ($ver, defaults off)]" )
+ fi
+ versions+=( $ver"[all features introduced in fish $ver]" )
+ done < <(
+ _call_program feature-flags $words[1] -NPc '"status features"'
+ )
+
+ # if an individual flag is already on, show the no- variant, and vice versa
+ flags+=( no-$^flags_on $flags_off )
+ # always show both for these 'groups'
+ flags+=( {no-,}all'[all features]' {no-,}${(u)versions} )
+
+ # only show redundant variants of individual flags when necessary
+ tmp=( no-$^flags_off )
+ [[ ${PREFIX##*,} == n* ]] || tmp=( '!'$^tmp )
+ flags+=( $tmp )
+
+ tmp=( ${(M)flags_on:#${${PREFIX##*,}[1]:----}*} )
+ (( $#tmp )) || tmp=( '!'$^flags_on )
+ flags+=( $tmp )
+
+ _values -s, 'feature flag' $flags && ret=0
+ ;;
+esac
+
+return ret
diff --git a/Completion/Unix/Command/_flac b/Completion/Unix/Command/_flac
index 0197aaf92..d7f3e801c 100644
--- a/Completion/Unix/Command/_flac
+++ b/Completion/Unix/Command/_flac
@@ -67,7 +67,6 @@ case $service in
- 'H' \
'(-)'{-v,--version}'[display version information]' \
'(-)'{-h,--help}'[display help information]' \
- '(-)'{-H,--explain}'[display detailed explanation of usage and options]' \
- encode \
'(-V --verify)'{-V,--verify}'[verify a correct encoding]' \
--lax --ignore-chunk-sizes '!--sector-align' --replay-gain \
@@ -88,6 +87,7 @@ case $service in
'(-p --qlp-coeff-precision-search -q --qlp-coeff-precision)'{-q,--qlp-coeff-precision=}'[specify precision]:precision (bits)' \
'(-r --rice-partition-order)'{-r,--rice-partition-order=}'[set min/max residual partition order]:order' \
"--limit-min-bitrate[don't allow frames consisting of only constant subframes]" \
+ '(-j --threads)'{-j+,--threads=}'[set number of encoding threads]:threads' \
'--endian=:byte order:(big little)' \
'--channels=:channels' \
'--bps=:bits per sample' \
@@ -102,6 +102,7 @@ case $service in
'(-F --decode-through-errors)'{-F,--decode-through-errors}'[continue decoding through stream errors]' \
'--apply-replaygain-which-is-not-lossless=:specification' \
'--cue=[set the beginning and ending cuepoints to decode]:cue point' \
+ '--decode-chained-stream[decode all links in a chained Ogg stream, not just the first one]' \
'(--force-raw-format --force-rf64-format --force-wave64-format --force-legacy-wave-format --force-extensible-wave-format --force-aiff-c-none-format --force-aiff-c-sowt-format)--force-aiff-format' \
'(--force-raw-format --force-aiff-format --force-wave64-format --force-legacy-wave-format --force-extensible-wave-format --force-aiff-c-none-format --force-aiff-c-sowt-format)--force-rf64-format' \
'(--force-raw-format --force-aiff-format --force-rf64-format --force-legacy-wave-format --force-extensible-wave-format --force-aiff-c-none-format --force-aiff-c-sowt-format)--force-wave64-format' \
@@ -112,6 +113,7 @@ case $service in
;;
metaflac)
_arguments -S $shared \
+ '(-o --output-name)'{-o+,--output-name=}'[write changes to a new file]:file:_files' \
'(--no-filename)--with-filename[prefix output with filename]' \
'(--with-filename)--no-filename' \
'--dont-use-padding[always rewrite the file]' \
diff --git a/Completion/Unix/Command/_fsh b/Completion/Unix/Command/_fsh
deleted file mode 100644
index c39373117..000000000
--- a/Completion/Unix/Command/_fsh
+++ /dev/null
@@ -1,22 +0,0 @@
-#compdef fsh
-
-local curcontext="$curcontext" state line ret=1
-local -a _comp_priv_prefix
-
-_arguments -C \
- '(- : *)'{-h,--help}'[display help information]' \
- '(- : *)'{-V,--version}'[display version information]' \
- '-r[specify method]:method:(rsh ssh)' \
- '-l[specify login id]:login:_users' \
- '(-T --timeout)'{-T,--timeout}':idle timeout:' \
- ':remote host name:_hosts' \
- '(-):command: _command_names -e' \
- '*::args:->command' && ret=0
-
-if [[ -n "$state" ]]; then
- shift 1 words
- (( CURRENT-- ))
- _normal && ret=0
-fi
-
-return ret
diff --git a/Completion/Unix/Command/_fuser b/Completion/Unix/Command/_fuser
index 05de1c529..90124ea30 100644
--- a/Completion/Unix/Command/_fuser
+++ b/Completion/Unix/Command/_fuser
@@ -69,9 +69,12 @@ case $variant in
args+=(
'-n[list only processes with non-blocking mandatory locks]'
)
- ;;
+ ;|
solaris2.<10->)
args+=( '-d[report device usage for all minor nodes bound to same device]' )
+ ;|
+ solaris2.<11->)
+ args+=( "-l[don't resolve symlinks to target file]" )
;;
sysv4 )
(( $+words[(r)-k] )) && argf=( ':name: _alternative signals\:signal\:_signals\ -p files:file:_files' )
diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc
index d81f31cf5..cf1cf7efa 100644
--- a/Completion/Unix/Command/_gcc
+++ b/Completion/Unix/Command/_gcc
@@ -1,10 +1,18 @@
-#compdef gcc g++ cc c++ llvm-gcc llvm-g++ clang clang++ -value-,LDFLAGS,-default- -value-,CFLAGS,-default- -value-,CXXFLAGS,-default- -value-,CPPFLAGS,-default- -P gcc-* -P g++-* -P c++-*
+#compdef gcc g++ cc c++ llvm-gcc llvm-g++ clang clang++ -value-,LDFLAGS,-default- -value-,CFLAGS,-default- -value-,CXXFLAGS,-default- -value-,CPPFLAGS,-default- -value-,CC,-default- -value-,CXX,-default- -P gcc-* -P g++-* -P c++-*
local curcontext="$curcontext" state line ret=1 expl i
local -a args args2 warnings arch
typeset -A opt_args
-if [[ "$service" = -value-* ]]; then
+if [[ "$service" = -value-,CC,* ]]; then
+ _description compilers expl compiler
+ compadd "$expl[@]" -M 'r:|-=* r:|=*' -k 'commands[(I)(clang|([ig]|sun|open)cc(|<->|-devel)|icx)]'
+ return
+elif [[ "$service" = -value-,CXX,* ]]; then
+ _description compilers expl compiler
+ compadd "$expl[@]" -M 'r:|-=* r:|=*' -k 'commands[(I)((clang|g)++(|<->|-devel)|(sun|open|)CC|icpx)]'
+ return
+elif [[ "$service" = -value-* ]]; then
compset -q
words=( fake "$words[@]" )
(( CURRENT++ ))
@@ -158,7 +166,7 @@ mips*)
'-mginv[ginv]'
'-mgpopt[use GP relative accesses for symbols known to be in a small data section]'
'-mindirect-jump=[change indirect jump instructions to inhibit speculation]:arg'
- '-mips16[ips16]'
+ '-mips16[mips16]'
'-mldc1-sdc1[ldc1 sdc1]'
'-mlocal-sdata[extend the -G behaviour to object local data]'
'-mmadd4[enable the generation of 4-operand madd.s, madd.d, etc]'
@@ -212,20 +220,20 @@ i[3456]86|x86_64)
'-mavx256-split-unaligned-load[split 32-byte AVX unaligned load]'
'-mavx256-split-unaligned-store[split 32-byte AVX unaligned store]'
'-mavx2[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX and AVX2 built-in functions and code generation]'
- '-mavx5124fmaps[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX512F and AVX5124FMAPS built- in functions and code generation]'
- '-mavx5124vnniw[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX512F and AVX5124VNNIW built- in functions and code generation]'
+ '-mavx5124fmaps[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX512F and AVX5124FMAPS built-in functions and code generation]'
+ '-mavx5124vnniw[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX512F and AVX5124VNNIW built-in functions and code generation]'
'-mavx512bf16[avx512bf16]'
'-mavx512bitalg[avx512bitalg]'
- '-mavx512bw[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512BW built- in functions and code generation]'
- '-mavx512cd[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512CD built- in functions and code generation]'
- '-mavx512dq[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512DQ built- in functions and code generation]'
- '-mavx512er[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512ER built- in functions and code generation]'
+ '-mavx512bw[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512BW built-in functions and code generation]'
+ '-mavx512cd[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512CD built-in functions and code generation]'
+ '-mavx512dq[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512DQ built-in functions and code generation]'
+ '-mavx512er[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512ER built-in functions and code generation]'
'-mavx512f[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F built-in functions and code generation]'
'-mavx512ifma[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512IFMA built-in functions and code generation]'
- '-mavx512pf[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512PF built- in functions and code generation]'
+ '-mavx512pf[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512PF built-in functions and code generation]'
'-mavx512vbmi2[avx512vbmi2]'
'-mavx512vbmi[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512VBMI built-in functions and code generation]'
- '-mavx512vl[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512VL built- in functions and code generation]'
+ '-mavx512vl[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2 and AVX512F and AVX512VL built-in functions and code generation]'
'-mavx512vnni[avx512vnni]'
'-mavx512vp2intersect[avx512vp2intersect]'
'-mavx512vpopcntdq[support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX, AVX2, AVX512F and AVX512VPOPCNTDQ built-in functions and code generation]'
@@ -337,7 +345,7 @@ i[3456]86|x86_64)
'-mstack-arg-probe[enable stack probing]'
'-mstack-protector-guard=-[use given stack-protector guard]:guard:(global tls)'
'-mstackrealign[realign stack in prologue]'
- '-mstringop-strategy=-[chose strategy to generate stringop using]:stringop strategy:(byte_loop libcall loop rep_4byte rep_8byte rep_byte unrolled_loop)'
+ '-mstringop-strategy=-[choose strategy to generate stringop using]:stringop strategy:(byte_loop libcall loop rep_4byte rep_8byte rep_byte unrolled_loop)'
'-mstv[disable Scalar to Vector optimization pass transforming 64-bit integer computations into a vector ones]'
'-mtbm[support TBM built-in functions and code generation]'
'-mthreads[support thread-safe exception handling on MinGW]'
@@ -469,7 +477,7 @@ webassembly*)
'-mexception-handling[exception handling]'
'-mmultivalue[multivalue]'
'-mmutable-globals[mutable globals]'
- '-mnontrapping-fptoint[no ntrapping fptoint]'
+ '-mnontrapping-fptoint[nontrapping float-to-int conversion]'
'-mreference-types[reference types]'
'-msign-ext[sign ext]'
'-msimd128[simd128]'
@@ -528,11 +536,11 @@ if [[ "$service" = clang* ]]; then
'-cpp[cpp]'
'--cuda-compile-host-device[compile CUDA code for both host and device]'
'--cuda-device-only[compile CUDA code for device only]'
- '--cuda-gpu-arch=[cUDA offloading device architecture]:arg'
+ '--cuda-gpu-arch=[CUDA offloading device architecture]:arg'
'--cuda-host-only[compile CUDA code for host only]'
'*--cuda-include-ptx=[include ptx for the following gpu architecture]:argument'
'--cuda-noopt-device-debug[enable device-side debug info generation]'
- '--cuda-path=[cUDA installation path]:arg'
+ '--cuda-path=[CUDA installation path]:arg'
'--cuda-path-ignore-env[ignore environment variables to detect CUDA installation]'
'-cuid=[an id for compilation unit]:argument'
'-current_version[current version]:current version'
@@ -577,9 +585,9 @@ if [[ "$service" = clang* ]]; then
'-fapplication-extension[restrict code to those available for App Extensions]'
'-fasm-blocks[asm blocks]'
'-fassume-sane-operator-new[assume sane operator new]'
- '-fast[ast]'
- '-fastcp[astcp]'
- '-fastf[astf]'
+ '-fast[fast]'
+ '-fastcp[fastcp]'
+ '-fastf[fastf]'
'-fautolink[autolink]'
'-fautomatic[automatic]'
'-fauto-profile-accurate[auto profile accurate]'
@@ -616,7 +624,6 @@ if [[ "$service" = clang* ]]; then
'-fconstexpr-steps=[constexpr steps]:arg'
'-fconvergent-functions[assume functions may be convergent]'
'-fconvert=[convert]:arg'
- '-fcoroutines-ts[enable support for the C++ Coroutines TS]'
'-fcoverage-compilation-dir=[the compilation directory to embed in the coverage mapping]:arg'
'-fcoverage-mapping[generate coverage mapping to enable code coverage analysis]'
'-fcoverage-prefix-map=[remap file source paths in coverage mapping]:arg'
@@ -654,7 +661,7 @@ if [[ "$service" = clang* ]]; then
'-fdenormal-fp-math=[denormal fp math]:arg'
'-fdepfile-entry=[depfile entry]:arg'
'-fdiagnostics-absolute-paths[print absolute paths in diagnostics]'
- '-fdiagnostics-fixit-info[supply fixit into with diagnostic messages]'
+ '-fdiagnostics-fixit-info[supply fixit info with diagnostic messages]'
'-fdiagnostics-format=[diagnostics format]:arg'
'-fdiagnostics-hotness-threshold=[prevent optimization remarks from being output if they do not meet threshold]:value'
'-fdiagnostics-parseable-fixits[print fixits in a machine parseable form]'
@@ -721,12 +728,12 @@ if [[ "$service" = clang* ]]; then
'-fgpu-rdc[generate relocatable device code, also known as separate compilation mode]'
'-fgpu-sanitize[enable sanitizer for AMDGPU target]'
'-fheinous-gnu-extensions[heinous GNU extensions]'
- '-fhip-new-launch-api,[-fno-hip-new-launch-api Use new kernel launching API for HIP]'
+ '-fhip-new-launch-api[Use new kernel launching API for HIP]'
'-fhonor-infinites[honor infinites]'
'-fhonor-infinities[honor infinities]'
'-fhonor-nans[honor nans]'
'-fignore-exceptions[enable support for ignoring exception handling constructs]'
- '-filelist[ilelist]:arg'
+ '-filelist[filelist]:arg'
'-fimplicit-module-maps[implicit module maps]'
'-fimplicit-modules[implicit modules]'
'-fimplicit-none[no implicit typing allowed unless overridden by IMPLICIT statements]'
@@ -931,7 +938,6 @@ if [[ "$service" = clang* ]]; then
'-fsymbol-partition=[symbol partition]:arg'
'-fsystem-module[build this module as a system module. only used with -emit-module]'
'-ftemplate-backtrace-limit=[template backtrace limit]:arg'
- '-ftemplate-depth--[template depth]:arg'
'-ftemplate-depth=[template depth]:arg'
'-fterminated-vtables[terminated vtables]'
'-fthin-link-bitcode=[write minimized bitcode to <file>]:file:_files'
@@ -1016,7 +1022,7 @@ if [[ "$service" = clang* ]]; then
'-headerpad_max_install_names[headerpad max install names]:argument'
'-help[display this information]'
'--help-hidden[display help for hidden options]'
- '--hip-device-lib=[hIP device library]:arg'
+ '--hip-device-lib=[HIP device library]:arg'
'--hip-device-lib-path=[hip device lib path]:arg'
'--hip-link[link clang-offload-bundler bundles for HIP]'
'--hip-version=[HIP version in the format of major.minor.patch]'
@@ -1089,7 +1095,7 @@ if [[ "$service" = clang* ]]; then
'-mmacosx-version-min=[macosx version min]:arg'
'-mmcu=[mcu]:arg'
'-module-dependency-dir[directory to dump module dependencies to]:arg'
- '-module-dir[odule dir]:dir'
+ '-module-dir[module dir]:dir'
'-module-file-info[provide information about a particular module file]'
'-moslib=[oslib]:arg'
'-moutline-atomics[generate local calls to out-of-line atomic operations]'
@@ -1225,13 +1231,13 @@ if [[ "$service" = clang* ]]; then
'--resource=[resource]:arg'
'-rewrite-legacy-objc[rewrite Legacy Objective-C source to C++]'
'-rewrite-objc[rewrite Objective-C source to C++]'
- '--rocm-device-lib-path=[rOCm device library path]:arg'
- '--rocm-path=[rOCm installation path]:arg'
+ '--rocm-device-lib-path=[ROCm device library path]:arg'
+ '--rocm-path=[ROCm installation path]:arg'
'-Rpass-analysis=[report transformation analysis from optimization passes]:regex'
'-Rpass-missed=[report missed transformations by optimization passes]:arg'
'-Rpass=[report transformations performed by optimization passes]:arg'
'-rpath[rpath]:arg'
- '-r[product a relocatable object as output]'
+ '-r[produce a relocatable object as output]'
'--rtlib=[compiler runtime library to use]:arg'
'-rtlib=[rtlib]:arg'
'--save-stats=[save llvm statistics]:arg'
@@ -1247,7 +1253,6 @@ if [[ "$service" = clang* ]]; then
'-seglinkedit[seglinkedit]'
'-segprot[segprot]:arg'
'-segs_read_only_addr[segs read only addr]:arg'
- '-segs_read_[segs read]:arg'
'-segs_read_write_addr[segs read write addr]:arg'
'--serialize-diagnostics[serialize compiler diagnostics to a file]:arg'
'-serialize-diagnostics[serialize diagnostics]:arg'
@@ -1302,9 +1307,9 @@ if [[ "$service" = clang* ]]; then
'-Xarch_host[pass arg to CUDA/HIP host compilation]:argument'
'-Xclang[pass <arg> to the clang compiler]:arg'
'-Xcuda-fatbinary[pass arg to fatbinary invocation]:argument'
- '-Xcuda-ptxas[pass arg to the ptxas assemler]:argument'
+ '-Xcuda-ptxas[pass arg to the ptxas assembler]:argument'
'-Xflang[pass <arg> to the flang compiler]:arg'
- '-Xopenmp-target[pass arg to the the target offloading toolchain]:argument'
+ '-Xopenmp-target[pass arg to the target offloading toolchain]:argument'
'-y[the action to perform on the input]:arg'
'-Z-[undocumented option]:argument'
)
@@ -1390,7 +1395,7 @@ warnings+=(
'-Wdate-time[warn about __TIME__, __DATE__ and __TIMESTAMP__ usage]'
'-Wdeclaration-after-statement[warn when a declaration is found after a statement]'
'-Wdelete-incomplete[warn when deleting a pointer to incomplete type]'
- '-Wdelete-non-virtual-dtor[warn about deleting polymorphic objects with non- virtual destructors]'
+ '-Wdelete-non-virtual-dtor[warn about deleting polymorphic objects with non-virtual destructors]'
'-Wdeprecated-declarations[warn about uses of __attribute__((deprecated)) declarations]'
'-Wdeprecated[warn if a deprecated compiler feature, class, method, or field is used]'
'-Wdesignated-init[warn about positional initialization of structs requiring designated initializers]'
@@ -1418,7 +1423,7 @@ warnings+=(
'-Wformat-overflow=[warn about function calls with format strings that write past the end of the destination region]:level:(1 2)'
'-Wformat-security[warn about possible security problems with format functions]'
'-Wformat-signedness[warn about sign differences with format functions]'
- '-Wformat-truncation[warn about calls to snprintf and similar functions that truncate output. Same as -Wformat- truncation=1. Same as -Wformat-truncation=]'
+ '-Wformat-truncation[warn about calls to snprintf and similar functions that truncate output]'
'-Wformat-truncation=[warn about calls to snprintf and similar functions that truncate output]:level:(1 2)'
'-Wformat=[warn about printf/scanf/strftime/strfmon format string anomalies]::level:(1 2)'
'-Wformat-y2k[warn about strftime formats yielding 2-digit years]'
@@ -1516,7 +1521,7 @@ warnings+=(
'-Wredundant-decls[warn about multiple declarations of the same object]'
'-Wregister[warn about uses of register storage specifier]'
'-Wreorder[warn when the compiler reorders code]'
- '-Wrestrict[warn when an argument passed to a restrict- qualified parameter aliases with another argument]'
+ '-Wrestrict[warn when an argument passed to a restrict-qualified parameter aliases with another argument]'
'-Wreturn-local-addr[warn about returning a pointer/reference to a local or temporary variable]'
'-Wreturn-type[warn whenever a function'\''s return type defaults to "int" (C), or about inconsistent return types (C++)]'
'-Wscalar-storage-order[warn on suspicious constructs involving reverse scalar storage order]'
@@ -1553,7 +1558,7 @@ warnings+=(
'-Wsuggest-override[suggest that the override keyword be used when the declaration of a virtual function overrides another]'
'-Wsurprising[warn about "suspicious" constructs]'
'-Wswitch-bool[warn about switches with boolean controlling expression]'
- '-Wswitch-default[warn about enumerated switches missing a "default-" statement]'
+ '-Wswitch-default[warn about enumerated switches missing a "default" statement]'
'-Wswitch-enum[warn about all enumerated switches missing a specific case]'
'-Wswitch-unreachable[warn about statements between switch'\''s controlling expression and the first case]'
'-Wswitch[warn about enumerated switches, with no default, missing a case]'
@@ -1584,7 +1589,7 @@ warnings+=(
'-Wunused-const-variable[warn when a const variable is unused. Same as -Wunused-const-variable=]'
'-Wunused-const-variable=[warn when a const variable is unused]:level:(1 2)'
'-Wunused-dummy-argument[warn about unused dummy arguments]'
- '-Wunused[enable all -Wunused- warnings]'
+ '-Wunused[enable all -Wunused-warnings]'
'-Wunused-function[warn when a function is unused]'
'-Wunused-label[warn when a label is unused]'
'-Wunused-local-typedefs[warn when typedefs locally defined in a function are not used]'
@@ -1697,6 +1702,7 @@ args+=(
'-fcompare-elim[perform comparison elimination after register allocation has finished]'
'-fcond-mismatch[allow the arguments of the ? operator to have different types]'
'-fconserve-stack[do not perform optimizations increasing noticeably stack usage]'
+ '-fcoroutines[enable support for C++ Coroutines]'
'-fcprop-registers[perform a register copy-propagation optimization pass]'
'-fcrossjumping[perform cross-jumping optimization]'
'-fcse-follow-jumps[when running CSE, follow jumps to their targets]'
@@ -1750,7 +1756,7 @@ args+=(
'-ffat-lto-objects[output lto objects containing both the intermediate language and binary output]'
'-ffinite-math-only[assume no NaNs or infinities are generated]'
'-ffixed--[mark <register> as being unavailable to the compiler]:register'
- '-ffloat-store[don'\''t allocate floats and doubles in extended- precision registers]'
+ '-ffloat-store[don'\''t allocate floats and doubles in extended-precision registers]'
'-fforward-propagate[perform a forward propagation pass on RTL]'
'-ffp-contract=-[perform floating-point expression contraction]:style [fast]:(on off fast)'
'-ffp-int-builtin-inexact[allow built-in functions ceil, floor, round, trunc to raise "inexact" exceptions]'
@@ -1800,7 +1806,6 @@ args+=(
'-fira-hoist-pressure[use IRA based register pressure calculation in RTL hoist optimizations]'
'-fira-loop-pressure[use IRA based register pressure calculation in RTL loop optimizations]'
'-fira-region=-[set regions for IRA]:region:(all mixed one)'
- '-fira-region=[set regions for IRA]:region:(one all mixed)'
'-fira-share-save-slots[share slots for saving different hard registers]'
'-fira-share-spill-slots[share stack slots for spilled pseudo-registers]'
'-fira-verbose=-[control IRA'\''s level of diagnostic messages]:verbosity: '
@@ -1840,6 +1845,8 @@ args+=(
'-fno-stack-limit[do not limit the size of the stack]'
'-fno-threadsafe-statics[do not generate thread-safe code for initializing local statics]'
'-fnothrow-opt[treat a throw() exception specification as noexcept to improve code size]'
+ '-foffload=[specify offloading targets]:target list'
+ '-foffload-options=:option list'
'-fomit-frame-pointer[when possible do not generate stack frames]'
'-fopenacc[enable OpenACC]'
'-fopenmp[enable OpenMP (implies -frecursive in Fortran)]'
@@ -1862,7 +1869,7 @@ args+=(
'-fPIE[generate position-independent code for executables if possible (large mode)]'
'-fpie[generate position-independent code for executables if possible (small mode)]'
'-fplan9-extensions[enable Plan 9 language extensions]'
- '-fplt[use PLT for PIC calls (-fno-plt- load the address from GOT at call site)]'
+ '-fplt[use PLT for PIC calls (-fno-plt-load the address from GOT at call site)]'
'-fplugin-arg--[specify argument <key>=<value> for plugin <name>]:-fplugin-arg-name-key=value: ' #TODO
'-fplugin=-[specify a plugin to load]:plugin: ' # TODO: complete plugins?
'-fpost-ipa-mem-report[report on memory allocation before interprocedural optimization]'
@@ -1907,11 +1914,7 @@ args+=(
'-fsched-spec-insn-heuristic[enable the speculative instruction heuristic in the scheduler]'
'-fsched-spec-load[allow speculative motion of some loads]'
'-fsched-spec-load-dangerous[allow speculative motion of more loads]'
- '-fsched-stalled-insns[allow premature scheduling of queued insns]'
- '-fsched-stalled-insns-dep[set dependence distance checking in premature scheduling of queued insns]'
- '-fsched-stalled-insns-dep=[set dependence distance checking in premature scheduling of queued insns]:insns:'
'-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]:insns:'
'-fsched-stalled-insns=-[set number of queued insns that can be prematurely scheduled]:instructions: '
'-fschedule-fusion[perform a target dependent instruction fusion optimization pass]'
'-fschedule-insns2[reschedule instructions after register allocation]'
@@ -1942,14 +1945,13 @@ args+=(
'-fsplit-wide-types[split wide types into independent registers]'
'-fssa-backprop[enable backward propagation of use properties at the SSA level]'
'-fssa-phiopt[optimize conditional patterns using SSA PHI nodes]'
- '-fstack-check=-[insert stack checking code into the program. -fstack-check=specific if to argument given]:type:(none generic specific)'
+ '-fstack-check=-[insert stack checking code into the program]:type:(none generic specific)'
'-fstack-limit-register=-[trap if the stack goes past <register>]:register: '
'-fstack-limit-symbol=-[trap if the stack goes past symbol <name>]:name: '
'-fstack-protector-all[use a stack protection method for every function]'
'-fstack-protector-explicit[use stack protection method only for functions with the stack_protect attribute]'
'-fstack-protector-strong[use a smart stack protection method for certain functions]'
'-fstack-protector[use propolice as a stack protection method]'
- '-fstack-reuse=[set stack reuse level for local variables]:level:(all named_vars none)'
'-fstack-reuse=-[set stack reuse level for local variables]:reuse-level:(all named_vars none)'
'-fstack-usage[output stack usage information on a per-function basis]'
'-fstdarg-opt[optimize amount of stdarg registers saved to stack at start of function]'
@@ -1989,10 +1991,9 @@ args+=(
'-ftree-loop-linear[enable loop interchange transforms. Same as -floop-interchange]'
'-ftree-loop-optimize[enable loop optimizations on tree level]'
'-ftree-loop-vectorize[enable loop vectorization on trees]'
- '-ftree-lrs[perform live range splitting during the SSA- >normal pass]'
- '-ftree-parallelize-loops=[enable automatic parallelization of loops]'
+ '-ftree-lrs[perform live range splitting during the SSA->normal pass]'
'-ftree-parallelize-loops=-[enable automatic parallelization of loops]:threads: '
- '-ftree-partial-pre[in SSA-PRE optimization on trees, enable partial- partial redundancy elimination]'
+ '-ftree-partial-pre[in SSA-PRE optimization on trees, enable partial-partial redundancy elimination]'
'-ftree-phiprop[enable hoisting loads from conditional pointers]'
'-ftree-pre[enable SSA-PRE optimization on trees]'
'-ftree-pta[perform function-local points-to analysis on trees]'
@@ -2083,7 +2084,7 @@ args+=(
'(-pg)-p[enable function profiling for prof]'
'-pie[create a position independent executable]'
{-pipe,--pipe}'[use pipes rather than intermediate files]'
- {-P,--no-line-commands}'[inhibit generation of linkemakers during preprocess]'
+ {-P,--no-line-commands}'[inhibit generation of linemarkers during preprocess]'
'(-p)-pg[enable function profiling for gprof]'
'-###[print commands to run this compilation]'
'-print-file-name=-[display the full path to library <library>]:library:->library'
@@ -2128,7 +2129,6 @@ args+=(
'-V[specify compiler version]:compiler version:'
{-v,--verbose}'[enable verbose output]'
'*-Wa,-[pass arguments to the assembler]:assembler option:'
- '--warn--[enable the specified warning]:warning:->warning'
'*-Werror=-[treat specified warning as error (or all if none specified)]::warning:->warning'
'-Wfatal-errors[exit on the first error occurred]'
'*-Wl,-[pass arguments to the linker]:linker option:'
diff --git a/Completion/Unix/Command/_gcore b/Completion/Unix/Command/_gcore
index ef3afd919..4e5041f3b 100644
--- a/Completion/Unix/Command/_gcore
+++ b/Completion/Unix/Command/_gcore
@@ -56,7 +56,7 @@ case $OSTYPE in
'-v[report progress on the dump as it proceeds]' \
'-b+[specify maximum size of core file]:size (MiB): ' \
'(-c)-o+[write core file to specified file]:file:_files' \
- '(-o)-c+[specify format of core file name]:format (%%N\:program name, %%U\:uid, %%P\:pid, %%T\:time stamp)' \
+ '(-o)-c+[specify format of core file name]:format (%N\:program name, %U\:uid, %P\:pid, %T\:time stamp)' \
'1:pid:_pids'
;;
*)
diff --git a/Completion/Unix/Command/_ghostscript b/Completion/Unix/Command/_ghostscript
index 2c6f40a35..021668c60 100644
--- a/Completion/Unix/Command/_ghostscript
+++ b/Completion/Unix/Command/_ghostscript
@@ -1,4 +1,4 @@
-#compdef gs ghostscript
+#compdef gs ghostscript gsnd
local -a specs names device
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index e9f72799c..c4ed3c3e9 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -70,6 +70,7 @@ _git-add () {
'(-f --force)'{-f,--force}'[allow adding otherwise ignored files]' \
'(-i --interactive : -)'{-i,--interactive}'[add contents interactively to index]' \
'(-p --patch)'{-p,--patch}'[like -i but go directly into patch mode for specified files]' \
+ "--no-auto-advance[don't advance to next file when selecting hunks interactively]" \
'(-U --unified)'{-U+,--unified=}'[generate diff with given lines of context]:number of lines' \
'--inter-hunk-context=[combine patch hunks closer than specified number of lines]:number of lines' \
'(-e --edit)'{-e,--edit}'[open diff against index in editor]' \
@@ -206,7 +207,8 @@ _git-archive () {
_git-backfill() {
_arguments -S \
'--min-batch-size=[specify minimum number of objects to request at a time]:number of objects' \
- '--sparse[only download objects at a path matching current sparse-checkout]'
+ '--sparse[only download objects at a path matching current sparse-checkout]' \
+ '--no-include-edges[exclude blobs from boundary commits in the backfill]'
}
(( $+functions[_git-bisect] )) ||
@@ -515,6 +517,7 @@ _git-checkout () {
"--ignore-other-worktrees[don't check if another worktree is using this branch]" \
'--recurse-submodules=-[control recursive updating of submodules]::checkout:__git_commits' \
'--no-overlay[remove files from index or working tree that are not in the tree-ish]' \
+ "--no-auto-advance[don't advance to next file when selecting hunks interactively]" \
'(-q --quiet --progress)--no-progress[suppress progress reporting]' \
'--progress[force progress reporting]' \
'(*)--pathspec-from-file=[read pathspec from file]:file:_files' \
@@ -555,7 +558,7 @@ _git-checkout () {
elif [[ -n ${opt_args[(I)-b|-B|-t|--track|--orphan|--detach]} ]]; then
_nothing
- elif [[ -n $line[1] ]] && __git_is_treeish ${(Q)line[1]}; then
+ elif [[ -n $line[1] && $line[1] != (@|HEAD) ]] && __git_is_treeish ${(Q)line[1]}; then
__git_ignore_line __git_tree_files ${PREFIX:-.} ${(Q)line[1]} && ret=0
else
__git_ignore_line __git_modified_files && ret=0
@@ -696,7 +699,7 @@ _git-clone () {
'(--single-branch)--no-single-branch[clone history leading up to each branch]' \
"--no-tags[don't clone any tags and make later fetches not follow them]" \
'--shallow-submodules[any cloned submodules will be shallow]' \
- '(--recursive --recurse-submodules)'{--recursive,--recurse-submodules}'=-[initialize submodules in the clone]::file:__git_files' \
+ '(--recursive --recurse-submodules)'{--recursive,--recurse-submodules}'=-[initialize submodules in the clone]::file:_files' \
'--separate-git-dir[place .git dir outside worktree]:path to .git dir:_path_files -/' \
'--ref-format=[specify reference format to use]:format:(files reftable)' \
\*--server-option='[send specified string to the server when using protocol version 2]:option' \
@@ -1011,6 +1014,7 @@ _git-format-patch () {
'--from=[add From: header to email headers]: :_email_addresses' \
'*--add-header=[add an arbitrary header to email headers]:header' \
'--cover-letter[generate a cover letter template]' \
+ '(--cover-letter)--commit-list-format=[format commit list in the cover letter]:format:(short-log modern)' \
'--notes=[append notes for the commit after the three-dash line]:: :__git_notes_refs' \
'( --no-signature --signature-file)--signature=[add a signature]:signature' \
'(--signature --signature-file)--no-signature[do not add a signature]' \
@@ -1219,6 +1223,49 @@ _git-gui () {
return ret
}
+(( $+functions[_git-history] )) ||
+_git-history() {
+ local curcontext=$curcontext ret=1
+ local -a state line common
+ declare -A opt_args
+
+ _arguments -C \
+ ': :->command' \
+ '*:: :->option-or-argument' && ret=0
+
+ case $state in
+ (command)
+ declare -a commands
+
+ commands=(
+ 'reword:rewrite commit message of specified commit'
+ 'split:interactively split up commit'
+ )
+
+ _describe -t commands command commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*}-$line[1]:
+ common=(
+ "--dry-run[don't update any references]"
+ '--update-refs=[control which references will be updates]:references [branches]:(branches head)'
+ ':commit:__git_commits'
+ )
+
+ case $line[1] in
+ reword) _arguments -S -s $endopt $common && ret=0 ;;
+ split)
+ _arguments -S -s $endopt $common \
+ '*: :__git_ignore_line_inside_arguments __git_tree_files ${PREFIX:-.} ${(Q)line[1]}' && ret=0
+ ;;
+ *) _default && ret=0 ;;
+ esac
+ ;;
+ esac
+
+ return ret
+}
+
(( $+functions[_git-init] )) ||
_git-init () {
_arguments -S -s $endopt \
@@ -1300,7 +1347,8 @@ _git-log () {
(( $+functions[_git-maintenance] )) ||
_git-maintenance() {
- local curcontext="$curcontext" state state_descr line ret=1
+ local curcontext="$curcontext" ret=1
+ local -a state state_descr line args
local -A opt_args
_arguments -C \
@@ -1324,16 +1372,27 @@ _git-maintenance() {
(option-or-argument)
curcontext=${curcontext%:*}-$line[1]:
case $line[1] in
- (run)
+ run)
_arguments -S $endopt \
'--auto[run tasks based on the state of the repository]' \
+ '--detach[perform maintenance in the background]' \
'--schedule=[run tasks based on frequency]:frequency (seconds)' \
"--quiet[don't report progress or other information to stderr]" \
'*--task=[run a specific task]:task:(gc commit-graph prefetch loose-objects incremental-repack pack-refs)' && ret=0
;;
- (start)
+ start)
_arguments \
- '--scheduler=:scheduler:(auto crontab systemd-timer launchctl schtasks)'
+ '--scheduler=:scheduler:(auto crontab systemd-timer launchctl schtasks)' && ret=0
+ ;;
+ unregister)
+ args=( '(-f --force)'{-f,--force}'[return success even if repository was not registered]' )
+ ;&
+ register)
+ _arguments -S $endopt $args \
+ '--config-file=[use given config file]:config file:_files' && ret=0
+ ;;
+ stop) _message 'no more arguments' ;;
+ *) _default && ret=0 ;;
esac
;;
esac
@@ -1591,6 +1650,7 @@ _git-range-diff () {
'(--right-only)--left-only[only emit output related to the first range]' \
'(--left-only)--right-only[only emit output related to the second range]' \
'(--remerge-diff)--diff-merges=[specify diff format to be used for merge commits]:format [m]:(off none 1 first-parent separate c combined cc dense-combined r remerge m on)' \
+ '--max-memory=[specify maximum memory for cost matrix]:memory [4G]' \
'(--diff-merges -p --patch -u)--remerge-diff[produce remerge-diff output for merge commits]' \
$diff_options \
'1:range 1:__git_commit_ranges' \
@@ -1638,6 +1698,7 @@ _git-rebase () {
"(--autostash --no-autostash)--no-autostash[don't stash uncommitted changes before rebasing and apply them afterwards]" \
'(--root)--fork-point[use merge-base --fork-point to refine upstream]' \
'--signoff[add Signed-off-by: trailer to the commit message]' \
+ '(--force-rebase)*--trailer=[add custom trailer to every rebased commit]:trailer:__git_trailers_tokens' \
'--no-ff[cherry-pick all rebased commits with --interactive, otherwise synonymous to --force-rebase]' \
'(--keep-base)--onto=[start new branch with HEAD equal to given revision]:newbase:__git_revisions' \
"(--apply --whitespace -C)--reschedule-failed-exec[automatically re-schedule any 'exec' that fails]" \
@@ -1661,6 +1722,7 @@ _git-reset () {
'(--soft --mixed --hard --merge -p --patch -U --unified --inter-hunk-context -- *)--keep[like --hard, but keep local working tree changes]' \
'--recurse-submodules=-[control recursive updating of submodules]::reset:__git_commits' \
'(-p --patch --soft --mixed -N --intent-to-add --hard --merge --keep)'{-p,--patch}'[select diff hunks to remove from the index]' \
+ "--no-auto-advance[don't advance to next file when selecting hunks interactively]" \
'(-U --unified --soft --mixed -N --intent-to-add --hard --merge --keep)'{-U+,--unified=}'[generate diff with given lines of context]:number of lines' \
'(--soft --mixed -N --intent-to-add --hard --merge --keep)--inter-hunk-context=[combine patch hunks closer than specified number of lines]:number of lines' \
'(-N --intent-to-add --soft --mixed --hard --merge --keep -p --patch -U --unified --inter-hunk-context -- *)'{-N,--intent-to-add}'[record only the fact that removed paths will be added later]' \
@@ -1903,6 +1965,7 @@ _git-sparse-checkout() {
reapply:'reapply the sparsity pattern rules to paths in the working tree'
disable:'disable the config setting, and restore all files in the working directory'
check-rules:'check whether sparsity rules match one or more paths'
+ clean:'remove files outside of the sparse-checkout definition'
)
_describe -t commands command commands && ret=0
@@ -1910,7 +1973,7 @@ _git-sparse-checkout() {
(option-or-argument)
curcontext=${curcontext%:*}-$line[1]:
case $line[1] in
- init)
+ init|reapply)
_arguments \
'--cone[allow for better performance with a limited set of patterns]' \
'--no-sparse-index[rewrite index to not be sparse]' && ret=0
@@ -1929,6 +1992,12 @@ _git-sparse-checkout() {
'--cone[interpret rules file patterns as cone mode patterns]' \
'--rules-file=[use patterns in specified file]:file:_files' && ret=0
;;
+ clean)
+ _arguments \
+ '(-f --force)'{-f,--force}'[remove files]' \
+ '--dry-run[list the directories that would be removed without deleting them]' \
+ '--verbose[list every file considered for removal]'
+ ;;
esac
;;
esac
@@ -1940,7 +2009,7 @@ _git-sparse-checkout() {
_git-stash () {
local curcontext=$curcontext state line ret=1
declare -A opt_args
- local -a save_arguments
+ local -a save_arguments args
save_arguments=(
'(-p --patch -a --all -u --include-untracked)'{-p,--patch}'[interactively select hunks from diff between HEAD and working tree to stash]'
@@ -2017,8 +2086,9 @@ _git-stash () {
'(-u --include-untracked)--only-untracked[show only the untracked files in the stash entry as part of the diff]' \
':: :__git_stashes' && ret=0
;;
- (pop|apply)
- _arguments -S $endopt \
+ apply) args=( '--label-'{ours,theirs,base}'=:label' ) ;&
+ pop)
+ _arguments -S $endopt $args \
'--index[try to reinstate the changes added to the index as well]' \
'(-q --quiet)'{-q,--quiet}'[suppress all output]' \
':: :__git_stashes' && ret=0
@@ -2237,12 +2307,16 @@ _git-submodule () {
_git-subtree () {
local curcontext="$curcontext" state state_descr line ret=1
declare -A opt_args
+ local -a common=(
+ '(-q --quiet)'{-q,--quiet}'[suppress progress output]'
+ '(-d --debug)'{-d,--debug}'[show debug messages]'
+ '(-P --prefix)'{-P+,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories'
+ '(-S --gpg-sign --no-gpg-sign)'{-S-,--gpg-sign=-}'[GPG-sign the commit]::key id'
+ "(-S --gpg-sign --no-gpg-sign)--no-gpg-sign[don't GPG-sign the commit]"
+ )
# TODO: -P should only complete paths inside the current repository.
- _arguments -C \
- '(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
- '(-P --prefix)'{-P+,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
- '(-d --debug)'{-d,--debug}'[show debug messages]' \
+ _arguments -C $common \
': :->command' \
'*::: := ->option-or-argument' && ret=0
@@ -2263,7 +2337,7 @@ _git-subtree () {
curcontext=${curcontext%:*}-$line[1]:
case $line[1] in
(add)
- _arguments \
+ _arguments $common \
'(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
'(-m --message)'{-m+,--message=}'[use the given message as the commit message for the merge commit]:message' \
'(-P --prefix)'{-P+,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
@@ -2276,35 +2350,27 @@ _git-subtree () {
# __git_ref_specs.
;;
(merge)
- _arguments -S \
- '(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
- '(-P --prefix)'{-P+,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
+ _arguments -S $common \
'(-m --message)'{-m+,--message=}'[use the given message as the commit message for the merge commit]:message' \
'--squash[import only a single commit from the subproject]' \
': :__git_references' && ret=0
;;
(pull)
- _arguments -S \
- '(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
- '(-P --prefix)'{-P+,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
+ _arguments -S $common \
'(-m --message)'{-m+,--message=}'[use the given message as the commit message for the merge commit]:message' \
'--squash[import only a single commit from the subproject]' \
': :__git_any_repositories' \
':: :__git_ref_specs' && ret=0
;;
(push)
- _arguments -S \
- '(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
- '(-P --prefix)'{-P+,--prefix=}'[the path to the subtree in the repository to manipulate]: :_directories' \
+ _arguments -S $common \
'(-m --message)'{-m+,--message=}'[use the given message as the commit message for the merge commit]:message' \
': :__git_any_repositories' \
':: :__git_ref_specs' && ret=0
;;
(split)
- _arguments -S \
+ _arguments -S $common \
'--annotate[add a prefix to commit message of new commits]:prefix' \
- '(-q --quiet)'{-q,--quiet}'[suppress progress output]' \
- '(-P --prefix)'{-P+,--prefix=}'[specify path to the subtree in the repository to manipulate]: :_directories' \
'(-b --branch)'{-b,--branch=}'[create a new branch]' \
'--onto=[try connecting new tree to an existing one]: :__git_ref_specs' \
'(-m --message)'{-m+,--message=}'[specify commit message for the merge]:message' \
@@ -2472,12 +2538,12 @@ _git-worktree() {
_arguments -s -S $endopt \
'(-n --dry-run)'{-n,--dry-run}"[don't remove, show only]" \
'(-v --verbose)'{-v,--verbose}'[report pruned objects]' \
- '--expire=[expire objects older than specified time]: :_git_approxidates' && ret=0
+ '--expire=[prune missing working trees older than specified time]: :_git_approxidates' && ret=0
;;
(list)
_arguments -S $endopt \
'(-v --verbose --porcelain -z)'{-v,--verbose}'[output additional information about worktrees]' \
- "--expire=[add 'prunable' annotation to worktrees older than specified time]: :_git_approxidates" \
+ "--expire=[add 'prunable' annotation to missing worktrees older than specified time]: :_git_approxidates" \
'(-v)--porcelain[machine-readable output]' \
'(-v)-z[terminate each line with a NUL rather than a newline]' && ret=0
;;
@@ -2527,56 +2593,71 @@ _tig () {
(( $+functions[_git-config] )) ||
_git-config () {
+ local curcontext="$curcontext" ret=1
+ local -a state state_descr line
+ local -a location filter display type include default comment
+ local -A opt_args
local name_arg value_arg
- local curcontext=$curcontext state line ret=1
- declare -A opt_args
if (( words[(I)--get-regexp] )); then
name_arg=':name regex'
- elif (( words[(I)--get-colorbool] )); then
- name_arg=':: :->is-a-tty'
elif (( words[(I)--get-color] )); then
name_arg='::default'
elif (( words[(I)--remove-section|--rename-section] )); then
- name_arg=': :->section'
+ name_arg=': : __git_config_sections -b "(|)" "^" section-names "section name"'
elif (( words[(I)--get|--get-all] )); then
- name_arg=': :->gettable-option'
+ name_arg=': :->gettable-options'
else
- name_arg=': :->option'
+ name_arg=': :->commands-options'
fi
if (( words[(I)--rename-section] )); then
- value_arg=': :->section'
+ value_arg=': : __git_config_sections -b "(|)" "^" section-names "section name"'
else
- value_arg=': :->value'
+ value_arg='*::: := ->values'
fi
- _arguments -C -S -s $endopt \
- '( --system --local --worktree -f --file --blob)--global[use user-global config file]' \
- '(--global --local --worktree -f --file --blob)--system[use system-wide config file]' \
- '(--global --system --worktree -f --file --blob)--local[use local config file]' \
- '(--global --system --local -f --file --blob)--worktree[use per-worktree config file]' \
- '(--global --system --local --worktree --blob)'{-f+,--file=}'[use given config file]:config file:_files' \
- '(--global --system --local --worktree -f --file)--blob=[read config from given blob object]:blob:__git_blobs' \
- '(-t --type --bool --int --bool-or-int --bool-or-str --path --expiry-date)'{-t+,--type=}'[ensure that incoming and outgoing values are canonicalize-able as the given type]:type:(bool int bool-or-int bool-or-str path expiry-date color)' \
- '(-t --type --int --bool-or-int --bool-or-str --path --expiry-date)--bool[setting is a boolean]' \
- '(-t --type --bool --bool-or-int --bool-or-str --path --expiry-date)--int[setting is an integer]' \
- '(-t --type --bool --int --bool-or-str --path --expiry-date)--bool-or-int[setting is a boolean or integer]' \
- '(-t --type --bool --int --bool-or-int --path --expiry-date)--bool-or-str[setting is a boolean or string]' \
- '(-t --type --bool --int --bool-or-int --bool-or-str --expiry-date)--path[setting is a path]' \
- '(-t --type --bool --int --bool-or-int --bool-or-str --path)--expiry-date[setting is an expiry date]' \
- '(-z --null)'{-z,--null}'[end values with NUL and newline between key and value]' \
- '--fixed-value[use string equality when comparing values]' \
- '(--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-scope)--show-origin[show origin of config]' \
- '(--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-scope[show scope of config (worktree, local, global, system, command)]' \
- '(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' \
- '--comment=[specify human-readable comment string]:comment' \
+ location=(
+ '(--system --local --worktree -f --file --blob)--global[use user-global config file]'
+ '(--global --local --worktree -f --file --blob)--system[use system-wide config file]'
+ '(--global --system --worktree -f --file --blob)--local[use local config file]'
+ '(--global --system --local -f --file --blob)--worktree[use per-worktree config file]'
+ '(--global --system --local --worktree --blob)'{-f+,--file=}'[use given config file]:config file:_files'
+ '(--global --system --local --worktree -f --file)--blob=[read config from given blob object]:blob:__git_blobs'
+ )
+ filter=(
+ '--fixed-value[use string equality when comparing values]'
+ )
+ display=(
+ '(-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]'
+ '(--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-scope)--show-origin[show origin of config]'
+ '(--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-scope[show scope of config (worktree, local, global, system, command)]'
+ '--show-names[show config keys in addition to their values]'
+ )
+ type=(
+ '(-t --type --bool --int --bool-or-int --bool-or-str --path --expiry-date)'{-t+,--type=}'[ensure that incoming and outgoing values are canonicalize-able as the given type]:type:(bool int bool-or-int bool-or-str path expiry-date color)'
+ '(-t --type --int --bool-or-int --bool-or-str --path --expiry-date)--bool[setting is a boolean]'
+ '(-t --type --bool --bool-or-int --bool-or-str --path --expiry-date)--int[setting is an integer]'
+ '(-t --type --bool --int --bool-or-str --path --expiry-date)--bool-or-int[setting is a boolean or integer]'
+ '(-t --type --bool --int --bool-or-int --path --expiry-date)--bool-or-str[setting is a boolean or string]'
+ '(-t --type --bool --int --bool-or-int --bool-or-str --expiry-date)--path[setting is a path]'
+ '(-t --type --bool --int --bool-or-int --bool-or-str --path)--expiry-date[setting is an expiry date]'
+ )
+ include=(
+ '(--includes)'--no-includes"[don't respect \"include.*\" directives]"
+ '(--no-includes)'--includes'[respect "include.*" directives in config files when looking up values]'
+ )
+ default=(
+ '(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'
+ )
+ comment=(
+ '--comment=[specify human-readable comment string]:comment'
+ )
+
+ _arguments -C -S -s $endopt $location $filter $display $type $include $default \
$name_arg \
$value_arg \
- '::value regex' \
- '(actions)' \
'(2 --name-only)--get[get the first matching value of the key]' \
'(2 --name-only)--get-all[get all matching values of the key]' \
@@ -2590,25 +2671,79 @@ _git-config () {
'(3 --bool --int --bool-or-int --bool-or-str --path -z --null --name-only --show-origin)--remove-section[remove the given section]' \
'(: --bool --int --bool-or-int --bool-or-str --path)'{-l,--list}'[list all variables set in config file]' \
'(-e --edit --bool --int --bool-or-int --bool-or-str --path -z --null --name-only --show-origin)'{-e,--edit}'[open config file for editing]' \
- '(2 3 --bool --int --bool-or-int --bool-or-str --path -z --null --name-only --show-origin)--get-color[find color setting]: :->gettable-color-option' \
- '(2 3 --bool --int --bool-or-int --bool-or-str --path -z --null --name-only --show-origin)--get-colorbool[check if color should be used]: :->gettable-colorbool-option' && ret=0
- __git_config_option-or-value "$@" && ret=0
+ '(2 3 --bool --int --bool-or-int --bool-or-str --path -z --null --name-only --show-origin)--get-color[find color setting]: :->gettable-color-options' \
+ '(2 3 --bool --int --bool-or-int --bool-or-str --path -z --null --name-only --show-origin)--get-colorbool[check if color should be used]: :->gettable-colorbool-options:stdout is tty:(true false auto)' && ret=0
+
+ filter+=(
+ '--all[return all values for multi-valued config options]'
+ '--value=[show config with values matching the pattern]:pattern'
+ )
+
+ case $state/$line[1] in
+ values/(list|get|set|unset|re(name|move)-section|edit))
+ curcontext=${curcontext%:*}-$line[1]:
+ ;|
+ values/list)
+ _arguments $location $display $type $include && ret=0
+ ;;
+ values/get)
+ _arguments $location $display $type $filter $include $default \
+ '--regexp[interpret the name as a regular expression]' \
+ '--url=[show config matching the given URL]:url:_urls' && ret=0
+ ;;
+ values/set)
+ _arguments $location $type $filter $comment \
+ '--append[add a new line without altering any existing values]' && ret=0
+ ;;
+ values/unset)
+ _arguments $location $type $filter && ret=0
+ ;;
+ values/rename-section)
+ _arguments $location \
+ ': : __git_config_sections -b "(|)" "^" section-names "old section name"' \
+ ': : __git_config_sections -b "(|)" "^" section-names "new name"' && ret=0
+ ;;
+ values/remove-section)
+ _arguments $location \
+ ': : __git_config_sections -b "(|)" "^" section-names "section"' && ret=0
+ ;;
+ values/edit)
+ _arguments $location && ret=0
+ ;;
+ commands-options/*)
+ _alternative \
+ 'commands:command:((
+ list:"list variables along with their values"
+ get:"emit the value for the specified key"
+ set:"set value for one or more config options"
+ unset:"remove value for one or more config options"
+ rename-section:"rename given section to a new name"
+ remove-section:"remove given section from the configuration file"
+ edit:"open editor to modify specified config file"
+ ))' \
+ 'option-names: : __git_config_option-or-value' && ret=0
+ ;;
+ *)
+ __git_config_option-or-value "$@" && ret=0
+ ;;
+ esac
+
return ret
}
(( $+functions[__git_config_option] )) ||
__git_config_option () {
- local -A opt_args=()
+ local -A opt_args
local -a line=( ${words[CURRENT]%%=*} )
- local state=option
+ local state=options
__git_config_option-or-value "$@"
}
(( $+functions[__git_config_value] )) ||
__git_config_value () {
- local -A opt_args=()
+ local -A opt_args
local -a line=( ${words[CURRENT]%%=*} ${words[CURRENT]#*=} )
- local state=value
+ local state=values
__git_config_option-or-value "$@"
}
@@ -2810,7 +2945,7 @@ __git_config_option-or-value () {
'diff.*.textconv:command to generate the text-converted version of a file::_cmdstring'
'diff.*.wordregex:regular expression that the diff driver should use to split words in a line:regular expression:->string'
'diff.*.xfuncname:regular expression that the diff driver should use to recognize the hunk header:regular expression:->string'
- diff.algorithm:'default diff algorithm::->diff.algorithm:default'
+ diff.algorithm:"default diff algorithm::_git_diff_algorithms"
diff.autorefreshindex:'run git update-index --refresh before git diff::->bool:true'
diff.colorMoved:"color moved lines in diffs::__git_color_moved"
diff.colorMovedWS:"ignore whitespace when detecting moved lines::__git_color_movedws"
@@ -3292,18 +3427,7 @@ __git_config_option-or-value () {
}
case $state in
- (section)
- __git_config_sections -b '(|)' '^' section-names 'section name' $* && ret=0
- ;;
- (is-a-tty)
- declare -a values
- values=(
- true
- false
- auto)
- _describe -t values 'stdout is a tty' values && ret=0
- ;;
- (option)
+ (commands-|)options)
local label=option
declare -a sections sections_and_options options
@@ -3522,16 +3646,16 @@ __git_config_option-or-value () {
sections_and_options -M 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' -qS . -- \
options -M 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' "$@" && ret=0
;;
- (gettable-option)
+ (gettable-options)
_wanted git-options expl option compadd -M 'r:|.=* r:|=*' -a - git_present_options && ret=0
;;
- (gettable-colorbool-option)
+ (gettable-colorbool-options)
__git_config_sections -b '(|)' -a '(|)' '^color\.[^.]+$' gettable-colorbool-options option && ret=0
;;
- (gettable-color-option)
+ (gettable-color-options)
__git_config_sections -b '(|)' -a '(|)' '^color\.[^.]+\..*$' gettable-color-options option && ret=0
;;
- (value)
+ (values)
local current=${${(0)"$(_call_program current "git config $opt_args[(I)--system|--global|--local]" ${(kv)opt_args[(I)-f|--file]} "-z --get ${(q)line[1]}")"}#*$'\n'}
case $line[1] in
(alias.*)
@@ -3689,14 +3813,6 @@ __git_config_option-or-value () {
__git_guard_number 'number of days'
fi
;;
- (diff.algorithm)
- __git_config_values -- "$current" "$parts[5]" \
- default:'basic greedy diff algorithm' \
- myers:'basic greedy diff algorithm' \
- minimal:'spend extra time to make sure the smallest possible diff is produced' \
- patience:'generate diffs with patience algorithm' \
- histogram:'generate diffs with histogram algorithm' && ret=0
- ;;
(diff.renames)
__git_config_booleans "$current" "$parts[5]" "$parts[2]" \
{copies,copy}:'try to detect both renames and copies' && ret=0
@@ -4072,6 +4188,7 @@ _git-reflog () {
'show:show log of ref'
'drop:remove reflog for specified references'
'exists:check whether a ref has a reflog'
+ 'write:write reflog entry for a reference'
)
_alternative \
@@ -4114,7 +4231,10 @@ _git-reflog () {
;;
(exists)
__git_references && ret=0
- ;;
+ ;;
+ write)
+ _arguments ': :__git_references' ':old oid' ':new oid' ':message' && ret=0
+ ;;
esac
esac
@@ -4138,6 +4258,9 @@ _git-refs() {
commands=(
'migrate:migrate ref store between different formats'
'verify:verify reference database consistency'
+ 'list:list references in the repository, alias for git-for-each-ref'
+ 'exists:check whether given reference exists'
+ 'optimize:optimize references to improve repository performance, alias for git-pack-refs'
)
_describe -t commands command commands && ret=0
@@ -4157,6 +4280,9 @@ _git-refs() {
'--strict[enable stricter error checking]' \
'--verbose[when verifying the reference database consistency, be chatty]' && ret=0
;;
+ list) _git-for-each-ref && ret=0 ;;
+ exists) __git_references && ret=0 ;;
+ optimize) _git-pack-refs && ret=0 ;;
*) _default && ret=0 ;;
esac
;;
@@ -4303,7 +4429,8 @@ _git-repack () {
'--pack-kept-objects[repack objects in packs marked with .keep]' \
'--keep-pack=[ignore named pack]:pack' \
'(-g --geometric)'{-g+,--geometric=}'[find a geometric progression with specified factor]:factor' \
- '(-m --write-midx)'{-m,--write-midx}'[write a multi-pack index of the resulting packs]' \
+ '(--write-midx)-m[write a multi-pack index of the resulting packs]' \
+ '(-m)--write-midx=-[write a multi-pack index of the resulting packs]:mode:(default incremental)' \
'--expire-to=[pack prefix to store a pack containing pruned objects]:directory:_directories' \
'--filter-to=[pack prefix to store a pack containing filtered out objects]:directory:_directories'
}
@@ -4363,6 +4490,7 @@ _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]' \
+ '--diff-algorithm=[choose a diff algorithm to use when computing blame]: :_git_diff_algorithms' \
'--ignore-rev=[ignore specified revision when blaming]:revision:__git_revisions' \
'--ignore-revs-file=[ignore revisions from file]:file:_files' \
'(--color-by-age)--color-lines[color redundant metadata from previous line differently]' \
@@ -4461,11 +4589,34 @@ _git-fsck () {
'*: :__git_objects'
}
+(( $+functions[_git-format-rev] )) ||
+_git-format-rev() {
+ _arguments -S $endopt \
+ '--format=[specify format]:format:__git_format_placeholders' \
+ '--stdin-mode=[specify stdin mode]:mode:(revs text)' \
+ '--notes=[display notes for pretty format]:reference' \
+ '(-z --null --null-input --null-output)'{-z,--null}'[use NUL for input and output termination]' \
+ '(-z --null)--null-input[use NUL for input termination]' \
+ '(-z --null)--null-output[use NUL for output termination]'
+}
+
(( $+functions[_git-get-tar-commit-id] )) ||
_git-get-tar-commit-id () {
_message 'no arguments allowed; accepts tar-file on standard input'
}
+(( $+functions[_git-last-modified] )) ||
+_git-last-modified() {
+ _arguments -s \
+ '(-r --recursive)'{-r,--recursive}'[recurse into subtrees]' \
+ '(-t --show-trees)'{-t,--show-trees}'[show tree entries when recursing into subtrees]' \
+ '--max-depth=[specify maximum tree depth to recurse]:depth [0]' \
+ '-z[separate lines with NUL character]' \
+ '1: :__git_commit_ranges' \
+ \!--{,end-of-options}':*: :__git_tree_files ${PREFIX:-.} HEAD' \
+ '*: :__git_tree_files ${PREFIX:-.} $line[1]'
+}
+
(( $+functions[_git-help] )) ||
_git-help () {
_arguments -S -s \
@@ -4841,10 +4992,14 @@ _git-send-email () {
'--smtp-server-port=[specify port to connect to SMTP server on]:smtp port:_ports' \
'--smtp-server-option=[specify the outgoing SMTP server option to use]:SMTP server option' \
'--smtp-ssl-cert-path=[path to ca-certificates (directory or file)]:ca certificates path:_files' \
+ '--smtp-ssl-client-cert=[path to client certificate file]: :_files' \
+ '--smtp-ssl-client-key=[path to the private key file for the client certificate]: :_files' \
'--smtp-user=[specify user to use for SMTP-AUTH]:smtp user:_users' \
'(--no-smtp-auth)--smtp-auth=[specify allowed AUTH mechanisms]:space-separated list of mechanisms' \
'(--smtp-auth)--no-smtp-auth[disable SMTP authentication]' \
'--smtp-debug=[enable or disable debug output]:smtp debug:((0\:"disable" 1\:"enable"))' \
+ '--imap-sent-folder=[IMAP folder where a copy of the emails should be sent]:IMAP folder' \
+ '--use-imap-only[only copy emails instead of actually sending them]' \
'--batch-size=[specify maximum number of messages per connection]:number' \
'--relogin-delay=[specify delay between successive logins]:delay (seconds)' \
'--cc-cmd=[specify command to generate Cc\: header with]:Cc\: command:_cmdstring' \
@@ -5328,11 +5483,7 @@ _git-merge-file () {
'( --theirs --union)--ours[resolve conflicts favoring our side of the lines]' \
'(--ours --union)--theirs[resolve conflicts favoring their side of the lines]' \
'(--ours --theirs )--union[resolve conflicts favoring both sides of the lines]' \
- '--diff-algorithm=[choose a diff algorithm]:diff algorithm:((default\:"basic greedy diff algorithm"
- myers\:"basic greedy diff algorithm"
- minimal\:"spend extra time to make sure the smallest possible diff is produced"
- patience\:"generate diffs with patience algorithm"
- histogram\:"generate diffs with histogram algorithm"))' \
+ '--diff-algorithm=[choose a diff algorithm]: :_git_diff_algorithms' \
'--marker-size[specify length of conflict markers]: :__git_guard_number "marker length"' \
'--object-id[use object IDs instead of filenames]' \
'(--zdiff3)--diff3[show conflicts in "diff3" style]' \
@@ -5374,13 +5525,20 @@ _git-mktree () {
(( $+functions[_git-multi-pack-index] )) ||
_git-multi-pack-index() {
- _arguments \
+ _arguments -S \
'--object-dir=[specify location of git objects]:directory:_directories' \
'(--progress)--no-progress[turn progress off]' '!(--no-progress)--progress' \
+ '--preferred-pack=[break ties in favor of specified pack]:pack' \
+ '--bitmap[write a multi-pack bitmap]' \
'--stdin-packs[write a multi-pack index containing only pack index basenames provided on stdin]' \
'--refs-snapshot=[specify a file which contains a "refs snapshot" taken prior to repacking]:file:_files' \
+ '--incremental[write an incremental MIDX file]' \
'--batch-size=[during repack, select packs so as to have pack files of at least the specified size]:size' \
- '1:verb:(write verify expire repack)'
+ "--write-chain-file[write new MIDX layer but don't update multi-pack-index-chain file]" \
+ '--base=[specify checksum of MIDX layer to use as base]:checksum' \
+ '1:verb:(write compact verify expire repack)' \
+ '2:from (checksum)' \
+ '3:to (checksum)'
}
(( $+functions[_git-pack-objects] )) ||
@@ -5494,6 +5652,21 @@ _git-read-tree () {
'3::third tree-ish to be read/merged:__git_tree_ishs'
}
+(( $+functions[_git-replay] )) ||
+_git-replay() {
+ _arguments -S $endopt \
+ '(--advance --revert)--contained[update all branches that point to commits in given range]' \
+ '(--advance --revert)--onto=[replay onto given commit]: :__git_revisions' \
+ '(--onto --revert)--advance=[advance given branch]: :__git_branches' \
+ '(--onto --advance)--revert=[revert commits onto given branch]: :__git_branches' \
+ '--ref=[specify reference to update with result]: :__git_ref_specs' \
+ '--ref-action=[control ref update behavior]:behavior:((
+ update\:"update directly using atomic transaction"
+ print\:"output update-ref commands for pipeline use"
+ ))' \
+ ':revision range:__git_commit_ranges'
+}
+
(( $+functions[_git-symbolic-ref] )) ||
_git-symbolic-ref () {
_arguments -S -s \
@@ -6280,7 +6453,11 @@ _git-hook() {
_arguments $args \
'--ignore-missing[ignore any missing hook by quietly returning zero]' \
"--to-stdin=[specify file which will be redirected to hook's stdin]:file:_files" \
- '1:subcommand:(run)' \
+ '--allow-unknown-hook-name' \
+ '-z[terminate output lines with NUL instead of newlines]' \
+ '--show-scope[prefix each hook name with a config scope]' \
+ '(-j --jobs)'{-j+,--jobs=}'[allow specified number of simultaneous hooks]:jobs' \
+ '1:subcommand:(run list)' \
'2:hook name:compadd $gitdir/hooks/*(x\:t)'
}
@@ -6337,6 +6514,13 @@ _git-stripspace () {
'(-c --comment-lines -s --strip-comments)'{-c,--comment-lines}'[prepend comment character and blank to each line]'
}
+(( $+functions[_git-url-parse] )) ||
+_git-url-parse() {
+ _arguments -S $endopt \
+ '(-c --component)'{-c+,--component=}'[specific URL component]:component:(scheme user password host port path)' \
+ '*: :_guard "^-*" url'
+}
+
# INTERNAL GIT COMPLETION FUNCTIONS
# Generic Helpers
@@ -6523,6 +6707,7 @@ _git_commands () {
gc:'cleanup unnecessary files and optimize local repository'
grep:'print lines matching a pattern'
gui:'run portable graphical interface to git'
+ history:'rewrite history'
init:'create empty git repository or re-initialize an existing one'
log:'show commit logs'
maintenance:'run tasks to optimize Git repository data'
@@ -6533,7 +6718,7 @@ _git_commands () {
push:'update remote refs along with associated objects'
range-diff:'compare two commit ranges'
rebase:'forward-port local commits to the updated upstream head'
- reset:'reset current HEAD to specified state'
+ reset:'reset HEAD or the index to a known state'
restore:'restore working tree files'
revert:'revert existing commits'
rm:'remove files from the working tree and from the index'
@@ -6545,7 +6730,7 @@ _git_commands () {
submodule:'initialize, update, or inspect submodules'
subtree:'split repository into subtrees and merge them'
switch:'switch branches'
- tag:'create, list, delete or verify tag object signed with GPG'
+ tag:'create, list, delete or verify tags'
worktree:'manage multiple working dirs attached to the same repository'
)
ancillary_manipulator_commands=(
@@ -6606,6 +6791,7 @@ _git_commands () {
pack-objects:'create packed archive of objects'
prune-packed:'remove extra objects that are already in pack files'
read-tree:'read tree information into directory index'
+ replay:'replay commits on a new base, works with bare repos too'
symbolic-ref:'read and modify symbolic references'
unpack-objects:'unpack objects from packed archive'
update-index:'register file contents in the working directory to the index'
@@ -6621,13 +6807,16 @@ _git_commands () {
diff-tree:'compare content and mode of blobs found via two tree objects'
for-each-ref:'output information on each ref'
for-each-repo:'run a git command on a list of repositories'
+ format-rev:'pretty format revisions from stdin'
get-tar-commit-id:'extract commit ID from an archive created using git archive'
+ last-modified:'show when files were last modified'
ls-files:'information about files in index/working directory'
ls-remote:'show references in a remote repository'
ls-tree:'list contents of a tree object'
merge-base:'find as good a common ancestor as possible for a merge'
name-rev:'find symbolic names for given revisions'
pack-redundant:'find redundant pack files'
+ repo:'retrieve information about repository'
rev-list:'list commit object in reverse chronological order'
rev-parse:'pick out and massage parameters for other git commands'
show-index:'show packed archive index'
@@ -6663,8 +6852,10 @@ _git_commands () {
mailinfo:'extract patch and authorship from a single email message'
mailsplit:'split mbox file into a list of files'
merge-one-file:'standard helper-program to use with git merge-index'
- patch-id:'compute unique ID for a patch'
- stripspace:'filter out empty lines')
+ patch-id:'compute unique ID for patches'
+ stripspace:'filter out empty lines'
+ url-parse:'parse and extract git URL components'
+ )
zstyle -a :completion:$curcontext: user-commands user_commands
@@ -6779,6 +6970,17 @@ __git_date_formats () {
_describe -t date-formats 'date format' date_formats -- '( format\:custom\ format )' -S :
}
+(( $+functions[_git_diff_algorithms] )) ||
+_git_diff_algorithms() {
+ _describe -t diff-algorithms 'diff algorithm' '(
+ default\:"basic greedy diff algorithm"
+ myers\:"basic greedy diff algorithm"
+ minimal\:"spend extra time to produce smallest possible diff"
+ patience\:"generate diffs with patience algorithm"
+ histogram\:"generate diffs with histogram algorithm"
+ )'
+}
+
(( $+functions[_git_diff_filters] )) ||
_git_diff_filters() {
local sep
@@ -6849,7 +7051,7 @@ _git_strategy_options() {
renormalize no-renormalize \
'find-renames::similarity threshold' \
subtree:path \
- 'diff-algorithm:algorithm:(patience minimal histogram myers)'
+ 'diff-algorithm:algorithm:_git_diff_algorithms'
}
(( $+functions[__git_encodings] )) ||
@@ -8172,11 +8374,7 @@ __git_setup_diff_options () {
'(--minimal --patience --histogram --diff-algorithm)--patience[generate diffs with patience algorithm]'
'(--minimal --patience --histogram --diff-algorithm)--histogram[generate diffs with histogram algorithm]'
'(--minimal --patience --histogram --diff-algorithm)*--anchored=[generate diffs using the "anchored diff" algorithm]:text'
- '(--minimal --patience --histogram --diff-algorithm)--diff-algorithm=[choose a diff algorithm]:diff algorithm:((default\:"basic greedy diff algorithm"
- myers\:"basic greedy diff algorithm"
- minimal\:"spend extra time to make sure the smallest possible diff is produced"
- patience\:"generate diffs with patience algorithm"
- histogram\:"generate diffs with histogram algorithm"))'
+ '(--minimal --patience --histogram --diff-algorithm)--diff-algorithm=[choose a diff algorithm]: :_git_diff_algorithms' \
'--stat=-[generate diffstat instead of patch]:: :__git_guard_diff-stat-width'
'--stat-width=-[generate diffstat with a given width]:width'
'--stat-graph-width=-[generate diffstat with a given graph width]:width'
@@ -8208,6 +8406,7 @@ __git_setup_diff_options () {
"(--color-moved-ws)--no-color-moved-ws=[don't ignore whitespace when performing move detection]"
"--ita-invisible-in-index[hide 'git add -N' entries from the index]"
"!(--ita-invisible-in-index)--ita-visible-in-index"
+ '--max-depth=[specify maximum tree depth to recurse]:depth'
'--no-renames[turn off rename detection]'
$exclusive_diff_options'--check[warn if changes introduce trailing whitespace or space/tab indents]'
'--full-index[show full object name of pre- and post-image blob]'
@@ -8225,7 +8424,7 @@ __git_setup_diff_options () {
'--diff-filter=-[select certain kinds of files for diff]: :_git_diff_filters'
'-S-[look for differences that add or remove the given string]:string'
'-G-[look for differences whose added or removed line matches the given regex]:pattern'
- '--pickaxe-all[when -S finds a change, show all changes in that changeset]'
+ '--pickaxe-all[when -G or -S find a change, show all changes in that changeset]'
'--pickaxe-regex[treat argument of -S as regular expression]'
'-O-[output patch in the order of glob-pattern lines in given file]: :_files'
'--rotate-to=[show the change in specified path first]:path:_directories'
@@ -8301,7 +8500,7 @@ __git_format_placeholders() {
_alternative \
'formats:: _describe -t formats "built-in format" builtin_fmts' \
'user-formats:: _describe -t user-formats "user format" user_fmts' \
- 'custom-formats:: _describe -t custom-formats "custom format" custom_fmts -qS:' \
+ 'custom-formats:: _describe -t custom-formats "custom format" custom_fmts -r: -S:' \
&& return
# @todo: still unsupported: more complicated place-holders like %C() and
@@ -8558,11 +8757,13 @@ __git_setup_fetch_options () {
'(-q --quiet)--progress[force progress reporting]'
'--show-forced-updates[check for forced-updates on all updated branches]'
'--set-upstream[set upstream for git pull/fetch]'
- '--shallow-since=[deepen history of shallow repository based on time]:time' \
- '*--shallow-exclude=[deepen history of shallow clone by excluding ref]:reference' \
- '--deepen[deepen history of shallow clone]:number of commits' \
+ '--shallow-since=[deepen history of shallow repository based on time]:time'
+ '*--shallow-exclude=[deepen history of shallow clone by excluding ref]:reference'
+ '--deepen[deepen history of shallow clone]:number of commits'
\*{-o+,--server-option=}'[send specified string to the server when using protocol version 2]:option'
- '--negotiation-tip=[only report refs reachable from specified object to the server]:commit:__git_commits' \
+ '--negotiation-restrict=[only report refs reachable from specified object to the server]:commit:__git_commits'
+ '!--negotiation-tip=:commit:__git_commits'
+ '--negotiation-include=[report given commit as "have" in negotiation]:commit:__git_commits'
)
}
diff --git a/Completion/Unix/Command/_gnutls b/Completion/Unix/Command/_gnutls
index 4c1698857..c62269afc 100644
--- a/Completion/Unix/Command/_gnutls
+++ b/Completion/Unix/Command/_gnutls
@@ -182,7 +182,8 @@ case "$service" in
'--cprint[prints certain information is C-friendly format]'
'--null-password[enforce a NULL password]'
'--empty-password[enforce an empty password]'
- '--key-type=[specify the key type to use on key generation]:key type'
+ '--key-type=[specify key type to use on key generation]:key type'
+ '--key-format=[specify key format to use on key generation]:key format:(seed expanded both)'
'(-i --certificate-info)'{-i,--certificate-info}'[print information on a certificate]'
'(-l --crl-info)'{-l,--crl-info}'[print information on a CRL]'
'--crq-info[print information on a certificate request]'
diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg
index ea0a452f2..d704af92f 100644
--- a/Completion/Unix/Command/_gpg
+++ b/Completion/Unix/Command/_gpg
@@ -95,7 +95,6 @@ fi
'(--encrypt-to)--no-encrypt-to[disable the use of all --encrypt-to keys]'
'--group[set up email aliases]:spec'
'-z[specify compression level]:compression level:((0\:no\ compression 1\:minimum 2 3 4 5 6\:default 7 8 9\:maximum))'
- '(-t --textmode)'{-t,--textmode}'[use canonical text mode]'
'(-n --dry-run)'{-n,--dry-run}"[don't make any changes]"
'(-i --interactive --batch)'{-i,--interactive}'[prompt before overwriting files]'
'(-i --interactive --no-batch)--batch[use batch mode]'
diff --git a/Completion/Unix/Command/_gphoto2 b/Completion/Unix/Command/_gphoto2
index 788c9702f..4ff5ce1c1 100644
--- a/Completion/Unix/Command/_gphoto2
+++ b/Completion/Unix/Command/_gphoto2
@@ -11,6 +11,7 @@ _arguments -s -C \
'--debug-loglevel=[set debug level]:debug level:(error debug data all)' \
'--debug-logfile=[name of file to write debug info to]:file:_files' \
'(-q --quiet)'{-q,--quiet}'[quiet output]' \
+ '(-q --quiet)--parsable[simple parsable output]' \
'--hook-script=[hook script to call after downloads, captures, etc.]:file:_files' \
'--stdout[send file to stdout]' \
'--stdout-size[print filesize before data]' \
@@ -41,8 +42,8 @@ _arguments -s -C \
'--keep[keep images on camera after capturing]' \
'--keep-raw[keep the RAW images on the camera with --capture-image-and-download]' \
'--no-keep[remove images from camera after capturing]' \
- '--wait-event=-[wait for event from camera]::count' \
- '--wait-event-and-download=-[wait for event from camera and download new images]::count' \
+ '--wait-event=-[wait for event from camera]:: :_numbers -u events -d forever wait\ time s\:seconds ms\:milliseconds' \
+ '--wait-event-and-download=-[wait for event from camera and download new images]:: :_numbers -u events -d forever wait\ time s\:seconds ms\:milliseconds' \
'--capture-preview[capture a quick preview]' \
'--show-preview[capture a quick preview and display using ASCII art]' \
'(-B --bulb)'{-B,--bulb=}'[set bulb exposure time]:exposure time (seconds)' \
@@ -54,7 +55,7 @@ _arguments -s -C \
'--capture-image-and-download[capture an image and download it]' \
'--capture-movie=-[capture a movie]:count or seconds' \
'--capture-sound[capture an audio clip]' \
- '--capture-tethered=-[wait for shutter release on the camera and download]::count' \
+ '--capture-tethered=-[wait for shutter release on the camera and download]:: :_numbers -u events wait\ time s\:seconds ms\:milliseconds' \
'(-l --list-folders)'{-l,--list-folders}'[list folders in folder]' \
'(-L --list-files)'{-L,--list-files}'[list files in folder]' \
'(-m --mkdir)'{-m,--mkdir=}'[create a directory]:directory' \
@@ -71,13 +72,17 @@ _arguments -s -C \
'--get-all-raw-data[get all raw data from folder]' \
'--get-audio-data=[get audio data given in range]:range' \
'--get-all-audio-data[get all audio data from folder]' \
+ '--get-exif=[get files in given range]:range' \
+ '--get-all-exif[get all files from folder]' \
'(-d --delete-file)'{-d,--delete-file=}'[delete files in given range]:range' \
'(-D --delete-all-files)'{-D,--delete-all-files}'[delete all files in folder]' \
'(-u --upload-file)'{-u,--upload-file=}'[upload a file to camera]:file:_files' \
'--filename=[specify pattern to save file as]:pattern:_date_formats' \
+ '--filenumber=[specify the number %n in the filename pattern starts at]:starting number [1]' \
'(-f --folder)'{-f,--folder=}'[specify camera folder]:folder [/]' \
'(-R --recurse --no-recurse)'{-R,--recurse}'[recursion (default for download)]' \
'(-R --recurse)--no-recurse[no recursion (default for deletion)]' \
+ '--reverse[reverse order of file operations]' \
'--new[process new files only]' \
'--force-overwrite[overwrite files without asking]' \
'--skip-existing[skip files that already exist on local filesystem]' && ret=0
diff --git a/Completion/Unix/Command/_hardlink b/Completion/Unix/Command/_hardlink
new file mode 100644
index 000000000..8a62779aa
--- /dev/null
+++ b/Completion/Unix/Command/_hardlink
@@ -0,0 +1,43 @@
+#compdef hardlink
+
+local ign
+local -a args
+
+(( $#words > 2 )) && ign='!(- *)'
+
+if _pick_variant linux=util-linux jak -V; then
+ args=(
+ '(-c --content -p --ignore-mode -o --ignore-owner -t --ignore-time)'{-c,--content}'[compare only file contents, same as -pot]'
+ '(-b --io-size)'{-b+,--io-size=}'[specify I/O buffer size for file reading]: :_numbers "IO buffer size" K M G T P'
+ '(-d --respect-dir)'{-d,--respect-dir}'[directory names have to be identical]'
+ '(-F --prioritize-trees)'{-F,--prioritize-trees}'[keep files found in the earliest specified top-level]'
+ '(-l --list-duplicates)'{-l,--list-duplicates}"[just list paths of duplicates, don't link them]"
+ '--mount[stay within the same filesystem]'
+ '(-q --quiet)'{-q,--quiet}"[quiet mode - don't print anything]"
+ '(-r --cache-size)'{-r+,--cache-size=}'[specify memory limit for cached file content data]: :_numbers size K M G T P'
+ '(--skip-reflinks)--reflink=-[create clone/CoW copies]::when [auto]:(auto always never)'
+ '--skip-reflinks[skip already cloned files]'
+ '(-S --maximum-size)'{-S+,--maximum-size=}'[specify maximum size for files]: :_numbers -u bytes -d 0 size K M G T P E Z Y'
+ '--exclude-subtree[specify regular expression to exclude directories]:regex'
+ '(-X --respect-xattrs)'{-X,--respect-xattrs}'[respect extended attributes]'
+ '(-y --method)'{-y+,--method=}'[specify file content comparison method]:method [sha256]:(sha256 sha1 crc32c memcmp)'
+ '(-z --zero)'{-z,--zero}'[delimit output with NULs instead of newlines]'
+ )
+fi
+
+_arguments -S -s $args \
+ '(-f --respect-name)'{-f,--respect-name}'[filenames have to be identical]' \
+ '(-i --include)'{-i+,--include=}'[regular expression to include files/dirs]:regex' \
+ '(-m --maximize -M --minimize)'{-m,--maximize}'[keep the file with the most links]' \
+ '(-M --minimize -m --maximize)'{-M,--minimize}'[keep the file with the fewest links]' \
+ '(-n --dry-run)'{-n,--dry-run}"[don't actually link anything]" \
+ '(-o --ignore-owner -c --content)'{-o,--ignore-owner}'[ignore owner changes]' \
+ '(-O --keep-oldest)'{-O,--keep-oldest}'[keep the oldest file of multiple equal files]' \
+ '(-p --ignore-mode -c --content)'{-p,--ignore-mode}'[ignore changes of file mode]' \
+ '(-s --minimum-size)'{-s+,--minimum-size=}'[specify minimum size for files]: :_numbers -u bytes -d 1 size K M G T P E Z Y' \
+ '(-t --ignore-time -c --content)'{-t,--ignore-time}'[ignore timestamps (when testing for equality)]' \
+ \*{-v,--verbose}'[more verbose output]' \
+ '(-x --exclude)'{-x+,--exclude=}'[specify regular expression to exclude files]:regex' \
+ "$ign"{-h,--help}'[display usage information]' \
+ "$ign"{-V,--version}'[display version information]' \
+ '*:file or directory:_files'
diff --git a/Completion/Linux/Command/_htop b/Completion/Unix/Command/_htop
index e8d2fffb1..73a6ea9fa 100644
--- a/Completion/Linux/Command/_htop
+++ b/Completion/Unix/Command/_htop
@@ -19,6 +19,8 @@ args=(
'(-)'{-h,--help}'[display usage information]'
'(-H --highlight-changes)'{-H+,--highlight-changes=}'[highlight new and old processes (optionally specify delay)]::delay (seconds) (1-86400) [5]'
'(-M --no-mouse)'{-M,--no-mouse}'[disable mouse]'
+ '--no-meters[hide meters]'
+ '(-n --max-iterations)'{-n+,--max-iterations=}'[exit after given number of frame updates]:number'
\*{-p+,--pid=}'[show only specified PIDs]: : _sequence _pids'
'--readonly[disable all system and process changing features]'
'(-s --sort-key)'{-s+,--sort-key=}'[sort by specified column]: :->sort-keys'
@@ -48,7 +50,7 @@ case $state in
tmp=( ${tmp//:/\\:} )
tmp=( ${tmp/[[:space:]]##/:} )
tmp=( ${tmp/(#m):[A-Z]/${(L)MATCH}} )
- _describe -t sort-keys 'column (key)' tmp && ret=0
+ _describe -t sort-keys 'column' tmp -M 'b:=M_ b:=IO_' && ret=0
;;
esac
diff --git a/Completion/Unix/Command/_id b/Completion/Unix/Command/_id
index 64b8c9b37..ce18ed719 100644
--- a/Completion/Unix/Command/_id
+++ b/Completion/Unix/Command/_id
@@ -44,8 +44,10 @@ else
freebsd*)
args+=(
'(-)-A[print process audit user ID]'
- '(-)-M[print MAC label of the current process]'
+ '(- 1)-M[print MAC label of the current process]'
'(-)-c[print current login class]'
+ '(-)-d[print home directory]'
+ '(-)-s[print shell]'
)
;|
darwin*|dragonfly*|freebsd*|netbsd*|openbsd*)
diff --git a/Completion/Unix/Command/_imagemagick b/Completion/Unix/Command/_imagemagick
index 6553868d9..958b2741d 100644
--- a/Completion/Unix/Command/_imagemagick
+++ b/Completion/Unix/Command/_imagemagick
@@ -12,7 +12,7 @@ typeset -A opt_args
#
# and certainly many other things...
-formats=(jpg jpeg jp2 j2k jpc jpx jpf tif tiff miff ras bmp cgm dcx ps eps fig fits fpx gif mpeg pbm pgm ppm pcd pcl pdf pcx png rad rgb rgba rle sgi html shtml tga ttf uil xcf xwd xbm xpm yuv svg webp)
+formats=(jpg jpeg jp2 j2k jpc jpx jpf tif tiff miff ras bmp cgm dcx ps eps fig fits fpx gif heic mpeg pbm pgm ppm pcd pcl pdf pcx png rad rgb rgba rle sgi html shtml tga ttf uil xcf xwd xbm xpm yuv svg webp)
if (( $# )); then
_files "$@" -g "*.(#i)(${(j:|:)formats})(-.)"
diff --git a/Completion/Unix/Command/_init_d b/Completion/Unix/Command/_init_d
index cdc373297..7b3c8ee41 100644
--- a/Completion/Unix/Command/_init_d
+++ b/Completion/Unix/Command/_init_d
@@ -1,7 +1,7 @@
#compdef -p */(init|rc[0-9S]#).d/*
-local cmds script
-local -a flags
+local cmds script state
+local -a flags line
_compskip=all
@@ -122,4 +122,21 @@ cmds=( $(_init_d_get_cmds) ) || return 1
(( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" commands cmds ||
cmds=(start stop)
-_arguments -s -A "-*" $flags ':init.d command:_sub_commands $cmds'
+local svcname=$words[1] ret=1
+
+_arguments -C -s -A "-*" $flags \
+ ':init.d command:_sub_commands $cmds' \
+ '*:: :->svcargs' && ret=0
+
+if [[ $state == svcargs ]]; then
+ case $svcname:$line[1] in
+ jail:(*stop|*restart|console|status)) _jails && ret=0 ;;
+ jail:*) _jails -c && ret=0 ;;
+ netif:*) _net_interfaces && ret=0 ;;
+ *)
+ _call_function ret _init_d-$svcname $line[1]
+ ;;
+ esac
+fi
+
+return ret
diff --git a/Completion/Unix/Command/_initctl b/Completion/Unix/Command/_initctl
deleted file mode 100644
index b60bdbc5b..000000000
--- a/Completion/Unix/Command/_initctl
+++ /dev/null
@@ -1,184 +0,0 @@
-#compdef initctl start stop restart reload status
-# Written by Bernhard Tittelbach
-# based on completion script by Mildred
-
-typeset -g -a -U _initctl_events_list _initctl_eventargs_list
-
-# run show-config -e and if possible parse out all events and KEY= arguments
-# otherwise provide some common values
-_initctl_fillarray_events_args ()
-{
- setopt extendedglob
- local showconfig="$(initctl show-config -e 2>| /dev/null)"
- if [[ -n "$showconfig" ]]; then
- _initctl_events_list=()
- _initctl_eventargs_list=()
- for cline in "${(f)showconfig}"; do
- if [[ "$cline" == (#s)\ \ (stop\ on|start\ on|emit)\ (#b)([[:alpha:]-_]##)(*)(#e) ]]; then
- _initctl_events_list+=($match[1])
- # this is a bit tricky, we take the string right of the matched event
- # and parse for \sUPPERCASE=\S (in perl-re syntax) substrings until there are no more matches
- # since we can't do multiple matches, we concatenated the remaining strings and try again
- local stml="$match[2]"
- while [[ "$stml" == (#b)(*)\ ([[:upper:]_]##\=)[^[:space:]](#b)(*) ]]; do
- _initctl_eventargs_list+=($match[2])
- stml="$match[1] $match[3]"
- done
- unset stml
- fi
- done
- else
- _initctl_events_list=( socket login-session-start desktop-session-start virtual-filesystems local-filesystems remote-filesystems all-swaps filesystem mounting mounted net-device-up start-portmap runlevel unmounted-remote-filesystems )
- _initctl_eventargs_list=( PRIMARY_DEVICE_FOR_DISPLAY= EXIT_STATUS= EXIT_SIGNAL= RUNLEVEL= MOUNTPOINT= TYPE= INTERFACE= )
- fi
- return 0
-}
-
-# list all upstart jobs, i.e. all files in /etc/init/
-_initctl_helper_jobs()
-{
- _path_files -W "/etc/init/" -g "*.conf(-.:r)"
-}
-
-# list events, generate array if necessary
-_initctl_known_events()
-{
- [[ ${#_initctl_events_list} -eq 0 ]] && _initctl_fillarray_events_args
- _values "Event" "$_initctl_events_list[@]"
-}
-
-# list events, allow multiple choices, generate array if necessary
-_initctl_multiple_known_events()
-{
- [[ ${#_initctl_events_list} -eq 0 ]] && _initctl_fillarray_events_args
- _values -s "," "event" "$_initctl_events_list[@]"
-}
-
-# list KEY= arguments, generate array if necessary
-_initctl_known_eventargs()
-{
- [[ ${#_initctl_eventargs_list} -eq 0 ]] && _initctl_fillarray_events_args
- _values "argument key" "$_initctl_eventargs_list[@]"
-}
-
-# describe and offer commands for initctl, then call matching completion function
-_initctl_command()
-{
- local cmds
- cmds=(
- start:"Start jobs"
- stop:"Stop jobs"
- restart:"Restart jobs"
- reload:"Send SIGHUP to process instance"
- status:"Query status of jobs"
- list:"List known jobs"
- emit:"Emit an event"
- reload-configuration:"tell init to reload config files (generally inotify is used)"
- version:"Request the version of the init daemon"
- log-priority:"Change the minimum priority of log messages from the init daemon"
- show-config:"Show start/stop/emit for processes"
- check-config:"Find jobs than can't be started"
- help:"display list of commands"
- )
-
- if (( CURRENT == 1 )); then
- _describe -t command "initctl command" cmds
- fi
-
- local cmd=$words[1]
-
- local curcontext="${curcontext%:*}:initctl-${cmd}"
- _call_function ret _initctl_${cmd_completion_funcs[${cmd}]-${cmd_completion_default}}
-}
-
-# completion for start/stop/restart/reload i.e. anything that take one job and multiple KEY= arguments's
-_initctl_startstop()
-{
- _arguments \
- '--no-wait[do not wait for operation to complete before exiting]' \
- "${common_args[@]}" \
- ':upstart job:_initctl_helper_jobs' \
- '*::argument key:_initctl_known_eventargs'
-}
-
-# completion for anything that takes one job
-_initctl_argjob()
-{
- _arguments \
- "${common_args[@]}" \
- ':upstart job:_initctl_helper_jobs' \
- '*::'
-}
-
-# completion for emit, providing options, one event and multiple KEY= arguments's
-_initctl_emit()
-{
- _arguments \
- '--no-wait[do not wait for event to finish before exiting]' \
- "${common_args[@]}" \
- ':event:_initctl_known_events' \
- '*::argument key:_initctl_known_eventargs'
-}
-
-# the fallback, just the options
-_initctl_basic()
-{
- _arguments \
- "${common_args[@]}"
-}
-
-# completion for show-config, additional option and one job
-_initctl_show-config()
-{
- _arguments \
- "(-e --enumerate)"{-e,--enumerate}"[enumerate emit lines]" \
- "${common_args[@]}" \
- '::upstart job:_initctl_helper_jobs' \
- '*::'
-}
-
-# completion for show-config, additional options and one job
-_initctl_check-config()
-{
- _arguments \
- "(-i --ignore-events)"{-i,--ignore-events}"[list of comma-separated events to ignore]:Events:_initctl_multiple_known_events" \
- "(-w --warn)"{-w,--warn}"[treat any unknown jobs or events as error]" \
- "${common_args[@]}" \
- '::upstart job:_initctl_helper_jobs' \
- '*::'
-}
-
-# after defining above functions, overwrite _initctl function so helper-functions are loaded only once
-_initctl()
-{
- local -a common_args
- common_args=(
- '--session[use D-Bus session bus to connect to init daemon (for testing)]'
- '--system[talk via DBUS system bus instead of socket]'
- '(-q --quiet)'{-q,--quiet}'[reduce output to errors only]'
- '(-v --verbose)'{-v,--verbose}'[increase output to include informational messages]'
- '--dest=[specify D-Bus name for init]:D-Bus name [com.ubuntu.Upstart]'
- '--help[display help and exit]'
- '--version[output version information and exit]'
- )
-
- # map each initctl function to a completion function
- local -A cmd_completion_funcs
- cmd_completion_funcs=( start startstop stop startstop restart startstop reload startstop show-config show-config status argjob emit emit check-config check-config )
-
- # define fallback completion function
- local cmd_completion_default=basic
-
- # depending on which command was used, call different completion functions
- case $service in
- initctl)
- _arguments "${common_args[@]}" '*::initctl command:_initctl_command'
- ;;
- start|stop|restart|reload|status)
- _call_function ret _initctl_${cmd_completion_funcs[${service}]-${cmd_completion_default}}
- ;;
- *) return 1 ;;
- esac
-}
-
-_initctl "$@"
diff --git a/Completion/Unix/Command/_jq b/Completion/Unix/Command/_jq
index e8e6b0913..fb44702b2 100644
--- a/Completion/Unix/Command/_jq
+++ b/Completion/Unix/Command/_jq
@@ -30,7 +30,7 @@ _arguments -S -s : \
'(-r --raw-output -j --join-output)--raw-output0[like -r, with NUL after each output]' \
'(-r --raw-output --raw-output0 -j --join-output)'{-j,--join-output}"[like -r, without newlines between outputs]" \
'(-f --from-file)'{-f,--from-file}'[read filter from file]: :_files' \
- '-L+[prepend a directory to the module search path]:_directories' \
+ \*{-L+,--library-path}'[prepend a directory to the module search path]:_directories' \
'(-e --exit-status)'{-e,--exit-status}'[report "false" and "null" results via exit code]' \
'*--arg[pre-set a variable to a string]:variable name: :value (string)' \
'*--argjson[pre-set a variable to an object]:variable name: :value (JSON)' \
diff --git a/Completion/Unix/Command/_ldd b/Completion/Unix/Command/_ldd
index 98ac41e14..bbac09225 100644
--- a/Completion/Unix/Command/_ldd
+++ b/Completion/Unix/Command/_ldd
@@ -26,6 +26,17 @@ else
'-s[display search path used]'
'-v[displays all dependency relationships]'
)
+ ;|
+ solaris2.<11->)
+ args+=(
+ '-c[disable configuration file used]'
+ '-D[skip deferred dependency loading]'
+ '-p[display unresolved parent and external references]'
+ '-S+[specify system root]:directory:_directories'
+ '-w[display unresolved weak references]'
+ '(- *)'{-\?,--help}'[display usage information]'
+ '(- *)'{-V,--version}'[display version information]'
+ )
;;
freebsd*)
args=(
diff --git a/Completion/Unix/Command/_less b/Completion/Unix/Command/_less
index b7e658d7e..f20a50818 100644
--- a/Completion/Unix/Command/_less
+++ b/Completion/Unix/Command/_less
@@ -88,17 +88,25 @@ _arguments -S -s -A "[-+]*" \
'(-\" --quotes)'{'-\"+',--quotes=}'[change quoting character]:quoting characters' \
'(-~ --tilde)'{-~,--tilde}"[don't display tildes after end of file]" \
'(-\# --shift)'{'-\#+',--shift=}"[specify amount to move when scrolling horizontally]:number of columns or fraction of screen width [.5]" \
+ '--autosave=[set additional actions which cause the history file to be saved]: : _values -s "" action
+ "(*)m[setting or clearing a mark]"
+ "(*)/[searching]"
+ "(*)\![running a shell command]"
+ "(m / !)\*[any action; same as m/!]"' \
+ '--emouse=[enable mouse features]:mouse feature:_sequence compadd - vscroll vdrag hscroll hdrag lclick rclick scroll drag hmove vmove move click all' \
+ '--end-prompt=[specify string to be printed after erasing the prompt]:string' \
'--exit-follow-on-close[exit F command on a pipe when writer closes pipe]' \
'--file-size[automatically determine the size of the input file]' \
'--follow-name[the F command changes file if the input file is renamed]' \
'--form-feed[stop scrolling when a form feed character (^L) is reached]' \
'--header=[set header size]:lines,columns,first-line' \
+ '--hilite-target=[highlight the target line]' \
'--incsearch[search file as each pattern character is typed in]' \
'--intr=[specify interrupt character instead of ^X]:char [^X]' \
'--line-num-width=[set the width of line number field]:width [7]' \
'--match-shift=[with -S, shift horizontally to make the match visible]:number of columns or fraction of screen width' \
'--modelines=[look for vim modelines]:number of lines to search' \
- '(--MOUSE)--mouse[enable mouse input]' \
+ '(--MOUSE)--mouse[enable mouse clicking and vertical scrolling]' \
'(--mouse)--MOUSE[enable mouse input, wheel down moves backwards in the file]' \
"--no-edit-warn[don't warn when using v command on a file opened by LESSOPEN]" \
'--no-histdups[remove duplicates from command history]' \
@@ -123,6 +131,7 @@ _arguments -S -s -A "[-+]*" \
"E[multi-file]" "F[from first line]" "K[highlight]"
"N[non-matching]" "R[literal]" "W[wrap]" -' \
'--show-preproc-errors[display a message if preprocessor exits with an error status]' \
+ '--past-eof[scrolling commands continue past end of file]' \
'--status-col-width=[set the width of the -J status column]:width [2]' \
'--status-line[highlight or color the entire line containing a mark]' \
'--use-backslash[subsequent options use backslash as escape char]' \
diff --git a/Completion/Unix/Command/_ln b/Completion/Unix/Command/_ln
index 05c89bac2..75e63514a 100644
--- a/Completion/Unix/Command/_ln
+++ b/Completion/Unix/Command/_ln
@@ -10,7 +10,7 @@ args=(
)
_pick_variant -r variant -b zsh gnu='(GNU|uutils)' $OSTYPE --version
-case $variant; in
+case $variant in
gnu)
opts=()
args=(
diff --git a/Completion/Unix/Command/_ls b/Completion/Unix/Command/_ls
index a92b91b31..5cd2e7f54 100644
--- a/Completion/Unix/Command/_ls
+++ b/Completion/Unix/Command/_ls
@@ -108,6 +108,12 @@ if ! _pick_variant gnu='(GNU|uutils)' unix --version; then
'-Z[display MAC label]'
)
fi
+ if [[ $OSTYPE = freebsd<15->.* ]]; then
+ arguments+=(
+ '(--group-directories-first)--group-directories=:order:(first last)'
+ '(--group-directories)--group-directories-first'
+ )
+ fi
if [[ $OSTYPE = darwin* ]]; then
arguments+=(
'-@[display extended attribute keys and sizes in long listing]'
@@ -118,14 +124,18 @@ if ! _pick_variant gnu='(GNU|uutils)' unix --version; then
'-%[distinguish dataless files and directories with a %]'
)
fi
- if [[ $OSTYPE = solaris* ]]; then
+ if [[ $OSTYPE = (aix|solaris)* ]]; then
arguments+=(
'(-q)-b[print octal escapes for control characters]'
'(-l -1 -C -m -x)-o[long listing but without group information]'
'(-l -t -s -r -a)-f[interpret each argument as a directory]'
+ '-H[follow symlinks on the command line]'
+ )
+ fi
+ if [[ $OSTYPE = solaris* ]]; then
+ arguments+=(
'(-E -l)-e[long listing with full and consistent date/time]'
'(-e -l)-E[long listing with ISO format date/time]'
- '-H[follow symlinks on the command line]'
'-v[long listing with verbose ACL information]'
'-V[long listing with compact ACL information]'
'-@[long listing with marker for extended attribute information]'
diff --git a/Completion/Unix/Command/_lsof b/Completion/Unix/Command/_lsof
index 60f59a589..a6dd4a03e 100644
--- a/Completion/Unix/Command/_lsof
+++ b/Completion/Unix/Command/_lsof
@@ -119,7 +119,7 @@ case $state in
states)
if compset -P 1 '*:'; then
_sequence _wanted states expl state compadd - -M 'm:{a-z}={A-Z}' \
- CLOSED IDLE BOUND LISTEN ESTABLISHED SYN_SENT SYN_RCDV ESTABLISHED \
+ CLOSED IDLE BOUND LISTEN ESTABLISHED SYN_SENT SYN_RCVD \
CLOSE_WAIT FIN_WAIT1 CLOSING LAST_ACK FIN_WAIT_2 TIME_WAIT && ret=0
else
compset -S ':*' || suf=( -qS : )
diff --git a/Completion/Unix/Command/_lua b/Completion/Unix/Command/_lua
index 3a1ef4fd7..0a4facbe3 100644
--- a/Completion/Unix/Command/_lua
+++ b/Completion/Unix/Command/_lua
@@ -1,4 +1,4 @@
-#compdef lua -P lua[0-9.-]##
+#compdef lua flua -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
diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index 28bc12fe7..888d73895 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -76,7 +76,7 @@ _man() {
[[ $variant == (freebsd)* ]] && args+=(
'(: -)-h[display help information]'
# @todo Could enumerate these
- '-m[search manual of specified architecture]:architecture'
+ '-m+[search manual of specified architecture]:architecture'
'-o[use non-localized man pages]'
'(-a)-S+[specify manual sections to search]: :->sects'
)
@@ -135,7 +135,7 @@ _man() {
[[ $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'
+ '-S+[search manual of specified architecture]:architecture'
)
[[ $variant == solaris* ]] && args+=(
"(${(j< >)modes})-l[display file locations]"
diff --git a/Completion/Unix/Command/_monotone b/Completion/Unix/Command/_monotone
deleted file mode 100644
index bcaab87f0..000000000
--- a/Completion/Unix/Command/_monotone
+++ /dev/null
@@ -1,43 +0,0 @@
-#compdef mtn
-
-local -a cmds
-cmds=(
- automate:automation db:database fdiff:debug fload:debug fmerge:debug
- get_roster:debug identify:debug rcs_import:debug annotate:informative
- cat:informative complete:informative diff:informative help:informative
- list:informative log:informative ls:informative show_conflicts:informative
- status:informative cert:key+cert chkeypass:key+cert dropkey:key+cert
- genkey:key+cert trusted:key+cert pull:network push:network serve:network
- sync:network privkey:packet\ i/o pubkey:packet\ i/o read:packet\ i/o
- cvs_import:rcs approve:review comment:review disapprove:review tag:review
- testresult:review checkout:tree co:tree explicit_merge:tree heads:tree
- merge:tree merge_into_dir:tree migrate_workspace:tree propagate:tree
- refresh_inodeprints:tree setup:tree set:vars unset:vars add:workspace
- attr:workspace ci:workspace commit:workspace drop:workspace mv:workspace
- pivot_root:workspace pluck:workspace rename:workspace revert:workspace
- rm:workspace update:workspace
-)
-
-_arguments \
- '--brief[print a brief version of the normal output]' \
- '--confdir[set location of configuration directory]:confdir:_files -/' \
- '(-d --db)'{-d,--db}'[set name of database]:dbname' \
- '--debug[print debug log to stderr while running]' \
- '--dump[file to dump debugging log to, on failure]:dumpfile:_files' \
- '--full-version[print detailed version number, then exit]' \
- '(-h --help)'{-h,--help}'[display help message]' \
- '(-k --key)'{-k,--key}'[set key for signatures]:key:' \
- '--keydir[set location of key store]:keydir:_files -/' \
- '--log[file to write the log to]:logfile:_files' \
- '--norc[do not load ~/.monotone/monotonerc or _MTN/monotonerc lua files]' \
- '--nostd[do not load standard lua hooks]' \
- '--pid-file[record process id of server]:arg:' \
- '--quiet[suppress verbose, informational and progress messages]' \
- '--rcfile[load extra rc file]:extra rcfile:_files' \
- '--reallyquiet[suppress warning, verbose, informational and progress messages]' \
- '--root[limit search for workspace to specified root]:root:_files -/' \
- '--ticker[set ticker style]:ticker style:(count dot none)' \
- '--version[print version number, then exit]' \
- '(-@ --xargs)'{-@,--xargs}'[insert command line arguments taken from the given file]:file:_files' \
- '1:command: _describe -t commands command cmds' \
- '*:file:_files'
diff --git a/Completion/Unix/Command/_moosic b/Completion/Unix/Command/_moosic
deleted file mode 100644
index 475a0c75c..000000000
--- a/Completion/Unix/Command/_moosic
+++ /dev/null
@@ -1,487 +0,0 @@
-#compdef moosic
-
-_moosic_add_cmds() {
-
- # querying for information
- typeset -a queries
- queries=(
- "help:print brief description of command"
- "current:print name of currently playing song"
- "current-time:print the amount of time the current song has been playing"
- "list:print the list of items in the current song queue"
- "plainlist:print the current song queue without numbering each line"
- "history:print a list of items that were recently played"
- {status,state}":print the current state of the music daemon"
- "length:print the number of items in the queue"
- "ispaused:show whether the current song is paused or not"
- "islooping:show whether the server is in loop mode"
- "isadvancing:show whether the server is advancing through the song queue"
- "version:print version information for client and server"
- )
-
-
- # appending to song queue
- typeset -a appending
- appending=(
- {append,add}":add the files to be played to the end of the song queue"
- {pl-append,pl-add}":add the items listed in the given playlist files to end of queue"
- "prepend:add the files to be played to the beginning of the song queue"
- "pl-prepend:add the items in the given playlist files to beginning of queue"
- "mixin:add the files to the song queue and reshuffle the entire queue"
- "pl-mixin:add items in given playlist files to song queue and reshuffle the entire queue"
- "replace:replace the current contents of the song queue with files listed"
- "pl-replace:replace current contents of song queue with songs given in playlists"
- "insert:insert the given items at a given point in the song queue"
- "pl-insert:insert items from playlist files at specified point in queue"
- "putback:reinsert current song at start of song queue"
- "stagger-add:adds file list to end of queue after rearranging queue into staggered order"
- "stagger-merge:adds given file list to queue in interleaved fashion"
- "interval-add:inserts given songs with regular frequency specified by interval argument"
- )
-
- # removing
- typeset -a removing
- removing=(
- {cut,del}":removes all song queue items in given range"
- "crop:removes all song queue items that do not fall within given range"
- "remove:remove all song queue items matching any one of given regexps"
- "filter:remove all queue items not matching all given regexps"
- "clear:clear song queue"
- "wipe:clear song queue and stop current song"
- )
-
- # rearranging
- typeset -a rearranging
- rearranging=(
- "move:move all items in given range to new position in song queue"
- "move-pattern:moves all items matching the given regexp to new position"
- "swap:trade places of songs in two specified ranges"
- {shuffle,reshuffle}":reshuffle song queue within an optional range"
- "sort:sort queue within optional range"
- "reverse:reverse order of song queue"
- "partial-sort:sort items matching each regexp"
- "stagger:stagger items matching each regexp"
- "sub:perform regular expression substitution on all items in queue"
- "suball:like sub, but replace all occurrences of the pattern"
- )
-
- # general management
- typeset -a general
- general=(
- "next:jumps ahead, number of songs optional"
- "previous:retreats to previously played song"
- "goto:jumps to next song matching regexp"
- "gobackto:jumps back to most recent previous song matching regexp"
- "noadvance:halt queue advancement"
- "advance:resume queue advancement"
- "toggle-advance:toggle queue advancement"
- "stop:stop playing current song, stop processing queue, put current song back"
- "pause:suspend current song to resume it later"
- "unpause:unpause current song"
- "play:resume playing"
- "loop:turn loop mode on"
- "noloop:turn loop mode off"
- "toggle-loop:toggle loop mode"
- "reconfigure:daemon reload configuration file"
- "showconfig:show daemon filetype associations"
- "start-server:starts new instance of daemon with given options"
- {quit,exit,die}":quit daemon"
- )
-
- _describe queries queries -J queries
- _describe appending appending -J appending
- _describe removing removing -J removing
- _describe rearranging rearranging -J rearranging
- _describe general general -J general
-}
-
-_moosic() {
- typeset context state line
- typeset -A opt_args
-
- typeset -a filelist_opts
- filelist_opts=(
- '(-g --shuffle-global)'{-g,--shuffle-global}'[shuffle filelist after directory expansion]'
- '(-d --shuffle-dir)'{-d,--shuffle-dir}'[shuffle results of expanding the directories]'
- '(-a --shuffle-args)'{-a,--shuffle-args}'[shuffle actual command line arguments]'
- '(-o --inorder)'{-o,--inorder}'[do not shuffle filelist]'
- '(-s --sort)'{-s,--sort}'[sort filelist lexicographically after expansion]'
- '(-r --no-recurse)'{-r,--no-recurse}'[do not recurse through directories]'
- '(-n --no-file-munge)'{-n,--no-file-munge}'[do not modify names in expanded filelist]'
- '(-f --auto-find)'{-f,--auto-find}'[perform fuzzy search for music files]'
- '(-F --auto-grep)'{-F,--auto-grep}'[like --auto-find but with regexp]'
- '(-U --allow-unplayable)'{-U,--allow-unplayable}'[allow addition of unknown song types]'
- )
-
- typeset -a auto_opts
- auto_opts=(
- '(-m --music-dir)'{-m,--music-dir}'[directory used for auto-find, auto-grep]:directory:_files'
- )
-
- typeset -a main_opts
- main_opts=(
- '(-i --ignore-case)'{-i,--ignore-case}'[treat regexps as if they are case-insensitive]'
- '(-S --showcommands)'{-S,--showcommands}'[show all moosic commands, then exit]'
- '(-h --help)'{-h,--help}'[print help message then exit]'
- '(-v --version)'{-v,--version}'[print version information, then exit]'
- '(-c --config-dir)'{-c,--config-dir}'[configuration directory]:directory:_files'
- '(-t --tcp)'{-t,--tcp}'[talk to server at specified host and port]:host\:port:'
- '(-N --no-startserver)'{-N,--no-startserver}'[do not start moosicd server]'
- )
-
- typeset -a list_opts
- list_opts=(
- '(-C --current-in-list)'{-C,--current-in-list}'[print currently playing song in list]'
- )
-
- # GLOBAL ARGUMENTS
- # do not use the -A option here. It will break the processing of
- # positional arguments.
- _arguments $main_opts $list_opts $auto_opts $filelist_opts \
- '1: :->cmd' \
- '*:: :->posarg'
-
- if [[ $state == cmd ]]; then
- _moosic_add_cmds
- elif [[ $state == posarg ]]; then
- _moosic_cmd_${line[1]}
- fi
-}
-
-# Do something, but only if the current word is 2.
-_do2() {
- if (( CURRENT == 2 )); then
- $@
- else
- _message 'no more arguments'
- fi
-}
-
-### QUERY COMMANDS
-
-_moosic_cmd_help() {
- _do2 '_moosic_add_cmds'
-}
-
-_moosic_cmd_current() {
- _message 'no arguments'
-}
-
-_moosic_cmd_current-time() {
- _do2 '_message' 'strftime string'
-}
-
-_moosic_cmd_list() {
- _do2 '_message' 'range'
-}
-
-_moosic_cmd_plainlist() {
- _do2 '_message' 'range'
-}
-
-_moosic_cmd_history() {
- _do2 '_message' 'maximum number of entries'
-}
-
-_moosic_cmd_status() {
- _message 'no arguments'
-}
-
-_moosic_cmd_state() {
- _message 'no arguments'
-}
-
-_moosic_cmd_length() {
- _message 'no arguments'
-}
-
-_moosic_cmd_ispaused() {
- _message 'no arguments'
-}
-
-_moosic_cmd_islooping() {
- _message 'no arguments'
-}
-
-_moosic_cmd_isadvancing() {
- _message 'no arguments'
-}
-
-_moosic_cmd_version() {
- _message 'no arguments'
-}
-
-### APPENDING COMMANDS
-
-_moosic_song_files()
-{
- _arguments -A '-*' $main_opts $filelist_opts $auto_opts \
- '*:song file:_files'
-}
-
-_moosic_cmd_append() {
- _moosic_song_files
-}
-
-_moosic_cmd_add() {
- _moosic_song_files
-}
-
-_moosic_cmd_pl-append() {
- _moosic_song_files
-}
-
-_moosic_cmd_pl-add() {
- _moosic_song_files
-}
-
-_moosic_cmd_prepend() {
- _moosic_song_files
-}
-
-_moosic_cmd_pl-prepend() {
- _moosic_song_files
-}
-
-_moosic_cmd_mixin() {
- _moosic_song_files
-}
-
-_moosic_cmd_pl-mixin() {
- _moosic_song_files
-}
-
-_moosic_cmd_replace() {
- _moosic_song_files
-}
-
-_moosic_cmd_pl-replace() {
- _moosic_song_files
-}
-
-_moosic_cmd_insert() {
- _moosic_song_files
-}
-
-_moosic_cmd_pl-insert() {
- _moosic_song_files
-}
-
-_moosic_cmd_putback() {
- _message 'no arguments'
-}
-
-_moosic_cmd_stagger-add() {
- _moosic_song_files
-}
-
-_moosic_cmd_stagger-merge() {
- _moosic_song_files
-}
-
-_moosic_cmd_interval-add() {
- _arguments -A '-*' $main_opts $filelist_opts \
- '1:interval:' \
- '*:song file:_files'
-}
-
-### REMOVING COMMANDS
-
-_moosic_cmd_cut() {
- _do2 '_message' 'range'
-}
-
-_moosic_cmd_del() {
- _do2 '_message' 'range'
-}
-
-_moosic_cmd_crop() {
- _do2 '_message' 'range'
-}
-
-_moosic_cmd_remove() {
- _do2 '_message' 'regex'
-}
-
-_moosic_cmd_filter() {
- _do2 '_message' 'regex'
-}
-
-_moosic_cmd_clear() {
- _message 'no arguments'
-}
-
-_moosic_cmd_wipe() {
- _message 'no arguments'
-}
-
-### REARRANGING COMMANDS
-
-_moosic_cmd_move() {
- _arguments -A '-*' $main_opts \
- '1:range:' \
- '2:index:' \
- '*:no more arguments:'
-}
-
-_moosic_cmd_move-pattern() {
- _arguments -A '-*' $main_opts \
- '1:regex:' \
- '2:index:' \
- '*:no more arguments:'
-}
-
-_moosic_cmd_swap() {
- _arguments -A '-*' $main_opts \
- '1:range:' \
- '2:range:' \
- '*:no more arguments:'
-}
-
-_moosic_cmd_shuffle() {
- _arguments -A '-*' $main_opts \
- '1:range (optional):' \
- '*:no more arguments:'
-}
-
-_moosic_cmd_reshuffle() {
- _arguments -A '-*' $main_opts \
- '1:range (optional):' \
- '*:no more arguments:'
-}
-
-_moosic_cmd_sort() {
- _arguments -A '-*' $main_opts \
- '1:range (optional):' \
- '*:no more arguments:'
-}
-
-_moosic_cmd_reverse() {
- _arguments -A '-*' $main_opts \
- '1:range (optional):' \
- '*:no more arguments:'
-}
-
-_moosic_cmd_partial-sort() {
- _do2 '_message' 'regex'
-}
-
-_moosic_cmd_stagger() {
- _do2 '_message' 'regex'
-}
-
-_moosic_cmd_sub() {
- _arguments -A '-*' $main_opts \
- '1:pattern:' \
- '2:replacement:' \
- '3:range (optional):' \
- '*:no more arguments:'
-}
-
-_moosic_cmd_suball() {
- _arguments -A '-*' $main_opts \
- '1:pattern:' \
- '2:replacement:' \
- '3:range (optional):' \
- '*:no more arguments:'
-}
-
-### GENERAL COMMANDS
-
-_moosic_cmd_next() {
- if (( CURRENT == 2 )); then
-
- typeset -a display display_cmd
- if zstyle -a ":completion:${curcontext}:next" \
- 'command' display_cmd; then
- $display_cmd
- else
- display=(${(f)"$(moosic list)"})
- fi
-
- typeset -a numbers
- numbers=({1..${#display}})
-
- compadd -V songs -d display -a numbers
- else
- _message 'no more arguments'
- fi
-}
-
-_moosic_cmd_previous() {
- _do2 '_message' 'number to skip'
-}
-
-_moosic_cmd_goto() {
- _do2 '_message' 'regex'
-}
-
-_moosic_cmd_gobackto() {
- _do2 '_message' 'regex'
-}
-
-_moosic_cmd_noadvance() {
- _message 'no arguments'
-}
-
-_moosic_cmd_advance() {
- _message 'no arguments'
-}
-
-_moosic_cmd_toggle-advance() {
- _message 'no arguments'
-}
-
-_moosic_cmd_stop() {
- _message 'no arguments'
-}
-
-_moosic_cmd_pause() {
- _message 'no arguments'
-}
-
-_moosic_cmd_unpause() {
- _message 'no arguments'
-}
-
-_moosic_cmd_play() {
- _message 'no arguments'
-}
-
-_moosic_cmd_loop() {
- _message 'no arguments'
-}
-
-_moosic_cmd_noloop() {
- _message 'no arguments'
-}
-
-_moosic_cmd_toggle-loop() {
- _message 'no arguments'
-}
-
-_moosic_cmd_reconfigure() {
- _message 'no arguments'
-}
-
-_moosic_cmd_showconfig() {
- _message 'no arguments'
-}
-
-_moosic_cmd_start-server() {
- _message 'options'
-}
-
-_moosic_cmd_quit() {
- _message 'no arguments'
-}
-
-_moosic_cmd_exit() {
- _message 'no arguments'
-}
-
-_moosic_cmd_die() {
- _message 'no arguments'
-}
-
-_moosic "$@"
diff --git a/Completion/Unix/Command/_mount b/Completion/Unix/Command/_mount
index bf75aa118..bdabd3791 100644
--- a/Completion/Unix/Command/_mount
+++ b/Completion/Unix/Command/_mount
@@ -293,8 +293,8 @@ if (( ! $+_fs_any )); then
'sync[do I/O synchronously]'
)
_fs_cdfs=(
- '(nodefperm)defperm[ignore permission bits]'
- '(defperm)defperm[use permission bits]'
+ '(defperm)nodefperm[ignore permission bits]'
+ '(nodefperm)defperm[use permission bits]'
'noversion[strip off version extension]'
'rrip[use RRIP extensions]'
)
diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc
index e3383e56d..83700d828 100644
--- a/Completion/Unix/Command/_mpc
+++ b/Completion/Unix/Command/_mpc
@@ -234,7 +234,7 @@ _mpc_play() {
}
_mpc_seek() {
- _message -e position 'position ([+-][HH:MM:SS]|<0-100>%%)'
+ _message -e position 'position ([+-][HH:MM:SS]|<0-100>%)'
}
_mpc_seekthrough() {
@@ -380,7 +380,7 @@ local mpccmd="$words[1]"
_arguments -C \
'(-q --quiet --no-status -v --verbose)'{-v,--verbose}'[give verbose output]' \
'(-q --quiet --no-status -v --verbose)'{-q,--quiet,--no-status}'[prevent printing song status on completion]' \
- '(-h --host)'{-h,--host=}'[connect to specified host]:_hosts' \
+ '(-h --host)'{-h,--host=}'[connect to specified host]: :_hosts' \
'(-p --port)'{-p,--port=}'[connect to server port]:port' \
'(-f --format)'{-f,--format=}'[specify the format of song display]:format string:->formats' \
'(-w --wait)'{-w,--wait}'[wait for operation to finish (e.g. database update)]' \
diff --git a/Completion/Unix/Command/_mtr b/Completion/Unix/Command/_mtr
index 9a73cfbd4..c5f7ea129 100644
--- a/Completion/Unix/Command/_mtr
+++ b/Completion/Unix/Command/_mtr
@@ -9,6 +9,7 @@ _arguments -s -S \
'(H -f --first-ttl)'{-f+,--first-ttl=}'[specify TTL to start]:TTL [1]' \
'(H -m --max-ttl)'{-m+,--max-ttl=}'[specify maximum number of hops to probe]:hops [30]' \
'(H -U --max-unknown)'{-U+,--max-unknown=}'[specify maximum unknown hosts]:maximum [5]' \
+ '(H -E --max-display-path)'{-E+,--max-display-path=}'[specify maximum number of ECMP paths to display]:ECMP paths [8]' \
'(H -P --port)'{-P+,--port=}'[specify target port for TCP, SCTP or UDP]:port' \
'(H -L --localport -T --tcp -S --sctp)'{-L+,--localport=}'[specify source port number for UDP]' \
'(H -s --psize 2)'{-s+,--psize=}'[packet size]:packet size (bytes)' \
@@ -41,6 +42,8 @@ _arguments -s -S \
"I[interarrival jitter]"' \
'(H -z --aslookup -y --ipinfo)'{-y+,--ipinfo=}'[select IP information in output]:information:((0\:display\ AS\ number 1\:display\ IP\ prefix 2\:display\ country\ code 3\:display\ RIR 4\:display\ allocation\ date))' \
'(H -y --ipinfo -z --aslookup)'{-z,--aslookup}'[display AS number]' \
+ '(H)--ipinfo_provider4=[specify provider for IPv4 AS lookups]:domain [origin.asn.cymru.com]' \
+ '(H)--ipinfo_provider6=[specify provider for IPv6 AS lookups]:domain [origin6.asn.cymru.com]' \
'(H)1:destination host:_hosts' \
'(H)2:packet size (bytes)' \
+ '(H)' \
diff --git a/Completion/Unix/Command/_mv b/Completion/Unix/Command/_mv
index cc33819b9..707f848c5 100644
--- a/Completion/Unix/Command/_mv
+++ b/Completion/Unix/Command/_mv
@@ -3,7 +3,7 @@
local args variant aopts=( -A '-*' )
_pick_variant -r variant -b zsh gnu='(GNU|uutils)' $OSTYPE --version
-case $variant; in
+case $variant in
gnu)
aopts=()
args=(
diff --git a/Completion/Unix/Command/_myrepos b/Completion/Unix/Command/_myrepos
index d26c1245b..b667746e8 100644
--- a/Completion/Unix/Command/_myrepos
+++ b/Completion/Unix/Command/_myrepos
@@ -61,7 +61,7 @@ case $state in
"offline:advise mr that it is in offline mode"
"online:advise mr that it is in online mode"
"remember:remember a command to be run later"
- "help:display this help."
+ "help:display help."
)
mr_alias=(
diff --git a/Completion/Unix/Command/_nano b/Completion/Unix/Command/_nano
new file mode 100644
index 000000000..29fb5337a
--- /dev/null
+++ b/Completion/Unix/Command/_nano
@@ -0,0 +1,87 @@
+#compdef nano rnano
+
+local -a args context state state_descr line expl
+local -A opt_args
+
+args=(
+ '(-A --smarthome)'{-A,--smarthome}'[enable smart home key]'
+ '(-B --backup)'{-B,--backup}'[save backups of existing files]'
+ '(-C --backupdir)'{-C+,--backupdir=}'[save uniquely numbered backups to specified directory]:backup directory:_directories'
+ '(-D --boldtext)'{-D,--boldtext}'[use bold instead of reverse video text]'
+ '(-E --tabstospaces)'{-E,--tabstospaces}'[convert typed tabs to spaces]'
+ '(-F --multibuffer)'{-F,--multibuffer}'[read file into new buffer by default]'
+ '(-G --locking)'{-G,--locking}'[use vim-style lock files]'
+ '(-H --historylog)'{-H,--historylog}'[remember search/replace strings]'
+ '(-I --ignorercfiles)'{-I,--ignorercfiles}"[don't look at nanorc files]"
+ '(-J --guidestripe)'{-J+,--guidestripe=}'[show vertical stripe at specified column]: :_numbers -l1 "column number"'
+ '(-K --rawsequences)'{-K,--rawsequences}'[interpret escape sequences directly instead of via ncurses]'
+ '(-L --nonewlines)'{-L,--nonewlines}"[don't automatically add EOF newline]"
+ '(-M --trimblanks)'{-M,--trimblanks}'[trim trailing whitespaces when hard-wrapping]'
+ '(-N --noconvert -u --unix)'{-N,--noconvert}"[don't convert files from DOS/Mac format]"
+ '(-O --bookstyle)'{-O,--bookstyle}'[when justifying, leading whitespace means new paragraph]'
+ '(-P --positionlog)'{-P,--positionlog}'[remember cursor position]'
+ '(-Q --quotestr)'{-Q+,--quotestr=}'[specify regular expression to match quoting]:quoting regex [^([ \t]*([!#%\:;>|}]|//))+]'
+ '(-R --restricted)'{-R,--restricted}'[restrict access to the file system]'
+ '(-S --softwrap)'{-S,--softwrap}'[soft-wrap long lines]'
+ '(-T --tabsize)'{-T+,--tabsize=}'[specify tab width]: :_numbers -u columns -l1 -d8 "tab width"'
+ '(-c --constantshow -U --quickblank)'{-U,--quickblank}'[hide status-bar messages after next keystroke]'
+ '(- : *)'{-V,--version}'[display version information]'
+ '(-W --wordbounds -X --wordchars)'{-W,--wordbounds}'[detect word boundaries more accurately]'
+ '(-W --wordbounds -X --wordchars)'{-X+,--wordchars=}'[specify word characters]:word characters'
+ '(-Y --syntax)'{-Y+,--syntax=}'[specify syntax-highlighting definition]: :->syntaxes'
+ '(-Z --zap)'{-Z,--zap}'[let Backspace/Delete erase marked region]'
+ '(-a --atblanks)'{-a,--atblanks}'[when soft wrapping, wrap at whitespace]'
+ '(-b --breaklonglines -w --nowrap)'{-b,--breaklonglines}'[automatically hard-wrap long lines]'
+ '(-c --constantshow -U --quickblank)'{-c,--constantshow}'[constantly report cursor position in status bar]'
+ '(-d --rebinddelete)'{-d,--rebinddelete}'[fix Backspace/Delete confusion problem]'
+ '(-e --emptyline)'{-e,--emptyline}'[keep line below title bar empty]'
+ '(-f --rcfile)'{-f+,--rcfile=}'[use only specified file for configuring nano]:rc file:_files'
+ '(-g --showcursor)'{-g,--showcursor}'[show cursor in file browser and help viewer]'
+ '(- : *)'{-h,--help}'[display help information]'
+ '(-i --autoindent)'{-i,--autoindent}'[automatically indent new lines]'
+ '(-j --jumpyscrolling)'{-j,--jumpyscrolling}'[scroll per half-screen, not per line]'
+ '(-k --cutfromcursor)'{-k,--cutfromcursor}"[make 'cut text' (^k) cut from cursor to end of line]"
+ '(-l --linenumbers)'{-l,--linenumbers}'[show line numbers]'
+ '(-m --mouse)'{-m,--mouse}'[enable mouse support]'
+ '(-n --noread)'{-n,--noread}'[only write to named files (do not read)]'
+ '(-o --operatingdir)'{-o+,--operatingdir=}'[specify operating directory]:operating directory:_directories'
+ '(-p --preserve -/ --modernbindings)'{-p,--preserve}'[preserve XON (^q) and XOFF (^s)]'
+ '(-q --indicator)'{-q,--indicator}'[show position indicator (scroll bar)]'
+ '(-r --fill)'{-r+,--fill=}'[specify width for hard-wrap and justify]: :_numbers -u columns -Nd-8 "wrap width"'
+ '(-s --speller)'{-s+,--speller=}'[specify spell-checking program]:spell-checking program/command:_cmdstring'
+ '(-t --saveonexit)'{-t,--saveonexit}'[save changes on exit without prompting]'
+ '(-N --noconvert -u --unix)'{-u,--unix}'[save files by default in Unix format]'
+ '(-v --view)'{-v,--view}'[disallow editing (read-only mode)]'
+ '(-b --breaklonglines -w --nowrap)'{-w,--nowrap}"[don't hard-wrap long lines]"
+ '(-x --nohelp)'{-x,--nohelp}"[don't show help lines at bottom]"
+ '(-y --afterends)'{-y,--afterends}'[make Ctrl+Right and Ctrl+Delete stop at word ends]'
+ '(- : *)'{-z,--listsyntaxes}'[list names of available syntax definitions]'
+ '(-! --magic)'{-!,--magic}'[use libmagic to determine syntax if necessary]'
+ '(-@ --colonparsing)'{-@,--colonparsing}'[accept filename:linenumber notation on command line]'
+ '(-% --stateflags)'{-%,--stateflags}'[show state flags in title bar]'
+ '(-_ --minibar)'{-_,--minibar}'[hide title bar and show mini bar at bottom]'
+ '(-0 --zero)'{-0,--zero}'[hide UI, use whole terminal]'
+ '(-/ --modernbindings)'{-/,--modernbindings}'[use better-known key bindings]'
+ '*: :->files'
+)
+
+_arguments -s -S : $args && ret=0
+
+case $state in
+ syntaxes)
+ local -a tmp
+ tmp=( ${(f)"$( _call_program syntaxes $words[1] --listsyntaxes )"} )
+ tmp=( ${tmp:#(#i)*available syntax*} )
+ tmp=( ${(@Z<n>)tmp} )
+ _wanted syntaxes expl syntax compadd -a - tmp && ret=0
+ ;;
+
+ files)
+ _alternative \
+ 'line-pattern: :_guard "(|+*)" "+line[,column] or +[crCR]{/|?}pattern"' \
+ 'files: :_files' \
+ && ret=0
+ ;;
+esac
+
+return ret
diff --git a/Completion/Unix/Command/_netstat b/Completion/Unix/Command/_netstat
index 35d639f99..256337e22 100644
--- a/Completion/Unix/Command/_netstat
+++ b/Completion/Unix/Command/_netstat
@@ -14,7 +14,7 @@ case $OSTYPE in
linux-gnu)
families=(
'(-4 --inet)'{-4,--inet}
- '(-6 --inet)'{-4,--inet6}
+ '(-6 --inet)'{-6,--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
diff --git a/Completion/Unix/Command/_ngrep b/Completion/Unix/Command/_ngrep
index 924597826..28d6ddc88 100644
--- a/Completion/Unix/Command/_ngrep
+++ b/Completion/Unix/Command/_ngrep
@@ -25,6 +25,8 @@ _arguments -s -S \
'-S+[set the upper limit on size of packets matched]:size (bytes)' \
'(-x)-W+[set the dump format]:packet display format:(normal byline single none)' \
'-c+[force the column width to the specified size]:columns' \
+ '-C[colorize matches in packet contents output]' \
+ '-u[show payload as UTF-8 characters]' \
'-P+[set the non-printable display char to what is specified]:character [.]' \
'-F+[read the bpf filter from the specified file]:file:_files' \
'-N[show sub protocol number]' \
diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm
index a78eb7068..725ed3c39 100644
--- a/Completion/Unix/Command/_nm
+++ b/Completion/Unix/Command/_nm
@@ -69,7 +69,13 @@ if _pick_variant -r variant binutils=GNU elftoolchain=elftoolchain elfutils=elfu
'--special-syms[include special symbols in the output]'
'--synthetic[display synthetic symbols as well]'
"--target=[target object format]:target:(${${(@M)${(f)$(_call_program targets nm --help)}:#*supported targets:*}##*: })"
- '--unicode=[specify how to treat UTF-8 encoded unicode characters]:how_to_treat:(default show invalid hex escape highlight)'
+ '--unicode=[specify how to treat UTF-8 encoded unicode characters]: : _values "treatment [default]"
+ {d,default}"[no special treatment]"
+ {l,locale}"[convert to current locale]"
+ {i,invalid}"[not part of a valid string]"
+ {x,hex}"[<> enclosed hex byte sequences]"
+ {e,escape}"[escape sequences (\\\\uxxxx)]"
+ {h,highlight}"[escape sequences highlighted in red]"' \
'(-W --no-weak)'{-W,--no-weak}'[ignore weak symbols]'
'--with-symbol-versions[display version strings after symbol names]'
'--without-symbol-versions[not display of symbol version information]'
diff --git a/Completion/Unix/Command/_nmap b/Completion/Unix/Command/_nmap
index 2a507baa3..4325a5317 100644
--- a/Completion/Unix/Command/_nmap
+++ b/Completion/Unix/Command/_nmap
@@ -1,63 +1,125 @@
#compdef nmap
-local curcontext="$curcontext" state line suf ret=1
+local curcontext="$curcontext" ign dir ret=1
+local -a state line expl suf
+local -A opt_args
+local -aU scripts categories
-_arguments -C \
+(( $#words == 2 )) || ign='!(- *)'
+_arguments -s -S -C \
+ '!(-6)-4' \
'!-sI:zombie host:_hosts' \
- '!-P'{T,S,U}'+:port list' \
- '*-s-[specify scan type]:scan type:((S\:TCP\ SYN\ scan T\:TCP\ connect\(\)\ scan F\:stealth\ FIN\ scan X\:stealth\ Xmas\ tree\ scan N\:stealth\ null\ scan P\:ping\ scanning U\:UDP\ scan O\:IP\ protocol\ scan I\:idle\ scan A\:ACK\ scan W\:window\ scan R\:RPC\ scan L\:list\ scan V\:version\ detection))' \
- '-b[specify ftp relay host]:ftp relay host:_hosts' \
- '*-P-[specify probe types and options]:probe type/options:->probe-opts' \
- '-A[enable OS detection and version scanning]' \
- '-O[enable remote OS identification]' \
- '-6[enable IPv6 support]' \
- '-I[enable TCP reverse ident scanning]' \
- '-f[use tiny fragmented IP packets]' \
- '*-v[verbose mode]' \
- '-h[show help information]' \
- '*-o-[log results]:log format:->log-forms:log filename:_files' \
- '--resume[resume cancelled scan]:log filename:_files' \
- '--append-output[append results to any log files]' \
+ '!-P'{S,A,U,Y}'+:port list' \
+ '!-PO+:protocol list' \
+ '!(-F -p --exclude-ports)-sn' \
'-iL[read target specifications from file]:file:_files' \
'-iR[scan random hosts]:num hosts' \
- '-p[specify ports to try]:port numbers' \
+ '--exclude[specify hosts/networks to exclude]:host list:_sequence _hosts' \
+ '--excludefile[use exclude list from a file]:file:_files' \
+ '*-s-[specify scan type]:scan type:((S\:TCP\ SYN\ scan T\:TCP\ connect\(\)\ scan F\:stealth\ FIN\ scan X\:stealth\ Xmas\ tree\ scan N\:stealth\ null\ scan P\:ping\ scanning U\:UDP\ scan O\:IP\ protocol\ scan I\:idle\ scan A\:TCP\ ACK\ scan W\:TCP\ window\ scan M\:TCP\ Maimon\ scan R\:RPC\ scan L\:list\ scan Y\:SCTP\ INIT\ scan Z\:SCTP\ COOKIE-ECHO\ scan V\:version\ detection n\:no\ port\ scan C\:equivalent\ to\ --script=default))' \
+ '*-P-[specify probe types and options]:probe type/options:->probe-opts' \
+ '(-R --dns-servers --system-dns)-n[skip reverse DNS to speed things up]' \
+ '(-n)-R[always do reverse DNS on targets]' \
+ '--resolve-all[scan all addresses resolved via DNS]' \
+ '--unique[scan each address only once]' \
+ '(--dns-servers -n)--system-dns[use OS DNS resolver for reverse lookups]' \
+ '(--system-dns -n)--dns-servers[specify custom DNS servers for reverse lookups]:server:_sequence _hosts' \
+ "--disable-arp-ping[don't do ARP or IPv6 ND of locally connected ethernet hosts]" \
+ "--discovery-ignore-rst[don't treat RST replies as proof of a target being up]" \
+ '--traceroute[trace hop path to each host]' \
+ '--scanflags[customize TCP scan flags]:TCP flags:->tcp-flags' \
+ '-b[specify ftp relay host]:ftp relay host:_hosts' \
+ '-p+[specify ports to try]:port numbers' \
+ '--exclude-ports[exclude specified ports]:port numbers' \
'-F[scan only ports listed in services file]' \
- '-D[perform decoy scan]:host list:_sequence -s, _hosts' \
- '-S[specify source address]:address:_hosts' \
+ "-r[don't randomize order in which ports are scanned]" \
+ '--top-ports[scan most common ports]:number of ports' \
+ '--port-ratio[scan ports more common than specified ratio]: :_numbers -l 0.0 -m 1.0 ratio' \
+ "--allports[don't exclude any ports from version detection]" \
+ '(--version-light --version-all)--version-intensity[limit version probes to try]:level:((0\:light 1 2 3 4 5 6 7 8 9\:try\ all))' \
+ '(--version-intensity --version-all)--version-light[alias for --version-intensity 2]' \
+ '(--version-intensity --version-light)--version-all[alias for --version-intensity 9]' \
+ '--version-trace[show packets related to version scanning]' \
+ '-O[enable remote OS identification]' \
+ '--osscan-limit[limit OS detection to promising targets]' \
+ '(--osscan-guess --fuzzy)'{--osscan-guess,--fuzzy}'[guess OS more aggressively]' \
+ '--max-os-tries[set maximum number of OS detection tries against a target]:tries [5]' \
+ '--script=[specify Lua scripts]:script:->scripts' \
+ '--script-args[provide arguments to scripts]:arguments' \
+ '--script-args-file[provide script arguments in a file]:file:_files' \
+ '--script-trace[show all data sent and received]' \
+ '--script-updatedb[update the script database]' \
+ "$ign--script-help=[show help about scripts]:script:->scripts" \
+ --{min,max}-hostgroup'[set parallel scan group size]:size' \
+ --{min,max}-parallelism'[specify number of scans to perform in parallel]:number' \
+ --{min,max}-rtt-timeout'[set time to wait for a probe response]: :_numbers -u seconds time \:s ms m h' \
+ '--initial-rtt-timeout[specify initial probe timeout]: :_numbers -u seconds timeout \:s ms m h' \
+ '--max-retries[cap number of port scan probe retransmissions]:tries' \
+ '--host-timeout[specify maximum time for scanning a single host]: :_numbers -u seconds timeout \:s ms m h' \
+ '--script-timeout[set a ceiling on script execution time]:max time' \
+ '(--scan-delay --max-scan-delay)'--{max-,}'scan-delay[set amount of time between probes to a given host]: :_numbers -u seconds delay \:s ms m h' \
+ '--min-rate[send packets no slower than number per second]:packets' \
+ '--max-rate[send packets no faster than number per second]:packets' \
+ '--defeat-'{rst,icmp}'-ratelimit' \
+ '--nsock-engine:IO multiplexing engine:(iocp epoll kqueue poll select)' \
+ '-T[set a timing template]:timing policy:(paranoid sneaky polite normal aggressive insane)' \
+ '-f[fragment packets]' \
+ '--mtu=[specify MTU, with -f]:mtu' \
+ '-D[perform decoy scan]:host list:_sequence _hosts' \
+ '-S[spoof source address]:address:_hosts' \
'-e[specify interface to use]:network interface:_net_interfaces' \
- '-g[specify source port number]:port number' \
+ '(-g --source-port)'{-g,--source-port=}'[specify source port number]:port number' \
+ '--data=[append a custom payload to sent packets]:payload (hex string)' \
+ '--data-string=[append a custom ASCII string to sent packets]:string' \
'--data-length[add random data to packets]:data length' \
- '(-R)-n[skip reverse DNS to speed things up]' \
- '(-n)-R[always do reverse DNS on targets]' \
- "-r[don't randomize order in which ports are scanned]" \
- '-ttl[specify IPv4 time to live for sent packets]' \
+ '--ip-options=[send packets with specified IP options]:IP options:->ip-options' \
+ '--ttl[specify IPv4 time to live for sent packets]:time-to-live' \
'--randomize-hosts[scan hosts in random order]' \
- '-M[specify maximum number of parallel TCP connects]:maximum TCP connects' \
+ '--spoof-mac=[spoof your MAC address]:MAC address' \
+ '--proxies=[relay connections through HTTP/SOCKS4 proxies]:proxy:_sequence _urls' \
+ '--badsum[send packets with a bogus TCP/UDP/SCTP checksum]' \
+ '--adler32[use deprecated Adler32 instead of CRC32C for SCTP checksums]' \
+ '*-o-[log results]:log format:->log-forms: :{_files || _date_formats}' \
+ '*-v-[increase verbosity]::level' \
+ '*-d-[increase debugging level]::level' \
+ '--reason[show why a port is in a particular state]' \
+ '--stats-every=[print periodic timing stats]: :_numbers -u seconds interval \:s ms m h' \
+ '--open[only show open (or possibly open) ports]' \
'--packet-trace[show all packets sent in tcpdump-like format]' \
- '--version-trace[show packets related to version scanning]' \
- '--datadir[specify directory containing data files]:directory:_directories' \
- '-T[specify timing policy]:timing policy:(Paranoid Sneaky Polite Normal Aggressive Insane)' \
- '--host-timeout[specify maximum time for scanning a single host]:timeout (ms)' \
- '--max-rtt-timeout[maximum time for a probe response]:timeout (ms)' \
- '--min-rtt-timeout[minimum time to wait for a probe response]:time (ms)' \
- '--initial-rtt-timeout[specify initial probe timeout]:timeout (ms)' \
- '--max-parallelism[specify max number of scans to perform in parallel]:number' \
- '--min-parallelism[scan at least specified number of ports in parallel]:number' \
- '--scan-delay[specify minimum amount of time between probes]:delay (ms)' \
- '--interactive[go into interactive mode]' \
+ "$ign--iflist[list interfaces and routes]" \
+ '--append-output[append results to any log files]' \
+ "$ign--resume[resume aborted scan]:log filename:_files" \
+ '--noninteractive[disable runtime interactions via keyboard]' \
+ '(--webxml)--stylesheet[specify XSL stylesheet to transform XML output to HTML]:stylesheet:_urls' \
+ '(--stylesheet)--webxml[load stylesheet from Nmap.Org]' \
+ '--no-stylesheet[omit XSL stylesheet declaration from XML]' \
+ '-6[enable IPv6 scanning]' \
+ '(-O)-A[enable OS detection, version detection, script scanning and traceroute]' \
+ '--datadir=[specify custom Nmap data file location]:directory:_directories' \
+ '--servicedb=[specify custom services file]:services file:_files' \
+ '--versiondb=[specify custom service probes file]:service probes file:_files' \
+ '(--send-ip)--send-eth[send using raw ethernet frames]' \
+ '(--send-eth)--send-ip[send using raw IP packets]' \
+ '(--unprivileged)--privileged[assume user is fully privileged]' \
+ '(--privileged)--unprivileged[assume user lacks raw socket privileges]' \
+ '!--release-memory' \
+ "$ign"{-V,--version}'[print version number]' \
+ "$ign"{-h,--help}'[print help summary]' \
'*:host:_hosts' && ret=0
case $state in
probe-opts)
- _values -S '' 'probe type/option' \
- "0[don't try to ping hosts before scanning]" \
- 'T[use TCP "ping"]' \
- 'S[use SYN packets instead of ACK]' \
- 'U[send UDP probes]' \
- 'E[use a true ping]' \
- 'P[use an ICMP timestamp request]' \
- 'M[use a netmask request]' \
- 'B[use ACK and ICMP echo in parallel]' && ret=0
+ _values -S '' 'discovery probe type [R]' \
+ 'n[skip host discovery]' \
+ 'A[use TCP with ACK flag]' \
+ 'S[use TCP with SYN flag]' \
+ 'U[use UDP discovery probe]' \
+ 'Y[use SCTP discovery probe]' \
+ 'E[use ICMP echo request ]' \
+ 'P[use ICMP timestamp request]' \
+ 'M[use ICMP netmask request]' \
+ 'O[IP protocol ping]' \
+ 'R[use ARP]' && ret=0
;;
log-forms)
_values 'log format' \
@@ -65,13 +127,50 @@ case $state in
'X[XML]' \
'G[grepable]' \
'A[all]' \
- 'S[S|<ipT kiDdI3]' && ret=0
+ 'S[S|<rIpt kIddi3]' && ret=0
;;
- host-list)
- suf=()
- compset -P '*,'
+ tcp-flags)
+ compset -P '(URG|ACK|PSH|RST|SYN|FIN)#'
+ _wanted tcp-flags expl 'TCP flag' compadd -S '' \
+ URG ACK PSH RST SYN FIN && ret=0
+ ;;
+ ip-options)
+ _values -S ' ' "IP option" \
+ 'R[record route (9 slots available)]' \
+ 'T[record internet timestamps (9 slots)]' \
+ 'U[record timestamps and ip addresses (4 slots)]' \
+ 'L[loose source routing (8 slots)]:hop ip' \
+ 'S[strict source routing (8 slots)]:hop ip' && ret=0
+ ;;
+ scripts)
+ compset -P '*,(|+)'
compset -S ',*' || suf=(-qS ,)
- _hosts "$suf[@]" && ret=0
+
+ if [[ $PREFIX$SUFFIX = */* ]]; then
+ _files -g "*.nse(-.)"
+ return
+ fi
+
+ categories=( all )
+ for dir in \
+ ${opt_args[--datadir]:+${~opt_args[--datadir]}/scripts(/N)} \
+ $NMAPDIR/scripts(/N) \
+ ${${commands[$words[1]]:-$words[1]}:P:h:h}/share/nmap/scripts(/N) \
+ ~/.nmap/scripts(/N) \
+ ../share/nmap/scripts(/N) \
+ $NMAPDATADIR/scripts(/N) \
+ .
+ do
+ if [[ -r $dir/script.db ]]; then
+ scripts+=( ${${${(SM)${(f)"$(<$dir/script.db)"}#filename = \"[^.]##.}%.}#*\"} )
+ categories+=( ${${(s.,.)${(SM)${(f)"$(<$dir/script.db)"}##categories = [^\}]#}#*\{}//[ \"]/} )
+ else
+ scripts+=( $dir/*.nse(N:t:r) )
+ fi
+ done
+ _alternative \
+ 'categories:category:compadd $suf -a categories' \
+ 'scripts:script:compadd -M "r:|-=* r:|=*" $suf -a scripts' && ret=0
;;
esac
diff --git a/Completion/Unix/Command/_numfmt b/Completion/Unix/Command/_numfmt
index 999c412a1..dd8f6182f 100644
--- a/Completion/Unix/Command/_numfmt
+++ b/Completion/Unix/Command/_numfmt
@@ -15,6 +15,7 @@ _arguments -S \
'(H)--padding=[pad the output to specified width]:width; positive - right-align; negative - left-align' \
'(H)--round=[use specified method for rounding when scaling]:method [from-zero]:(up down from-zero towards-zero nearest)' \
'(H)--suffix=[add suffix to output numbers and accept optional suffix in input numbers]:suffix' \
+ '(H)--unit-separator=[insert separator between number and unit on output]:separator' \
"(H)--to=[auto-scale output numbers to specified unit]:unit:$units" \
'(H)--to-unit=[specify output unit size]:unit size [1]' \
'(H -z --zero-terminated -d --delimiter)'{-z,--zero-terminated}'[line delimiter is NUL, not newline]' \
diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump
index 71a615c97..0a8820327 100644
--- a/Completion/Unix/Command/_objdump
+++ b/Completion/Unix/Command/_objdump
@@ -67,8 +67,13 @@ case $variant in
'!(--no-recurse-limit)--recurse-limit'
'--no-recurse-limit[disable demangling recursion limit]'
'(-w --wide)'{-w,--wide}'[format output for more than 80 columns]'
- '-U+[specify how to display unicode characters]:method:(d l e x h i)'
- '--unicode=[specify how to display unicode characters]:method:(default locale escape hex highlight invalid)'
+ '(-U --unicode)'{-U+,--unicode=}'[specify how to treat UTF-8 encoded unicode characters]: : _values "treatment [default]"
+ {d,default}"[no special treatment]"
+ {l,locale}"[convert to current locale]"
+ {i,invalid}"[not part of a valid string]"
+ {x,hex}"[<> enclosed hex byte sequences]"
+ {e,escape}"[escape sequences (\\\\uxxxx)]"
+ {h,highlight}"[escape sequences highlighted in red]"' \
'(-z --disassemble-zeroes)'{-z,--disassemble-zeroes}"[don't skip blocks of zeroes when disassembling]"
'--start-address=[only process data whose address is >= ADDR]:address'
diff --git a/Completion/Unix/Command/_opustools b/Completion/Unix/Command/_opustools
index 1fd97798a..c860a170f 100644
--- a/Completion/Unix/Command/_opustools
+++ b/Completion/Unix/Command/_opustools
@@ -14,7 +14,7 @@ case $service in
'--cvbr[use constrained variable bitrate encoding]' \
'--downmix-mono[downmix to mono]' \
'--downmix-stereo[downmix to stereo (if >2 channels)]' \
- '--expect-loss[set expected packet loss]:expected packet loss (%%) (0-100) [0]' \
+ '--expect-loss[set expected packet loss]:expected packet loss (%) (0-100) [0]' \
'--framesize[set maximum frame size]:maximum frame size (milliseconds) [20]:(2.5 5 10 20 40 60)' \
'--hard-cbr[use hard constant bitrate encoding]' \
'--max-delay[set maximum container delay]:maximum container delay (milliseconds) (0-1000) [1000]' \
@@ -57,7 +57,7 @@ case $service in
'--no-dither[do not dither 16-bit output]' \
'--float[output 32-bit floating-point samples]' \
'--force-wav[force RIFF wav header on output]' \
- '--packet-loss[simulate random packet loss]:packet loss probability (%%) (0-100)' \
+ '--packet-loss[simulate random packet loss]:packet loss probability (%) (0-100)' \
'--save-range[save check values for every frame to a file]:output for check values:_files'
;;
opusinfo)
diff --git a/Completion/Unix/Command/_pandoc b/Completion/Unix/Command/_pandoc
index 797e73eaa..0bf017882 100644
--- a/Completion/Unix/Command/_pandoc
+++ b/Completion/Unix/Command/_pandoc
@@ -9,10 +9,10 @@ _pandoc_format() {
local format=${PREFIX%%(+|-)*}
if compset -P '*(+|-)'; then
local pm=${IPREFIX[-1]} # '+' or '-'
- local -a extensions=(${${$(pandoc --list-extensions=$format):#$pm*}#(+|-)})
+ local -a extensions=( ${${$(_call_program extensions pandoc --list-extensions=$format):#$pm*}#(+|-)} )
_wanted extensions expl 'extension' compadd -S '+' -r '-+ ' -a extensions
else
- local -a formats=( $(pandoc --list-$inout[2]-formats) )
+ local -a formats=( $(_call_program formats pandoc --list-$inout[2]-formats) )
_wanted formats expl 'format' compadd -S '+' -r '-+ ' -a formats
fi
}
@@ -22,15 +22,19 @@ _pandoc_format() {
_pandoc_all_formats(){
local -a expl
local -aU formats
- formats=( $(pandoc --list-input-formats) $(pandoc --list-output-formats) )
- _wanted formats expl 'format' compadd -a formats
+ formats=(
+ $(_call_program input-formats pandoc --list-input-formats)
+ $(_call_program output-formats pandoc --list-output-formats)
+ )
+ _description formats expl 'format'
+ compadd "$expl[@]" "$@" -a formats
}
# pdf engine choice
(( $+functions[_pandoc_pdf_engine] )) ||
_pandoc_pdf_engine(){
_alternative \
- 'engines:engine:(pdflatex lualatex xelatex latexmk tectonic wkhtmltopdf weasyprint prince context pdfroff)' \
+ 'engines:engine:(pdflatex lualatex xelatex latexmk tectonic wkhtmltopdf weasyprint pagedjs-cli prince context groff pdfroff typst)' \
'engine-executables:engine executable:_files -g "*(#q*)"'
}
@@ -43,7 +47,7 @@ _pandoc_pdf_engine_opts(){
_tex
;;
*)
- _message "Options for ${pdf_engine}"
+ _message "option for ${pdf_engine}"
;;
esac
}
@@ -79,7 +83,7 @@ _pandoc_template(){
(( $+functions[_pandoc_highlight_style] )) ||
_pandoc_highlight_style(){
_alternative \
- 'styles:style:( $(pandoc --list-highlight-styles) )' \
+ 'styles:style:( $(_call_program styles pandoc --list-highlight-styles) )' \
'style-files:style file:_files -g "*.theme(-.)"'
}
@@ -195,7 +199,8 @@ _arguments -s \
'--abbreviations=[specify a custom abbreviations file]:file:_files ' \
{-s,--standalone}'[produce output with an appropriate header and footer]' \
'--template=[use specified file as a custom template for the generated document. Implies --standalone]: :_pandoc_template' \
- {\*-V+,\*--variable=}'[set the variable KEY to the value VALUE]:key\:value: ' \
+ {\*-V+,\*--variable=}'[set a template variable]:key\:value' \
+ \*--variable-json='[set a template variable to the value specified by a JSON string]:key\:json' \
'(- :)'{-D+,--print-default-template=}'[print the system default template for an output]:format:( $(pandoc --list-output-formats) )' \
'(- :)--print-default-data-file=[print a system default data file]:file: ' \
'--eol=[manually specify line endings (crlf|lf|native)]: :_pandoc_eol' \
@@ -209,6 +214,7 @@ _arguments -s \
'--highlight-style=[specify coloring style to be used in highlighted source code]: :_pandoc_highlight_style' \
'(- :)--print-highlight-style=[prints a JSON version of a highlighting style]: :_pandoc_highlight_style' \
'--syntax-definition=[load a KDE XML syntax definition file]:file:_files -g "*.xml(-.)"' \
+ '--syntax-highlighting=[specify method to use for syntax highlighting]:method' \
\*{-H+,--include-in-header=}'[include contents of file, verbatim, at the end of the header, implies --standalone]:file:_files' \
\*{-B+,--include-before-body=}'[include contents of file, verbatim, at the beginning of the document body, implies --standalone]:file:_files' \
\*{-A+,--include-end-body=}'[include contents of file, verbatim, at the end of the document body, implies --standalone]:file:_files' \
@@ -217,6 +223,7 @@ _arguments -s \
'--no-check-certificate[disable the certificate verification]' \
'--self-contained[produce a standalone HTML file with no external dependencies, using data: URIs to incorporate the contents of linked scripts, stylesheets, images, and videos. Implies --standalone]' \
'--embed-resources=-[produce a standalone HTML document with no external dependencies]::enable:(true false)' \
+ '--link-images=-[include links to images instead of embedding the images in ODT]::enable:(true false)' \
'--html-q-tags[use <q> tags for quotes in HTML]' \
'--ascii[use only ASCII characters in output, supported only for HTML and DocBook output]' \
'--reference-links[use reference-style links, rather than inline links]' \
@@ -224,7 +231,9 @@ _arguments -s \
'--markdown-headings[specify style for level1 and 2 headings in markdown output]:style [atx]:(setext atx)' \
'--list-tables=-[render tables as list tables in RST output]::enable(true false)' \
'--top-level-division=[treat top-level headers as given division type in LaTeX, ConTeXt, DocBook and TEI output]:top level division:(default section chapter part)' \
- {-N,--number-sections}'[number section headings in LaTeX, ConTeXt, HTML, or EPUB output]' \
+ '(--lof --list-of-figures)'{--lof=-,--list-of-figures=-}'[include an automatically generated list of figures]::enable:(true false)' \
+ '(--lot --list-of-tables)'{--lot=-,--list-of-tables=-}'[include an automatically generated list of tables]::enable:(true false)' \
+ '(-N --number-sections)'{-N-,--number-sections=-}'[number section headings in LaTeX, ConTeXt, HTML, or EPUB output]::enable:(true false)' \
'--number-offset=[specify offset for section headings in HTML output (ignored in other output formats)]:number[number,...] [0]' \
'--listings[use the listings package for LaTeX code blocks]' \
{-i,--incremental}'[make list items in slide shows display incrementally (one by one)]' \
diff --git a/Completion/Unix/Command/_patchutils b/Completion/Unix/Command/_patchutils
index a5f6441b1..83bf1d67f 100644
--- a/Completion/Unix/Command/_patchutils
+++ b/Completion/Unix/Command/_patchutils
@@ -13,6 +13,9 @@ case $service in
'(-z --decompress)'{-z,--decompress}'[decompress .gz and .bz2 files]'
)
;|
+ (combine|inter|filter|flip)diff)
+ args+=( '--in-place[write output to original input files]' )
+ ;|
interdiff|combinediff|flipdiff)
args+=(
'(-q --quiet)'{-q,--quiet}'[quieter output]'
@@ -22,6 +25,7 @@ case $service in
'(-B --ignore-blank-lines)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]'
'(-i --ignore-case)'{-i,--ignore-case}'[ignore case differences]'
'(-b --ignore-space-change)'{-b,--ignore-space-change}'[ignore changes in the amount of whitespace]'
+ '--color=-[colorize the output]::when [auto]:(never always auto)'
'!(--in-place)--interpolate' '!-h'
'!(--no-revert-omitted --in-place)--combinediff'
'!(--no-revert-omitted)--flip'
@@ -33,7 +37,6 @@ case $service in
"--no-revert-omitted[don't revert files changed in only the first patch]"
)
;;
- flipdiff) args+=( '--in-place[write output to original input files]' ) ;;
filterdiff|grepdiff|lsdiff)
args+=(
'(-i --include)'{-i,--include}'[include only files matching pattern]:pattern:_files'
@@ -42,6 +45,8 @@ case $service in
'--lines=[only list hunks containing lines within specified range]:range'
'(-F --files)'{-F+,--files=}'[only list files within specified range]:range'
'--strip=[remove specified number of pathname components before displaying]:components'
+ '--git-prefixes=[specify handling of a/ and b/ prefixes in git diffs]:handling:(strip keep)'
+ '--git-extended-diffs=[process git diffs without hunks]:action [include]:(exclude include)'
'--addprefix=[insert specified path prefix before displaying path names]:prefix:_directories'
'*:diff file:_files'
)
@@ -68,7 +73,7 @@ case $service in
'--format=[use specified output format]:format:(unified context)'
'--addnewprefix=[insert specified path prefix before new file path names]:prefix:_directories'
'--addoldprefix=[insert specified path prefix before original file path names]:prefix:_directories'
- '--as-numbered-lines=[display lines of selected hunks]:line numbers:(before after)'
+ '--as-numbered-lines=[display lines of selected hunks]:line numbers:(before after original-before original-after)'
"--remove-timestamps[don't include timestamps in output]"
)
;|
@@ -103,5 +108,6 @@ case $service in
;;
esac
+
_arguments -s $args
diff --git a/Completion/Unix/Command/_perl b/Completion/Unix/Command/_perl
index 1631560ce..ad0c7c553 100644
--- a/Completion/Unix/Command/_perl
+++ b/Completion/Unix/Command/_perl
@@ -7,7 +7,7 @@ _perl () {
'-0-[input record separator ($/)]:: :_perl_input_seps' \
'-a[autosplit mode with -n or -p (splits $_ into @F)]' \
'-C-[control some unicode features]: :_perl_unicode_flags' \
- "-c[check syntax only (runs BEGIN and END blocks)]" \
+ "-c[check syntax only]" \
'( -dt -d: -dt:)-d[run scripts under debugger]' \
'(-d -d: -dt:)-dt[run scripts under debugger (debugged code uses threads)]' \
'(-d -dt -dt:)-d\:-[run under control of a debugging/tracing module]:debugging/tracing module:_perl_modules --strip-prefix --perl-hierarchy=Devel' \
diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep
index b7009eafb..b3ef86223 100644
--- a/Completion/Unix/Command/_pgrep
+++ b/Completion/Unix/Command/_pgrep
@@ -1,8 +1,7 @@
-#compdef pgrep pkill
+#compdef pgrep pkill pidwait
# Notes:
-# - We assume that Linux systems use procps-ng - specifically, procps-ng >=3.3.4
-# (which changed the behaviour of -f and added -a)
+# - We assume that Linux systems use procps-ng
# - We don't really need to keep pgopts and pkopts separate, but it seems like
# it should make things a bit easier to follow
@@ -17,13 +16,13 @@ typeset -a arguments sig_arguments aopts
arguments=(
'-a[include process ancestors in match list]'
'-c+[match only on specified login class]:login class:_login_classes'
- '(-F --pidfile)'{-F+,--pidfile=}'[match only processes in specified PID file]:PID file:_files'
+ '(-F --pidfile -p --pid)'{-F+,--pidfile=}'[match only processes in specified PID file]:PID file:_files'
'(-f --full)'{-f,--full}'[match against full command line]'
'(-G --group)'{-G+,--group=}'[match only on specified real group IDs]: :_sequence _groups'
'(-g --pgroup)'{-g+,--pgroup=}'[match only on specified process group IDs]: :->pgid'
'(: * -)'{-h,--help}'[display help information]'
'-I[request confirmation before signalling each process]'
- '-i[ignore case distinctions]'
+ '(-i --ignore-case)'{-i,--ignore-case}'[ignore case distinctions]'
'-j+[match only on specified jail IDs]:jail:_sequence _jails -0 -o jid'
'(-L --logpidfile)'{-L,--logpidfile}'[fail if PID file not locked (with -F)]'
'(-N)-M+[extract name list from specified core]:core file:_files'
@@ -67,15 +66,25 @@ arguments=(
case $OSTYPE in
linux*)
# Note: We deliberately exclude -v but not --inverse from pkill
- pgopts=AacdFfGghLlnoOPrstUuVvwx-
- pkopts=AceFfGgHhLnoOPstUuVx-
+ pgopts=AacdFfGghLlnopOPQrstUuVvwx-
+ pkopts=AceFfGgHhLmnoOPstUuVx-
+ pwopts=AceFfGghiLnOoPpQrstUuVx-
arguments=(
${arguments:#((#s)|*\))(\*|)-[acl]*}
'(-c --count)'{-c,--count}'[display count of matching processes]'
+ '(-p --pid -F --pidfile)'{-p+,--pid=}'[match process PIDs]: :_sequence _pids'
+ '(-Q --shell-quote)'{-Q,--shell-quote}'[output the command line in shell-quoted form]'
+ )
+ [[ $service == pkill ]] && arguments+=(
+ '(-m --mrelease)'{-m,--mrelease}'[release process memory immediately after kill]'
)
[[ $service == pgrep ]] && arguments+=(
'(-a -l --list-full --list-name)'{-a,--list-full}'[display full command line]'
'(-a -l --list-full --list-name)'{-l,--list-name}'[display process name]'
+ '--quiet[suppress all normal output]'
+ )
+ [[ $service == pidwait ]] && arguments+=(
+ '(-e --echo)'{-e,--echo}'[display PIDs before waiting]'
)
;;
dragonfly*|freebsd*)
@@ -110,7 +119,9 @@ case $OSTYPE in
;;
esac
-if [[ $service == pgrep ]]; then
+if [[ $service == pidwait ]]; then
+ arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pwopts]*} )
+elif [[ $service == pgrep ]]; then
arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pgopts]*} )
else
arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pkopts]*} )
@@ -140,7 +151,7 @@ fi
arguments+=( $sig_arguments + o '*: :->pname' )
-[[ $OSTYPE == linux* ]] || aopts+=( -A '*-' )
+[[ $OSTYPE == linux* ]] || aopts+=( -A '-?*' )
_arguments -C -s -S $aopts : $arguments && ret=0
# complete comma-separated list of various IDs
diff --git a/Completion/Unix/Command/_php b/Completion/Unix/Command/_php
index 9a8f519b1..3ed3e2705 100644
--- a/Completion/Unix/Command/_php
+++ b/Completion/Unix/Command/_php
@@ -155,7 +155,7 @@ _php() {
if compset -P 1 '*='; then
_default && ret=0
else
- compset -S '=*' || suf=( -qS '=' )
+ compset -S '=*' || suf=( -r= -S= )
_wanted directives expl 'INI directive' \
compadd "$suf[@]" -a directives && ret=0
fi
diff --git a/Completion/Unix/Command/_pip b/Completion/Unix/Command/_pip
index bafc7f9e9..370012d56 100644
--- a/Completion/Unix/Command/_pip
+++ b/Completion/Unix/Command/_pip
@@ -85,7 +85,6 @@ case $state in
'--src=[check out --editable packages into given directory]: :_directories'
'--ignore-requires-python[ignore the Requires-Python information]'
"--no-deps[don't install package dependencies]"
- '(-b --build)'{-https://cloud.kiddleb+,--build=}'[specify directory to unpack packages into]: :_directories'
'--global-option=[extra global options to be supplied to the setup.py call before the install command]:options'
"--no-clean[don't clean up build directories]"
'--require-hashes[require a hash to check each requirement against]'
diff --git a/Completion/Unix/Command/_pmap b/Completion/Unix/Command/_pmap
index 5fd92ab9e..2226d3329 100644
--- a/Completion/Unix/Command/_pmap
+++ b/Completion/Unix/Command/_pmap
@@ -1,11 +1,11 @@
#compdef pmap
if _pick_variant procps=procps-ng unix -V 2>/dev/null; then
- # based on procps-ng-3.3.15
_arguments -s \
'(exit -A --range)'{-A+,--range}'[limit results to the specified address range]:low,high: ' \
'(exit -q --quiet)'{-q,--quiet}'[do not display some header or footer lines]' \
'(exit -p --show-path)'{-p,--show-path}'[show full path to files in the mapping column]' \
+ '(exit -k --use-kernel-name)'{-k,--use-kernel-name}'[use names provided by kernel]' \
'(exit)*: :_pids' \
+ '(format)' \
'(exit)'{-d,--device}'[show the device format]' \
diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix
index 006c950e3..8c172b424 100644
--- a/Completion/Unix/Command/_postfix
+++ b/Completion/Unix/Command/_postfix
@@ -67,7 +67,7 @@ case $service in
'-d[delete]:queue id:_postfix_queue_id' \
'-h[hold]:queue id:_postfix_queue_id' \
'-H[release]:queue id:_postfix_queue_id' \
- '*-r[requeue]:queue id, or "ALL":_postfix_queue_id' \
+ '*-r[requeue]:queue id:_phony ALL _postfix_queue_id' \
'1:queue:(hold incoming active deferred)'
;;
(postqueue)
diff --git a/Completion/Unix/Command/_postgresql b/Completion/Unix/Command/_postgresql
index 595eb1cb4..aff245578 100644
--- a/Completion/Unix/Command/_postgresql
+++ b/Completion/Unix/Command/_postgresql
@@ -200,7 +200,7 @@ __pgsql_cfg_params_values() {
_message -e values 'PostgreSQL run-time configuration-parameter value'
else
compset -S '=*'
- __pgsql_cfg_params "$@" -qS=
+ __pgsql_cfg_params "$@" -r= -S=
fi
}
@@ -332,7 +332,7 @@ __pgsql_cfg_variables_values() {
_message -e values 'PostgreSQL special-variable value'
else
compset -S '=*'
- __pgsql_variables "$@" -qS=
+ __pgsql_variables "$@" -r= -S=
fi
}
diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps
index 7d83f90ea..7e3db03a7 100644
--- a/Completion/Unix/Command/_ps
+++ b/Completion/Unix/Command/_ps
@@ -36,12 +36,8 @@ args=(
'*-U+[select processes by real user]:user:_sequence -s , _users'
'-o+[specify output format]:property:_sequence -s , _ps_props -'
- '-c[show scheduler properties]'
'-f[full listing]'
- '-j[show session ID and process group ID]'
'-l[long listing]'
- '-L[show information about each light weight process]'
- '-y[show RSS in place of ADDR (used with -l)]'
)
bsd=(
@@ -51,15 +47,10 @@ bsd=(
'x[include processes with no controlling terminal]'
'(j l s u X)v[output in virtual memory format]'
'*w[wide output]'
- 'L[display all format specifiers]'
- 'S[include child process data with the parent]'
- 'T[select processes attached to current terminal]'
)
bsdarg=(
'*p[select processes by ID]'
'*t[select processes by attached terminal]'
- 'O[specify additional output fields]'
- 'o[specify output format]'
)
case $OSTYPE in
@@ -76,11 +67,30 @@ case $OSTYPE in
'-Z[show zone with which process is associated]'
)
;;
- linux-gnu|dragonfly*|freebsd*|netbsd*|openbsd*)
+ ^aix*)
+ args+=(
+ '-L[show information about each light weight process]'
+ '-c[show scheduler properties]'
+ '-j[show session ID and process group ID]'
+ '-y[show RSS in place of ADDR (used with -l)]'
+ )
+ bsd+=(
+ 'L[display all format specifiers]'
+ 'S[include child process data with the parent]'
+ 'T[select processes attached to current terminal]'
+ )
+ bsdarg+=(
+ 'O[specify additional output fields]'
+ 'o[specify output format]'
+ )
+ ;|
+ linux-gnu|aix*|dragonfly*|freebsd*|netbsd*|openbsd*)
bsd+=(
'e[show environment after command]'
'(j l s v X)u[output in resource usage format]'
)
+ ;|
+ linux-gnu|dragonfly*|freebsd*|netbsd*|openbsd*)
bsdarg+=(
'N[set namelist file for WCHAN display]'
'*U[select processes by effective user]'
@@ -89,10 +99,14 @@ case $OSTYPE in
linux-gnu|dragonfly*|freebsd*|openbsd*)
bsd+=( 'H[show threads as if they were processes]' )
;|
+ aix*|darwin*|dragonfly*|freebsd*|netbsd*|openbsd*)
+ bsd+=(
+ 'c[show just executable name for command]'
+ )
+ ;|
darwin*|dragonfly*|freebsd*|netbsd*|openbsd*)
bsd+=(
'A[select every process]'
- 'c[show just executable name for command]'
'h[repeat header lines, one per page of output]'
'(r)m[sort by memory usage]'
'(m)r[sort by CPU usage]'
@@ -110,9 +124,6 @@ case $OSTYPE in
darwin*|freebsd*)
bsd+=( 'X[skip processes with no controlling terminal]' )
;|
- freebsd*|dragonfly*)
- bsd+=( 'f[show command and environment for swapped out processes]' )
- ;|
netbsd*|openbsd*)
bsdarg+=( 'W[extract swap information from specified file]' )
;|
@@ -121,6 +132,26 @@ case $OSTYPE in
'd[show process hierarchy]'
)
;|
+ aix*)
+ args+=(
+ '-M[list 64 bit processes]'
+ "-N[don't gather thread statistics]"
+ '-L+[show process descendants]:pid list:_sequence _pids'
+ '-T+[show process tree rooted at given pid]:pid:_pids'
+ '-P[display project info]'
+ "-X[don't truncate user and group names]"
+ '-Z[display page size settings]'
+ '-k[list kernel processes]'
+ '-c+[filter by workload management class]:class list'
+ '-m[list kernel threads]'
+ )
+ bsd+=(
+ 'g[display all processes]'
+ 'n[numerical output]'
+ 's[display kernel stack size of each process]'
+ "X[don't truncate user and group names]"
+ )
+ ;|
darwin*)
bsd+=(
'd[select all processes except session leaders]'
@@ -143,13 +174,19 @@ case $OSTYPE in
fi
;;
dragonfly*)
- bsd+=( 'R[subsort by parent/child chain]' )
+ bsd+=(
+ 'R[subsort by parent/child chain]'
+ 'f[show command and environment for swapped out processes]'
+ )
;;
freebsd*)
bsd+=(
- '*J[select processes by jail ID]'
'Z[show mac label]'
)
+ bsdarg+=(
+ 'D[expand list of selected processes based on process tree]'
+ '*J[select processes by jail ID]'
+ )
;;
netbsd*) bsd+=( '(j l u v)s[output in thread format]' ) ;;
openbsd*)
@@ -169,6 +206,7 @@ case $OSTYPE in
'-M[show security data]'
'(--forest -H)'{--forest,-H}'[show process hierarchy]'
'-P[add psr column]'
+ '--delimiter=[specify column delimiter]:string'
'--headers[repeat header lines, one per page of output]'
'(--cols --columns --width)'{--cols,--columns,--width}'[set screen width]:width'
'(--lines --rows)'{--lines,--rows}'[set screen height]'
@@ -205,8 +243,9 @@ case $OSTYPE in
;;
esac
-if (( CURRENT > 1 )) && [[ $OSTYPE != (solaris*|linux-gnu) ||
- ( $OSTYPE = linux-gnu && $words[CURRENT-1] != -* ) ]]; then
+if (( CURRENT > 1 )) && [[ $OSTYPE != (aix*|solaris*|linux-gnu) ||
+ ( $OSTYPE = (aix*|linux-gnu) && $words[CURRENT-1] != -* ) ]]
+then
case $words[CURRENT-1] in
*k)
local sopt
@@ -215,6 +254,7 @@ if (( CURRENT > 1 )) && [[ $OSTYPE != (solaris*|linux-gnu) ||
_sequence -s , _ps_props $sopt - && return ;;
*g) [[ $OSTYPE = darwin* ]] && _wanted -C option-g-1 processes \
expl 'process ID' _sequence -s , _pids && return ;;
+ *D) _wanted directions expl direction compadd up down both && return ;;
*G) _sequence -s , _groups && return ;;
*J) _sequence _jails -0 && return ;;
*[MNW]) _files && return ;;
diff --git a/Completion/Unix/Command/_pump b/Completion/Unix/Command/_pump
deleted file mode 100644
index 08ec026ed..000000000
--- a/Completion/Unix/Command/_pump
+++ /dev/null
@@ -1,24 +0,0 @@
-#compdef pump
-
-_arguments \
- '(-c --config-file=)'{-c,--config-file=}'[specify configuration file to use]:configuration file:_files' \
- '(-h --hostname=)'{-h,--hostname=}'[specify hostname to request]:hostname:_hosts' \
- '(-i --interface=)'{-i,--interface=}'[specify interface to configure]:interface:_net_interfaces' \
- '(-k --kill)'{-k,--kill}'[kill daemon (and disable all interfaces)]' \
- '(-l --lease=)'{-l,--lease=}'[specify lease time to request]:time (hours)' \
- '(-L --leasesecs=)'{-L,--leasesecs=}'[specify seconds to request for]:time (seconds)]' \
- '(-r --release)'{-r,--release}'[release interface]:interface:_net_interfaces' \
- '(-R --renew)'{-R,--renew}'[force immediate lease renewal]:interface:_net_interfaces' \
- '(-v --verbose)'{-v,--verbose}'[log verbose debug info]' \
- '(-s --status)'{-s,--status}'[display interface status]:interface:_net_interfaces' \
- '(-d --no-dns)'{-d,--no-dns}"[don't update resolv.conf]" \
- '(- *)'{-?,--help}'[display help information]' \
- "--no-gateway[don't set a gateway for this interface]" \
- "--no-setup[don't set up anything]" \
- "--no-resolvconf[don't set up resolvconf]" \
- '--no-bootp[ignore non-DHCP BOOTP responses]' \
- '--lookup-hostname[force lookup of hostname]' \
- '--script=[specify script to use]:script:_files' \
- "--win-client-ident[set the client identifier to match window's]" \
- '--usage[display brief usage message]' \
- ':interface:_net_interfaces'
diff --git a/Completion/Unix/Command/_pv b/Completion/Unix/Command/_pv
index 0e1f148d5..4bec330a6 100644
--- a/Completion/Unix/Command/_pv
+++ b/Completion/Unix/Command/_pv
@@ -17,7 +17,6 @@ _arguments -s -S $args \
'(-I --fineta -F --format)'{-I,--fineta}'[show absolute estimated time of arrival]' \
'(-r --rate -F --format)'{-r,--rate}'[show data transfer rate counter]' \
'(-a --average-rate -F --format)'{-a,--average-rate}'[show data transfer average rate counter]' \
- '(-m --average-rate-window)'{-m+,--average-rate-window=}'[compute average rate over period]:duration (seconds) [30]' \
'(-b --bytes -8 --bits -F --format)'{-b,--bytes}'[show number of bytes transferred]' \
'(-8 --bits -b --bytes -F --format)'{-8,--bits}'[show number of bits transferred]' \
'(-k --si)'{-k,--si}'[treat suffixes as multiples of 1000 rather than 1024]' \
@@ -33,10 +32,11 @@ _arguments -s -S $args \
'(-l --line-mode -R --remote)'{-l,--line-mode}'[count lines instead of bytes]' \
'(-0 --null -l --line-mode)'{-0,--null}'[lines are null-terminated]' \
'(-i --interval)'{-i+,--interval=}'[update every after specified interval]:interval (seconds) [1]' \
- '(-m --average-rate-window)'{-m,--average-rate-window}'[compute average rate over past period]:period (seconds) [30]' \
+ '(-m --average-rate-window)'{-m,--average-rate-window}'[compute average rate over period]:period (seconds) [30]' \
'(-w --width)'{-w+,--width}'[assume terminal is specified characters wide]:width' \
'(-H --height)'{-H+,--height=}'[assume terminal is specified rows high]:height' \
'(-N --name)'{-N+,--name=}'[prefix visual information with given name]:name' \
+ '(-u --bar-style)'{-u+,--bar-style=}'[set default bar style]:name [plain]:(plain block granular shaded)' \
'(-x --extra-display)'{-x+,--extra-display=}'[also send progress to destination]:destination:_sequence - compadd windowtitle processtitle' \
'(-v --stats)'{-v,--stats}'[output transfer statistics at the end]' \
'(-f --force -R --remote)'{-f,--force}'[output even if standard error is not a terminal]' \
@@ -70,6 +70,8 @@ case $state in
'a:average data transfer rate'
'b:bytes transferred so far'
'T:percentage of transfer buffer in use'
+ 'A:last written'
+ 'L:previous line'
'N:name prefix'
'%:literal %'
)
diff --git a/Completion/Unix/Command/_rar b/Completion/Unix/Command/_rar
index d1d381974..27120dfa5 100644
--- a/Completion/Unix/Command/_rar
+++ b/Completion/Unix/Command/_rar
@@ -15,17 +15,19 @@ common=(
'-dh[open shared files]'
'-ep[exclude paths from name]'
'-f[freshen files]'
- '-idn[hide archived names]'
- '-idp[disable percentage display]'
+ '-id-[disable messages]: : _values -s "" message
+ "c[copyright]" "d[done]" "n[archived names]" "p[percentage indicator]" "q[quiet]"' \
'-ierr[send all messages to stderr]'
'-inul[disable all messages]'
'-kb[keep broken extracted files]'
'-o\+[overwrite existing files]'
'-o\-[do not overwrite existing files]'
+ '-ol-[save symbolic links as the link instead of the file]:: :((a\:absolute s\:skip))' \
'-ow[save or restore file owner and group]'
'-p+:password'
'-p\-[do not query password]'
'-r[recurse subdirectories]'
+ '-si-[read data from standard input]::name'
'-ta+[process files modified after a date]:date (YYYYMMDDHHMMSS)'
'-tb+[process files modified before a date]:date (YYYYMMDDHHMMSS)'
'-tn+[process files newer than a specified time]:time'
@@ -56,9 +58,8 @@ case $service in
else
_arguments -S \
'-ep3[expand paths to full including the drive letter]' \
- '-idc[disable ___ display]' \
- '-idd[disable ___ display]' \
- '-idq[disable ___ display]' \
+ '-mes[skip encrypted files]' \
+ '-op-[set output path for extracted files]:path:_directories' \
'-n+:file to include:_files' \
'-n@+:file of files to include:_files' \
"$common[@]" \
@@ -106,6 +107,7 @@ case $service in
'-en[do not put end of archive block]' \
'-ep1[exclude base directory from names]' \
'-ep2[expand paths to full]' \
+ '-ep4-[exclude path prefix from names]:prefix' \
'-hp[encrypt both file data and headers]' \
'-ilog[log errors to file (registered versions only)]' \
'-isnd[enable sound]' \
@@ -113,7 +115,6 @@ case $service in
'-m+[set compression level]:compression level:(( 0\:store 1\:fastest 2\:fast 3\:normal 4\:good 5\:maximal ))' \
'-md+[dictionary size]:dictionary size (KB):( 64 128 256 512 1024 2048 4096 a b c d e f g )' \
'-ms[specify file types to store]' \
- '-ol[save symbolic links as the link instead of the file]' \
'-p[set password]' \
'-r0[recurse subdirectories for wildcard names only]' \
'-rr[add data recovery record]' \
diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf
index 43cbc81c6..a0ecdaf2a 100644
--- a/Completion/Unix/Command/_readelf
+++ b/Completion/Unix/Command/_readelf
@@ -2,11 +2,11 @@
local variant args sections
-sections=( .bss .data .dynamic .dynsym .got .interp .shstrtab .symtab .text )
+sections=( .bss .comment .data .dynamic .dynsym .got .interp .shstrtab .symtab .text )
_pick_variant -r variant elftoolchain=elftoolchain elfutils=elfutils binutils --version
args=(
- '(-a --all)'{-a,--all}'[show all tables]'
+ '(-a --all -h --file-header -l --program-headers --segments -S --section-headers --sections -r --relocs -d --dynamic -V --version-info -A --arch-specific -I --histogram --got-contents)'{-a,--all}'[show all tables]'
'(-g --section-groups)'{-g,--section-groups}'[show section groups]'
'(-h --file-header)'{-h,--file-header}'[show file header]'
'(-l --program-headers --segments)'{-l,--program-headers,--segments}'[show program headers]'
@@ -57,8 +57,12 @@ case $variant in
'(-C)--demangle=-[decode symbol names]::style [auto]:(none auto gnu-v3 java gnat dlang rust)'
'!(--no-recurse-limit)--recurse-limit'
'--no-recurse-limit[disable demangling recursion limit]'
- '-U+[specify how to display unicode characters]:method:(d l e x h i)'
- '--unicode=[specify how to display unicode characters]:method:(default locale escape hex highlight invalid)'
+ '(-U --unicode)'{-U+,--unicode=}'[specify how to treat UTF-8 encoded unicode characters]: : _values "treatment [locale]"
+ {l,locale,d,default}"[convert to current locale]"
+ {i,invalid}"[not part of a valid string]"
+ {x,hex}"[<> enclosed hex byte sequences]"
+ {e,escape}"[escape sequences (\\\\uxxxx)]"
+ {h,highlight}"[escape sequences highlighted in red]"' \
'(-X --extra-sym-info)'{-X,--extra-sym-info}'[display extra information when showing symbols]'
'!(-X --extra-sym-info)--no-extra-sym-info'
'(-L --lint --enable-checks)'{-L,--lint,--enable-checks}'[display warning messages for possible problems]'
@@ -71,6 +75,7 @@ case $variant in
'--ctf-symbols=[use specified section as the CTF external symbol table]:section'
'--ctf-strings=[use specified section as the CTF external string table]:section'
'--sframe=-[display SFrame info from section]::section name [.sframe]'
+ '(-a --all)--got-contents[display GOT section contents]'
'(-T --silent-truncation)'{-T,--silent-truncation}"[if a symbol name is truncated, don't add ... suffix]"
)
;;
diff --git a/Completion/Unix/Command/_rm b/Completion/Unix/Command/_rm
index cc2e456b5..4575e4dc4 100644
--- a/Completion/Unix/Command/_rm
+++ b/Completion/Unix/Command/_rm
@@ -9,7 +9,7 @@ args=(
'*:: :->file'
)
_pick_variant -r variant -b zsh gnu='(GNU|uutils)' $OSTYPE --version
-case $variant; in
+case $variant in
gnu)
opts=()
args+=(
diff --git a/Completion/Unix/Command/_rmdir b/Completion/Unix/Command/_rmdir
index 029fa5b85..deb244abb 100644
--- a/Completion/Unix/Command/_rmdir
+++ b/Completion/Unix/Command/_rmdir
@@ -8,7 +8,7 @@ args=(
)
_pick_variant -r variant -b zsh gnu='(GNU|uutils)' $OSTYPE --version
-case $variant; in
+case $variant in
gnu)
aopts=()
args+=(
diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsync
index 1657d411e..d6748f0f5 100644
--- a/Completion/Unix/Command/_rsync
+++ b/Completion/Unix/Command/_rsync
@@ -209,9 +209,9 @@ _rsync() {
'--force-change[affect user-/system-immutable files/dirs]' \
'--force-uchange[affect user-immutable files/dirs]' \
'--force-schange[affect system-immutable files/dirs]' \
- "--max-delete=[don't delete more than NUM files]: :_numbers -f -u bytes size B K M G T P" \
+ "--max-delete=[don't delete more than the specified number of files]:number" \
"--max-size=[don't transfer any file larger than specified size]: :_numbers -f -u bytes size B K M G T P" \
- '--min-size=[do not transfer any file smaller than specified size]:number' \
+ "--min-size=[don't transfer any file smaller than specified size]: :_numbers -f -u bytes size B K M G T P" \
'--max-alloc=[set limit to individual memory allocation]: :_numbers -f -u bytes -d 1g size B K M G T P' \
'(-P)--partial[keep partially transferred files]' \
'--no-partial[turn off --partial]' \
@@ -278,8 +278,8 @@ _rsync() {
'(--usermap --groupmap --chown)--chown=[simple username/groupname mapping]:user and/or group:_rsync_users_groups' \
'*'{-M+,--remote-option=}'[send option to the remote side only]:option string' \
'--preallocate[preallocate the full length of new files]' \
- '--iconv=[request charset conversion of filenames]:number' \
- '--checksum-seed=:number' \
+ '--iconv=[request charset conversion of filenames]:convert specification' \
+ '--checksum-seed=[set checksum seed (advanced)]:number' \
'--read-batch=[read a batched update from the specified file]:file:_files'
}
diff --git a/Completion/Unix/Command/_ruby b/Completion/Unix/Command/_ruby
index 82111b455..eebf6c25f 100644
--- a/Completion/Unix/Command/_ruby
+++ b/Completion/Unix/Command/_ruby
@@ -1,8 +1,8 @@
#compdef ruby irb erb ruby-mri -P (ruby|[ei]rb)[0-9.]# -value-,RUBY(LIB|OPT|PATH),-default-
-local curcontext="$curcontext" state line expl desc RUBY ret=1
+local curcontext="$curcontext" state line expl desc RUBY variant ret=1
typeset -A opt_args
-local -a opts irb erb all common charsets suf
+local -a opts irb erb all common charsets suf jit_opts
all=(
'*-r+[require the library before executing your script]:library name:->library'
@@ -47,23 +47,112 @@ opts=(
'--backtrace-limit=[limit the maximum length of backtrace]:number'
'!'{-y,--yydebug}
'!--dump=:target:(version copyright usage yydebug syntax parsetree parsetree_with_comment insns)'
- '(--mjit --yjit)--jit[enable jit for the platform]'
- '(--jit --yjit)--mjit[enable C compiler-based JIT compiler]'
- '(--jit --mjit)--yjit[enable in-process JIT compiler]'
- '--mjit-warnings[enable printing JIT warnings]'
- '--mjit-debug[enable JIT debugging (very slow)]'
- '--mjit-wait[wait until JIT compilation finishes every time (for testing)]'
- '--mjit-save-temps[save JIT temporary files]'
- '--mjit-verbose=-[print JIT logs of level num or less to stderr]:maximum log level [0]'
- '--mjit-max-cache=-[specify max number of methods to be JIT-ed in a cache]:number [100]'
- '--mjit-min-calls=-[specify number of calls to trigger JIT]:calls [10000]'
- '--yjit-stat[enable collecting YJIT statistics]'
- '--yjit-exec-mem-size=-[size of executable memory block in MiB]:mem size'
- '--yjit-call-threshold=-[number of calls to trigger JIT]:number'
- '--yjit-max-versions=-[maximum number of versions per basic block]:versions'
- '--yjit-greedy-versioning[greedy versioning mode]'
)
+if [[ $service == ruby[0-9.]# ]]; then
+ _pick_variant -r variant -c "$service --version" \
+ ruby_no_jit='ruby ([01].|2.[0-5])' \
+ ruby_experimental_jit='ruby (2.[67]|3.0)' \
+ ruby31='ruby 3.1' ruby32='ruby 3.2' ruby33='ruby 3.3' ruby34='ruby 3.4' \
+ ruby40='ruby 4.0' ruby41_higher
+
+ if [[ $variant != "ruby_no_jit" ]]; then
+ jit_opts=('(--jit --mjit --yjit --rjit --zjit)--jit[enable default JIT for the platform]')
+ fi
+
+ case "$variant" in
+ (ruby_experimental_jit|ruby31)
+ jit_opts+=(
+ '--jit-warnings[enable printing JIT warnings]'
+ '--jit-debug[enable JIT debugging (very slow)]'
+ '--jit-wait[wait until JIT compilation finishes every time (for testing)]'
+ '--jit-save-temps[save JIT temporary files]'
+ '--jit-verbose=-[print JIT logs of level num or less to stderr]:log level'
+ '--jit-max-cache=-[specify max number of methods to be JIT-ed in a cache]:num'
+ '--jit-min-calls=-[specify number of calls to trigger JIT]:num'
+ )
+ ;|
+ (ruby31|ruby32)
+ jit_opts+=(
+ '(--jit --mjit --yjit)--mjit[enable C compiler-based JIT compiler]'
+ '(--jit --mjit --yjit)--yjit[enable in-process JIT compiler]'
+ )
+ ;|
+ (ruby31|ruby32)
+ jit_opts+=(
+ '--mjit-warnings[enable printing JIT warnings]'
+ '--mjit-debug[enable JIT debugging (very slow)]'
+ '--mjit-wait[wait until JIT compilation finishes every time (for testing)]'
+ '--mjit-save-temps[save JIT temporary files]'
+ '--mjit-verbose=-[print JIT logs of level num or less to stderr]:log level'
+ '--mjit-max-cache=-[specify max number of methods to be JIT-ed in a cache]:num'
+ '--mjit-min-calls=-[specify number of calls to trigger JIT]:num'
+ '--yjit-max-versions=[Maximum number of versions per basic block (default: 4)]:num'
+ '--yjit-greedy-versioning[Greedy versioning mode (default: disabled)]'
+ )
+ ;|
+ (ruby32|ruby33|ruby34|ruby40|ruby41_higher)
+ jit_opts+=(
+ '--yjit-stats[Enable collecting YJIT statistics]'
+ '--yjit-exec-mem-size=[Hard limit on executable memory block in MiB]:mem size'
+ '--yjit-call-threshold=[Number of calls to trigger JIT]:num'
+ )
+ ;|
+ (ruby33|ruby34|ruby40|ruby41_higher)
+ # mjit was removed since Ruby 3.3
+ jit_opts+=(
+ '--yjit-cold-threshold=[Global calls after which ISEQs not compiled (default: 200K)]:num'
+ '--yjit-disable[Disable YJIT for lazily enabling it with RubyVM::YJIT.enable]'
+ '--yjit-code-gc[Run code GC when the code size reaches the limit]'
+ '--yjit-perf[Enable frame pointers and perf profiling]'
+ '--yjit-trace-exits[Record Ruby source location when exiting from generated code]'
+ '--yjit-trace-exits-sample-rate=[Trace exit locations only every Nth occurrence]:num'
+ )
+ ;|
+ (ruby34|ruby40|ruby41_higher)
+ jit_opts+=(
+ '--yjit-mem-size=[Soft limit on YJIT memory usage in MiB (default: 128)]:mem size'
+ "--yjit-log=[Enable logging of YJIT's compilation activity]: :_files"
+ )
+ ;|
+ (ruby33|ruby34)
+ # ruby 3.3 and 3.4 provide rjit
+ jit_opts+=(
+ '(--jit --yjit --rjit)--yjit[Enable in-process JIT compiler]'
+ '--rjit-exec-mem-size=[Size of executable memory block in MiB (default: 64)]:mem size'
+ '--rjit-call-threshold=[Number of calls to trigger JIT (default: 10)]:num'
+ '--rjit-stats[Enable collecting RJIT statistics]'
+ '--rjit-disable[Disable RJIT for lazily enabling it with RubyVM::RJIT.enable]'
+ '--rjit-trace[Allow TracePoint during JIT compilation]'
+ '--rjit-trace-exits[Trace side exit locations]'
+ )
+ ;|
+ (ruby40|ruby41_higher)
+ # zjit was introduced since ruby 4
+ jit_opts+=(
+ '(--jit --yjit --zjit)--yjit[Enable in-process JIT compiler]'
+ '(--jit --yjit --zjit)--zjit[enable method-based JIT compiler]'
+ '--zjit-mem-size=[Max amount of memory that ZJIT can use in MiB (default: 128)]:mem size'
+ '--zjit-call-threshold=[Number of calls to trigger JIT (default: 30)]:num'
+ '--zjit-num-profiles=[Number of profiled calls before JIT (default: 5)]:num'
+ '--zjit-stats-quiet[Collect ZJIT stats and suppress output]'
+ '--zjit-stats=-[Collect ZJIT stats]: :_files'
+ '--zjit-disable[Disable ZJIT for lazily enabling it with RubyVM::ZJIT.enable]'
+ '--zjit-perf[Dump ISEQ symbols into /tmp/perf-{}.map for Linux perf]'
+ '--zjit-log-compiled-iseqs=[Log compiled ISEQs to the file. The file will be truncated]: :_files'
+ '--zjit-trace-exits=-[Record source on side-exit]:counter'
+ '--zjit-trace-exits-sample-rate=[Frequency at which to record side exits]:frequency'
+ )
+ ;|
+ (ruby41_higher)
+ jit_opts+=(
+ '--zjit-trace-compiles[Record compilation phases as Perfetto trace events]'
+ '--zjit-trace-invalidation[Record invalidation events as Perfetto trace events]'
+ )
+ ;|
+ esac
+fi
+
irb=(
'-f[suppress read of ~/.irbrc]'
$opts[(r)*-d\[*]
@@ -121,7 +210,7 @@ case "$service" in
;;
ruby[0-9.]#)
RUBY=$words[1]
- _arguments -C -s -S : $opts $all $common && ret=0
+ _arguments -C -s -S : $opts $all $common $jit_opts && ret=0
;;
irb[0-9.]#)
RUBY=${words[1]/irb/ruby}
diff --git a/Completion/Unix/Command/_screen b/Completion/Unix/Command/_screen
index 9336ae82d..65cb63e31 100644
--- a/Completion/Unix/Command/_screen
+++ b/Completion/Unix/Command/_screen
@@ -76,6 +76,7 @@ _arguments -C \
'-m[ignore $STY variable, do create a new screen session]' \
'-O[choose optimal output rather than exact vt100 emulation]' \
'-p[preselect the named window]:window number or name:((\=\:windowlist -\:blank\ window \:window\ number))' \
+ '-P[enable authentication]' \
'-q[quiet startup, exit with non-zero return code if unsuccessful]' \
'-Q[send response to stdout of command query process]:screen command:(echo info lastmsg number select time title windows)' \
'-r[reattach to a detached screen process]: :->detached-sessions' \
diff --git a/Completion/Unix/Command/_script b/Completion/Unix/Command/_script
index 25f8ea35f..431a112e1 100644
--- a/Completion/Unix/Command/_script
+++ b/Completion/Unix/Command/_script
@@ -30,7 +30,7 @@ case $OSTYPE in
"(-T --log-timing -t --timing $hlp)"{-T+,--log-timing=}'[log timing information to file]:file:_files'
"(-m --logging-format $hlp)"{-m+,--logging-format=}'[specify log file format]:format:(classic advanced)'
"(-a --append $hlp)"{-a,--append}'[append to the log file]'
- "(-c --command $hlp)"{-c,--command=}'[run specified command instead of a shell]:command:_cmdstring'
+ "(-c --command $hlp --)"{-c,--command=}'[run specified command instead of a shell]:command:_cmdstring'
"(-e --return $hlp)"{-e,--return}'[return exit status of the child process]'
"(-f --flush $hlp)"{-f,--flush}'[flush output after each write]'
"(-E --echo $hlp)"{-E+,--echo=}'[echo input]:when:(auto always never)'
@@ -40,6 +40,7 @@ case $OSTYPE in
"(-t --timing $hlp)"{-t-,--timing=-}'[output timing data]::timing file:_files'
'(- 1)'{-h,--help}'[display help information]'
'(- 1)'{-V,--version}'[display version information]'
+ '!--:*::: : _normal $service'
)
;;
darwin*|dragonfly*|netbsd*|freebsd*)
diff --git a/Completion/Unix/Command/_sed b/Completion/Unix/Command/_sed
index ecbec61d1..262628155 100644
--- a/Completion/Unix/Command/_sed
+++ b/Completion/Unix/Command/_sed
@@ -88,7 +88,7 @@ elif _pick_variant -r variant gnu=GNU unix --version; then
'v:fail if GNU extensions not supported or older than specified version'
)
cmds_end+=(
- "e:execute a command and include it's output"
+ "e:execute a command and include its output"
'F:print the filename of the current input file'
'Q:quit'
'z:empty the pattern space'
diff --git a/Completion/Unix/Command/_service b/Completion/Unix/Command/_service
index 28563429b..5f9ca0d67 100644
--- a/Completion/Unix/Command/_service
+++ b/Completion/Unix/Command/_service
@@ -11,14 +11,18 @@ zstyle -T ":completion:${ctx}" tag-order && \
case $OSTYPE in
freebsd<14->.*)
- args=( '-E+[set environment variable before executing the rc.d script]:variable:_parameters -g "*export*~*readonly*" -S=' )
+ args=(
+ '(-l -r)-d[enable debugging of rc.d scripts]'
+ '-E+[set environment variable before executing the rc.d script]:variable:_parameters -g "*export*~*readonly*" -S='
+ '(-l -r)-q[quiet]'
+ )
;&
freebsd<11->.*)
args+=( '-j+[perform actions in specified jail]:jail:_jails' )
;&
freebsd*|dragonfly*)
actions=(
- '(*)-r[show the results of boot time rcorder]'
+ '(* -q -d)-r[show the results of boot time rcorder]'
'(*)-R[restart all enabled local services]'
)
;&
@@ -28,7 +32,7 @@ case $OSTYPE in
'*::service argument:_init_d' \
+ '(actions)' $actions \
'(*)-e[show services that are enabled]' \
- '(*)-l[list all scripts in /etc/rc.d and the local startup directory]' \
+ '(* -q -d)-l[list all scripts in /etc/rc.d and the local startup directory]' \
':service name:_services'
;;
*)
diff --git a/Completion/Unix/Command/_sh b/Completion/Unix/Command/_sh
index f0f18d4bb..d50b81ccc 100644
--- a/Completion/Unix/Command/_sh
+++ b/Completion/Unix/Command/_sh
@@ -1,36 +1,151 @@
-#compdef sh ash csh dash ksh ksh88 ksh93 mksh oksh pdksh rc tcsh yash
+#compdef sh ash csh dash ksh ksh88 ksh93 lksh mksh oksh osh pdksh posh rc rksh rksh93 tcsh yash ysh
-local bourne argv0
-local -a args all_opts=( -{{0..9},{A..Z},{a..z}} )
+(( $+functions[_sh_set_options] )) ||
+_sh_set_options() {
+ local MATCH MBEGIN MEND k_ v_
+ local -a opts_ tmp_ expl_
-[[ $service == (csh|?csh|fish|rc) ]] || bourne=1
+ tmp_=( ${(f)"$( _call_program options $words[1] -c '"set -o"' )"} )
-# Bourne-style shells support +x variants
-# @todo Uncomment when workers/45422 is fixed
-# (( bourne )) && all_opts+=( ${all_opts/#-/+} )
-# Bourne-style shells take argv[0] as the second argument to -c
-(( bourne )) && argv0=':argv[0]:'
+ # remove heading
+ [[ $tmp_[1] == (#i)*'current option'* ]] && tmp_=( $tmp_[2,-1] )
+ # convert osh/ysh syntax
+ [[ $tmp_[1] == set\ [+-]o\ * ]] && {
+ tmp_=( ${(@)tmp_##set [+-]o } )
+ tmp_=( ${tmp_:^tmp_} )
+ }
+ # loop since some shells arrange the options in columns
+ for k_ v_ in $=tmp_; do
+ opts_+=( $k_ )
+ done
-# All of the recognised shells support at least these arguments
-args=(
- "(1 -)-c[execute specified command string]: :_cmdstring$argv0"
- '-e[exit immediately on non-zero return]'
- '-i[act as interactive shell]'
- '-l[act as login shell]'
- '-x[print command trace]'
- '1:script file:_files'
- '*:: :_files'
-)
-# Bourne-style shells support -o/+o option. Not all of them support -ooption in
-# the same argument, but we'll allow it here for those that do
-(( bourne )) && args+=(
- '-o+[set specified option]:option:'
- '+o+[unset specified option]:option:'
-)
-# Since this is a generic function we don't know what other options these shells
-# support, but we don't want them to break the ones listed above, so we'll just
-# ignore any other single-alphanumeric option. Obviously this doesn't account
-# for long options
-args+=( '!'${^${all_opts:#(${(~j<|>)${(@M)${(@M)args#(*[\*\)]|)[+-]?}%[+-]?}})}} )
+ _wanted set-options expl_ 'set option' compadd -a "$@" - opts_
+}
-_arguments -s -S -A '-*' : $args
+local variant apat='[+-]?*'
+local -a args oopts
+
+case ${${(Q)words[1]}:t} in
+ r#ksh)
+ _pick_variant -r variant \
+ ksh93=showme \
+ mksh='utf8-#mode' \
+ oksh='csh-#history' \
+ '' \
+ -c '"set -o"'
+ ;;
+ sh)
+ _pick_variant -r variant \
+ zsh=junkie \
+ bash=onecmd \
+ ksh93=showme \
+ mksh='utf8-#mode' \
+ oksh='csh-#history' \
+ ksh=keyword \
+ dash=debug \
+ '' \
+ -c '"set -o"'
+ ;;
+esac
+case $variant in
+ bash|zsh) _$variant "$@"; return ;;
+ ?*) service=$variant ;;
+esac
+
+# bourne/ksh/posix-style shells. not meant to be totally accurate, but mostly
+if [[ $service != (csh|?csh|rc) ]]; then
+ args=(
+ # invocation options
+ '(1 -)-c[execute specified command string]: :_cmdstring:argv[0]:'
+ '-i[act as interactive shell]'
+ '-l[act as login shell]' # not defined by posix but very widely supported
+ '-o+[set specified option]: :_sh_set_options'
+ '+o+[unset specified option]: :_sh_set_options'
+ '(-c)-s[read commands from standard input]'
+ # set options. these are all defined by posix
+ '(-a +a)'{'-a[',"+a[don't "}'mark all variables for export]'
+ '(-b +b)'{'-b[',"+b[don't "}'report status of terminated background jobs immediately]'
+ '(-C +C)'{'-C[',"+C[don't "}'prevent output redirection from overwriting existing files]'
+ '(-e +e)'{'-e[',"+e[don't "}'exit immediately on non-zero return]'
+ '(-f +f)'{'-f[',"+f[don't "}'disable file globbing]'
+ '(-h +h)'{'-h[',"+h[don't "}'hash commands]'
+ '(-m +m)'{'-m[',"+m[don't "}'enable job control]'
+ '(-n +n)'{'-n[',"+n[don't "}'read (syntax-check) commands only]'
+ '(-u +u)'{'-u[',"+u[don't "}'treat unset variables as an error during parameter expansion]'
+ '(-v +v)'{'-v[',"+v[don't "}'print shell input lines as they are read]'
+ '(-x +x)'{'-x[',"+x[don't "}'print command trace]'
+ )
+
+ case $service in
+ dash)
+ args=(
+ ${args:#\(*\)[+-]h\[*}
+ '(-E +E -V +V)'{'-E[',"+E[don't "}'use emacs-style command-line editing]'
+ '(-I +I)'{'-I[',"+I[don't "}'ignore EOF]'
+ '(-E +E -V +V)'{'-V[',"+V[don't "}'use vi-style command-line editing]'
+ )
+ ;;
+ yash)
+ PREFIX= _sh_set_options -O oopts
+ oopts=( ${oopts:#cmdline} )
+ args+=(
+ '(- : *)--help[display help information]'
+ '(- : *)'{-V,--version}'[display version information]'
+ "(--profile)--noprofile[don't load ~/.yash_profile]"
+ "(--rcfile)--norcfile[don't load ~/.yashrc]"
+ '(--noprofile)--profile=[load specified file instead of ~/.yash_profile]:.yash_profile file:_files'
+ '(--norcfile)--rcfile=[load specified file instead of ~/.yashrc]:.yashrc file:_files'
+ ${${(M)args:#\(*\)-c\[*}/-c/--cmdline}
+ --$^oopts
+ ++$^oopts
+ )
+ ;;
+ *ksh*)
+ args+=(
+ '(-k +k)'{'-k[',"+k[don't "}'recognise parameter assignments anywhere in a command]'
+ '(-p +p)'{'-p[',"+p[don't "}'enable privileged mode]'
+ '(-r +r)'{'-r[',"+r[don't "}'enable restricted mode]'
+ )
+ ;|
+ oksh|r#[lm]ksh)
+ args+=(
+ '(-X +X)'{'-X[',"+X[don't "}'mark directories with trailing / when globbing]'
+ )
+ ;|
+ ksh93)
+ PREFIX= _sh_set_options -O oopts
+ oopts=( ${${oopts:#rc}//[_-]/} )
+ args+=(
+ '(-B +B)'{'-B[',"+B[don't "}'enable brace expansion]'
+ '(-D +D)'{'-D[',"+D[don't "}'display strings subject to language translation]'
+ '(-E +E --rc)'{'--rc[','-E[',"+E[don't "}'load $ENV or ~/.kshrc]'
+ '(-G +G)'{'-G[',"+G[don't "}'enable ** pattern (globstar)]'
+ '(-H +H)'{'-H[',"+H[don't "}'enable history expansion]'
+ '(-t +t)'{'-t[',"+t[don't "}'read one command and exit]'
+ --$^oopts
+ )
+ [[ $PREFIX == --n* ]] && args+=( --no$^oopts )
+ ;;
+ r#[lm]ksh)
+ args+=(
+ '(-U +U)'{'-U[',"+U[don't "}'enable UTF-8 support]'
+ '-T+[spawn on specified tty]:tty:_files -g "*(%c)"'
+ )
+ ;;
+ esac
+
+# others. these options are common to all of those currently enumerated
+else
+ apat='-?*'
+ args=(
+ '(1 -)-c[execute specified command string]: :_cmdstring'
+ '-e[exit immediately on non-zero return]'
+ '-i[act as interactive shell]'
+ '-l[act as login shell]'
+ '-x[print command trace]'
+ )
+fi
+
+args+=( '1:script file:_files' '*:: :_files' )
+
+_arguments -s -S -A $apat : $args
diff --git a/Completion/Unix/Command/_shutdown b/Completion/Unix/Command/_shutdown
index a237b14e0..fdadd3b12 100644
--- a/Completion/Unix/Command/_shutdown
+++ b/Completion/Unix/Command/_shutdown
@@ -1,35 +1,39 @@
#compdef shutdown
-local -a args
+local curcontext="$curcontext" variant="$OSTYPE" ret=1
+local -a state line args suffixes
-if [[ -d /etc/systemd ]]; then
- _arguments \
- '--help[display usage information]' \
- '(-H --halt)'{-H,--halt}'[halt the machine]' \
- '(-P --poweroff -h)'{-P,--poweroff,-h}'[power-off the machine (default)]' \
- '(-r --reboot)'{-r,--reboot}'[reboot the machine]' \
- "(--no-wall)-k[don't shutdown, just write wall message]" \
- "(-k)--no-wall[don't send a wall message]" \
- '-c[cancel pending shutdown]' \
- '1: :_guard "^-*" "time (now/hh\:mm/+mins)"' \
- '*:warning message'
- return
-fi
+[[ -d /run/systemd/system ]] && variant=systemd
-case $OSTYPE in
+case $variant in
+ systemd)
+ args=(
+ "(-k)--no-wall[don't send a wall message]"
+ '1: :->times'
+ '*:warning message'
+ + '(action)'
+ '(* : -)--help[display usage information]'
+ "(--no-wall)-k[don't shutdown, just write wall message]"
+ {-H,--halt}'[halt the machine]'
+ {-P,--poweroff,-h}'[power-off the machine (default)]'
+ {-r,--reboot}'[reboot the machine]'
+ '-c[cancel pending shutdown]'
+ )
+ ;;
*bsd*|dragonfly*|linux*|darwin*)
args=(
- '-h[halt the system after shutdown]'
- '-r[reboot the system]'
+ '(-p -r -c)-h[halt the system after shutdown]'
+ '(-p -h -c)-r[reboot the system]'
'-k[kick everybody off]'
'-n[prevent file system cache from being flushed]'
- '1: :_guard "^-*" "time (now/hh\:mm/+mins)"'
+ '1: :->times'
+ '(*)-[read warning message from standard input]' \
'*:warning message'
)
;|
*bsd*|dragonfly*)
args+=(
- '-p[turn off power after shutdown]'
+ '(-h -r -c)-p[turn off power after shutdown]'
)
;|
(net|open)bsd*)
@@ -39,13 +43,14 @@ case $OSTYPE in
)
;|
freebsd*|dragonfly*)
+ suffixes=( s:seconds :m:minutes h:hours )
args+=(
'-o[execute halt or reboot instead of sending a signal to init]'
)
;|
freebsd<12->.*)
args+=(
- '-c[power cycle the system instead of halting if possible]'
+ '(-h -r -p)-c[power cycle the system instead of halting if possible]'
)
;;
netbsd*)
@@ -74,4 +79,16 @@ case $OSTYPE in
;;
esac
-_arguments $args
+_arguments -C $args && ret=0
+
+if [[ -n $state ]]; then
+ if compset -P '+'; then
+ _numbers -u minutes "grace period" $suffixes
+ else
+ _alternative \
+ 'relative-times:relative time:{ compadd "$expl[@]" -S "" +; compadd "$expl[@]" now }' \
+ 'absolute-times: :_guard "^-*" "time ([yymmdd]hhmm)"' && ret=0
+ fi
+fi
+
+return ret
diff --git a/Completion/Unix/Command/_sleep b/Completion/Unix/Command/_sleep
new file mode 100644
index 000000000..677062ab9
--- /dev/null
+++ b/Completion/Unix/Command/_sleep
@@ -0,0 +1,25 @@
+#compdef sleep
+
+local sum inf fraction
+local -a expl units
+
+case $OSTYPE in
+ linux-gnu)
+ args=(
+ -S
+ '--help[display help information]'
+ '--version[display version information]'
+ )
+ ;& # fall-through
+ solaris*)
+ inf="_phony infinity --"
+ ;& # fall-through
+ darwin*|freebsd*)
+ units=( :s:seconds m:minutes h:hours d:days )
+ sum='*'
+ fraction='-f'
+ ;;
+esac
+
+_arguments $args \
+ "${sum}:interval:$inf _numbers $fraction -u seconds interval $units"
diff --git a/Completion/Unix/Command/_sort b/Completion/Unix/Command/_sort
index 90827de4f..ac808a6d4 100644
--- a/Completion/Unix/Command/_sort
+++ b/Completion/Unix/Command/_sort
@@ -45,7 +45,6 @@ case $variant in
"$ordering"{-R,--random-sort}'[sort by random hash of keys]'
"$ordering"{-V,--version-sort}'[sort version numbers]'
"$ordering--sort=[specify comparator]:comparator:(general-numeric human-numeric month numeric random version)"
- '(-i --ignore-nonprinting)'{-i,--ignore-nonprinting}'[consider only printable characters]'
'--random-source=[get random bytes from file]:file:_files'
'--batch-size=[maximum inputs to merge]:number'
'--compress-program=[specify program to compress temporary files with]:program:(gzip bzip2 lzop xz)'
diff --git a/Completion/Unix/Command/_sqlite b/Completion/Unix/Command/_sqlite
index a83624083..9b8431248 100644
--- a/Completion/Unix/Command/_sqlite
+++ b/Completion/Unix/Command/_sqlite
@@ -47,20 +47,24 @@ options+=(
$^dashes'-bail[stop after hitting an error]'
$^dashes'-cmd[run specified command before reading stdin]:sqlite meta-command'
$^dashes'-deserialize[open the database using sqlite3_deserialize()]'
+ $^dashes'-escape[set rendering of control characters in output]:escape [ascii]:(symbol ascii off)'
'(-*batch -*interactive)'$^dashes'-batch[force batch I/O]'
'(-*batch -*interactive)'$^dashes'-interactive[force interactive I/O]'
+ $^dashes'-ifexists[only open if database already exists]'
$^dashes'-lookaside[specify size and number of entries for lookaside memory]:size (bytes): :entries'
$^dashes'-maxsize[specify maximum size for a --deserialize database]:size'
$^dashes'-memtrace[trace all memory allocations and deallocations]'
$^dashes'-mmap[set default mmap size]:size'
$^dashes'-newline[set output row separator]:separator [\n]'
$^dashes'-nofollow[refuse to open symbolic links to database files]'
+ $^dashes"-noinit[don't read ~/.sqliterc file at startup]"
$^dashes'-nonce[set the safe-mode escape nonce]:string'
$^dashes'-no-rowid-in-view[disable rowid-in-view using sqlite3_config()]'
$^dashes'-pagecache[specify size and number of slots for page cache memory]:size (bytes): :slots'
$^dashes'-pcachetrace[trace all page cache operations]'
$^dashes'-readonly[open the database read-only]'
$^dashes'-safe[enable safe-mode]'
+ $^dashes'-screenwidth[use specified default screen width]:width'
$^dashes'-stats[print memory stats before each finalize]'
$^dashes'-unsafe-testing[allow unsafe commands and modes for testing]'
$^dashes'-vfs[use specified default VFS]:vfs:(unix-dotfile unix-excl unix-none unix-namedsem)'
diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh
index 9ab1a1139..c95849e84 100644
--- a/Completion/Unix/Command/_ssh
+++ b/Completion/Unix/Command/_ssh
@@ -13,7 +13,7 @@ _ssh () {
'-A[enable forwarding of the authentication agent connection]'
'-C[compress data]'
'-c+[select encryption cipher]:encryption cipher:->ciphers'
- '-F+[specify alternate config file]:config file:_files'
+ '-F+[specify alternate config file]:config file:_phony none _files'
'*-i+[select identity file]:SSH identity file:_files -g "*(-.^AR)"'
'*-o+[specify extra options]:option string:->option'
)
@@ -41,7 +41,7 @@ _ssh () {
'-B+[bind to specified interface before attempting to connect]:interface:_net_interfaces' \
'(-P)-b+[specify interface to transmit on]:bind address:_bind_addresses' \
'-D+[specify a dynamic port forwarding]:dynamic port forwarding:->dynforward' \
- '-e+[set escape character]:escape character (or `none'\''):' \
+ '-e+[set escape character]:escape character:_phony none' \
'-E+[append log output to file instead of stderr]:log file:_files' \
'(-n)-f[go to background]' \
'-g[allow remote hosts to connect to local forwarded ports]' \
@@ -61,7 +61,7 @@ _ssh () {
'-p+[specify port on remote host]:port number on remote host' \
'(-v)*-q[quiet operation]' \
'*-R+[specify remote port forwarding]:remote port forwarding:->forward' \
- '-S+[specify location of control socket for connection sharing]:path to control socket:_files' \
+ '-S+[specify location of control socket for connection sharing]:path to control socket:_phony none _files' \
'(- 1 *)-Q+[query parameters]:query option:((cipher\:"supported symmetric ciphers" cipher-auth\:"supported symmetric ciphers that support authenticated encryption" compression mac\:"supported message integrity codes" kex\:"key exchange algorithms" kex-gss\:"GSSAPI key exchange algorithms" key\:"key types" key-cert\:"certificate key types" key-plain\:"non-certificate key types" key-sig\:"all key types and signature algorithms" protocol-version\:"supported SSH protocol versions" sig\:"supported signature algorithms" help\:"show supported queries" HostbasedAcceptedAlgorithms HostKeyAlgorithms KexAlgorithms MACs PubkeyAcceptedAlgorithms))' \
'-s[invoke subsystem]' \
'(-t)-T[disable pseudo-tty allocation]' \
@@ -263,7 +263,7 @@ _ssh () {
"$p1($cmn -f -k -u -D)-U[indicate that CA key is held by ssh-agent]" \
"$p1($cmn -f -k -u -U)-D+[indicate the CA key is stored in a PKCS#11 token]:PKCS11 shared library:_files -g '*.(so|dylib)(|.<->)(-.)'" \
"$p1($cmn -f -k -u)-n+[specify user/host principal names to include in certificate]:principals" \
- "$p1($cmn -f -u)-V+[specify certificate validity interval]:interval" \
+ "$p1($cmn -f -u)-V+[specify certificate validity interval]:interval:_phony -S\: always" \
"($cmn -I -h -n -D -O -U -V)-k[generate a KRL file]" \
"$p1($cmn -I -h -n -D -O -U -V)-u[update a KRL]" \
- signature \
@@ -402,8 +402,8 @@ _ssh () {
'values:truth value:(yes no)' && ret=0
;;
(#i)escapechar=*)
- _message -e 'escape character (or `none'\'')'
- ret=0
+ _description escape-characters expl 'escape character'
+ _phony "$expl[@]" none && ret=0
;;
(#i)fingerprinthash=*)
_values 'fingerprint hash algorithm' \
diff --git a/Completion/Unix/Command/_strings b/Completion/Unix/Command/_strings
index 685daa286..774399328 100644
--- a/Completion/Unix/Command/_strings
+++ b/Completion/Unix/Command/_strings
@@ -18,6 +18,13 @@ if _pick_variant -r variant binutils=GNU elftoolchain=elftoolchain elfutils=elfu
l\:16-bit\ little-endian
B\:32-bit\ big-endian
L\:32-bit\ little-endian))'
+ '(-U --unicode -e --encoding)'{-U+,--unicode=}'[specify how to treat UTF-8 encoded unicode characters]: : _values "treatment [default]"
+ {d,default}"[rely on --encoding]"
+ {l,locale}"[convert to current locale]"
+ {i,invalid}"[not part of a valid string]"
+ {x,hex}"[<> enclosed hex byte sequences]"
+ {e,escape}"[escape sequences (\\\\uxxxx)]"
+ {h,highlight}"[escape sequences highlighted in red]"' \
'(-f --print-file-name)'{-f,--print-file-name}'[print name of the file before each string]'
'(-n --bytes)'{-n+,--bytes=}"$bytes"
'(-d -t --radix)'{-t+,--radix=}"$format"
diff --git a/Completion/Unix/Command/_strip b/Completion/Unix/Command/_strip
index 59cb537b9..930080f89 100644
--- a/Completion/Unix/Command/_strip
+++ b/Completion/Unix/Command/_strip
@@ -49,7 +49,9 @@ if _pick_variant -r variant gnu=GNU elftoolchain=elftoolchain $OSTYPE --version;
'(*)-o+[output file]:output file:_files'
'--keep-section-symbols[retain section symbols]'
'--keep-file-symbols[retain symbols specifying source file names]'
- '(-v --verbose)'{-v,--verbose}'[list all object files modified or members of archives]')
+ '(-v --verbose)'{-v,--verbose}'[list all object files modified or members of archives]'
+ '--plugin=[load specified plugin]:plugin'
+ )
;;
elftoolchain)
args+=(
diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion
index e2889c71a..d3f800610 100644
--- a/Completion/Unix/Command/_subversion
+++ b/Completion/Unix/Command/_subversion
@@ -79,7 +79,7 @@ _svn () {
usage=${${(M)${(f)"$(_call_program options svn help $dash_v -- $cmd)"}:#usage:*}#usage:*$cmd] }
_store_cache svn-${cmd}-usage usage
fi
- if _cache_invalid svn-${cmd}-usage || \
+ if _cache_invalid svn-${cmd}-args || \
! _retrieve_cache svn-${cmd}-args;
then
args=(
@@ -119,7 +119,7 @@ _svn () {
_store_cache svn-${cmd}-args args
fi
- case $cmd in;
+ case $cmd in
(add)
args+=(
'*:file: _svn_modified "addable"'
diff --git a/Completion/Unix/Command/_sudo b/Completion/Unix/Command/_sudo
index c334c6765..33a9d6c0c 100644
--- a/Completion/Unix/Command/_sudo
+++ b/Completion/Unix/Command/_sudo
@@ -52,7 +52,7 @@ else
'(--preserve-env -i --login -s --shell -e --edit)-E[preserve user environment when running command]' \
'(-E -i --login -s --shell -e --edit)--preserve-env=-[preserve user environment when running command]::environment variable:_sequence _parameters -g "*export*"' \
'(-H --set-home -i --login -s --shell -e --edit)'{-H,--set-home}"[set HOME variable to target user's home dir]" \
- '(-P --preserve-groups -i -login -s --shell -e --edit)'{-P,--preserve-groups}"[preserve group vector instead of setting to target's]" \
+ '(-P --preserve-groups -i --login -s --shell -e --edit)'{-P,--preserve-groups}"[preserve group vector instead of setting to target's]" \
'*:: :->normal'
)
fi
@@ -85,7 +85,7 @@ if [[ $state = normal ]]; then
'options:option:(-s --shell -l --login)' \
'parameters: :_parameters -g "*export*~*readonly*" -qS=' && ret=0
else
- _normal
+ _normal && ret=0
fi
fi
diff --git a/Completion/Unix/Command/_tcpdump b/Completion/Unix/Command/_tcpdump
index 7047b2d34..25605875f 100644
--- a/Completion/Unix/Command/_tcpdump
+++ b/Completion/Unix/Command/_tcpdump
@@ -94,9 +94,6 @@ _data_link_types () {
fi
}
-_bpf_filter () {
-}
-
args=(
'-A[print each packet in ASCII]'
'-c+[exit after receiving specified number of packets]:number of packets'
diff --git a/Completion/Unix/Command/_tex b/Completion/Unix/Command/_tex
index 1a70b5058..c5f0c370c 100644
--- a/Completion/Unix/Command/_tex
+++ b/Completion/Unix/Command/_tex
@@ -24,6 +24,6 @@ _arguments : \
'-src-specials=-[insert source specials in certain places of the DVI file]:WHERE:_values -s , WHERE cr display hbox math par parend vbox' \
'-translate-file=-[use the TCX file TCXNAME]:TCXNAME:' \
'-8bit[make all characters printable by default]' \
- '-help[display this help and exit]' \
+ '-help[display help and exit]' \
'-version[output version information and exit]' \
'*:TeX or LaTeX file:_files -g "*.(tex|TEX|texinfo|texi|dtx)(-.)"'
diff --git a/Completion/Unix/Command/_texinfo b/Completion/Unix/Command/_texinfo
index 2f5d0f91f..a37bc8ae9 100644
--- a/Completion/Unix/Command/_texinfo
+++ b/Completion/Unix/Command/_texinfo
@@ -123,13 +123,16 @@ case $service in
'--conf-dir=[specify additional directory for configuration files]:directory:_directories' \
'--init-file=[specify initialisation file]:file:_files' \
\*{-c+,--set-customization-variable=}'[set customization variable]:variable' \
+ '--trace-includes[print names of included files]' \
'(-v --verbose)'{-v,--verbose}'[explain what is being done]' \
'(* -)--version[display version info]' \
- '(--html --xml --plaintext)--docbook[output in DocBook XML format]' \
- '(--docbook --xml --plaintext)--html[output in HTML format]' \
+ '(--html --xml --epub3 --latex --plaintext)--docbook[output in DocBook XML format]' \
+ '(--docbook --xml --epub3 --latex --plaintext)--html[output in HTML format]' \
'--no-headers[suppress node separators and menus]' \
- '(--docbook --html --plaintext)--xml[output in XML (TexinfoML) format]' \
- '(--docbook --html --xml)--plaintext[output in plain text format]' \
+ '(--docbook --html --epub3 --latex --plaintext)--xml[output in XML (TexinfoML) format]' \
+ '(--docbook --html --xml --latex --plaintext)--epub3[output in EPUB 3 format]' \
+ '(--docbook --html --xml --epub3 --plaintext)--latex[output in LaTeX format]' \
+ '(--docbook --html --xml --epub3 --latex)--plaintext[output in plain text format]' \
'--dvi[output in dvi format]' \
'--dvipdf[output in pdf format]' \
'--ps[output in ps format]' \
@@ -138,11 +141,13 @@ case $service in
'(--docbook --xml)--no-split[suppress splitting of output]' \
'--no-number-sections[output chapter and section numbers]' \
'!(--no-number-sections)--number-sections' \
+ '--no-number-footnotes[number footnotes sequentially]' \
+ '!(--no-number-footnotes)--number-footnotes' \
'(-o --output=)'{-o,--output}'[specify output file]:output file:_files' \
'(--docbook --html --xml)--disable-encoding[output special characters]' \
'!(--disable-encoding)--enable-encoding' \
'(--docbook --html --xml)--fill-column=[specify width to break lines at]:width [72]' \
- '(--docbook --html --xml)--footnote-style=[specify style for output of footnotes]:((separate\:in\ own\ node end\:at\ end\ of\ node))' \
+ '(--docbook --html --xml)--footnote-style=[specify style for output of footnotes]:style [end]:((separate\:in\ own\ node end\:at\ end\ of\ node))' \
'(--docbook --html --xml)--paragraph-indent=[specify spaces to indent paragraphs by]:indent [3]' \
'(--docbook --html --xml)--split-size=[split Info files at specified size]:size [300000]' \
'(--docbook --xml --plaintext)--css-include=[specify file in include in HTML <style> output]:file:_files' \
@@ -151,7 +156,7 @@ case $service in
'(--docbook --xml --plaintext)--split=[split output at specified boundary]:split boundary:(chapter section node)' \
'(--docbook --xml --plaintext)--transliterate-file-names[produce file names in ASCII transliteration]' \
'(--docbook --xml --plaintext)--node-files[produce redirection files for nodes]' \
- '-Xopt=[specify option to texi2dvi]:options' \
+ '*-Xopt=[pass option to texi2dvi]:option' \
'-D[define variable]:variable' \
'-I[specify directory to append to @include search path]:directory:_files -/' \
'-P[specify directory to prepend to @include search path]:directory:_files -/' \
diff --git a/Completion/Unix/Command/_tiff b/Completion/Unix/Command/_tiff
index 1aeff3ff7..f44df0ec9 100644
--- a/Completion/Unix/Command/_tiff
+++ b/Completion/Unix/Command/_tiff
@@ -157,7 +157,8 @@ tiffinfo)
'-s[display offsets and byte counts for all data strips]' \
'-i[ignore read errors]' \
'-f+[force fill order]:fill order:(lsb2msb msb2lsb)' \
- '-w[display raw data in words]' \
+ '-w[show image data as 16-bit words]' \
+ '-W[warn about unknown tags]' \
'-z[enable strip chopping]' \
'-M+[set the memory allocation limit]:limit (MiB), 0 for unlimited' \
'*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
@@ -172,7 +173,7 @@ tiffmedian)
':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0
;;
tiffsplit)
- _arguments \
+ _arguments : \
'-M+[set the memory allocation limit]:limit (MiB), 0 for unlimited' \
':input file:_files -g "*.(#i)tif(|f)(-.)"' \
':output file prefix' && ret=0
@@ -235,6 +236,7 @@ pal2rgb)
*)
_description files expl 'picture file'
_files "$expl[@]" -g "$pat" && ret=0
+;;
esac
if [[ -n "$state" ]]; then
@@ -265,7 +267,7 @@ if [[ -n "$state" ]]; then
while _tags; do
while _next_label values expl 'compression scheme'; do
compadd "$expl[@]" - none jbig g4 packbits sgilog && ret=0
- compadd "$expl[@]" -qS: - lzw zip lzma zstd webp jpeg g3 && ret=0
+ compadd "$expl[@]" -qS: - lzw zip lerc lzma zstd webp jpeg g3 && ret=0
done
(( ret )) || return 0
done
diff --git a/Completion/Unix/Command/_timeout b/Completion/Unix/Command/_timeout
index f1961012d..676f8e8cd 100644
--- a/Completion/Unix/Command/_timeout
+++ b/Completion/Unix/Command/_timeout
@@ -11,9 +11,9 @@ local args
)
_arguments -S -A "-" $args \
- '--preserve-status[always exit with the same status as command even if it times out]' \
- "--foreground[don't propagate timeout to the command children]" \
+ '(-p --preserve-status)'{-p,--preserve-status}'[always exit with the same status as command even if it times out]' \
+ '(-f --foreground)'{-f,--foreground}"[don't propagate timeout to the command children]" \
'(-s --signal)'{-s,--signal}'[specify the signal to send on timeout]:signal:_signals' \
- '(-k --kill-after)'{-k,--kill-after}'[followup first signal with SIGKILL if command persists after specified time]:time' \
+ '(-k --kill-after)'{-k+,--kill-after=}'[followup first signal with SIGKILL if command persists after specified time]: :_numbers -f -u seconds duration \:s\:seconds m\:minutes h\:hours d\:days' \
'1: :_numbers -f -u seconds duration :s:seconds m:minutes h:hours d:days' \
'*:::command: _normal -p $service'
diff --git a/Completion/Unix/Command/_tla b/Completion/Unix/Command/_tla
deleted file mode 100644
index ec7e76d44..000000000
--- a/Completion/Unix/Command/_tla
+++ /dev/null
@@ -1,631 +0,0 @@
-#compdef tla
-
-autoload -z is-at-least
-local TLA=$words[1]
-local tla_version
-local hide_short
-
-# ask the user which version of tla this is
-if ! zstyle -s ":completion:${curcontext}:" tla-version tla_version; then
- # ask tla instead
- tla_version="$($TLA --version)"
- if [[ "${${(f)tla_version}[1]}" == The\ GNU\ Arch\ Revision\ Control\ System\ \(tla\)\ (#b)([0-9.]##) ]]; then
- tla_version="$match[1]"
- else
- tla_version="${${$($TLA --version)#tla tla-}%% from regexps.com*}"
- [[ $tla_version == *[a-zA-Z]* ]] && tla_version=1.3 # tla doesn't know
- fi
-fi
-
-# test whether to hide short options from completion
-if zstyle -s ":completion:${curcontext}:" hide-shortopts hide_short; then
- case $hide_short in
- true|yes|on|1) hide_short='!' ;;
- *) hide_short='' ;;
- esac
-fi
-
-# completion functions
-
-(( $+functions[_tla_archives] )) ||
-_tla_archives () { _arch_archives tla "$@" }
-
-(( $+functions[_tla_categories] )) ||
-_tla_categories () { _arch_namespace tla 1 "$argv[@]" }
-
-(( $+functions[_tla_branches] )) ||
-_tla_branches () {_arch_namespace tla 2 "$argv[@]" }
-
-(( $+functions[_tla_versions] )) ||
-_tla_versions () { _arch_namespace tla 3 "$argv[@]" }
-
-(( $+functions[_tla_revisions] )) ||
-_tla_revisions () { _arch_namespace tla 4 "$argv[@]" }
-
-(( $+functions[_tla_local_revisions] )) ||
-_tla_local_revisions () {
- local expl1 expl2 tree_version=`$TLA tree-version`
- _description -V applied-patches expl1 "patch from this version"
- _description -V other-patches expl2 "patch from other versions"
- compadd "$expl1[@]" `$TLA logs`
- compadd "$expl2[@]" `$TLA logs --full $($TLA log-versions | grep -v $tree_version)`
- # This is incredibly slow.
- # Should complete based on -A, -R, -d
-}
-
-(( $+functions[_tla_config] )) ||
-_tla_config () {
-
- # zsh 4.1.1+ is recommended; 4.0.6 gives the error below when doing
- # tla build-config e<TAB>
- # _path_files:322: no matches found: configs//e/.(/)
- # whereas 4.1.1 completes correctly
-
- local configdir root ret=1 n expl
-
- n=$opt_args[(i)(-d|--dir)]
- [[ -n "$n" ]] && configdir=$opt_args[$n]
- root="$(_call_program tla $TLA tree-root ${configdir} 2>&1)"
- if (( $? )); then
- _message -e messages "Error: $root"
- return $ret
- fi
-
- if [[ -d "$root/configs" ]]; then
- configdir=("$root/configs")
- _description files expl 'config file'
- _files -W configdir "$expl[@]" && ret=0
- else
- _message -e messages "No configs/ directory in tree whose root is $root"
- fi
- return $ret
-}
-
-(( $+functions[_tla_limit] )) ||
-_tla_limit () { #presently only does push-mirror style limits
- [[ $words[$CURRENT] == *@* ]] && return 1
-
- local expl archive
- archive=${words[(r)*@*]:-$($TLA my-default-archive 2> /dev/null)}
- if [ $archive ]; then
-
- if [[ $PREFIX != *--* ]]; then
- _description -V categories expl "category in $archive"
- compadd -q -S -- "$expl[@]" `$TLA categories -A $archive`
- else
- _tla_namespace_branches 3
- fi
- fi
-}
-
-(( $+functions[_tla_tree_or_rev] )) ||
-_tla_tree_or_rev () {
- _alternative 'trees:tree:_files -/' 'revisions:revision:_tla_revisions'
-}
-
-(( $+functions[_tla_libraries] )) ||
-_tla_libraries () {
- local libraries expl
- libraries=($(_call_program tla $TLA my-revision-library))
- _description -V libraries expl "revision library"
- compadd "$expl[@]" -a libraries
-}
-
-(( $+functions[_tla_my_revision_library] )) ||
-_tla_my_revision_library () {
- if [[ -n $words[(r)-d] ]] || [[ -n $words[(r)--delete] ]]; then
- _tla_libraries
- else
- _files -/
- fi
-}
-
-(( $+functions[_tla_log_versions] )) ||
-_tla_log_versions () {
- local logs expl
- if is-at-least 1.1 $tla_version; then
- logs=($(_call_program tla $TLA log-versions))
- else
- logs=($(_call_program tla $TLA logs))
- fi
- _description -V versions expl "log version"
- compadd "$expl[@]" -a logs
-}
-
-# command argument definitions
-# commands with different versions
-
-local cmd_register_archive cmd_archives cmd_ls_archives cmd_redo
-local cmd_redo_changes cmd_changes cmd_what_changed cmd_categories
-local cmd_branches cmd_versions cmd_cacherev cmd_logs cmd_log_versions
-local cmd_log_ls cmd_update cmd_join_branch cmd_replay cmd_deltapatch
-local cmd_delta_patch cmd_apply_delta cmd_sync_tree cmd_make_sync_tree
-local cmd_delta cmd_revdelta cmd_library_categories cmd_library_branches
-local cmd_library_versions cmd_library_revisions
-local cmd_archive_register
-
-cmd_log_ls=('*:version:_tla_log_versions')
-cmd_log_versions=()
-# the options should only complete items that are in the tree
-
-if is-at-least 1.1 $tla_version; then
- cmd_register_archive=('::archive:_tla_archives' ':location:_files -/')
- cmd_archive_register=($cmd_register_archive)
- cmd_archives=('::regex:')
- cmd_redo=('::changeset:_files -/')
- cmd_changes=('::revision:_tla_revisions'
- # ':separator:(--)' '*::limit:_files'
- #don't understand the limit usage
- )
- cmd_categories=('::archive:_tla_archives')
- cmd_branches=('::category:_tla_categories')
- cmd_versions=('::branch:_tla_branches')
- cmd_cacherev=('::revision:_tla_revisions')
- #should only complete non-cached revisions
-
- cmd_logs=($cmd_log_ls)
- cmd_update=('::revision:_tla_revisions')
- cmd_join_branch=(':revision:_tla_revisions')
- #should only complete continuation revisions
-
- cmd_replay=('*::revision:_tla_revisions')
- cmd_deltapatch=(':FROM:_tla_tree_or_rev' ':TO:_tla_tree_or_rev')
- cmd_sync_tree=(':revision:_tla_revisions')
- cmd_delta=(':FROM:_tla_tree_or_rev' ':TO:_tla_tree_or_rev' '::DEST:_files -/')
- cmd_library_categories=('::archive:_tla_archives --library')
- cmd_library_branches=('::category:_tla_categories --library')
- cmd_library_versions=('::branch:_tla_branches --library')
- cmd_library_revisions=('::version:_tla_versions --library')
-else
- cmd_register_archive=(':archive:_tla_archives' ':location:_files -/')
- cmd_archives=()
- cmd_redo=()
- cmd_changes=('::revision:_tla_revisions')
- cmd_categories=()
- cmd_branches=(':category:_tla_categories')
- cmd_versions=(':branch:_tla_branches')
- cmd_cacherev=(':revision:_tla_revisions' '::dir:_files -/')
- cmd_logs=($cmd_log_versions)
- cmd_update=(':dir:_files -/' '::newdir:_files -/'
- '::revision:_tla_revisions')
- cmd_join_branch=(':dir:_files -/' '::newdir:_files -/'
- ':revision:_tla_revisions')
- cmd_replay=(':dir:_files -/' '::newdir:_files -/' '::revision:_tla_revisions')
- cmd_deltapatch=(':FROM:_tla_tree_or_rev' ':TO:_tla_tree_or_rev'
- ':UPON:_tla_tree_or_rev' '::DEST:_files -/')
- cmd_sync_tree=(':dir:_files -/' '::newdir:_files -/'
- ':revision:_tla_revisions')
- cmd_delta=(':FROM:_tla_tree_or_rev' ':TO:_tla_tree_or_rev')
- cmd_library_categories=()
- cmd_library_branches=(':category:_tla_categories --library')
- cmd_library_versions=(':branch:_tla_branches --library')
- cmd_library_revisions=(':version:_tla_versions --library')
-fi
-
-cmd_ls_archives=($cmd_archives)
-cmd_redo_changes=($cmd_redo)
-cmd_what_changed=($cmd_changes)
-cmd_delta_patch=($cmd_deltapatch)
-cmd_apply_delta=($cmd_deltapatch)
-cmd_make_sync_tree=($cmd_sync_tree)
-cmd_revdelta=($cmd_delta)
-
-# commands the same in all versions
-
-local cmd_help
-cmd_help=()
-
-local cmd_my_id
-cmd_my_id=('::id-string:')
-
-local cmd_my_default_archive
-cmd_my_default_archive=('::archive:_tla_archives')
-
-local cmd_whereis_archive
-cmd_whereis_archive=(':archive:_tla_archives')
-
-local cmd_init_tree
-cmd_init_tree=('::version:_tla_versions')
-
-local cmd_tree_root
-cmd_tree_root=('::directory:_files -/')
-
-local cmd_tree_version
-cmd_tree_version=('::directory:_files -/')
-
-local cmd_set_tree_version
-cmd_set_tree_version=(':version:_tla_versions')
-
-local cmd_build_config cmd_buildcfg
-cmd_build_config=(':config:_tla_config')
-cmd_buildcfg=($cmd_build_config)
-
-local cmd_cat_config cmd_catcfg cmd_cfgcat
-cmd_cat_config=(':config:_tla_config')
-cmd_catcfg=($cmd_cat_config)
-cmd_cfgcat=($cmd_cat_config)
-
-local cmd_undo cmd_undo_changes
-cmd_undo=('::revision:_tla_revisions')
-cmd_undo_changes=($cmd_undo)
-
-local cmd_file_diffs
-cmd_file_diffs=(':file:_files' '::revision:_tla_revisions')
-
-local cmd_file_find
-cmd_file_find=(':file:_files' '::revision:_tla_revisions')
-
-local cmd_inventory cmd_srcfind
-cmd_inventory=('::separator:(--)' '*:directory:_files -/')
-cmd_srcfind=($cmd_inventory)
-
-local cmd_tree_lint cmd_lint
-cmd_tree_lint=('::directory:_files -/')
-cmd_lint=($cmd_tree_lint)
-
-local cmd_id cmd_invtag
-cmd_id=('*:file:_files')
-cmd_invtag=($cmd_id)
-
-local cmd_id_tagging_method cmd_tagging_method methods
-cmd_id_tagging_method=('::tagging method:(($methods))')
-methods=(
- 'names:use naming conventions only'
- 'implicit:use naming conventions but permit for inventory tags'
- 'tagline:use naming conventions but permit for inventory tags'
- 'explicit:require explicit designation of source'
-)
-cmd_tagging_method=($cmd_id_tagging_method)
-
-local cmd_add cmd_add_id cmd_add_tag
-cmd_add=('*:file to add:_files')
-cmd_add_id=($cmd_add)
-cmd_add_tag=($cmd_add)
-
-local cmd_delete cmd_delete_id cmd_delete_tag
-cmd_delete=('*:file to delete:_files')
-cmd_delete_id=($cmd_delete)
-cmd_delete_tag=($cmd_delete)
-
-local cmd_move cmd_move_id cmd_move_tag
-cmd_move_id=(':old name:_files' ':new name:_files')
-cmd_move_id=($cmd_move)
-cmd_move_tag=($cmd_move)
-#would be nice not to offer dirs for newname if oldname is a file, and
-#vice versa
-
-local cmd_mv
-cmd_mv=('*:file:_files')
-# not really right, but close enough
-
-local cmd_default_id cmd_explicit_default cmd_default_tag
-cmd_default_id=('::TAG-PREFIX:')
-cmd_explicit_default=($cmd_default_id)
-cmd_default_tag=($cmd_default_id)
-
-local cmd_tagging_defaults cmd_id_tagging_defaults
-cmd_tagging_defaults=()
-cmd_id_tagging_defaults=($cmd_tagging_defaults)
-
-local cmd_changeset cmd_mkpatch
-cmd_changeset=(
- ':ORIG:_files -/'
- ':MOD:_files -/'
- ':DEST:_files -/'
- '*:file:_files'
-)
-cmd_mkpatch=("$cmd_changeset[@]")
-
-local cmd_dopatch cmd_do_changeset cmd_apply_changeset
-cmd_dopatch=(':changeset:_files -/' ':target:_files -/')
-cmd_do_changeset=($cmd_dopatch)
-cmd_apply_changeset=($cmd_dopatch)
-
-local cmd_show_changeset
-cmd_show_changeset=('::changeset:_files -/')
-
-local cmd_make_archive
-cmd_make_archive=('::name:' ':location:_files -/')
-
-local cmd_archive_setup
-cmd_archive_setup=('*:version:_tla_branches --trailing-dashes')
-
-local cmd_make_category
-cmd_make_category=(':category:_tla_archives -S /')
-
-local cmd_make_branch
-cmd_make_branch=(':branch:_tla_categories --trailing-dashes')
-
-local cmd_make_version
-cmd_make_version=(':version:_tla_branches --trailing-dashes')
-
-local cmd_import cmd_imprev
-cmd_import=('::version:_tla_versions')
-cmd_imprev=($cmd_import)
-
-local cmd_commit cmd_cmtrev
-cmd_commit=('::version:_tla_versions' ':separator:(--)' '*:file:_files')
-cmd_cmtrev=($cmd_commit)
-
-local cmd_get cmd_getrev
-cmd_get=(':revision:_tla_revisions' '::directory:_files -/')
-cmd_getrev=($cmd_get)
-
-local cmd_get_patch cmd_get_changeset
-cmd_get_patch=(':revision:_tla_revisions' '::dir:_files -/')
-cmd_get_changeset=($cmd_get_patch)
-
-local cmd_lock_revision
-cmd_lock_revision=(':revision:_tla_revisions')
-
-local cmd_push_mirror cmd_archive_mirror
-cmd_push_mirror=(
- '::FROM or MINE:_tla_archives'
- '::TO:_tla_archives'
- '::LIMIT:_tla_limit'
-)
-cmd_archive_mirror=($cmd_push_mirror)
-
-local cmd_revisions
-cmd_revisions=('::version:_tla_versions')
-
-local cmd_ancestry
-cmd_ancestry=('::revision:_tla_revisions')
-
-local cmd_ancestry_graph
-cmd_ancestry_graph=('::revision:_tla_revisions')
-
-local cmd_cat_archive_log
-cmd_cat_archive_log=(':revision:_tla_revisions')
-
-local cmd_cachedrevs
-cmd_cachedrevs=(':version:_tla_versions')
-
-local cmd_uncacherev
-cmd_uncacherev=(':revision:_tla_revisions' '::dir:_files -/')
-
-local cmd_archive_meta_info
-cmd_archive_meta_info=(':item-name:((name\:foo mirror\:bar))')
-
-local cmd_archive_snapshot
-cmd_archive_snapshot=(':dir:_files -/' '::limit:_tla_revisions')
-
-local cmd_archive_version
-cmd_archive_version=()
-
-local cmd_archive_fixup
-cmd_archive_fixup=()
-
-local cmd_make_log
-cmd_make_log=('::version:_tla_versions')
-
-local cmd_add_log cmd_add_log_version
-cmd_add_log=(':version:_tla_versions')
-cmd_add_log_version=($cmd_add_log)
-
-local cmd_remove_log cmd_remove_log_version
-cmd_remove_log=(':version:_tla_log_versions')
-cmd_remove_log_version=($cmd_remove_log)
-
-local cmd_abrowse
-cmd_abrowse=('::LIMIT:_tla_revisions')
-
-local cmd_cat_log
-cmd_cat_log=(':revision-spec:_tla_local_revisions')
-
-local cmd_changelog
-cmd_changelog=('::version:_tla_versions')
-
-local cmd_log_for_merge
-cmd_log_for_merge=('::version:_tla_versions')
-
-local cmd_merges
-cmd_merges=(':INTO:_tla_revisions' '::FROM:_tla_revisions')
-
-local cmd_new_merges
-cmd_new_merges=('::version:_tla_versions')
-
-local cmd_tag cmd_tagrev cmd_branch
-cmd_tag=(':SOURCE-REVISION:_tla_revisions' ':TAG-VERSION:_tla_versions')
-cmd_tagrev=($cmd_tag)
-cmd_branch=($cmd_tag)
-
-local cmd_star_merge
-cmd_star_merge=(':FROM:_tla_revisions')
-
-local cmd_missing cmd_whats_missing
-cmd_missing=('::revision:_tla_revisions')
-cmd_whats_missing=($cmd_missing)
-
-local cmd_pristines cmd_ls_pristines
-cmd_pristines=('::limit:_tla_revisions')
-cmd_ls_pristines=($cmd_pristines)
-
-local cmd_lock_pristine
-cmd_lock_pristine=(':revision:_tla_revisions')
-
-local cmd_add_pristine
-cmd_add_pristine=(':revision:_tla_revisions')
-
-local cmd_find_pristine
-cmd_find_pristine=(':revision:_tla_revisions')
-
-local cmd_my_revision_library cmd_library_dir
-cmd_my_revision_library=(':library:_tla_my_revision_library')
-cmd_library_dir=($my_revision_library)
-
-local cmd_library_find
-cmd_library_find=(':revision:_tla_revisions --library')
-
-local cmd_library_add
-cmd_library_add=(':revision:_tla_revisions --exclude-library-revisions')
-
-local cmd_library_remove
-cmd_library_remove=(':revision:_tla_revisions --library')
-
-local cmd_library_archives
-cmd_library_archives=()
-
-local cmd_library_log
-cmd_library_log=(':revision:_tla_revisions --library')
-
-local cmd_library_file
-cmd_library_file=(':file:_files' ':revision:_tla_revisions --library')
-
-local cmd_grab
-cmd_grab=(':location:_files')
-
-local cmd_parse_package_name
-cmd_parse_package_name=(':name:')
-
-local cmd_valid_package_name
-cmd_valid_package_name=(':name:')
-
-local cmd_library_config
-cmd_library_config=(':library:_tla_libraries')
-
-local cmd_rbrowse
-cmd_rbrowse=('::regular expression:')
-
-local cmd_rm
-cmd_rm=('*:file:_files')
-
-local cmd_escape
-cmd_escape=(':string:')
-
-local cmd_diff
-cmd_diff=('::revision:_tla_revisions')
-
-local cmd_export
-cmd_export=(':revision:_tla_revisions' ':dir:_files -/')
-
-#mutually exclusive options
-
-local -A excludes
-excludes=(
-# This first line means that if --output was given, don't complete
-# --no-output or --keep. The converse is not true.
---output '--no-output --keep'
---no-output --output
-
---silent ' --quiet --report --verbose --debug'
---quiet '--silent --report --verbose --debug'
---report '--silent --quiet --verbose --debug'
---verbose '--silent --quiet --report --debug'
---debug '--silent --quiet --report --verbose '
-
---sparse --non-sparse
---non-sparse --sparse
-
---files ' --directories --both'
---directories '--files --both'
---both '--files --directories '
-
---mirror --mirror-from
---mirror-from --mirror
-
---no-cached --cached-tags
---cached-tags --no-cached
-
---non-greedy --greedy
---greedy --non-greedy
-)
-
-_tla_main () {
- typeset -A opt_args
- local arguments
- if (( CURRENT > 2 )); then
- local cmd=${words[2]}
- local var_cmd=cmd_${cmd//-/_}
- curcontext="${curcontext%:*:*}:tla-$cmd:"
- (( CURRENT-- ))
- shift words
-
- arguments=()
- local input
- input=(${${(M)${(f)"$($TLA $cmd -h)"}:# *}# })
-
- local i j=1
- local short long arg desc action
- short=()
- long=()
- arg=()
- desc=()
- action=()
- for (( i=1 ; i <= ${#input} ; i++ )); do
- [[ "$input[i]" != *[^\ ]* ]] && continue # stupid blank lines
- short[j]="${${${input[i]}[1,2]}#--}"
- long[j]="${${input[i]#-?, }%% *}"
-
- arg[j]="${${${input[i]%% *}##* }##-*}"
- [[ $long[j] == --archive ]] && arg[j]=ARCHIVE # tla doesn't mention this
-
- desc[j]="${input[i]##* }"
- if [[ "$input[i+1]" == \ *[^\ ]* ]]; then # description continues
- (( i++ ))
- desc[j]="$desc[j] ${input[i]##* }"
- fi
- [[ "$short[j]" == -[hHV] ]] && continue
- desc[j]="${${desc[j]//\[/\\[}//\]/\\]}" # escape brackets
-
- case $arg[j] in
- DIR|PATCH-DIR|DEST|OUTPUT|PATH)
- action[j]='_files -/' ;;
- FILES|FILE|SNAP-FILE)
- action[j]='_files' ;;
- MASTER|MASTER-SOURCE|ARCHIVE)
- action[j]='_tla_archives' ;;
- CATEGORY)
- action[j]='_tla_categories' ;;
- BRANCH)
- action[j]='_tla_branches' ;;
- VERSION)
- action[j]='_tla_versions' ;;
- CFG)
- action[j]='_tla_configs' ;;
- LIB)
- action[j]='_tla_libraries' ;;
-# PATCH,FILE) # not sure how to complete this
-# action[j]='_tla_patch_file' ;;
- *)
- action[j]='' ;;
- esac
-
- (( j++ ))
-
- done
-
- local excluded k
- for (( i = 1 ; i < j ; i++ )); do
- excluded=($short[i] $long[i])
- foreach opt (${=excludes[$long[i]]})
- k=$long[(i)$opt]
- excluded=($excluded $short[k] $long[k])
- #excludes matching short options too :-)
- end
-
-
- # generate arguments to _arguments ;-)
- # make long and short options mutually exclusive
- [ $short[i] ] && arguments=("$arguments[@]"
- "${hide_short}(${excluded})${short[i]}[${desc[i]}]${arg[i]:+:$arg[i]:$action[i]}")
- [ $long[i] ] && arguments=("$arguments[@]"
- "(${excluded})${long[i]}[${desc[i]}]${arg[i]:+:$arg[i]:$action[i]}")
- done
-
- arguments=("$arguments[@]" "${(@P)var_cmd-*:FILE:_files}")
- else
- local help
- local -U cmds
- help=(${(f)"$($TLA help)"})
- cmds=(${${${${(M)help:#* :*}/ #: #/:}%% ##}## #})
- arguments=(':command:(($cmds))')
- fi
- _arguments -S -A '-*' \
- {"${hide_short}(: -)-V",'(: -)--version'}'[display version]' \
- {"${hide_short}(: -)-h",'(: -)--help'}'[display help]' \
- '(: -)-H[display verbose help]' \
- "$arguments[@]"
-}
-
-_tla_main "$@"
diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux
index b9c220f17..80c69d2fb 100644
--- a/Completion/Unix/Command/_tmux
+++ b/Completion/Unix/Command/_tmux
@@ -567,7 +567,7 @@ _tmux-list-windows() {
[[ -n ${tmux_describe} ]] && print "list windows of a session" && return
_arguments -s \
'-a[list all windows the tmux server possesses]' \
- '-F[specify output format]:format:__tmux-formats' \
+ '-F+[specify output format]:format:__tmux-formats' \
'-f+[filter items]:filter format:__tmux-formats' \
'-t+[specify session]:session:__tmux-sessions'
}
@@ -764,7 +764,7 @@ _tmux-respawn-pane() {
'-c+[specify a new working directory for the pane]:directory:_directories' \
'*-e[specify environment variable]:environment variable:_parameters -g "*export*" -qS=' \
'-k[kill window if it is in use]' \
- '-t+[specify target pane]:pane:__tmux-pane' \
+ '-t+[specify target pane]:pane:__tmux-panes' \
':command:_cmdambivalent'
}
@@ -886,7 +886,7 @@ _tmux-server-access() {
}
_tmux-set-buffer() {
- [[ -n ${tmux_describe} ]] && print "set contents of a paster buffer" && return
+ [[ -n ${tmux_describe} ]] && print "set contents of a paste buffer" && return
_arguments -s -A "-*" -S \
'-a[append to rather than overwriting target buffer]' \
'-b+[specify target buffer index]:pane:__tmux-buffers' \
@@ -999,7 +999,7 @@ _tmux-show-hooks() {
_tmux-show-buffer() {
[[ -n ${tmux_describe} ]] && print "display the contents of a paste buffer" && return
- _arguments '-b[specify target buffer index]:pane:->buffer'
+ _arguments '-b[specify target buffer index]:buffer:__tmux-buffers'
}
_tmux-show-environment() {
@@ -1648,16 +1648,22 @@ function __tmux-session-options() {
'display-panes-active-colour:colour for active pane in display-panes'
'display-panes-time:time (in msecs) of display-panes output'
'display-time:time (in msecs) messages are displayed'
+ 'focus-follows-mouse:select panes when the mouse enters them'
'history-limit:number of copy-mode lines per window'
+ 'initial-repeat-time:initial repeat-key timeout'
'key-table:default key table'
'lock-after-time:lock sessions after N seconds'
'lock-command:command to run for locking a client'
'message-command-style:status line message command style'
+ 'message-format:prompt and message area format'
'message-line:status message and command prompt position'
'message-style:status line message style'
'mouse:enable mouse support'
'prefix:primary prefix key'
'prefix2:secondary prefix key'
+ 'prompt-command-cursor-style:cursor style in vi prompt command mode'
+ 'prompt-cursor-colour:prompt cursor colour'
+ 'prompt-cursor-style:prompt cursor style'
'renumber-windows:renumber windows if a window is closed'
'repeat-time:time for multiple commands without prefix-key presses'
'set-titles:try to set xterm window titles'
@@ -1729,22 +1735,29 @@ function __tmux-server-options() {
tmux_server_options=(
'backspace:set key sent by tmux for backspace'
'buffer-limit:number of buffers kept per session'
+ 'codepoint-widths:list of override widths for Unicode codepoints'
'command-alias:custom command aliases'
'copy-command:specify the default command when "copy-pipe" is called without arguments'
+ 'default-client-command:default tmux command with no subcommand'
'default-terminal:default terminal definition string'
'escape-time:set timeout to detect single escape characters (in msecs)'
'editor:specify the command used when tmux runs an editor'
'exit-unattached:make server exit if it has no attached clients'
'exit-empty:exit when there are no active sessions'
'extended-keys:control whether tmux will send extended keys through to the terminal'
+ 'extended-keys-format:extended-key output format'
'focus-events:request focus events from terminal'
+ 'get-clipboard:how tmux answers clipboard requests'
'history-file:tmux command history file name'
+ 'input-buffer-size:input bytes allowed before dropping'
'message-limit:set size of message log per client'
+ 'prefix-timeout:prefix-key timeout'
'prompt-history-limit:set the number of history items to save in the history file'
'set-clipboard:use esc sequences to set terminal clipboard'
'terminal-features:set terminal features not detected by terminfo'
'terminal-overrides:override terminal descriptions'
'user-keys:set list of user-defined key escape sequences'
+ 'variation-selector-always-wide:treat Unicode VS16 as always wide'
)
_describe -t tmux-server-options 'tmux server option' tmux_server_options
}
@@ -1800,6 +1813,7 @@ function __tmux-window-options() {
'aggressive-resize:aggressively resize windows'
'allow-passthrough:allow programs in the pane to bypass tmux'
'allow-rename:allow programs to change window titles'
+ 'allow-set-title:allow apps to set pane titles'
'alternate-screen:allow alternate screen feature to be used'
'automatic-rename-format:format for automatic renames'
'automatic-rename:attempt to automatically rename windows'
@@ -1808,6 +1822,9 @@ function __tmux-window-options() {
'copy-mode-current-match-style:set the style of the current search match in copy mode'
'copy-mode-mark-style:set the style of the line containing the mark in copy mode'
'copy-mode-match-style:set the style of search matches in copy mode'
+ 'copy-mode-position-format:format for the position indicator in copy mode'
+ 'copy-mode-position-style:style for position indicator in copy mode'
+ 'copy-mode-selection-style:style for selection in copy mode'
'cursor-colour:set the colour of the cursor'
'cursor-style:set the style of the cursor'
'fill-character:set the character used to fill unused window areas'
@@ -1832,13 +1849,21 @@ function __tmux-window-options() {
'pane-border-status:turn border status off or set its position'
'pane-border-style:style of border pane'
"pane-colours:an array used to configure tmux's colour palette"
+ 'pane-scrollbars:pane scrollbar visibility mode'
+ 'pane-scrollbars-position:side used for pane scrollbars'
+ 'pane-scrollbars-style:pane scrollbar style'
+ 'pane-status-current-style:current pane status-line style'
+ 'pane-status-style:pane status-line style'
'popup-border-lines:set the type of line used to draw popup borders'
"popup-border-style:set the style for the popup's border"
'popup-style:set the popup style'
"remain-on-exit:don't destroy windows after the program exits"
"remain-on-exit-format:set the text shown at bottom of exited panes"
'scroll-on-clear:scroll previous contents into history before clear'
+ 'session-status-current-style:current session status-line style'
+ 'session-status-style:session status-line style'
'synchronize-panes:send input to all panes of a window'
+ 'tiled-layout-max-columns:column limit for the tiled layout'
'window-active-style:style of active window'
'window-size:indicate how to automatically size windows'
'window-status-activity-style:style of status bar activity tag'
diff --git a/Completion/Unix/Command/_totd b/Completion/Unix/Command/_totd
deleted file mode 100644
index 4d55d29bb..000000000
--- a/Completion/Unix/Command/_totd
+++ /dev/null
@@ -1,13 +0,0 @@
-#compdef totdconfig
-
-_arguments \
- - set1 \
- '-a[add totd specific options]' \
- '-D[add totd specific config into dhclient-enter-hooks]' \
- '-d:name server:_hosts' \
- '-l[configure resolv.conf]' \
- - set2 \
- '-r:config to remove:(dhcp totd resolv all)' \
- - set3 \
- '-h[help]'
-
diff --git a/Completion/Unix/Command/_tree b/Completion/Unix/Command/_tree
index 595249126..fdb22a9c9 100644
--- a/Completion/Unix/Command/_tree
+++ b/Completion/Unix/Command/_tree
@@ -1,22 +1,29 @@
#compdef tree
+# tree has its own weird option-parsing method that requires arguments to short
+# options to appear in the next word... except for -L (as of 2.2.1)
_arguments -s -S \
'-a[show all files, including hidden ones]' \
'-d[list directories only]' \
'-l[follow symlinks that point to directories]' \
'-f[print full path prefix for each file]' \
'-x[stay on current filesystem]' \
- '-L[specify max tree depth to descend]:level' \
+ '-L+[specify max tree depth to descend]: :_numbers -l1 depth' \
'-R[recursively cross down the tree and execute tree again]' \
- '-P[only list files matching a pattern]:pattern:_files' \
- "-I[don't list files matching a pattern]:pattern:_files" \
+ '-P[only list files matching specified pattern]:pattern:_files' \
+ "-I[don't list files matching specified pattern]:pattern:_files" \
+ '--gitignore[respect .gitignore files for filtering]' \
+ '*--gitfile=[use specified file as gitignore file]:gitignore file:_files' \
'--ignore-case[ignore case when pattern matching]' \
'--matchdirs[include directory names in -P pattern matching]' \
+ '--metafirst[print file meta-data at beginning of line]' \
+ '--info[print file comments found in .info files]' \
+ '*--infofile=[use specified file as info file]:info file:_files' \
'--noreport[omit file and directory report at end]' \
- '--charset=[character set for HTML and for line drawing]:charset' \
- "--filelimit=[don't descend directories with more than specified number of entries]:entries" \
- '--timefmt=[use specified time format]:format:_date_formats' \
- '-o[output to specified file]:file:_files' \
+ '--charset=[specify character set for HTML and line drawing]:charset' \
+ "--filelimit=[don't descend directories with more than specified number of entries]: :_numbers entries" \
+ '--timefmt=[use specified time format]: :_date_formats' \
+ '-o[output to specified file]: :_files' \
'--du[print directory sizes]' \
'--prune[exclude empty directories from the output]' \
'(-N)-q[print non-printable characters as question mark, not caret]' \
@@ -32,24 +39,33 @@ _arguments -s -S \
'-F[append descriptive character to end, like ls -F]' \
'--inodes[print inode numbers]' \
'--device[print device number to which file or directory belongs]' \
- '(--sort -t -c -U)-v[sort the output as version]' \
+ '(--sort -t -c -U)-v[sort output as version]' \
'(-v --sort -c -U)-t[sort output by modification time]' \
'(-v --sort -t -U)-c[sort output by change time]' \
'(-v --sort -t -c -r --dirsfirst)-U[leave files unsorted]' \
'(-U)-r[sort in reversed order]' \
- '(-v -t -c -U)--sort[sort in specified order]:order:(name version size mtime ctime)' \
- '(-U)--dirsfirst[list directories before files]' \
+ '(-v -t -c -U)--sort=[sort in specified order]:order:(name version size mtime ctime none)' \
+ '(-U --filesfirst)--dirsfirst[list directories before files]' \
+ '(-U --dirsfirst)--filesfirst[list files before directories]' \
"-i[don't print indentation lines]" \
- '(-S -X)-A[use ANSI line graphics hack when printing indentation lines]' \
- '(-A -X)-S[use console (CP437) line graphics]' \
- '(-C)-n[turn colorization off always, over-ridden by the -C option]' \
+ '(-S -H -J -X)-A[use ANSI line graphics hack when printing indentation lines]' \
+ '(-A)-S[equivalent to --charset=IBM437]' \
+ '(-C)-n[turn colorization off always]' \
'(-n)-C[turn colorization on always]' \
- '(-A -S -n -C -J -H -T --nolinks)-X[XML output]' \
- '(-A -S -n -C -X -H -T --nolinks)-J[JSON output]' \
- '(-n -C -X)-H[turn on HTML output]:base HREF' \
- '(-n -C -X)-T[title for HTML output]:title' \
- '(-n -C -X)--nolinks[turn off hyperlinks in HTML output]' \
- '--fromfile[read paths from specified files]' \
- '(-)--version[version of tree]' \
- '(-)--help[verbose usage listing]' \
- '*:directory:_files -/'
+ '(-A -J -H -T --nolinks)-X[turn on XML output]' \
+ '(-A -X -H -T --nolinks)-J[turn on JSON output]' \
+ '(-A -J -X)-H[turn on HTML output]:base HREF' \
+ '(-A -J -X)--hintro=[use specified file as HTML intro]:HTML intro file:_files' \
+ '(-A -J -X)--houtro=[use specified file as HTML outro]:HTML outro file:_files' \
+ '(-A -J -X)-T[specify title for HTML output]:title' \
+ '(-A -J -X --hyperlink)--nolinks[turn off hyperlinks in HTML output]' \
+ '(-H -J -X --nolinks)--hyperlink[turn on OSC 8 hyperlinks]' \
+ '(-H -J -X --nolinks)--scheme=[specify schema used for OSC 8 hyperlinks]:schema [file\://]' \
+ '(-H -J -X --nolinks)--authority=[specify authority (host name) used for OSC 8 hyperlinks]: :_hosts' \
+ '(--fromtabfile)--fromfile[read paths from specified files]:paths file:_files' \
+ '(--fromfile)--fromtabfile[read tab-indented paths from specified files]:paths file:_files' \
+ '--fflinks[process symbolic link information with in files (with --from*file)]' \
+ '--opt-toggle[turn on option toggling]' \
+ '(- :)--version[display version information]' \
+ '(- :)--help[display help information]' \
+ '*: :_directories'
diff --git a/Completion/Unix/Command/_twidge b/Completion/Unix/Command/_twidge
deleted file mode 100644
index d8b3b3def..000000000
--- a/Completion/Unix/Command/_twidge
+++ /dev/null
@@ -1,77 +0,0 @@
-#compdef twidge
-## completion for twidge 1.0.8, based on twidge(1)
-
-function _twidge_command {
- typeset -a twidge_commands
- typeset -i skip=1
-
- twidge lscommands | while read cmd desc; do
- if [[ $cmd == ---* ]] {
- skip=0
- continue
- }
- if (( skip )) {
- continue
- }
- twidge_commands+="${cmd}:${desc}"
- done
-
- _describe command twidge_commands
-}
-
-function _twidge_args {
- typeset -a args_common args_more args_other args_update
-
- args_common=(
- '(-a --all)'{-a,--all}'[receive all content]'
- '(-e --exec)'{-e,--exec}'[execute command for each retrieved item]:command'
- '(-l --long)'{-l,--long}'[long output format]'
- '(-m --mailto)'{-m,--mailto}'[mail retrieved items]:mail address'
- )
-
- args_more=(
- '(-s --saveid)'{-s,--saveid}'[save ID of most recent message]'
- '(-u --unseen)'{-u,--unseen}'[only show unseen messages]'
- )
-
- args_other=(
- '(-U --username)'{-U,--username}'[show updates of different user]:username'
- )
-
- args_update=(
- '(-i --inreplyto)'{-i,--inreplyto}'[update in reply to a message]:message id'
- '(-i --inreplyto 1)-r[read RFC2822 Mail]'
- ':status'
- )
-
- case ${words[1]} in
- lsarchive)
- _arguments $args_common $args_more $args_other
- ;;
- ls(dm(|archive)|recent|replies|rt(|archive|replies)))
- _arguments $args_common $args_more
- ;;
- lsfollow(ers|ing))
- _arguments $args_common :username
- ;;
- dmsend)
- _arguments :recipient :status
- ;;
- (un|)follow)
- _message username
- ;;
- update)
- _arguments $args_update
- ;;
- esac
-}
-
-function _twidge {
- _arguments \
- '(-c --config)'{-c,--config}'[config file]:file:_files' \
- '(-d --debug)'{-d,--debug}'[enable debugging output]' \
- '(-): :_twidge_command' \
- '(-)*:: :_twidge_args'
-}
-
-_twidge "$@"
diff --git a/Completion/Unix/Command/_w b/Completion/Unix/Command/_w
index 2da57a8f6..b63018024 100644
--- a/Completion/Unix/Command/_w
+++ b/Completion/Unix/Command/_w
@@ -9,6 +9,7 @@ case $OSTYPE in
'(-c --container)'{-c,--container}'[show container uptime]'
'(H -h)--no-header[suppress the heading]'
'(H -i --ip-addr)'{-i,--ip-addr}'[display IP address instead of hostname]'
+ '(H -t --terminal)'{-t,--terminal}'[scan terminal devices to locate user sessions]'
'(H -o --old-style -s --short)'{-o,--old-style}'[old style output format]'
'(H -s --short -o --old-style)'{-s,--short}'[use short output format]'
'(H -u --no-current)'{-u,--no-current}'[ignore the username while figuring out the current process and cpu times]'
@@ -41,12 +42,18 @@ case $OSTYPE in
'-A[sort tty names alphabetically instead of utmp or utmpx order]'
)
;|
- solaris*)
+ aix*|solaris*)
args+=( '!(-s -w -l)'{-l,-w}
'-s[short output form]'
'(-)-u[produce only the heading line]'
)
;|
+ aix*)
+ args+=(
+ "-X[don't truncate user names]"
+ '-@[tag system activity with workload partition name]:wpar'
+ )
+ ;;
esac
_arguments -S -s \
diff --git a/Completion/Unix/Command/_w3m b/Completion/Unix/Command/_w3m
index de425cfb1..65c150590 100644
--- a/Completion/Unix/Command/_w3m
+++ b/Completion/Unix/Command/_w3m
@@ -14,6 +14,8 @@ _arguments -C \
'(-e -s )-j[JIS]' \
'(-v *)-B[load bookmark]' \
'-bookmark[specify bookmark file]:bookmark file:_files' \
+ '-R[restore from session file]' \
+ '-session[specify session file]:session file:_files' \
'-T[specify content-type]:content type:_mime_types' \
'-m[internet message mode]' \
'(-B *)-v[visual startup mode]' \
@@ -36,9 +38,11 @@ _arguments -C \
"-no-proxy[don't use proxy]" \
'(-6)-4[IPv4 only (-o dns_order=4)]' \
'(-4)-6[IPv6 only (-o dns_order=6)]' \
+ '-insecure[use insecure SSL config options]' \
"-no-mouse[don't use mouse]" \
'(-no-cookie)-cookie[use cookie]' \
"(-cookie)-no-cookie[don't use cookie]" \
+ '-cookie-jar[use specified cookie file]:file:_files' \
'(-no-graph)-graph[use DEC special graphics for border of table and menu]' \
'(-graph)-no-graph[use ASCII character for border of table and menu]' \
'-S[squeeze multiple blank lines]' \
@@ -86,13 +90,13 @@ case "$state" in
'history:history:compadd -a w3mhistory' && ret=0
;;
option)
- local -a options
- options=( ${${(M)${(f)"$(_call_program options $words[1] -show-option 2>/dev/null)"}:# -o *}/(#b) -o (*)=[^ ]#[[:blank:]]##(*)/$match[1]:${match[2]:l}} )
+ local -a wopts
+ wopts=( ${${(M)${(f)"$(_call_program options $words[1] -show-option)"}:# -o *}/(#b) -o (*)=[^ ]#[[:blank:]]##(*)/$match[1]:${match[2]:l}} )
if compset -P 1 '*='; then
_message -e values 'value'
else
compset -S '=*' || suf=( -S '=' )
- _describe -t options 'option' options "$suf[@]" && ret=0
+ _describe -t config-options 'option' wopts "$suf[@]" && ret=0
fi
;;
esac
diff --git a/Completion/Unix/Command/_wget b/Completion/Unix/Command/_wget
index acc8d5c6e..4e49193c8 100644
--- a/Completion/Unix/Command/_wget
+++ b/Completion/Unix/Command/_wget
@@ -55,7 +55,7 @@ _arguments -C -s \
'--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]' \
+ '(--password --http-password --ftp-password)--ask-password[prompt for passwords]' \
'--use-askpass=:command:_command_names -e' \
'--no-iri[turn off IRI support]' \
'--local-encoding=[specify local encoding for IRIs]:encoding' \
@@ -105,7 +105,7 @@ _arguments -C -s \
'--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' \
- '--private-key-type=[specify private key type]:key type:key type:(PEM DER)' \
+ '--private-key-type=[specify private key type]:key type:(PEM DER)' \
"--ca-certificate=[specify file with bundle of CA's]:file:_files" \
"--ca-directory=[specify dir where hash list of CA's are stored]:directory:_directories" \
'--crl-file=[specify file with bundle of CRLs]:file:_files' \
diff --git a/Completion/Unix/Command/_xmlsoft b/Completion/Unix/Command/_xmlsoft
index b8cf92700..aefb0e978 100644
--- a/Completion/Unix/Command/_xmlsoft
+++ b/Completion/Unix/Command/_xmlsoft
@@ -37,9 +37,8 @@ case $service in
'--novalid[skip the DTD loading phase]' \
'--nodtdattr[do not default attributes from the DTD]' \
'--noout[do not dump the result]' \
- '--maxdepth[increase the maximum depth]:depth' \
- '--maxvars[increase the maximum variables]:variables' \
- '--maxparserdepth[increase the maximum parser depth]:depth' \
+ '--maxdepth[increase the maximum depth]:depth [3000]' \
+ '--maxvars[increase the maximum variables]:variables [15000]' \
'--huge[relax hardcoded limits of the parser]' \
'--seed-rand[initialise random number generator]:seed' \
'--html[input document is an HTML file]' \
@@ -64,7 +63,6 @@ case $service in
'--version[display the version of the XML library used]' \
'--debug[dump a debug tree of the in-memory document]' \
'--shell[run a navigating shell]' \
- '--debugent[debug the entities defined in the document]' \
'--copy[used to test the internal copy implementation]' \
'--recover[output what was parsable on broken XML documents]' \
'--huge[remove any internal arbitrary parser limits]' \
@@ -75,8 +73,6 @@ case $service in
'--load-trace[print trace of all external entities loaded]' \
'--nonet[refuse to fetch DTDs or entities over network]' \
'--nocompact[do not generate compact text nodes]' \
- '--htmlout[output results as HTML]' \
- '--nowrap[do not put HTML doc wrapper]' \
'--valid[validate the document in addition to std well-formed check]' \
'(--dtdvalid --relaxng --schema)--postvalid[do a posteriori validation, i.e after parsing]' \
'(--postvalid --relaxng --schema --dtdvalidfpi)--dtdvalid[do a posteriori validation against a given DTD]:DTD:_webbrowser' \
@@ -86,17 +82,19 @@ case $service in
'(--noout --output -o)'{--output,-o}'[save to a given file]:output file:_files' \
'--repeat[repeat 100 times, for timing or profiling]' \
'--insert[ad-hoc test for valid insertions]' \
+ '--strict-namespace[return failure if document has namespace errors]' \
'--compress[turn on gzip compression of output]' \
'--html[use the HTML parser]' \
'--xmlout[use the XML serializer when using --html]' \
'--nodefdtd[do not default HTML doctype]' \
'--push[use the push mode of the parser]' \
- '--pushsmall[use the push mode of the parser using tiny increments]' \
'--memory[parse from memory]' \
- '--maxmem[limit memory allocation]:bytes' \
+ '--maxmem[limit memory allocation]:maximum (bytes)' \
'--nowarning[do not emit warnings from parser/validator]' \
'--noblanks[drop (ignorable?) blanks spaces]' \
'--nocdata[replace cdata section with text nodes]' \
+ '--nodict[create document without dictionary]' \
+ '--pedantic[enable additional warnings]' \
'--format[reformat/reindent the input]' \
'--encode[output in the given encoding]:encoding:(${encoding[@]})' \
'--dropdtd[remove the DOCTYPE of the input docs]' \
@@ -124,6 +122,8 @@ case $service in
'--sax[do not build a tree but work just at the SAX level]' \
'--oldxml10[use XML-1.0 parsing rules before the 5th edition]' \
'(--noout)--xpath[evaluate the XPath expression, implies --noout]:XPath expression' \
+ '(--noout)--xpath0[evaluate the XPath expression separating results by NUL, implies --noout]:XPath expression' \
+ '--max-ampl[set maximum amplification factor]:factor [5]' \
'*:XML file:_webbrowser' && return
;;
*XML_CATALOG_FILES*)
diff --git a/Completion/Unix/Command/_xxd b/Completion/Unix/Command/_xxd
index e9015a081..f56590915 100644
--- a/Completion/Unix/Command/_xxd
+++ b/Completion/Unix/Command/_xxd
@@ -22,13 +22,14 @@ local arguments
arguments=(
# output options
- '(-b -bits -i -include -p -postscript -plain -ps -r -revert -u -uppercase)'{-b,-bits}'[output in binary digits, rather than hex]'
- '( -E -EBCDIC -i -include -p -postscript -plain -ps -r -revert )'{-E,-EBCDIC}'[print human-readable part in EBCDIC rather than ASCII]'
- '(-i -include -p -postscript -plain -ps -r -revert)-e[little-endian dump]'
- '(-b -bits -E -EBCDIC -i -include -p -postscript -plain -ps -r -revert )'{-i,-include}'[output in C include file style]'
- '(-b -bits -E -EBCDIC -i -include -p -postscript -plain -ps -C -capitalize )'{-p,-postscript,-plain,-ps}'[read or write a plain hexdump (no line numbers or ASCII rendering)]'
+ '(-b -bits -i -include -t -p -postscript -plain -ps -r -revert -u -uppercase)'{-b,-bits}'[output in binary digits, rather than hex]'
+ '(-E -EBCDIC -i -include -t -p -postscript -plain -ps -r -revert)'{-E,-EBCDIC}'[print human-readable part in EBCDIC rather than ASCII]'
+ '(-i -include -t -p -postscript -plain -ps -r -revert)-e[little-endian dump]'
+ '(-E -EBCDIC -i -include -p -postscript -plain -ps -r -revert)'{-i,-include}'[output in C include file style]'
+ '(-E -EBCDIC -p -postscript -plain -ps -r -revert)-t[append terminating zero to C include output]'
+ '(-b -bits -E -EBCDIC -i -include -t -p -postscript -plain -ps -C -capitalize)'{-p,-postscript,-plain,-ps}'[read or write a plain hexdump (no line numbers or ASCII rendering)]'
- '(-b -bits -E -EBCDIC -i -include -r -revert -u -uppercase)'{-r,-revert}'[reverse mode\: read a hex dump and output binary data]'
+ '(-b -bits -E -EBCDIC -i -include -t -r -revert -u -uppercase)'{-r,-revert}'[reverse mode\: read a hex dump and output binary data]'
'(-b -bits -r -revert -u -uppercase)'{-u,-uppercase}'[output upper-case hex digits]'
'(- :)'{-h,-help}'[display usage message]'
@@ -42,7 +43,7 @@ arguments=(
'(-o -offset)'{-o+,-offset}'[add specified offset to displayed file position]:offset'
'-d[show offset in decimal instead of hex]'
'-R+[colorize the output]:when:(always auto never)'
- '(-s -skip -seek)'{-s+,-skip,-seek}'[specify file offset to dump from]: :_guard "(0x|)[0-9a-fA-F]#" "file offset to dump from (absolute or relative)"'
+ '(-s -skip -seek)'{-s+,-skip,-seek}'[specify file offset to dump from]: :_guard "([+-]|)(0x|)[0-9a-fA-F]#" "file offset to dump from (bytes, absolute or +/- relative)"'
': :_files'
)
diff --git a/Completion/Unix/Command/_xz b/Completion/Unix/Command/_xz
index 6e68e0f69..d441a6545 100644
--- a/Completion/Unix/Command/_xz
+++ b/Completion/Unix/Command/_xz
@@ -18,12 +18,13 @@ case "$service" in
'(I -k --keep)'{-k,--keep}"[keep (don't delete) input files]" \
'(I -f --force)'{-f,--force}'[force overwrite]' \
'(I -c --stdout)'{-c,--stdout}'[write on standard output]' \
+ "(I)--no-sync[don't flush writes before removing input file]" \
'(I)*'{-q,--quiet}'[suppress all warnings]' \
'(I)*'{-v,--verbose}'[verbose mode]' \
'(I * --files --files0)--files=-[read list of files to process from file]::file:_files' \
'(I * --files --files0)--files0=-[read null terminated list of files to process from file]::file:_files' \
'(I -F --format)'{-F+,--format=}'[specify file format]:format:(auto xz lzma lzip raw)' \
- '(I -T --threads)'{-T+,--threads=}'[use specified number of threads]:threads [1]' \
+ '(I -T --threads)'{-T+,--threads=}'[use specified number of threads]:threads [0]' \
'(I -M --memlimit --memory)'{-M+,--memlimit=,--memory=}'[set memory usage limit]: :_numbers -u bytes "memory limit" KiB MiB GiB %\:percentage\ of\ available\ RAM' \
'(I)--no-adjust[give error if settings exceed memory limit]' \
'(I -Q --no-warn)'{-Q,--no-warn}'[make warnings not affect exit status]' \
@@ -49,11 +50,14 @@ case "$service" in
'(* comp decomp level filters common)--info-memory[display amount of RAM and memory usage limits]' \
'(- *)'{-h,--help}'[display help message]' \
'(- *)'{-H,--long-help}'[display the long help (lists also the advanced options)]' \
+ '(- *)--filters-help[display liblzma filter string syntax information]' \
'(* comp decomp level filters common)'{-V,--version}'[display version number]' \
+ '(level)' \
'(I filters decomp)-'{-best,-fast,1,2,3,4,5,6,7,8,9} \
+ filters \
- '(I level decomp --extreme)'--{x86,powerpc,ia64,arm,armthumb,arm64,sparc}=-'[add a branch/call/jump filter]::option:->bcj-options' \
+ '(I level decomp --extreme)'--{x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv}=-'[add a branch/call/jump filter]::option:->bcj-options' \
+ '(I level decomp --extreme)--filters=[set filter chain using liblzma filter string]:filter string' \
+ '!(I level decomp --extreme)--filters'{1..9}'=:filter string' \
'(I level decomp --extreme)'--lzma{1,2}=-'[add lzma filter]::option:->lzma-options' \
'(I level decomp --extreme)--delta=-[add delta filter]::option:->delta-options' && ret=0
;;
diff --git a/Completion/Unix/Command/_zdump b/Completion/Unix/Command/_zdump
index f96bdd764..9e71a5f53 100644
--- a/Completion/Unix/Command/_zdump
+++ b/Completion/Unix/Command/_zdump
@@ -1,6 +1,26 @@
#compdef zdump
-_arguments \
- '-v[lowest possible]' \
- '-c[cutoff]:cutoff year:' \
+local -a args
+
+case $OSTYPE in
+ aix*|(net|free)bsd*|linux*|solaris*)
+ args+=( '(-)--version[display version information]' )
+ ;|
+ aix*|(net|free)bsd*|linux*)
+ args+=( '(-)--help[display usage information]' )
+ ;|
+ (net|free)bsd*|linux*)
+ args+=( '-i[output a description of time intervals]' )
+ ;|
+ aix*|(free|net|open)bsd*|linux*)
+ args+=(
+ '(-c)-t[cut off interval output at the given times]:cut off (seconds since epoch)'
+ '(-v)-V[like -v, but omit times relative to the extreme time values]'
+ )
+ ;|
+esac
+
+_arguments -S $args \
+ '(-V)-v[print time at lowest possible time value]' \
+ '(-t)-c[cut off interval output at the given years]:cutoff years [-500,2500]' \
'*:time zone:_time_zone'
diff --git a/Completion/Unix/Command/_zfs b/Completion/Unix/Command/_zfs
index dd67ea767..412469521 100644
--- a/Completion/Unix/Command/_zfs
+++ b/Completion/Unix/Command/_zfs
@@ -69,6 +69,8 @@ rw_ds_props=(
'compression:value:($comp_algorithms)'
'copies:value:(1 2 3)'
'dedup:value:($dedup_algorithms)'
+ 'defaultuserquota:->quotas'
+ 'defaultgroupquota: :->quotas'
'devices:value:(on off)'
'encryption:value:(off on aes128-ccm aes-192-ccm aes-256-ccm aes-128-gcm aes-192-gcm aes-256-gcm)'
'exec:value:(on off)'
@@ -79,7 +81,7 @@ rw_ds_props=(
'paths:mountpoint:_directories -W / -P /'"
'multilevel:value:(on off)'
'nbmand:value:(on off)'
- {prefetch,primarycache}':value:(all none metadata)'
+ {prefetch,primarycache,secondarycache}':value:(all none metadata)'
'quota: :->quotas'
'readonly:value:(on off)'
'recordsize:value:(512 1K 2K 4K 8K 16K 32K 64K 128K 256K 512K 1M)'
@@ -89,7 +91,6 @@ rw_ds_props=(
'properties:property:(auto none)'"
'reservation: :->quotas'
'rstchown:value:(on off)'
- 'secondarycache:value:(all none metadata)'
'setuid:value:(on off)'
'shadow:value' # TODO: complete URI|none
'share:share properties'
@@ -128,9 +129,11 @@ case $service:$implementation in
'bcloneused[amount of storage used by cloned blocks]'
'dedup_table_size[size of dedup table on-disk]'
'dedupcached[size of dedup table in arc]'
+ 'encryptionroot'
'expandsize[uninitialized space within the pool]'
'fragmentation[amount of fragmentation in the pool]'
'freeing[amount of space remaining to be reclaimed]'
+ 'last_scrubbed_txg[transaction group (TXG) up to which the most recent scrub operated]'
'load_guid[unique identifier generated when pool is loaded]'
'used[amount of storage space used within the pool]'
)
@@ -150,12 +153,24 @@ case $service:$implementation in
rw_ds_props+=(
'aclmode:value:(discard groupmask passthrough restricted)'
'acltype:value:(off noacl nfsv4 posix posixacl)'
+ 'defaultprojectquota:->quotas'
+ 'defaultprojectobjquota:->quotas'
+ 'defaultgroupobjquota:->quotas'
+ 'defaultuserobjquota:->quotas'
+ 'dnodesize:value:(legacy auto 1k 2k 4k 8k 16k)'
+ 'direct:value:(disabled standard always)'
+ 'groupobjquota@'
'mlslabel:value:(none)' # TODO: list sensitivity labels
- 'redundant_metadata:value:(all most)'
+ 'overlay:value:(on off)'
+ 'projectquota@' 'projectobjquota@'
+ 'redundant_metadata:value:(all most some none)'
+ 'snapdev:value:(hidden visible)'
+ 'special_small_blocks:size [0]'
+ 'userobjquota@'
'vscan:value:(on off)'
'xattr:value:(on off dir sa)'
- "filesystem_limit: :{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ -prefix n ]]; then compadd none; else _message -e limits 'number or none'; fi}"
- "snapshot_limit: :{if [[ -prefix [0-9]## ]]; then _message -e 'number'; elif [[ -prefix n ]]; then compadd none; else _message -e limits 'number or none'; fi}"
+ "filesystem_limit:unlimited:_phony none _numbers limit"
+ "snapshot_limit:unlimited:_phony none _numbers limit"
'volmode:mode:((
default\:use\ system-wide\ tunable
full\:expose\ as\ block\ devices
@@ -166,8 +181,8 @@ case $service:$implementation in
)
ro_ds_props+=(
createtxg clones filesystem_count guid logicalreferenced logicalused
- receive_resume_token refcompressratio snapshot_count snapshots_changed
- volblocksize written
+ objsetid receive_resume_token redact_snaps refcompressratio
+ snapshot_count snapshots_changed volblocksize written
)
delegatable_perms=(
bookmark load-key change-key userobjquota userobjused groupobjquota
@@ -240,8 +255,6 @@ case $service:$implementation in
"defaultwritelimit: : _alternative \
'sizes: :_guard \[0-9\]\#\(\|\[BKMGTPEZ\]\) size\ \(bytes\ per\ second\)' \
'properties:property:(none)'"
- 'defaultuserquota:->quotas'
- 'defaultgroupquota: :->quotas'
'keysource:value:->keysources'
)
ci_ds_props+=(
@@ -256,13 +269,13 @@ case $service:$implementation in
zfs:openzfs)
subcmds+=(
bookmark change-key load-key program project projectspace redact
- unload-key wait
+ rewrite unload-key wait version
)
;|
zpool:openzfs)
subcmds+=(
- checkpoint events labelclear initialize reopen resilver sync trim wait
- version
+ checkpoint events labelclear initialize reopen resilver sync prefetch
+ trim wait version
)
;|
zfs:solaris)
@@ -282,8 +295,9 @@ case $service:$implementation in
;;
zpool:*)
subcmds+=(
- add attach clear create destroy detach export get history import iostat
- list offline online reguid remove replace scrub set split status upgrade
+ add attach clear create destroy ddtprune detach export get history
+ import iostat list offline online reguid remove replace scrub set
+ split status upgrade
)
;;
zstream:*)
@@ -292,15 +306,18 @@ case $service:$implementation in
esac
case $OSTYPE in
- solaris*)
+ solaris*|linux-gnu)
rw_ds_props+=( 'zoned:value:(on off)' )
- ;;
+ ;|
freebsd*)
[[ $OSTYPE = freebsd<-12>.* ]] && subcmds+=( remap )
rw_ds_props+=( 'jailed:value:(on off)' )
;;
linux-gnu)
- rw_ds_props+=( 'relatime:value:(on off)' )
+ rw_ds_props+=(
+ 'relatime:value:(on off)'
+ 'volthreading:value:(on off)'
+ )
ci_ds_props+=(
{,fs,def,root}'context:SELinux context:_selinux_contexts -a file_type'
)
@@ -460,9 +477,11 @@ case $service:$words[1] in
;;
zfs:clone)
- [[ $implementation = solaris ]] && args+=(
- '-K[create encryption key]'
- )
+ if [[ $implementation = solaris ]]; then
+ args+=( '-K[create encryption key]' )
+ else
+ args+=( "-u[don't mount newly created dataset]" )
+ fi
_arguments -C -A "-*" -S $args \
'-p[create parent datasets]' \
'*-o+[set property]:property:->create-properties' \
@@ -508,7 +527,11 @@ case $service:$words[1] in
if [[ $implementation = solaris ]]; then
args=( '-I+[specify dataset states to display instead of normal datasets]:dataset state:_sequence compadd - receiving resumable hidden all' )
else
- args=( '-p[use exact (parsable) numeric output]' )
+ args=(
+ '(-j --json)'{-j,--json}'[output in JSON format]'
+ '--json-int[output numbers in integer format instead of strings]'
+ '-p[use exact (parsable) numeric output]'
+ )
fi
_arguments -A "-*" -S $args \
'(-d)-r[recursively display children]' \
@@ -604,13 +627,25 @@ case $service:$words[1] in
'*:file:_files'
;;
+ zfs:rewrite)
+ _arguments -A "-*" -S -s \
+ '-P[rewrite physical blocks only so snapshots and incremental streams are unaffected]' \
+ '-l+[specify maximum number of bytes to write]:maximum (bytes)' \
+ '-o+[specify starting offset]:offset (bytes)' \
+ '-r[recurse into directories]' \
+ '-v[print names of all successfully rewritten files]' \
+ "-x[don't cross file system boundaries]" \
+ '*:file or directory:_files'
+ ;;
+
zfs:mount)
[[ $OSTYPE != freebsd* ]] && args=( '-O[overlay mount]' )
[[ $implementation = openzfs ]] && args+=(
'-l[load keys for encrypted filesystems as they are being mounted]'
'(-a)-R[mount filesystems along with all their children]'
)
- _arguments -A "-*" -S $args \
+ _arguments -A "-*" -S : $args \
+ '(- :)'{-j,--json}'[show all mounted file systems in JSON format]' \
'-o+[specify temporary file system options]: :_values -s , "option" {,no}{atime,dev,exec,relatime,suid,xattr} ro rw' \
'-v[report mount progress]' \
'-f[force mount]' \
@@ -898,6 +933,11 @@ case $service:$words[1] in
':property:($delegatable_perms $ro_ds_props ${rw_ds_props%%:*})'
;;
+ (zfs|zpool):version)
+ _arguments -A "-*" -S \
+ '-j[output in JSON format]'
+ ;;
+
zpool:(clear|online))
[[ $OSTYPE = linux* ]] && args=(
"--power[power on the device's slot in the storage enclosure]"
@@ -985,12 +1025,19 @@ case $service:$words[1] in
'-f[force use of in-use devices]' \
'-n[display configuration without creating pool]' \
'-R+[use alternate root]:alternate root:_directories' \
- '-m+[set mountpoint for root dataset]:mountpoint' \
+ '-m+[set mountpoint for root dataset]:mountpoint:_phony none _path_files -/ -P / -W /' \
'-t+[use a temporary pool name]:pool name' \
':pool :_guard "^-*" "pool name"' \
'*: :->virtual-devices'
;;
+ zpool:ddtprune)
+ _arguments -A "-*" -S \
+ '(-p)-d[prune entries based on age]:age (days)' \
+ '(-d)-p[prune to target percentage of unique entries]:target (percentage)' \
+ ':pool:_zfs_pool'
+ ;;
+
zpool:destroy)
_arguments -A "-*" -S \
'-f[force active datasets to be unmounted]' \
@@ -1020,9 +1067,17 @@ case $service:$words[1] in
;;
zpool:get)
- [[ $implementation = solaris ]] && args=(
- '-s+[specify sources to display]: :_values -s , "source" local default none'
- )
+ if [[ $implementation = openzfs ]]; then
+ args=(
+ '(-j --json)'{-j,--json}'[output in JSON format]'
+ '--json-int[output numbers in integer format instead of strings]'
+ --json-pool-key-guid
+ )
+ else
+ args=(
+ '-s+[specify sources to display]: :_values -s , "source" local default none'
+ )
+ fi
_arguments -A "-*" -S $args \
'-H[suppress headers and tab-delimit fields]' \
'-p[display numbers in parseable (exact) values]' \
@@ -1076,6 +1131,7 @@ case $service:$words[1] in
zpool:initialize)
_arguments -A "-*" -S \
+ '(-a --all : *)'{-a,--all}'[begin, cancel, suspend initializing on all pools]' \
'(-s --suspend -c --cancel)'{-c,--cancel}'[cancel initializing on specified devices]' \
'(-s --suspend -c --cancel)'{-s,--suspend}'[suspend initializing on specified devices]' \
'(-u --uninit)'{-u,--uninit}'[clear initialization state on specified devices]' \
@@ -1130,6 +1186,9 @@ case $service:$words[1] in
zpool:list)
[[ $implementation = openzfs ]] && args=(
'-g[display vdev GUIDs instead of normal device names]'
+ '(-j --json)'{-j,--json}'[output in JSON format]'
+ '--json-int[output numbers in integer format instead of strings]'
+ --json-pool-key-guid
'-L[display real paths for vdevs resolving all symbolic links]'
'-p[display numbers in parsable (exact) values]'
'-P[display full paths for vdevs instead of only the last component of the path]'
@@ -1167,12 +1226,21 @@ case $service:$words[1] in
;;
zpool:online)
- _arguments -C -A "-*" -S $args \
+ _arguments -C -A "-*" -S \
'-e[expand device to use all available space]' \
':pool:_zfs_pool' \
'*:virtual device:->pool-devices'
;;
+ zpool:prefetch)
+ _arguments -A "-*" -S \
+ '-t+[metadata type]:metadata type:((
+ brt\:block\ reference\ table
+ ddt\:deduplication\ table
+ ))' \
+ ':pool:_zfs_pool'
+ ;;
+
zpool:reopen)
_arguments -A "-*" -S \
"-n[don't restart an in-progress scrub operation]" \
@@ -1180,7 +1248,9 @@ case $service:$words[1] in
;;
zpool:reguid)
- _zfs_pool
+ _arguments -A "-*" -S \
+ '-g+[set pool guid]:guid (64-bit decimal)' \
+ ':pool:_zfs_pool'
;;
zpool:remove)
@@ -1215,6 +1285,10 @@ case $service:$words[1] in
zpool:scrub)
[[ $implementation = openzfs ]] && args=(
+ '(-a --all *)'{-a,--all}'[begin, pause, stop scrub on all pools]'
+ '-C[continue scrub from last saved txg]'
+ '-S+[specify start date for transactions]:date (YYYY-MM-DD HH\:MM):_dates'
+ '-E+[specify end date for transactions]:date (YYYY-MM-DD HH\:MM):_dates'
'(-s)-p[pause scrubbing]'
'-w[wait until scrub has completed before returning]'
'-e[only scrub files with known data errors]'
@@ -1259,6 +1333,9 @@ case $service:$words[1] in
'-c+[run scripts on each vdev]:script:_sequence _files -W "($ZPOOL_SCRIPTS_PATH /etc/zfs/zpool.d ~/.zpool.d)"'
'-e[only show unhealthy vdevs]'
'-i[display vdev initialization status]'
+ '(-j --json)'{-j,--json}'[output in JSON format]'
+ '--json-int[output numbers in integer format instead of strings]'
+ --json-flat-vdevs --json-pool-key-guid
'-g[display vdev GUIDs instead of the normal device names]'
'-L[display real paths for vdevs resolving all symbolic links]'
'-p[display numbers in parsable (exact) values and times in nanoseconds]'
@@ -1280,6 +1357,7 @@ case $service:$words[1] in
zpool:trim)
_arguments -C -A "-*" -S \
+ '(-a --all 1 *)'{-a,--all}'[perform TRIM on all pools]' \
'(-d --secure)'{-d,--secure}'[initiate a secure TRIM]' \
'(-r --rate)'{-r,--rate}'[set rate at which the TRIM operation progresses]:rate (bytes per second)' \
'(-c --cancel)'{-c,--cancel}'[cancel trimming]' \
diff --git a/Completion/Unix/Command/_zip b/Completion/Unix/Command/_zip
index cfa51be36..29c242caa 100644
--- a/Completion/Unix/Command/_zip
+++ b/Completion/Unix/Command/_zip
@@ -166,7 +166,7 @@ case $state in
elif [[ -f $testfile.ZIP ]]; then
zipfile=$testfile.ZIP
else
- return 1
+ return ret
fi 2>/dev/null
if [[ $zipfile != $_zip_cache_name ]]; then
_zip_cache_name="$zipfile"
diff --git a/Completion/Unix/Command/_zstd b/Completion/Unix/Command/_zstd
index 92c4a8e41..db23e541b 100644
--- a/Completion/Unix/Command/_zstd
+++ b/Completion/Unix/Command/_zstd
@@ -52,6 +52,7 @@ elif (( $words[(I)(-d|--decompress|--uncompress|-l|--list|-t|--test)] )); then
'(--sparse)-o[specify output file]:file:_files -g "^*.(|t)zst(-.)"'
"(M)--no-check[ignore checksums in compressed frame]"
'!(M --no-check)'{-C,--check}
+ '--pass-through[pass through uncompressed files as-is]'
'*:files:_files -g "*.(|t)zst(-.)"'
)
else
@@ -108,6 +109,7 @@ _arguments -s -S : $args \
'--filelist=[read list of files to operate upon from file]: :_files' \
'--output-dir-flat=[store processed files in directory]: :_directories' \
'--output-dir-mirror=[store processed files in directory respecting original structure]: :_directories' \
+ '--no-asyncio[disable asynchronous IO]' \
'--trace=[log tracing information to file]: :_files' \
+ '(M)' \
\!{-z,--compress,--uncompress} \
diff --git a/Completion/Unix/Type/_arch_archives b/Completion/Unix/Type/_arch_archives
deleted file mode 100644
index 9ffd7e3d3..000000000
--- a/Completion/Unix/Type/_arch_archives
+++ /dev/null
@@ -1,14 +0,0 @@
-#autoload
-
-local ARCHCMD="$1"
-shift
-local expl completions library name_arg='-n'
-if [[ -n $argv[(r)--library] ]]; then
- library='library-'
- # remove parameter from $@ before calling compadd
- argv[(r)--library]=()
- name_arg=
-fi
-completions=($(_call_program ${ARCHCMD} ${ARCHCMD} ${library:-}archives $name_arg))
-_description -V archives expl "${library:-}archives"
-compadd "$@" "$expl[@]" -- "$completions[@]"
diff --git a/Completion/Unix/Type/_arch_namespace b/Completion/Unix/Type/_arch_namespace
deleted file mode 100644
index 171293887..000000000
--- a/Completion/Unix/Type/_arch_namespace
+++ /dev/null
@@ -1,105 +0,0 @@
-#autoload
-
-_arch_namespace () { #double as arch_namespace_categories
- local ARCHCMD="$1"
- shift
-# takes an integer argument specifying how many components:
-# 1: category
-# 2: branch
-# 3: version
-# 4: revision
- local suffix expl archive=`$ARCHCMD my-default-archive 2> /dev/null`
- local trailing_dashes=0
- [[ -n $argv[(r)--trailing-dashes] ]] && trailing_dashes=1
- local library
- [[ -n $argv[(r)--library] ]] && library='library-';
- local exclude_library_revisions=0
- [[ -n $argv[(r)--exclude-library-revisions] ]] && exclude_library_revisions=1
-
- if [ $1 -gt 1 ] || (( trailing_dashes )); then
- suffix=(-q -S --)
- fi
- if [[ $PREFIX = */* ]]; then
- compset -P '*/'
- archive=${IPREFIX%/*}
- _description -V categories expl "${library:-}categories in $archive"
- compadd $suffix "$expl[@]" `$ARCHCMD ${library:-}categories $archive`
- elif [ -z $IPREFIX ]; then
- local index=$(( words[(i)-A] + 1 ))
- (( index < CURRENT )) || index=$(( words[(i)--archive] + 1 ))
- (( index < CURRENT )) && archive=$words[$index]
-
- if [ $archive ]; then
- _description -V categories expl "${library:-}categories in $archive"
- compadd "$expl[@]" $suffix `$ARCHCMD ${library:-}categories $archive`
- fi
-
- _arch_archives "$ARCHCMD" -S / ${library:+--library}
- fi
- if [ $archive ] && [ $1 -gt 1 ] && [[ $PREFIX != *@* ]] \
- && [[ $PREFIX = *--* ]]; then
- #this match could be better
- _arch_namespace_branches "$ARCHCMD" $(($1 - 1))
- fi
-}
-
-(( $+functions[_arch_namespace_branches] )) ||
-_arch_namespace_branches () {
- local ARCHCMD="$1"
- shift
- local suffix expl
- if [ $1 -gt 1 ] || (( $trailing_dashes )); then
- suffix=(-q -S --)
- fi
- if [[ $IPREFIX != *-- ]]; then
- compset -P 1 '*--'
- local category=${IPREFIX%--}
- _description -V branches expl "${library:-}branches"
- compadd $suffix "$expl[@]" \
- ${${(@)$($ARCHCMD ${library:-}branches $category)}##*--}
- fi
- if [ $1 -gt 1 ] && [[ $IPREFIX = *-- ]] && [[ $PREFIX = *--* ]]; then
- _arch_namespace_versions "${ARCHCMD}" $(($1 - 1))
- fi
-}
-
-(( $+functions[_arch_namespace_versions] )) ||
-_arch_namespace_versions () {
- local ARCHCMD="$1"
- shift
- local suffix expl
- if [ $1 -gt 1 ]; then
- suffix=(-q -S --)
- fi
- if [[ $IPREFIX != *--*-- ]] || [[ $IPREFIX != */*--*-- ]]; then
- compset -P 1 '*--'
- local branch=${IPREFIX%--}
- _description -V versions expl "${library:-}versions"
- compadd $suffix "$expl[@]" \
- ${${(@)$($ARCHCMD ${library:-}versions $branch)}##*--}
- fi
- if [ $1 -gt 1 ] && [[ $IPREFIX = *--*-- ]] && ([[ $IPREFIX = */*--*-- ]] \
- || [[ $PREFIX != */* ]]) && [[ $PREFIX = *--* ]]; then
- _arch_namespace_revisions "${ARCHCMD}"
- fi
-}
-
-(( $+functions[_arch_namespace_revisions] )) ||
-_arch_namespace_revisions () {
- local ARCHCMD="$1"
- local expl
- if [[ $IPREFIX != *--*--*-- ]] || [[ $IPREFIX != */*--*--*-- ]]; then
- compset -P 1 '*--'
- local version=${IPREFIX%--}
- _description -V revisions expl "${library:-}revisions"
- local completions c
- completions=(
- ${${(@)$($ARCHCMD ${library:-}revisions $version)}##*--}
- )
- (( exclude_library_revisions )) && \
- foreach c ($($ARCHCMD library-revisions $version)); do completions[(r)$c]=(); done
- compadd "$expl[@]" -a completions
- fi
-}
-
-_arch_namespace "$@"
diff --git a/Completion/Unix/Type/_date_formats b/Completion/Unix/Type/_date_formats
index 55af7c591..2b7139492 100644
--- a/Completion/Unix/Type/_date_formats
+++ b/Completion/Unix/Type/_date_formats
@@ -59,7 +59,7 @@ specs=(
)
case $OSTYPE in
- linux-gnu)
+ freebsd*|linux-gnu)
[[ $1 == zsh ]] || # %N is handled below in this case
specs+=( 'N:fractional part of seconds since epoch, in nanoseconds' )
;|
@@ -107,6 +107,6 @@ done
_describe -t date-format-specifier 'date format specifier' specs \
-p "${(Q)PREFIX:-%}" -S '' && ret=0
-[[ $1 == zsh ]] && _message -e date-format-precision 'precision for %%. (1-9)'
+[[ $1 == zsh ]] && _message -e date-format-precision 'precision for %. (1-9)'
return ret
diff --git a/Completion/Unix/Type/_diff_options b/Completion/Unix/Type/_diff_options
index 03ea1d7fe..ba3f02c8f 100644
--- a/Completion/Unix/Type/_diff_options
+++ b/Completion/Unix/Type/_diff_options
@@ -26,7 +26,7 @@ _diff_palette() {
}
if _pick_variant -r variant -c $cmd gnu=GNU unix -v ||
- [[ $OSTYPE = (freebsd<12->|darwin<22->).* ]]; then
+ [[ $OSTYPE = (freebsd<12->.|darwin<22->.|netbsd)* ]]; then
(( $#words > 2 )) && ign='!'
# output formats
diff --git a/Completion/Unix/Type/_pspdf b/Completion/Unix/Type/_pspdf
index 1df3f860c..3fcc2175f 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
+#compdef gsbj gsdj gsdj500 gslj gslp ps2ascii ghostview mgv pstoedit pstotgif
local expl ext
diff --git a/Completion/Unix/Type/_terminals b/Completion/Unix/Type/_terminals
index 04ece1167..156ba7e96 100644
--- a/Completion/Unix/Type/_terminals
+++ b/Completion/Unix/Type/_terminals
@@ -1,8 +1,37 @@
#compdef infocmp -value-,TERM,-default-
-local desc expl
+local entry
+local -aU desc
+local -a terms names
-desc=( $TERMINFO ~/.terminfo $TERMINFO_DIRS /usr/{,share/}{,lib/}terminfo /{etc,lib}/terminfo )
+desc=(
+ $TERMINFO ~/.terminfo $TERMINFO_DIRS /usr/{,share/}{,lib/}terminfo
+ /{etc,lib}/terminfo
+)
+desc=( $desc(N:P) ) # may have symlinks to the same path
+terms=( $desc/*/^*+?*(N:t) ) # entries named with a + are common includes
-_wanted terminals expl 'terminal name' \
- compadd "$@" - $desc/*/*(N:t)
+if [[ $OSTYPE = (freebsd|dragonfly)* ]]; then
+ while read entry; do
+ [[ "$entry" != [^[:blank:]\#\*_]*:* ]] && continue
+
+ names=( ${${(s:|:)entry%%:*}##[[:blank:]]#} )
+ if [[ $#names -gt 1 && $names[-1] = *\ * ]]; then
+ terms+=( ${^names[1,-2]:#*[ +]?*}:${names[-1]} )
+ else
+ terms+=( ${names:#*\ *} )
+ fi
+ done < /etc/termcap
+
+elif [[ $OSTYPE = netbsd* ]]; then
+ grep $'^[^#\t]*,$' /usr/share/misc/terminfo | while read entry; do
+ names=( ${(s:|:)entry%,} )
+ if [[ $#names -gt 1 && $names[-1] = *\ * ]]; then
+ terms+=( ${^names[1,-2]:#*[ +]?*}:${names[-1]} )
+ else
+ terms+=( ${names:#*\ *} )
+ fi
+ done
+fi
+
+_describe -t terminals 'terminal name' terms "$@"
diff --git a/Completion/X/Command/_acroread b/Completion/X/Command/_acroread
deleted file mode 100644
index 4a5cb5cb8..000000000
--- a/Completion/X/Command/_acroread
+++ /dev/null
@@ -1,119 +0,0 @@
-#compdef acroread
-
-local curcontext="$curcontext" state line
-local cmdfile
-
-if [[ -z $_acroread_version ]]; then
- _acroread_version="$($words[1] -version 2>/dev/null)"
-fi
-
-if [[ -z $_acroread_version ]]; then
- if [[ $words[1] = */* && -x $words[1] ]]; then
- cmdfile=$words[1]
- elif [[ -x $commands[$words[1]] ]]; then
- cmdfile=$commands[$words[1]]
- fi
-
- # Try extracting the version number directly from the executable.
- # (This will fail if the executable is a wrapper script for acroread.)
- _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=}
-
- if [[ -z $_acroread_version ]]; then
- local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
- if [[ -r $acropath ]]; then
- _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=}
- fi
- fi
-fi
-
-if [[ $_acroread_version == [789].* ]]; then
- local -a extra_args
- extra_args=()
- if [[ $_acroread_version == [89].* ]]; then
- extra_args+=(-man '-installCertificate:server ip::server port')
- fi
- if [[ $_acroread_version == 9.* ]]; then
- extra_args+=(-openInNewInstance)
- fi
- _arguments -C \
- "${extra_args[@]}" \
- '--display=:X display:_x_display' \
- '--screen=:X screen (overrides the screen part of DISPLAY)' \
- --sync \
- '-geometry:[<width>x<height>][{+|-}<x offset>{+|-}<y offset>]' \
- -help \
- -iconic \
- '*-setenv:<var>=<value>' \
- -tempFile \
- '-tempFileTitle:title' \
- -openInNewWindow \
- -version \
- '-visual:X visual:_x_visual' \
- '-toPostScript:*::PostScript conversion options:= ->tops' \
- '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return
-
- [[ -n "$state" ]] && _arguments \
- '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \
- -binary \
- '-start:integer' \
- '-end:integer' \
- -optimizeForSpeed \
- -landscape \
- -reverse \
- '(-even)-odd' \
- '(-odd)-even' \
- -commentsOff \
- -annotsOff \
- -stampsOff \
- -markupsOn \
- '(-level3)-level2' \
- '(-level2)-level3' \
- -printerhalftones \
- -saveVM \
- '-scale:integer' \
- -shrink \
- -expand \
- '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \
- '-transQuality:transparency flattening level:(1 2 3 4 5)' \
- '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return
-else
- _x_arguments -C \
- -help \
- -helpall \
- \*-iconic \
- \*+iconic \
- '-name:application name:_x_name' \
- '*-setenv:<var>=<value>' \
- -tempFile \
- '-tempFileTitle:title' \
- '(+useFrontEndProgram)-useFrontEndProgram' \
- '(-useFrontEndProgram)+useFrontEndProgram' \
- '-visual:X visual:_x_visual' \
- '-xrm:X resource specification:_x_resource' \
- '-toPostScript:*::PostScript conversion options:= ->tops' \
- '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return
-
- [[ -n "$state" ]] && _arguments \
- '-pairs:*:pdf_file_1 ps_file_1 ...:_files -g "*.(#i)(pdf|ps)(-.)"' \
- -binary \
- '-start:integer' \
- '-end:integer' \
- -optimizeForSpeed \
- -landscape \
- -reverse \
- '(-even)-odd' \
- '(-odd)-even' \
- -commentsOff \
- '(-level2 -level3)-level1' \
- '(-level1 -level3)-level2' \
- '(-level1 -level2)-level3' \
- -printerhalftones \
- -saveVM \
- '-scale:integer' \
- -shrink \
- '-size:page size (or custom size wxh in points):(letter tabloid ledger legal executive a3 a4 a5 b4 b5)' \
- '-transQuality:transparency flattening level:(1 2 3 4 5)' \
- '*:PDF file:_files -g "*.(#i)pdf(-.)"' && return
-fi
-
-return 1
diff --git a/Completion/X/Command/_dcop b/Completion/X/Command/_dcop
deleted file mode 100644
index a0329e110..000000000
--- a/Completion/X/Command/_dcop
+++ /dev/null
@@ -1,119 +0,0 @@
-#compdef dcop dcopstart dcopfind dcopref dcopclient dcopobject
-
-local curcontext="$curcontext" desc vals arg base max=0 ret=1
-local app obj fun
-local -a state line expl
-
-case $service in
- dcop(client|object))
- state=( dcopref )
- max=2
- ;;
- dcopref) max=3 ;;
- dcopstart)
- if (( CURRENT > 2 )); then
- _urls && return
- fi
- ;;
- dcopfind)
- local cmd=$words[1]
- _arguments -C \
- '-a[print application id instead of DCOPRef]' \
- '-l[if object not found, run dcopstart and retry]' \
- '*::args:->args' && ret=0
- unset state
- words=( $cmd $words )
- (( CURRENT++ ))
- ;;
-esac
-
-if (( max && CURRENT > max )); then
- _message 'no more arguments'
- return 1
-fi
-
-if [[ -z "$state" ]]; then
- state=(application object function)
- [[ $words[2] = DCOPRef* && CURRENT -ne 2 ]]
- base=$?
- state=( ${state[CURRENT-base]:-arg} )
-
- [[ $state[1] = application && $service = dcop(|find) ]] && state+=( dcopref )
-fi
-
-while (( $#state )); do
- unset app obj fun
-
- if [[ $words[2] = (#b)DCOPRef*\(([^,]#)((#e)|,)([^\\\)]#)(*) ]]; then
- if [[ -n $match[2] ]]; then
- app=$match[1]
- if [[ -n $match[4] ]]; then
- obj=$match[3]
- [[ -n $words[3] && CURRENT -gt 3 ]] && fun=$words[3]
- fi
- fi
- else
- case $CURRENT in
- <5->) fun="$words[4]" ;&
- 4) obj="$words[3]" ;&
- 3) app="$words[2]" ;;
- esac
- fi
- vals=( ${(f)"$(_call_program dcop-$state[1]s ${(M)words[1]##*/}dcop $app $obj 2>/dev/null)"} )
-
- case "$state[1]" in
- application|object)
- [[ -n ${(M)vals:#*\(default\)} ]] && vals+=( default )
- _wanted dcop-$state[1]s expl $state[1] compadd "$@" - ${vals% \(default\)} && ret=0
- ;;
-
- function)
- [[ $service = dcopfind ]] && vals=( ${(M)vals:#bool *} )
- _wanted dcop-$state[1]s expl $state[1] compadd "$@" - ${${vals#* }%\(*} && ret=0
- ;;
-
- arg)
- arg=${${${(M)vals:#*$fun\(*}#*\(}%\)*},
- arg=${${(s.,.)arg}[CURRENT-base-3]}
- if [[ -n $arg ]]; then
- if [[ $arg = (Q(|C)String|*int )* || $arg != *\ * ]]; then
- # don't mention the argument's type
- desc="${arg##* }"
- else
- desc="${arg##* } (${arg% *})"
- fi
- case $arg in
- bool*) _wanted argument expl "$desc" compadd true false && return ;;
- (#i)*(file|path|dir)*) _wanted argument expl "$desc" _files && return ;;
- (#i)*url*) _wanted argument expl "$desc" _urls && return ;;
- *) _message -e argument "$desc" ;;
- esac
- else
- _message 'no more arguments'
- fi
- ;;
-
- dcopref)
- if ! compset -P '*\('; then
- _wanted dcoprefs expl 'dcop ref' compadd -S '' 'DCOPRef(' && ret=0
- elif compset -P '*,'; then
- if compset -S '(|\\)\)*'; then
- set -- -S '' "$@"
- else
- set -- "$@" -S"${${QIPREFIX:+)}:-\)}$compstate[quote] "
- fi
- state+=( object )
- else
- if compset -S ',*'; then
- set -- "$@" -S ''
- else
- set -- "$@" -S ,
- fi
- state+=( application )
- fi
- ;;
- esac
- shift state
-done
-
-return ret
diff --git a/Completion/X/Command/_mplayer b/Completion/X/Command/_mplayer
index 1f99a1789..e954744de 100644
--- a/Completion/X/Command/_mplayer
+++ b/Completion/X/Command/_mplayer
@@ -115,7 +115,7 @@ case "$state" in
_tags files urls
while _tags; do
_requested files expl 'media file' _files -g \
- "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4a|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && ret=0
+ "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4a|m4b|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && ret=0
if _requested urls; then
while _next_label urls expl URL; do
_urls "$expl[@]" && ret=0
diff --git a/Completion/X/Command/_nedit b/Completion/X/Command/_nedit
index 75ca1bad4..8bf7cac43 100644
--- a/Completion/X/Command/_nedit
+++ b/Completion/X/Command/_nedit
@@ -1,4 +1,4 @@
-#compdef nedit nedit-nc=nc ncl=nc
+#compdef nedit nedit-nc=nc ncl=nc nedit-client=nc
local state line expl nedit_common curcontext="$curcontext" ret=1
typeset -A opt_args
diff --git a/Completion/X/Command/_netscape b/Completion/X/Command/_netscape
deleted file mode 100644
index 78b2da649..000000000
--- a/Completion/X/Command/_netscape
+++ /dev/null
@@ -1,93 +0,0 @@
-#compdef netscape
-
-local curcontext="$curcontext" state line expl ret=1 suf files
-typeset -A opt_args
-
-_x_arguments -C \
- '-xrm:resource:_x_resource' \
- '-help[show usage message]' \
- '-version[show the version number and build date]' \
- '-visual[use a specific server visual]:visual:_x_visual -b' \
- '-install[install a private colormap]' \
- '-no-install[use the default colormap]' \
- '-ncols[max no. of colors to allocate for images]:n:' \
- '-mono[force 1-bit-deep image display]' \
- '-iconic[start up iconified]' \
- '-remote[execute a command in an existing Netscape]:remote command:->remote' \
- '-id[id of X window to send remote commands to]:window-id:' \
- '-raise[raise window following remote command]' \
- "-noraise[don't raise window following remote command]" \
- '-nethelp[show nethelp]' \
- -{dont-force-window-stacking,no-about-splash} \
- -{,no-}{,irix-}session-management \
- -{done-save,ignore}-geometry-prefs \
- -{component-bar,composer,edit,messenger,mail,discussions,news} \
- '*:location:->urls' && ret=0
-
-# Handle netscape remote commands
-if [[ "$state" = "remote" ]]; then
- local -a remote_commands
- remote_commands=(openURL openFile saveAs mailto addBookmark)
-
- compset -P '*\('
- if compset -S '(|\\)\)*'; then
- set - -S "" "$@"
- else
- set - -S"${${QIPREFIX:+)}:-\)}$compstate[quote] " "$@"
- fi
- case $IPREFIX in
- openURL*|addBookmark*) state=urls;;
- openFile*) _files "$@" -W ~;;
- saveAs*)
- if compset -P "*,"; then
- _wanted types expl 'data type' \
- compadd "$@" -M 'm:{a-zA-Z}={A-Za-z}' HTML Text PostScript && ret=0
- else
- compset -S ",*" || suf=","
- _files -qS "$suf" -W ~ && ret=0
- fi
- ;;
- mailto*)
- _email_addresses -s, -c && ret=0
- ;;
- *)
- compset -S '(|\\)\(*' || suf="${${QIPREFIX:+(}:-\(}"
- _wanted commands expl 'remote command' \
- compadd -qS "$suf" -M 'm:{a-zA-Z}={A-Za-z}' -a \
- remote_commands && ret=0
- ;;
- esac
-fi
-
-if [[ "$state" = "urls" ]]; then
- _tags files urls
- while _tags; do
- _requested files expl 'file' _files "$@" && files=yes ret=0
- if _requested urls; then
- # Complete netscape urls
- if compset -P about: ; then
- _wanted values expl 'about what' \
- compadd "$@" authors blank cache document fonts global hype \
- image-cache license logo memory-cache mozilla plugins && ret=0
- elif compset -P news: ; then
- _newsgroups "$@" && ret=0
- elif compset -P mailto: ; then
- _email_addresses -c && ret=0
- else
- _tags prefixes
- while _tags; do
- while _next_label prefixes expl 'URL prefix' "$@"; do
- _urls "$expl[@]" && ret=0
- compset -S '[^:]*'
- compadd -S '' "$expl[@]" about: news: mailto: mocha: javascript: && ret=0
- done
- (( ret )) || return 0
- done
- [[ -z "$files" ]] && _tags files
- fi
- fi
- (( ret )) || return 0
- done
-fi
-
-return ret
diff --git a/Completion/X/Command/_papers b/Completion/X/Command/_papers
new file mode 100644
index 000000000..1c6076728
--- /dev/null
+++ b/Completion/X/Command/_papers
@@ -0,0 +1,18 @@
+#compdef papers
+
+_arguments -s -S : \
+ + '(help)' \
+ '(- : *)--version[display version information]' \
+ '(- : *)'{-h,--help}'[display help information]' \
+ '(- : *)--help-all[display all help information]' \
+ '(- : *)--help-gapplication[display help information for GApplication options]' \
+ + '(mode)' \
+ {-f,--fullscreen}'[run in fullscreen mode]' \
+ {-s,--presentation}'[run in presentation mode]' \
+ + '(page)' \
+ {-p,--page-label=}'[specify page label of document to display]:page label:' \
+ {-i,--page-index=}'[specify page number of document to display]:page index:' \
+ {-n,--named-dest=}'[specify named destination to display]:named destination:' \
+ + etc \
+ '--gapplication-service[enter GApplication service mode]' \
+ '*:document file:_files -g "*.(#i)(cb7|cbr|cbt|cbz|djv|djvu|pdf|tif|tiff)(-.)"'
diff --git a/Completion/X/Command/_pdftk b/Completion/X/Command/_pdftk
index b26deb15f..4029e52fe 100644
--- a/Completion/X/Command/_pdftk
+++ b/Completion/X/Command/_pdftk
@@ -6,8 +6,7 @@ _pdfwithhandle()
_files "$@" -g '(#i)*.pdf'
}
-local expl
-local -a opts operations
+local -a expl opts operations
opts=(output encrypt_40bit encrypt_128bit allow owner_pw user_pw flatten
compress uncompress keep_first_id keep_final_id drop_xfa verbose
@@ -22,15 +21,13 @@ case $words[CURRENT-1] in
;;
(allow)
- #_description permissions expl "permission"
- #compadd $expl \
_values -s , permission \
Printing DegradedPrinting ModifyContents Assembly CopyContents \
ScreenReaders ModifyAnnotations FillIn AllFeatures
;;
(attach_files)
- _files "$@"
+ _files
;;
(fill_form)
@@ -51,11 +48,9 @@ case $words[CURRENT-1] in
esac && return 0
if [[ -n $words[(r)(${(j:|:)operations})] ]]; then
- _description options expl "option"
- compadd $@ $expl $opts
+ _wanted options expl "option" compadd -a opts
else
- _tags files operations
- _alternative \
- 'files:PDF file:_pdfwithhandle' \
- "operations:operation:($operations)"
+ _alternative \
+ 'files:PDF file:_pdfwithhandle' \
+ "operations:operation:compadd -a operations"
fi
diff --git a/Completion/X/Command/_xv b/Completion/X/Command/_xv
index 513a953dc..1c35d3a2c 100644
--- a/Completion/X/Command/_xv
+++ b/Completion/X/Command/_xv
@@ -42,4 +42,4 @@ _x_arguments \
'-gsres:ghostscript resolution' \
'-gsgeom:ghostscript page size' \
'-DEBUG:debug level' \
- '*:picture file:_files -g \*.\(\#i\)\(png\|gif\|jpeg\|jpg\|tiff\|tif\|pbm\|pgm\|ppm\|xbm\|xpm\|ras\(\|t\)\|tga\|rle\|rgb\|bmp\|pcx\|fits\|pm\)\(-.\)'
+ '*:picture file:_files -g \*.\(\#i\)\(png\|gif\|jpeg\|jpg\|tiff\|tif\|pbm\|pgm\|ppm\|xbm\|xpm\|ras\(\|t\)\|tga\|rle\|rgb\|bmp\|pcx\|fits\|pm\|eps\)\(-.\)'
diff --git a/Completion/Zsh/Command/_alias b/Completion/Zsh/Command/_alias
index 617627cbe..86e9a88f0 100644
--- a/Completion/Zsh/Command/_alias
+++ b/Completion/Zsh/Command/_alias
@@ -3,7 +3,7 @@
local curcontext="$curcontext" state line expl type suf
typeset -A opt_args
-_arguments -C -s -A "-*" -S \
+_arguments -C -s -A "-*" -S -S : \
'(-r +r -s +s)-+g[list or define global aliases]' \
'(-g +g -s +s)-+r[list or define regular aliases]' \
'(-r +r -g +g)-+s[list or define suffix aliases]' \
diff --git a/Completion/Zsh/Command/_bindkey b/Completion/Zsh/Command/_bindkey
index df9c8f225..81016fe4f 100644
--- a/Completion/Zsh/Command/_bindkey
+++ b/Completion/Zsh/Command/_bindkey
@@ -10,7 +10,7 @@
local state expl line curcontext="$curcontext" ret=1
typeset -A opt_args
-_arguments -C -s -S \
+_arguments -C -s -S -S : \
'(-v -a -M -l -D -A -N -p)-e[select emacs keymap and bind it to main]' \
'(-e -a -M -l -D -A -N -p)-v[select viins keymap and bind it to main]' \
'(-e -v -M -l -D -A -N -p)-a[select vicmd keymap]' \
diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command
index 503f860a2..02ff985c3 100644
--- a/Completion/Zsh/Command/_command
+++ b/Completion/Zsh/Command/_command
@@ -1,6 +1,6 @@
#compdef command
-_arguments \
+_arguments -S : \
'-v[indicate result of command search]:*:command:_path_commands' \
'-V[show result of command search in verbose form]:*:command:_path_commands' \
'(-)-p[use default PATH to find command]' \
diff --git a/Completion/Zsh/Command/_compadd b/Completion/Zsh/Command/_compadd
index 4456cf71e..e42e1dd36 100644
--- a/Completion/Zsh/Command/_compadd
+++ b/Completion/Zsh/Command/_compadd
@@ -88,7 +88,7 @@ case $service in
;;
esac
-_arguments -C -s -S -A "-*" $args && ret=0
+_arguments -C -s -S -S -A "-*" : $args && ret=0
if [[ -n $state ]]; then
if (( $+opt_args[-a] )); then
diff --git a/Completion/Zsh/Command/_compinit b/Completion/Zsh/Command/_compinit
new file mode 100644
index 000000000..eed4dacb8
--- /dev/null
+++ b/Completion/Zsh/Command/_compinit
@@ -0,0 +1,9 @@
+#compdef compinit
+
+_arguments : \
+ '(-i -u)-C[bypass security and dump-file checks]' \
+ '-d+[automatically create dump file / specify dump-file path]::dump file:_files' \
+ "-D[don't automatically create dump file]" \
+ '(-C -u)-i[ignore insecure files]' \
+ "(-C -i)-u[don't check for insecure files]" \
+ "-w[explain why dump file isn't loaded]"
diff --git a/Completion/Zsh/Command/_dirs b/Completion/Zsh/Command/_dirs
index 0281f3736..489366f08 100644
--- a/Completion/Zsh/Command/_dirs
+++ b/Completion/Zsh/Command/_dirs
@@ -1,6 +1,6 @@
#compdef dirs
-_arguments -s \
+_arguments -s -S -S : \
'(-)-c[clear the directory stack]' \
'(* -c)-l[display directory names in full]' \
'(* -c)-v[display numbered list of directory stack]' \
diff --git a/Completion/Zsh/Command/_disable b/Completion/Zsh/Command/_disable
index da3803039..c4cc00243 100644
--- a/Completion/Zsh/Command/_disable
+++ b/Completion/Zsh/Command/_disable
@@ -6,7 +6,7 @@ ali_arr=(${(k)aliases} ${(k)galiases})
sali_arr=(${(k)saliases})
func_arr=(${(k)functions})
-_arguments -C -s -A "-*" -S \
+_arguments -C -s -A "-*" -S -S : \
"(-f -r -s -p)-a[act on regular or global aliases]:*:regular or global alias:compadd -k ali_arr" \
"(-a -r -s -p)-f[act on functions]:*:function:compadd -k func_arr" \
"(-a -f -s -p)-r[act on reserved words]:*:reserved-word:compadd -k reswords" \
diff --git a/Completion/Zsh/Command/_emulate b/Completion/Zsh/Command/_emulate
index d6fb0c3d9..3477bc556 100644
--- a/Completion/Zsh/Command/_emulate
+++ b/Completion/Zsh/Command/_emulate
@@ -1,8 +1,9 @@
#compdef emulate
-_arguments -C -s \
- '-L[set local_options and local_traps as well]' \
+_arguments -s -S -S -A '-*' : \
+ '(2 3)-l[list options to be set or unset]' \
+ '(2 3)-L[set local_options and local_traps as well]' \
'-R[reset all options instead of only those needed for script portability]' \
'1:shell to emulate:(zsh sh ksh csh)' \
- '2:specify optional command:(-c)' \
- '3:command:_cmdstring'
+ '(-l -L)2:specify optional command:(-c)' \
+ '(-l -L)3: :_cmdstring'
diff --git a/Completion/Zsh/Command/_enable b/Completion/Zsh/Command/_enable
index b62619d89..c581e49a3 100644
--- a/Completion/Zsh/Command/_enable
+++ b/Completion/Zsh/Command/_enable
@@ -6,7 +6,7 @@ ali_arr=(${(k)dis_aliases} ${(k)dis_galiases})
sali_arr=(${(k)dis_saliases})
func_arr=(${(k)dis_functions})
-_arguments -C -s -A "-*" -S \
+_arguments -C -s -A "-*" -S -S : \
"(-f -r -s -p)-a[act on regular or global aliases]:*:alias:compadd -k ali_arr" \
"(-a -r -s -p)-f[act on functions]:*:function:compadd -k func_arr" \
"(-a -f -s -p)-r[act on reserved words]:*:reserved-word:compadd -k dis_reswords" \
diff --git a/Completion/Zsh/Command/_exec b/Completion/Zsh/Command/_exec
index 2498b57c0..76f11b69d 100644
--- a/Completion/Zsh/Command/_exec
+++ b/Completion/Zsh/Command/_exec
@@ -1,6 +1,6 @@
#compdef exec
-_arguments -s -S -A '-*' : \
+_arguments -s -S -S -A '-*' : \
'-a+[set argv\[0\] to specified string]:argv[0] string' \
'-c[clear environment]' \
'-l[simulate login shell (prepend - to argv\[0\])]' \
diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc
index 626d35956..fc35114f5 100644
--- a/Completion/Zsh/Command/_fc
+++ b/Completion/Zsh/Command/_fc
@@ -12,7 +12,7 @@ words=( "${(@)words[1,CURRENT-1]:#*=*}" "${(@)words[CURRENT,-1]}" )
(( CURRENT -= cur ))
fc_common=(
- -s -S
+ -s -S -S :
'(-A -R -W -p -P)-I[include internal (new) events only]'
'(-A -R -W -p -P)-L[include local events only]'
'(-A -R -W -p -P)-r[reverse order of the events]'
diff --git a/Completion/Zsh/Command/_hash b/Completion/Zsh/Command/_hash
index d4bb59d28..b7af750c2 100644
--- a/Completion/Zsh/Command/_hash
+++ b/Completion/Zsh/Command/_hash
@@ -9,7 +9,7 @@ common_args=( \
case ${service} in
hash)
- _arguments -C -s -S \
+ _arguments -C -s -S -S : \
'(-f -m -v)-r[empty hash table]' \
'(-f -r)-m[treat arguments as patterns]' \
'(-f -r -m)-v[list entries as they are added]' \
@@ -18,7 +18,7 @@ case ${service} in
'(-d -f -r -m -v -L)*:hash:->hashval' && ret=0
;;
rehash)
- _arguments -C -s ${common_args[@]} && return 0
+ _arguments -C -s -S -S : ${common_args[@]} && return 0
;;
esac
diff --git a/Completion/Zsh/Command/_jobs_builtin b/Completion/Zsh/Command/_jobs_builtin
index 70804cf0f..46146986b 100644
--- a/Completion/Zsh/Command/_jobs_builtin
+++ b/Completion/Zsh/Command/_jobs_builtin
@@ -1,6 +1,6 @@
#compdef jobs
-_arguments -C -s \
+_arguments -C -s -S -S : \
"(-d -l -p -r -s *)-Z[specify string to replace shell's argument and environment with]:string" \
'(-Z)-d[show directory from which each job was started]' \
'(-Z)-l[list process IDs]' \
diff --git a/Completion/Zsh/Command/_kill b/Completion/Zsh/Command/_kill
index 3b5c02151..24bf67fac 100644
--- a/Completion/Zsh/Command/_kill
+++ b/Completion/Zsh/Command/_kill
@@ -3,7 +3,7 @@
local curcontext="$curcontext" line state ret=1
typeset -A opt_args
-_arguments -C \
+_arguments -C -s -S -S : \
'(-s -l -L 1)-n[specify signal number]:signal number' \
'(-l -L)-q[send the specified integer with the signal using sigqueue]:value' \
'(-n -l -L 1)-s[specify signal name]:signal:_signals -s' \
diff --git a/Completion/Zsh/Command/_print b/Completion/Zsh/Command/_print
index 0610cd4cf..506bf8ca6 100644
--- a/Completion/Zsh/Command/_print
+++ b/Completion/Zsh/Command/_print
@@ -19,7 +19,7 @@ if [[ $service = print ]]; then
rest='*: :_default'
fi
- _arguments -C -s -A "-*" -S \
+ _arguments -C -s -A "-*" -S -S : \
'-r[ignore escape conventions of echo]' \
'(-r -b -f -m -s -S -l -N -o -O -i -c -u -p -z -D -P)-R[emulate BSD echo (no escapes, -n & -e flags only)]' \
'-b[recognise bindkey escape sequences]' \
diff --git a/Completion/Zsh/Command/_prompt b/Completion/Zsh/Command/_prompt
index ef6aac355..e44d02e0f 100644
--- a/Completion/Zsh/Command/_prompt
+++ b/Completion/Zsh/Command/_prompt
@@ -1,6 +1,6 @@
#compdef prompt
-_arguments -s \
+_arguments -s -S : \
'-l[list themes]:*:' \
'-c[show selected theme]:*:' \
"-h[help]::prompt theme:($prompt_themes):*:" \
diff --git a/Completion/Zsh/Command/_read b/Completion/Zsh/Command/_read
index 1f733b0e8..e71531c31 100644
--- a/Completion/Zsh/Command/_read
+++ b/Completion/Zsh/Command/_read
@@ -6,7 +6,7 @@ local pflag
(:>&p) 2>/dev/null &&
pflag='(-q -s -u -z)-p[input is read from the coprocess]'
-_arguments -s -A "-*" -S \
+_arguments -s -A "-*" -S -S : \
'-r[raw mode]' \
'(-p -k -s -u -z)-q[read y or n character from terminal]' \
'(-q)-k+[specify number of characters to read]:: :_guard "[0-9]#" "number of characters"' \
diff --git a/Completion/Zsh/Command/_set b/Completion/Zsh/Command/_set
index 27c7f3c7d..5939b48af 100644
--- a/Completion/Zsh/Command/_set
+++ b/Completion/Zsh/Command/_set
@@ -1,6 +1,6 @@
#compdef set
-noglob _arguments -s -S \
+noglob _arguments -s -S -S : \
- list '+[list names of parameters]' - others \
'-o+[set specified option]:option:_options' \
'+o+[unset specified option]:option:_options' \
@@ -21,5 +21,5 @@ noglob _arguments -s -S \
{-,+}d[no-globalrcs] {-,+}e[errexit] {-,+}f[no-rcs] {-,+}g[histignorespace] \
{-,+}h[histignoredups] {-,+}i[interactive] {-,+}k[interactivecomments] \
{-,+}l[login] {-,+}m[monitor] {-,+}n[no-exec] {-,+}p[privileged] \
- {-,+}r[restricted] {-,+}t[singlecommand] {-,+}u[no-unset] {-,+}v[verbose] \
+ {-,+}t[singlecommand] {-,+}u[no-unset] {-,+}v[verbose] \
{-,+}w[chaselinks] {-,+}x[xtrace] {-,+}y[shwordsplit]
diff --git a/Completion/Zsh/Command/_strftime b/Completion/Zsh/Command/_strftime
index a57a76ce4..fce1f5d95 100644
--- a/Completion/Zsh/Command/_strftime
+++ b/Completion/Zsh/Command/_strftime
@@ -6,7 +6,7 @@ if (( words[(I)-r] )); then
two='date string'
fi
-_arguments -S -A '-*' -s \
+_arguments -S -S -A '-*' -s : \
'-n[omit trailing newline]' \
'-q[run quietly]' \
'(3)-r[reverse lookup using strptime]' \
diff --git a/Completion/Zsh/Command/_tcpsys b/Completion/Zsh/Command/_tcpsys
index 1240ffbf8..c22a2c3a8 100644
--- a/Completion/Zsh/Command/_tcpsys
+++ b/Completion/Zsh/Command/_tcpsys
@@ -21,7 +21,7 @@ case $service in
else
argargs+=(':host:_hosts' ':port:_ports' '*:session:->session')
fi
- _arguments -C $argargs
+ _arguments -C -s -S : $argargs
;;
esac
diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset
index 99b9e7e0d..895a3aa5d 100644
--- a/Completion/Zsh/Command/_typeset
+++ b/Completion/Zsh/Command/_typeset
@@ -93,7 +93,7 @@ for ((i=1;i<=$#use;++i)); do
args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[dUurRtT]]:+$func}]} )
done
-_arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq' && ret=0
+_arguments -C -s -A "-*" -S -S : "${args[@]}" '*::vars:= ->vars_eq' && ret=0
if [[ "$state" = vars_eq ]]; then
if [[ $func = f ]]; then
diff --git a/Completion/Zsh/Command/_unhash b/Completion/Zsh/Command/_unhash
index ff0c03f49..97ccd098a 100644
--- a/Completion/Zsh/Command/_unhash
+++ b/Completion/Zsh/Command/_unhash
@@ -1,6 +1,6 @@
#compdef unhash
-_arguments -s -S \
+_arguments -s -S -S : \
'(-a -f -s *)-d[remove named directories]:*:named directory:compadd -k nameddirs' \
'(-d -f -s *)-a[remove aliases]:*:alias:_aliases' \
'(-a -d -f *)-s[remove suffix aliases]:*:suffix alias:_aliases -s s' \
diff --git a/Completion/Zsh/Command/_vared b/Completion/Zsh/Command/_vared
index e7072ca6d..493bae698 100644
--- a/Completion/Zsh/Command/_vared
+++ b/Completion/Zsh/Command/_vared
@@ -1,6 +1,6 @@
#compdef vared
-_arguments -s -A "-*" \
+_arguments -s -S -S -A "-*" : \
'(-a)-A[edit associative array]' \
'(-A)-a[edit array parameter]' \
"-c[create parameter or change type]" \
diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which
index 7eb5129ab..95ad5ab2d 100644
--- a/Completion/Zsh/Command/_which
+++ b/Completion/Zsh/Command/_which
@@ -15,14 +15,14 @@ xarg='-x+[specify spaces to use for indentation in function expansion]: :_number
case ${service} in
whence)
- _arguments -C -s -A "-*" -S \
+ _arguments -C -s -A "-*" -S -S : \
'(-c -w)-v[verbose output]' \
'(-v -w)-c[csh-like output]' \
"${cargs[@]}" "$farg" "$aarg" "$xarg" && ret=0
;;
- where) _arguments -C -s -A "-*" -S "${cargs[@]}" "$xarg" && ret=0;;
- which) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$xarg" && ret=0;;
- type) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$farg" && ret=0;;
+ where) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$xarg" && ret=0;;
+ which) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$aarg" "$xarg" && ret=0;;
+ type) _arguments -C -s -A "-*" -S -S : "${cargs[@]}" "$aarg" "$farg" && ret=0;;
esac
if [[ "$state" = command ]]; then
diff --git a/Completion/Zsh/Command/_zattr b/Completion/Zsh/Command/_zattr
index e48047f6c..c7033de71 100644
--- a/Completion/Zsh/Command/_zattr
+++ b/Completion/Zsh/Command/_zattr
@@ -4,24 +4,24 @@ local context state line expl ret=1 REPLY
case $service in
zgetattr)
-_arguments \
+_arguments -S -S : \
'1:file:_files' \
'2:attribute:->attrs' \
'3:parameter'
;;
zsetattr)
-_arguments \
+_arguments -S -S : \
'1:file:_files' \
'2:attribute:->attrs' \
'3:value'
;;
zdelattr)
-_arguments \
+_arguments -S -S : \
'1:file:_files' \
'2:attribute:->attrs'
;;
zlistattr)
-_arguments \
+_arguments -S -S : \
'1:file:_files' \
'2:parameter'
;;
diff --git a/Completion/Zsh/Command/_zcompile b/Completion/Zsh/Command/_zcompile
index 727ead3b1..f1d1e9ac9 100644
--- a/Completion/Zsh/Command/_zcompile
+++ b/Completion/Zsh/Command/_zcompile
@@ -3,7 +3,7 @@
local state line expl curcontext="$curcontext" ret=1
typeset -A opt_args
-_arguments -C -s \
+_arguments -C -s -S -S -A '-*' : \
"(-t -c -m -a)-U[don't expand aliases]" \
'(-t -M)-R[mark as read]' \
'(-t -R)-M[mark as mapped]' \
diff --git a/Completion/Zsh/Command/_zed b/Completion/Zsh/Command/_zed
index f84993d73..25763d3fb 100644
--- a/Completion/Zsh/Command/_zed
+++ b/Completion/Zsh/Command/_zed
@@ -1,11 +1,11 @@
#compdef zed fned histed
case $service in
-(fned) _arguments -S : ':shell function:_functions';;
-(histed) _arguments -S : \
+(fned) _arguments -S -S : ':shell function:_functions';;
+(histed) _arguments -S -S : \
'1:history file:_files' \
'2:history size: ';;
-(zed) _arguments -S : \
+(zed) _arguments -s -S -S -A '-*' : \
'(-h 1 3 4)-f[edit function]' \
'(-h 1 3 4)-x+[specify spaces to use for indentation in function expansion]:spaces' \
'(-f -x 1 2)-h[edit history]' \
diff --git a/Completion/Zsh/Command/_zformat b/Completion/Zsh/Command/_zformat
new file mode 100644
index 000000000..e0f5dc699
--- /dev/null
+++ b/Completion/Zsh/Command/_zformat
@@ -0,0 +1,24 @@
+#compdef zformat
+
+local -a args=(
+ - align
+ '-a[align strings]'
+ '1:array to store formatted strings in:_parameters -g "*array*~*readonly*"'
+ '2:separator string'
+ '*:strings to align (left\:right)'
+
+ - format
+ '(-F)-f[format string (ternary tests spec value)]'
+ '(-f)-F[format string (ternary tests spec length)]'
+ '(-Q)-q[escape % in specs by default, preserve escapes in format string (with -fF)]'
+ '(-q)-Q[escape % in specs by default (with -fF)]'
+ '1:parameter to store formatted string in:_parameters -g "^*readonly*"'
+ '2:format string'
+ '*:format spec ([quote]char\:string)'
+)
+
+# don't complete operands until we see one of -afF
+[[ -n ${(M)${(@Q)words}:#-[A-Za-z]#[afF][A-Za-z]#} ]] ||
+args=( ${args:#(|<->|\*):?*} )
+
+_arguments -s -S -S -A '-?*' : $args
diff --git a/Completion/Zsh/Command/_zle b/Completion/Zsh/Command/_zle
index 97ec8c875..ec83c38fa 100644
--- a/Completion/Zsh/Command/_zle
+++ b/Completion/Zsh/Command/_zle
@@ -15,7 +15,7 @@ compwids=(accept-and-menu-complete
opts=(-A -C -D -F -L -M -N -R -T -U -a -c -l -r \* :)
-_arguments -s -S \
+_arguments -s -S -S : \
"($opts)-A[define widget alias]:old widget:->widget :new widget:->widget" \
"($opts)-C[define completion widget]:new widget name:->comp-widget :completion widget:->builtin-comp-widget :widget shell function:->function" \
"($opts)-D[delete widget]:*:widget:->widget" \
@@ -36,14 +36,14 @@ _arguments -s -S \
'(-)*::widget args:->args' && ret=0
[[ $state == listing ]] &&
- _arguments -s -S '!-l' \
+ _arguments -s -S -S : '!-l' \
"(-a)-L[list as commands]" \
"(-L)-a[list all widgets]" \
'*:widget name:->widget' && ret=0
case "$state[1]" in
(args)
- _arguments \
+ _arguments -s -S : \
'(-N)-n[numeric prefix]:number:' \
'(-n)-N[reset numeric prefix]' \
'-K[specify temporary keymap]:keymap:compadd -a keymaps' \
@@ -67,7 +67,7 @@ case "$state[1]" in
compadd -M 'r:|-=* r:|=*' -k "widgets[(I)(.|)(${(j(|))compwids})]" && ret=0
;;
(redisplay)
- _arguments -s -S '!-R' \
+ _arguments -s -S -S : '!-R' \
"-c[clear listing]" \
":status line" "*:strings to list" && ret=0
;;
diff --git a/Completion/Zsh/Command/_zmodload b/Completion/Zsh/Command/_zmodload
index f3e38c0f6..3acb75c6e 100644
--- a/Completion/Zsh/Command/_zmodload
+++ b/Completion/Zsh/Command/_zmodload
@@ -4,7 +4,7 @@ local suf comp state line expl curcontext="$curcontext" ret=1 NORMARG
typeset -A opt_args
suf=()
-_arguments -n -C -S -s \
+_arguments -n -C -S -S -s -A '-*' : \
'(-R -P -i -u -d -a -b -c -I -p -f -e -F -m)-A[create module aliases]' \
'(-)-R[remove module aliases]' \
'(-A -R -F -L -m -P -l -e)-u[unload module]' \
diff --git a/Completion/Zsh/Command/_zmv b/Completion/Zsh/Command/_zmv
index df5cb5113..8b4b60897 100644
--- a/Completion/Zsh/Command/_zmv
+++ b/Completion/Zsh/Command/_zmv
@@ -1,6 +1,6 @@
#compdef zmv zln zcp
-_arguments -s -S -A '-*' \
+_arguments -s -S -S -A '-*' : \
'(-C -L -s -p)-M[force mv]' \
'(-M -L -s -p)-C[force cp]' \
'(-M -C -p)-L[force ln]' \
diff --git a/Completion/Zsh/Command/_zparseopts b/Completion/Zsh/Command/_zparseopts
index ae81937c1..72dc787a4 100644
--- a/Completion/Zsh/Command/_zparseopts
+++ b/Completion/Zsh/Command/_zparseopts
@@ -4,7 +4,7 @@ local ret=1
local -a context line state state_descr alts opts
local -A opt_args
-_arguments -A '-*' : \
+_arguments -S -S -A '-*' : \
'-a+[specify array in which to store parsed options]:array:_parameters -g "*array*~*readonly*"' \
'-A+[specify association in which to store parsed options]:association:_parameters -g "*association*~*readonly*"' \
'-D[remove parsed options from positional parameters]' \
@@ -13,6 +13,7 @@ _arguments -A '-*' : \
'-G[enable GNU-style parsing]' \
'-K[preserve contents of arrays/associations when specs are not matched]' \
'-M[enable mapping among equivalent options with opt1=opt2 spec form]' \
+ '-n+[specify program name for usage errors]:program name' \
'-v+[specify array from which to parse options]:array:_parameters -g "*array*"' \
'(-)-[end zparseopts options; specs follow]' \
'*: :->spec' \
diff --git a/Completion/Zsh/Command/_zpty b/Completion/Zsh/Command/_zpty
index 99251aa0a..75393ecf1 100644
--- a/Completion/Zsh/Command/_zpty
+++ b/Completion/Zsh/Command/_zpty
@@ -3,7 +3,7 @@
local state line list names expl sep curcontext="$curcontext"
typeset -A opt_args
-_arguments -C -s -S \
+_arguments -C -s -S -S -A '-*' : \
'(-r -w -t -n -L -d)-e[echo input characters]' \
'(-r -w -t -n -L -d)-b[io to pseudo-terminal blocking]' \
'(-r -w -t -n -L -e -b)-d[delete command]:*:name:->name' \
diff --git a/Completion/Zsh/Command/_zsocket b/Completion/Zsh/Command/_zsocket
index eeed9f1d8..bf0298b17 100644
--- a/Completion/Zsh/Command/_zsocket
+++ b/Completion/Zsh/Command/_zsocket
@@ -1,6 +1,6 @@
#compdef zsocket
-_arguments -s -w -A "-*" \
+_arguments -s -w -S -S -A "-*" : \
'-v[verbose output]' \
'-d[target file descriptor]:fd:_file_descriptors' \
- outbound \
diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle
index 0c81c2f2e..9bba030c8 100644
--- a/Completion/Zsh/Command/_zstyle
+++ b/Completion/Zsh/Command/_zstyle
@@ -339,7 +339,7 @@ while (( $#state )); do
ctop=c
;;
- (:chwpd:*)
+ (:chpwd:*)
ctop=d
;;
diff --git a/Completion/Zsh/Function/__arguments b/Completion/Zsh/Function/__arguments
index af7710971..1264d372b 100644
--- a/Completion/Zsh/Function/__arguments
+++ b/Completion/Zsh/Function/__arguments
@@ -32,7 +32,7 @@ else
'-W[(rarely needed) enable single-letter option stacking with arguments in the same word (-x X -y == -xXy)]' \
"-C[modify \$curcontext for \`->action' (instead of \$context)]" \
"-R[when \`->action' matches, return 300]" \
- "-S[honour \`--' as end-of-options guard]" \
+ "*-S[honour \`--' (and \`-' if given twice) as end-of-options guard]" \
"-A[do not complete options after non-options]:pattern matching unknown options (e.g., '-*')" \
'-O[pass elements of array variable to function calls in actions]:array variable name:_parameters -g array' \
"-M[specify matchspec for completing option names and values]:matchspec for completing option names and values [ 'r\\:|[_-]=* r\\:|=*' ]" \
diff --git a/Completion/Zsh/Type/_history_modifiers b/Completion/Zsh/Type/_history_modifiers
index 1a049d6cb..bb704b3a3 100644
--- a/Completion/Zsh/Type/_history_modifiers
+++ b/Completion/Zsh/Type/_history_modifiers
@@ -60,6 +60,7 @@ while true; do
else
list=(
"s:substitute string"
+ "S:substitute pattern"
"&:repeat substitution"
)
if (( ! global )); then
diff --git a/Completion/Zsh/Type/_jobs_fg b/Completion/Zsh/Type/_jobs_fg
index 57117f0d6..49bf72425 100644
--- a/Completion/Zsh/Type/_jobs_fg
+++ b/Completion/Zsh/Type/_jobs_fg
@@ -1,3 +1,8 @@
#compdef disown fg
-_jobs "$@"
+local -a ca_args=( "$@" )
+local -a args=( '(-)*: :_jobs' )
+
+[[ $service == disown ]] && args+=( '(: *)-a[disown all jobs]' )
+
+_arguments -s -S -A '-*' -O ca_args : $args
diff --git a/Completion/compdump b/Completion/compdump
index 6daf92f9f..f089b9bdf 100644
--- a/Completion/compdump
+++ b/Completion/compdump
@@ -135,7 +135,7 @@ print "typeset -gUa _comp_assocs" >& $_d_fd
print "_comp_assocs=( ${(qq)_comp_assocs} )" >& $_d_fd
exec {_d_fd}>&-
-mv -f $_d_file ${_d_file%.$HOST.$$}
+mv -f -- $_d_file ${_d_file%.$HOST.$$}
unfunction compdump
autoload -Uz compdump
diff --git a/Completion/compinit b/Completion/compinit
index 60dbb599d..2d6bf554a 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -77,38 +77,16 @@ setopt extendedglob
typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1
typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name _i_why
-while [[ $# -gt 0 && $1 = -[dDiuCw] ]]; do
- case "$1" in
- -d)
- _i_autodump=1
- shift
- if [[ $# -gt 0 && "$1" != -[dfQC] ]]; then
- _i_dumpfile="$1"
- shift
- fi
- ;;
- -D)
- _i_autodump=0
- shift
- ;;
- -i)
- _i_fail=ign
- shift
- ;;
- -u)
- _i_fail=use
- shift
- ;;
- -C)
- _i_check=
- shift
- ;;
- -w)
- _i_why=1
- shift
- ;;
- esac
-done
+# note: for historical reasons it must be possible to give the optional arg to
+# -d in the next parameter. zparseopts handles this by default
+local -A _i_opth
+zparseopts -A _i_opth -D -F - C d:: D i u w || return
+(( $+_i_opth[-C] )) && _i_check=
+(( $+_i_opth[-d] )) && _i_autodump=1 _i_dumpfile=$_i_opth[-d]
+(( $+_i_opth[-D] )) && _i_autodump=0
+(( $+_i_opth[-i] )) && _i_fail=ign
+(( $+_i_opth[-u] )) && _i_fail=use
+(( $+_i_opth[-w] )) && _i_why=1
# The associative arrays containing the definitions for the commands and
# services.
@@ -345,7 +323,7 @@ compdef() {
[[ $2 = .menu-select ]] && zmodload -i zsh/complist
zle -C "$1" "$2" "$func"
if [[ -n $new ]]; then
- bindkey "$3" | IFS=$' \t' read -A opt
+ opt=( ${(z)${ bindkey "$3" }} )
[[ $opt[-1] = undefined-key ]] && bindkey "$3" "$1"
else
bindkey "$3" "$1"
@@ -372,8 +350,8 @@ compdef() {
# And bind the keys...
for i; do
if [[ -n $new ]]; then
- bindkey "$i" | IFS=$' \t' read -A opt
- [[ $opt[-1] = undefined-key ]] || continue
+ opt=( ${(z)${ bindkey "$i" }} )
+ [[ $opt[-1] = undefined-key ]] || continue
fi
bindkey "$i" "$func"
done
@@ -461,6 +439,7 @@ if [[ -n "$_i_check" ]]; then
if ! read -q \
"?zsh compinit: insecure $_i_q, run compaudit for list.
Ignore insecure $_i_q and continue [y] or abort compinit [n]? "; then
+ print -u2
print -u2 "$0: initialization aborted"
unfunction compinit compdef
unset _comp_dumpfile _comp_secure compprefuncs comppostfuncs \
@@ -468,6 +447,7 @@ Ignore insecure $_i_q and continue [y] or abort compinit [n]? "; then
return 1
fi
+ print -u2
fi
fpath=(${fpath:|_i_wdirs})
(( $#_i_wfiles )) && _i_files=( "${(@)_i_files:#(${(j:|:)_i_wfiles%.zwc})}" )
@@ -484,6 +464,8 @@ autoload -RUz compdump compinstall
_i_done=''
+[[ _i_why -eq 1 ]] && print -ru2 "Using dump file: $_comp_dumpfile"
+
if [[ -f "$_comp_dumpfile" ]]; then
if [[ -n "$_i_check" ]]; then
IFS=$' \t' read -rA _i_line < "$_comp_dumpfile"
@@ -493,7 +475,7 @@ if [[ -f "$_comp_dumpfile" ]]; then
builtin . "$_comp_dumpfile"
_i_done=yes
elif [[ _i_why -eq 1 ]]; then
- print -nu2 "Loading dump file skipped, regenerating"
+ print -nu2 "Loading dump file skipped"
local pre=" because: "
if [[ _i_autodump -ne 1 ]]; then
print -nu2 $pre"-D flag given"
@@ -513,8 +495,9 @@ if [[ -f "$_comp_dumpfile" ]]; then
_i_done=yes
fi
elif [[ _i_why -eq 1 ]]; then
- print -u2 "No existing compdump file found, regenerating"
+ print -u2 "No existing dump file found"
fi
+
if [[ -z "$_i_done" ]]; then
typeset -A _i_test
@@ -547,6 +530,7 @@ if [[ -z "$_i_done" ]]; then
# If autodumping was requested, do it now.
if [[ $_i_autodump = 1 ]]; then
+ [[ _i_why -eq 1 ]] && print -u2 "Regenerating dump file"
compdump
fi
fi
diff --git a/Completion/openSUSE/Command/_SUSEconfig b/Completion/openSUSE/Command/_SUSEconfig
deleted file mode 100644
index 737a80b17..000000000
--- a/Completion/openSUSE/Command/_SUSEconfig
+++ /dev/null
@@ -1,14 +0,0 @@
-#compdef SuSEconfig
-
-local modules
-modules=( /sbin/conf.d/SuSEconfig.*~(*.rpm*|*.swap|*.bak|*.orig|*~|\#*)(N:e) )
-
-_arguments \
- '--help' \
- '--quick' \
- '--force' \
- '--verbose' \
- '--nonewpackage' \
- '-norestarts' \
- '-nomodule' \
- '--module:module:compadd -a modules'
diff --git a/Config/.cvsignore b/Config/.cvsignore
deleted file mode 100644
index dd265a713..000000000
--- a/Config/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-defs.mk
-*.swp
diff --git a/Config/version.mk b/Config/version.mk
index 637bade7a..0b34ea7a2 100644
--- a/Config/version.mk
+++ b/Config/version.mk
@@ -27,5 +27,5 @@
# This must also serve as a shell script, so do not add spaces around the
# `=' signs.
-VERSION=5.9.0.3-test
-VERSION_DATE='August 24, 2025'
+VERSION=5.9.999.3-test
+VERSION_DATE='May 27, 2026'
diff --git a/Doc/.cvsignore b/Doc/.cvsignore
deleted file mode 100644
index 606228be7..000000000
--- a/Doc/.cvsignore
+++ /dev/null
@@ -1,20 +0,0 @@
-Makefile
-help.txt
-version.yo
-zsh*.1
-zsh.texi
-zsh.info*
-*.html
-zsh.aux zsh.toc
-zsh.cp zsh.cps
-zsh.fn zsh.fns
-zsh.ky zsh.kys
-zsh.pg zsh.pgs
-zsh.vr zsh.vrs
-zsh.log zsh.dvi
-zsh.tp zsh.tps
-zsh.idx
-zsh_*.ps
-infodir
-*.swp
-zsh.pdf zsh_a4.pdf zsh_us.pdf
diff --git a/Doc/Makefile.in b/Doc/Makefile.in
index f68f40a9e..3b68ed61a 100644
--- a/Doc/Makefile.in
+++ b/Doc/Makefile.in
@@ -84,7 +84,7 @@ 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) \
-Zsh/options.yo Zsh/params.yo Zsh/prompt.yo Zsh/redirect.yo Zsh/restricted.yo \
+Zsh/options.yo Zsh/params.yo Zsh/prompt.yo Zsh/redirect.yo \
Zsh/seealso.yo Zsh/tcpsys.yo Zsh/zftpsys.yo Zsh/zle.yo
# ========== DEPENDENCIES FOR BUILDING ==========
@@ -121,9 +121,9 @@ zsh.pdf zsh_a4.pdf zsh_us.pdf: $(sdir)/zsh.texi
intro.pdf intro.a4.pdf intro.us.pdf: $(sdir)/intro.ms
if test $@ = intro.us.pdf || \
{ test $@ = intro.pdf && test "$(PAPERSIZE)" = us; }; then \
- pdfroff -mspdf --no-kill-null-pages -P-pletter --pdf-output=$@ $(sdir)/intro.ms; \
+ groff -ms -Tpdf -P-pletter $(sdir)/intro.ms > $@; \
else \
- pdfroff -mspdf --no-kill-null-pages -P-pa4 --pdf-output=$@ $(sdir)/intro.ms; \
+ groff -ms -Tpdf -P-pa4 $(sdir)/intro.ms > $@; \
fi
intro.html: $(sdir)/intro.ms
@@ -219,7 +219,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/compat.yo Zsh/restricted.yo
+ Zsh/compat.yo
zshbuiltins.1: Zsh/builtins.yo
diff --git a/Doc/Zsh/.cvsignore b/Doc/Zsh/.cvsignore
deleted file mode 100644
index 71e99e521..000000000
--- a/Doc/Zsh/.cvsignore
+++ /dev/null
@@ -1,4 +0,0 @@
-modlist.yo
-modmenu.yo
-manmodmenu.yo
-*.swp
diff --git a/Doc/Zsh/arith.yo b/Doc/Zsh/arith.yo
index 17eb3cc36..4a0709b27 100644
--- a/Doc/Zsh/arith.yo
+++ b/Doc/Zsh/arith.yo
@@ -144,7 +144,7 @@ provided by the tt(zsh/mathfunc) module
or compare it to the string tt(NaN):
example(% zmodload zsh/mathfunc
-% (( isnan(0.0 / 0) )) && print is nan
+% LPAR()LPAR() isnan+LPAR()0.0 / 0+RPAR() RPAR()RPAR() && print is nan
is nan
% typeset -F f=nan && [[ $f == NaN ]] && print is nan
is nan)
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index c322cee77..ca9ba996b 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -464,13 +464,14 @@ enditem()
)
findex(disown)
cindex(jobs, disowning)
-xitem(tt(disown) [ var(job) ... ])
+xitem(tt(disown) [ tt(-a) | var(job) ... ])
xitem(var(job) ... tt(&|))
item(var(job) ... tt(&!))(
Remove the specified var(job)s from the job table; the shell will
no longer report their status, and will not complain if you
try to exit an interactive shell with them running or stopped.
If no var(job) is specified, disown the current job.
+With tt(-a), disown all jobs.
If the var(job)s are currently stopped and the tt(AUTO_CONTINUE) option
is not set, a warning is printed containing information about how to
@@ -570,8 +571,7 @@ change.
The var(flags) may be any of the invocation-time flags described in
sectref(Invocation)(zsh),
-except that `tt(-o EMACS)' and `tt(-o VI)' may not be used. Flags such
-as `tt(+r)'/`tt(+o RESTRICTED)' may be prohibited in some circumstances.
+except that `tt(-o EMACS)' and `tt(-o VI)' may not be used.
If tt(-c) var(arg) appears in var(flags), var(arg) is evaluated while the
requested emulation is temporarily in effect. In this case the emulation
@@ -989,16 +989,16 @@ tt(read -zr).
)
findex(getopts)
cindex(options, processing)
-item(tt(getopts) var(optstring) var(name) [ var(arg) ... ])(
+item(tt(getopts) [ tt(-p) ] var(optstring) var(name) [ var(arg) ... ])(
Checks the var(arg)s for legal options. If the var(arg)s are omitted,
-use the positional parameters. A valid option argument
+the positional parameters are used. A valid option argument
begins with a `tt(PLUS())' or a `tt(-)'. An argument not beginning with
a `tt(PLUS())' or a `tt(-)', or the argument `tt(-)tt(-)', ends the options.
Note that a single `tt(-)' is not considered a valid option argument.
var(optstring) contains the letters that tt(getopts)
recognizes. If a letter is followed by a `tt(:)', that option
-requires an argument. The options can be
-separated from the argument by blanks.
+requires an argument. The argument may appear either immediately
+following the option in the same word, or in the next word.
Each time it is invoked, tt(getopts) places the option letter it finds
in the shell parameter var(name), prepended with a `tt(PLUS())' when
@@ -1008,15 +1008,17 @@ is stored in tt(OPTARG).
vindex(OPTIND, use of)
vindex(OPTARG, use of)
+When the terminator `tt(-)tt(-)' is encountered, tt(OPTIND) is
+incremented such that it can be tt(shift)ed away with the options. This
+is not true of other non-option arguments, including a single `tt(-)'.
+
The first option to be examined may be changed by explicitly assigning
to tt(OPTIND). tt(OPTIND) has an initial value of tt(1), and is
normally set to tt(1) upon entry to a shell function and restored
-upon exit. (The tt(POSIX_BUILTINS) option disables this, and also changes
-the way the value is calculated to match other shells.) tt(OPTARG)
-is not reset and retains its value from the most recent call to
-tt(getopts). If either of tt(OPTIND) or tt(OPTARG) is explicitly
-unset, it remains unset, and the index or option argument is not
-stored. The option itself is still stored in var(name) in this case.
+upon exit. tt(OPTARG) is not reset and retains its value from the most
+recent call to tt(getopts). If either of tt(OPTIND) or tt(OPTARG) is
+explicitly unset, it remains unset, and the index or option argument is
+not stored. The option itself is still stored in var(name) in this case.
A leading `tt(:)' in var(optstring) causes tt(getopts) to store the
letter of any invalid option in tt(OPTARG), and to set var(name) to
@@ -1024,6 +1026,14 @@ letter of any invalid option in tt(OPTARG), and to set var(name) to
missing. Otherwise, tt(getopts) sets var(name) to `tt(?)' and prints
an error message when an option is invalid. The exit status is
nonzero when there are no more options.
+
+When either the tt(POSIX_BUILTINS) option is enabled or the tt(-p)
+option is given to tt(getopts) itself, tt(getopts) behaves in a more
+POSIX-compatible manner. Specifically, handling of
+`tt(PLUS())'-prefixed options is disabled (they are treated as
+non-options) and the value of tt(OPTIND) is calculated differently.
+Additionally, with tt(POSIX_BUILTINS) (but not with tt(-p)), the value
+of tt(OPTIND) is not kept local to the calling function.
)
findex(hash)
item(tt(hash) [ tt(-Ldfmrv) ] [ var(name)[tt(=)var(value)] ] ...)(
@@ -1735,7 +1745,7 @@ If the tt(-m) flag is given the arguments are taken as patterns
options with names matching these patterns are set.
Note that a bad option name does not cause execution of subsequent shell
-code to be aborted; this is behaviour is different from that of `tt(set
+code to be aborted; this behaviour is different from that of `tt(set
-o)'. This is because tt(set) is regarded as a special builtin by the
POSIX standard, but tt(setopt) is not.
)
diff --git a/Doc/Zsh/compat.yo b/Doc/Zsh/compat.yo
index 4d3567d45..df0ace63d 100644
--- a/Doc/Zsh/compat.yo
+++ b/Doc/Zsh/compat.yo
@@ -1,12 +1,11 @@
-texinode(Compatibility)(Restricted Shell)()(Invocation)
+texinode(Compatibility)()()(Invocation)
sect(Compatibility)
cindex(compatibility)
cindex(sh compatibility)
cindex(ksh compatibility)
Zsh tries to emulate bf(sh) or bf(ksh) when it is invoked as
tt(sh) or tt(ksh) respectively; more precisely, it looks at the first
-letter of the name by which it was invoked, excluding any initial `tt(r)'
-(assumed to stand for `restricted'), and if that is `tt(b)', `tt(s)' or `tt(k)' it
+letter of the name by which it was invoked, and if that is `tt(b)', `tt(s)' or `tt(k)' it
will emulate bf(sh) or bf(ksh). Furthermore, if invoked as tt(su) (which
happens on certain systems when the shell is executed by the tt(su)
command), the shell will try to find an alternative name from the tt(SHELL)
diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo
index fbfccf82e..563833f7b 100644
--- a/Doc/Zsh/compsys.yo
+++ b/Doc/Zsh/compsys.yo
@@ -32,7 +32,7 @@ enditemize()
A full context specification contains other elements, as we shall describe.
-Besides commands names and contexts, the system employs two more
+Besides command names and contexts, the system employs two more
concepts, em(styles) and em(tags). These provide ways for the user
to configure the system's behaviour.
@@ -167,7 +167,8 @@ change, it is easiest to delete the dump file by hand so that
tt(compinit) will re-create it the next time it is run. The check
performed to see if there are new functions can be omitted by giving
the option tt(-C). In this case the dump file will only be created if
-there isn't one already.
+there isn't one already. Use option tt(-w) to explain why a dump file
+isn't loaded and/or why it's regenerated.
The dumping is actually done by another function, tt(compdump), but you
will only need to run this yourself if you change the configuration
@@ -774,7 +775,7 @@ for color names
kindex(commands, completion tag)
item(tt(commands))(
for names of external commands. Also used by complex commands such as
-tt(cvs) when completing names subcommands.
+tt(cvs) when completing names of subcommands.
)
kindex(contexts, completion tag)
item(tt(contexts))(
@@ -1208,7 +1209,7 @@ generated. Its value is a list of names of completers. If any of
these is the name of the completer that generated the matches in this
completion, the string will not be added.
-The default value for this style is `tt(_expand _old_list _correct
+The default value for this style is `tt(_expand _oldlist _correct
_approximate)', i.e. it contains the completers for which a string
with all matches will almost never be wanted.
)
@@ -3701,6 +3702,10 @@ example(foobar -x -- -y)
the `tt(-x)' is considered an option, the `tt(-y)' is considered an
argument, and the `tt(-)tt(-)' is considered to be neither.
+
+If this option is given twice (as tt(-S -S)), a single `tt(-)' is also
+treated this way. This is useful for completing zsh's own builtins as
+well as functions that use tt(zparseopts) for option parsing.
)
item(tt(-A) var(pat))(
Do not complete options after the first non-option
@@ -3979,10 +3984,9 @@ typeset -A opt_args)
to prevent tt(_arguments) from altering the global environment.
)
item(tt({)var(eval-string)tt(}))(
-vindex(expl, use of)
-A string in braces is evaluated as shell code to generate matches. If the
-var(eval-string) itself does not begin with an opening parenthesis or
-brace it is split into separate words before execution.
+A string in braces is evaluated as shell code to generate matches.
+This is similar to the `tt(SP())var(word) var(...)' action described
+below, but isn't limited to a single command.
)
item(tt(= )var(action))(
If the var(action) starts with `tt(= )' (an equals sign followed by a
@@ -4000,8 +4004,9 @@ causes tt(_arguments) on a restricted range; it is necessary to use this
trick to insert an appropriate command name into the range for the second
call to tt(_arguments) to be able to parse the line.
)
-xitem(var(tt(SP())word...))
-item(var(word...))(
+xitem(tt(SP())var(word) var(...))
+item(var(word) var(...))(
+vindex(expl, use of)
This covers all forms other than those above. If the var(action)
starts with a space, the remaining list of words will be invoked unchanged.
@@ -4403,16 +4408,22 @@ Multiple groups separated by tt(-)tt(-) can be supplied, potentially with
different completion options var(opt)s.
The var(descr) is taken as a string to display above the matches if the
-tt(format) style for the tt(descriptions) tag is set. This is followed by
-one or two names of arrays followed by options to pass to tt(compadd). The
-array var(name1) contains the possible completions with their descriptions in
-the form `var(completion)tt(:)var(description)'. Any literal colons in
-var(completion) must be quoted with a backslash. If a var(name2) is
+tt(format) style for the tt(descriptions) tag is set.
+
+This is followed by one or two names of arrays. Alternatively, the arrays
+may be given inline, following the rules described below, using the syntax
+tt(LPAR())var(item) var(...)tt(RPAR()). (There is no separate
+tt(LPAR()LPAR())var(...)tt(RPAR()RPAR()) form as with tt(_arguments).)
+
+The array var(name1) contains the possible completions with their (optional)
+descriptions in the form `var(completion)tt(:)var(description)'. Any literal
+colons in var(completion) must be quoted with a backslash. If a var(name2) is
given, it should have the same number of elements as var(name1); in this
case the corresponding elements are added as possible completions instead
of the var(completion) strings from var(name1). The completion list
-will retain the descriptions from var(name1). Finally, a set of
-completion options can appear.
+will retain the descriptions from var(name1).
+
+Finally, a set of options to pass to tt(compadd) can appear.
If the option `tt(-o)' appears before the first argument, the matches added
will be treated as names of command options (N.B. not shell options),
@@ -4439,6 +4450,7 @@ it does not need to appear inside a loop over tag labels.
)
findex(_description)
item(tt(_description) [ tt(-x) ] [ tt(-12VJ) ] var(tag) var(name) var(descr) [ var(spec) ... ])(
+vindex(expl, use of)
This function is not to be confused with the previous one; it is used as
a helper function for creating options to tt(compadd). It is buried
inside many of the higher level completion functions and so often does
@@ -4900,6 +4912,24 @@ Finally, the tt(_path_files) function uses the styles tt(expand),
tt(ambiguous), tt(special-dirs), tt(list-suffixes) and tt(file-sort)
described above.
)
+findex(_phony)
+item(tt(_phony) ... [ var(word) ... ] [ [ tt(--) ] var(function) [ tt(-) ] ... ])(
+This function allows extra matches to be mixed in with the matches
+generated by a function. Sometimes a command accepts special values like
+`tt(any)', `tt(all)', or `tt(none)' to be specified but the applicable
+completion function only generates real values.
+
+tt(_phony) takes all the same arguments as tt(compadd). With the exception
+of `tt(-a)', `tt(-d)', `tt(-k)' and `tt(-l)', these are passed on to the
+following function. Unless there is only one word, a `tt(--)' separator is
+needed to indicate where the words finish and the function begins. You can
+also omit the function in which case an empty input won't match the phony
+values, allowing descriptions to be displayed. This is useful where real
+values can't be generated and tt(_message -e) would otherwise be used.
+
+To ensure that real and phony matches are grouped together, any options
+defining the match group should be passed to tt(_phony).
+)
findex(_pick_variant)
redef(SPACES)(0)(tt(ifztexi(NOTRANS(@ @ @ @ @ @ @ @ @ @ @ @ @ @ ))ifnztexi( )))
xitem(tt(_pick_variant )[ tt(-b) var(builtin-label) ] [ tt(-c) var(command) ] [ tt(-r) var(name) ])
diff --git a/Doc/Zsh/compwid.yo b/Doc/Zsh/compwid.yo
index cff46fb29..3e8e9f446 100644
--- a/Doc/Zsh/compwid.yo
+++ b/Doc/Zsh/compwid.yo
@@ -520,8 +520,12 @@ item(tt(-d) var(array))(
This adds per-completion display strings. The var(array) should contain one
element per var(completion) given. The completion code will then display the
first element instead of the first var(completion), and so on. The
-var(array) may be given as the name of an array parameter or directly
-as a space-separated list of words in parentheses.
+var(array) may be given as the name of an array parameter, or directly
+as a literal array enclosed in parentheses. A literal array is a space or
+comma separated list of words; quotes have no special meaning and
+backslashes can be used for escaping (for example, `tt((foo\ bar))' produces
+one element, tt(foo bar), while `tt((foo bar))' produces two elements,
+tt(foo) and tt(bar)).
If there are fewer display strings than var(completions), the leftover
var(completions) will be displayed unchanged and if there are more display
@@ -869,16 +873,20 @@ builtin, but in the case of the condition codes the contents of the special
parameters are not modified.
startitem()
+findex(-prefix, within [[)
item(tt(-prefix) [ var(number) ] var(pattern))(
true if the test for the tt(-P) option of tt(compset) would succeed.
)
+findex(-suffix, within [[)
item(tt(-suffix) [ var(number) ] var(pattern))(
true if the test for the tt(-S) option of tt(compset) would succeed.
)
+findex(-after, within [[)
item(tt(-after) var(beg-pat))(
true if the test of the tt(-N) option with only the var(beg-pat) given
would succeed.
)
+findex(-between, within [[)
item(tt(-between) var(beg-pat end-pat))(
true if the test for the tt(-N) option with both patterns would succeed.
)
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 03572bf45..aeb47851c 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -190,9 +190,11 @@ ordinary, such as a Delete key that sends neither tt(^H) nor tt(^?).
The keystrokes read by tt(zkbd) are recorded as a definition for an
associative array named tt(key), written to a file in the subdirectory
-tt(.zkbd) within either your tt(HOME) or tt(ZDOTDIR) directory. The name
-of the file is composed from the tt(TERM), tt(VENDOR) and tt(OSTYPE)
-parameters, joined by hyphens.
+tt(.zkbd) within either your tt(HOME) or, if specified, tt(ZDOTDIR) directory.
+Alternatively, you can tell tt(zkbd) the directory to write new files into
+with the tt(-d) option, e.g. tt(zkbd -d $ZCACHEDIR/zkbd). In either case, the
+directory is created if it did not exist. The name of the file is composed from
+the tt(TERM), tt(VENDOR) and tt(OSTYPE) parameters, joined by hyphens.
You may read this file into your tt(.zshrc) or another startup file with
the `tt(source)' or `tt(.)' commands, then reference the tt(key) parameter
@@ -4404,7 +4406,7 @@ the context prefix `tt(:completion:nslookup)'.
See also the tt(pager), tt(prompt) and tt(rprompt) styles below.
)
findex(regexp-replace)
-item(tt(regexp-replace) var(var) var(regexp) var(replace))(
+item(tt(regexp-replace) var(var) var(regexp) [ var(replace) ])(
Use regular expressions to perform a global search and replace operation
on a variable. POSIX extended regular expressions (ERE) are used,
unless the option tt(RE_MATCH_PCRE) has been set, in which case
@@ -4414,7 +4416,8 @@ library).
var(var) is the name of the variable containing the string to be matched.
The variable will be modified directly by the function. The
-variables tt(MATCH), tt(MBEGIN), tt(MEND), tt(match), tt(mbegin), tt(mend)
+variables tt(MATCH), tt(MBEGIN), tt(MEND), tt(match), tt(mbegin), tt(mend),
+as well as any variables starting with tt(_regexp_replace)
should be avoided as these are used by the regular expression code.
var(regexp) is the regular expression to match against the string.
@@ -4422,6 +4425,7 @@ var(regexp) is the regular expression to match against the string.
var(replace) is the replacement text. This can contain parameter, command
and arithmetic expressions which will be replaced: in particular, a
reference to tt($MATCH) will be replaced by the text matched by the pattern.
+If not given, matches are replaced with nothing.
The return status is 0 if at least one match was performed, else 1.
@@ -4651,6 +4655,79 @@ Same as tt(zmv -C) and tt(zmv -L), respectively. These functions do not
appear in the zsh distribution, but can be created by linking tt(zmv) to
the names tt(zcp) and tt(zln) in some directory in your tt(fpath).
)
+findex(zgetopt)
+item(tt(zgetopt) [ tt(-A) var(array) ] [ tt(-l) var(spec) ] [ tt(-n) var(name) ] [ tt(-o) var(spec) ] tt(--) [ var(arg) ... ])(
+This is a wrapper around tt(zparseopts) (from tt(zsh/zutil)) which
+provides an interface similar to the util-linux implementation of
+tt(getopt+LPAR()1+RPAR()) (sometimes called `GNU tt(getopt)'). It
+simplifies GNU-style argument parsing (including permutation) and
+can make it easier to write functions and scripts with complex APIs,
+particularly ones where the order of options is significant.
+
+The typical usage pattern is as follows:
+
+example(zgetopt -o abc: -l aaa,bbb,ccc: -- "$@" || return
+while (( $# )); do
+ case $1 in
+ -a|--aaa+RPAR() ...; shift ;; # handle -a
+ -b|--bbb+RPAR() ...; shift ;; # handle -b
+ -c|--ccc+RPAR() ...; shift 2 ;; # handle -c and arg
+ --+RPAR() ...; shift; break ;; # end of options
+ esac
+done
+# handle operands)
+
+It can also be called as a stand-alone script from other shells
+using the more traditional print-and-eval pattern:
+
+example(args=$( zgetopt -n myscript -o abc: -l aaa,bbb,ccc: -- "$@" ) || return
+eval set -- "$args"
+while [ $# -ne 0 ]; do ...; done)
+
+Options:
+
+startsitem()
+sitem(tt(-A var(array)))(When called as a function, assign the parsed
+arguments to the named array var(array). Defaults to tt(argv), which
+overwrites the caller's positional parameters. Has no meaning when
+called as a script, in which case the parsed and quoted arguments are
+always printed to standard output. An empty string forces the
+printing behaviour in either mode.)
+sitem(tt(-l var(spec)))(Specify long options to recognise when
+parsing. These should be given using just the option name (no
+dashes), suffixed by `tt(:)' or `tt(::)' if it takes a mandatory or
+optional argument respectively. Multiple options can be defined
+either by separating them by commas or by supplying -l again.
+Example: tt(-l foo,bar: -l baz))
+sitem(tt(-n var(name)))(Specify the name to use in the error message
+if argument parsing fails. Defaults to the name of the nearest
+calling function or the base name of tt($ZSH_ARGZERO). Note that
+errors related to the usage of tt(zgetopt) itself are always reported
+as coming from tt(zgetopt).)
+sitem(tt(-o var(spec)))(Specify short options to recognise when
+parsing. These should be given as a single string, in the same format
+used by the tt(getopts) built-in or the tt(getopt+LPAR()3+RPAR())
+library function, again using `tt(:)' or `tt(::)' to indicate a
+mandatory or optional argument. The spec may be prefixed with `tt(+)'
+to indicate that option parsing should stop at the first non-option
+argument (equivalent to setting the environment variable
+tt(POSIXLY_CORRECT)). Example: tt(-o ab:cd::))
+endsitem()
+
+At least one of tt(-o) or tt(-l) must be given. The function's own
+options should be followed by zero or more arguments to parse. It is
+critical that these be separated explicitly by `tt(--)', as in the
+above examples, to ensure that the function can accurately
+distinguish the arguments it's meant to parse from its own.
+
+Refer to the manual for util-linux's tt(getopt+LPAR()1+RPAR()) for
+more information about the way arguments are parsed and results are
+returned. Note however that this function is not intended to be a
+complete re-implementation. In particular: it omits all
+portability/compatibility features, it doesn't support the
+tt(--alternative) option, and it doesn't support abbreviating long
+options.
+)
item(tt(zkbd))(
See subref(Keyboard Definition)(above).
)
diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index 0cefaf7d1..cbdaddead 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -663,7 +663,7 @@ item(tt(${)var(name)tt(::=)var(word)tt(}))(
In the first form, if var(name) is unset then set it to var(word); in the
second form, if var(name) is unset or null then set it to var(word); and
in the third form, unconditionally set var(name) to var(word). In all
-forms, the value of the parameter is then substituted.
+forms, the value of var(name) is then substituted.
)
xitem(tt(${)var(name)tt(?)var(word)tt(}))
item(tt(${)var(name)tt(:?)var(word)tt(}))(
@@ -1699,7 +1699,7 @@ are not the same as the flags used within parameter substitutions.
At the outermost level of substitution, the `tt((P))' flag (rule tt(4.))
ignores these transformations and uses the unmodified value of the
parameter as the name to be replaced. This is usually the desired
-behavior because padding may make the value syntactically illegal as a
+behavior because padding may make the value syntactically invalid as a
parameter name, but if capitalization changes are desired, use the
tt(${${(P)foo}}) form (rule tt(25.)).
)
diff --git a/Doc/Zsh/grammar.yo b/Doc/Zsh/grammar.yo
index e75e66a6c..8dbfd1164 100644
--- a/Doc/Zsh/grammar.yo
+++ b/Doc/Zsh/grammar.yo
@@ -531,7 +531,6 @@ itemiz(Execution of incorrectly positioned loop control structures
(tt(continue), tt(break)))
itemiz(Attempts to use regular expression with no regular expression
module available)
-itemiz(Disallowed operations when the tt(RESTRICTED) options is set)
itemiz(Failure to create a pipe needed for a pipeline)
itemiz(Failure to create a multio)
itemiz(Failure to autoload a module needed for a declared shell feature)
diff --git a/Doc/Zsh/invoke.yo b/Doc/Zsh/invoke.yo
index 9c589b278..b6ed73fe5 100644
--- a/Doc/Zsh/invoke.yo
+++ b/Doc/Zsh/invoke.yo
@@ -105,8 +105,6 @@ can be stacked after the `tt(-b)' and will take effect as normal.
startmenu()
menu(Compatibility)
-menu(Restricted Shell)
endmenu()
includefile(Zsh/compat.yo)
-includefile(Zsh/restricted.yo)
diff --git a/Doc/Zsh/manual.yo b/Doc/Zsh/manual.yo
index 8cbe2cfd2..6dcec0063 100644
--- a/Doc/Zsh/manual.yo
+++ b/Doc/Zsh/manual.yo
@@ -49,6 +49,7 @@ menu(Functions Index)
menu(Editor Functions Index)
menu(Style and Tag Index)
+startdetailmenu()
--- The Detailed Node Listing ---
Introduction
@@ -64,7 +65,6 @@ menu(See Also)
Invocation
menu(Compatibility)
-menu(Restricted Shell)
Shell Grammar
@@ -111,6 +111,7 @@ menu(Zle Widgets)
menu(User-Defined Widgets)
menu(Standard Widgets)
menu(Character Highlighting)
+menu(Cursor Shape and Color)
Completion Widgets
@@ -177,6 +178,7 @@ menu(Mathematical Functions)
menu(User Configuration Functions)
menu(Other Functions)
+enddetailmenu()
endmenu()
texinode(The Z Shell Manual)(Introduction)(Top)(Top)
chapter(The Z Shell Manual)
diff --git a/Doc/Zsh/mod_nearcolor.yo b/Doc/Zsh/mod_nearcolor.yo
index df7771397..ef565fff3 100644
--- a/Doc/Zsh/mod_nearcolor.yo
+++ b/Doc/Zsh/mod_nearcolor.yo
@@ -23,10 +23,14 @@ it will be compared against each of the available colours and the
closest will be selected. The first sixteen colours are never matched in
this process due to being unpredictable.
-It isn't possible to reliably detect support for true colour in the
-terminal emulator. It is therefore recommended to be selective in
-loading the tt(zsh/nearcolor) module. For example, the following
-checks the tt(COLORTERM) environment variable:
+The use of a hex triplet will automatically load the tt(zsh/nearcolor)
+module if the terminal doesn't support 24-bit colour. This behaviour can
+be modified via the tt(.term.extensions) parameter DASH()- see
+sectref(Terminal Extensions)(zshzle).
+
+The module can also be loaded manually. It is recommended to be
+selective in doing so. For example, the following checks the
+tt(COLORTERM) environment variable:
example([[ $COLORTERM = *LPAR()24bit|truecolor+RPAR()* ]] || \
zmodload zsh/nearcolor)
diff --git a/Doc/Zsh/mod_pcre.yo b/Doc/Zsh/mod_pcre.yo
index 41fab4475..8458145dd 100644
--- a/Doc/Zsh/mod_pcre.yo
+++ b/Doc/Zsh/mod_pcre.yo
@@ -66,18 +66,26 @@ while [[ $? -eq 0 ]] do
pcre_match -b -n $b[2] -- $string
done
print -l $accum)
-)
-enditem()
-
-If the regular expression contains callouts, these are executed as shell code.
-During the execution of the callout, the string the regular expression is
-matching against is available in the parameter tt(.pcre.subject). If there is a
-non-zero return status from the shell code, the callout does not match.
The option tt(-d) uses the alternative breadth-first DFA search algorithm of
pcre. This sets tt(match), or the array given with tt(-a), to all the matches
found from the same start point in the subject.
+If the regular expression contains string callouts, these are executed as
+shell code, while numerical callouts are ignored. During the execution of the
+callout, the string the regular expression is matching against is available
+in the parameter tt(.pcre.subject). The parameter tt(.pcre.pos) contains the
+position in that string that is currently being matched against. If there is
+a non-zero return status from the shell code, the callout does not match. Note
+that callouts are not available in the below -pcre-match test condition. It is
+also likely not a good idea to call any pcre related builtins from a callout. As
+an example, the following will print out `tt(bar)':
+
+example(pcre_compile 'foo+LPAR()?C"echo ${.pcre.subject[${.pcre.pos},-1]}"+RPAR()'
+pcre_match foobar)
+)
+enditem()
+
The tt(zsh/pcre) module makes available the following test condition:
startitem()
diff --git a/Doc/Zsh/mod_random.yo b/Doc/Zsh/mod_random.yo
index d797ca381..3bd904d42 100644
--- a/Doc/Zsh/mod_random.yo
+++ b/Doc/Zsh/mod_random.yo
@@ -24,22 +24,24 @@ Returns a random floating point number between 0 and 1 inclusive.
enditem()
startitem()
-item(tt(zrand_int)+LPAR()tt(upper), tt(lower), tt(inclusive)RPAR()) (
-Returns a random integer between tt(lower) and tt(upper). All parameters are
-optional. If none are specified it is equivalent to
-tt(SRANDOM).
+item(tt(zrand_int)+LPAR()var(upper), var(lower), var(inclusive)RPAR()) (
+Returns a random integer between var(lower) and var(upper). All parameters
+are optional. If none are specified it is equivalent to tt(SRANDOM). Note
+that this is equivalent to passing the default values except that it
+is inclusive.
-tt(upper) is the upper bound on the resultant number and defaults to
-4,294,967,295.
+var(upper) is the upper bound on the resultant number and defaults to
+4,294,967,295. It is exclusive by default, unless var(inclusive) is passed.
-tt(lower) is the lower bound and defaults to 0.
+var(lower) is the lower bound and defaults to 0.
The defaults of these two arguments are also the maximum and minimum to which
either can be set.
-tt(inclusive) is a flag that controls whether the result is ever equal to
-tt(upper). By default it is not. If this argument is set to a non-zero value
-then it may be.
+var(inclusive) is a flag that controls whether the var(upper) bound is
+exclusive or inclusive. Passing any non-zero value makes it inclusive,
+otherwise it is exclusive when the var(upper) bound is specified. The
+var(lower) bound is always inclusive.
This is to facilitate a construct like tt($a[zrand_int+LPAR()$#a+RPAR()+1]) rather
than tt($a[zrand_int+LPAR()$#a-1+RPAR()+1]).
@@ -50,7 +52,7 @@ be an array index range error for it to also potentially return 16 ($#a). You
could, however, use the construct tt(zrand_int+LPAR()16,1,1+RPAR()) instead of
adding 1 to achieve the same result, but it is more verbose.
-Most statistics algorithms seem to also expect 0 to tt(upper)-1, so this was
+Most statistics algorithms seem to also expect 0 to var(upper)-1, so this was
deemed the most commonly desired case and chosen as the default.
)
enditem()
diff --git a/Doc/Zsh/mod_socket.yo b/Doc/Zsh/mod_socket.yo
index 78d9254e8..2c699b1d1 100644
--- a/Doc/Zsh/mod_socket.yo
+++ b/Doc/Zsh/mod_socket.yo
@@ -7,7 +7,7 @@ startitem()
findex(zsocket)
cindex(sockets)
cindex(sockets, Unix domain)
-item(tt(zsocket) [ tt(-altv) ] [ tt(-d) var(fd) ] [ var(args) ])(
+item(tt(zsocket) [ tt(-alstv) ] [ tt(-d) var(fd) ] [ var(args) ])(
tt(zsocket) is implemented as a builtin to allow full use of shell
command line editing, file I/O, and job control mechanisms.
)
@@ -33,6 +33,11 @@ File descriptors can be closed with normal shell syntax when no longer
needed, for example:
example(exec {REPLY}>&-)
+
+The tt(zsocket -s var(fd)) command may also be used to shut down a
+socket fd before closing it. This will send an EOF to the other side,
+while this side can still read their subsequent response before closing
+the connection fully, for example.
)
enditem()
diff --git a/Doc/Zsh/mod_tcp.yo b/Doc/Zsh/mod_tcp.yo
index d19e8cc92..5dd1d5da1 100644
--- a/Doc/Zsh/mod_tcp.yo
+++ b/Doc/Zsh/mod_tcp.yo
@@ -7,7 +7,7 @@ startitem()
findex(ztcp)
cindex(TCP)
cindex(sockets, TCP)
-item(tt(ztcp) [ tt(-acflLtv) ] [ tt(-d) var(fd) ] [ var(args) ])(
+item(tt(ztcp) [ tt(-acflLstv) ] [ tt(-d) var(fd) ] [ var(args) ])(
tt(ztcp) is implemented as a builtin to allow full use of shell
command line editing, file I/O, and job control mechanisms.
@@ -24,7 +24,7 @@ startitem()
item(File descriptor)(
The file descriptor in use for the connection. For normal inbound (tt(I))
and outbound (tt(O)) connections this may be read and written by the usual
-shell mechanisms. However, it should only be close with `tt(ztcp -c)'.
+shell mechanisms. However, it should only be closed with `tt(ztcp -c)'.
)
item(Connection type)(
A letter indicating how the session was created:
@@ -42,6 +42,9 @@ An inbound connection accepted with `tt(ztcp -a)'.
item(tt(O))(
An outbound connection created with `tt(ztcp) var(host) var(...)'.
)
+item(tt(S))(
+A connection that has been shut down with `tt(ztcp -s)'.
+)
enditem()
)
@@ -122,6 +125,24 @@ subsect(Closing Connections)
cindex(sockets, closing TCP)
startitem()
+item(tt(ztcp) tt(-s) var(fd))(
+tt(ztcp -s) will shut down the socket associated
+with var(fd). This means a graceful termination
+of the connection is initiated, flushing unsent
+data (due to Nagle's algorithm, for example). To
+complete it, you should also drain any remaining
+data on the fd by reading it. Afterwards you should
+use tt(ztcp -c) to close the fd. If you close it
+without first using tt(ztcp -s) and draining the
+data, the kernel may reset the connection, causing
+data you sent to not be received by the other end.
+
+Note that this is only useful for inbound and
+outbound connections, not for listening sockets.
+)
+enditem()
+
+startitem()
xitem(tt(ztcp) tt(-cf) [ tt(-v) ] [ var(fd) ])
item(tt(ztcp) tt(-c) [ tt(-v) ] [ var(fd) ])(
tt(ztcp -c) will close the socket associated
@@ -129,6 +150,8 @@ with var(fd). The socket will be removed from the
session table. If var(fd) is not specified,
tt(ztcp) will close everything in the session table.
+See also the previous tt(ztcp -s) entry.
+
Normally, sockets registered by zftp (see
sectref(The zsh/zftp Module)(zshmodules))
cannot be closed this way. In order
@@ -166,6 +189,8 @@ prints `tt(This is a message)'.
To tidy up, on tt(host1):
example(ztcp -c $listenfd
+ztcp -s $fd
ztcp -c $fd)
and on tt(host2)
-example(ztcp -c $fd)
+example(ztcp -s $fd
+ztcp -c $fd)
diff --git a/Doc/Zsh/mod_watch.yo b/Doc/Zsh/mod_watch.yo
index 06ab3cbea..df477a770 100644
--- a/Doc/Zsh/mod_watch.yo
+++ b/Doc/Zsh/mod_watch.yo
@@ -40,7 +40,8 @@ vindex(WATCHFMT)
item(tt(WATCHFMT))(
The format of login/logout reports if the tt(watch) parameter is set.
Default is `tt(%n has %a %l from %m)'.
-Recognizes the following escape sequences:
+Recognizes the following escape sequences, many of which are described
+further in sectref(Simple Prompt Escapes)(zshmisc):
startitem()
item(tt(%n))(
@@ -71,6 +72,10 @@ Start (stop) using a different foreground color.
item(tt(%K{)var(color)tt(}) LPAR()tt(%k)RPAR())(
Start (stop) using a different background color.
)
+item(tt(%H{)var(group)tt(}))(
+Change all character visual attributes using a highlighting
+specification from the tt(.zle.hlgroups) associative array.
+)
item(tt(%S) LPAR()tt(%s)RPAR())(
Start (stop) standout mode.
)
diff --git a/Doc/Zsh/mod_zpty.yo b/Doc/Zsh/mod_zpty.yo
index 599b9e6d2..b0b5fdf20 100644
--- a/Doc/Zsh/mod_zpty.yo
+++ b/Doc/Zsh/mod_zpty.yo
@@ -30,10 +30,13 @@ and tt(syswrite) is em(not) recommended; use tt(zpty -r) and tt(zpty -w)
unless you know exactly what you are doing.
)
item(tt(zpty) tt(-d) [ var(name) ... ])(
-The second form, with the tt(-d) option, is used to delete commands
-previously started, by supplying a list of their var(name)s. If no
-var(name) is given, all commands are deleted. Deleting a command causes
-the HUP signal to be sent to the corresponding process.
+The tt(-d) option is used to delete commands previously started, by
+supplying a list of their var(name)s. If no var(name) is given, all
+commands are deleted. Deleting a command causes the HUP signal to be sent
+to the corresponding process. It is not a good idea to use this form in a
+subshell, as it will kill the command but leave the parent shell confused
+about the state, and it may try to kill another process that re-used the
+process ID.
)
item(tt(zpty) tt(-w) [ tt(-n) ] var(name) [ var(string) ... ])(
The tt(-w) option can be used to send the to command var(name) the given
@@ -82,9 +85,10 @@ when the command has exited: the return value is zero if at least
one character could still be read even if the pattern failed to match.
)
item(tt(zpty) tt(-t) var(name))(
-The tt(-t) option without the tt(-r) option can be used to test
-whether the command var(name) is still running. It returns a zero
-status if the command is running and a non-zero value otherwise.
+The tt(-t) option without the tt(-r) option can be used to test whether the
+command var(name) is still running. It returns a zero status if the command
+is running and a non-zero value otherwise. Note that this does not indicate
+whether or not any output is available to read.
)
item(tt(zpty) [ tt(-L) ])(
The last form, without any arguments, is used to list the commands
diff --git a/Doc/Zsh/mod_zutil.yo b/Doc/Zsh/mod_zutil.yo
index 06b953f69..11fe8a073 100644
--- a/Doc/Zsh/mod_zutil.yo
+++ b/Doc/Zsh/mod_zutil.yo
@@ -158,11 +158,13 @@ var(pattern) matches at least one of the strings in the value.
enditem()
)
findex(zformat)
-xitem(tt(zformat -f) var(param) var(format) var(spec) ...)
-xitem(tt(zformat -F) var(param) var(format) var(spec) ...)
+xitem(tt(zformat -f) [ tt(-qQ) ] ] var(param) var(format) var(spec) ...)
+xitem(tt(zformat -F) [ tt(-qQ) ] ] var(param) var(format) var(spec) ...)
item(tt(zformat -a) var(array) var(sep) var(spec) ...)(
-This builtin provides different forms of formatting. The first form
-is selected with the tt(-f) option. In this case the var(format)
+This builtin provides different forms of formatting.
+
+The first form is selected with the tt(-f) option.
+In this case the var(format)
string will be modified by replacing sequences starting with a percent
sign in it with strings from the var(spec)s. Each var(spec) should be
of the form `var(char)tt(:)var(string)' which will cause every
@@ -176,9 +178,21 @@ width makes the result be padded with spaces to the right if the
var(string) is shorter than the requested width. Padding to the left
can be achieved by giving a negative minimum field width. If a maximum
field width is specified, the var(string) will be truncated after that
-many characters. After all `tt(%)' sequences for the given var(spec)s
-have been processed, the resulting string is stored in the parameter
-var(param).
+many characters.
+
+The var(char) in each var(spec) may optionally be preceded by an
+escaping indicator, either `tt(%)' to explicitly enable the
+var(spec)-escaping behaviour of tt(-q) described below, or `tt(%%)' to
+explicitly disable it. The default behaviour is to em(not) escape specs.
+
+Any `tt(%)' sequence in tt(format) that does not match a given var(spec)
+(or one of the special sequences described below) is output as-is. If
+desired, these sequences may be processed by a second round of
+formatting, by prompt expansion, etc. DASH()- see also tt(-q).
+
+The sequence `tt(%%)' can be used to produce a literal tt(%).
+After all `tt(%)' sequences have been processed, the resulting string is
+stored in the parameter var(param).
The tt(%)-escapes also understand ternary expressions in the form used by
prompts. The tt(%) is followed by a `tt(LPAR())' and then an ordinary
@@ -207,11 +221,42 @@ expression.
With tt(-F) instead of tt(-f), ternary expressions choose between the
`true' or `false' text on the basis of whether the format specifier is
-present and non-empty. A test number indicates a minimum width for the
-value given in the format specifier. Negative numbers reverse this,
-so the test is for whether the value exceeds a maximum width.
+present and non-empty. If a test number is provided, it tests the width
+of the value given in the format specifier DASH()- with a positive
+number the condition is true when the width is em(greater than) that
+number, and with a negative number the condition is true when the width
+is em(less than or equal to) the absolute value of that number.
+
+With tt(-q), `tt(%)' characters in the var(spec)s are escaped by default
+as they are inserted into the formatted string, and pre-escaped `tt(%)' and
+`tt(RPAR())` characters in the format string are left as they are. For
+example:
+
+example(zformat -qF REPLY '%%foo%% %B%d%b' d:%bar%)
+
+outputs `tt(%%foo%% %B%%bar%%%b)' to tt(REPLY). This is useful when the
+formatted string will undergo further expansion DASH()- in this example
+the tt(%B)...tt(%b) sequences could be used with prompt expansion to
+produce bold text. One notable use case is formatting a description to
+be passed to tt(compadd -x) in a completion function.
+
+Since the output with tt(-q) is expected to be subject to further
+processing, width specifiers don't count the extra escape characters,
+ensuring that the widths are correct em(after) that processing.
+Additionally, with tt(-F), ternary-expression test numbers are compared
+against the em(pre-escaped) spec lengths.
+
+tt(-Q) is like tt(-q) except that it interprets pre-escaped `tt(%)' and
+`tt(RPAR())` characters in the format string as normal.
-The form, using the tt(-a) option, can be used for aligning
+The optional escaping indicator can be used to exempt individual
+var(spec)s from escaping as described above. For example:
+
+example(zformat -qF REPLY '%d %D' d:%foo% %%D:%bar%)
+
+outputs `tt(%%foo%% %bar%)' to tt(REPLY).
+
+The form using the tt(-a) option can be used for aligning
strings. Here, the var(spec)s are of the form
`var(left)tt(:)var(right)' where `var(left)' and `var(right)' are
arbitrary strings. These strings are modified by replacing the colons
@@ -230,7 +275,7 @@ item(tt(zregexparse))(
This implements some internals of the tt(_regex_arguments) function.
)
findex(zparseopts)
-item(tt(zparseopts) [ tt(-D) tt(-E) tt(-F) tt(-G) tt(-K) tt(-M) ] [ tt(-a) var(array) ] [ tt(-A) var(assoc) ] [ tt(-v) var(argv) ] [ tt(-) ] var(spec) ...)(
+item(tt(zparseopts) [ tt(-DEFGKM) ] [ tt(-a) var(array) ] [ tt(-A) var(assoc) ] [ tt(-n) var(name) ] [ tt(-v) var(argv) ] [ tt(-) ] var(spec) ...)(
This builtin simplifies the parsing of options in positional parameters,
i.e. the set of arguments given by tt($*). Each var(spec) describes one
option and must be of the form `var(opt)[tt(=)var(array)]'. If an option
@@ -239,7 +284,11 @@ into the var(array) specified with the tt(-a) option; if the optional
`tt(=)var(array)' is given, it is instead copied into that array, which
should be declared as a normal array and never as an associative array.
-Note that it is an error to give any var(spec) without an
+At least one var(spec) must be given. If a single spec is given which
+is either an empty string or a single hyphen (as in
+tt(zparseopts -DF '')), it signifies that no options are recognised.
+(This is useful for future-proofing functions that might gain options
+later.) Otherwise, it is an error to give any var(spec) without an
`tt(=)var(array)' unless one of the tt(-a) or tt(-A) options is used.
Unless the tt(-E) option is given, parsing stops at the first string
@@ -298,10 +347,11 @@ ambiguities may arise when at least one overlapping var(spec) takes an
argument, as in `tt(-foo: -foobar)'. In that case, the last matching
var(spec) wins. (This is not an issue with GNU-style parsing.)
-The options of tt(zparseopts) itself cannot be stacked because, for
-example, the stack `tt(-DEK)' is indistinguishable from a var(spec) for
-the GNU-style long option `tt(-)tt(-DEK)'. The options of tt(zparseopts)
-itself are:
+In order to distinguish GNU-style long option var(spec)s from
+tt(zparseopts)'s own options, they em(must) be preceded by a `tt(-)',
+`tt(--)', or short option tt(spec), as in tt(zparseopts -Ga opts - -foo).
+
+The options of tt(zparseopts) itself are:
startitem()
item(tt(-a) var(array))(
@@ -386,11 +436,20 @@ item(tt(-M))(
This changes the assignment rules to implement a map among equivalent
option names. If any var(spec) uses the `tt(=)var(array)' form, the
string var(array) is interpreted as the name of another var(spec),
-which is used to choose where to store the values. If no other var(spec)
+which is used to choose where to store the values.
+Values stored in an associative array (tt(-A)) use the name of the
+mapped-to option, whereas values stored in an array use the last
+as-given option name. If no other var(spec)
is found, the values are stored as usual. This changes only the way the
values are stored, not the way tt($*) is parsed, so results may be
unpredictable if the `var(name)tt(+)' specifier is used inconsistently.
)
+item(tt(-n) var(name))(
+If this option is given, var(name) is used when printing usage errors
+intended for the end user. Otherwise, the name of the calling function
+or script is used. Error messages arising from misusage of tt(zparseopts)
+itself are not affected by this option.
+)
item(tt(-v) var(argv))(
With this option, the elements of the named array var(argv) are used as the
positional parameters to parse, rather than those given by tt($*). The
@@ -433,4 +492,12 @@ to have the effect of
example(foo=(-a)
bar=(-a '' -b xyz))
)
+
+The following is a useful general-purpose pattern:
+
+example(local -A opts
+zparseopts -DFGA opts - x -long: || return
+(( $+opts[-x] )) && ... # handle -x
+(( $+opts[--long] )) && ... # handle --long, optarg in $opts[--long]
+)
enditem()
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index a7e862c70..6f3bef189 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -240,7 +240,7 @@ pindex(AUTONAMEDIRS)
pindex(NOAUTONAMEDIRS)
cindex(directories, named)
item(tt(AUTO_NAME_DIRS))(
-Any parameter that is set to the absolute name of a directory
+Any global parameter that is set to the absolute name of a directory
immediately becomes a name for that directory, that will be used
by the `tt(%~)'
and related prompt sequences, and will be available when completion
@@ -1194,7 +1194,7 @@ This option is only used if the option tt(CLOBBER) is not set: note that
it is set by default.
If this option is set, then regular files of zero length may be
-ovewritten (`clobbered'). Note that it is possible another process
+overwritten (`clobbered'). Note that it is possible another process
has written to the file between this test and use of the file by
the current process. This option should therefore not be used in
cases where files to be clobbered may be written to asynchronously.
@@ -1837,8 +1837,8 @@ pindex(NOLOCALOPTIONS)
item(tt(LOCAL_OPTIONS) <K>)(
If this option is set at the point of return from a shell function,
most options (including this one) which were in force upon entry to
-the function are restored; options that are not restored are
-tt(PRIVILEGED) and tt(RESTRICTED). Otherwise, only this option,
+the function are restored; the tt(PRIVILEGED) option is not restored.
+Otherwise, only this option,
and the tt(LOCAL_LOOPS), tt(XTRACE) and tt(PRINT_EXIT_VALUE) options are
restored. Hence if this is explicitly unset by a shell function the
other options in force at the point of return will remain so.
@@ -2255,13 +2255,12 @@ Furthermore, functions and shell builtins are not executed after
an tt(exec) prefix; the command to be executed must be an external
command found in the path.
-Furthermore, the tt(getopts) builtin behaves in a POSIX-compatible
-fashion in that the associated variable tt(OPTIND) is not made
-local to functions, and its value is calculated differently to match
-other shells.
-
Moreover, the warning and special exit code from
tt([[ -o )var(non_existent_option)tt( ]]) are suppressed.
+
+Other builtins may be affected as described in
+ifzman(zmanref(zshbuiltins))\
+ifnzman(noderef(Shell Builtin Commands)).
)
pindex(POSIX_IDENTIFIERS)
pindex(NO_POSIX_IDENTIFIERS)
@@ -2466,16 +2465,6 @@ tt(-m) option of tt(setopt) and tt(unsetopt), and changing it inside a
function always changes it globally regardless of the tt(LOCAL_OPTIONS)
option.
)
-pindex(RESTRICTED)
-pindex(NO_RESTRICTED)
-pindex(NORESTRICTED)
-cindex(restricted shell)
-item(tt(RESTRICTED) (tt(-r)))(
-Enables restricted mode. This option cannot be changed using
-tt(unsetopt), and setting it inside a function always changes it
-globally regardless of the tt(LOCAL_OPTIONS) option. See
-sectref(Restricted Shell)(zsh).
-)
pindex(SHIN_STDIN)
pindex(NO_SHIN_STDIN)
pindex(SHINSTDIN)
diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index ecedc3862..a4dd1a2ca 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -1082,7 +1082,7 @@ Code specified by the tt(-c) option to the command line that invoked
the shell.
)
item(tt(cmdsubst))(
-Command substitution using of the tt(`)var(...)tt(`),
+Command substitution using the tt(`)var(...)tt(`),
tt($+LPAR())var(...)tt(RPAR()), tt(${{)var(name)tt(}) var(...)tt(}),
tt(${|)var(...)tt(}), or tt(${ )var(...)tt( }) constructs.
)
@@ -1115,13 +1115,19 @@ item(tt(globsort))(
Code executed to order files by the tt(o) glob qualifier.
)
item(tt(insubst))(
-The tt(<LPAR())var(...)tt(RPAR()) form of process substitution.
+The tt(>LPAR())var(...)tt(RPAR()) form of process substitution.
)
item(tt(loadautofunc))(
Code read directly from a file to define an autoloaded function.
)
+item(tt(math))(
+Code executed in the tt($+LPAR()LPAR())var(...)tt(RPAR()RPAR()) or
+tt(LPAR()LPAR())var(...)tt(RPAR()RPAR()) constructs,
+by the tt(let) builtin, in an array subscript, or in
+another arithmetic context.
+)
item(tt(outsubst))(
-The tt(>LPAR())var(...)tt(RPAR()) form of process substitution.
+The tt(<LPAR())var(...)tt(RPAR()) form of process substitution.
)
item(tt(sched))(
Code executed by the tt(sched) builtin.
@@ -1175,6 +1181,9 @@ the argument passed to the option. Otherwise it is not set.
vindex(ZSH_EXEPATH)
item(tt(ZSH_EXEPATH))(
Full pathname of the executable file of the current zsh process.
+This value should be accurate on Linux, macOS, FreeBSD, DragonflyBSD,
+NetBSD, Solaris, Cygwin, and their derivatives. On other systems, it is
+determined from tt(argv[0]), which is not always accurate.
)
vindex(ZSH_NAME)
item(tt(ZSH_NAME))(
@@ -1256,6 +1265,12 @@ vindex(COLUMNS)
item(tt(COLUMNS) <S>)(
The number of columns for this terminal session.
Used for printing select lists and for the line editor.
+If the shell is non-interactive and a legal value is imported from the
+environment, it is preserved. Otherwise, the value is reset on start-up
+and in response to certain events such as the receipt of a tt(SIGWINCH)
+signal. Explicitly setting it to an illegal value such as tt(0) also
+resets it. (Unsetting the parameter does not have this effect; it
+simply `hides' the value that the shell is tracking internally.)
)
vindex(CORRECT_IGNORE)
item(tt(CORRECT_IGNORE))(
@@ -1462,6 +1477,7 @@ vindex(LINES)
item(tt(LINES) <S>)(
The number of lines for this terminal session.
Used for printing select lists and for the line editor.
+See tt(COLUMNS).
)
vindex(LISTMAX)
item(tt(LISTMAX))(
diff --git a/Doc/Zsh/restricted.yo b/Doc/Zsh/restricted.yo
deleted file mode 100644
index a84fd28ea..000000000
--- a/Doc/Zsh/restricted.yo
+++ /dev/null
@@ -1,84 +0,0 @@
-texinode(Restricted Shell)()(Compatibility)(Invocation)
-sect(Restricted Shell)
-cindex(restricted shell)
-pindex(RESTRICTED)
-When the basename of the command used to invoke zsh starts with the letter
-`tt(r)' or the `tt(-r)' command line option is supplied at invocation, the
-shell becomes restricted. Emulation mode is determined after stripping the
-letter `tt(r)' from the invocation name. The following are disabled in
-restricted mode:
-
-startitemize()
-itemiz(changing directories with the tt(cd) builtin)
-itemiz(changing or unsetting the tt(EGID), tt(EUID), tt(GID),
-tt(HISTFILE), tt(HISTSIZE), tt(IFS), tt(LD_AOUT_LIBRARY_PATH),
-tt(LD_AOUT_PRELOAD), tt(LD_LIBRARY_PATH), tt(LD_PRELOAD),
-tt(MODULE_PATH), tt(module_path), tt(PATH), tt(path), tt(SHELL),
-tt(UID) and tt(USERNAME) parameters)
-itemiz(specifying command names containing tt(/))
-itemiz(specifying command pathnames using tt(hash))
-itemiz(redirecting output to files)
-itemiz(using the tt(exec) builtin command to replace the shell with another
-command)
-itemiz(using tt(jobs -Z) to overwrite the shell process' argument and
-environment space)
-itemiz(using the tt(ARGV0) parameter to override tt(argv[0]) for external
-commands)
-itemiz(turning off restricted mode with tt(set +r) or tt(unsetopt
-RESTRICTED))
-enditemize()
-
-These restrictions are enforced after processing the startup files. The
-startup files should set up tt(PATH) to point to a directory of commands
-which can be safely invoked in the restricted environment. They may also
-add further restrictions by disabling selected builtins.
-
-Restricted mode can also be activated any time by setting the
-tt(RESTRICTED) option. This immediately enables all the restrictions
-described above even if the shell still has not processed all startup
-files.
-
-A shell em(Restricted Mode) is an outdated way to restrict what users may
-do: modern systems have better, safer and more reliable ways to
-confine user actions, such as em(chroot jails), em(containers) and
-em(zones).
-
-A restricted shell is very difficult to implement safely. The feature
-may be removed in a future version of zsh.
-
-It is important to realise that the restrictions only apply to the shell,
-not to the commands it runs (except for some shell builtins). While a
-restricted shell can only run the restricted list of commands accessible
-via the predefined `tt(PATH)' variable, it does not prevent those
-commands from running any other command.
-
-As an example, if `tt(env)' is among the list of em(allowed) commands,
-then it allows the user to run any command as `tt(env)' is not a shell
-builtin command and can run arbitrary executables.
-
-So when implementing a restricted shell framework it is important to be
-fully aware of what actions each of the em(allowed) commands or features
-(which may be regarded as em(modules)) can perform.
-
-Many commands can have their behaviour affected by environment
-variables. Except for the few listed above, zsh does not restrict
-the setting of environment variables.
-
-If a `tt(perl)', `tt(python)', `tt(bash)', or other general purpose
-interpreted script is treated as a restricted
-command, the user can work around the restriction by
-setting specially crafted `tt(PERL5LIB)', `tt(PYTHONPATH)',
-`tt(BASH_ENV)' (etc.) environment variables. On GNU systems, any
-command can be made to run arbitrary code when performing character set
-conversion (including zsh itself) by setting a `tt(GCONV_PATH)'
-environment variable. Those are only a few examples.
-
-Bear in mind that, contrary to some other shells, `tt(readonly)' is not a
-security feature in zsh as it can be undone and so cannot be used to
-mitigate the above.
-
-A restricted shell only works if the allowed commands are few
-and carefully written so as not to grant more access to users than
-intended. It is also important to restrict what zsh module the user may
-load as some of them, such as `tt(zsh/system)', `tt(zsh/mapfile)' and
-`tt(zsh/files)', allow bypassing most of the restrictions.
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 8c1cd078d..761bd5bc4 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -56,6 +56,7 @@ menu(User-Defined Widgets)
menu(Standard Widgets)
menu(Terminal Extensions)
menu(Character Highlighting)
+menu(Cursor Shape and Color)
endmenu()
texinode(Keymaps)(Zle Builtins)()(Zsh Line Editor)
@@ -2636,7 +2637,7 @@ as by adding `tt(-cursor)' to disable cursor shape and color changing.
When ZLE starts, it will add entries for features that were auto-detected. This
auto-detection uses extensions itself, all named with a `tt(query)' prefix. As
-this happens when ZLE starts disabling them needs to be done early in the
+this happens when ZLE starts, disabling them needs to be done early in the
startup files. A value of `tt(-query)' will disable all terminal queries on
startup, including those that query terminal properties such as colors rather
than detecting features. Populating the array with the status of auto-detected
@@ -2712,7 +2713,7 @@ termcap and the tt(COLORTERM) environment variable.
)
enditem()
-texinode(Character Highlighting)()(Terminal Extensions)(Zsh Line Editor)
+texinode(Character Highlighting)(Cursor Shape and Color)(Terminal Extensions)(Zsh Line Editor)
sect(Character Highlighting)
vindex(zle_highlight, setting)
@@ -2977,8 +2978,8 @@ special array parameter tt(region_highlight); see
ifnzman(noderef(Zle Widgets))\
ifzman(above).
-texinode(Cursor Shape and Color)()()(Character Highlighting)
-subsect(Cursor Shape and Color)
+texinode(Cursor Shape and Color)()(Character Highlighting)(Zsh Line Editor)
+sect(Cursor Shape and Color)
cindex(cursor shape)
cindex(cursor color)
diff --git a/Doc/help/.cvsignore b/Doc/help/.cvsignore
deleted file mode 100644
index 0751b2579..000000000
--- a/Doc/help/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-[_a-zA-Z0-9]*
diff --git a/Doc/intro.ms b/Doc/intro.ms
index 49f6cc07f..60aa01a19 100644
--- a/Doc/intro.ms
+++ b/Doc/intro.ms
@@ -1,12 +1,12 @@
.nr PI 0
.nr LL 6.5i
.if \n(.g \{\
-.if "\*(.T"ascii" .ftr C R
-.if "\*(.T"latin1" .ftr C R
+.if "\*(.T"ascii" .ftr CR R
+.if "\*(.T"latin1" .ftr CR R
.if "\*(.T"html" .nr HTML 1
.nr De \n[.ss]
.\}
-.\" ----- macro defintions -----
+.\" ----- macro definitions -----
.\" Ds/De: start/end of example
.\" Sh: section header
.\" XXX: It seems we can't use the same definition for both pdf and html
@@ -16,7 +16,7 @@
.ie \n[HTML] \{\
.de Ds
.DS I .5i
-.ft C
+.ft CR
..
.de De
.DE
@@ -31,7 +31,7 @@
.el \{\
.de Ds
.DS I .5i
-.ft C
+.ft CR
.ps 9
.vs 11
.ss 11
@@ -47,6 +47,7 @@
.de Sh
.NH
.XN \\$1
+.pdfbookmark 1 \\*[SN-DOT] \\$1
..
.\}
.\"
@@ -104,11 +105,11 @@ The text will frequently mention options that you can set to change
the behaviour of \fBzsh\fP. You can set these options with the
command
.Ds
-%\0setopt\0\fIoptionname\fC
+%\0setopt\0\fIoptionname\f(CR
.De
and unset them again with
.Ds
-%\0unsetopt\0\fIoptionname\fC
+%\0unsetopt\0\fIoptionname\f(CR
.De
Case is ignored in option names, as are embedded underscores.
.Sh "Filename Generation"
@@ -134,7 +135,7 @@ foo.c\0\0q.c
.De
Also, if the \fIEXTENDEDGLOB\fP option is set,
some new features are activated.
-For example, the \fC^\fP character negates the pattern following it:
+For example, the \f(CR^\fP character negates the pattern following it:
.Ds
%\0setopt\0extendedglob
%\0ls\0-d\0^*.c
@@ -152,7 +153,7 @@ file.pro\0\0\0foo.o\0\0\0\0\0\0main.o\0\0\0\0\0q.c\0\0\0\0\0\0\0\0run234\0\0\0\0
\&.rhosts\0\0\0bar.o\0\0\0\0\0file.h\0\0\0\0file.pro\0\0foo.o\0\0\0\0\0main.h\0\0\0\0main.o
.De
An expression of the form
-\fC<\fIx\fR\-\fIy\fC>\fR
+\f(CR<\fIx\fR\-\fIy\f(CR>\fR
matches a range of integers:
.Ds
%\0ls\0run<200-300>
@@ -167,7 +168,7 @@ run303
run123\0\0run2\0\0\0\0run234\0\0run240\0\0run303
.De
The \fINUMERICGLOBSORT\fP option will sort files with numbers
-according to the number. This will not work with \fCls\fP as it
+according to the number. This will not work with \f(CRls\fP as it
resorts its arguments:
.Ds
%\0setopt\0numericglobsort
@@ -181,7 +182,7 @@ bar.o\0\0foo.c\0\0foo.o
%\0ls\0*.(c|o|pro)
bar.o\0\0\0\0\0file.pro\0\0foo.c\0\0\0\0\0foo.o\0\0\0\0\0main.o\0\0\0\0q.c
.De
-Also, the string \fC**/\fP forces a recursive search of
+Also, the string \f(CR**/\fP forces a recursive search of
subdirectories:
.Ds
%\0ls\0-R
@@ -213,8 +214,8 @@ stuff/xxx/foobar\0\0stuff/yyy/frobar
.De
.PP
It is possible to exclude certain files from the patterns using
-the ~ character. A pattern of the form \fC*.c~bar.c\fP lists all
-files matching \fC*.c\fP, except for the file \fCbar.c\fP.
+the ~ character. A pattern of the form \f(CR*.c~bar.c\fP lists all
+files matching \f(CR*.c\fP, except for the file \f(CRbar.c\fP.
.Ds
%\0ls\0*.c
foo.c\0\0\0\0foob.c\0\0\0\0bar.c
@@ -228,7 +229,7 @@ One can add a number of \fIqualifiers\fP to the end of
any of these patterns, to restrict matches to certain
file types. A qualified pattern is of the form
.DS
-\fIpattern\fC(\fR...\fC)\fR
+\fIpattern\f(CR(\fR...\f(CR)\fR
.De
with single-character qualifiers inside the parentheses.
.Ds
@@ -253,12 +254,12 @@ bar.o\0\0\0\0\0\0\0foo*\0\0\0\0\0\0\0\0link@\0\0\0\0\0\0\0morestuff/\0\0run123\0
file.h\0\0\0\0\0\0foo.c\0\0\0\0\0\0\0main.h\0\0\0\0\0\0pipe\0\0\0\0\0\0\0\0run2\0\0\0\0\0\0\0\0run303
file.pro\0\0\0\0foo.o\0\0\0\0\0\0\0main.o\0\0\0\0\0\0q.c\0\0\0\0\0\0\0\0\0run234\0\0\0\0\0\0stuff/
.De
-Note that \fC*(x)\fP and \fC*(*)\fP both match executables.
-\fC*(X)\fP matches files executable by others, as opposed to
-\fC*(x)\fP, which matches files executable by the owner.
-\fC*(R)\fP and \fC*(r)\fP match readable files;
-\fC*(W)\fP and \fC*(w)\fP, which checks for writable files.
-\fC*(W)\fP is especially important, since it checks for world-writable
+Note that \f(CR*(x)\fP and \f(CR*(*)\fP both match executables.
+\f(CR*(X)\fP matches files executable by others, as opposed to
+\f(CR*(x)\fP, which matches files executable by the owner.
+\f(CR*(R)\fP and \f(CR*(r)\fP match readable files;
+\f(CR*(W)\fP and \f(CR*(w)\fP, which checks for writable files.
+\f(CR*(W)\fP is especially important, since it checks for world-writable
files:
.Ds
%\0l\0*(w)
@@ -273,12 +274,12 @@ lrwxrwxrwx\0\01\0pfalstad\0\0\0\0\0\0\010\0May\023\018:12\0link\0->\0/usr/bin/
.De
If you want to have all the files of a certain type as well as all
symbolic links pointing to files of that type, prefix the qualifier
-with a \fC-\fP:
+with a \f(CR-\fP:
.Ds
%\0l\0*(-/)
link@\0\0\0\0\0\0\0morestuff/\0\0stuff/
.De
-You can filter out the symbolic links with the \fC^\fP character:
+You can filter out the symbolic links with the \f(CR^\fP character:
.Ds
%\0l\0*(W^@)
run240
@@ -287,7 +288,7 @@ foo*\0\0\0\0\0\0\0\0link@\0\0\0\0\0\0\0morestuff/\0\0stuff/
%\0l\0*(x^@/)
foo*
.De
-To find all plain files, you can use \fC.\fP:
+To find all plain files, you can use \f(CR.\fP:
.Ds
%\0l\0*(.)
Makefile\0\0file.h\0\0\0\0foo*\0\0\0\0\0\0foo.o\0\0\0\0\0main.o\0\0\0\0run123\0\0\0\0run234\0\0\0\0run303
@@ -301,8 +302,8 @@ pipe
%\0l\0-l\0*(p)
prw-r--r--\0\01\0pfalstad\0\0\0\0\0\0\0\00\0May\023\018:12\0pipe
.De
-\fC*(U)\fP matches all files owned by you.
-To search for all files not owned by you, use \fC*(^U)\fP:
+\f(CR*(U)\fP matches all files owned by you.
+To search for all files not owned by you, use \f(CR*(^U)\fP:
.Ds
%\0l\0-l\0*(^U)
-rw-------\0\01\0subbarao\0\0\0\0\0\0\029\0May\023\018:13\0sub
@@ -331,30 +332,30 @@ If \fBZDOTDIR\fP is not set, then the value of \fBHOME\fP is used;
this is the usual case.
.\".KE <--- missing .KS or .KF above
.PP
-\&\fC.zshenv\fP is sourced on all invocations of the shell,
-unless the \fC-f\fP option is set. It should contain commands to set
+\&\f(CR.zshenv\fP is sourced on all invocations of the shell,
+unless the \f(CR-f\fP option is set. It should contain commands to set
the command search path, plus other important environment
variables.
-\&\fC.zshenv\fP should not contain commands that produce output
+\&\f(CR.zshenv\fP should not contain commands that produce output
or assume the shell is attached to a tty.
.PP
-\&\fC.zshrc\fP is sourced in interactive shells. It should contain
+\&\f(CR.zshrc\fP is sourced in interactive shells. It should contain
commands to set up aliases, functions, options, key bindings, etc.
.PP
-\&\fC.zlogin\fP is sourced in login shells. It should contain
+\&\f(CR.zlogin\fP is sourced in login shells. It should contain
commands that should be executed only in login shells.
-\&\fC.zlogout\fP is sourced when login shells exit.
-\&\fC.zprofile\fP is similar to \fC.zlogin\fP, except that it is sourced before
-\&\fC.zshrc\fP.
-\&\fC.zprofile\fP is meant as an alternative to \fC.zlogin\fP for
+\&\f(CR.zlogout\fP is sourced when login shells exit.
+\&\f(CR.zprofile\fP is similar to \f(CR.zlogin\fP, except that it is sourced before
+\&\f(CR.zshrc\fP.
+\&\f(CR.zprofile\fP is meant as an alternative to \f(CR.zlogin\fP for
ksh fans;
the two are not intended to be used together, although this
could certainly be done if desired.
-\&\fC.zlogin\fP is not the place for alias definitions, options, environment
+\&\f(CR.zlogin\fP is not the place for alias definitions, options, environment
variable settings, etc.;
as a general rule, it should not change the shell environment
at all. Rather, it should be used to set the terminal type
-and run a series of external commands (\fCfortune\fP, \fCmsgs\fP, etc).
+and run a series of external commands (\f(CRfortune\fP, \f(CRmsgs\fP, etc).
.Sh "Shell Functions"
.PP
\fBzsh\fP also allows you to create your own commands by defining shell
@@ -367,7 +368,7 @@ functions. For example:
pfalstad:*:3564:35:Paul\0John\0Falstad:/u/pfalstad:/usr/princeton/bin/zsh
.De
This function looks up a user in the NIS password map.
-The \fC$1\fP expands to the first argument to \fCyp\fP.
+The \f(CR$1\fP expands to the first argument to \f(CRyp\fP.
The function could have been equivalently defined in one of the following
ways:
.Ds
@@ -411,8 +412,8 @@ pfalstad:*:3564:35:Paul\0John\0Falstad:/u/pfalstad:/usr/princeton/bin/zsh
subbarao:*:3338:35:Kartik\0Subbarao:/u/subbarao:/usr/princeton/bin/zsh
sukthnkr:*:1267:35:Rahul\0Sukthankar:/u/sukthnkr:/usr/princeton/bin/tcsh
.De
-The \fCfor i\fP loops through each of the function's arguments,
-setting \fCi\fP equal to each of them in turn.
+The \f(CRfor i\fP loops through each of the function's arguments,
+setting \f(CRi\fP equal to each of them in turn.
We can also make the function do something sensible
if no arguments are given:
.Ds
@@ -427,9 +428,9 @@ usage:\0yp\0name\0...
pfalstad:*:3564:35:Paul\0John\0Falstad:/u/pfalstad:/usr/princeton/bin/zsh
sukthnkr:*:1267:35:Rahul\0Sukthankar:/u/sukthnkr:/usr/princeton/bin/tcsh
.De
-\fC$#\fP is the number of arguments supplied to the function.
+\f(CR$#\fP is the number of arguments supplied to the function.
If it is equal to zero, we print a usage message; otherwise,
-we loop through the arguments, and \fCypmatch\fP all of them.
+we loop through the arguments, and \f(CRypmatch\fP all of them.
.\".KE <--- missing .KS or .KF above
.PP
Here's a function that selects a random line from a file:
@@ -448,16 +449,16 @@ SunOS\0Release\04.1.1\0(PHOENIX)\0#19:\0Tue\0May\014\019:03:15\0EDT\01991
%
.De
-\fCrandline\fP has a local variable, \fCz\fP, that holds the number of
-lines in the file. \fC$[RANDOM % z + 1]\fP expands to a random number
-between 1 and \fCz\fP. An expression of the form \fC$[\fR...\fC]\fR
+\f(CRrandline\fP has a local variable, \f(CRz\fP, that holds the number of
+lines in the file. \f(CR$[RANDOM % z + 1]\fP expands to a random number
+between 1 and \f(CRz\fP. An expression of the form \f(CR$[\fR...\f(CR]\fR
expands to the value of the arithmetic expression within the brackets,
and the \fBRANDOM\fP variable returns a random number each time it
-is referenced. \fC%\fP is the modulus operator, as in C.
-Therefore, \fCsed -n $[RANDOM%z+1]p\fP picks a random line from its
-input, from 1 to \fCz\fP.
+is referenced. \f(CR%\fP is the modulus operator, as in C.
+Therefore, \f(CRsed -n $[RANDOM%z+1]p\fP picks a random line from its
+input, from 1 to \f(CRz\fP.
.PP
-Function definitions can be viewed with the \fCfunctions\fP builtin:
+Function definitions can be viewed with the \f(CRfunctions\fP builtin:
.Ds
%\0functions\0randline
randline\0()\0{
@@ -507,12 +508,12 @@ Note that this could also have been implemented as an alias:
-rwxr-xr-x\0\01\0pfalstad\0\0\0\0\0\0\029\0May\024\004:38\0foo
.De
.PP
-Instead of defining a lot of functions in your \fC.zshrc\fP,
+Instead of defining a lot of functions in your \f(CR.zshrc\fP,
all of which you may not use,
-it is often better to use the \fCautoload\fP builtin.
+it is often better to use the \f(CRautoload\fP builtin.
The idea is, you create a directory where function
definitions are stored, declare the names in
-your \fC.zshrc\fP, and tell the shell where to look for them.
+your \f(CR.zshrc\fP, and tell the shell where to look for them.
Whenever you reference a function, the shell
will automatically load it into memory.
.Ds
@@ -536,7 +537,7 @@ yp\0()\0{
\0\0\0\0\0\0\0\0ypmatch\0$1\0passwd.byname
}
.De
-This idea has other benefits. By adding a \fC#!\fP header
+This idea has other benefits. By adding a \f(CR#!\fP header
to the files, you can make them double as shell scripts.
(Although it is faster to use them as functions, since a
separate process is not created.)
@@ -556,7 +557,7 @@ ypmatch\0$1\0passwd.byname
sukthnkr:*:1267:35:Rahul\0Sukthankar:/u/sukthnkr:/usr/princeton/bin/tcsh
.De
Now other people, who may not use \fBzsh\fP, or who don't want to
-copy all of your \fC.zshrc\fP, may use these functions as shell
+copy all of your \f(CR.zshrc\fP, may use these functions as shell
scripts.
.Sh "Directories"
.PP
@@ -568,7 +569,7 @@ phoenix%\0PROMPT='%~>\0'
~/src>
.De
the shell will print the current directory in the prompt,
-using the \fC~\fP character.
+using the \f(CR~\fP character.
However, \fBzsh\fP is smarter than most other shells in this respect:
.Ds
~/src>\0cd\0~subbarao
@@ -584,10 +585,10 @@ However, \fBzsh\fP is smarter than most other shells in this respect:
~foo/news/nntp/inews>
.De
Note that \fBzsh\fP prints \fIother\fP users' directories
-in the form \fC~user\fP. Also note that you can
+in the form \f(CR~user\fP. Also note that you can
set a parameter and use it as a directory name;
-\fBzsh\fP will act as if \fCfoo\fP is a user
-with the login directory \fC/usr/princeton/common/src\fP.
+\fBzsh\fP will act as if \f(CRfoo\fP is a user
+with the login directory \f(CR/usr/princeton/common/src\fP.
This is convenient, especially if you're sick of seeing
prompts like this:
.Ds
@@ -601,10 +602,10 @@ directory a short name, like this:
/usr/princeton/common/src/news/nntp/inews
~inews>
.De
-When you reference a directory in the form \fC~inews\fP,
+When you reference a directory in the form \f(CR~inews\fP,
the shell assumes that you want the directory displayed
-in this form; thus simply typing \fCecho ~inews\fP or
-\fCcd ~inews\fP causes the prompt to be shortened.
+in this form; thus simply typing \f(CRecho ~inews\fP or
+\f(CRcd ~inews\fP causes the prompt to be shortened.
You can define a shell function for this purpose:
.Ds
~inews>\0namedir\0()\0{\0$1=$PWD\0;\0\0:\0~$1\0}
@@ -615,25 +616,25 @@ You can define a shell function for this purpose:
~spool>\0cd\0.msgs
~spool/.msgs>
.De
-You may want to add this one-line function to your \fC.zshrc\fP.
+You may want to add this one-line function to your \f(CR.zshrc\fP.
\fBzsh\fP can also put the current directory in your title bar,
if you are using a windowing system.
-One way to do this is with the \fCchpwd\fP function, which is
+One way to do this is with the \f(CRchpwd\fP function, which is
automatically executed by the shell whenever you change
directory. If you are using xterm, this will work:
.Ds
chpwd\0()\0{\0print\0-Pn\0'^[]2;%~^G'\0}
.De
-The \fC-P\fP option tells \fCprint\fP to treat its arguments like a prompt
-string; otherwise the \fC%~\fP would not be expanded.
-The \fC-n\fP option suppresses the terminating newline, as with \fCecho\fP.
+The \f(CR-P\fP option tells \f(CRprint\fP to treat its arguments like a prompt
+string; otherwise the \f(CR%~\fP would not be expanded.
+The \f(CR-n\fP option suppresses the terminating newline, as with \f(CRecho\fP.
.PP
-If you are using an IRIS \fCwsh\fP, do this:
+If you are using an IRIS \f(CRwsh\fP, do this:
.Ds
chpwd\0()\0{\0print\0-Pn\0'\e2201.y%~\e234'\0}
.De
-The \fCprint -D\fP command has other uses. For example, to
+The \f(CRprint -D\fP command has other uses. For example, to
print the current directory to standard output in short form,
you can do this:
.Ds
@@ -648,8 +649,8 @@ and to print each component of the path in short form:
.Sh "Directory Stacks"
.PP
If you use csh, you may know about directory stacks.
-The \fCpushd\fP command puts the current directory on the
-stack, and changes to a new directory; the \fCpopd\fP command
+The \f(CRpushd\fP command puts the current directory on the
+stack, and changes to a new directory; the \f(CRpopd\fP command
pops a directory off the stack and changes to it.
.Ds
phoenix%\0cd\0
@@ -670,7 +671,7 @@ Z\0/etc>\0popd\0
/tmp\0~
.De
\fBzsh\fP's directory stack commands work similarly. One
-difference is the way \fCpushd\fP is handled if no arguments
+difference is the way \f(CRpushd\fP is handled if no arguments
are given. As in csh, this exchanges the top two elements
of the directory stack:
.Ds
@@ -725,15 +726,15 @@ by setting a few more options and parameters:
/tmp>\0cd\0-4
~>
.De
-Note that \fC~2\fP expanded to the second directory in the
-history list, and that \fCcd -3\fP recalled the third
+Note that \f(CR~2\fP expanded to the second directory in the
+history list, and that \f(CRcd -3\fP recalled the third
directory in the list.
.PP
You may be wondering what all those options do.
-\fIAUTOPUSHD\fP made \fCcd\fP act like \fCpushd\fP.
-(\fCalias cd=pushd\fP is not sufficient, for various reasons.)
-\fIPUSHDMINUS\fP swapped the meaning of \fCcd +1\fP and
-\fCcd -1\fP; we want them to mean the opposite of what they mean in csh,
+\fIAUTOPUSHD\fP made \f(CRcd\fP act like \f(CRpushd\fP.
+(\f(CRalias cd=pushd\fP is not sufficient, for various reasons.)
+\fIPUSHDMINUS\fP swapped the meaning of \f(CRcd +1\fP and
+\f(CRcd -1\fP; we want them to mean the opposite of what they mean in csh,
because it makes more sense in this scheme, and it's easier to type:
.Ds
~>\0dh
@@ -754,7 +755,7 @@ because it makes more sense in this scheme, and it's easier to type:
/usr/pub>
.De
\fIPUSHDSILENT\fP keeps the shell from printing
-the directory stack each time we do a \fCcd\fP,
+the directory stack each time we do a \f(CRcd\fP,
and \fIPUSHDTOHOME\fP we mentioned earlier:
.Ds
/usr/pub>\0unsetopt\0pushdsilent
@@ -793,10 +794,10 @@ from getting too large, much like \fIHISTSIZE\fP:
.PP
Command substitution in \fBzsh\fP can take two forms.
In the traditional form, a command enclosed in
-backquotes (\fC`\fP...\fC`\fP) is replaced on the command line with its output.
+backquotes (\f(CR`\fP...\f(CR`\fP) is replaced on the command line with its output.
This is the form used by the older shells.
Newer shells (like \fBzsh\fP) also provide another form,
-\fC$(\fR...\fC)\fR. This form is much easier to nest.
+\f(CR$(\fR...\f(CR)\fR. This form is much easier to nest.
.Ds
%\0ls\0-l\0`echo\0/vmunix`
-rwxr-xr-x\0\01\0root\0\0\0\0\0\01209702\0May\014\019:04\0/vmunix
@@ -832,7 +833,7 @@ crw-rw-rw-\0\01\0root\0\0\0\0\0\020,\0\028\0May\023\018:35\0/dev/ttyqc
%\0ls\0-l\0=rn
-rwxr-xr-x\0\01\0root\0\0\0\0\0\0\0172032\0Mar\0\06\018:40\0/usr/princeton/bin/rn
.De
-A command name with a \fC=\fP prepended is replaced with its full
+A command name with a \f(CR=\fP prepended is replaced with its full
pathname. This can be very convenient. If it's not convenient
for you, you can turn it off:
.Ds
@@ -857,11 +858,11 @@ subbarao\0ttyt7\0\0\0May\023\015:02\0\0\0(mad55sx15.Prince)
subbarao\0ttyu6\0\0\0May\023\015:04\0\0\0(mad55sx15.Prince)
shgchan\0\0ttyvb\0\0\0May\023\016:51\0\0\0(gaudi.Princeton.)
.De
-A command of the form \fC=(\fR...\fC)\fR is replaced with the name of a \fIfile\fP
+A command of the form \f(CR=(\fR...\f(CR)\fR is replaced with the name of a \fIfile\fP
containing its output. (A command substitution, on the other
hand, is replaced with the output itself.)
-\fCprint -l\fP is like \fCecho\fP, excepts that it prints its arguments
-one per line, the way \fCfgrep\fP expects them:
+\f(CRprint -l\fP is like \f(CRecho\fP, excepts that it prints its arguments
+one per line, the way \f(CRfgrep\fP expects them:
.Ds
%\0print\0-l\0foo\0bar
foo
@@ -929,26 +930,26 @@ when the command is finished.
---
>\0strfile*
.De
-If you read \fBzsh\fP's man page, you may notice that \fC<(\fR...\fC)\fR
+If you read \fBzsh\fP's man page, you may notice that \f(CR<(\fR...\f(CR)\fR
is another form of process substitution which is similar to
-\fC=(\fR...\fC)\fR.
+\f(CR=(\fR...\f(CR)\fR.
There is an important difference between the two.
-In the \fC<(\fR...\fC)\fR case, the shell creates a named pipe (FIFO)
+In the \f(CR<(\fR...\f(CR)\fR case, the shell creates a named pipe (FIFO)
instead of a file. This is better, since it does not
fill up the file system; but it does not work in all cases.
-In fact, if we had replaced \fC=(\fR...\fC)\fR with \fC<(\fR...\fC)\fR in
+In fact, if we had replaced \f(CR=(\fR...\f(CR)\fR with \f(CR<(\fR...\f(CR)\fR in
the examples above, all of them would have stopped working
-except for \fCfgrep -f <(\fR...\fC)\fR.
+except for \f(CRfgrep -f <(\fR...\f(CR)\fR.
You can not edit a pipe, or open it as a mail folder;
-\fCfgrep\fP, however, has no problem with reading
+\f(CRfgrep\fP, however, has no problem with reading
a list of words from a pipe.
-You may wonder why \fCdiff <(foo) bar\fP doesn't work, since
-\fCfoo | diff - bar\fP works; this is because \fCdiff\fP creates
+You may wonder why \f(CRdiff <(foo) bar\fP doesn't work, since
+\f(CRfoo | diff - bar\fP works; this is because \f(CRdiff\fP creates
a temporary file if it notices that one of its arguments
-is \fC-\fP, and then copies its standard input to the temporary
+is \f(CR-\fP, and then copies its standard input to the temporary
file.
.PP
-\fC>(\fR...\fC)\fR is just like \fC<(\fR...\fC)\fR except that the
+\f(CR>(\fR...\f(CR)\fR is just like \f(CR<(\fR...\f(CR)\fR except that the
command between the parentheses will get its input from the named
pipe.
.Ds
@@ -978,13 +979,13 @@ too, works with pipes.
.Ds
%\0cut\0-d:\0-f1\0/etc/passwd\0|\0sort\0<newnames
.De
-The sort will get as its standard input first the output of \fCcut\fP
-and then the contents of \fCnewnames\fP.
+The sort will get as its standard input first the output of \f(CRcut\fP
+and then the contents of \f(CRnewnames\fP.
.PP
Suppose you would like to watch the standard output of a command on
your terminal, but want to pipe the standard error to another command.
An easy way to do this in \fBzsh\fP is by redirecting the standard
-error using \fC2> >(\fR...\fC)\fR.
+error using \f(CR2> >(\fR...\f(CR)\fR.
.Ds
%\0find\0/\0-name\0games\02>\0>(grep\0-v\0'Permission'\0>\0realerrors)
.De
@@ -1056,8 +1057,8 @@ nicecolors\0\0etc/\0\0\0\0\0\0\0\0scr/\0\0\0\0\0\0\0\0tmp/\0\0\0\0\0\0\0\0iris/\
%\0nrable
Mailboxes/\0\0mail/\0\0\0\0\0\0\0notes
.De
-(The pattern \fC*(R)\fP matches all readable files in the current
-directory, and \fC*(^R)\fP matches all unreadable files.)
+(The pattern \f(CR*(R)\fP matches all readable files in the current
+directory, and \f(CR*(^R)\fP matches all unreadable files.)
.PP
Most other shells have aliases of this kind (\fIcommand\fP aliases).
However, \fBzsh\fP also has \fIglobal\fP aliases, which are substituted
@@ -1082,8 +1083,8 @@ Connected\0to\0wuarchive.wustl.edu.
Here are some more interesting uses.
.Ds
%\0alias\0-g\0M='|\0more'\0GF='|\0fgrep\0-f\0~/.friends'
-%\0who\0M\0\0\0#\0\fIpipes\0the\0output\0of\0\fCwho\fI\0through\0\fCmore
-%\0who\0GF\0\0#\0\fIsee\0if\0your\0friends\0are\0on\fC
+%\0who\0M\0\0\0#\0\fIpipes\0the\0output\0of\0\f(CRwho\fI\0through\0\f(CRmore
+%\0who\0GF\0\0#\0\fIsee\0if\0your\0friends\0are\0on\f(CR
%\0w\0GF\0\0\0\0#\0\fIsee\0what\0your\0friends\0are\0doing
.De
Another example makes use of \fBzsh\fP's process substitution.
@@ -1092,13 +1093,13 @@ If you run NIS, and you miss being able to do this:
%\0grep\0pfalstad\0/etc/passwd
.De
you can define an alias that will seem more natural
-than \fCypmatch pfalstad passwd\fP:
+than \f(CRypmatch pfalstad passwd\fP:
.Ds
%\0alias\0-g\0PASS='<(ypcat\0passwd)'
%\0grep\0pfalstad\0PASS
pfalstad:*:3564:35:Paul\0John\0Falstad:/u/pfalstad:/usr/princeton/bin/zsh
.De
-If you're really crazy, you can even call it \fC/etc/passwd\fP:
+If you're really crazy, you can even call it \f(CR/etc/passwd\fP:
.Ds
%\0alias\0-g\0/etc/passwd='<(ypcat\0passwd)'
%\0grep\0pfalstad\0/etc/passwd
@@ -1106,13 +1107,13 @@ pfalstad:*:3564:35:Paul\0John\0Falstad:/u/pfalstad:/usr/princeton/bin/zsh
.De
The last example shows one of the perils of global aliases;
they have a lot of potential to cause confusion.
-For example, if you defined a global alias called \fC|\fP (which is
+For example, if you defined a global alias called \f(CR|\fP (which is
possible), \fBzsh\fP would begin to act very strangely; every pipe
symbol would be replaced with the text of your alias.
To some extent, global aliases are like macros in C;
discretion is advised in using them and in choosing names for them.
Using names in all caps is not a bad idea, especially
-for aliases which introduce shell metasyntax (like \fCM\fP and \fCGF\fP
+for aliases which introduce shell metasyntax (like \f(CRM\fP and \f(CRGF\fP
above).
.PP
Note that \fBzsh\fP aliases are not like csh aliases. The syntax for
@@ -1123,12 +1124,12 @@ For example, if you try:
alias\0rm\0mv\0'\e!*\0/tmp/wastebasket'
.De
no aliases will be defined, but \fBzsh\fP will not report an error.
-In csh, this line defines an alias that makes \fCrm\fP safe---files
-that are \fCrm\fP'd will be moved to a temporary directory instead of
+In csh, this line defines an alias that makes \f(CRrm\fP safe---files
+that are \f(CRrm\fP'd will be moved to a temporary directory instead of
instantly destroyed. In \fBzsh\fP's syntax, however, this line asks
-the shell to print any existing alias definitions for \fCrm\fP,
-\fCmv\fP, or \fC!*\ /tmp/wastebasket\fP. Since there are none, most
-likely, the shell will not print anything, although \fCalias\fP will
+the shell to print any existing alias definitions for \f(CRrm\fP,
+\f(CRmv\fP, or \f(CR!*\ /tmp/wastebasket\fP. Since there are none, most
+likely, the shell will not print anything, although \f(CRalias\fP will
return a nonzero exit code. The proper syntax is this:
.Ds
alias\0rm='mv\0\e!*\0/tmp/wastebasket'
@@ -1138,7 +1139,7 @@ However, this won't work either:
%\0rm\0foo.dvi
zsh:\0no\0matches\0found:\0!*
.De
-While this makes \fCrm\fP safe, it is certainly not what the user
+While this makes \f(CRrm\fP safe, it is certainly not what the user
intended. In \fBzsh\fP, you must use a shell function for this:
.Ds
%\0unalias\0rm
@@ -1167,35 +1168,35 @@ on\0()\0{\0last\0-2\0$1\0;\0who\0|\0grep\0$1\0}
.De
The first two aliases were converted to regular \fBzsh\fP aliases, while
the third, since it needed to handle arguments, was converted to
-a function. \fCc2z\fP can convert most aliases to \fBzsh\fP format without
+a function. \f(CRc2z\fP can convert most aliases to \fBzsh\fP format without
any problems. However, if you're using some really arcane csh tricks,
-or if you have an alias with a name like \fCdo\fP (which is reserved
+or if you have an alias with a name like \f(CRdo\fP (which is reserved
in \fBzsh\fP), you may have to fix some of the aliases by hand.
.PP
-The \fCc2z\fP script checks your csh setup, and produces a list
+The \f(CRc2z\fP script checks your csh setup, and produces a list
of \fBzsh\fP commands which replicate your aliases and parameter settings
as closely as possible. You could include its output in your
-startup file, \fC.zshrc\fP.
+startup file, \f(CR.zshrc\fP.
.Sh "History"
.PP
There are several ways to manipulate history in \fBzsh\fP.
-One way is to use csh-style \fC!\fP history:
+One way is to use csh-style \f(CR!\fP history:
.Ds
%\0/usr/local/bin/!:0\0!-2*:s/foo/bar/\0>>!$
.De
If you don't want to use this, you can turn it off
-by typing \fCsetopt nobanghist\fP. If you are afraid of accidentally
+by typing \f(CRsetopt nobanghist\fP. If you are afraid of accidentally
executing the wrong command you can set the \fIHISTVERIFY\fP option.
If this option is set, commands that result from history expansion
will not be executed immediately, but will be put back into the editor
buffer for further consideration.
.PP
-If you're not familiar with \fC!\fP history, here follows some
-explanation. History substitutions always start with a \fC!\fP,
-commonly called \*Qbang\*U. After the \fC!\fP comes an (optional)
+If you're not familiar with \f(CR!\fP history, here follows some
+explanation. History substitutions always start with a \f(CR!\fP,
+commonly called \*Qbang\*U. After the \f(CR!\fP comes an (optional)
designation of which \*Qevent\*U (command) to use, then a colon, and
then a designation of what word of that command to use. For example,
-\fC!-\fIn\fR refers to the command \fIn\fP commands ago.
+\f(CR!-\fIn\fR refers to the command \fIn\fP commands ago.
.Ds
%\0ls
foo\0\0bar
@@ -1207,7 +1208,7 @@ baz\0\0bam
No word designator was used, which means that the whole command
referred to was repeated. Note that the shell will echo the result of
the history substitution. The word designator can, among other
-things, be a number indicating the argument to use, where \fC0\fP is
+things, be a number indicating the argument to use, where \f(CR0\fP is
the command.
.Ds
%\0/usr/bin/ls\0foo
@@ -1217,13 +1218,13 @@ foo
bar
.De
In this example, no event designator was used, which tells \fBzsh\fP
-to use the previous command. A \fC$\fP specifies the last argument
+to use the previous command. A \f(CR$\fP specifies the last argument
.Ds
%\0mkdir\0/usr/local/lib/emacs/site-lisp/calc
%\0cd\0!:$
cd\0/usr/local/lib/emacs/site-lisp/calc
.De
-If you use more words of the same command, only the first \fC!\fP
+If you use more words of the same command, only the first \f(CR!\fP
needs an event designator.
.Ds
%\0make\0prig\0>>\0make.log
@@ -1240,7 +1241,7 @@ behaviour, set the \fICSHJUNKIEHISTORY\fP option.
%\0!-2:0\0prog2\0>>\0!:$
make\0prog2\0>>\0cshjunkiehistory
.De
-Another way to use history is to use the \fCfc\fP command. For
+Another way to use history is to use the \f(CRfc\fP command. For
example, if you type an erroneous command:
.Ds
%\0for\0i\0in\0`cat\0/etc/clients`\0
@@ -1252,9 +1253,9 @@ zsh:\0command\0not\0found:\0rpu
zsh:\0command\0not\0found:\0rpu
\&\fR...
.De
-typing \fCfc\fP will execute an editor on this command, allowing
-you to fix it. (The default editor is \fCvi\fP, by the way,
-not \fCed\fP).
+typing \f(CRfc\fP will execute an editor on this command, allowing
+you to fix it. (The default editor is \f(CRvi\fP, by the way,
+not \f(CRed\fP).
.Ds
%\0fc
49
@@ -1277,7 +1278,7 @@ for\0i\0in\0`cat\0/etc/clients`\0
\0\0\0\0\0\0bonnet\0\0\0\0up\0\02\0days,\021:18,\0\0\0\0load\0average:\00.93,\00.80,\00.50
\&\fR...
.De
-A variant of the \fCfc\fP command is \fCr\fP, which redoes the last
+A variant of the \f(CRfc\fP command is \f(CRr\fP, which redoes the last
command, with optional changes:
.Ds
%\0echo\0foo
@@ -1296,10 +1297,10 @@ bar
.PP
\fBzsh\fP's command line editor, \fBZLE\fP, is quite powerful.
It is designed to emulate either emacs or vi; the default
-is emacs. To set the bindings for vi mode, type \fCbindkey -v\fP. If
+is emacs. To set the bindings for vi mode, type \f(CRbindkey -v\fP. If
your \fBEDITOR\fP or \fBVISUAL\fP environment variable is vi,
\fBzsh\fP will use vi emulation by default. You can then switch to
-emacs mode with \fCbindkey -e\fP.
+emacs mode with \f(CRbindkey -e\fP.
.PP
In addition to basic editing, the shell allows you to
recall previous lines in the history. In emacs mode,
@@ -1312,15 +1313,15 @@ Mailboxes\0\0\0bin\0\0\0\0\0\0\0\0\0func\0\0\0\0\0\0\0\0nicecolors\0\0scr\0\0\0\
News\0\0\0\0\0\0\0\0etc\0\0\0\0\0\0\0\0\0iris\0\0\0\0\0\0\0\0notes\0\0\0\0\0\0\0src
%\0echo\0foobar
foobar
-%\0\fI^P\fC
-%\0echo\0foobar\fI^P\fC
+%\0\fI^P\f(CR
+%\0echo\0foobar\fI^P\f(CR
%\0ls\0~_
.De
-Pressing \fI^P\fP once brings up the previous line (\fCecho foobar\fP);
-pressing it again brings up the line before that (\fCls ~\fP).
+Pressing \fI^P\fP once brings up the previous line (\f(CRecho foobar\fP);
+pressing it again brings up the line before that (\f(CRls ~\fP).
The cursor is left at the end of the line, allowing you to
edit the line if desired before executing it.
-In many cases, \fBZLE\fP eliminates the need for the \fCfc\fP command,
+In many cases, \fBZLE\fP eliminates the need for the \f(CRfc\fP command,
since it is powerful enough to handle even multiline commands:
.Ds
%\0for\0i\0in\0a\0b\0c\0d\0e
@@ -1332,7 +1333,7 @@ b
c
d
e
-%\0\fI^P\fC
+%\0\fI^P\f(CR
%\0for\0i\0in\0a\0b\0c\0d\0e\0
\0do\0
\0echo\0$i\0
@@ -1362,13 +1363,13 @@ Also, you can search the history for a certain command using
(part of the) word at the beginning of the current line. Hitting
\fIESC-P\fP another time gets you the command before that, etc.
.Ds
-%\0set\0\fIESC-P\fC
-%\0setopt\0autolist\0\fIESC-P\fC
+%\0set\0\fIESC-P\f(CR
+%\0setopt\0autolist\0\fIESC-P\f(CR
%\0setopt\0nocorrect_
.De
Another way is to do an incremental search, emacs-style:
.Ds
-%\0\fI^R\fC
+%\0\fI^R\f(CR
%\0_
i-search:
@@ -1380,16 +1381,16 @@ i-search:\0le
.De
Suppose you have retrieved an old history event in one of these ways
and would like to execute several consecutive old commands starting
-with this one. \fC^O\fP will execute the current command and then put
+with this one. \f(CR^O\fP will execute the current command and then put
the next command from the history into the editor buffer. Typing
-\fC^O\fP several times will therefore reexecute several consecutive
+\f(CR^O\fP several times will therefore reexecute several consecutive
commands from the history. Of course, you can edit some of those
commands in between.
.PP
In addition to completion (see below), \fITAB\fP performs expansion if
possible.
.Ds
-%\0ls\0*.c\fITAB\fC
+%\0ls\0*.c\fITAB\f(CR
%\0ls\0foofile.c\0fortune.c\0rnd.c\0strfile.c\0unstr.c_
.De
For example, suppose you have a bunch of weird files in an important
@@ -1399,26 +1400,26 @@ directory:
\0\0*\0*\0*\0\0\0\0\0\0\0;\0&\0%\0$??foo\0\0dspfok\0\0\0\0\0\0\0\0foo.c
\0\0!"foo"!\0\0\0\0\0\0\0`\0\e\0`\0\0\0\0\0\0\0\0\0foo\0\0\0\0\0\0\0\0\0\0\0rrr
.De
-You want to remove them, but you don't want to damage \fCfoo.c\fP.
+You want to remove them, but you don't want to damage \f(CRfoo.c\fP.
Here is one way to do this:
.Ds
-%\0rm\0*\fITAB\fC
+%\0rm\0*\fITAB\f(CR
%\0rm\0\e\0\e\0\e*\e\0\e*\e\0\e*\e\0\e\0\e\0\0\e!\e"foo\e"\e!\0\e;\e\0\e&\e\0%\e\0\e$'
''
'foo\0\e`\e\0\e\e\e\0\e`\0dspfok\0foo\0foo.c\0rrr_
.De
-When you expand \fC*\fP, \fBzsh\fP inserts the names of all the files
+When you expand \f(CR*\fP, \fBzsh\fP inserts the names of all the files
into the editing buffer, with proper shell quoting.
-Now, just move back and remove \fCfoo.c\fP from the buffer:
+Now, just move back and remove \f(CRfoo.c\fP from the buffer:
.Ds
%\0rm\0\e\0\e\0\e*\e\0\e*\e\0\e*\e\0\e\0\e\0\0\e!\e"foo\e"\e!\0\e;\e\0\e&\e\0%\e\0\e$'
''
'foo\0\e`\e\0\e\e\e\0\e`\0dspfok\0foo\0\kxr\l'|\nxu\(ul'rr
.De
and press return.
-Everything except \fCfoo.c\fP will be deleted from the directory. If
+Everything except \f(CRfoo.c\fP will be deleted from the directory. If
you do not want to actually expand the current word, but would like to
-see what the matches are, type \fC^Xg\fP.
+see what the matches are, type \f(CR^Xg\fP.
.Ds
%\0rm\0f*\fI^Xg\fP
foo\0\0\0\0foo.c
@@ -1430,23 +1431,23 @@ Here's another trick; let's say you have typed this command in:
.De
and you forget which library you want. You need to escape
out for a minute and check by typing
-\fCls /usr/lib\fP, or some other such command;
+\f(CRls /usr/lib\fP, or some other such command;
but you don't want to retype the whole command again,
and you can't press return now because the current command
is incomplete.
In \fBzsh\fP, you can put the line on the \fIbuffer stack\fP, using
\fIESC-Q\fP, and type some other commands. The next time a prompt is printed,
-the \fCgcc\fP line will be popped off the stack and put
+the \f(CRgcc\fP line will be popped off the stack and put
in the editing buffer automatically; you can then enter the
proper library name and press return (or, \fIESC-Q\fP again and look
for some other libraries whose names you forgot).
.PP
A similar situation: what if you forget the option to gcc that
finds bugs using AI techniques? You could either use \fIESC-Q\fP
-again, and type \fCman gcc\fP, or you could press \fIESC-H\fP, which
+again, and type \f(CRman gcc\fP, or you could press \fIESC-H\fP, which
essentially does the same thing; it puts the current line on
-the buffer stack, and executes the command \fCrun-help gcc\fP,
-where \fCrun-help\fP is an alias for \fCman\fP.
+the buffer stack, and executes the command \f(CRrun-help gcc\fP,
+where \f(CRrun-help\fP is an alias for \f(CRman\fP.
.PP
Another interesting command is \fIESC-A\fP. This executes the
current line, but retains it in the buffer, so that it appears
@@ -1472,12 +1473,12 @@ press \fIESC-'\fP (escape-quote):
.Ds
%\0'don'\e''t\0do\0that;\0type\0'\e''rm\0-rf\0\e*'\e'',\0with\0a\0\e\0before\0the\0*.'
.De
-then move to the beginning and add the \fCecho\fP command.
+then move to the beginning and add the \f(CRecho\fP command.
.Ds
%\0echo\0'don'\e''t\0do\0that;\0type\0'\e''rm\0-rf\0\e*'\e'',\0with\0a\0\e\0before\0the\0*.'
don't\0do\0that;\0type\0'rm\0-rf\0\e*',\0with\0a\0\e\0before\0the\0*.
.De
-Let's say you want to create an alias to do this \fCecho\fP command.
+Let's say you want to create an alias to do this \f(CRecho\fP command.
This can be done by recalling the line with \fI^P\fP and pressing
\fIESC-'\fP again:
.Ds
@@ -1493,12 +1494,12 @@ an alias.
don't\0do\0that;\0type\0'rm\0-rf\0\e*',\0with\0a\0\e\0before\0the\0*.
.De
If one of these fancy editor commands changes your command line in a
-way you did not intend, you can undo changes with \fC^_\fP, if you can
-get it out of your keyboard, or \fC^X^U\fP, otherwise.
+way you did not intend, you can undo changes with \f(CR^_\fP, if you can
+get it out of your keyboard, or \f(CR^X^U\fP, otherwise.
.PP
Another use of the editor is to edit the value of variables.
For example, an easy way to change your path is to use
-the \fCvared\fP command:
+the \f(CRvared\fP command:
.Ds
%\0vared\0PATH
>\0/u/pfalstad/scr:/u/pfalstad/bin/sun4:/u/maruchck/scr:/u/subbarao/bin:/u/maruc
@@ -1512,16 +1513,16 @@ of the edit buffer will be assigned to \fBPATH\fP.
Another great \fBzsh\fP feature is completion. If you hit \fITAB\fP, \fBzsh\fP
will complete all kinds of stuff. Like commands or filenames:
.Ds
-%\0comp\fITAB\fC
+%\0comp\fITAB\f(CR
%\0compress\0_
-%\0ls\0nic\fITAB\fC
+%\0ls\0nic\fITAB\f(CR
%\0ls\0nicecolors\0_
-%\0ls\0/usr/pr\fITAB\fC
+%\0ls\0/usr/pr\fITAB\f(CR
%\0ls\0/usr/princeton/_
-%\0ls\0-l\0=com\fITAB\fC
+%\0ls\0-l\0=com\fITAB\f(CR
%\0ls\0-l\0=compress\0_
.De
If the completion is ambiguous, the editor will beep. If you find
@@ -1530,36 +1531,36 @@ can even be done in the middle of words. To use this, you will have
to set the \fICOMPLETEINWORD\fP option:
.Ds
%\0setopt\0completeinword
-%\0ls\0/usr/p\kxt\l'|\nxu\(ul'on\fITAB\fC
+%\0ls\0/usr/p\kxt\l'|\nxu\(ul'on\fITAB\f(CR
%\0ls\0/usr/prince\kxt\l'|\nxu\(ul'on/
%\0setopt\0alwaystoend
-%\0ls\0/usr/p\kxt\l'|\nxu\(ul'on\fITAB\fC
+%\0ls\0/usr/p\kxt\l'|\nxu\(ul'on\fITAB\f(CR
%\0ls\0/usr/princeton/_
.De
You can list possible completions by pressing \fI^D\fP:
.Ds
-%\0ls\0/vmu\fITAB\0\(embeep\(em\fC
+%\0ls\0/vmu\fITAB\0\(embeep\(em\f(CR
%\0ls\0/vmunix_
-%\0ls\0/vmunix\fI^D\fC
+%\0ls\0/vmunix\fI^D\f(CR
vmunix\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0vmunix.old\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
vmunix.new.kernelmap.old\0\0vmunix.org
.De
Or, you could just set the \fIAUTOLIST\fP option:
.Ds
%\0setopt\0autolist
-%\0ls\0/vmu\fITAB\0\(embeep\(em\fC
+%\0ls\0/vmu\fITAB\0\(embeep\(em\f(CR
vmunix\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0vmunix.old\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
vmunix.new.kernelmap.old\0\0vmunix.org
%\0ls\0/vmunix_
.De
If you like to see the types of the files in these lists, like in
-\fCls\ -F\fP, you can set the \fILISTTYPES\fP option. Together with
+\f(CRls\ -F\fP, you can set the \fILISTTYPES\fP option. Together with
\fIAUTOLIST\fP you can use \fILISTAMBIGUOUS\fP. This will only list
the possibilities if there is no unambiguous part to add:
.Ds
%\0setopt\0listambiguous
-%\0ls\0/vmu\fITAB\0\(embeep\(em\fC
-%\0ls\0/vmunix_\fITAB\0\(embeep\(em\fC
+%\0ls\0/vmu\fITAB\0\(embeep\(em\f(CR
+%\0ls\0/vmunix_\fITAB\0\(embeep\(em\f(CR
vmunix\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0vmunix.old\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
vmunix.new.kernelmap.old\0\0vmunix.org
.De
@@ -1569,12 +1570,12 @@ continue to edit the line you were editing, with the completion
listing appearing beneath it.
.PP
Another interesting option is \fIMENUCOMPLETE\fP. This affects the
-way \fITAB\fP works. Let's look at the \fC/vmunix\fP example again:
+way \fITAB\fP works. Let's look at the \f(CR/vmunix\fP example again:
.Ds
%\0setopt\0menucomplete
-%\0ls\0/vmu\fITAB\fC
-%\0ls\0/vmunix\fITAB\fC
-%\0ls\0/vmunix.new.kernelmap.old\fITAB\fC
+%\0ls\0/vmu\fITAB\f(CR
+%\0ls\0/vmunix\fITAB\f(CR
+%\0ls\0/vmunix.new.kernelmap.old\fITAB\f(CR
%\0ls\0/vmunix.old_
.De
Each time you press \fITAB\fP, it displays the next possible completion.
@@ -1592,10 +1593,10 @@ exact matches to be accepted, even if there are other possible
completions:
.Ds
%\0setopt\0recexact
-%\0ls\0/vmu\fITAB\0\(embeep\(em\fC
+%\0ls\0/vmu\fITAB\0\(embeep\(em\f(CR
vmunix\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0vmunix.old\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0
vmunix.new.kernelmap.old\0\0vmunix.org
-%\0ls\0/vmunix_\fITAB\fC
+%\0ls\0/vmunix_\fITAB\f(CR
%\0ls\0/vmunix\0_
.De
To facilitate the typing of pathnames, a slash will be added whenever
@@ -1607,25 +1608,25 @@ slashes when you type a space or return after them.
The \fIfignore\fP variable lists suffixes of files to ignore
during completion.
.Ds
-%\0ls\0foo\fITAB\0\(embeep\(em\fC
+%\0ls\0foo\fITAB\0\(embeep\(em\f(CR
foofile.c\0\0foofile.o
%\0fignore=(\0.o\0\e~\0.bak\0.junk\0)
%\0ls\0foo\fITAB\fP
%\0ls\0foofile.c\0_
.De
-Since \fCfoofile.o\fP has a suffix that is in the \fCfignore\fP list,
-it was not considered a possible completion of \fCfoo\fP.
+Since \f(CRfoofile.o\fP has a suffix that is in the \f(CRfignore\fP list,
+it was not considered a possible completion of \f(CRfoo\fP.
.PP
Username completion is also supported:
.Ds
-%\0ls\0~pfal\fITAB\fC
+%\0ls\0~pfal\fITAB\f(CR
%\0ls\0~pfalstad/_
.De
and parameter name completion:
.Ds
-%\0echo\0$ORG\fITAB\fC
+%\0echo\0$ORG\fITAB\f(CR
%\0echo\0$ORGANIZATION\0_
-%\0echo\0${ORG\fITAB\fC
+%\0echo\0${ORG\fITAB\f(CR
%\0echo\0${ORGANIZATION\0_
.De
Note that in the last example a space is added after the completion as
@@ -1636,65 +1637,65 @@ brace after such a completion.
.PP
There is also option completion:
.Ds
-%\0setopt\0nocl\fITAB\fC
+%\0setopt\0nocl\fITAB\f(CR
%\0setopt\0noclobber\0_
.De
and binding completion:
.Ds
-%\0bindkey\0'^X^X'\0pu\fITAB\fC
+%\0bindkey\0'^X^X'\0pu\fITAB\f(CR
%\0bindkey\0'^X^X'\0push-line\0_
.De
-The \fCcompctl\fP command is used to control completion of the
+The \f(CRcompctl\fP command is used to control completion of the
arguments of specific commands. For example, to specify that certain
-commands take other commands as arguments, you use \fCcompctl -c\fP:
+commands take other commands as arguments, you use \f(CRcompctl -c\fP:
.Ds
%\0compctl\0-c\0man\0nohup
-%\0man\0upt\fITAB\fC
+%\0man\0upt\fITAB\f(CR
%\0man\0uptime\0_
.De
To specify that a command should complete filenames, you should use
-\fCcompctl -f\fP. This is the default. It can be combined with \fC-c\fP,
+\f(CRcompctl -f\fP. This is the default. It can be combined with \f(CR-c\fP,
as well.
.Ds
%\0compctl\0-cf\0echo
-%\0echo\0upt\fITAB\fC
+%\0echo\0upt\fITAB\f(CR
%\0echo\0uptime\0_
-%\0echo\0fo\fITAB\fC
+%\0echo\0fo\fITAB\f(CR
%\0echo\0foo.c
.De
-Similarly, use \fC-o\fP to specify options, \fC-v\fP to specify
-variables, and \fC-b\fP to specify bindings.
+Similarly, use \f(CR-o\fP to specify options, \f(CR-v\fP to specify
+variables, and \f(CR-b\fP to specify bindings.
.Ds
%\0compctl\0-o\0setopt\0unsetopt
%\0compctl\0-v\0typeset\0vared\0unset\0export
%\0compctl\0-b\0bindkey
.De
-You can also use \fC-k\fP to specify a custom list of keywords to use
-in completion. After the \fC-k\fP comes either the name of an array
+You can also use \f(CR-k\fP to specify a custom list of keywords to use
+in completion. After the \f(CR-k\fP comes either the name of an array
or a literal array to take completions from.
.Ds
%\0ftphosts=(ftp.uu.net\0wuarchive.wustl.edu)
%\0compctl\0-k\0ftphosts\0ftp
-%\0ftp\0wu\fITAB\fC
+%\0ftp\0wu\fITAB\f(CR
%\0ftp\0wuarchive.wustl.edu\0_
%\0compctl\0-k\0'(cpirazzi\0subbarao\0sukthnkr)'\0mail\0finger
-%\0finger\0cp\fITAB\fC
+%\0finger\0cp\fITAB\f(CR
%\0finger\0cpirazzi\0_
.De
To better specify the files to complete for a command, use the
-\fC-g\fP option which takes any glob pattern as an argument. Be sure
+\f(CR-g\fP option which takes any glob pattern as an argument. Be sure
to quote the glob patterns as otherwise they will be expanded when the
-\fCcompctl\fP command is run.
+\f(CRcompctl\fP command is run.
.Ds
%\0ls
letter.tex\0\0letter.dvi\0\0letter.aux\0\0letter.log\0\0letter.toc
%\0compctl\0-g\0'*.tex'\0latex
%\0compctl\0-g\0'*.dvi'\0xdvi\0dvips
-%\0latex\0l\fITAB\fC
+%\0latex\0l\fITAB\f(CR
%\0latex\0letter.tex\0_
-%\0xdvi\0l\fITAB\fC
+%\0xdvi\0l\fITAB\f(CR
%\0xdvi\0letter.dvi\0_
.De
Glob patterns can include qualifiers within parentheses. To rmdir
@@ -1705,43 +1706,43 @@ them:
%\0compctl\0-g\0'*(/)'\0rmdir
.De
RCS users like to run commands on files which are not in the current
-directory, but in the RCS subdirectory where they all get \fC,v\fP
+directory, but in the RCS subdirectory where they all get \f(CR,v\fP
suffixes. They might like to use
.Ds
%\0compctl\0-g\0'RCS/*(:t:s/\e,v//)'\0co\0rlog\0rcs
%\0ls\0RCS
builtin.c,v\0\0lex.c,v\0\0\0\0\0\0zle_main.c,v
-%\0rlog\0bu\fITAB\fC
+%\0rlog\0bu\fITAB\f(CR
%\0rlog\0builtin.c\0_
.De
-The \fC:t\fP modifier keeps only the last part of the pathname and the
-\fC:s/\e,v//\fP will replace any \fC,v\fP by nothing.
+The \f(CR:t\fP modifier keeps only the last part of the pathname and the
+\f(CR:s/\e,v//\fP will replace any \f(CR,v\fP by nothing.
.PP
-The \fC-s\fP flag is similar to \fC-g\fP, but it uses all expansions,
+The \f(CR-s\fP flag is similar to \f(CR-g\fP, but it uses all expansions,
instead of just globbing, like brace expansion, parameter substitution
and command substitution.
.Ds
%\0compctl\0-s\0'$(setopt)'\0unsetopt
.De
will only complete options which are actually set to be arguments to
-\fCunsetopt\fP.
+\f(CRunsetopt\fP.
.PP
Sometimes a command takes another command as its argument. You can
tell \fBzsh\fP to complete commands as the first argument to such a
command and then use the completion method of the second command. The
-\fC-l\fP flag with a null-string argument is used for this.
+\f(CR-l\fP flag with a null-string argument is used for this.
.Ds
%\0compctl\0-l\0''\0nohup\0exec
-%\0nohup\0comp\fITAB\fC
+%\0nohup\0comp\fITAB\f(CR
%\0nohup\0compress\0_
-%\0nohup\0compress\0fil\fITAB\fC
+%\0nohup\0compress\0fil\fITAB\f(CR
%\0nohup\0compress\0filename\0_
.De
Sometimes you would like to run really complicated commands to find
out what the possible completions are. To do this, you can specify a
shell function to be called that will assign the possible completions
to a variable called reply. Note that this variable must be an array.
-Here's another (much slower) way to get the completions for \fCco\fP
+Here's another (much slower) way to get the completions for \f(CRco\fP
and friends:
.Ds
%\0function\0getrcs\0{
@@ -1755,31 +1756,31 @@ and friends:
.De
Some command arguments use a prefix that is not a part of the things
to complete. The kill builtin command takes a signal name after a
-\fC-\fP. To make such a prefix be ignored in the completion process,
-you can use the \fC-P\fP flag.
+\f(CR-\fP. To make such a prefix be ignored in the completion process,
+you can use the \f(CR-P\fP flag.
.Ds
%\0compctl\0-P\0-\0-k\0signals\0kill
%\0kill\0-H\fITAB\fP
%\0kill\0-HUP\0_
.De
-TeX is usually run on files ending in \fC.tex\fP, but also sometimes
+TeX is usually run on files ending in \f(CR.tex\fP, but also sometimes
on other files. It is somewhat annoying to specify that the arguments
-of TeX should end in \fC.tex\fP and then not be able to complete these
+of TeX should end in \f(CR.tex\fP and then not be able to complete these
other files. Therefore you can specify things like \*QComplete to
-files ending in \fC.tex\fP if available, otherwise complete to any
+files ending in \f(CR.tex\fP if available, otherwise complete to any
filename.\*U. This is done with \fIxor\fPed completion:
.Ds
%\0compctl\0-g\0'*.tex'\0+\0-f\0tex
.De
-The \fC+\fP tells the editor to only take the next thing into account
+The \f(CR+\fP tells the editor to only take the next thing into account
if the current one doesn't generate any matches. If you have not
changed the default completion, the above example is in fact
equivalent to
.Ds
%\0compctl\0-g\0'*.tex'\0+\0tex
.De
-as a lone \fC+\fP at the end is equivalent to specifying the default
-completion after the \fC+\fP. This form of completion is also
+as a lone \f(CR+\fP at the end is equivalent to specifying the default
+completion after the \f(CR+\fP. This form of completion is also
frequently used if you want to run some command only on a certain type
of files, but not necessarily in the current directory. In this case
you will want to complete both files of this type and directories.
@@ -1796,8 +1797,8 @@ typed part of the argument.
If you play with completion, you will soon notice that you would like
to specify what to complete, depending on what flags you give to the
command and where you are on the command line. For example, a command
-could take any filename argument after a \fC-f\fP flag, a username
-after a \fC-u\fP flag and an executable after a \fC-x\fP flag. This
+could take any filename argument after a \f(CR-f\fP flag, a username
+after a \f(CR-u\fP flag and an executable after a \f(CR-x\fP flag. This
section will introduce you to the ways to specify these things. To
many people it seems rather difficult at first, but taking the trouble
to understand it can save you lots of typing in the end. Even I keep
@@ -1805,13 +1806,13 @@ being surprised when \fBzsh\fP manages to complete a small or even
empty prefix to the right file in a large directory.
.PP
To tell \fBzsh\fP about these kinds of completion, you use \*Qextended
-completion\*U by specifying the \fC-x\fP flag to compctl. The
-\fC-x\fP flag takes a list of patterns/flags pairs. The patterns
+completion\*U by specifying the \f(CR-x\fP flag to compctl. The
+\f(CR-x\fP flag takes a list of patterns/flags pairs. The patterns
specify when to complete and the flags specify what. The flags are
-simply those mentioned above, like \fC-f\fP or \fC-g \fIglob
+simply those mentioned above, like \f(CR-f\fP or \f(CR-g \fIglob
pattern\fR.
.PP
-As an example, the \fCr[\fIstring1\fC,\fIstring2\fC]\fR pattern
+As an example, the \f(CRr[\fIstring1\f(CR,\fIstring2\f(CR]\fR pattern
matches if the cursor is after something that starts with
\fIstring1\fP and before something that starts with \fIstring2\fP.
The \fIstring2\fP is often something that you do not want to match
@@ -1825,13 +1826,13 @@ foo1\0\0\0bar1\0\0\0foo.Z\0\0bar.Z
%\0compress\0-d\0f\fITAB\fP
%\0compress\0-d\0foo.Z\0_
.De
-In the above example, if the cursor is after the \fC-d\fP the pattern
-will match and therefore \fBzsh\fP uses the \fC-g *.Z\fP flag that will only
-complete files ending in \fC.Z\fP. Otherwise, if no pattern matches,
-it will use the flags before the \fC-x\fP and in this case complete
-every file that does not end in \fC.Z\fP.
+In the above example, if the cursor is after the \f(CR-d\fP the pattern
+will match and therefore \fBzsh\fP uses the \f(CR-g *.Z\fP flag that will only
+complete files ending in \f(CR.Z\fP. Otherwise, if no pattern matches,
+it will use the flags before the \f(CR-x\fP and in this case complete
+every file that does not end in \f(CR.Z\fP.
.PP
-The \fCs[\fIstring\fC]\fR pattern matches if the current word starts
+The \f(CRs[\fIstring\f(CR]\fR pattern matches if the current word starts
with \fIstring\fP. The \fIstring\fP itself is not considered to be
part of the completion.
.Ds
@@ -1839,74 +1840,74 @@ part of the completion.
%\0kill\0-H\fITAB\fP
%\0kill\0-HUP\0_
.De
-The \fCtar\fP command takes a tar file as an argument after the
-\fC-f\fP option. The \fCc[\fIoffset\fC,\fIstring\fC]\fR pattern
+The \f(CRtar\fP command takes a tar file as an argument after the
+\f(CR-f\fP option. The \f(CRc[\fIoffset\f(CR,\fIstring\f(CR]\fR pattern
matches if the word in position \fIoffset\fP relative to the current
word is \fIstring\fP. More in particular, if \fIoffset\fP is -1, it
matches if the previous word is \fIstring\fP. This suggests
.Ds
%\0compctl\0-f\0-x\0'c[-1,-f]'\0-g\0'*.tar'\0--\0tar
.De
-But this is not enough. The \fC-f\fP option could be the last of a
-longer string of options. \fCC[\fR...\fC,\fR...\fC]\fR is just like
-\fCc[\fR...\fC,\fR...\fC]\fR, except that it uses glob-like pattern
+But this is not enough. The \f(CR-f\fP option could be the last of a
+longer string of options. \f(CRC[\fR...\f(CR,\fR...\f(CR]\fR is just like
+\f(CRc[\fR...\f(CR,\fR...\f(CR]\fR, except that it uses glob-like pattern
matching for \fIstring\fP. So
.Ds
%\0compctl\0-f\0-x\0'C[-1,-*f]'\0-g\0'*.tar'\0--\0tar
.De
-will complete tar files after any option string ending in an \fCf\fP.
+will complete tar files after any option string ending in an \f(CRf\fP.
But we'd like even more. Old versions of tar used all options as the
first argument, but without the minus sign. This might be
inconsistent with option usage in all other commands, but it is still
-supported by newer versions of \fCtar\fP. So we would also like to
-complete tar files if the first argument ends in an \fCf\fP and we're
+supported by newer versions of \f(CRtar\fP. So we would also like to
+complete tar files if the first argument ends in an \f(CRf\fP and we're
right behind it.
.PP
We can `and' patterns by putting them next to each other with a space
between them. We can `or' these sets by putting comma's between them.
-We will also need some new patterns. \fCp[\fInum\fC]\fR will match if
+We will also need some new patterns. \f(CRp[\fInum\f(CR]\fR will match if
the current argument (the one to be completed) is the \fInum\fPth
-argument. \fCW[\fIindex\fC,\fIpattern\fC]\fR will match if the
+argument. \f(CRW[\fIindex\f(CR,\fIpattern\f(CR]\fR will match if the
argument in place \fIindex\fP matches the \fIpattern\fP. This gives
us
.Ds
%\0compctl\0-f\0-x\0'C[-1,-*f]\0,\0W[1,*f]\0p[2]'\0-g\0'*.tar'\0--\0tar
.De
In words: If the previous argument is an option string that ends in an
-\fCf\fP, or the first argument ended in an \fCf\fP and it is now the
-second argument, then complete only filenames ending in \fC.tar\fP.
+\f(CRf\fP, or the first argument ended in an \f(CRf\fP and it is now the
+second argument, then complete only filenames ending in \f(CR.tar\fP.
.PP
All the above examples used only one set of patterns with one
completion flag. You can use several of these pattern/flag pairs
-separated by a \fC-\fP. The first matching pattern will be used.
-Suppose you have a version of \fCtar\fP that supports compressed files
-by using a \fC-Z\fP option. Leaving the old tar syntax aside for a
-moment, we would like to complete files ending in \fC.tar.Z\fP if a
-\fC-Z\fP option has been used and files ending in \fC.tar\fP
-otherwise, all this only after a \fC-f\fP flag. Again, the \fC-Z\fP
+separated by a \f(CR-\fP. The first matching pattern will be used.
+Suppose you have a version of \f(CRtar\fP that supports compressed files
+by using a \f(CR-Z\fP option. Leaving the old tar syntax aside for a
+moment, we would like to complete files ending in \f(CR.tar.Z\fP if a
+\f(CR-Z\fP option has been used and files ending in \f(CR.tar\fP
+otherwise, all this only after a \f(CR-f\fP flag. Again, the \f(CR-Z\fP
can be alone or it can be part of a longer option string, perhaps the
-same as that of the \fC-f\fP flag. Here's how to do it; note the
+same as that of the \f(CR-f\fP flag. Here's how to do it; note the
backslash and the secondary prompt which are not part of the
-\fCcompctl\fP command.
+\f(CRcompctl\fP command.
.Ds
%\0compctl\0-f\0-x\0'C[-1,-*Z*f]\0,\0R[-*Z*,---]\0C[-1,-*f]'\0-g\0'*.tar.Z'\0-\0\e
>\0'C[-1,-*f]'\0-g\0'*.tar'\0--\0tar
.De
The first pattern set tells us to match if either the previous
-argument was an option string including a \fCZ\fP and ending in an
-\fCf\fP or there was an option string with a \fCZ\fP somewhere and the
-previous word was any option string ending in an \fCf\fP. If this is
+argument was an option string including a \f(CRZ\fP and ending in an
+\f(CRf\fP or there was an option string with a \f(CRZ\fP somewhere and the
+previous word was any option string ending in an \f(CRf\fP. If this is
the case, we need a compressed tar file. Only if this is not the case
the second pattern set will be considered. By the way,
-\fCR[\fIpattern1\fC,\fIpattern2\fC]\fR is just like
-\fCr[\fR...\fC,\fR...\fC]\fR except that it uses pattern matching with
+\f(CRR[\fIpattern1\f(CR,\fIpattern2\f(CR]\fR is just like
+\f(CRr[\fR...\f(CR,\fR...\f(CR]\fR except that it uses pattern matching with
shell metacharacters instead of just strings.
.PP
-You will have noticed the \fC--\fP before the command name. This ends
-the list of pattern/flag pairs of \fC-x\fP. It is usually used just
+You will have noticed the \f(CR--\fP before the command name. This ends
+the list of pattern/flag pairs of \f(CR-x\fP. It is usually used just
before the command name, but you can also use an extended completion
-as one part of a list of xored completions, in which case the \fC--\fP
-appears just before one of the \fC+\fP signs.
+as one part of a list of xored completions, in which case the \f(CR--\fP
+appears just before one of the \f(CR+\fP signs.
.PP
Note the difference between using extended completion as part of a
list of xored completions as in
@@ -1917,38 +1918,38 @@ foo\0\0bar
%\0compress\0-d\0f\fITAB\fP
%\0compress\0-d\0foo\0_
.De
-and specifying something before the \fC-x\fP as in
+and specifying something before the \f(CR-x\fP as in
.Ds
%\0compctl\0-g\0'^*.Z'\0-x\0'r[-d,---]'\0-g\0'*.Z'\0--\0compress
%\0compress\0-d\0f\fITAB\fP
%\0compress\0-d\0f_
.De
-In the first case, the alternative glob pattern (\fC^*.Z\fP) will be
+In the first case, the alternative glob pattern (\f(CR^*.Z\fP) will be
used if the first part does not generate any possible completions,
while in the second case the alternative glob pattern will only be
-used if the \fCr[\fR...\fC]\fR pattern doesn't match.
+used if the \f(CRr[\fR...\f(CR]\fR pattern doesn't match.
.Sh "Bindings"
.PP
Each of the editor commands we have seen was actually a function bound
by default to a certain key. The real names of the commands are:
.Ds
-\fCexpand-or-complete\0\0\0\fITAB\fR
-\fCpush-line\0\0\0\0\0\0\0\0\0\0\0\0\fIESC-Q\fR
-\fCrun-help\0\0\0\0\0\0\0\0\0\0\0\0\0\fIESC-H\fR
-\fCaccept-and-hold\0\0\0\0\0\0\fIESC-A\fR
-\fCquote-line\0\0\0\0\0\0\0\0\0\0\0\fIESC-'\fR
+\f(CRexpand-or-complete\0\0\0\fITAB\fR
+\f(CRpush-line\0\0\0\0\0\0\0\0\0\0\0\0\fIESC-Q\fR
+\f(CRrun-help\0\0\0\0\0\0\0\0\0\0\0\0\0\fIESC-H\fR
+\f(CRaccept-and-hold\0\0\0\0\0\0\fIESC-A\fR
+\f(CRquote-line\0\0\0\0\0\0\0\0\0\0\0\fIESC-'\fR
.De
These bindings are arbitrary; you could change them if you want.
-For example, to bind \fCaccept-line\fP to \fI^Z\fP:
+For example, to bind \f(CRaccept-line\fP to \fI^Z\fP:
.Ds
%\0bindkey\0'^Z'\0accept-line
.De
-Another idea would be to bind the delete key to \fCdelete-char\fP;
+Another idea would be to bind the delete key to \f(CRdelete-char\fP;
this might be convenient if you use \fI^H\fP for backspace.
.Ds
%\0bindkey\0'^?'\0delete-char
.De
-Or, you could bind \fI^X\fP\fI^H\fP to \fCrun-help\fP:
+Or, you could bind \fI^X\fP\fI^H\fP to \f(CRrun-help\fP:
.Ds
%\0bindkey\0'^X^H'\0run-help
.De
@@ -1960,22 +1961,22 @@ Other examples:
>\0'
%\0bindkey\0'^Q'\0push-line-or-edit
.De
-\fCuniversal-argument\fP multiplies the next command by 4.
+\f(CRuniversal-argument\fP multiplies the next command by 4.
Thus \fI^X\fP\fI^Z\fP\fI^W\fP might delete the last four words on the line.
-If you bind space to \fCmagic-space\fP, then csh-style history
+If you bind space to \f(CRmagic-space\fP, then csh-style history
expansion is done on the line whenever you press the space bar.
.PP
Something that often happens is that I am typing a multiline command
and discover an error in one of the previous lines. In this case,
-\fCpush-line-or-edit\fP will put the entire multiline construct into
+\f(CRpush-line-or-edit\fP will put the entire multiline construct into
the editor buffer. If there is only a single line, it is equivalent
-to \fCpush-line\fP.
+to \f(CRpush-line\fP.
.PP
-The \fC-s\fP flag to \fCbindkey\fP specifies that you are binding the key
-to a string, not a command. Thus \fCbindkey -s '^T' 'uptime\en'\fP
+The \f(CR-s\fP flag to \f(CRbindkey\fP specifies that you are binding the key
+to a string, not a command. Thus \f(CRbindkey -s '^T' 'uptime\en'\fP
lets you VMS lovers get the load average whenever you press \fI^T\fP.
.PP
-If you have a NeXT keyboard, the one with the \fC|\fP and \fC\e\fP keys
+If you have a NeXT keyboard, the one with the \f(CR|\fP and \f(CR\e\fP keys
very inconveniently placed, the following
bindings may come in handy:
.Ds
@@ -1984,10 +1985,10 @@ bindings may come in handy:
.De
Now you can type \fIALT-/\fP to get a backslash, and \fIALT-=\fP to
get a vertical bar. This only works inside \fBzsh\fP, of course;
-\fCbindkey\fP has no effect on the key mappings inside \fCtalk\fP
-or \fCmail\fP, etc.
+\f(CRbindkey\fP has no effect on the key mappings inside \f(CRtalk\fP
+or \f(CRmail\fP, etc.
.PP
-Some people like to bind \fC^S\fP and \fC^Q\fP to editor commands.
+Some people like to bind \f(CR^S\fP and \f(CR^Q\fP to editor commands.
Just binding these has no effect, as the terminal will catch them and
use them for flow control. You could unset them as stop and start
characters, but most people like to use these for external commands.
@@ -2002,12 +2003,12 @@ In \fBzsh\fP, parameters are set like this:
%\0echo\0$foo
bar
.De
-Spaces before or after the \fC=\fP are frowned upon:
+Spaces before or after the \f(CR=\fP are frowned upon:
.Ds
%\0foo\0=\0bar
zsh:\0command\0not\0found:\0foo
.De
-Also, \fCset\fP doesn't work for setting parameters:
+Also, \f(CRset\fP doesn't work for setting parameters:
.Ds
%\0set\0foo=bar
%\0set\0foo\0=\0bar
@@ -2016,9 +2017,9 @@ Also, \fCset\fP doesn't work for setting parameters:
%
.De
Note that no error message was printed. This is because both
-of these commands were perfectly valid; the \fCset\fP builtin
+of these commands were perfectly valid; the \f(CRset\fP builtin
assigns its arguments to the \fIpositional parameters\fP
-(\fC$1\fP, \fC$2\fP, etc.).
+(\f(CR$1\fP, \f(CR$2\fP, etc.).
.Ds
%\0set\0foo=bar
%\0echo\0$1
@@ -2038,11 +2039,11 @@ function like this:
%\0echo\0$foo\0$fuu
bar\0brrr
.De
-But then, of course you can't use the form of \fCset\fP with
-options, like \fCset -F\fP (which turns off filename generation).
-Also, the \fCset\fP command by itself won't list all the parameters
+But then, of course you can't use the form of \f(CRset\fP with
+options, like \f(CRset -F\fP (which turns off filename generation).
+Also, the \f(CRset\fP command by itself won't list all the parameters
like it should.
-To get around that you need a \fCcase\fP statement:
+To get around that you need a \f(CRcase\fP statement:
.Ds
%\0set\0()\0{
>\0\0\0\0case\0$1\0in
@@ -2075,7 +2076,7 @@ bar
%\0echo\0${foo+set}
set
.De
-Also, csh-style \fC:\fP modifiers may be appended to a parameter
+Also, csh-style \f(CR:\fP modifiers may be appended to a parameter
substitution.
.Ds
%\0echo\0$PWD
@@ -2096,15 +2097,15 @@ c
.De
The equivalent constructs in ksh (which are also supported in \fBzsh\fP)
are a bit more general and easier to remember.
-When the shell expands \fC${foo#\fR\fIpat\fR\fC}\fR,
+When the shell expands \f(CR${foo#\fR\fIpat\fR\f(CR}\fR,
it checks to see if \fIpat\fP matches a substring at the beginning
of the value
-of \fCfoo\fP. If so, it removes that portion of \fCfoo\fP, using the shortest
+of \f(CRfoo\fP. If so, it removes that portion of \f(CRfoo\fP, using the shortest
possible match.
-With \fC${foo##\fR\fIpat\fR\fC}\fR, the longest possible match is removed.
-\fC${foo%\fR\fIpat\fR\fC}\fR and \fC${foo%%\fR\fIpat\fR\fC}\fR remove the match
+With \f(CR${foo##\fR\fIpat\fR\f(CR}\fR, the longest possible match is removed.
+\f(CR${foo%\fR\fIpat\fR\f(CR}\fR and \f(CR${foo%%\fR\fIpat\fR\f(CR}\fR remove the match
from the end.
-Here are the ksh equivalents of the \fC:\fP modifiers:
+Here are the ksh equivalents of the \f(CR:\fP modifiers:
.Ds
%\0echo\0${PWD%/*}
/home/learning/pf/zsh/zsh2.00
@@ -2138,9 +2139,9 @@ bar.c\0\0\0\0bar.h\0\0\0\0bar.o\0\0\0\0bar.pro
There is yet another syntax to modify substituted parameters. You can
add certain modifiers in parentheses after the opening brace like:
.Ds
-${(\fImodifiers\fC)\fIparameter\fC}
+${(\fImodifiers\f(CR)\fIparameter\f(CR}
.De
-For example, \fCo\fP sorts the words resulting from the expansion:
+For example, \f(CRo\fP sorts the words resulting from the expansion:
.Ds
%\0echo\0${path}
/usr/bin\0/usr/bin/X11\0/etc
@@ -2182,7 +2183,7 @@ exec.c\0\0glob.c\0\0init.c
%\0ls\0$srcs
exec.c\0\0glob.c\0\0init.c
.De
-Another way to get the \fC$srcs\fP trick to work is to use an array:
+Another way to get the \f(CR$srcs\fP trick to work is to use an array:
.Ds
%\0unset\0srcs
%\0srcs=(\0glob.c\0exec.c\0init.c\0)\0\0
@@ -2227,7 +2228,7 @@ accessed. Here are some examples:
%\0false;\0echo\0$status
1
.De
-(\fC$?\fP and \fC$status\fP are equivalent.)
+(\f(CR$?\fP and \f(CR$status\fP are equivalent.)
.Ds
%\0echo\0$HOST\0$HOSTTYPE
dendrite\0sun4
@@ -2240,7 +2241,7 @@ dendrite\0sun4
%\0ls\0$OLDPWD/.getwd\0
/tmp/.getwd
.De
-\fC~+\fP and \fC~-\fP are short for \fC$PWD\fP and \fC$OLDPWD\fP, respectively.
+\f(CR~+\fP and \f(CR~-\fP are short for \f(CR$PWD\fP and \f(CR$OLDPWD\fP, respectively.
.Ds
%\0ls\0~-/.getwd
/tmp/.getwd
@@ -2260,8 +2261,8 @@ zsh\0v2.00.03
pf
.De
.PP
-The \fCcdpath\fP variable sets the search path for the \fCcd\fP command.
-If you do not specify \fC.\fP somewhere in the path, it is assumed to
+The \f(CRcdpath\fP variable sets the search path for the \f(CRcd\fP command.
+If you do not specify \f(CR.\fP somewhere in the path, it is assumed to
be the first component.
.Ds
%\0cdpath=(\0/usr\0~\0~/zsh\0)
@@ -2310,7 +2311,7 @@ The same is true of \fBCDPATH\fP and \fBcdpath\fP:
In general, predefined parameters with names in all lowercase are
arrays; assignments to them take the form:
.Ds
-\fIname\fR\fC=(\fR\0\fIelem\fR\0...\0\fC)\fR
+\fIname\fR\f(CR=(\fR\0\fIelem\fR\0...\0\f(CR)\fR
.De
Predefined parameters with names in all uppercase are strings. If
there is both an array and a string version of the same parameter, the
@@ -2361,7 +2362,7 @@ In \fBzsh\fP, if you say
.Ds
%\0>file
.De
-the command \fCcat\fP is normally assumed:
+the command \f(CRcat\fP is normally assumed:
.Ds
%\0>file
foo!\0\0\0\0
@@ -2376,14 +2377,14 @@ foo!
.De
However, this is not csh or sh compatible. To correct this,
change the value of the parameter \fBNULLCMD\fP,
-which is \fCcat\fP by default.
+which is \f(CRcat\fP by default.
.Ds
%\0NULLCMD=:
%\0>file
%\0ls\0-l\0file
-rw-r--r--\0\01\0pfalstad\0\0\0\0\0\0\0\00\0May\024\005:41\0file
.De
-If \fCNULLCMD\fP is unset, the shell reports an error if no
+If \f(CRNULLCMD\fP is unset, the shell reports an error if no
command is specified (like csh).
.Ds
%\0unset\0NULLCMD
@@ -2392,9 +2393,9 @@ zsh:\0redirection\0with\0no\0command
.De
Actually, \fBREADNULLCMD\fP is used whenever you have a null command
reading input from a single file. Thus, you can set \fBREADNULLCMD\fP
-to \fCmore\fP or \fCless\fP rather than \fCcat\fP. Also, if you
-set \fBNULLCMD\fP to \fC:\fP for sh compatibility, you can still read
-files with \fC< file\fP if you leave \fBREADNULLCMD\fP set to \fCmore\fP.
+to \f(CRmore\fP or \f(CRless\fP rather than \f(CRcat\fP. Also, if you
+set \fBNULLCMD\fP to \f(CR:\fP for sh compatibility, you can still read
+files with \f(CR< file\fP if you leave \fBREADNULLCMD\fP set to \f(CRmore\fP.
.Sh "Prompting"
.PP
The default prompt for \fBzsh\fP is:
@@ -2402,8 +2403,8 @@ The default prompt for \fBzsh\fP is:
phoenix%\0echo\0$PROMPT
%m%#\0
.De
-The \fC%m\fP stands for the short form of the current hostname,
-and the \fC%#\fP stands for a \fC%\fP or a \fC#\fP, depending on whether
+The \f(CR%m\fP stands for the short form of the current hostname,
+and the \f(CR%#\fP stands for a \f(CR%\fP or a \f(CR#\fP, depending on whether
the shell is running as root or not.
\fBzsh\fP supports many other control sequences
in the \fBPROMPT\fP variable.
@@ -2417,7 +2418,7 @@ in the \fBPROMPT\fP variable.
%\0PROMPT='%h\0%~>\0'
6\0~/etc/TeX/zsh>\0
.De
-\fC%h\fP\0represents\0the\0number\0of\0current\0history\0event.
+\f(CR%h\fP\0represents\0the\0number\0of\0current\0history\0event.
.Ds
%\0PROMPT='%h\0%~\0%M>\0'
10\0~/etc/TeX/zsh\0apple-gunkies.gnu.ai.mit.edu>\0
@@ -2432,7 +2433,7 @@ in the \fBPROMPT\fP variable.
pfalstad\0Fri\024\0ttyp0>
.De
\fBPROMPT2\fP is used in multiline commands, like for-loops. The
-\fC%_\fP escape sequence was made especially for this prompt. It is
+\f(CR%_\fP escape sequence was made especially for this prompt. It is
replaced by the kind of command that is being entered.
.Ds
%\0PROMPT2='%_>\0'
@@ -2456,7 +2457,7 @@ of the screen.
p0\06:15\0phoenix[5]\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0~/etc/TeX/zsh
.De
These special escape sequences can also be used with the
-\fC-P\fP option to \fCprint\fP:
+\f(CR-P\fP option to \f(CRprint\fP:
.Ds
%\0print\0-P\0%h\0tty%l
15\0ttyp1
@@ -2478,22 +2479,22 @@ Normally, this is done by specifying a list of usernames.
.Ds
%\0watch=(\0pfalstad\0subbarao\0sukthnkr\0egsirer\0)
.De
-The \fClog\fP command reports all people logged in
+The \f(CRlog\fP command reports all people logged in
that you are watching for.
.Ds
%\0log
pfalstad\0has\0logged\0on\0p0\0from\0mickey.
pfalstad\0has\0logged\0on\0p5\0from\0mickey.
-%\0\fR...\fC
+%\0\fR...\f(CR
subbarao\0has\0logged\0on\0p8\0from\0phoenix.
-%\0\fR...\fC
+%\0\fR...\f(CR
subbarao\0has\0logged\0off\0p8\0from\0phoenix.
-%\0\fR...\fC
+%\0\fR...\f(CR
sukthnkr\0has\0logged\0on\0p8\0from\0dew.
-%\0\fR...\fC
+%\0\fR...\f(CR
sukthnkr\0has\0logged\0off\0p8\0from\0dew.
.De
-If you specify hostnames with an \fC@\fP prepended,
+If you specify hostnames with an \f(CR@\fP prepended,
the shell will watch for all users logging in from
the specified host.
.Ds
@@ -2503,7 +2504,7 @@ djthongs\0has\0logged\0on\0q2\0from\0phoenix.
pfalstad\0has\0logged\0on\0p0\0from\0mickey.
pfalstad\0has\0logged\0on\0p5\0from\0mickey.
.De
-If you give a tty name with a \fC%\fP prepended, the shell
+If you give a tty name with a \f(CR%\fP prepended, the shell
will watch for all users logging in on that tty.
.Ds
%\0watch=(\0%ttyp0\0%console\0)
@@ -2558,7 +2559,7 @@ eps\0logged\0on\0at\04:19pm\0Thu\023.
pfalstad\0logged\0on\0at\03:39am\0Fri\024.
pfalstad\0logged\0on\0at\03:42am\0Fri\024.
.De
-If you have a \fC.friends\fP file in your home directory,
+If you have a \f(CR.friends\fP file in your home directory,
a convenient way to make \fBzsh\fP watch for all your friends
is to do this:
.Ds
@@ -2566,7 +2567,7 @@ is to do this:
%\0echo\0$watch
subbarao\0maruchck\0root\0sukthnkr\0\fR...
.De
-If watch is set to \fCall\fP, then all users logging in or out
+If watch is set to \f(CRall\fP, then all users logging in or out
will be reported.
.Sh "Options"
.PP
@@ -2584,7 +2585,7 @@ of a directory, and it will become the current directory.
%\0pwd
/etc
.De
-With \fICDABLEVARS\fP, if the argument to \fCcd\fP is the name of a
+With \fICDABLEVARS\fP, if the argument to \f(CRcd\fP is the name of a
parameter whose value is a valid directory, it will become
the current directory.
.Ds
@@ -2608,10 +2609,10 @@ zsh:\0correct\0`x.v11r4'\0to\0`X.V11R4'\0[nyae]?\0n
zsh:\0correct\0to\0`/etc/paswd'\0to\0`/etc/passwd'\0[nyae]?\0y
/etc/passwd
.De
-If you press \fCy\fP
+If you press \f(CRy\fP
when the shell asks you if you want to correct a word, it will
-be corrected. If you press \fCn\fP, it will be left alone.
-Pressing \fCa\fP aborts the command, and pressing \fCe\fP brings the line
+be corrected. If you press \f(CRn\fP, it will be left alone.
+Pressing \f(CRa\fP aborts the command, and pressing \f(CRe\fP brings the line
up for editing again, in case you agree the word is spelled wrong
but you don't like the correction.
.PP
@@ -2625,14 +2626,14 @@ foo
%
.De
-With \fICSHJUNKIEQUOTES\fP set, this is illegal, as it is
+With \fICSHJUNKIEQUOTES\fP set, this is invalid, as it is
in csh.
.Ds
%\0setopt\0cshjunkiequotes
%\0ls\0'foo
zsh:\0unmatched\0'
.De
-\fIGLOBDOTS\fP lets files beginning with a \fC.\fP be matched without
+\fIGLOBDOTS\fP lets files beginning with a \f(CR.\fP be matched without
explicitly specifying the dot. This can also be specified for a particular
pattern by appending (D) to it.
.Ds
@@ -2677,7 +2678,7 @@ xyze\0xyae\0xbde\0xcde
%\0echo\0x{y{z,a},{b,c}d}e
x{y{z,a},{b,c}d}e
.De
-\fIIGNOREEOF\fP forces the user to type \fCexit\fP or \fClogout\fP,
+\fIIGNOREEOF\fP forces the user to type \f(CRexit\fP or \f(CRlogout\fP,
instead of just pressing \fI^D\fP.
.Ds
%\0setopt\0ignoreeof
@@ -2685,7 +2686,7 @@ instead of just pressing \fI^D\fP.
zsh:\0use\0'exit'\0to\0exit.
.De
\fIINTERACTIVECOMMENTS\fP turns on interactive comments;
-comments begin with a \fC#\fP.
+comments begin with a \f(CR#\fP.
.Ds
%\0setopt\0interactivecomments
%\0date\0#\0this\0is\0a\0comment
@@ -2701,9 +2702,9 @@ overwriting an existing file.
zsh:\0file\0exists:\0/u/pfalstad/.zshrc
.De
If you really do want to clobber a file, you can use the
-\fC>!\fP operator.
-To make things easier in this case, the \fC>\fP is stored in
-the history list as a \fC>!\fP:
+\f(CR>!\fP operator.
+To make things easier in this case, the \f(CR>\fP is stored in
+the history list as a \f(CR>!\fP:
.Ds
%\0cat\0/dev/null\0>!\0~/.zshrc
%\0cat\0/etc/motd\0>\0~/.zshrc
@@ -2725,10 +2726,10 @@ single quotes in a singly quoted string:
.De
Finally,
\fISUNKEYBOARDHACK\fP wins the award for the strangest option.
-If a line ends with \fC`\fP, and there are an odd number of them
-on the line, the shell will ignore the trailing \fC`\fP. This
+If a line ends with \f(CR`\fP, and there are an odd number of them
+on the line, the shell will ignore the trailing \f(CR`\fP. This
is provided for keyboards whose RETURN key is too small,
-and too close to the \fC`\fP key.
+and too close to the \f(CR`\fP key.
.Ds
%\0setopt\0sunkeyboardhack
%\0date`
diff --git a/Doc/ztexi.yo b/Doc/ztexi.yo
index b754bf252..943988b62 100644
--- a/Doc/ztexi.yo
+++ b/Doc/ztexi.yo
@@ -256,6 +256,12 @@ def(endmenu)(0)(\
def(menu)(1)(\
* ARG1+NOTRANS(::)\
)
+def(startdetailmenu)(0)(\
+ NOTRANS(@detailmenu)\
+)
+def(enddetailmenu)(0)(\
+ NOTRANS(@end detailmenu)\
+)
COMMENT(--- indices ---)
diff --git a/Etc/.cvsignore b/Etc/.cvsignore
deleted file mode 100644
index 937897a04..000000000
--- a/Etc/.cvsignore
+++ /dev/null
@@ -1,4 +0,0 @@
-Makefile
-FAQ
-FAQ.html
-*.swp
diff --git a/Etc/CONTRIBUTORS b/Etc/CONTRIBUTORS
index 0c8190a93..7275a8ee8 100644
--- a/Etc/CONTRIBUTORS
+++ b/Etc/CONTRIBUTORS
@@ -35,7 +35,7 @@ Anderson, arno, Frank Benkstein, Jay Berkenbilt, Frank Blendinger, Zack
Cerza, Brendan Cully, Baptiste Daroussin, Danek Duvall, Ryan F, Sean
Finney, Daniel Friesel, Alexey I. Froloff, Tobias Gruetzmacher, Pierre
Habouzit, Richard Hartmann, Benjamin R. Haskell, Ag. D. Hatzimanikas,
-Pete Hollobon, Erik Johansson, Kohsuke Kawaguchi, Dough Kearns, Hannu
+Pete Hollobon, Erik Johansson, Kohsuke Kawaguchi, Doug Kearns, Hannu
Koivisto, Henryk Konsek, Chris Lamb, Vincent Lefevre, Roger Leigh, Eric
Mangold, Max Mikhanosha, Arkadiusz Miskiewicz, Matthieu Moy, Scott
Murray, Alexander Myodov, Štěpán Němec, Kalle Olavi Niemitalo, Kazuhiro
diff --git a/Etc/creating-a-release.txt b/Etc/creating-a-release.txt
index 80fe2b301..631eb3dc8 100644
--- a/Etc/creating-a-release.txt
+++ b/Etc/creating-a-release.txt
@@ -1,6 +1,6 @@
To create a zsh release:
-- Be satisfied that 'master' is releaseable.
+- Be satisfied that the branch you're working from is releaseable.
(No recent destabilizing changes, `make check` passes, etc)
- Bump or update:
@@ -11,17 +11,20 @@ To create a zsh release:
README (first two paragraphs, 'incompatibilities since' sections)
NEWS ('changes since' sections)
- The version-number sequence is as follows:
+ The version-number sequence for master releases is as follows:
- 5.8, 5.8.0.1-dev, 5.8.0.2-test, 5.8.1, 5.8.1.1-dev, 5.8.1.2-test, 5.9
+ 5.8, 5.8.999.1-dev, 5.8.999.2-test, 5.9, 5.9.999.1-dev, ...
+
+ The version-number sequence for release-branch releases is as follows:
+
+ 5.8, 5.8.0.1-dev, 5.8.0.2-test, 5.8.1, 5.8.1.1-dev, ...
Please note:
- All version numbers in this document are examples only and may not
reflect the actual version history of the shell.
- - A slightly different ordering of version-number components was used
- prior to zsh 5.8. All subsequent releases should use the scheme
- described above.
+ - The versioning scheme has changed a few times in the shell's history.
+ The current scheme was introduced following the release of zsh 5.9.1.
- Usually there is only one -dev version (1-dev), but there may be more
if for example there is a wordcode compatibility break, in which case
the sequence would be something like 1-dev, 2-dev, 3-test, .... No
@@ -52,11 +55,33 @@ To create a zsh release:
- If the tagged release is a stable release (as opposed to a test release):
- vi Config/version.mk # bump to 5.9.0.1-dev and tomorrow's date
+ vi Config/version.mk # bump to x.y.z.1-dev and tomorrow's date
git commit -am "Post-release version bump." &&
zshdev-add-nnnnn-and-changelog unposted
# or local equivalent (see above)
+ "x.y.z.1-dev" will be different depending on whether the release was produced
+ from master or a release branch. Refer to the version sequence above.
+
+- If the tagged release is a stable release of a new major version produced from
+ master (the version string is like "5.9"), create a release branch for the
+ development of minor updates to that version:
+
+ git checkout zsh-5.9 # tag you just created
+ git switch -c zsh-5.9-patches # release branch
+
+ Then bump the version number there too (see previous step).
+
+ In summary, for a stable release of a new major version like "5.9":
+
+ - Bump 5.8.999.2-test to 5.9 (and update README etc) in master
+ - Tag zsh-5.9 in master
+ - Bump 5.9 to 5.9.999.1-dev in master
+ - Create zsh-5.9-patches branch from zsh-5.9 tag
+ - Bump 5.9 to 5.9.0.1-dev in zsh-5.9-patches
+
+- Remember to push all of these changes, including the tag.
+
- Create tarball:
git checkout zsh-5.8.1.2-test
diff --git a/Functions/.cvsignore b/Functions/.cvsignore
deleted file mode 100644
index 89ff7b089..000000000
--- a/Functions/.cvsignore
+++ /dev/null
@@ -1,2 +0,0 @@
-Makefile
-*.swp
diff --git a/Functions/Misc/is-at-least b/Functions/Misc/is-at-least
index 5985684be..954990dcf 100644
--- a/Functions/Misc/is-at-least
+++ b/Functions/Misc/is-at-least
@@ -1,62 +1,53 @@
#
-# Test whether $ZSH_VERSION (or some value of your choice, if a second argument
-# is provided) is greater than or equal to x.y.z-r (in argument one). In fact,
-# it'll accept any dot/dash-separated string of numbers as its second argument
-# and compare it to the dot/dash-separated first argument. Leading non-number
-# parts of a segment (such as the "zefram" in 3.1.2-zefram4) are not considered
-# when the comparison is done; only the numbers matter. Any left-out segments
-# in the first argument that are present in the version string compared are
-# considered as zeroes, eg 3 == 3.0 == 3.0.0 == 3.0.0.0 and so on.
+# is-at-least: compare two version strings
#
-# Usage examples:
-# is-at-least 3.1.6-15 && setopt NO_GLOBAL_RCS
-# is-at-least 3.1.0 && setopt HIST_REDUCE_BLANKS
-# is-at-least 586 $MACHTYPE && echo 'You could be running Mandrake!'
-# is-at-least $ZSH_VERSION || print 'Something fishy here.'
+# Usage: is-at-least minimum_version [current_version]
+#
+# Returns true if current_version is equal to or newer than minimum_version.
+# If current_version is omitted, $ZSH_VERSION is used.
+# {minimum,current}_version is a string consisting of a few 'segments'
+# joined by either '.' or '-'. For example:
+# 1.2-test 3.1.2-zefram4
+# 4.4.5beta23 12.34-patch23a
+#
+# A segment with no digits, such as 'test' above, is ignored.
+#
+# Two segments are compared numerically if the first differing characters
+# are both digits, and lexically otherwise.
+#
+# If number of segments in the two version strings differ, missing
+# segments are assumed to be '0'. This means
+# 5.9, 5.9.0, 5.9.0.0, 5.9-test
+# are all considered to be the same version.
#
-# Note that segments that contain no digits at all are ignored, and leading
-# text is discarded if trailing digits follow, because this was the meaning
-# of certain zsh version strings in the early 2000s. Other segments that
-# begin with digits are compared using NUMERIC_GLOB_SORT semantics, and any
-# other segments starting with text are compared lexically.
-
emulate -L zsh
+setopt extended_glob
-local IFS=".-" min_cnt=0 ver_cnt=0 part min_ver version order
+local IFS=".-" min_ver cur_ver n order
: ${2=$ZSH_VERSION}
# sort out the easy corner cases first
-[[ $1 = $2 ]] && return 0 # same version
-[[ -n $2 ]] || return 1 # no version
+[[ -z $1 || -z $2 ]] && return 1 # no version
+[[ $1 = $2 ]] && return 0 # same version
+# split into segments
min_ver=(${=1})
-version=(${=2} 0)
+cur_ver=(${=2})
-while (( $min_cnt <= ${#min_ver} )); do
- while [[ "$part" != <-> ]]; do
- (( ++ver_cnt > ${#version} )) && return 0
- if [[ ${version[ver_cnt]} = *[0-9][^0-9]* ]]; then
- # Contains a number followed by text. Not a zsh version string.
- order=( ${version[ver_cnt]} ${min_ver[ver_cnt]} )
- if [[ ${version[ver_cnt]} = <->* ]]; then
- # Leading digits, compare by sorting with numeric order.
- [[ $order != ${${(On)order}} ]] && return 1
- else
- # No leading digits, compare by sorting in lexical order.
- [[ $order != ${${(O)order}} ]] && return 1
- fi
- [[ $order[1] != $order[2] ]] && return 0
- fi
- part=${version[ver_cnt]##*[^0-9]}
- done
+# remove segments containing no digits
+min_ver=( ${min_ver:#[^0-9]##} )
+cur_ver=( ${cur_ver:#[^0-9]##} )
+(( $#min_ver == 0 || $#cur_ver == 0 )) && return 1
- while true; do
- (( ++min_cnt > ${#min_ver} )) && return 0
- [[ ${min_ver[min_cnt]} = <-> ]] && break
- done
-
- (( part > min_ver[min_cnt] )) && return 0
- (( part < min_ver[min_cnt] )) && return 1
- part=''
+# find the first segment that differs
+for (( n = 1; n <= $#min_ver; ++n )) do
+ [[ ${min_ver[n]} != ${cur_ver[n]-0} ]] && break
done
+
+# if all segments in $min_ver are equal to those in $cur_ver
+(( n > $#min_ver )) && return 0
+
+# now compare the two segments that differ
+order=( ${cur_ver[n]-0} ${min_ver[n]-0} )
+[[ $order != ${${(On)order}} ]] && return 1 || return 0
diff --git a/Functions/Misc/regexp-replace b/Functions/Misc/regexp-replace
index d4408f0f7..86b28c5aa 100644
--- a/Functions/Misc/regexp-replace
+++ b/Functions/Misc/regexp-replace
@@ -1,91 +1,98 @@
-# Replace all occurrences of a regular expression in a variable. The
-# variable is modified directly. Respects the setting of the
-# option RE_MATCH_PCRE.
+# Replace all occurrences of a regular expression in a scalar variable.
+# The variable is modified directly. Respects the setting of the option
+# RE_MATCH_PCRE, but otherwise sets the zsh emulation mode.
#
-# First argument: *name* (not contents) of variable.
-# Second argument: regular expression
-# Third argument: replacement string. This can contain all forms of
-# $ and backtick substitutions; in particular, $MATCH will be replaced
-# by the portion of the string matched by the regular expression.
+# Arguments:
+#
+# 1. *name* (not contents) of variable or more generally any lvalue;
+# expected to be scalar.
+#
+# 2. regular expression
+#
+# 3. replacement string. This can contain all forms of
+# $ and backtick substitutions; in particular, $MATCH will be
+# replaced by the portion of the string matched by the regular
+# expression. Parsing errors are fatal to the shell process.
-# we use positional parameters instead of variables to avoid
-# clashing with the user's variable. Make sure we start with 3 and only
-# 3 elements:
-argv=("$1" "$2" "$3")
+if (( $# < 2 || $# > 3 )); then
+ print -ru2 "Usage: $0 <varname> <regexp> [<replacement>]"
+ return 2
+fi
-# $4 records whether pcre is enabled as that information would otherwise
-# be lost after emulate -L zsh
-4=0
-[[ -o re_match_pcre ]] && 4=1
+local _regexp_replace_use_pcre=0
+[[ -o re_match_pcre ]] && _regexp_replace_use_pcre=1
emulate -L zsh
+local _regexp_replace_subject=${(P)1} \
+ _regexp_replace_regexp=$2 \
+ _regexp_replace_replacement=$3 \
+ _regexp_replace_result \
+ MATCH MBEGIN MEND
-local MATCH MBEGIN MEND
local -a match mbegin mend
-if (( $4 )); then
+if (( _regexp_replace_use_pcre )); then
# if using pcre, we're using pcre_match and a running offset
# That's needed for ^, \A, \b, and look-behind operators to work
# properly.
zmodload zsh/pcre || return 2
- pcre_compile -- "$2" && pcre_study || return 2
+ pcre_compile -- "$_regexp_replace_regexp" && pcre_study || return 2
- # $4 is the current *byte* offset, $5, $6 reserved for later use
- 4=0 6=
+ local _regexp_replace_offset=0 _regexp_replace_start _regexp_replace_stop _regexp_replace_new ZPCRE_OP
+ local -a _regexp_replace_finds
- local ZPCRE_OP
- while pcre_match -b -n $4 -- "${(P)1}"; do
- # append offsets and computed replacement to the array
- # we need to perform the evaluation in a scalar assignment so that if
- # it generates an array, the elements are converted to string (by
+ while pcre_match -b -n $_regexp_replace_offset -- "$_regexp_replace_subject"; do
+ # we need to perform the evaluation in a scalar assignment so that
+ # if it generates an array, the elements are converted to string (by
# joining with the first character of $IFS as usual)
- 5=${(e)3}
- argv+=(${(s: :)ZPCRE_OP} "$5")
+ _regexp_replace_new=${(Xe)_regexp_replace_replacement}
+
+ _regexp_replace_finds+=( ${(s[ ])ZPCRE_OP} "$_regexp_replace_new" )
# for 0-width matches, increase offset by 1 to avoid
# infinite loop
- 4=$((argv[-2] + (argv[-3] == argv[-2])))
+ (( _regexp_replace_offset = _regexp_replace_finds[-2] + (_regexp_replace_finds[-3] == _regexp_replace_finds[-2]) ))
done
- (($# > 6)) || return # no match
+ (( $#_regexp_replace_finds )) || return # no match
- set +o multibyte
+ unsetopt multibyte
- # $5 contains the result, $6 the current offset
- 5= 6=1
- for 2 3 4 in "$@[7,-1]"; do
- 5+=${(P)1[$6,$2]}$4
- 6=$(($3 + 1))
+ _regexp_replace_offset=1
+ for _regexp_replace_start _regexp_replace_stop _regexp_replace_new in "$_regexp_replace_finds[@]"; do
+ _regexp_replace_result+=${_regexp_replace_subject[_regexp_replace_offset,_regexp_replace_start]}$_regexp_replace_new
+ (( _regexp_replace_offset = _regexp_replace_stop + 1 ))
done
- 5+=${(P)1[$6,-1]}
-else
+ _regexp_replace_result+=${_regexp_replace_subject[_regexp_replace_offset,-1]}
+
+else # no PCRE
# in ERE, we can't use an offset so ^, (and \<, \b, \B, [[:<:]] where
# available) won't work properly.
- # $4 is the string to be matched
- 4=${(P)1}
-
- while [[ -n $4 ]]; do
- if [[ $4 =~ $2 ]]; then
- # append initial part and substituted match
- 5+=${4[1,MBEGIN-1]}${(e)3}
- # truncate remaining string
- if ((MEND < MBEGIN)); then
- # zero-width match, skip one character for the next match
- ((MEND++))
- 5+=${4[1]}
- fi
- 4=${4[MEND+1,-1]}
- # indicate we did something
- 6=1
- else
- break
+ local _regexp_replace_ok=0
+ while [[ $_regexp_replace_subject =~ $_regexp_replace_regexp ]]; do
+ # append initial part and substituted match
+ _regexp_replace_result+=$_regexp_replace_subject[1,MBEGIN-1]${(Xe)_regexp_replace_replacement}
+ # truncate remaining string
+ if (( MEND < MBEGIN )); then
+ # zero-width match, skip one character for the next match
+ (( MEND++ ))
+ _regexp_replace_result+=$_regexp_replace_subject[MBEGIN]
fi
+ _regexp_replace_subject=$_regexp_replace_subject[MEND+1,-1]
+ _regexp_replace_ok=1
+ [[ -z $_regexp_replace_subject ]] && break
done
- [[ -n $6 ]] || return # no match
- 5+=$4
+ (( _regexp_replace_ok )) || return
+ _regexp_replace_result+=$_regexp_replace_subject
fi
-eval $1=\$5
+# assign result to target variable if at least one substitution was
+# made. At this point, if the variable was originally array or assoc, it
+# is converted to scalar. If $1 doesn't contain a valid lvalue
+# specification, an exception is raised (exits the shell process if
+# non-interactive).
+: ${(P)1::="$_regexp_replace_result"}
+
diff --git a/Functions/Misc/zgetopt b/Functions/Misc/zgetopt
new file mode 100755
index 000000000..4d5481abd
--- /dev/null
+++ b/Functions/Misc/zgetopt
@@ -0,0 +1,181 @@
+#!/bin/zsh -f
+
+# wrapper around zparseopts which gives it an interface similar to util-linux's
+# getopt(1). see zshcontrib(1) for documentation
+
+emulate -L zsh -o extended_glob
+zmodload -i zsh/zutil || return 3
+
+local func=${funcstack[1]:-${0:t}}
+local caller=${funcstack[2]:-${ZSH_ARGZERO:t}}
+local errname=$caller:$func
+local optspec pat i posix=0
+local -a match mbegin mend optvv argvv
+local -a array lopts sopts name
+local -a specs no_arg_opts req_arg_opts opt_arg_opts tmp
+
+[[ $zsh_eval_context[-1] == toplevel ]] && errname=$func
+
+# same as leading + in short-opts spec
+(( $+POSIXLY_CORRECT )) && posix=1
+
+zparseopts -n $errname -D -F -G - \
+ {A,-array}:-=array \
+ {l,-longoptions,-long-options}+:-=lopts \
+ {n,-name}:-=name \
+ {o,-options}:-=sopts \
+|| {
+ print -ru2 "usage: $func [-A <array>] [-l <spec>] [-n <name>] [-o <spec>] -- <arg> ..."
+ return 2
+}
+
+name=( ${(@)name/#(-n|--name=)/} )
+[[ -n $name ]] || name=( $caller )
+
+(( $#array )) && array=( "${(@)array/#(-A|--array=)/}" )
+
+if [[ $zsh_eval_context[-1] != toplevel ]]; then
+ [[ $array == *[^A-Za-z0-9_.]* ]] && {
+ print -ru2 - "$errname: invalid array name: $array"
+ return 2
+ }
+ (( $#array )) || array=( argv )
+
+elif [[ -n $array ]]; then
+ print -ru2 - "$errname: -A option not meaningful unless called as function"
+ return 2
+fi
+
+# getopt requires a short option spec; we'll require either short or long
+(( $#sopts || $#lopts )) || {
+ print -ru2 - "$errname: missing option spec"
+ return 2
+}
+
+optspec=${(@)sopts/#(-o|--options=)/}
+sopts=( )
+
+for (( i = 1; i <= $#optspec; i++ )); do
+ # leading '+': act POSIXLY_CORRECT
+ if [[ $i == 1 && $optspec[i] == + ]]; then
+ posix=1
+ # leading '-': should leave operands interspersed with options, but this is
+ # not really possible with zparseopts
+ elif [[ $i == 1 && $optspec[i] == - ]]; then
+ print -ru2 - "$errname: optspec with leading - (disable operand collection) not supported"
+ return 2
+ # special characters: [+=\\] because they're special to zparseopts, ':'
+ # because it's special to getopt, '-' because it's the parsing terminator
+ elif [[ $optspec[i] == [+:=\\-] ]]; then
+ print -ru2 - "$errname: invalid short-option name: $optspec[i]"
+ return 2
+ # 'a'
+ elif [[ $optspec[i+1] != : ]]; then
+ sopts+=( $optspec[i] )
+ # 'a:'
+ elif [[ $optspec[i+2] != : ]]; then
+ sopts+=( $optspec[i]: )
+ (( i += 1 ))
+ # 'a::'
+ elif [[ $optspec[i+3] != : ]]; then
+ sopts+=( $optspec[i]:: )
+ (( i += 2 ))
+ fi
+done
+
+lopts=( ${(@)lopts/#(-l|--long(|-)options=)/} )
+lopts=( ${(@s<,>)lopts} )
+
+# don't allow characters that are special to zparseopts in long-option specs.
+# see above
+pat='(*[+=\\]*|:*|*:::##|*:[^:]*)'
+[[ -n ${(@M)lopts:#$~pat} ]] && {
+ print -ru2 - "$errname: invalid long-option spec: ${${(@M)lopts:#$~pat}[1]}"
+ return 2
+}
+
+lopts=( ${(@)lopts/#/-} )
+specs=( $sopts $lopts )
+
+# used below to identify options with optional optargs
+no_arg_opts=( ${(@)${(@M)specs:#*[^:]}/#/-} )
+req_arg_opts=( ${(@)${(@)${(@M)specs:#*[^:]:}/#/-}/%:#} )
+opt_arg_opts=( ${(@)${(@)${(@M)specs:#*::}/#/-}/%:#} )
+
+# getopt returns all instances of each option given, so add +
+specs=( ${(@)specs/%(#b)(:#)/+$match[1]} )
+
+# if we've got nothing now, the user probably gave -o '' or sth. pass an
+# explicit '' to zparseopts
+(( $#specs )) || specs=( '' )
+
+# POSIXLY_CORRECT: stop parsing options after first non-option argument
+if (( posix )); then
+ argvv=( "$@" )
+ zparseopts -n $name -a optvv -v argvv -D -F -G - "${(@)specs}" || return 1
+
+# default: permute options following non-option arguments
+else
+ zparseopts -n $name -a optvv -D -E -F -G - "${(@)specs}" || return 1
+ # -D + -E leaves an explicit -- in argv where-ever it might appear
+ local seen
+ while (( $# )); do
+ [[ -z $seen && $1 == -- ]] && seen=1 && shift && continue
+ argvv+=( "$1" )
+ shift
+ done
+fi
+
+# getopt outputs all optargs as separate parameters, even missing optional ones,
+# so we scan through and add/separate those if needed
+(( $#opt_arg_opts )) && {
+ local cur next
+ local -a old_optvv=( "${(@)optvv}" )
+ optvv=( )
+
+ for (( i = 1; i <= $#old_optvv; i++ )); do
+ cur=$old_optvv[i]
+ next=$old_optvv[i+1]
+ # option with no optarg
+ if [[ -n ${no_arg_opts[(r)$cur]} ]]; then
+ optvv+=( $cur )
+ # option with required optarg -- will appear in next element
+ elif [[ -n ${req_arg_opts[(r)$cur]} ]]; then
+ optvv+=( $cur "$next" )
+ (( i++ ))
+ # long option with optional optarg -- will appear in same element delimited
+ # by = (even if missing)
+ elif [[ $cur == *=* && -n ${opt_arg_opts[(r)${cur%%=*}]} ]]; then
+ optvv+=( ${cur%%=*} "${cur#*=}" )
+ # short option with optional optarg -- will appear in same element with no
+ # delimiter (thus the option appears alone if the optarg is missing)
+ elif [[ -n ${opt_arg_opts[(r)${(M)cur#-?}]} ]]; then
+ optvv+=( ${(M)cur#-?} "${cur#-?}" )
+ # ???
+ else
+ print -ru2 - "$errname: parse error, please report!"
+ print -ru2 - "$errname: specs: ${(j< >)${(@q+)specs}}"
+ print -ru2 - "$errname: old_optvv: ${(j< >)${(@q+)old_optvv}}"
+ print -ru2 - "$errname: cur: $cur"
+ optvv+=( $cur ) # i guess?
+ fi
+ done
+}
+
+# called as function, assign to array. use EXIT trap to assign in caller's
+# context
+if [[ -n $array ]]; then
+ trap "$array=( ${(j< >)${(@q+)optvv}} -- ${(j< >)${(@q+)argvv}} )" EXIT
+
+# called as function, print
+elif [[ $zsh_eval_context[-1] != toplevel ]]; then
+ print -r - "${(@q+)optvv}" -- "${(@q+)argvv}"
+
+# called as a script, print. use unconditional single-quoting. this is ugly but
+# it's the closest to what getopt does and it offers compatibility with legacy
+# shells
+else
+ print -r - "${(@qq)optvv}" -- "${(@qq)argvv}"
+fi
+
+return 0
diff --git a/Functions/Misc/zkbd b/Functions/Misc/zkbd
index 1065a84f1..493cc65ea 100644
--- a/Functions/Misc/zkbd
+++ b/Functions/Misc/zkbd
@@ -9,9 +9,15 @@
}
emulate -RL zsh
-local zkbd term key seq
+local zkbd override term key seq
-zkbd=${ZDOTDIR:-$HOME}/.zkbd
+zparseopts -D -F -- d:=override || return 1
+
+if (( $#override )); then
+ zkbd=$override[2]
+else
+ zkbd=${ZDOTDIR:-$HOME}/.zkbd
+fi
[[ -d $zkbd ]] || mkdir $zkbd || return 1
trap 'unfunction getmbkey getseq; command rm -f $zkbd/$TERM.tmp' 0
diff --git a/Functions/Misc/zmv b/Functions/Misc/zmv
index 2002af5a6..ed4868346 100644
--- a/Functions/Misc/zmv
+++ b/Functions/Misc/zmv
@@ -183,7 +183,7 @@ repl=$2
shift 2
if [[ -n $opt_s && $action != ln ]]; then
- print -r -- "$myname: invalid option: -s" >&2
+ print -r -- "$myname: bad option: -s" >&2
return 1
fi
diff --git a/NEWS b/NEWS
index 7509eb0df..43ece675d 100644
--- a/NEWS
+++ b/NEWS
@@ -20,25 +20,38 @@ The parameter expansion flag ! was added for the referred-to name of a
named reference.
The parameter ZSH_EXEPATH expands to the full path of the current zsh
-process, reliably on Linux, Mac, {Net,Free,Dragonfly}BSD and falls
-back to argv[0] elsewhere.
+process, reliably on Linux, Mac, {Net,Free,Dragonfly}BSD, Solaris, and
+Cygwin, and falls back to argv[0] elsewhere.
The default keymap is now emacs. Users of the vi keymaps please check
README to see if you are affected.
In region_highlight and zle_highlight, italic and faint can be
specified as font attributes for terminals that support them.
+Additionally, a layer number can be specified using layer= to indicate
+precedence where highlighted regions overlap, and colours can be mixed
+with a previous layer's using opacity=.
-Highlighting groups can be referenced in region_highlight,
-zle_highlight, WATCHFMT and completion explanation strings for
-common attribute combinations and a layer can be specified to
-indicate precedence where highlighted regions overlap.
-Highlighting groups are also supported in the prompt via a new %H
-prompt escape.
+Highlighting groups with arbitrary text attribute combinations can be
+defined via the .zle.hlgroups parameter. These groups can be referenced
+by name in region_highlight and zle_highlight via hl=, and in prompt
+expansion, WATCHFMT, and completion explanation strings via the %H
+escape sequence.
Ellipsis markers shown by the line editor to indicate where the line
doesn't fit in the terminal can be highlighted.
+The shell now keeps track of various terminal settings and capabilities,
+such as support for 24-bit colour, via .term.extensions and related
+parameters. By default the terminal is queried to determine the
+appropriate values when ZLE starts.
+
+The zsh/nearcolor module is automatically loaded when an RGB hex triplet
+is used and the terminal doesn't support 24-bit colour.
+
+The shape and colour of the terminal cursor can be controlled, similarly
+to highlight regions, via the zle_cursorform parameter.
+
The ERR_EXIT and ERR_RETURN options were refined to be more self-
consistent and better aligned with the POSIX-2017 specification of
`set -e`. For details on what exactly changed, see the list of
@@ -54,11 +67,33 @@ NTP, etc. For the most part this is transparent to users. However, as a
side effect, some features like $SECONDS and the time keyword gained
(nominal) nanosecond precision.
-The zsh/zutil module's zparseopts builtin learnt a -v option which can
-be used to specify the array of arguments to parse instead of $@.
+POSIX real-time signals (SIGRTMIN etc) are now supported by the kill
+and trap builtins, TRAP* functions, and the signals parameter, where
+available.
+
+The kill builtin learnt a new option -q to send the signal via
+sigqueue(3) along with an arbitrary integer value, where available.
+
+The kill builtin also learnt a new -L option to print a list of all
+known signal numbers and their names.
+
+The zsh/zutil module's zparseopts builtin learnt the following:
+
+ - a new -G option enables GNU-style argument parsing
+ ('--opt=arg', etc.)
+
+ - a new -n option sets the program name for usage errors
+
+ - a new -v option specifies the array of arguments to parse instead
+ of $@
+
+ - a single empty option spec signifies that no options are recognised
-The zparseopts builtin also learnt a -G option which enables GNU-style
-argument parsing ('--opt=arg', etc.).
+Also, zparseopts now uses standard argument parsing for its own options,
+enabling support for option stacking (-DFG instead of -D -F -G).
+
+A new contrib function zgetopt was added. It wraps `zparseopts -G` to
+provide an interface similar to util-linux's getopt(1).
The module zsh/pcre has been updated to use the pcre2 library.
@@ -68,14 +103,37 @@ and zrand_int() math functions.
The shell keyword time now works on builtins, assignments, and
current-shell actions.
+The new completion helper _as_if can be used to complete one command as
+if it were another command with particular arguments.
+
The new completion helper _shadow can be used to temporarily wrap or
substitute a function. The contrib function mkshadow makes it easier
to use outside of completion contexts.
The zsh/mathfunc module now provides isnan() and isinf() functions.
-Changes since 5.8.1
--------------------
+The getopts builtin learnt a -p option to make it behave like the
+POSIX_BUILTINS option has been temporarily enabled.
+
+The shell now keeps track of the 'current' job inside subshells. This
+enables some job-control features (disown without arguments, the %% job
+spec, etc) to work where they previously didn't.
+
+The disown builtin learnt a new -a option to disown all jobs.
+
+The zsh/zutil module's zformat builtin learnt two new options, -q and
+-Q, to escape '%' characters in format strings and/or specs so further
+processing can be applied to the result. Quoting of each spec can also
+be controlled via the spec prefixes '%' and '%%'.
+
+A 'math' context now appears in $zsh_eval_context within arithmetic
+constructs. This can be used to create dual-purpose math functions.
+
+The shell now preserves COLUMNS and LINES from the environment when run
+non-interactively.
+
+Changes from 5.8.1 to 5.9
+-------------------------
zsh 5.9 is dedicated to the memory of Sven Guckes, who was, amongst other
things, a long-time zsh advocate. For more information, see:
diff --git a/README b/README
index 7fb2c2b80..35e6744a5 100644
--- a/README
+++ b/README
@@ -52,6 +52,11 @@ or, if your $VISUAL and $EDITOR environment variables vary,
to your .zshrc file. These snippets are compatible with previous
versions of the shell.
+Restricted mode has been removed. This was associated with the option
+RESTRICTED (-r). This was an outdated way to restrict what users may do and
+was very difficult to apply safely. Furthermore, modern systems have better,
+safer and more reliable ways to confine user actions.
+
The ERR_EXIT and ERR_RETURN options were refined to be more self-
consistent and better aligned with the POSIX-2017 specification of
`set -e`:
@@ -136,6 +141,52 @@ The typeset builtin now prints the floating-point values NaN, Inf, and
-Inf using that capitalisation, which matches the capitalisation used by
arithmetic expansion. (Previously they were printed in lowercase.)
+The zsh/zutil module's zparseopts builtin now always uses the last
+option name as given when storing it in an array. (Previously, options
+mapped with -M would sometimes be stored using the first name given.)
+
+Also, as a consequence of the zparseopts builtin now using standard
+argument parsing for its own options, long-option specs must be guarded
+using -- or similar.
+
+The _values completion helper now understands the leading '!' spec form
+supported by _arguments, bringing it in line with the documentation. As
+a consequence, a leading '!' in a value name must now be escaped if it
+should be taken literally, as in: _values desc '!hidden' '\!literal'
+
+The getopts builtin no longer interprets arguments beginning with a +
+as potential options during parsing when the POSIX_BUILTINS option is
+enabled. Additionally, as a consequence of learning the related -p
+option, an opt spec beginning with a hyphen must be guarded by - or --.
+(Note that the effect of a hyphen in the opt spec is unspecified.)
+
+The zsh/zutil module's zformat builtin now interprets the sequences %%
+and %) differently. Previously they were implemented via implicit
+specs, which could lead to unexpected behaviour in some (uncommon)
+circumstances.
+
+Local parameters are no longer converted to named directories. For
+example, the following now emits an error (assuming there is no other
+candidate for ~b):
+
+ () { local b=/bin; cd ~b }
+
+Completion utility functions like _description now escape '%' characters
+in most format specs by default, eliminating the need for function
+authors to manually escape them in _arguments optarg descriptions, etc.
+'%' characters output by some third-party functions may appear doubled
+until they're updated to account for this.
+
+Previously, the (w) subscript flag coerced an out-of-range index to the
+nearest in-range one. (e.g., given x='a b c', $x[(w)4] expanded to c.)
+This has been changed so that an out-of-range index now yields an empty
+string, as in other subscripting cases.
+
+Assignment and expansion via ${name=word}, ${name:=word}, and
+${name::=word} now respect parameter attributes (e.g. `typeset -u`) and
+generally behave more consistently, especially when name contains a
+subscript.
+
Incompatibilities between 5.8.1 and 5.9
---------------------------------------
diff --git a/Src/.cvsignore b/Src/.cvsignore
deleted file mode 100644
index 47b31911f..000000000
--- a/Src/.cvsignore
+++ /dev/null
@@ -1,35 +0,0 @@
-*.dll
-*.epro
-*.export
-*.mdh
-*.mdh.tmp
-*.mdhi
-*.mdhs
-*.o
-*.o.c
-*.so
-*.swp
-*.syms
-Makefile
-Makemod.in Makemod
-[_a-zA-Z0-9]*.pro
-ansi2knr
-bltinmods.list
-cscope.out
-libzsh.so*
-modules-bltin
-modules.index
-modules.index.tmp
-modules.stamp
-patchlevel.h
-sigcount.h
-signames.c signames2.c
-stamp-modobjs
-stamp-modobjs.tmp
-tags TAGS
-version.h
-zsh
-zshcurses.h
-zshpaths.h
-zshterm.h
-zshxmods.h
diff --git a/Src/Builtins/.cvsignore b/Src/Builtins/.cvsignore
deleted file mode 100644
index 1f8af3e1c..000000000
--- a/Src/Builtins/.cvsignore
+++ /dev/null
@@ -1,17 +0,0 @@
-Makefile
-Makefile.in
-*.export
-so_locations
-*.pro
-*.epro
-*.syms
-*.o
-*.o.c
-*.so
-*.mdh
-*.mdhi
-*.mdhs
-*.mdh.tmp
-rlimits.h
-*.swp
-*.dll
diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c
index e76c2118d..6184f178b 100644
--- a/Src/Builtins/rlimits.c
+++ b/Src/Builtins/rlimits.c
@@ -236,7 +236,7 @@ free_resinfo(void)
/**/
static int
-find_resource(char c)
+find_resource(convchar_t c)
{
int i;
for (i=0; i<RLIM_NLIMITS; ++i) {
@@ -738,13 +738,14 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
return 1;
}
res = -1;
- if (options && *options == '-') {
+ if (options && *options++ == '-') {
argv++;
- while (*++options) {
- if(*options == Meta)
- *++options ^= 32;
+ while (*options) {
+ int sz;
+ convchar_t opt = unmeta_one(options, &sz);
+ options += sz;
res = -1;
- switch (*options) {
+ switch (opt) {
case 'H':
hard = 1;
continue;
@@ -752,8 +753,8 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
soft = 1;
continue;
case 'N':
- if (options[1]) {
- number = options + 1;
+ if (*options) {
+ number = options;
} else if (*argv) {
number = *argv++;
} else {
@@ -768,7 +769,7 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
/*
* fake it so it looks like we just finished an option...
*/
- while (options[1])
+ while (*options)
options++;
break;
case 'a':
@@ -781,15 +782,15 @@ bin_ulimit(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
nres = RLIM_NLIMITS;
continue;
default:
- res = find_resource(*options);
+ res = find_resource(opt);
if (res < 0) {
/* unrecognised limit */
- zwarnnam(name, "bad option: -%c", *options);
+ zwarnnam(name, "bad option: -%c", opt);
return 1;
}
break;
}
- if (options[1]) {
+ if (*options) {
resmask |= 1 << res;
nres++;
}
diff --git a/Src/Builtins/sched.c b/Src/Builtins/sched.c
index 835e72cb7..49c66d040 100644
--- a/Src/Builtins/sched.c
+++ b/Src/Builtins/sched.c
@@ -194,9 +194,10 @@ bin_sched(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
} else if (!strcmp(arg, "o")) {
flags |= SCHEDFLAG_TRASH_ZLE;
} else {
- if (*arg)
- zwarnnam(nam, "bad option: -%c", *arg);
- else
+ if (*arg) {
+ convchar_t warg = unmeta_one(arg, NULL);
+ zwarnnam(nam, "bad option: -%c", warg);
+ } else
zwarnnam(nam, "option expected");
return 1;
}
diff --git a/Src/Modules/.cvsignore b/Src/Modules/.cvsignore
deleted file mode 100644
index f72db844e..000000000
--- a/Src/Modules/.cvsignore
+++ /dev/null
@@ -1,18 +0,0 @@
-Makefile
-Makefile.in
-*.export
-so_locations
-*.pro
-*.epro
-*.syms
-*.o
-*.o.c
-*.so
-*.mdh
-*.mdhi
-*.mdhs
-*.mdh.tmp
-*.swp
-errnames.c errcount.h
-*.dll
-curses_keys.h
diff --git a/Src/Modules/attr.c b/Src/Modules/attr.c
index f4bd04982..dd29e42f6 100644
--- a/Src/Modules/attr.c
+++ b/Src/Modules/attr.c
@@ -68,7 +68,7 @@ xsetxattr(const char *path, const char *name, const void *value,
size_t size, int flags, int symlink)
{
#ifdef XATTR_EXTRA_ARGS
- return setxattr(path, name, value, size, 0, flags | symlink ? XATTR_NOFOLLOW : 0);
+ return setxattr(path, name, value, size, 0, flags | (symlink ? XATTR_NOFOLLOW : 0));
#else
switch (symlink) {
case 0:
@@ -98,7 +98,8 @@ static int
bin_getattr(char *nam, char **argv, Options ops, UNUSED(int func))
{
int ret = 0;
- int val_len = 0, attr_len = 0, slen;
+ int slen;
+ ssize_t val_len = 0, attr_len = 0;
char *value, *file = argv[0], *attr = argv[1], *param = argv[2];
int symlink = OPT_ISSET(ops, 'h');
@@ -169,7 +170,8 @@ static int
bin_listattr(char *nam, char **argv, Options ops, UNUSED(int func))
{
int ret = 0;
- int val_len, list_len = 0, slen;
+ int slen;
+ ssize_t val_len, list_len = 0;
char *value, *file = argv[0], *param = argv[1];
int symlink = OPT_ISSET(ops, 'h');
diff --git a/Src/Modules/attr.mdd b/Src/Modules/attr.mdd
index fbe917bbf..3b765f489 100644
--- a/Src/Modules/attr.mdd
+++ b/Src/Modules/attr.mdd
@@ -7,6 +7,6 @@ fi
'
load=no
-autofeatures="b:zgetattr b:zsetattr b:zdelattr"
+autofeatures="b:zgetattr b:zsetattr b:zdelattr b:zlistattr"
objects="attr.o"
diff --git a/Src/Modules/cap.c b/Src/Modules/cap.c
index c79c9f07c..a99e15c88 100644
--- a/Src/Modules/cap.c
+++ b/Src/Modules/cap.c
@@ -30,21 +30,19 @@
#include "cap.mdh"
#include "cap.pro"
-#ifdef HAVE_CAP_GET_PROC
-
static int
bin_cap(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
{
int ret = 0;
cap_t caps;
- if(*argv) {
+ if (*argv) {
unmetafy(*argv, NULL);
caps = cap_from_text(*argv);
- if(!caps) {
+ if (!caps) {
zwarnnam(nam, "invalid capability string");
return 1;
}
- if(cap_set_proc(caps)) {
+ if (cap_set_proc(caps)) {
zwarnnam(nam, "can't change capabilities: %e", errno);
ret = 1;
}
@@ -52,15 +50,18 @@ bin_cap(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
char *result = NULL;
ssize_t length;
caps = cap_get_proc();
- if(caps)
+ if (caps)
result = cap_to_text(caps, &length);
- if(!caps || !result) {
+ if (!caps || !result) {
zwarnnam(nam, "can't get capabilities: %e", errno);
ret = 1;
} else
puts(result);
+ if (result)
+ cap_free(result);
}
- cap_free(caps);
+ if (caps)
+ cap_free(caps);
return ret;
}
@@ -75,14 +76,17 @@ bin_getcap(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
cap_t caps;
caps = cap_get_file(unmetafy(dupstring(*argv), NULL));
- if(caps)
+ if (caps)
result = cap_to_text(caps, &length);
if (!caps || !result) {
zwarnnam(nam, "%s: %e", *argv, errno);
ret = 1;
} else
printf("%s %s\n", *argv, result);
- cap_free(caps);
+ if (result)
+ cap_free(result);
+ if (caps)
+ cap_free(caps);
} while(*++argv);
return ret;
}
@@ -95,13 +99,13 @@ bin_setcap(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
unmetafy(*argv, NULL);
caps = cap_from_text(*argv++);
- if(!caps) {
+ if (!caps) {
zwarnnam(nam, "invalid capability string");
return 1;
}
do {
- if(cap_set_file(unmetafy(dupstring(*argv), NULL), caps)) {
+ if (cap_set_file(unmetafy(dupstring(*argv), NULL), caps)) {
zwarnnam(nam, "%s: %e", *argv, errno);
ret = 1;
}
@@ -110,14 +114,6 @@ bin_setcap(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
return ret;
}
-#else /* !HAVE_CAP_GET_PROC */
-
-# define bin_cap bin_notavail
-# define bin_getcap bin_notavail
-# define bin_setcap bin_notavail
-
-#endif /* !HAVE_CAP_GET_PROC */
-
/* module paraphernalia */
static struct builtin bintab[] = {
diff --git a/Src/Modules/cap.mdd b/Src/Modules/cap.mdd
index 905f7ca47..543cf0139 100644
--- a/Src/Modules/cap.mdd
+++ b/Src/Modules/cap.mdd
@@ -1,5 +1,5 @@
name=zsh/cap
-link=dynamic
+link=`if test "x$enable_cap" = xyes; then echo dynamic; else echo no; fi`
load=no
autofeatures="b:cap b:getcap b:setcap"
diff --git a/Src/Modules/clone.c b/Src/Modules/clone.c
index 4b2655505..db6d4b401 100644
--- a/Src/Modules/clone.c
+++ b/Src/Modules/clone.c
@@ -60,9 +60,9 @@ bin_clone(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
if (setsid() != mypid)
zwarnnam(nam, "failed to create new session: %e", errno);
#elif defined(TIOCNOTTY)
- if (ioctl(SHTTY, TIOCNOTTY, 0))
- zwarnnam(*args, "%e", errno);
- setpgrp(0L, mypid);
+ if (ioctl(SHTTY, TIOCNOTTY, 0))
+ zwarnnam(nam, "%e", errno);
+ setpgrp(0L, mypid);
#endif
dup2(ttyfd,0);
dup2(ttyfd,1);
diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c
index 8950cc153..f07ce7fd2 100644
--- a/Src/Modules/curses.c
+++ b/Src/Modules/curses.c
@@ -260,7 +260,7 @@ zcurses_validate_window(char *win, int criteria)
{
LinkNode target;
- if (win==NULL || strlen(win) < 1) {
+ if (win==NULL || !*win) {
zc_errno = ZCURSES_EINVALID;
return NULL;
}
@@ -284,8 +284,14 @@ zcurses_validate_window(char *win, int criteria)
static int
zcurses_free_window(ZCWin w)
{
- if (!(w->flags & ZCWF_PERMANENT) && delwin(w->win)!=OK)
- return 1;
+ int ret = 0;
+
+ if (!(w->flags & ZCWF_PERMANENT) && delwin(w->win)!=OK) {
+ DPUTS2(1, "BUG: Failed to delete ncurses window %s with %d children",
+ w->name ? w->name : "(null)",
+ w->children ? countlinknodes(w->children) : 0);
+ ret = 1;
+ }
if (w->name)
zsfree(w->name);
@@ -295,7 +301,7 @@ zcurses_free_window(ZCWin w)
zfree(w, sizeof(struct zc_win));
- return 0;
+ return ret;
}
static struct zcurses_namenumberpair *
@@ -378,6 +384,7 @@ zcurses_colorget(const char *nam, char *colorpair)
++next_cp;
if (next_cp >= COLOR_PAIRS || init_pair(next_cp, f, b) == ERR) {
+ --next_cp;
zsfree(cp);
return NULL;
}
@@ -385,6 +392,7 @@ zcurses_colorget(const char *nam, char *colorpair)
cpn = (Colorpairnode)zshcalloc(sizeof(struct colorpairnode));
if (!cpn) {
+ --next_cp;
zsfree(cp);
return NULL;
}
@@ -507,7 +515,7 @@ zccmd_addwin(const char *nam, char **args)
if (zcurses_validate_window(args[0], ZCURSES_UNUSED) == NULL &&
zc_errno) {
- zerrnam(nam, "%s: %s", zcurses_strerror(zc_errno), args[0], 0);
+ zwarnnam(nam, "%s: %s", zcurses_strerror(zc_errno), args[0]);
return 1;
}
@@ -527,8 +535,7 @@ zccmd_addwin(const char *nam, char **args)
node = zcurses_validate_window(args[5], ZCURSES_USED);
if (node == NULL) {
- zwarnnam(nam, "%s: %s", zcurses_strerror(zc_errno), args[0],
- 0);
+ zwarnnam(nam, "%s: %s", zcurses_strerror(zc_errno), args[5]);
zsfree(w->name);
zfree(w, sizeof(struct zc_win));
return 1;
@@ -555,7 +562,9 @@ zccmd_addwin(const char *nam, char **args)
return 1;
}
- zinsertlinknode(zcurses_windows, lastnode(zcurses_windows), (void *)w);
+ /* prepend window so that freelinklist will free children before parents,
+ * otherwise they will be leaked */
+ zinsertlinknode(zcurses_windows, (LinkNode)zcurses_windows, (void *)w);
return 0;
}
@@ -622,6 +631,9 @@ zccmd_delwin(const char *nam, char **args)
if (w->name)
zsfree(w->name);
+ if (w->children)
+ freelinklist(w->children, (FreeFunc)NULL);
+
zfree((ZCWin)remnode(zcurses_windows, node), sizeof(struct zc_win));
return ret;
@@ -641,8 +653,7 @@ zccmd_refresh(const char *nam, char **args)
node = zcurses_validate_window(args[0], ZCURSES_USED);
if (node == NULL) {
- zwarnnam(nam, "%s: %s", zcurses_strerror(zc_errno), args[0],
- 0);
+ zwarnnam(nam, "%s: %s", zcurses_strerror(zc_errno), args[0]);
return 1;
}
@@ -727,6 +738,7 @@ zccmd_char(const char *nam, char **args)
#ifdef HAVE_SETCCHAR
wchar_t c;
cchar_t cc;
+ size_t ret;
#endif
node = zcurses_validate_window(args[0], ZCURSES_USED);
@@ -738,7 +750,8 @@ zccmd_char(const char *nam, char **args)
w = (ZCWin)getdata(node);
#ifdef HAVE_SETCCHAR
- if (mbrtowc(&c, args[1], MB_CUR_MAX, NULL) < 1)
+ ret = mbrtowc(&c, args[1], MB_CUR_MAX, NULL);
+ if (ret == 0 || ret == MB_INVALID || ret == MB_INCOMPLETE)
return 1;
if (setcchar(&cc, &c, A_NORMAL, 0, NULL)==ERR)
@@ -834,6 +847,14 @@ zccmd_endwin(UNUSED(const char *nam), UNUSED(char **args))
* doing stuff with shttyinfo when we shouldn't really be.
*/
gettyinfo(&shttyinfo);
+ freelinklist(zcurses_windows, (FreeFunc) zcurses_free_window);
+ zcurses_windows = znewlinklist();
+ if (zcurses_colorpairs) {
+ deletehashtable(zcurses_colorpairs);
+ zcurses_colorpairs = NULL;
+ }
+ next_cp = 0;
+ zc_color_phase = 0;
}
return 0;
}
@@ -911,7 +932,14 @@ zccmd_bg(const char *nam, char **args)
ZCWin w;
char **attrs;
int ret = 0;
+#ifdef HAVE_SETCCHAR
+ cchar_t cc;
+ wchar_t wch = L' ';
+ attr_t bg_attrs = A_NORMAL;
+ short bg_cp = 0;
+#else
chtype ch = 0;
+#endif
if (!args[0])
return 1;
@@ -924,12 +952,20 @@ zccmd_bg(const char *nam, char **args)
w = (ZCWin)getdata(node);
- for(attrs = args+1; *attrs; attrs++) {
+ for (attrs = args+1; *attrs; attrs++) {
if (strchr(*attrs, '/')) {
Colorpairnode cpn;
if ((cpn = zcurses_colorget(nam, *attrs)) == NULL)
ret = 1;
- else if (cpn->colorpair >= 256) {
+ else
+#ifdef HAVE_SETCCHAR
+ bg_cp = (short)cpn->colorpair;
+ } else if (**attrs == '@') {
+ wch = (wchar_t)(unsigned char)((*attrs)[1] == Meta
+ ? (*attrs)[2] ^ 32
+ : (*attrs)[1]);
+#else
+ if (cpn->colorpair >= 256) {
/* pretty unlikely, but... */
zwarnnam(nam, "bg color pair %s has index (%d) too large (max 255)",
cpn->node.nam, cpn->colorpair);
@@ -939,6 +975,7 @@ zccmd_bg(const char *nam, char **args)
}
} else if (**attrs == '@') {
ch |= (*attrs)[1] == Meta ? (*attrs)[2] ^ 32 : (*attrs)[1];
+#endif
} else {
char *ptr;
int onoff;
@@ -962,14 +999,31 @@ zccmd_bg(const char *nam, char **args)
zwarnnam(nam, "attribute `%s' not known", ptr);
ret = 1;
} else {
+#ifdef HAVE_SETCCHAR
+ switch (onoff) {
+ case ZCURSES_ATTRON:
+ bg_attrs |= zca->number;
+ break;
+ case ZCURSES_ATTROFF:
+ bg_attrs &= ~zca->number;
+ break;
+ }
+ }
+ }
+ }
+
+ if (ret == 0) {
+ if (setcchar(&cc, &wch, bg_attrs, bg_cp, NULL) == ERR)
+ return 1;
+ return wbkgrnd(w->win, &cc) != OK;
+ }
+#else
switch(onoff) {
case ZCURSES_ATTRON:
- if (wattron(w->win, zca->number) == ERR)
- ret = 1;
+ ch |= zca->number;
break;
case ZCURSES_ATTROFF:
- if (wattroff(w->win, zca->number) == ERR)
- ret = 1;
+ ch &= ~zca->number;
break;
}
}
@@ -978,6 +1032,7 @@ zccmd_bg(const char *nam, char **args)
if (ret == 0)
return wbkgd(w->win, ch) != OK;
+#endif
return ret;
}
@@ -998,12 +1053,10 @@ zccmd_scroll(const char *nam, char **args)
w = (ZCWin)getdata(node);
if (!strcmp(args[1], "on")) {
- if (scrollok(w->win, TRUE) == ERR)
- return 1;
+ scrollok(w->win, TRUE);
w->flags |= ZCWF_SCROLL;
} else if (!strcmp(args[1], "off")) {
- if (scrollok(w->win, FALSE) == ERR)
- return 1;
+ scrollok(w->win, FALSE);
w->flags &= ~ZCWF_SCROLL;
} else {
char *endptr;
@@ -1050,17 +1103,13 @@ zccmd_input(const char *nam, char **args)
w = (ZCWin)getdata(node);
- if (nargs >= 3) {
- keypad(w->win, TRUE);
- } else {
- keypad(w->win, FALSE);
- }
+ keypad(w->win, nargs >= 3);
if (nargs >= 4) {
#ifdef NCURSES_MOUSE_VERSION
if (!(zcurses_flags & ZCF_MOUSE_ACTIVE) ||
(zcurses_flags & ZCF_MOUSE_MASK_CHANGED)) {
- if (mousemask(zcurses_mouse_mask, NULL) == (mmask_t)ERR) {
+ if (!mousemask(zcurses_mouse_mask, NULL)) {
zwarnnam(nam, "current mouse mode is not supported");
return 1;
}
@@ -1112,10 +1161,8 @@ zccmd_input(const char *nam, char **args)
switch (ret) {
case OK:
ret = wctomb(instr, (wchar_t)wi);
- if (ret == 0) {
- instr[0] = Meta;
- instr[1] = '\0' ^ 32;
- instr[2] = '\0';
+ if (ret <= 0) {
+ return 1;
} else {
(void)metafy(instr, ret, META_NOALLOC);
}
@@ -1306,8 +1353,7 @@ zccmd_mouse(const char *nam, char **args)
zwarnnam(nam, "mouse delay requires an integer argument");
return 1;
}
- if (mouseinterval((int)delay) != OK)
- ret = 1;
+ mouseinterval((int)delay);
} else {
char *arg = *args;
int onoff = 1;
@@ -1373,8 +1419,7 @@ zccmd_position(const char *nam, char **args)
}
array[6] = NULL;
- setaparam(args[1], array);
- return 0;
+ return !setaparam(args[1], array);
}
@@ -1412,8 +1457,11 @@ zccmd_querychar(const char *nam, char **args)
if (getcchar(&cc, &c, &attrs, &cp, NULL) == ERR)
return 1;
- /* Hmmm... I always get 0 for cp, whereas the following works... */
- cp = PAIR_NUMBER(winch(w->win));
+ /* only overwrite with workaround if we do get 0, the winch method
+ * is limited to 256 color pairs */
+ if (!cp)
+ /* Hmmm... I always get 0 for cp, whereas the following works... */
+ cp = PAIR_NUMBER(winch(w->win));
count = wctomb(instr, c);
if (count == -1)
@@ -1423,6 +1471,7 @@ zccmd_querychar(const char *nam, char **args)
inc = winch(w->win);
/* I think the following is correct, the manual is a little terse */
cp = PAIR_NUMBER(inc);
+ attrs = inc & A_ATTRIBUTES;
inc &= A_CHARTEXT;
if (imeta(inc)) {
instr[0] = Meta;
@@ -1432,7 +1481,6 @@ zccmd_querychar(const char *nam, char **args)
instr[0] = (unsigned char) inc;
instr[1] = '\0';
}
- attrs = inc;
#endif
/*
@@ -1568,10 +1616,10 @@ static int
bin_zcurses(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
{
char **saargs;
- struct zcurses_subcommand *zcsc;
+ const struct zcurses_subcommand *zcsc;
int num_args;
- struct zcurses_subcommand scs[] = {
+ static const struct zcurses_subcommand scs[] = {
{"init", zccmd_init, 0, 0},
{"addwin", zccmd_addwin, 5, 6},
{"delwin", zccmd_delwin, 1, 1},
@@ -1671,14 +1719,14 @@ static char **
zcurses_windowsgetfn(UNUSED(Param pm))
{
LinkNode node;
- char **arr, **arrptr;
+ char **arr;
int count = countlinknodes(zcurses_windows);
- arrptr = arr = (char **)zhalloc((count+1) * sizeof(char *));
+ arr = (char **)zhalloc((count+1) * sizeof(char *)) + count;
+ *arr = NULL;
for (node = firstnode(zcurses_windows); node; incnode(node))
- *arrptr++ = dupstring(((ZCWin)getdata(node))->name);
- *arrptr = NULL;
+ *--arr = dupstring(((ZCWin)getdata(node))->name);
return arr;
}
@@ -1774,9 +1822,8 @@ boot_(UNUSED(Module m))
int
cleanup_(Module m)
{
+ zccmd_endwin(NULL, NULL);
freelinklist(zcurses_windows, (FreeFunc) zcurses_free_window);
- if (zcurses_colorpairs)
- deletehashtable(zcurses_colorpairs);
return setfeatureenables(m, &module_features, NULL);
}
diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c
index 7d1720de5..09f8224f0 100644
--- a/Src/Modules/db_gdbm.c
+++ b/Src/Modules/db_gdbm.c
@@ -38,20 +38,8 @@
#define PM_UPTODATE PM_DONTIMPORT_SUID /* Safe PM_ bit to re-use */
#endif
-static Param createhash( char *name, int flags );
-static int append_tied_name( const char *name );
-static int remove_tied_name( const char *name );
-static char *unmetafy_zalloc(const char *to_copy, int *new_len);
-static void myfreeparamnode(HashNode hn);
-
static int no_database_action = 0;
-/*
- * Make sure we have all the bits I'm using for memory mapping, otherwise
- * I don't know what I'm doing.
- */
-#if defined(HAVE_GDBM_H) && defined(HAVE_GDBM_OPEN)
-
#include <gdbm.h>
static char *backtype = "db/gdbm";
@@ -139,7 +127,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
resource_name = OPT_ARG(ops, 'f');
pmname = *args;
- if ((tied_param = (Param)paramtab->getnode(paramtab, pmname)) &&
+ if ((tied_param = (Param)realparamtab->getnode(realparamtab, pmname)) &&
!(tied_param->node.flags & PM_UNSET)) {
/*
* Unset any existing parameter. Note there's no implicit
@@ -150,7 +138,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
* We need to do this before attempting to open the DB
* in case this variable is already tied to a DB.
*
- * This can fail if the variable is readonly or restricted.
+ * This can fail if the variable is readonly.
* We could call unsetparam() and check errflag instead
* of the return status.
*/
@@ -165,7 +153,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
return 1;
}
- if (!(tied_param = createhash(pmname, pmflags))) {
+ if (!(tied_param = creategdbmhash(pmname, pmflags))) {
zwarnnam(nam, "cannot create the requested parameter %s", pmname);
gdbm_close(dbf);
return 1;
@@ -191,7 +179,7 @@ bin_ztie(char *nam, char **args, Options ops, UNUSED(int func))
dbf_carrier->dbfile_path = ztrdup(resource_name);
addmodulefd(gdbm_fdesc(dbf), FDT_INTERNAL);
- append_tied_name(pmname);
+ append_tied_name(tied_param->node.nam);
return 0;
}
@@ -205,7 +193,7 @@ bin_zuntie(char *nam, char **args, Options ops, UNUSED(int func))
int ret = 0;
for (pmname = *args; *args++; pmname = *args) {
- pm = (Param) paramtab->getnode(paramtab, pmname);
+ pm = (Param) realparamtab->getnode(realparamtab, pmname);
if(!pm) {
zwarnnam(nam, "cannot untie %s", pmname);
ret = 1;
@@ -245,7 +233,7 @@ bin_zgdbmpath(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
return 1;
}
- pm = (Param) paramtab->getnode(paramtab, pmname);
+ pm = (Param) realparamtab->getnode(realparamtab, pmname);
if(!pm) {
zwarnnam(nam, "no such parameter: %s", pmname);
return 1;
@@ -657,7 +645,8 @@ finish_(UNUSED(Module m))
* Utility functions *
*********************/
-static Param createhash( char *name, int flags ) {
+/**/
+static Param creategdbmhash( char *name, int flags ) {
Param pm;
HashTable ht;
@@ -666,20 +655,11 @@ static Param createhash( char *name, int flags ) {
return NULL;
}
- if (pm->old)
- pm->level = locallevel;
-
/* This creates standard hash. */
ht = pm->u.hash = newparamtable(17, name);
- if (!pm->u.hash) {
- paramtab->removenode(paramtab, name);
- paramtab->freenode(&pm->node);
- zwarnnam(name, "out of memory when allocating hash");
- return NULL;
- }
/* Does free Param (unsetfn is called) */
- ht->freenode = myfreeparamnode;
+ ht->freenode = freegdbmnode;
/* These provide special features */
ht->getnode = ht->getnode2 = getgdbmnode;
@@ -692,6 +672,7 @@ static Param createhash( char *name, int flags ) {
* Adds parameter name to `zgdbm_tied`
*/
+/**/
static int append_tied_name( const char *name ) {
int old_len = arrlen(zgdbm_tied);
char **new_zgdbm_tied = zshcalloc( (old_len+2) * sizeof(char *));
@@ -717,6 +698,7 @@ static int append_tied_name( const char *name ) {
* Removes parameter name from `zgdbm_tied`
*/
+/**/
static int remove_tied_name( const char *name ) {
int old_len = arrlen(zgdbm_tied);
int new_len;
@@ -772,6 +754,8 @@ static int remove_tied_name( const char *name ) {
* - does zalloc of exact size for the new string,
* - restores work buffer to original content, to restore strlen
*/
+
+/**/
static char *
unmetafy_zalloc(const char *to_copy, int *new_len) {
char *work, *to_return;
@@ -795,8 +779,9 @@ unmetafy_zalloc(const char *to_copy, int *new_len) {
return to_return;
}
+/**/
static void
-myfreeparamnode(HashNode hn)
+freegdbmnode(HashNode hn)
{
Param pm = (Param) hn;
@@ -817,7 +802,3 @@ myfreeparamnode(HashNode hn)
}
zfree(pm, sizeof(struct param));
}
-
-#else
-# error no gdbm
-#endif /* have gdbm */
diff --git a/Src/Modules/db_gdbm.mdd b/Src/Modules/db_gdbm.mdd
index 210c22177..122ba8a36 100644
--- a/Src/Modules/db_gdbm.mdd
+++ b/Src/Modules/db_gdbm.mdd
@@ -1,5 +1,5 @@
name=zsh/db/gdbm
-link='if test "x$ac_cv_lib_gdbm_gdbm_open" = xyes && test "x$ac_cv_header_gdbm_h" = xyes; then
+link='if test "x$enable_gdbm" = xyes; then
echo dynamic
else
echo no
@@ -10,3 +10,5 @@ load=no
autofeatures="b:ztie b:zuntie b:zgdbmpath p:zgdbm_tied"
objects="db_gdbm.o"
+
+libs="@GDBM_LIBS@"
diff --git a/Src/Modules/hlgroup.c b/Src/Modules/hlgroup.c
index 1dc6ac2ef..819b54696 100644
--- a/Src/Modules/hlgroup.c
+++ b/Src/Modules/hlgroup.c
@@ -124,6 +124,8 @@ scangroup(ScanFunc func, int flags, int sgr)
PM_TYPE(v->pm->node.flags) != PM_HASHED)
return;
hlg = v->pm->gsu.h->getfn(v->pm);
+ if (!hlg)
+ return;
memset((void *)&pm, 0, sizeof(struct param));
pm.node.flags = PM_SCALAR;
@@ -131,6 +133,8 @@ scangroup(ScanFunc func, int flags, int sgr)
for (i = 0; i < hlg->hsize; i++)
for (hn = hlg->nodes[i]; hn; hn = hn->next) {
+ if (((Param) hn)->node.flags & PM_UNSET)
+ continue;
pm.u.str = convertattr(((Param) hn)->u.str, sgr);
pm.node.nam = hn->nam;
func(&pm.node, flags);
diff --git a/Src/Modules/ksh93.c b/Src/Modules/ksh93.c
index fa0785cda..5204ab8cc 100644
--- a/Src/Modules/ksh93.c
+++ b/Src/Modules/ksh93.c
@@ -73,11 +73,14 @@ matchgetfn(Param pm)
if (zsh_match && *zsh_match) {
if (isset(KSHARRAYS)) {
char **ap =
- (char **) zalloc(sizeof(char *) * (arrlen(zsh_match)+1));
+ (char **) zalloc(sizeof(char *) * (arrlen(zsh_match)+2));
+ char *match;
pm->u.arr = ap;
- *ap++ = ztrdup(getsparam("MATCH"));
+ match = ztrdup(getsparam("MATCH"));
+ *ap++ = match ? match : ztrdup("");
while (*zsh_match)
- *ap = ztrdup(*zsh_match++);
+ *ap++ = ztrdup(*zsh_match++);
+ *ap = NULL;
} else
pm->u.arr = zarrdup(zsh_match);
} else if (isset(KSHARRAYS)) {
@@ -159,7 +162,7 @@ ksh93_wrapper(Eprog prog, FuncWrap w, char *name)
#define LOCAL_NAMEREF (PM_LOCAL|PM_UNSET|PM_NAMEREF)
if ((pm = createparam(".sh.command", LOCAL_NAMEREF))) {
pm->level = locallevel; /* Why is this necessary? */
- /* Force scoping by assignent hack */
+ /* Force scoping by assignment hack */
setloopvar(".sh.command", "ZSH_DEBUG_CMD");
pm->node.flags |= PM_READONLY;
}
@@ -194,8 +197,7 @@ ksh93_wrapper(Eprog prog, FuncWrap w, char *name)
strcpy(sh_edmode, "\033");
else
strcpy(sh_edmode, "");
- if (sh_edchar == sh_unsetval)
- sh_edchar = dupstring(getsparam("KEYS"));
+ sh_edchar = dupstring(getsparam("KEYS"));
if (varedarg) {
char *ie = itype_end((sh_name = dupstring(varedarg)), INAMESPC, 0);
if (ie && *ie) {
@@ -264,18 +266,8 @@ boot_(Module m)
int
cleanup_(Module m)
{
- struct paramdef *p;
-
deletewrapper(m, wrapper);
- /* Clean up namerefs, otherwise deleteparamdef() is confused */
- for (p = partab; p < partab + sizeof(partab)/sizeof(*partab); ++p) {
- if (p->flags & PM_NAMEREF) {
- HashNode hn = gethashnode2(paramtab, p->name);
- if (hn)
- ((Param)hn)->node.flags &= ~PM_NAMEREF;
- }
- }
return setfeatureenables(m, &module_features, NULL);
}
diff --git a/Src/Modules/langinfo.c b/Src/Modules/langinfo.c
index 520b0370c..3f5af82f2 100644
--- a/Src/Modules/langinfo.c
+++ b/Src/Modules/langinfo.c
@@ -384,7 +384,7 @@ liitem(const char *name)
nlcode = &nl_vals[0];
for (element = (char **)nl_names; *element; element++, nlcode++) {
- if ((!strcmp(*element, name)))
+ if (!strcmp(*element, name))
return nlcode;
}
@@ -395,23 +395,19 @@ liitem(const char *name)
static HashNode
getlanginfo(UNUSED(HashTable ht), const char *name)
{
- int len;
nl_item *elem;
char *listr, *nameu;
Param pm = NULL;
nameu = dupstring(name);
- unmetafy(nameu, &len);
+ unmetafy(nameu, NULL);
pm = (Param) hcalloc(sizeof(struct param));
- pm->node.nam = nameu;
+ pm->node.nam = dupstring(name);
pm->node.flags = PM_READONLY | PM_SCALAR;
pm->gsu.s = &nullsetscalar_gsu;
- if(name)
- elem = liitem(name);
- else
- elem = NULL;
+ elem = liitem(nameu);
if (elem && (listr = nl_langinfo(*elem))) {
pm->u.str = dupstring(listr);
@@ -445,7 +441,6 @@ scanlanginfo(UNUSED(HashTable ht), ScanFunc func, int flags)
func(&pm->node, flags);
}
}
-
}
static struct paramdef partab[] = {
diff --git a/Src/Modules/langinfo.mdd b/Src/Modules/langinfo.mdd
index d56898d42..33166746c 100644
--- a/Src/Modules/langinfo.mdd
+++ b/Src/Modules/langinfo.mdd
@@ -1,6 +1,6 @@
name=zsh/langinfo
-link=`if test x$ac_cv_func_nl_langinfo; then echo either; else echo no; fi`
+link=`if test x$ac_cv_func_nl_langinfo = xyes; then echo either; else echo no; fi`
load=no
autofeatures="p:langinfo"
diff --git a/Src/Modules/nearcolor.c b/Src/Modules/nearcolor.c
index 83d7118b0..08bc7d8b1 100644
--- a/Src/Modules/nearcolor.c
+++ b/Src/Modules/nearcolor.c
@@ -37,13 +37,19 @@ struct cielab {
};
typedef struct cielab *Cielab;
+static inline double
+square(double a)
+{
+ return a*a;
+}
+
static double
deltae(Cielab lab1, Cielab lab2)
{
/* taking square root unnecessary as we're just comparing values */
- return pow(lab1->L - lab2->L, 2) +
- pow(lab1->a - lab2->a, 2) +
- pow(lab1->b - lab2->b, 2);
+ return square(lab1->L - lab2->L) +
+ square(lab1->a - lab2->a) +
+ square(lab1->b - lab2->b);
}
static void
@@ -73,7 +79,7 @@ RGBtoLAB(int red, int green, int blue, Cielab lab)
static int
mapRGBto88(int red, int green, int blue)
{
- int component[] = { 0, 0x8b, 0xcd, 0xff, 0x2e, 0x5c, 0x8b, 0xa2, 0xb9, 0xd0, 0xe7 };
+ int component[] = { 0, 0x8b, 0xcd, 0xff, 0x2e, 0x5c, 0x73, 0x8b, 0xa2, 0xb9, 0xd0, 0xe7 };
struct cielab orig, next;
double nextl, bestl = -1;
int r, g, b;
@@ -83,7 +89,7 @@ mapRGBto88(int red, int green, int blue)
RGBtoLAB(red, green, blue, &orig);
/* try every one of the 72 colours */
- for (r = 0; r < 11; r++) {
+ for (r = 0; r < 12; r++) {
for (g = 0; g <= 3; g++) {
for (b = 0; b <= 3; b++) {
if (r > 3) g = b = r; /* advance inner loops to the block of greys */
@@ -99,7 +105,7 @@ mapRGBto88(int red, int green, int blue)
}
}
- return (comp_r > 3) ? 77 + comp_r :
+ return (comp_r > 3) ? 76 + comp_r :
16 + (comp_r * 16) + (comp_g * 4) + comp_b;
}
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index 779dcd024..2bcfe81a3 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -40,7 +40,7 @@ static int incleanup;
/**/
static char *
-paramtypestr(Param pm)
+paramtypestr(Param pm, int append)
{
char *val = NULL;
int f = pm->node.flags;
@@ -91,6 +91,13 @@ paramtypestr(Param pm)
} else
val = dupstring("");
+ if (append) {
+ if ((pm->node.flags & PM_NAMEREF) && pm->u.str && *(pm->u.str) &&
+ (pm = (Param) realparamtab->getnode(realparamtab, pm->node.nam)) &&
+ !(pm->node.flags & PM_UNSET)) {
+ val = zhtricat(val, "-", paramtypestr(pm, 0));
+ }
+ }
return val;
}
@@ -106,12 +113,7 @@ getpmparameter(UNUSED(HashTable ht), const char *name)
pm->gsu.s = &nullsetscalar_gsu;
if ((rpm = (Param) realparamtab->getnode2(realparamtab, name)) &&
!(rpm->node.flags & PM_UNSET)) {
- pm->u.str = paramtypestr(rpm);
- if ((rpm->node.flags & PM_NAMEREF) && rpm->u.str && *(rpm->u.str) &&
- (rpm = (Param) realparamtab->getnode(realparamtab, name)) &&
- !(rpm->node.flags & PM_UNSET)) {
- pm->u.str = zhtricat(pm->u.str, "-", paramtypestr(rpm));
- }
+ pm->u.str = paramtypestr(rpm, 1);
} else {
pm->u.str = dupstring("");
pm->node.flags |= (PM_UNSET|PM_SPECIAL);
@@ -139,7 +141,7 @@ scanpmparameters(UNUSED(HashTable ht), ScanFunc func, int flags)
if (func != scancountparams &&
((flags & (SCANPM_WANTVALS|SCANPM_MATCHVAL)) ||
!(flags & SCANPM_WANTKEYS)))
- pm.u.str = paramtypestr((Param) hn);
+ pm.u.str = paramtypestr((Param) hn, 1);
func(&pm.node, flags);
}
}
@@ -150,17 +152,12 @@ scanpmparameters(UNUSED(HashTable ht), ScanFunc func, int flags)
static void
setpmcommand(Param pm, char *value)
{
- if (isset(RESTRICTED)) {
- zwarn("restricted: %s", value);
- zsfree(value);
- } else {
- Cmdnam cn = zshcalloc(sizeof(*cn));
+ Cmdnam cn = zshcalloc(sizeof(*cn));
- cn->node.flags = HASHED;
- cn->u.cmd = value;
+ cn->node.flags = HASHED;
+ cn->u.cmd = value;
- cmdnamtab->addnode(cmdnamtab, ztrdup(pm->node.nam), &cn->node);
- }
+ cmdnamtab->addnode(cmdnamtab, ztrdup(pm->node.nam), &cn->node);
}
/**/
@@ -220,10 +217,20 @@ getpmcommand(UNUSED(HashTable ht), const char *name)
Cmdnam cmd;
Param pm = NULL;
- if (!(cmd = (Cmdnam) cmdnamtab->getnode(cmdnamtab, name)) &&
- isset(HASHLISTALL)) {
- cmdnamtab->filltable(cmdnamtab);
- cmd = (Cmdnam) cmdnamtab->getnode(cmdnamtab, name);
+ if (!(cmd = (Cmdnam) cmdnamtab->getnode(cmdnamtab, name))) {
+ if (isset(HASHLISTALL)) {
+ cmdnamtab->filltable(cmdnamtab);
+ cmd = (Cmdnam) cmdnamtab->getnode(cmdnamtab, name);
+ } else {
+ /* this will return the path even if hashcmds is disabled,
+ * and store it in the hash if it is enabled */
+ char *found = findcmd((char*)name, 1, 0);
+ if (found) {
+ cmd = (Cmdnam) hcalloc(sizeof(*cmd));
+ cmd->u.cmd = found;
+ cmd->node.flags = HASHED;
+ }
+ }
}
pm = (Param) hcalloc(sizeof(struct param));
pm->node.nam = dupstring(name);
@@ -967,6 +974,7 @@ setpmoptions(Param pm, HashTable ht)
for (hn = ht->nodes[i]; hn; hn = hn->next) {
struct value v;
char *val;
+ int n;
v.scanflags = v.valflags = v.start = 0;
v.end = -1;
@@ -976,8 +984,9 @@ setpmoptions(Param pm, HashTable ht)
val = getstrvalue(&v);
if (!val || (strcmp(val, "on") && strcmp(val, "off")))
zwarn("invalid value: %s", val);
- else if (dosetopt(optlookup(hn->nam),
- (val && strcmp(val, "off")), 0, opts))
+ else if (!(n = optlookup(hn->nam)))
+ zwarn("no such option: %s", hn->nam);
+ else if (dosetopt(n, (val && strcmp(val, "off")), 0, opts))
zwarn("can't change option: %s", hn->nam);
}
/* See setpmcommands() above */
@@ -1293,7 +1302,7 @@ getpmjobtext(UNUSED(HashTable ht), const char *name)
selectjobtab(&jtab, &jmax);
- job = strtod(name, &pend);
+ job = strtol(name, &pend, 10);
/* Non-numeric keys are looked up by job name */
if (*pend)
job = getjob(name, NULL);
@@ -1367,7 +1376,8 @@ pmjobstate(Job jtab, int job)
state = "running";
else if (WIFEXITED(pn->status)) {
if (WEXITSTATUS(pn->status))
- sprintf((state = buf2), "exit %d", (pn->status));
+ sprintf((state = buf2), "exit %d",
+ WEXITSTATUS(pn->status));
else
state = "done";
} else if (WIFSTOPPED(pn->status))
@@ -1401,7 +1411,7 @@ getpmjobstate(UNUSED(HashTable ht), const char *name)
selectjobtab(&jtab, &jmax);
- job = strtod(name, &pend);
+ job = strtol(name, &pend, 10);
if (*pend)
job = getjob(name, NULL);
if (job >= 1 && job <= jmax &&
@@ -1473,7 +1483,7 @@ getpmjobdir(UNUSED(HashTable ht), const char *name)
selectjobtab(&jtab, &jmax);
- job = strtod(name, &pend);
+ job = strtol(name, &pend, 10);
if (*pend)
job = getjob(name, NULL);
if (job >= 1 && job <= jmax &&
@@ -2091,9 +2101,12 @@ static Groupset get_all_groups(void)
for (gaptr = gs->array; gaptr < gs->array + gs->num; gaptr++) {
grptr = getgrgid(gaptr->gid);
if (!grptr) {
- return NULL;
- }
- gaptr->name = dupstring(grptr->gr_name);
+ /* a group we're in has been deleted from /etc/groups */
+ char buf[DIGBUFSIZE];
+ convbase(buf, (zlong)gaptr->gid, 10);
+ gaptr->name = dupstring(buf);
+ } else
+ gaptr->name = dupstring(grptr->gr_name);
}
return gs;
diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c
index 67157cc01..98b52f8de 100644
--- a/Src/Modules/pcre.c
+++ b/Src/Modules/pcre.c
@@ -134,7 +134,7 @@ pcre_callout(pcre2_callout_block_8 *block, UNUSED(void *callout_data))
Eprog prog;
int ret=0;
- if (!block->callout_number &&
+ if (!block->callout_number && block->callout_string &&
((prog = parse_string((char *) block->callout_string, 0))))
{
int ef = errflag, lv = lastval;
diff --git a/Src/Modules/pcre.mdd b/Src/Modules/pcre.mdd
index 3e1579117..dac271b48 100644
--- a/Src/Modules/pcre.mdd
+++ b/Src/Modules/pcre.mdd
@@ -5,3 +5,5 @@ load=no
autofeatures="b:pcre_compile b:pcre_study b:pcre_match"
objects="pcre.o"
+
+libs="@PCRE_LIBS@"
diff --git a/Src/Modules/random.c b/Src/Modules/random.c
index 88ac9543c..8aca7e9d4 100644
--- a/Src/Modules/random.c
+++ b/Src/Modules/random.c
@@ -82,12 +82,15 @@ getrandom_buffer(void *buf, size_t len)
zwarn("Unable to get random data: %e.", errno);
return -1;
}
+ continue;
}
-#ifndef HAVE_ARC4RANDOM_BUF
+#ifdef HAVE_ARC4RANDOM_BUF
+ } while (0);
+#else
bufptr += ret;
val += ret;
+ } while (val < len);
#endif
- } while (ret < len);
return ret;
}
@@ -110,17 +113,11 @@ get_bound_random_buffer(uint32_t *buffer, size_t count, uint32_t max)
size_t i; /* loop counter */
getrandom_buffer((void*) buffer, count*sizeof(uint32_t));
- if (max == UINT32_MAX)
- return;
for(i=0;i<count;i++) {
multi_result = ((uint64_t) buffer[i]) * (uint64_t) max;
leftover = (uint32_t) multi_result;
- /*
- * The following if statement should (according to Google's Gemini)
- * only be executed with a probability of 1/2**32 or 2.33e-10
- */
if(leftover < max) {
threshold= -max % max;
while (leftover < threshold) {
@@ -162,30 +159,37 @@ math_zrand_int(UNUSED(char *name), int argc, mnumber *argv, UNUSED(int id))
{
mnumber ret;
uint32_t i;
- zlong lower=0, upper=UINT32_MAX,incl=0, diff;
+ zlong lower = 0,
+ upper = UINT32_MAX,
+ incl = 0,
+ diff = UINT32_MAX;
ret.type = MN_INTEGER;
switch (argc) {
- case 0: ret.u.l=get_srandom(NULL);
- return ret;
- break;
+ case 0: incl = 1; break;
case 3: incl = (argv[2].u.l != 0)?1:0;
case 2: lower = argv[1].u.l;
case 1: upper = argv[0].u.l;
default: diff = upper-lower+incl;
}
- if (lower < 0 || lower >= UINT32_MAX) {
- zwarn("Lower bound (%z) out of range: 0-4294967295",lower);
+ if (lower < 0 || lower > UINT32_MAX) {
+ zwarn("lower bound (%z) out of range: 0-4294967295",lower);
+ ret.u.l = 0; return ret;
} else if (upper < lower) {
- zwarn("Upper bound (%z) must be greater than Lower Bound (%z)",upper,lower);
- } else if (upper < 0 || upper >= UINT32_MAX) {
- zwarn("Upper bound (%z) out of range: 0-4294967295",upper);
+ zwarn("upper bound (%z) must be greater than lower bound (%z)",upper,lower);
+ ret.u.l = 0; return ret;
+ } else if (upper < 0 || upper > UINT32_MAX) {
+ zwarn("upper bound (%z) out of range: 0-4294967295", upper);
+ ret.u.l = 0; return ret;
}
- if ( diff == 0 ) {
+ if (diff == 0) {
ret.u.l=upper; /* still not convinced this shouldn't be an error. */
+ } else if (upper == UINT32_MAX && lower == 0 && incl == 1) {
+ ret.u.l = get_srandom(NULL);
+ return ret;
} else {
get_bound_random_buffer(&i,1,(uint32_t) diff);
ret.u.l=i+lower;
@@ -253,9 +257,8 @@ setup_(UNUSED(Module m))
return 1;
}
- errno=0;
if (!(S_ISCHR(st.st_mode)) ) {
- zwarn("Error getting kernel random pool: %e.", errno);
+ zwarn("Error getting kernel random pool: /dev/urandom is not a character device");
return 1;
}
#endif /* USE_URANDOM */
diff --git a/Src/Modules/random_real.c b/Src/Modules/random_real.c
index 4a8fcae19..3fc279b6d 100644
--- a/Src/Modules/random_real.c
+++ b/Src/Modules/random_real.c
@@ -70,7 +70,7 @@ _zclz64(uint64_t x) {
}
if (!(x & 0xC000000000000000ull)) {
n+=2;
- x<<=1;
+ x<<=2;
}
if (!(x & 0x8000000000000000ull)) {
n+=1;
diff --git a/Src/Modules/regex.c b/Src/Modules/regex.c
index d02769ef0..859312a2a 100644
--- a/Src/Modules/regex.c
+++ b/Src/Modules/regex.c
@@ -77,7 +77,7 @@ zcond_regex_match(char **a, int id)
r = regcomp(&re, rhre, rcflags);
if (r) {
zregex_regerrwarn(r, &re, "failed to compile regex");
- break;
+ goto CLEAN_BASEMETA;
}
/* re.re_nsub is number of parenthesized groups, we also need
* 1 for the 0 offset, which is the entire matched portion
diff --git a/Src/Modules/socket.c b/Src/Modules/socket.c
index c65b7dfce..3ecab42c9 100644
--- a/Src/Modules/socket.c
+++ b/Src/Modules/socket.c
@@ -56,9 +56,9 @@
static int
bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
{
- int err=1, verbose=0, test=0, targetfd=0;
+ int verbose=0, test=0, targetfd=0;
ZSOCKLEN_T len;
- struct sockaddr_un soun;
+ struct sockaddr_un soun = { 0 };
int sfd;
if (OPT_ISSET(ops,'v'))
@@ -90,6 +90,10 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
}
localfn = args[0];
+ if (strlen(localfn) >= sizeof(soun.sun_path)) {
+ zwarnnam(nam, "socket path too long: %d > %d", strlen(localfn), sizeof(soun.sun_path) -1 );
+ return 1;
+ }
sfd = socket(PF_UNIX, SOCK_STREAM, 0);
@@ -225,6 +229,16 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
if (verbose)
printf("new connection from %s is on fd %d\n", soun.sun_path, sfd);
}
+ else if (OPT_ISSET(ops,'s'))
+ {
+ if (!args[0]) {
+ zwarnnam(nam, "-s requires an argument");
+ return 1;
+ }
+
+ if (shutdown(atoi(args[0]), SHUT_WR))
+ zwarn("shutdown failed: %e", errno);
+ }
else
{
if (!args[0]) {
@@ -232,6 +246,11 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
return 1;
}
+ if (strlen(args[0]) >= sizeof(soun.sun_path)) {
+ zwarnnam(nam, "socket path too long: %d > %d", strlen(args[0]), sizeof(soun.sun_path) -1 );
+ return 1;
+ }
+
sfd = socket(PF_UNIX, SOCK_STREAM, 0);
if (sfd == -1) {
@@ -242,7 +261,7 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
soun.sun_family = AF_UNIX;
strncpy(soun.sun_path, args[0], sizeof(soun.sun_path)-1);
- if ((err = connect(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un)))) {
+ if (connect(sfd, (struct sockaddr *)&soun, sizeof(struct sockaddr_un))) {
zwarnnam(nam, "connection failed: %e", errno);
close(sfd);
return 1;
@@ -273,7 +292,7 @@ bin_zsocket(char *nam, char **args, Options ops, UNUSED(int func))
}
static struct builtin bintab[] = {
- BUILTIN("zsocket", 0, bin_zsocket, 0, 3, 0, "ad:ltv", NULL),
+ BUILTIN("zsocket", 0, bin_zsocket, 0, 3, 0, "ad:lstv", NULL),
};
static struct features module_features = {
diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c
index 5bf201dd3..cb216f33a 100644
--- a/Src/Modules/stat.c
+++ b/Src/Modules/stat.c
@@ -191,14 +191,14 @@ static void
stattimeprint(time_t tim, long nsecs, char *outbuf, int flags)
{
if (flags & STF_RAW) {
- sprintf(outbuf, "%ld", (unsigned long)tim);
+ sprintf(outbuf, "%ld", (long)tim);
if (flags & STF_STRING)
strcat(outbuf, " (");
}
if (flags & STF_STRING) {
char *oend = outbuf + strlen(outbuf);
- /* Where the heck does "40" come from? */
- ztrftime(oend, 40, timefmt, (flags & STF_GMT) ? gmtime(&tim) :
+ /* the buffer is PATH_MAX+9 long, but we already printed some stuff */
+ ztrftime(oend, PATH_MAX - DIGBUFSIZE - 10, timefmt, (flags & STF_GMT) ? gmtime(&tim) :
localtime(&tim), nsecs);
if (flags & STF_RAW)
strcat(oend, ")");
@@ -450,7 +450,8 @@ bin_stat(char *name, char **args, Options ops, UNUSED(int func))
ops->ind['s'] = 1;
break;
} else {
- zwarnnam(name, "bad option: -%c", *arg);
+ convchar_t warg = unmeta_one(arg, NULL);
+ zwarnnam(name, "bad option: -%c", warg);
return 1;
}
}
diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index f1c0d7042..57daf0d87 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -357,7 +357,7 @@ bin_sysopen(char *nam, char **args, Options ops, UNUSED(int func))
for (o = sizeof(openopts)/sizeof(*openopts) - 1; o >= 0 &&
strcasecmp(openopts[o].name, opt); o--) {}
if (o < 0) {
- zwarnnam(nam, "unsupported option: %s\n", opt);
+ zwarnnam(nam, "unsupported option: %s", opt);
return 1;
}
#if defined(FD_CLOEXEC) && !defined(O_CLOEXEC)
@@ -556,7 +556,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
#endif
while (*args && **args == '-') {
- int opt;
+ convchar_t opt;
char *optptr = *args + 1, *optarg;
args++;
if (!*optptr || !strcmp(optptr, "-"))
@@ -653,7 +653,8 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
break;
default:
- zwarnnam(nam, "flock: unknown option: %c", *optptr);
+ opt = unmeta_one(optptr, NULL);
+ zwarnnam(nam, "flock: bad option: %c", opt);
return 1;
}
optptr++;
@@ -686,7 +687,8 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
else
flags = O_RDWR | O_NOCTTY;
if ((flock_fd = open(unmeta(args[0]), flags)) < 0) {
- zwarnnam(nam, "failed to open %s for writing: %e", args[0], errno);
+ zwarnnam(nam, "failed to open %s for %sing: %e", args[0],
+ readlock ? "read" : "writ", errno);
return 1;
}
flock_fd = movefd(flock_fd);
diff --git a/Src/Modules/tcp.c b/Src/Modules/tcp.c
index 0bbce5d49..4366f3c02 100644
--- a/Src/Modules/tcp.c
+++ b/Src/Modules/tcp.c
@@ -279,6 +279,29 @@ zts_byfd(int fd)
return NULL;
}
+/**/
+mod_export int
+tcp_shutdown(Tcp_session sess)
+{
+ if (sess && sess->fd != -1)
+ {
+ if (sess->flags & ZTCP_LISTEN) {
+ zwarn("can't shutdown a listening socket");
+ return 1;
+ }
+ if (sess->flags & ZTCP_SHUTDOWN) {
+ zwarn("session is already shutdown");
+ return 1;
+ }
+ int err = shutdown(sess->fd, SHUT_WR);
+ if (err)
+ zwarn("shutdown failed: %e", errno);
+ sess->flags |= ZTCP_SHUTDOWN;
+ return 0;
+ }
+ return -1;
+}
+
static void
tcp_cleanup(void)
{
@@ -366,6 +389,22 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
}
}
+ if (OPT_ISSET(ops,'s')) {
+ targetfd = atoi(args[0]);
+ if(!targetfd) {
+ zwarnnam(nam, "%s is an invalid argument to -s", args[0]);
+ return 1;
+ }
+
+ sess = zts_byfd(targetfd);
+ if (sess) {
+ tcp_shutdown(sess);
+ return 0;
+ } else {
+ zwarnnam(nam, "fd %s not found in tcp table", args[0]);
+ return 1;
+ }
+ }
if (OPT_ISSET(ops,'c')) {
if (!args[0]) {
@@ -373,12 +412,12 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
}
else {
targetfd = atoi(args[0]);
- sess = zts_byfd(targetfd);
if(!targetfd) {
zwarnnam(nam, "%s is an invalid argument to -c", args[0]);
return 1;
}
+ sess = zts_byfd(targetfd);
if (sess)
{
if ((sess->flags & ZTCP_ZFTP) && !force)
@@ -594,6 +633,8 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
schar = 'Z';
else if (sess->flags & ZTCP_LISTEN)
schar = 'L';
+ else if (sess->flags & ZTCP_SHUTDOWN)
+ schar = 'S';
else if (sess->flags & ZTCP_INBOUND)
schar = 'I';
else
@@ -606,7 +647,8 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
printf("%s:%d %s %s:%d is on fd %d%s\n",
localname, ntohs(sess->sock.in.sin_port),
((sess->flags & ZTCP_LISTEN) ? "-<" :
- ((sess->flags & ZTCP_INBOUND) ? "<-" : "->")),
+ ((sess->flags & ZTCP_SHUTDOWN) ? "<>" :
+ ((sess->flags & ZTCP_INBOUND) ? "<-" : "->"))),
remotename, ntohs(sess->peer.in.sin_port),
sess->fd,
(sess->flags & ZTCP_ZFTP) ? " ZFTP" : "");
@@ -696,7 +738,7 @@ bin_ztcp(char *nam, char **args, Options ops, UNUSED(int func))
}
static struct builtin bintab[] = {
- BUILTIN("ztcp", 0, bin_ztcp, 0, 3, 0, "acd:flLtv", NULL),
+ BUILTIN("ztcp", 0, bin_ztcp, 0, 3, 0, "acd:flLstv", NULL),
};
static struct features module_features = {
diff --git a/Src/Modules/tcp.h b/Src/Modules/tcp.h
index f69e246e0..a9ea7df2d 100644
--- a/Src/Modules/tcp.h
+++ b/Src/Modules/tcp.h
@@ -81,8 +81,9 @@ union tcp_sockaddr {
typedef struct tcp_session *Tcp_session;
-#define ZTCP_LISTEN 1
-#define ZTCP_INBOUND 2
+#define ZTCP_LISTEN 1
+#define ZTCP_INBOUND 2
+#define ZTCP_SHUTDOWN 4
#define ZTCP_ZFTP 16
struct tcp_session {
diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c
index af4009a3a..2187bec42 100644
--- a/Src/Modules/termcap.c
+++ b/Src/Modules/termcap.c
@@ -51,7 +51,7 @@ static char *boolcodes[] = {
/**/
static int
-ztgetflag(char *s)
+ztgetflag(const char *s)
{
char **b;
@@ -59,7 +59,7 @@ ztgetflag(char *s)
* off, but other curses variants can't, so we fudge it. *
* This feature of ncurses appears to have gone away as *
* of NCURSES_MAJOR_VERSION == 5, so don't rely on it. */
- switch (tgetflag(s)) {
+ switch (tgetflag((char *) s)) {
case -1:
break;
case 0:
@@ -82,11 +82,20 @@ bin_echotc(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
char *s, buf[2048], *t, *u;
int num, argct;
- s = *argv++;
if (termflags & TERM_BAD)
return 1;
if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
return 1;
+
+ s = *argv++;
+ for (t = s; *t; t++) {
+ /* ncurses helpfully just crashes if you pass it nonascii */
+ if ((unsigned char)*t > 0x7f) {
+ zwarnnam(name, "no such capability: %s", s);
+ return 1;
+ }
+ }
+
/* if the specified termcap has a numeric value, display it */
if ((num = tgetnum(s)) != -1) {
printf("%d\n", num);
@@ -143,8 +152,9 @@ static struct builtin bintab[] = {
static HashNode
gettermcap(UNUSED(HashTable ht), const char *name)
{
- int len, num;
- char *tcstr, buf[2048], *u, *nameu;
+ int num;
+ char *tcstr, buf[2048], *u;
+ const char *t;
Param pm = NULL;
/* This depends on the termcap stuff in init.c */
@@ -153,18 +163,21 @@ gettermcap(UNUSED(HashTable ht), const char *name)
if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
return NULL;
-
- nameu = dupstring(name);
- unmetafy(nameu, &len);
+ for (t = name; *t; t++) {
+ /* ncurses helpfully just crashes if you pass it nonascii */
+ if ((unsigned char)*t > 0x7f) {
+ return NULL;
+ }
+ }
pm = (Param) hcalloc(sizeof(struct param));
- pm->node.nam = nameu;
+ pm->node.nam = dupstring(name);
pm->node.flags = PM_READONLY;
u = buf;
/* logic in the following cascade copied from echotc, above */
- if ((num = tgetnum(nameu)) != -1) {
+ if ((num = tgetnum((char *) name)) != -1) {
pm->gsu.i = &nullsetinteger_gsu;
pm->u.val = num;
pm->node.flags |= PM_INTEGER;
@@ -172,7 +185,7 @@ gettermcap(UNUSED(HashTable ht), const char *name)
}
pm->gsu.s = &nullsetscalar_gsu;
- switch (ztgetflag(nameu)) {
+ switch (ztgetflag(name)) {
case -1:
break;
case 0:
@@ -184,7 +197,7 @@ gettermcap(UNUSED(HashTable ht), const char *name)
pm->node.flags |= PM_SCALAR;
return &pm->node;
}
- if ((tcstr = tgetstr(nameu, &u)) != NULL && tcstr != (char *)-1) {
+ if ((tcstr = tgetstr((char *) name, &u)) != NULL && tcstr != (char *)-1) {
pm->u.str = dupstring(tcstr);
pm->node.flags |= PM_SCALAR;
} else {
@@ -201,7 +214,7 @@ scantermcap(UNUSED(HashTable ht), ScanFunc func, int flags)
{
Param pm = NULL;
int num;
- char **capcode, *tcstr, buf[2048], *u;
+ char **capcode, *tcstr, buf[2048];
#ifndef HAVE_NUMCODES
static char *numcodes[] = {
@@ -252,7 +265,6 @@ scantermcap(UNUSED(HashTable ht), ScanFunc func, int flags)
#endif
pm = (Param) hcalloc(sizeof(struct param));
- u = buf;
pm->node.flags = PM_READONLY | PM_SCALAR;
pm->gsu.s = &nullsetscalar_gsu;
@@ -286,6 +298,7 @@ scantermcap(UNUSED(HashTable ht), ScanFunc func, int flags)
zstrcodes
#endif
; *capcode; capcode++) {
+ char *u = buf;
if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL &&
tcstr != (char *)-1) {
pm->u.str = dupstring(tcstr);
diff --git a/Src/Modules/terminfo.c b/Src/Modules/terminfo.c
index f9ab64fb3..1df5f5c30 100644
--- a/Src/Modules/terminfo.c
+++ b/Src/Modules/terminfo.c
@@ -68,12 +68,20 @@ bin_echoti(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
long pars[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
char *strcap[] = { "pfkey", "pfloc", "pfx", "pln", "pfxl", NULL };
- s = *argv++;
/* This depends on the termcap stuff in init.c */
if (termflags & TERM_BAD)
return 1;
if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
return 1;
+
+ s = *argv++;
+ for (t = s; *t; t++) {
+ /* ncurses helpfully just crashes if you pass it nonascii */
+ if ((unsigned char)*t > 0x7f) {
+ zwarnnam(name, "no such terminfo capability: %s", s);
+ return 1;
+ }
+ }
/* if the specified capability has a numeric value, display it */
if (((num = tigetnum(s)) != -1) && (num != -2)) {
printf("%d\n", num);
@@ -111,7 +119,7 @@ bin_echoti(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
/* get the arguments */
for (arg=0; argv[arg]; arg++) {
if (strarg && arg > 0)
- pars[arg] = (long) argv[arg];
+ pars[arg] = (long) unmetafy(dupstring(argv[arg]), NULL);
else
pars[arg] = atoi(argv[arg]);
}
@@ -134,8 +142,9 @@ static struct builtin bintab[] = {
static HashNode
getterminfo(UNUSED(HashTable ht), const char *name)
{
- int len, num;
- char *tistr, *nameu;
+ int num;
+ char *tistr;
+ const char *t;
Param pm = NULL;
/* This depends on the termcap stuff in init.c */
@@ -144,22 +153,27 @@ getterminfo(UNUSED(HashTable ht), const char *name)
if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
return NULL;
- nameu = dupstring(name);
- unmetafy(nameu, &len);
+ for (t = name; *t; t++) {
+ /* ncurses helpfully just crashes if you pass it nonascii */
+ if ((unsigned char)*t > 0x7f) {
+ return NULL;
+ }
+ }
pm = (Param) hcalloc(sizeof(struct param));
- pm->node.nam = nameu;
+ pm->node.nam = dupstring(name);
pm->node.flags = PM_READONLY;
- if (((num = tigetnum(nameu)) != -1) && (num != -2)) {
+ if (((num = tigetnum((char *) name)) != -1) && (num != -2)) {
pm->u.val = num;
pm->node.flags |= PM_INTEGER;
pm->gsu.i = &nullsetinteger_gsu;
- } else if ((num = tigetflag(nameu)) != -1) {
+ } else if ((num = tigetflag((char *) name)) != -1) {
pm->u.str = num ? dupstring("yes") : dupstring("no");
pm->node.flags |= PM_SCALAR;
pm->gsu.s = &nullsetscalar_gsu;
- } else if ((tistr = (char *)tigetstr(nameu)) != NULL && tistr != (char *)-1) {
+ } else if ((tistr = (char *)tigetstr((char *) name)) != NULL &&
+ tistr != (char *)-1) {
pm->u.str = metafy(tistr, -1, META_HEAPDUP);
pm->node.flags |= PM_SCALAR;
pm->gsu.s = &nullsetscalar_gsu;
diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c
index bb27ab9db..dc601619f 100644
--- a/Src/Modules/watch.c
+++ b/Src/Modules/watch.c
@@ -241,7 +241,7 @@ watch3ary(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt)
static char *
watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
{
- char buf[40], buf2[80];
+ char buf[256], buf2[80];
time_t timet;
struct tm *tm;
char *fm2;
@@ -332,7 +332,7 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
case 'D':
if (fm2[1] == '{') {
char *dd, *ss;
- int n = 79;
+ int n = sizeof(buf2)-1;
for (ss = fm2 + 2, dd = buf2;
n-- && *ss && *ss != '}'; ++ss, ++dd)
@@ -349,7 +349,8 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini)
}
timet = getlogtime(u, inout);
tm = localtime(&timet);
- len = ztrftime(buf, 40, fm2, tm, 0L);
+ /* metafy may double the length in the worst case */
+ len = ztrftime(buf, sizeof(buf)/2, fm2, tm, 0L);
if (len > 0)
metafy(buf, len, META_NOALLOC);
applytextattributes(TSC_RAW);
@@ -695,8 +696,10 @@ static struct builtin bintab[] = {
};
static struct paramdef partab[] = {
- PARAMDEF("WATCH", PM_SCALAR|PM_SPECIAL, &watch, NULL),
- PARAMDEF("watch", PM_ARRAY|PM_SPECIAL, &watch, NULL),
+ PARAMDEF("WATCH", PM_SCALAR|PM_SPECIAL|PM_TIED, &watch,
+ NULL /* &colonarr_gsu (see setup_()) */),
+ PARAMDEF("watch", PM_ARRAY|PM_SPECIAL|PM_TIED, &watch,
+ NULL /* &vararray_gsu (see setup_() */),
};
static struct features module_features = {
@@ -739,23 +742,14 @@ boot_(UNUSED(Module m))
{
static char const * const default_watchfmt = DEFAULT_WATCHFMT;
- Param pma = (Param) paramtab->getnode(paramtab, "watch");
- Param pms = (Param) paramtab->getnode(paramtab, "WATCH");
- if (pma && pms && pma->u.arr == watch && pms->u.arr == watch) {
- /* only tie the two parameters if both were added */
- pma->ename = "WATCH";
- pms->ename = "watch";
- pma->node.flags |= PM_TIED;
- pms->node.flags |= PM_TIED;
- }
watch = mkarray(NULL);
/* These two parameters are only set to defaults if not set.
* So setting them in .zshrc will not be enough to load the
* module. It's useless until the watch array is set anyway. */
- if (!paramtab->getnode(paramtab, "WATCHFMT"))
+ if (!realparamtab->getnode2(realparamtab, "WATCHFMT"))
setsparam("WATCHFMT", ztrdup_metafy(default_watchfmt));
- if (!paramtab->getnode(paramtab, "LOGCHECK"))
+ if (!realparamtab->getnode2(realparamtab, "LOGCHECK"))
setiparam("LOGCHECK", 60);
addprepromptfn(&checksched);
diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index 230ad86f6..738b22b43 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -82,10 +82,6 @@ union zftp_sockaddr {
#endif
};
-#ifdef USE_LOCAL_H_ERRNO
-int h_errno;
-#endif
-
/*
* For FTP block mode
*
@@ -119,8 +115,8 @@ struct zfheader {
enum {
ZFHD_MARK = 16, /* restart marker */
ZFHD_ERRS = 32, /* suspected errors in block */
- ZFHD_EOFB = 64, /* block is end of record */
- ZFHD_EORB = 128 /* block is end of file */
+ ZFHD_EOFB = 64, /* block is end of file */
+ ZFHD_EORB = 128 /* block is end of record */
};
typedef int (*readwrite_t)(int, char *, off_t, int);
@@ -496,7 +492,7 @@ zfsetparam(char *name, void *val, int flags)
Param pm = NULL;
int type = (flags & ZFPM_INTEGER) ? PM_INTEGER : PM_SCALAR;
- if (!(pm = (Param) paramtab->getnode(paramtab, name))
+ if (!(pm = (Param) realparamtab->getnode2(realparamtab, name))
|| (pm->node.flags & PM_UNSET)) {
/*
* just make it readonly when creating, in case user
@@ -530,7 +526,7 @@ zfunsetparam(char *name)
{
Param pm;
- if ((pm = (Param) paramtab->getnode(paramtab, name))) {
+ if ((pm = (Param) realparamtab->getnode2(realparamtab, name))) {
pm->node.flags &= ~PM_READONLY;
unsetparam_pm(pm, 0, 1);
}
@@ -2038,7 +2034,7 @@ zfgetinfo(char *prompt, int noecho)
}
if (fgets(instr, 256, stdin) == NULL)
- instr[len = 0] = '\0';
+ instr[0] = '\0';
else if (instr[len = strlen(instr)-1] == '\n')
instr[len] = '\0';
@@ -2102,7 +2098,7 @@ zftp_params(UNUSED(char *name), char **args, UNUSED(int flags))
/* maybe user CTRL-c'd in the middle somewhere */
for (aptr = newarr; *aptr; aptr++)
zsfree(*aptr);
- zfree(newarr, len+1);
+ zfree(newarr, (len+1)*sizeof(char *));
return 1;
}
if (zfsess->userparams)
@@ -2191,7 +2187,7 @@ zftp_login(char *name, char **args, UNUSED(int flags))
int cnt;
for (cnt = 0; *args; args++)
cnt++;
- zwarnnam(name, "warning: %d command arguments not used\n", cnt);
+ zwarnnam(name, "warning: %d command arguments not used", cnt);
}
zfstatusp[zfsessno] |= ZFST_LOGI;
zfsetparam("ZFTP_USER", ztrdup(user), ZFPM_READONLY);
@@ -2480,7 +2476,7 @@ zftp_mode(char *name, char **args, UNUSED(int flags))
cmd[5] = (char) nt;
if (zfsendcmd(cmd) > 2)
return 1;
- zfstatusp[zfsessno] &= ZFST_MMSK;
+ zfstatusp[zfsessno] &= ~ZFST_MMSK;
zfstatusp[zfsessno] |= (nt == 'S') ? ZFST_STRE : ZFST_BLOC;
zfsetparam("ZFTP_MODE", ztrdup(str), ZFPM_READONLY);
return 0;
@@ -2563,7 +2559,7 @@ zftp_getput(char *name, char **args, int flags)
for (; *args; args++) {
char *ln, *rest = NULL;
off_t startat = 0;
- if (progress && (shfunc = getshfunc("zftp_progress"))) {
+ if (progress && getshfunc("zftp_progress")) {
off_t sz = -1;
/*
* This calls the SIZE command to get the size for remote
@@ -2875,10 +2871,10 @@ freesession(Zftp_session sptr)
{
char **ps, **pd;
zsfree(sptr->name);
- for (ps = zfparams, pd = zfsess->params; *ps; ps++, pd++)
+ for (ps = zfparams, pd = sptr->params; *ps; ps++, pd++)
if (*pd)
zsfree(*pd);
- zfree(zfsess->params, sizeof(zfparams));
+ zfree(sptr->params, sizeof(zfparams));
if (sptr->userparams)
freearray(sptr->userparams);
zfree(sptr, sizeof(struct zftp_session));
@@ -3097,8 +3093,13 @@ bin_zftp(char *name, char **args, UNUSED(Options ops), UNUSED(int func))
break;
default:
- zwarnnam(name, "preference %c not recognized", *ptr);
- break;
+ {
+ int sz;
+ convchar_t p = unmeta_one(ptr, &sz);
+ ptr += sz - 1;
+ zwarnnam(name, "preference %c not recognized", p);
+ break;
+ }
}
}
}
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index c2656698c..6e201e76b 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -292,6 +292,7 @@ get_pty(int master, int *retfd)
}
}
}
+ return 1; /* don't try to open a slave if we got no master */
}
name[5] = 't';
if ((sfd = open(name, O_RDWR|O_NOCTTY)) >= 0) {
@@ -436,16 +437,18 @@ newptycmd(char *nam, char *pname, char **args, int echo, int nblock)
zexit(lastval, ZEXIT_NORMAL);
}
#ifndef USE_CYGWIN_FIX
- master = movefd(master);
- if (master == -1) {
- zerrnam(nam, "cannot duplicate fd %d: %e", master, errno);
- scriptname = oscriptname;
- ineval = oineval;
- return 1;
+ {
+ int orig_master = master;
+ master = movefd(master);
+ if (master == -1) {
+ zerrnam(nam, "cannot duplicate fd %d: %e", orig_master, errno);
+ scriptname = oscriptname;
+ ineval = oineval;
+ return 1;
+ }
}
-#else
- addmodulefd(master, FDT_INTERNAL);
#endif
+ addmodulefd(master, FDT_MODULE);
p = (Ptycmd) zalloc(sizeof(*p));
@@ -529,12 +532,11 @@ deleteallptycmds(void)
static void
checkptycmd(Ptycmd cmd)
{
- char c;
- int r;
+ unsigned char c;
if (cmd->read != -1 || cmd->fin)
return;
- if ((r = read(cmd->fd, &c, 1)) <= 0) {
+ if (read(cmd->fd, &c, 1) <= 0) {
if (kill(cmd->pid, 0) < 0) {
cmd->fin = 1;
zclose(cmd->fd);
@@ -581,14 +583,19 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
buf = (char *) zhalloc((blen = 256) + 1);
}
if (cmd->read != -1) {
- buf[used] = (char) cmd->read;
- buf[used + 1] = '\0';
- seen = used = 1;
+ int readchar = cmd->read;
cmd->read = -1;
+ if (imeta(readchar)) {
+ buf[used++] = Meta;
+ buf[used++] = (char) (readchar ^ 32);
+ } else
+ buf[used++] = (char) readchar;
+ buf[used] = '\0';
+ seen = 1;
}
do {
if (noblock && cmd->read == -1) {
- int pollret;
+ int pollret = -1;
/*
* Check there is data available. Borrowed from
* poll_read() in utils.c and simplified.
@@ -604,6 +611,7 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
(SELECT_ARG_2_T) &foofd, NULL, NULL, &expire_tv);
#else
#ifdef FIONREAD
+ int val;
if (ioctl(cmd->fd, FIONREAD, (char *) &val) == 0)
pollret = (val > 0);
#endif
@@ -617,9 +625,13 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
* character. cmd->read stores the character read.
*/
long mode;
+ unsigned char c;
- if (setblock_fd(0, cmd->fd, &mode))
- pollret = read(cmd->fd, &cmd->read, 1);
+ if (setblock_fd(0, cmd->fd, &mode)) {
+ pollret = read(cmd->fd, &c, 1);
+ if (pollret == 1)
+ cmd->read = (int) c;
+ }
if (mode != -1)
fcntl(cmd->fd, F_SETFL, mode);
}
@@ -688,8 +700,12 @@ ptyread(char *nam, Ptycmd cmd, char **args, int noblock, int mustmatch)
#endif
#endif
) {
- cmd->old = (char *) zalloc(cmd->olen = used);
- memcpy(cmd->old, buf, cmd->olen);
+ if (used) {
+ cmd->old = (char *) zalloc(cmd->olen = used);
+ memcpy(cmd->old, buf, cmd->olen);
+ }
+ if (prog)
+ freepatprog(prog);
return 1;
}
@@ -786,7 +802,7 @@ bin_zpty(char *nam, char **args, Options ops, UNUSED(int func))
OPT_ISSET(ops,'m'))) ||
(OPT_ISSET(ops,'L') && (OPT_ISSET(ops,'b') || OPT_ISSET(ops,'e') ||
OPT_ISSET(ops,'m')))) {
- zwarnnam(nam, "illegal option combination");
+ zwarnnam(nam, "invalid option combination");
return 1;
}
if (OPT_ISSET(ops,'r') || OPT_ISSET(ops,'w')) {
diff --git a/Src/Modules/zselect.c b/Src/Modules/zselect.c
index 8c1267240..92a3b38c2 100644
--- a/Src/Modules/zselect.c
+++ b/Src/Modules/zselect.c
@@ -47,6 +47,10 @@ handle_digits(char *nam, char *argptr, fd_set *fdset, int *fdmax)
return 1;
}
fd = (int)zstrtol(argptr, &endptr, 10);
+ if (fd < 0 || fd >= FD_SETSIZE) {
+ zwarnnam(nam, "file descriptor out of range [0-%d]: %d", FD_SETSIZE-1, fd);
+ return 1;
+ }
if (*endptr) {
zwarnnam(nam, "garbage after file descriptor: %s", endptr);
return 1;
diff --git a/Src/Modules/zutil.c b/Src/Modules/zutil.c
index 9e1eabcf1..fce293dc4 100644
--- a/Src/Modules/zutil.c
+++ b/Src/Modules/zutil.c
@@ -595,7 +595,7 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
case 'q': min = 2; max = 2; break;
case 'g': min = 1; max = 3; break;
default:
- zwarnnam(nam, "invalid option: %s", args[0]);
+ zwarnnam(nam, "bad option: %s", args[0]);
return 1;
}
n = arrlen(args) - 1;
@@ -809,11 +809,13 @@ bin_zstyle(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
* olenp *olenp is the size allocated for *outp
* endchar Terminator character in addition to `\0' (may be '\0')
* presence -F: Ternary expressions test emptyness instead
+ * quote -q: >0 if instr should be %-quoted
+ * qspecs qspecs[c] is the number of %s added by %-quoting
* skip If 1, don't output, just parse.
*/
static char *zformat_substring(char* instr, char **specs, char **outp,
int *ousedp, int *olenp, int endchar,
- int presence, int skip)
+ int presence, int quote, int *qspecs, int skip)
{
char *s;
@@ -844,6 +846,15 @@ static char *zformat_substring(char* instr, char **specs, char **outp,
} else if (*s == '.' || testit)
s++;
+ // next char isn't a legal spec char -- unwind, treat the sequence
+ // literally
+ if (!testit && (!*s || *s == '%' || *s == ')' || *s == '-' || *s == '.')) {
+ // but swallow the % if no -q and this is %% or %)
+ if (!quote)
+ start += (s - start == 1 && (*s == '%' || *s == ')'));
+ s = start;
+ }
+
if (testit && (unsigned char) *s) {
int actval, testval, endcharl;
@@ -861,6 +872,8 @@ static char *zformat_substring(char* instr, char **specs, char **outp,
actval = strlen(specs[(unsigned char) *s]);
else
actval = 1;
+ // don't count extra %s from quoting when testing this
+ actval -= qspecs[(unsigned char) *s];
actval = right ? (testval < actval) : (testval >= actval);
} else {
if (right) /* put the sign back */
@@ -879,20 +892,36 @@ static char *zformat_substring(char* instr, char **specs, char **outp,
* Either skip true text and output false text, or
* vice versa... unless we are already skipping.
*/
- if (!(s = zformat_substring(s+1, specs, outp, ousedp,
- olenp, endcharl, presence, skip || actval)))
+ if (!(s = zformat_substring(s+1, specs, outp, ousedp, olenp,
+ endcharl, presence, quote, qspecs,
+ skip || actval)) || !*s)
return NULL;
- if (!(s = zformat_substring(s+1, specs, outp, ousedp,
- olenp, ')', presence, skip || !actval)))
+ if (!(s = zformat_substring(s+1, specs, outp, ousedp, olenp,
+ ')', presence, quote, qspecs,
+ skip || !actval)) || !*s)
return NULL;
} else if (skip) {
continue;
} else if ((spec = specs[(unsigned char) *s])) {
- int len;
+ int len, smin = min, smax = max;
- if ((len = strlen(spec)) > max && max >= 0)
- len = max;
- outl = (min >= 0 ? (min > len ? min : len) : len);
+ // the assumption with quoted specs is that the output will be
+ // subject to further % expansion -- adjust width specifiers so
+ // so that the result will be correct *after* that expansion
+ if ((smin > 0 || smax > 0) && qspecs[(unsigned char) *s]) {
+ int i;
+ for (i = 0; spec[i]; i++) {
+ if (spec[i] == '%') {
+ smin += (smin > 0 && i < smin) ? 1 : 0;
+ smax += (smax > 0 && i < smax) ? 1 : 0;
+ i++;
+ }
+ }
+ }
+
+ if ((len = strlen(spec)) > smax && smax >= 0)
+ len = smax;
+ outl = (smin >= 0 ? (smin > len ? smin : len) : len);
if (*ousedp + outl >= *olenp) {
int nlen = *olenp + outl + 128;
@@ -952,42 +981,96 @@ static char *zformat_substring(char* instr, char **specs, char **outp,
}
static int
-bin_zformat(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
+bin_zformat(char *nam, char **args, Options ops, UNUSED(int func))
{
- char opt;
+ unsigned char qopt = OPT_ISSET(ops, 'q') ? 'q' : OPT_ISSET(ops, 'Q') ? 'Q' : 0;
int presence = 0;
- if (args[0][0] != '-' || !(opt = args[0][1]) || args[0][2]) {
- zwarnnam(nam, "invalid argument: %s", args[0]);
+ if (OPT_ISSET(ops, 'q') && OPT_ISSET(ops, 'Q')) {
+ zwarnnam(nam, "only one of -qQ allowed");
+ return 1;
+ }
+ if (OPT_ISSET(ops, 'a') + OPT_ISSET(ops, 'f') + OPT_ISSET(ops, 'F') < 1) {
+ zwarnnam(nam, "one of -afF expected");
+ return 1;
+ }
+ if (OPT_ISSET(ops, 'a') + OPT_ISSET(ops, 'f') + OPT_ISSET(ops, 'F') > 1) {
+ zwarnnam(nam, "only one of -afF allowed");
+ return 1;
+ }
+ if (OPT_ISSET(ops, 'a') && qopt) {
+ zwarnnam(nam, "-qQ not allowed with -a");
return 1;
}
- args++;
- switch (opt) {
+ switch (OPT_ISSET(ops, 'a') ? 'a' : OPT_ISSET(ops, 'f') ? 'f' : 'F') {
case 'F':
presence = 1;
/* fall-through */
case 'f':
{
- char **ap, *specs[256] = {0}, *out;
- int olen, oused = 0;
-
- specs['%'] = "%";
- specs[')'] = ")";
+ char **ap, *specs[256] = {0}, *out, *arg;
+ int quote, olen, oused = 0;
+ int qspecs[256] = {0};
/* Parse the specs in argv. */
- for (ap = args + 2; *ap; ap++) {
- if (!ap[0][0] || ap[0][0] == '-' || ap[0][0] == '.' ||
- idigit(ap[0][0]) || ap[0][1] != ':') {
- zwarnnam(nam, "invalid argument: %s", *ap);
+ for (ap = args + 2; (arg = *ap); ap++) {
+ // quote by default (spec like d:...) with -qQ
+ quote = !!qopt;
+
+ // spec like %%d:... -- explicitly disable quoting
+ if (arg[0] == '%' && arg[1] == '%') {
+ quote = 0;
+ arg += 2;
+ // spec like %d:... -- explicitly enable quoting
+ } else if (arg[0] == '%') {
+ quote = 1;
+ arg += 1;
+ }
+
+ if (!arg[0] || arg[0] == '-' || arg[0] == '.' ||
+ arg[0] == '%' || arg[0] == ')' ||
+ idigit(arg[0]) || arg[1] != ':') {
+ zwarnnam(nam, "invalid spec: %s", *ap);
return 1;
}
- specs[(unsigned char) ap[0][0]] = ap[0] + 2;
+
+ if (quote) {
+ int len = 0, pct = 0;
+ char *aptr, *sptr, *spec = arg + 2;
+
+ for (aptr = arg + 2; *aptr; aptr++, len++) {
+ if (*aptr == '%') {
+ len++, pct++;
+ }
+ }
+
+ if (pct) {
+ spec = (char *) zhalloc(len + 1);
+ sptr = spec;
+ for (aptr = arg + 2; *aptr; aptr++) {
+ *sptr++ = *aptr;
+ if (*aptr == '%') {
+ *sptr++ = *aptr;
+ }
+ }
+ *sptr = '\0';
+ }
+
+ specs[(unsigned char) *arg] = spec;
+ qspecs[(unsigned char) *arg] = pct;
+ } else {
+ specs[(unsigned char) *arg] = arg + 2;
+ }
}
+
out = (char *) zhalloc(olen = 128);
- zformat_substring(args[1], specs, &out, &oused, &olen, '\0',
- presence, 0);
+ if (!zformat_substring(args[1], specs, &out, &oused, &olen, '\0',
+ presence, qopt == 'q', qspecs, 0)) {
+ zwarnnam(nam, "malformed format string: %s", args[1]);
+ return 1;
+ }
out[oused] = '\0';
setsparam(args[0], ztrdup(out));
@@ -1084,7 +1167,7 @@ bin_zformat(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
}
break;
}
- zwarnnam(nam, "invalid option: -%c", opt);
+ DPUTS(1, "BUG: unhandled option");
return 1;
}
@@ -1401,8 +1484,10 @@ rmatch(RParseResult *sm, char *subj, char *var1, char *var2, int comp)
next = br->state;
if (next->pattern && !next->patprog) {
tokenize(next->pattern);
- if (!(next->patprog = patcompile(next->pattern, 0, NULL)))
+ if (!(next->patprog = patcompile(next->pattern, 0, NULL))) {
+ freematch(&match1);
return 3;
+ }
}
if (next->pattern && pattry(next->patprog, subj) &&
(!next->guard || (execstring(next->guard, 1, 0,
@@ -1654,9 +1739,9 @@ add_opt_val(Zoptdesc d, char *arg)
if (!v) {
v = (Zoptval) zhalloc(sizeof(*v));
v->next = v->onext = NULL;
- v->name = n;
new = 1;
}
+ v->name = n; // insert the last given name into arrays
v->arg = arg;
if ((d->flags & ZOF_ARG) && !(d->flags & (ZOF_OPT | ZOF_SAME))) {
v->str = NULL;
@@ -1735,11 +1820,12 @@ zalloc_default_array(char ***aval, char *assoc, int keep, int num)
}
static int
-bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
+bin_zparseopts(char *nam, char **args, Options ops, UNUSED(int func))
{
char *o, *p, *n, **pp, **aval, **ap, *assoc = NULL, **cp, **np;
char *paramsname = NULL, **params;
- int del = 0, flags = 0, extract = 0, fail = 0, gnu = 0, keep = 0;
+ char *progname = scriptname ? scriptname : (argzero ? argzero : nam);
+ int flags = 0, del, extract, fail, gnu, keep;
Zoptdesc sopts[256], d;
Zoptarr a, defarr = NULL;
Zoptval v;
@@ -1748,133 +1834,61 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
opt_arrs = NULL;
memset(sopts, 0, 256 * sizeof(Zoptdesc));
- while ((o = *args++)) {
- if (*o == '-') {
- switch (o[1]) {
- case '\0':
- o = NULL;
- break;
- case '-':
- if (o[2])
- args--;
- /* else unreachable, default parsing removes "--" */
- o = NULL;
- break;
- case 'D':
- if (o[2]) {
- args--;
- o = NULL;
- break;
- }
- del = 1;
- break;
- case 'E':
- if (o[2]) {
- args--;
- o = NULL;
- break;
- }
- extract = 1;
- break;
- case 'F':
- if (o[2]) {
- args--;
- o = NULL;
- break;
- }
- fail = 1;
- break;
- case 'G':
- if (o[2]) {
- args--;
- o = NULL;
- break;
- }
- gnu = 1;
- break;
- case 'K':
- if (o[2]) {
- args--;
- o = NULL;
- break;
- }
- keep = 1;
- break;
- case 'M':
- if (o[2]) {
- args--;
- o = NULL;
- break;
- }
- flags |= ZOF_MAP;
- break;
- case 'a':
- if (defarr) {
- zwarnnam(nam, "default array given more than once");
- return 1;
- }
- if (o[2])
- n = o + 2;
- else if (*args)
- n = *args++;
- else {
- zwarnnam(nam, "missing array name");
- return 1;
- }
- defarr = (Zoptarr) zhalloc(sizeof(*defarr));
- defarr->name = n;
- defarr->num = 0;
- defarr->vals = defarr->last = NULL;
- defarr->next = NULL;
- opt_arrs = defarr;
- break;
- case 'A':
- if (assoc) {
- zwarnnam(nam, "associative array given more than once");
- return 1;
- }
- if (o[2])
- assoc = o + 2;
- else if (*args)
- assoc = *args++;
- else {
- zwarnnam(nam, "missing array name");
- return 1;
- }
- break;
- case 'v':
- if (paramsname) {
- zwarnnam(nam, "argv array given more than once");
- return 1;
- }
- if (o[2])
- paramsname = o + 2;
- else if (*args)
- paramsname = *args++;
- else {
- zwarnnam(nam, "missing array name");
- return 1;
- }
- break;
- default:
- /* Anything else is an option description */
- args--;
- o = NULL;
- break;
- }
- if (!o) {
- o = "";
- break;
- }
- } else {
- args--;
- break;
+ del = OPT_ISSET(ops, 'D');
+ extract = OPT_ISSET(ops, 'E');
+ fail = OPT_ISSET(ops, 'F');
+ gnu = OPT_ISSET(ops, 'G');
+ keep = OPT_ISSET(ops, 'K');
+ flags |= OPT_ISSET(ops, 'M') ? ZOF_MAP : 0;
+
+ if (OPT_ISSET(ops, 'a')) {
+ if (!*OPT_ARG(ops, 'a')) {
+ zwarnnam(nam, "missing array name for -a");
+ return 1;
+ }
+ defarr = (Zoptarr) zhalloc(sizeof(*defarr));
+ defarr->name = OPT_ARG(ops, 'a');
+ defarr->num = 0;
+ defarr->vals = defarr->last = NULL;
+ defarr->next = NULL;
+ opt_arrs = defarr;
+ }
+ if (OPT_ISSET(ops, 'A')) {
+ if (!*OPT_ARG(ops, 'A')) {
+ zwarnnam(nam, "missing array name for -A");
+ return 1;
+ }
+ assoc = OPT_ARG(ops, 'A');
+ }
+ if (OPT_ISSET(ops, 'n')) {
+ if (!*OPT_ARG(ops, 'n')) {
+ zwarnnam(nam, "missing program name for -n");
+ return 1;
+ }
+ progname = OPT_ARG(ops, 'n');
+ }
+ if (OPT_ISSET(ops, 'v')) {
+ if (!*OPT_ARG(ops, 'v')) {
+ zwarnnam(nam, "missing array name for -v");
+ return 1;
}
+ paramsname = OPT_ARG(ops, 'v');
}
- if (!o) {
+
+ params = getaparam((paramsname = paramsname ? paramsname : "argv"));
+ if (!params) {
+ zwarnnam(nam, "no such array: %s", paramsname);
+ return 1;
+ }
+
+ /* allow a single '' or - spec to signify no options recognised */
+ if (*args && !args[1] && (!**args || !strcmp(*args, "-"))) {
+ args++;
+ } else if (!*args) {
zwarnnam(nam, "missing option descriptions");
return 1;
}
+
while ((o = dupstring(*args++))) {
int f = 0;
if (!*o) {
@@ -1952,11 +1966,7 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
return 1;
}
}
- params = getaparam((paramsname = paramsname ? paramsname : "argv"));
- if (!params) {
- zwarnnam(nam, "no such array: %s", paramsname);
- return 1;
- }
+
np = cp = pp = ((extract && del) ? arrdup(params) : params);
for (; (o = *pp); pp++) {
/* Not an option. With GNU style, this includes '-' */
@@ -1980,10 +1990,15 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
while (*++o) {
if (!(d = sopts[(unsigned char) *o])) {
if (fail) {
- if (*o != '-' || o > *pp + 1)
- zwarnnam(nam, "bad option: -%c", *o);
- else
- zwarnnam(nam, "bad option: -%s", o);
+ if (*o != '-' || o > *pp + 1) {
+ convchar_t wc = unmeta_one(o, NULL);
+ fprintf(stderr, "%s: bad option: -", progname);
+ MB_CHARINIT();
+ zputs(MB_NICECHAR(wc), stderr);
+ fputc('\n', stderr);
+ } else {
+ fprintf(stderr, "%s: bad option: -%s\n", progname, o);
+ }
return 1;
}
o = NULL;
@@ -2002,8 +2017,8 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
(!(d->flags & (ZOF_GNUL | ZOF_GNUS)) &&
pp[1] && pp[1][0] != '-')) {
if (!pp[1]) {
- zwarnnam(nam, "missing argument for option: -%s",
- d->name);
+ fprintf(stderr, "%s: missing argument for option: -%s\n",
+ progname, d->name);
return 1;
}
add_opt_val(d, *++pp);
@@ -2045,8 +2060,8 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
(!(d->flags & (ZOF_GNUL | ZOF_GNUS)) &&
pp[1] && pp[1][0] != '-')) {
if (!pp[1]) {
- zwarnnam(nam, "missing argument for option: -%s",
- d->name);
+ fprintf(stderr, "%s: missing argument for option: -%s\n",
+ progname, d->name);
return 1;
}
add_opt_val(d, *++pp);
@@ -2133,8 +2148,8 @@ bin_zparseopts(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
}
static struct builtin bintab[] = {
- BUILTIN("zformat", 0, bin_zformat, 3, -1, 0, NULL, NULL),
- BUILTIN("zparseopts", 0, bin_zparseopts, 1, -1, 0, NULL, NULL),
+ BUILTIN("zformat", 0, bin_zformat, 2, -1, 0, "afFqQ", NULL),
+ BUILTIN("zparseopts", 0, bin_zparseopts, 0, -1, 0, "a:A:DEFGKMn:v:", NULL),
BUILTIN("zregexparse", 0, bin_zregexparse, 3, -1, 0, "c", NULL),
BUILTIN("zstyle", 0, bin_zstyle, 0, -1, 0, NULL, NULL),
};
diff --git a/Src/Zle/.cvsignore b/Src/Zle/.cvsignore
deleted file mode 100644
index 3295c6b85..000000000
--- a/Src/Zle/.cvsignore
+++ /dev/null
@@ -1,20 +0,0 @@
-Makefile
-Makefile.in
-*.export
-so_locations
-*.pro
-*.epro
-*.syms
-*.o
-*.o.c
-*.so
-*.mdh
-*.mdhi
-*.mdhs
-*.mdh.tmp
-thingies.list
-widgets.list
-zle_things.h
-zle_widget.h
-*.swp
-*.dll
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 54e6146ad..b6a8dd235 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -83,7 +83,7 @@ mod_export int menuacc;
/* Brace insertion stuff. */
/**/
-int hasunqu, useqbr, brpcs, brscs;
+int useqbr, brpcs, brscs;
/* Flags saying in what kind of string we are. */
@@ -307,7 +307,6 @@ do_completion(UNUSED(Hookdef dummy), Compldat dat)
*compqstack = (instring == QT_NONE) ? QT_BACKSLASH : (char)instring;
compqstack[1] = '\0';
- hasunqu = 0;
useline = (wouldinstab ? -1 : (lst != COMP_LIST_COMPLETE));
useexact = isset(RECEXACT);
zsfree(compexactstr);
@@ -1176,7 +1175,7 @@ check_param(char *s, int set, int test)
if (found &&
p[1] != Inpar && p[1] != Inbrack && p[1] != Snull) {
/* This is a parameter expression, not $(...), $[...], $'...'. */
- char *b = p + 1, *e = b, *ie;
+ char *b = p + 1, *e, *ie;
int br = 1, nest = 0;
if (*b == Inbrace) {
@@ -1719,7 +1718,7 @@ set_comp_sep(void)
return 1;
owb = offs;
offs = soffs;
- if ((p = check_param(ns, 0, 1))) {
+ if (check_param(ns, 0, 1)) {
for (p = ns; *p; p++)
if (*p == Dnull)
*p = '"';
@@ -3288,7 +3287,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
if ((*ap)->flags & (CMF_NOLIST | CMF_MULT))
nl++;
}
- /* used -O nosort or -V, don't sort */
+ /* used -o nosort or -V, don't sort */
} else {
/* didn't use -1 or -2, so remove all duplicates (efficient) */
if (!(flags & CGF_UNIQALL) && !(flags & CGF_UNIQCON)) {
@@ -3309,12 +3308,14 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
} else if (!ap[0]->disp) {
/* Mark those, that would show the same string in the list. */
for (dup = 0; bp[0] && !(bp[0])->disp &&
- !strcmp((*ap)->str, (bp[0])->str); bp = ++sp) {
+ !strcmp((*ap)->str, (bp[0])->str); bp = ++asp) {
(bp[0])->flags |= CMF_MULT;
dup = 1;
}
- if (dup)
+ if (dup) {
(*ap)->flags |= CMF_FMULT;
+ asp--;
+ }
}
}
if (del) {
diff --git a/Src/Zle/compctl.c b/Src/Zle/compctl.c
index de3ccdfce..c66bca888 100644
--- a/Src/Zle/compctl.c
+++ b/Src/Zle/compctl.c
@@ -383,7 +383,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
* cct is a temporary just to hold flags; it never needs freeing.
*/
struct compctl cct;
- char **argv = *av, argv_end[2] = "x";
+ char **argv = *av, argv_end[1] = "";
int ready = 0, hx = 0;
/* Handle `compctl + foo ...' specially: turn it into
@@ -412,10 +412,12 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
for (; !ready && argv[0] && argv[0][0] == '-' && (argv[0][1] || !first);) {
if (!argv[0][1])
*argv = "-+";
- while (!ready && *++(*argv)) {
- if(**argv == Meta)
- *++*argv ^= 32;
- switch (**argv) {
+ ++*argv;
+ while (!ready && **argv) {
+ int sz;
+ convchar_t arg = unmeta_one(*argv, &sz);
+ *argv += sz;
+ switch (arg) {
case 'f':
cct.mask |= CC_FILES;
break;
@@ -509,17 +511,18 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
case 't':
{
char *p;
+ convchar_t s;
if (cl) {
- zwarnnam(name, "illegal option -%c", **argv);
+ zwarnnam(name, "bad option: -%c", arg);
return 1;
}
- if ((*argv)[1]) {
- p = (*argv) + 1;
+ if (**argv) {
+ p = *argv;
*argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "retry specification expected after -%c",
- **argv);
+ arg);
return 1;
} else {
p = *++argv;
@@ -539,8 +542,8 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
cct.mask2 = CC_DEFCONT;
break;
default:
- zwarnnam(name, "invalid retry specification character `%c'",
- *p);
+ s = unmeta_one(p, NULL);
+ zwarnnam(name, "invalid retry specification character `%c'", s);
return 1;
}
if (p[1]) {
@@ -551,11 +554,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'k':
- if ((*argv)[1]) {
- cct.keyvar = (*argv) + 1;
+ if (**argv) {
+ cct.keyvar = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "variable name expected after -%c", **argv);
+ zwarnnam(name, "variable name expected after -%c", arg);
return 1;
} else {
cct.keyvar = *++argv;
@@ -563,11 +566,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'K':
- if ((*argv)[1]) {
- cct.func = (*argv) + 1;
+ if (**argv) {
+ cct.func = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "function name expected after -%c", **argv);
+ zwarnnam(name, "function name expected after -%c", arg);
return 1;
} else {
cct.func = *++argv;
@@ -580,11 +583,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
case 'X':
cct.mask &= ~CC_EXPANDEXPL;
expl:
- if ((*argv)[1]) {
- cct.explain = (*argv) + 1;
+ if (**argv) {
+ cct.explain = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "string expected after -%c", **argv);
+ zwarnnam(name, "string expected after -%c", arg);
return 1;
} else {
cct.explain = *++argv;
@@ -592,23 +595,23 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'y':
- if ((*argv)[1]) {
- cct.ylist = (*argv) + 1;
+ if (**argv) {
+ cct.ylist = *argv;
*argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "function/variable expected after -%c",
- **argv);
+ arg);
} else {
cct.ylist = *++argv;
*argv = argv_end;
}
break;
case 'P':
- if ((*argv)[1]) {
- cct.prefix = (*argv) + 1;
+ if (**argv) {
+ cct.prefix = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "string expected after -%c", **argv);
+ zwarnnam(name, "string expected after -%c", arg);
return 1;
} else {
cct.prefix = *++argv;
@@ -616,11 +619,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'S':
- if ((*argv)[1]) {
- cct.suffix = (*argv) + 1;
+ if (**argv) {
+ cct.suffix = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "string expected after -%c", **argv);
+ zwarnnam(name, "string expected after -%c", arg);
return 1;
} else {
cct.suffix = *++argv;
@@ -628,11 +631,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'g':
- if ((*argv)[1]) {
- cct.glob = (*argv) + 1;
+ if (**argv) {
+ cct.glob = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "glob pattern expected after -%c", **argv);
+ zwarnnam(name, "glob pattern expected after -%c", arg);
return 1;
} else {
cct.glob = *++argv;
@@ -640,12 +643,12 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 's':
- if ((*argv)[1]) {
- cct.str = (*argv) + 1;
+ if (**argv) {
+ cct.str = *argv;
*argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "command string expected after -%c",
- **argv);
+ arg);
return 1;
} else {
cct.str = *++argv;
@@ -654,13 +657,13 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
break;
case 'l':
if (cl) {
- zwarnnam(name, "illegal option -%c", **argv);
+ zwarnnam(name, "bad option: -%c", arg);
return 1;
- } else if ((*argv)[1]) {
- cct.subcmd = (*argv) + 1;
+ } else if (**argv) {
+ cct.subcmd = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "command name expected after -%c", **argv);
+ zwarnnam(name, "command name expected after -%c", arg);
return 1;
} else {
cct.subcmd = *++argv;
@@ -669,13 +672,13 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
break;
case 'h':
if (cl) {
- zwarnnam(name, "illegal option -%c", **argv);
+ zwarnnam(name, "bad option: -%c", arg);
return 1;
- } else if ((*argv)[1]) {
- cct.substr = (*argv) + 1;
+ } else if (**argv) {
+ cct.substr = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "command name expected after -%c", **argv);
+ zwarnnam(name, "command name expected after -%c", arg);
return 1;
} else {
cct.substr = *++argv;
@@ -683,11 +686,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'W':
- if ((*argv)[1]) {
- cct.withd = (*argv) + 1;
+ if (**argv) {
+ cct.withd = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "path expected after -%c", **argv);
+ zwarnnam(name, "path expected after -%c", arg);
return 1;
} else {
cct.withd = *++argv;
@@ -695,11 +698,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'J':
- if ((*argv)[1]) {
- cct.gname = (*argv) + 1;
+ if (**argv) {
+ cct.gname = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "group name expected after -%c", **argv);
+ zwarnnam(name, "group name expected after -%c", arg);
return 1;
} else {
cct.gname = *++argv;
@@ -707,11 +710,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'V':
- if ((*argv)[1]) {
- cct.gname = (*argv) + 1;
+ if (**argv) {
+ cct.gname = *argv;
*argv = argv_end;
} else if (!argv[1]) {
- zwarnnam(name, "group name expected after -%c", **argv);
+ zwarnnam(name, "group name expected after -%c", arg);
return 1;
} else {
cct.gname = *++argv;
@@ -730,9 +733,9 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
case 'M':
if (cclist & COMP_LIST) {
cclist |= COMP_LISTMATCH;
- } else if ((*argv)[1]) {
+ } else if (**argv) {
if ((cct.matcher =
- parse_cmatcher(name, (cct.mstr = (*argv) + 1))) ==
+ parse_cmatcher(name, (cct.mstr = *argv))) ==
pcm_err) {
cct.matcher = NULL;
cct.mstr = NULL;
@@ -741,7 +744,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
*argv = argv_end;
} else if (!argv[1]) {
zwarnnam(name, "matching specification expected after -%c",
- **argv);
+ arg);
return 1;
} else {
if ((cct.matcher =
@@ -755,16 +758,16 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
case 'H':
- if ((*argv)[1])
- cct.hnum = atoi((*argv) + 1);
+ if (**argv)
+ cct.hnum = atoi(*argv);
else if (argv[1])
cct.hnum = atoi(*++argv);
else {
- zwarnnam(name, "number expected after -%c", **argv);
+ zwarnnam(name, "number expected after -%c", arg);
return 1;
}
if (!argv[1]) {
- zwarnnam(name, "missing pattern after -%c", **argv);
+ zwarnnam(name, "missing pattern after -%c", arg);
return 1;
}
cct.hpat = *++argv;
@@ -776,7 +779,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
break;
case 'C':
if (cl) {
- zwarnnam(name, "illegal option -%c", **argv);
+ zwarnnam(name, "bad option: -%c", arg);
return 1;
}
if (first && !hx) {
@@ -788,7 +791,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
break;
case 'D':
if (cl) {
- zwarnnam(name, "illegal option -%c", **argv);
+ zwarnnam(name, "bad option: -%c", arg);
return 1;
}
if (first && !hx) {
@@ -801,7 +804,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
break;
case 'T':
if (cl) {
- zwarnnam(name, "illegal option -%c", **argv);
+ zwarnnam(name, "bad option: -%c", arg);
return 1;
}
if (first && !hx) {
@@ -813,11 +816,11 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
break;
case 'L':
if (cl) {
- zwarnnam(name, "illegal option -%c", **argv);
+ zwarnnam(name, "bad option: -%c", arg);
return 1;
}
if (!first || hx) {
- zwarnnam(name, "illegal use of -L flag");
+ zwarnnam(name, "invalid use of -L flag");
return 1;
}
cclist |= COMP_LIST;
@@ -828,7 +831,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
return 1;
}
if (!argv[1]) {
- zwarnnam(name, "condition expected after -%c", **argv);
+ zwarnnam(name, "condition expected after -%c", arg);
return 1;
}
if (first) {
@@ -845,10 +848,10 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
}
break;
default:
- if (!first && (**argv == '-' || **argv == '+') && !argv[0][1])
- (*argv)--, argv--, ready = 1;
+ if (!first && (arg == '-' || arg == '+') && !**argv)
+ *argv -= sz + 1, argv--, ready = 1;
else {
- zwarnnam(name, "bad option: -%c", **argv);
+ zwarnnam(name, "bad option: -%c", arg);
return 1;
}
}
@@ -857,7 +860,7 @@ get_compctl(char *name, char ***av, Compctl cc, int first, int isdef, int cl)
if (*++argv && (!ready || ready == 2) &&
**argv == '+' && !argv[0][1]) {
if (cl) {
- zwarnnam(name, "xor'ed completion illegal");
+ zwarnnam(name, "xor'ed completion invalid");
return 1;
}
/* There's an alternative (+) completion: assign
@@ -1462,8 +1465,6 @@ printcompctl(char *s, Compctl cc, int printflags, int ispat)
while (cc2) {
/* loop over conditions */
- c = cc2->cond;
-
printf(" '");
for (c = cc2->cond; c;) {
/* loop over or's */
@@ -2041,6 +2042,13 @@ addmatch(char *s, char *t)
}
if (!ms)
return;
+
+ /* when inserting braces on the command line, always use the quoted length */
+ for (bp = brbeg; bp; bp = bp->next)
+ bp->curpos = bp->qpos;
+ for (bp = brend; bp; bp = bp->next)
+ bp->curpos = bp->qpos;
+
add_match_data(isalt, ms, s, lc, ipre, ripre, isuf,
(incompfunc ? dupstring(curcc->prefix) : curcc->prefix),
prpre,
@@ -2886,7 +2894,7 @@ sep_comp_string(char *ss, char *s, int noffs)
return 1;
owb = offs;
offs = soffs;
- if ((p = check_param(ns, 0, 1))) {
+ if (check_param(ns, 0, 1)) {
for (p = ns; *p; p++)
if (*p == Dnull)
*p = '"';
@@ -3609,8 +3617,7 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd)
} else {
/* Otherwise ignore the path we *
* prepended to the pattern. */
- while ((p2 = p3 =
- (char *)ugetnode(l))) {
+ while ((p3 = (char *) ugetnode(l))) {
for (ns = sf1; *p3 && ns; p3++)
if (*p3 == '/')
ns--;
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 5152764b8..3643bf72f 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -269,9 +269,10 @@ parse_cmatcher(char *name, char *s)
case 'M': fl = CMF_LINE; break;
case 'x': break;
default:
- if (name)
- zwarnnam(name, "unknown match specification character `%c'",
- *s);
+ if (name) {
+ convchar_t c = unmeta_one(s, NULL);
+ zwarnnam(name, "unknown match specification character `%c'", c);
+ }
return pcm_err;
}
if (s[1] != ':') {
@@ -496,9 +497,16 @@ parse_class(Cpattern p, char *iptr)
}
/* find end of class. End character can appear literally first. */
- for (optr = iptr; optr == iptr || *optr != endchar; optr++)
+ for (optr = iptr; optr == iptr || *optr != endchar; optr++) {
if (!*optr)
return optr;
+ /* skip POSIX class names like [:alpha:] */
+ if (endchar == ']' && *optr == '[' && optr[1] == ':') {
+ char *nptr = strchr(optr+2, ':');
+ if (nptr && nptr[1] == ']')
+ optr = nptr + 1;
+ }
+ }
/*
* We can always fit the parsed class within the same length
* because of the tokenization (including a null byte).
@@ -789,10 +797,13 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
argv++;
goto ca_args;
default:
- zwarnnam(name, "bad option: -%c", *p);
- zsfree(mstr);
- zfree(dat.dpar, dparsize);
- return 1;
+ {
+ convchar_t c = unmeta_one(p, NULL);
+ zwarnnam(name, "bad option: -%c", c);
+ zsfree(mstr);
+ zfree(dat.dpar, dparsize);
+ return 1;
+ }
}
if (sp) {
if (p[1]) {
@@ -1156,8 +1167,11 @@ bin_compset(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
case 'S': test = CVT_SUFPAT; break;
case 'q': return set_comp_sep();
default:
- zwarnnam(name, "bad option -%c", argv[0][1]);
- return 1;
+ {
+ convchar_t c = unmeta_one(&argv[0][1], NULL);
+ zwarnnam(name, "bad option: -%c", c);
+ return 1;
+ }
}
if (argv[0][2]) {
sa = argv[0] + 2;
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 9c26b6f99..f4d22a968 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -670,7 +670,7 @@ doiscol(int pos)
static int
clprintfmt(char *p, int ml)
{
- int cc = 0, i = 0, ask, beg;
+ int cc = 0, i = 0, ask;
initiscol();
@@ -696,7 +696,7 @@ clprintfmt(char *p, int ml)
chrlen--;
p++;
}
- if ((beg = !(cc % zterm_columns)))
+ if (!(cc % zterm_columns))
ml++;
if (mscroll && !(cc % zterm_columns) &&
!--mrestlines && (ask = asklistscroll(ml)))
@@ -1072,7 +1072,7 @@ static int
compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
{
char *p, nc[2*DIGBUFSIZE + 12], nbuf[2*DIGBUFSIZE + 12];
- int l = 0, cc = 0, m, ask, beg, stat;
+ int l = 0, cc = 0, m, beg, stat;
if ((stat = !fmt)) {
if (mlbeg >= 0) {
@@ -1301,7 +1301,7 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
ml++;
fputs(" \010", shout);
}
- if (mscroll && beg && !--mrestlines && (ask = asklistscroll(ml))) {
+ if (mscroll && beg && !--mrestlines && asklistscroll(ml)) {
*stop = 1;
if (stat && n)
mfirstl = -1;
@@ -1624,7 +1624,7 @@ compprintlist(int showall)
q = p;
while (n && i-- && !errflag) {
wid = (g->widths ? g->widths[mc] : g->width);
- if (!(m = *q)) {
+ if (!*q) {
if (clprintm(g, NULL, mc, ml, (!i), wid))
goto end;
break;
@@ -2244,7 +2244,7 @@ setmstatus(char *status, char *sline, int sll, int scs,
strcpy(status, "interactive: ");
if (pl > h - 3) {
strcat(status, "...");
- strcat(status, p + pl - h - 3);
+ strcat(status, p + pl - h + 3);
} else
strcat(status, p);
@@ -2640,6 +2640,7 @@ domenuselect(Hookdef dummy, Chdata dat)
}
do_last_key = 0;
+ int was_inter = (mode == MM_INTER);
if (!cmd || cmd == Th(z_sendbreak)) {
zbeep();
molbeg = -1;
@@ -2778,9 +2779,13 @@ domenuselect(Hookdef dummy, Chdata dat)
metafy_line();
iforcemenu = 0;
- if (cmd != Th(z_acceptandinfernexthistory))
+ if (cmd != Th(z_acceptandinfernexthistory)) {
modeline = setmstatus(status, saveline, savell, savecs,
&modecs, &modell, &modelen);
+ /* if we are completing a quoted word, by this point we've
+ * lost track of this, so put we back where it should be */
+ we = savecs;
+ }
if (nmatches < 1 || !minfo.cur || !*(minfo.cur)) {
nolist = 1;
@@ -2822,8 +2827,12 @@ domenuselect(Hookdef dummy, Chdata dat)
Menustack s = (Menustack) zhalloc(sizeof(*s));
int ol;
- if (mode == MM_INTER)
- do_single(*minfo.cur);
+ if (mode == MM_INTER) {
+ Cmatch *cur = minfo.cur;
+ minfo.cur = NULL;
+ do_single(*cur);
+ minfo.cur = cur;
+ }
mode = 0;
s->prev = u;
u = s;
@@ -3279,6 +3288,7 @@ domenuselect(Hookdef dummy, Chdata dat)
strncpy(zlemetaline, origline, origll);
zlemetacs = origcs;
minfo.len = modelen;
+ we = wb + modelen;
} else {
mode = 0;
comprecursive = 1;
@@ -3407,6 +3417,8 @@ domenuselect(Hookdef dummy, Chdata dat)
acc = 1;
break;
}
+ if (was_inter)
+ minfo.cur = NULL;
do_single(**p);
mselect = (**p)->gnum;
}
@@ -3423,7 +3435,12 @@ domenuselect(Hookdef dummy, Chdata dat)
clearlist = listshown = 1;
if (acc && validlist && minfo.cur) {
menucmp = lastambig = hasoldlist = 0;
- do_single(*(minfo.cur));
+ if (mode == MM_INTER) {
+ Cmatch *cur = minfo.cur;
+ minfo.cur = NULL;
+ do_single(*cur);
+ } else
+ do_single(*(minfo.cur));
}
if (wasnext || broken) {
menucmp = 1;
diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c
index bc82ff4d0..7e0411294 100644
--- a/Src/Zle/compmatch.c
+++ b/Src/Zle/compmatch.c
@@ -189,7 +189,7 @@ free_cline(Cline l)
Cline
cp_cline(Cline l, int deep)
{
- Cline r = NULL, *p = &r, t, lp = NULL;
+ Cline r = NULL, *p = &r, t;
while (l) {
if ((t = freecl))
@@ -203,7 +203,7 @@ cp_cline(Cline l, int deep)
if (t->suffix)
t->suffix = cp_cline(t->suffix, 0);
}
- *p = lp = t;
+ *p = t;
p = &(t->next);
l = l->next;
}
@@ -1250,8 +1250,6 @@ comp_match(char *pfx, char *sfx, char *w, Patprog cp, Cline *clp, int qu,
} else
*exact = !strcmp(pfx, w);
}
- if (!qu)
- hasunqu = 1;
return r;
}
@@ -2046,7 +2044,7 @@ join_strs(int la, char *sa, int lb, char *sb)
NULL, 0);
if (rr <= convlen) {
ptrdiff_t diff = rp - rs;
- int alloclen = (convlen > 20) ? convlen : 20;
+ int alloclen = (convlen >= 20) ? convlen + 1 : 20;
rs = realloc(rs, (rl += alloclen));
rr += alloclen;
@@ -2088,7 +2086,7 @@ join_strs(int la, char *sa, int lb, char *sb)
lb--;
}
}
- if (la || lb)
+ if (la || lb || !rp)
return NULL;
*rp = '\0';
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 5b0889523..f7d74ec7a 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -186,7 +186,7 @@ cline_str(Cline l, int ins, int *csp, LinkList posl)
if ((brp = brbeg)) {
for (bp = brbeg; bp; bp = bp->next) {
- bp->curpos = (hasunqu ? bp->pos : bp->qpos);
+ bp->curpos = bp->qpos;
olen -= strlen(bp->str);
}
}
@@ -195,7 +195,7 @@ cline_str(Cline l, int ins, int *csp, LinkList posl)
olen -= strlen(bp->str);
for (bp = brend; bp; bp = bp->next)
- bp->curpos = olen - (hasunqu ? bp->pos : bp->qpos);
+ bp->curpos = olen - bp->qpos;
}
while (brp && !brp->curpos) {
inststrlen(brp->str, 1, -1);
@@ -588,9 +588,7 @@ instmatch(Cmatch m, int *scs)
/* Ignored prefix. */
if (m->ipre) {
- char *p = m->ipre + (menuacc ? m->qipl : 0);
-
- inststrlen(p, 1, (l = strlen(p)));
+ inststrlen(m->ipre, 1, (l = strlen(m->ipre)));
r += l;
}
/* -P prefix. */
@@ -965,10 +963,9 @@ do_single(Cmatch m)
int l, sr = 0, scs;
int havesuff = 0;
int partest = (m->ripre || ((m->flags & CMF_ISPAR) && parpre));
- char *str = m->orig, *ppre = m->ppre, *psuf = m->psuf, *prpre = m->prpre;
+ char *str = m->orig, *psuf = m->psuf, *prpre = m->prpre;
if (!prpre) prpre = "";
- if (!ppre) ppre = "";
if (!psuf) psuf = "";
fixsuffix();
@@ -1138,7 +1135,6 @@ do_single(Cmatch m)
/*{{*/
/* Otherwise, add a `,' suffix, and let `}' remove it. */
zlemetacs = scs;
- havesuff = 1;
inststrlen(",", 1, 1);
minfo.insc++;
makesuffix(1);
@@ -1774,8 +1770,6 @@ calclist(int showall)
width < zterm_columns && nth < g->dcount;
nth++, tline++) {
- m = *p;
-
if (tline == tlines) {
tcol++;
tline = 0;
@@ -2125,7 +2119,7 @@ printlist(int over, CLPrintFunc printm, int showall)
q = p;
while (n && i--) {
wid = (g->widths ? g->widths[mc] : g->width);
- if (!(m = *q)) {
+ if (!*q) {
printm(g, NULL, mc, ml, (!i), wid);
break;
}
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 55b0a9b9f..e666d93ba 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -890,7 +890,7 @@ bin_compdescribe(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
return 1;
}
}
- zwarnnam(nam, "invalid option: %s", args[0]);
+ zwarnnam(nam, "bad option: %s", args[0]);
return 1;
}
@@ -921,7 +921,8 @@ struct cadef {
char *nonarg; /* pattern for non-args (-A argument) */
};
-#define CDF_SEP 1 /* -S was specified: -- terminates options */
+#define CDF_SEP 1 /* -S was specified: -- terminates options */
+#define CDF_ZSEP 2 /* -S -S was specified: - terminates options */
/* Description for an option. */
@@ -1079,6 +1080,28 @@ bslashcolon(char *s)
return r;
}
+/* add backslashes before colons *and* other backslashes. this is suitable for
+ * re-escaping something that was un-escaped with rembslash(). basically it
+ * ensures that _describe handles a literal '\' correctly */
+
+static char *
+bslashcolon2(char *s)
+{
+ char *p, *r;
+
+ r = p = zhalloc((2 * strlen(s)) + 1);
+
+ while (*s) {
+ if (*s == ':' || *s == '\\')
+ *p++ = '\\';
+ *p++ = *s++;
+ }
+ *p = '\0';
+
+ return r;
+}
+
+
/* Get an index into the single array used in struct cadef
* opt is the option letter and pre is either - or +
* we only keep an array for the 94 ASCII characters from ! to ~ so
@@ -1233,7 +1256,7 @@ parse_cadef(char *nam, char **args)
if (*p == 's')
single = 1;
else if (*p == 'S')
- flags |= CDF_SEP;
+ flags |= (flags & CDF_SEP) ? CDF_ZSEP : CDF_SEP;
else if (*p == 'A') {
if (p[1]) {
nonarg = p + 1;
@@ -1448,6 +1471,9 @@ parse_cadef(char *nam, char **args)
zwarnnam(nam, "invalid option definition: %s", *args);
return NULL;
}
+ // treat empty description as if missing
+ if (p == descr)
+ descr = NULL;
*p++ = '\0';
c = *p;
} else
@@ -1696,6 +1722,8 @@ get_cadef(char *nam, char **args)
*
* "d" is a complete set of argument/option definitions to scan.
* "line" is the word we are scanning.
+ * "ign_active" indicates that whether an option def is active or not
+ * should be ignored when matching
* "full" indicates that the option must match a full word; otherwise
* we look for "=" arguments or prefixes.
* *"end" is set to point to the end of the option, in some cases
@@ -1703,24 +1731,25 @@ get_cadef(char *nam, char **args)
*/
static Caopt
-ca_get_opt(Cadef d, char *line, int full, char **end)
+ca_get_opt(Cadef d, char *line, int ign_active, int full, char **end)
{
Caopt p;
/* The full string may be an option. */
- for (p = d->opts; p; p = p->next)
- if (p->active && !strcmp(p->name, line)) {
+ for (p = d->opts; p; p = p->next) {
+ if ((ign_active || p->active) && !strcmp(p->name, line)) {
if (end)
*end = line + strlen(line);
return p;
}
+ }
if (!full) {
/* The string from the line probably only begins with an option. */
for (p = d->opts; p; p = p->next)
- if (p->active && ((!p->args || p->type == CAO_NEXT) ?
+ if ((ign_active || p->active) && ((!p->args || p->type == CAO_NEXT) ?
!strcmp(p->name, line) : strpfx(p->name, line))) {
int l = strlen(p->name);
if ((p->type == CAO_OEQUAL || p->type == CAO_EQUAL) &&
@@ -1744,7 +1773,7 @@ ca_get_opt(Cadef d, char *line, int full, char **end)
/* Same as above, only for single-letter-style. */
static Caopt
-ca_get_sopt(Cadef d, char *line, char **end, LinkList *lp)
+ca_get_sopt(Cadef d, char *line, int ign_active, char **end, LinkList *lp)
{
Caopt p, pp = NULL;
char pre = *line++;
@@ -1753,8 +1782,8 @@ ca_get_sopt(Cadef d, char *line, char **end, LinkList *lp)
*lp = NULL;
for (p = NULL; *line; line++) {
- if ((sidx = single_index(pre, *line)) != -1 &&
- (p = d->single[sidx]) && p->active && p->args) {
+ if (d->single && (sidx = single_index(pre, *line)) != -1 &&
+ (p = d->single[sidx]) && (ign_active || p->active) && p->args) {
if (p->type == CAO_NEXT) {
if (!l)
*lp = l = newlinklist();
@@ -1770,7 +1799,7 @@ ca_get_sopt(Cadef d, char *line, char **end, LinkList *lp)
pp = p;
break;
}
- } else if (!p || (p && !p->active))
+ } else if (!p || (p && !(ign_active || p->active)))
return NULL;
pp = (p->name[0] == pre ? p : NULL);
p = NULL;
@@ -1787,16 +1816,15 @@ static int
ca_foreign_opt(Cadef curset, Cadef all, char *option)
{
Cadef d;
- Caopt p;
+ LinkList l;
for (d = all; d; d = d->snext) {
if (d == curset)
continue;
-
- for (p = d->opts; p; p = p->next) {
- if (!strcmp(p->name, option))
- return 1;
- }
+ if (ca_get_opt(d, option, 1, 0, NULL))
+ return 1;
+ if (ca_get_sopt(d, option, 1, NULL, &l))
+ return 1;
}
return 0;
}
@@ -1906,7 +1934,7 @@ ca_inactive(Cadef d, char **xor, int cur, int opts)
if (a && a->num == n && (!grp || (a->gsname &&
!strncmp(a->gsname, grp, grplen))))
a->active = 0;
- } else if ((opt = ca_get_opt(d, x, 1, NULL)) &&
+ } else if ((opt = ca_get_opt(d, x, 0, 1, NULL)) &&
(!grp || (opt->gsname && !strncmp(opt->gsname, grp, grplen))) &&
!(single && *opt->name && opt->name[1] && opt->name[2]))
opt->active = 0;
@@ -2096,8 +2124,10 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
ca_inactive(d, argxor, cur - 1, 0);
argxor = NULL;
}
- if ((d->flags & CDF_SEP) && cur != compcurrent && state.actopts &&
- !strcmp(line, "--")) {
+ if (cur != compcurrent && state.actopts &&
+ !(state.def && state.inopt) &&
+ (((d->flags & CDF_SEP) && !strcmp(line, "--")) ||
+ ((d->flags & CDF_ZSEP) && !strcmp(line, "-")))) {
ca_inactive(d, NULL, cur, 1);
state.actopts = 0;
continue;
@@ -2125,6 +2155,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
} else if ((state.def = state.def->next)) {
state.argbeg = cur;
state.argend = argend;
+ goto cont;
} else if (sopts && nonempty(sopts)) {
state.curopt = (Caopt) uremnode(sopts, firstnode(sopts));
state.def = state.curopt->args;
@@ -2139,6 +2170,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
} else {
state.curopt = NULL;
state.opt = 1;
+ goto cont;
}
} else {
state.opt = state.arg = 1;
@@ -2154,7 +2186,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
/* See if it's an option. */
if (state.opt == 2 && (*line == '-' || *line == '+') &&
- (state.curopt = ca_get_opt(d, line, 0, &pe)) &&
+ (state.curopt = ca_get_opt(d, line, 0, 0, &pe)) &&
(state.curopt->type == CAO_OEQUAL ?
(compwords[cur] || pe[-1] == '=') :
(state.curopt->type == CAO_EQUAL ?
@@ -2203,7 +2235,7 @@ ca_parse_line(Cadef d, Cadef all, int multi, int first)
}
} else if (state.opt == 2 && d->single &&
(*line == '-' || *line == '+') &&
- ((state.curopt = ca_get_sopt(d, line, &pe, &sopts)) ||
+ ((state.curopt = ca_get_sopt(d, line, 0, &pe, &sopts)) ||
(cur != compcurrent && sopts && nonempty(sopts)))) {
/* Or maybe it's a single-letter option? */
@@ -2610,7 +2642,7 @@ bin_comparguments(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
case 'W': min = 3; max = 3; break;
case 'n': min = 1; max = 1; break;
default:
- zwarnnam(nam, "invalid option: %s", args[0]);
+ zwarnnam(nam, "bad option: %s", args[0]);
return 1;
}
n = arrlen(args) - 1;
@@ -2785,7 +2817,7 @@ bin_comparguments(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
subc = newlinklist();
while (lstate) {
- opt = ca_get_opt(lstate->d, args[1], 1, NULL);
+ opt = ca_get_opt(lstate->d, args[1], 0, 1, NULL);
if (opt && opt->args) {
ret = 0;
@@ -2944,6 +2976,7 @@ struct cvval {
int type; /* CVV_* below */
Caarg arg; /* argument definition */
int active; /* still allowed */
+ int not; /* don't complete this value (`!...') */
};
#define CVV_NOARG 0
@@ -2989,7 +3022,7 @@ parse_cvdef(char *nam, char **args)
Cvval val, *valp;
Caarg arg;
char **oargs = args, sep = '\0', asep = '=', *name, *descr, *p, *q, **xor, c;
- int xnum, multi, vtype, hassep = 0, words = 0;
+ int xnum, multi, vtype, hassep = 0, words = 0, not = 0;
while (args && args[0] && args[1] &&
args[0][0] == '-' &&
@@ -3031,6 +3064,8 @@ parse_cvdef(char *nam, char **args)
p = dupstring(*args);
xnum = 0;
+ if ((not = (*p == '!')))
+ p++;
/* xor list? */
if (*p == '(') {
LinkList list = newlinklist();
@@ -3049,7 +3084,7 @@ parse_cvdef(char *nam, char **args)
sav = *p;
*p = '\0';
- addlinknode(list, dupstring(q));
+ addlinknode(list, rembslash(q));
xnum++;
*p = sav;
}
@@ -3133,17 +3168,18 @@ parse_cvdef(char *nam, char **args)
xor = (char **) zalloc(2 * sizeof(char *));
xor[1] = NULL;
}
- xor[xnum] = ztrdup(name);
+ xor[xnum] = ztrdup(rembslash(name));
}
*valp = val = (Cvval) zalloc(sizeof(*val));
valp = &((*valp)->next);
val->next = NULL;
- val->name = ztrdup(name);
+ val->name = ztrdup(rembslash(name));
val->descr = ztrdup(descr);
val->xor = xor;
val->type = vtype;
val->arg = arg;
+ val->not = not;
}
return ret;
}
@@ -3455,7 +3491,6 @@ cv_parse_word(Cvdef d)
more[-1] = sav;
} else {
zaddlinknode(state.vals, tricat(arg, compsuffix, ""));
- nosfx = 1;
}
} else
zaddlinknode(state.vals, ztrdup(""));
@@ -3499,7 +3534,7 @@ bin_compvalues(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
case 'L': min = 3; max = 4; break;
case 'v': min = 1; max = 1; break;
default:
- zwarnnam(nam, "invalid option: %s", args[0]);
+ zwarnnam(nam, "bad option: %s", args[0]);
return 1;
}
n = arrlen(args) - 1;
@@ -3571,21 +3606,23 @@ bin_compvalues(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
char *str;
for (p = cv_laststate.d->vals; p; p = p->next) {
- if (p->active) {
+ if (p->active && !p->not) {
switch (p->type) {
case CVV_NOARG: l = noarg; break;
case CVV_ARG: l = arg; break;
default: l = opt; break;
}
if (p->descr) {
- int len = strlen(p->name) + strlen(p->descr) + 2;
+ // see note on bslashcolon2()
+ char *n = bslashcolon2(p->name);
+ size_t len = strlen(n) + strlen(p->descr) + 2;
str = (char *) zhalloc(len);
- strcpy(str, p->name);
+ strcpy(str, n);
strcat(str, ":");
strcat(str, p->descr);
} else
- str = p->name;
+ str = bslashcolon2(p->name);
addlinknode(l, str);
}
}
@@ -3859,7 +3896,7 @@ bin_comptags(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
case 'S': min = 1; max = 1; break;
case 'A': min = 2; max = 3; break;
default:
- zwarnnam(nam, "invalid option: %s", args[0]);
+ zwarnnam(nam, "bad option: %s", args[0]);
return 1;
}
n = arrlen(args) - 1;
@@ -4652,7 +4689,7 @@ cfp_opt_pats(char **pats, char *matcher)
q = dupstring(q);
t = q + strlen(q) - 1;
if (*t == ')') {
- for (s = t--; t > q; t--)
+ while (--t > q)
if (*t == ')' || *t == '|' || *t == '~' || *t == '(')
break;
if (t != q && *t == '(')
@@ -4666,10 +4703,9 @@ cfp_opt_pats(char **pats, char *matcher)
for (s = add; *s && !idigit(*s); s++);
*s = '\0';
} else if (*q == '[') {
- int not;
char *x = ++q;
- if ((not = (*x == '!' || *x == '^')))
+ if (*x == '!' || *x == '^')
x++;
for (; *x; x++) {
if (x[1] == '-' && x[2]) {
@@ -4981,7 +5017,7 @@ bin_compfiles(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
case 'p':
case 'P':
if (args[0][2] && (args[0][2] != '-' || args[0][3])) {
- zwarnnam(nam, "invalid option: %s", *args);
+ zwarnnam(nam, "bad option: %s", *args);
return 1;
} else {
char **tmp;
@@ -5009,7 +5045,7 @@ bin_compfiles(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
}
case 'i':
if (args[0][2]) {
- zwarnnam(nam, "invalid option: %s", *args);
+ zwarnnam(nam, "bad option: %s", *args);
return 1;
} else {
char **tmp;
@@ -5065,7 +5101,7 @@ bin_compfiles(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
return ret;
}
}
- zwarnnam(nam, "invalid option: %s", *args);
+ zwarnnam(nam, "bad option: %s", *args);
return 1;
}
diff --git a/Src/Zle/termquery.c b/Src/Zle/termquery.c
index d8be6e49a..6b545fe1a 100644
--- a/Src/Zle/termquery.c
+++ b/Src/Zle/termquery.c
@@ -209,7 +209,7 @@ probe_terminal(const char *tquery, seqstate_t *states,
int *num = numbers;
int finish = 0, number = 0;
int ch;
- struct ttyinfo ti, torig;
+ struct ttyinfo ti = { 0 }, torig;
struct value vbuf;
Value v = getvalue(&vbuf, &WAITVAR, 0);
long timeout = v ? -1 - getintvalue(v) : TIMEOUT;
@@ -457,6 +457,8 @@ handle_color(int bg, int red, int green, int blue)
case 2: /* cursor color */
memo_cursor = (red << 24) | (green << 16) | (blue << 8);
break;
+ default: /* invalid color */
+ return;
}
colour = zalloc(8);
@@ -507,8 +509,25 @@ query_terminal(void) {
char *tqend = tquery;
static seqstate_t states[] = QUERY_STATES;
char **f, **flist = getaparam(EXTVAR);
+ char *envid = getsparam("TERM_PROGRAM");
+ int badapple = 0;
size_t i;
+ /* If TERM_PROGRAM is set in the environment, use that and
+ * skip the XTVERSION query */
+ if (envid) {
+ char *envver;
+ handle_query(4, NULL, 0, envid, strlen(envid), NULL);
+ if ((envver = getsparam("TERM_PROGRAM_VERSION"))) {
+ handle_query(5, NULL, 0, envver, strlen(envver), NULL);
+ /* Older macOS terminal doesn't consume RGB queries,
+ * nor does it support truecolor. Given that it's widely
+ * used, we handle it explicitly. */
+ badapple = !strcmp(envid, "Apple_Terminal") &&
+ zstrtol(envver, NULL, 10) < 470;
+ }
+ }
+
for (f = flist; f && *f; f++)
if (!strcmp(*f, "-query"))
return; /* disable all queries */
@@ -536,7 +555,7 @@ query_terminal(void) {
(!strcmp(cterm, "truecolor") ||
!strcmp(cterm, "24bit")))))
handle_query(3, NULL, 0, NULL, 0, NULL);
- else
+ else if ((i != 4 || !badapple) && (i != 5 || !envid))
struncpy(&tqend, (char *) queries[i], /* collate escape sequences */
sizeof(tquery) - (tqend - tquery));
}
@@ -574,7 +593,7 @@ base64_decode(const char *src, size_t len)
unsigned int n;
char *buf = hcalloc((3 * len) / 4 + 1);
char *b = buf;
- char c;
+ unsigned char c;
while (len && (c = src[i]) != '=') {
n = isdigit(c) ? c - '0' + 52 :
@@ -602,7 +621,7 @@ static char*
url_encode(const char* path, size_t *ulen)
{
char *url = zhalloc(strlen(path) * 3 + 1); /* worst case length triples */
- const char *in = path;
+ const unsigned char *in = (unsigned char*)path;
char *out = url;
for (; *in; in++) {
@@ -642,16 +661,17 @@ system_clipput(char clip, char *content, size_t clen)
/**/
static int
-extension_enabled(const char *class, const char *ext, unsigned clen, int def)
+extension_enabled(const char *prefix, const char *ext, unsigned plen, int def)
{
- char **e, **elist = getaparam(EXTVAR);
+ char dash, **e, **elist = getaparam(EXTVAR);
for (e = elist; e && *e; e++) {
int negate = (**e == '-');
- if (strncmp(*e + negate, class, clen))
+ if (strncmp(*e + negate, prefix, plen))
continue;
- if (!*(*e + negate + clen) || !strcmp(*e + negate + clen + 1, ext))
+ if (!(dash = *(*e + negate + plen)) ||
+ (dash == '-' && !strcmp(*e + negate + plen + 1, ext)))
return !negate;
}
return def;
@@ -660,7 +680,7 @@ extension_enabled(const char *class, const char *ext, unsigned clen, int def)
struct extension {
char *key, *seq[2];
- int class, enabled;
+ int prefix, enabled;
};
static const struct extension editext[] = {
@@ -690,11 +710,11 @@ collate_seq(int sindex, int dir)
int negate = (**e == '-');
if (negate != enabled)
continue;
- if ((editext[i].class &&
- !strncmp(*e + negate, editext[i].key, editext[i].class) &&
- !*(*e + negate + editext[i].class)) ||
- !strcmp(*e + negate + editext[i].class,
- editext[i].key + editext[i].class))
+ if ((!editext[i].prefix ||
+ !strncmp(*e + negate, editext[i].key, editext[i].prefix)) &&
+ ((editext[i].prefix && !*(*e + negate + editext[i].prefix)) ||
+ !strcmp(*e + negate + editext[i].prefix,
+ editext[i].key + editext[i].prefix)))
{
enabled = !negate;
break;
@@ -735,7 +755,7 @@ prompt_markers(void)
static const char PR[] = "\033]133;P;k=i\033\\"; /* primary (PS1) */
static const char SE[] = "\033]133;P;k=s\033\\"; /* secondary (PS2) */
static const char RI[] = "\033]133;P;k=r\033\\"; /* right (RPS1,2) */
- static const char *markers[] = { PR, SE, RI };
+ static const char *markers[] = { pre, PR, SE, RI };
static const char *nomark[] = { NULL, NULL, NULL, NULL };
if (!extension_enabled("integration", "prompt", 11, 1))
@@ -889,12 +909,14 @@ zle_set_cursorform(void)
}
}
- if (!setup || trashedzle) {
+ if (trashedzle)
+ setup = 0;
+ else if (!setup) {
cursor_enabled_mask = 0;
setup = 1;
- if (!extension_enabled("cursor", "shape", 6, 1))
+ if (extension_enabled("cursor", "shape", 6, 1))
cursor_enabled_mask |= CURF_SHAPE_MASK | CURF_BLINK | CURF_STEADY;
- if (!extension_enabled("cursor", "color", 6, 1))
+ if (extension_enabled("cursor", "color", 6, 1))
cursor_enabled_mask |= CURF_COLOR_MASK;
}
}
@@ -912,7 +934,7 @@ free_cursor_forms(void)
void
cursor_form(void)
{
- char seq[31];
+ char seq[32];
char *s = seq;
unsigned int want, changed;
static unsigned int state = CURF_DEFAULT;
@@ -936,7 +958,7 @@ cursor_form(void)
} else
context = invicmdmode() ? CURC_COMMAND : (vichgflag ? CURC_INSERT : CURC_EDIT);
want = (context == CURC_DEFAULT) ? CURF_DEFAULT : cursor_forms[context];
- if (!(changed = (want ^ state) & ~cursor_enabled_mask))
+ if (!(changed = (want ^ state) & cursor_enabled_mask))
return;
if (changed & CURF_HIDDEN)
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 53c722621..84143168d 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -539,7 +539,7 @@ historysearchforward(char **args)
;
if (histpos < zlell)
histpos++;
- CCRIGHT();
+ CCRIGHTPOS(histpos);
srch_str = zlelineasstring(zleline, histpos, 0, NULL, NULL, 0);
}
free(line);
@@ -867,6 +867,7 @@ pushlineoredit(char **args)
ZS_memcpy(zleline, zhline, ics);
zlell += ics;
zlecs += ics;
+ zleline[zlell] = ZWC('\0');
free(zhline);
}
ret = pushline(args);
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index ea80f9e3c..e28ff6f35 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -989,7 +989,7 @@ bin_bindkey_meta(char *name, char *kmname, Keymap km, UNUSED(char **argv), UNUSE
/* Change key bindings. func can be: *
* 'r' bind sequences to undefined-key *
- * 's' bind sequneces to specified send-strings *
+ * 's' bind sequences to specified send-strings *
* 0 bind sequences to specified functions *
* If the -R option is used, bind to key ranges *
* instead of single key sequences. */
@@ -1675,8 +1675,8 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
if (keybuf[keybuflen - 1] == '\007' || /* BEL sometimes used */
(keybuf[keybuflen - 2] == '\033' &&
keybuf[keybuflen - 1] == '\\') ||
- (keybuf[keybuflen - 2] == Meta && /* ST can be 0x9b */
- (unsigned char) keybuf[keybuflen - 1] == (0x9b ^ 32)))
+ (keybuf[keybuflen - 2] == Meta && /* ST can be 0x9c */
+ (unsigned char) keybuf[keybuflen - 1] == (0x9c ^ 32)))
{
keybuflen = oscdcs - 2; /* discard */
timeout = oscdcs = 0;
@@ -1778,7 +1778,6 @@ getkeycmd(void)
if(!func) {
if (++hops == 20) {
zerr("string inserting another one too many times");
- hops = 0;
return NULL;
}
ungetbytes_unmeta(str, strlen(str));
diff --git a/Src/Zle/zle_main.c b/Src/Zle/zle_main.c
index aee62a505..ea88a4247 100644
--- a/Src/Zle/zle_main.c
+++ b/Src/Zle/zle_main.c
@@ -1154,7 +1154,7 @@ zlecore(void)
break;
}
handleprefixes();
- /* for vi mode, make sure the cursor isn't somewhere illegal */
+ /* for vi mode, make sure the cursor isn't somewhere invalid */
if (invicmdmode() && zlecs > findbol() &&
(zlecs == zlell || zleline[zlecs] == ZWC('\n')))
DECCS();
@@ -1272,10 +1272,10 @@ zleread(char **lp, char **rp, int flags, int context, char *init, char *finish)
raw_lp = lp;
txtcurrentattrs = txtpendingattrs = txtunknownattrs = 0;
lpromptbuf = promptexpand(lp ? *lp : NULL, 1,
- markers[flags == ZLCON_LINE_CONT ? 2 : 1], NULL, NULL);
+ markers[context == ZLCON_LINE_CONT ? 2 : 1], NULL, NULL);
pmpt_attr = txtcurrentattrs;
raw_rp = rp;
- rpromptbuf = promptexpand(rp ? *rp : NULL, 1, markers[2], NULL, NULL);
+ rpromptbuf = promptexpand(rp ? *rp : NULL, 1, markers[3], NULL, NULL);
rpmpt_attr = txtcurrentattrs;
prompt_attr = mixattrs(pmpt_attr, pmpt_attr & TXT_ATTR_ALL, rpmpt_attr);
free_prepostdisplay();
@@ -2022,7 +2022,8 @@ reexpandprompt(void)
looping = reexpanding;
txtcurrentattrs = txtpendingattrs = txtunknownattrs = 0;
- new_lprompt = promptexpand(raw_lp ? *raw_lp : NULL, 1, markers[0], NULL, NULL);
+ new_lprompt = promptexpand(raw_lp ? *raw_lp : NULL, 1,
+ markers[zlecontext == ZLCON_LINE_CONT ? 2 : 1], NULL, NULL);
pmpt_attr = txtcurrentattrs;
free(lpromptbuf);
lpromptbuf = new_lprompt;
@@ -2030,7 +2031,7 @@ reexpandprompt(void)
if (looping != reexpanding)
continue;
- new_rprompt = promptexpand(raw_rp ? *raw_rp : NULL, 1, markers[2], NULL, NULL);
+ new_rprompt = promptexpand(raw_rp ? *raw_rp : NULL, 1, markers[3], NULL, NULL);
rpmpt_attr = txtcurrentattrs;
prompt_attr = mixattrs(pmpt_attr, pmpt_attr & TXT_ATTR_ALL, rpmpt_attr);
free(rpromptbuf);
@@ -2051,7 +2052,7 @@ resetprompt(UNUSED(char **args))
return redisplay(NULL);
}
-/* same bug called from outside zle */
+/* same but called from outside zle */
/**/
static void
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index 3e50d5d4b..2aef1b77a 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -76,7 +76,7 @@ doinsert(ZLE_STRING_T zstr, int len)
count = len * m;
#endif
/*
- * Ensure we replace a complete combining characterfor each
+ * Ensure we replace a complete combining character for each
* character we overwrite. Switch to inserting at first newline.
*/
for (i = count; pos < zlell && zleline[pos] != ZWC('\n') && i--; ) {
@@ -626,6 +626,7 @@ viputbefore(UNUSED(char **args))
kct = -1;
yankcs = zlecs;
pastebuf(&kbuf, n, 0);
+ free(kbuf.buf);
return 0;
} else if (zmod.flags & MOD_VIBUF)
kctbuf = &vibuf[zmod.vibuf];
@@ -662,6 +663,7 @@ viputafter(UNUSED(char **args))
kct = -1;
yankcs = zlecs;
pastebuf(&kbuf, n, 1);
+ free(kbuf.buf);
return 0;
} else if (zmod.flags & MOD_VIBUF)
kctbuf = &vibuf[zmod.vibuf];
@@ -684,8 +686,11 @@ putreplaceselection(UNUSED(char **args))
Cutbuffer putbuf;
int clear = 0;
int pos = 2;
+ int isvibuf;
- startvichange(-1);
+ if (invicmdmode())
+ startvichange(-1);
+ isvibuf = zmod.flags & MOD_VIBUF;
if (n < 0 || zmod.flags & MOD_NULL)
return 1;
if (zmod.flags & MOD_OSSEL) {
@@ -696,8 +701,9 @@ putreplaceselection(UNUSED(char **args))
prevbuf.buf = stringaszleline(pbuf, 0, &x, NULL, NULL);
prevbuf.len = x;
prevbuf.flags = 0;
+ clear = 1; /* stringaszleline returns permanent memory */
} else {
- putbuf = (zmod.flags & MOD_VIBUF) ? &vibuf[zmod.vibuf] : &cutbuf;
+ putbuf = isvibuf ? &vibuf[zmod.vibuf] : &cutbuf;
if (!putbuf->buf)
return 1;
memcpy(&prevbuf, putbuf, sizeof(prevbuf));
@@ -706,6 +712,14 @@ putreplaceselection(UNUSED(char **args))
if (zmod.vibuf == 35) {
putbuf->buf = 0;
clear = 1;
+ } else if (!isvibuf) {
+ /* when putbuf is pointing at cutbuf, we can't clear putbuf->buf
+ * because that's where we want to put the stuff, but valgrind will be
+ * quite sad if killregion reallocs it, so I think we need to copy it */
+ ZLE_STRING_T newbuf = (ZLE_STRING_T)zalloc(prevbuf.len * ZLE_CHAR_SIZE);
+ ZS_memcpy(newbuf, prevbuf.buf, prevbuf.len);
+ prevbuf.buf = newbuf;
+ clear = 1;
}
}
@@ -791,7 +805,7 @@ bracketedstring(void)
int next, timeout;
while (endesc[endpos]) {
- if (current + 1 >= psize)
+ if (current + 2 >= psize)
pbuf = zrealloc(pbuf, psize *= 2);
if ((next = getbyte(1L, &timeout, 1)) == EOF)
break;
@@ -853,11 +867,11 @@ whatcursorposition(UNUSED(char **args))
char msg[100];
char *s = msg, *mbstr;
int bol = findbol(), len;
- ZLE_CHAR_T c = zleline[zlecs];
if (zlecs == zlell)
strucpy(&s, "EOF");
else {
+ ZLE_CHAR_T c = zleline[zlecs];
strucpy(&s, "Char: ");
switch (c) {
case ZWC(' '):
@@ -1193,6 +1207,7 @@ quoteline(UNUSED(char **args))
sizeline(len);
ZS_memcpy(zleline, str, len);
zlecs = zlell = len;
+ zleline[zlell] = ZWC('\0');
return 0;
}
diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c
index 3bafff3f1..7f4678683 100644
--- a/Src/Zle/zle_move.c
+++ b/Src/Zle/zle_move.c
@@ -274,7 +274,7 @@ backwardmetafiedchar(char *start, char *endptr, convchar_t *retchr)
*/
#endif
if (endptr > start) {
- if (endptr > start - 1 && endptr[-2] == Meta)
+ if (endptr > start + 1 && endptr[-2] == Meta)
{
if (retchr)
*retchr = (convchar_t)(endptr[-1] ^ 32);
@@ -642,6 +642,8 @@ vimatchbracket(UNUSED(char **args))
DECCS();
else
INCCS();
+ if (zlecs < 0 && zlecs >= zlell)
+ break;
if (zleline[zlecs] == oth)
ct--;
else if (zleline[zlecs] == me)
diff --git a/Src/Zle/zle_params.c b/Src/Zle/zle_params.c
index 54019bf3b..6ac7d4f0a 100644
--- a/Src/Zle/zle_params.c
+++ b/Src/Zle/zle_params.c
@@ -247,8 +247,10 @@ set_buffer(UNUSED(Param pm), char *x)
if(x) {
setline(x, 0);
zsfree(x);
- } else
+ } else {
viinsbegin = zlecs = zlell = 0;
+ zleline[zlell] = ZWC('\0');
+ }
fixsuffix();
menucmp = 0;
}
@@ -342,6 +344,7 @@ set_lbuffer(UNUSED(Param pm), char *x)
ZS_memmove(zleline + len, zleline + zlecs, zlell - zlecs);
ZS_memcpy(zleline, y, len);
zlell = zlell - zlecs + len;
+ zleline[zlell] = ZWC('\0');
zlecs = len;
zsfree(x);
if (len)
@@ -371,6 +374,7 @@ set_rbuffer(UNUSED(Param pm), char *x)
else
y = ZWS(""), len = 0;
sizeline(zlell = zlecs + len);
+ zleline[zlell] = ZWC('\0');
ZS_memcpy(zleline + zlecs, y, len);
zsfree(x);
if (len)
@@ -750,6 +754,14 @@ unset_killring(Param pm, int exp)
static void
set_register(Param pm, char *value)
{
+ set_register_buf(pm, value);
+ zsfree(value);
+}
+
+/**/
+static void
+set_register_buf(Param pm, char *value)
+{
int n = 0;
int offset = -1;
Cutbuffer vbuf;
@@ -767,8 +779,12 @@ set_register(Param pm, char *value)
}
vbuf = &vibuf[*pm->node.nam - offset];
+ if (vbuf->buf)
+ free(vbuf->buf);
if (*value)
vbuf->buf = stringaszleline(value, 0, &n, NULL, NULL);
+ else
+ vbuf->buf = NULL;
vbuf->len = n;
}
@@ -776,7 +792,7 @@ set_register(Param pm, char *value)
static void
unset_register(Param pm, UNUSED(int exp))
{
- set_register(pm, "");
+ set_register_buf(pm, "");
}
/**/
@@ -846,7 +862,7 @@ set_registers(Param pm, HashTable ht)
v.arr = NULL;
v.pm = (Param) hn;
- set_register(v.pm, getstrvalue(&v));
+ set_register_buf(v.pm, getstrvalue(&v));
}
if (ht != pm->u.hash)
deleteparamtable(ht);
@@ -944,20 +960,16 @@ get_context(UNUSED(Param pm))
switch (zlecontext) {
case ZLCON_LINE_CONT:
return "cont";
- break;
case ZLCON_SELECT:
return "select";
- break;
case ZLCON_VARED:
return "vared";
- break;
case ZLCON_LINE_START:
default:
return "start";
- break;
}
}
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index 255c701f2..b3a648056 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -40,7 +40,7 @@
* nmw_ind is the next free element, i.e. nmwbuf[nmw_ind] will be the next
* element to be written (we never insert into omwbuf). We initialise
* nmw_ind to 1 to avoid the index stored in the character looking like a
- * NULL. This wastees a word but it's safer than messing with pointers.
+ * NULL. This wastes a word but it's safer than messing with pointers.
*
* The layout of the buffer is as a string of entries that consist of multiple
* elements of the allocated array with no boundary (the code keeps track of
@@ -492,12 +492,12 @@ set_region_highlight(UNUSED(Param pm), char **aval)
struct region_highlight *rhp;
len = aval ? arrlen(aval) : 0;
+ free_region_highlights_memos();
if (n_region_highlights != len + N_SPECIAL_HIGHLIGHTS) {
/* no null termination, but include special highlighting at start */
int newsize = len + N_SPECIAL_HIGHLIGHTS;
int diffsize = newsize - n_region_highlights;
- free_region_highlights_memos();
region_highlights = (struct region_highlight *)
zrealloc(region_highlights,
sizeof(struct region_highlight) * newsize);
@@ -688,7 +688,7 @@ static int more_start, /* more text before start of screen? */
static int
omw_size, /* allocated size of omwbuf */
nmw_size, /* allocated size of nmwbuf */
- nmw_ind; /* next insert point in nmw_ind */
+ nmw_ind; /* next insert point in nmwbuf */
#endif
/*
@@ -1437,26 +1437,60 @@ zrefresh(void)
#ifdef MULTIBYTE_SUPPORT
if (WC_ISPRINT(*u)) {
int width = WCWIDTH(*u);
- /* Handle wide characters as above */
- if (width > rpms.sen - rpms.s) {
- do {
- *rpms.s++ = zr_sp;
- } while (rpms.s < rpms.sen);
- nbuf[rpms.ln][winw + 1] = zr_nl;
- snextline(&rpms);
- }
- if (width > rpms.sen - rpms.s) {
- rpms.s->chr = ZWC('?');
- rpms.s->atr = all_attr;
- rpms.s++;
- } else {
- rpms.s->chr = *u;
- rpms.s->atr = 0;
- rpms.s++;
- while (--width > 0) {
- rpms.s->chr = WEOF;
+ if (width > 0) {
+ int ichars = 1;
+ if (isset(COMBININGCHARS) && IS_BASECHAR(*u)) {
+ for (ichars = 1; u + ichars < outputline + outll; ichars++)
+ if (!IS_COMBINING(u[ichars]))
+ break;
+ }
+ /* Handle wide characters as above */
+ if (width > rpms.sen - rpms.s) {
+ do {
+ *rpms.s++ = zr_sp;
+ } while (rpms.s < rpms.sen);
+ nbuf[rpms.ln][winw + 1] = zr_nl;
+ snextline(&rpms);
+ }
+ if (width > rpms.sen - rpms.s) {
+ rpms.s->chr = ZWC('?');
+ rpms.s->atr = all_attr;
+ rpms.s++;
+ } else {
rpms.s->atr = 0;
+ if (ichars > 1)
+ addmultiword(rpms.s, u, ichars);
+ else
+ rpms.s->chr = *u;
rpms.s++;
+ while (--width > 0) {
+ rpms.s->chr = WEOF;
+ rpms.s->atr = 0;
+ rpms.s++;
+ }
+ }
+ u += ichars - 1;
+ } else {
+ /* either the COMBINING_CHARS option is off,
+ or there was no base character, then render as special */
+ char dispchars[11];
+ char *dispptr = dispchars;
+ wchar_t wc;
+ if ((unsigned)*u > 0xffffU)
+ sprintf(dispchars, "<%.08x>", (unsigned)*u);
+ else
+ sprintf(dispchars, "<%.04x>", (unsigned)*u);
+ while (*dispptr) {
+ if (mbtowc(&wc, dispptr, 1) == 1) {
+ rpms.s->chr = wc;
+ rpms.s->atr = all_attr;
+ rpms.s++;
+ if (rpms.s == rpms.sen) {
+ nbuf[rpms.ln][winw + 1] = zr_nl;
+ snextline(&rpms);
+ }
+ }
+ dispptr++;
}
}
}
@@ -1475,9 +1509,32 @@ zrefresh(void)
rpms.s->atr = all_attr;
rpms.s++;
} else {
+#ifdef MULTIBYTE_SUPPORT
+ /* non-printable wide char */
+ char dispchars[11];
+ char *dispptr = dispchars;
+ wchar_t wc;
+ if ((unsigned)*u > 0xffffU)
+ sprintf(dispchars, "<%.08x>", (unsigned)*u);
+ else
+ sprintf(dispchars, "<%.04x>", (unsigned)*u);
+ while (*dispptr) {
+ if (mbtowc(&wc, dispptr, 1) == 1) {
+ rpms.s->chr = wc;
+ rpms.s->atr = all_attr;
+ rpms.s++;
+ if (rpms.s == rpms.sen) {
+ nbuf[rpms.ln][winw + 1] = zr_nl;
+ snextline(&rpms);
+ }
+ }
+ dispptr++;
+ }
+#else
rpms.s->chr = *u;
rpms.s->atr = 0;
rpms.s++;
+#endif
}
if (rpms.s == rpms.sen) {
nbuf[rpms.ln][winw + 1] = zr_nl; /* text wrapped */
@@ -1491,7 +1548,7 @@ zrefresh(void)
*/
snextline(&rpms);
}
- zfree(outputline, outsz);
+ zfree(outputline, (outsz+2) * ZLE_CHAR_SIZE);
free(statusdup);
}
*rpms.s = zr_zr;
@@ -1556,7 +1613,7 @@ zrefresh(void)
* Ensure we don't start overwriting in the middle of a wide
* character.
*/
- while(rpms.sen > nbuf[rpms.tosln - 1] && rpms.sen->chr == WEOF) {
+ while(rpms.sen > nbuf[rpms.tosln] && rpms.sen->chr == WEOF) {
extra_ellipsis++;
rpms.sen--;
}
@@ -1631,7 +1688,7 @@ zrefresh(void)
zfree(obuf[iln], (winw + 2) * sizeof(**obuf));
for (t0 = iln; t0 != olnct; t0++)
obuf[t0] = obuf[t0 + 1];
- obuf[--olnct] = NULL;
+ obuf[olnct--] = NULL;
}
/* don't try to insert a line if olnct = vmaxln (vmaxln is the number
of lines that have been displayed by this routine) so that we don't
@@ -1641,6 +1698,7 @@ zrefresh(void)
obuf[iln] && !ZR_strncmp(obuf[iln], nbuf[iln + 1], 16)) {
moveto(iln, 0);
tcout(TCINSLINE);
+ zfree(obuf[olnct], (winw + 2) * sizeof(**obuf));
for (t0 = olnct; t0 != iln; t0--)
obuf[t0] = obuf[t0 - 1];
obuf[iln] = NULL;
@@ -2006,7 +2064,7 @@ refreshline(int ln)
/*
* inserting characters - characters pushed off the right
* should be annihilated, but we don't do this if we're on the
- * last line lest undesired scrolling occurs due to `illegal'
+ * last line lest undesired scrolling occurs due to `invalid'
* characters on screen
*/
if (tccan(TCINS) && (vln != zterm_lines - 1)) {
@@ -2452,7 +2510,7 @@ singlerefresh(ZLE_STRING_T tmpline, int tmpll, int tmpcs)
for (t0 = 0; t0 < tmpll; t0++) {
unsigned ireg;
- zattr base_attr = mixattrs(default_attr, default_attr, prompt_attr);
+ zattr base_attr = mixattrs(default_attr, default_mask, prompt_attr);
zattr all_attr;
struct region_highlight *rhp;
/*
diff --git a/Src/Zle/zle_thingy.c b/Src/Zle/zle_thingy.c
index f71435b01..f6c521d11 100644
--- a/Src/Zle/zle_thingy.c
+++ b/Src/Zle/zle_thingy.c
@@ -402,7 +402,7 @@ bin_zle_list(UNUSED(char *name), char **args, Options ops, UNUSED(char func))
for (; *args && !ret; args++) {
HashNode hn = thingytab->getnode2(thingytab, *args);
- if (!(t = (Thingy) hn) ||
+ if (!(t = (Thingy) hn) || !t->widget ||
(!OPT_ISSET(ops,'a') && (t->widget->flags & WIDGET_INT)))
ret = 1;
else if (OPT_ISSET(ops,'L')) {
@@ -704,7 +704,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
{
Thingy t;
struct modifier modsave = zmod;
- int ret, saveflag = 0, setbindk = 0, setlbindk = 0, remetafy;
+ int ret = 1, saveflag = 0, setbindk = 0, setlbindk = 0, remetafy;
char *wname = *args++, *keymap_restore = NULL, *keymap_tmp;
if (!wname)
@@ -739,9 +739,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
flag = args[0][1] ? args[0]+1 : args[1];
if (flag == NULL || strcmp(flag, "nolast")) {
zwarnnam(name, "%s", "'nolast' expected after -f");
- if (remetafy)
- metafy_line();
- return 1;
+ goto cleanup_zle_call;
}
if (!args[0][1])
*++args = skip_this_arg;
@@ -752,9 +750,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
num = args[0][1] ? args[0]+1 : args[1];
if (!num) {
zwarnnam(name, "number expected after -%c", **args);
- if (remetafy)
- metafy_line();
- return 1;
+ goto cleanup_zle_call;
}
if (!args[0][1])
*++args = skip_this_arg;
@@ -771,27 +767,21 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
keymap_tmp = args[0][1] ? args[0]+1 : args[1];
if (!keymap_tmp) {
zwarnnam(name, "keymap expected after -%c", **args);
- if (remetafy)
- metafy_line();
- return 1;
+ goto cleanup_zle_call;
}
if (!args[0][1])
*++args = skip_this_arg;
keymap_restore = dupstring(curkeymapname);
if (selectkeymap(keymap_tmp, 0)) {
- if (remetafy)
- metafy_line();
- return 1;
+ goto cleanup_zle_call;
}
break;
case 'w':
setbindk = 1;
break;
default:
- zwarnnam(name, "unknown option: %s", *args);
- if (remetafy)
- metafy_line();
- return 1;
+ zwarnnam(name, "bad option: %s", *args);
+ goto cleanup_zle_call;
}
}
args++;
@@ -805,6 +795,7 @@ bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
setlbindk |= t->widget && (t->widget->flags & ZLE_NOLAST) == ZLE_NOLAST;
ret = execzlefunc(t, args, setbindk, setlbindk);
unrefthingy(t);
+cleanup_zle_call:
if (saveflag)
zmod = modsave;
if (keymap_restore)
@@ -1014,7 +1005,7 @@ bin_zle_transform(char *name, char **args, Options ops, UNUSED(char func))
}
/*******************/
-/* initialiasation */
+/* initialisation */
/*******************/
/**/
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 8f32c68e3..3e46acdab 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -538,7 +538,7 @@ parambeg(char *s)
* This is really a parameter expression (not $(...) or $[...]
* or $'...').
*/
- char *b = p + 1, *e = b;
+ char *b = p + 1, *e;
int n = 0, br = 1;
if (*b == Inbrace) {
@@ -1655,7 +1655,7 @@ get_comp_string(void)
* so start at the beginning of the line and continue
* until cspos.
*/
- wptr = cptr = zlemetaline;
+ wptr = zlemetaline;
for (;;) {
cptr = itype_end(wptr, IIDENT, 0);
if (cptr == wptr) {
@@ -1678,7 +1678,7 @@ get_comp_string(void)
char *sqbr = zlemetaline + wb - 1, *cptr, *wptr;
/* Need to search forward for word characters */
- cptr = wptr = zlemetaline;
+ wptr = zlemetaline;
for (;;) {
cptr = itype_end(wptr, IIDENT, 0);
if (cptr == wptr) {
@@ -1706,7 +1706,7 @@ get_comp_string(void)
}
/* This variable will hold the current word in quoted form. */
offs = zlemetacs - wb;
- if ((p = parambeg(s))) {
+ if (parambeg(s)) {
for (p = s; *p; p++)
if (*p == Dnull)
*p = '"';
@@ -1771,9 +1771,9 @@ get_comp_string(void)
* \! in double quotes is extracted by the history code before normal
* parsing, so sanitize it here, too.
*/
- if (instring == QT_DOUBLE) {
+ if (instring == QT_DOUBLE && isset(BANGHIST) && bangchar) {
for (q = s; *q; q++)
- if (*q == '\\' && q[1] == '!')
+ if (*q == '\\' && (unsigned char)q[1] == bangchar)
*q = Bnull;
}
}
@@ -2205,7 +2205,7 @@ get_comp_string(void)
char sav = *lastp;
*lastp = '\0';
- untokenize(lastprebr = ztrdup(s));
+ untokenize(lastprebr = ztrdup(quotename(s)));
*lastp = sav;
}
if ((lastpostbr = ztrdup(firsts)))
@@ -2251,7 +2251,7 @@ inststrlen(char *str, int move, int len)
free(zlestr);
zsfree(instr);
if (move)
- zlecs += len;
+ zlecs += zlelen;
}
return len;
}
@@ -2884,6 +2884,7 @@ magicspace(char **args)
ZLE_STRING_T bangq;
ZLE_CHAR_T zlebangchar[1];
int ret;
+ int bangq_off;
#ifdef MULTIBYTE_SUPPORT
mbstate_t mbs;
#endif
@@ -2910,8 +2911,12 @@ magicspace(char **args)
break;
}
+ /* selfinsert can call spaceinline which can realloc zleline, we can't
+ * use the bangq pointer after that */
+ bangq_off = (bangq < zleline + zlell) ? (int)(bangq - zleline) : -1;
+
if (!(ret = selfinsert(args)) &&
- (!bangq || bangq + 2 > zleline + zlecs))
+ (bangq_off < 0 || bangq_off + 2 > zlecs))
doexpandhist();
return ret;
}
@@ -2929,7 +2934,7 @@ static int cmdwb, cmdwe;
/**/
static char *
-getcurcmd(void)
+getcurcmd(int trackpos)
{
int curlincmd;
char *s = NULL;
@@ -2957,6 +2962,17 @@ getcurcmd(void)
strinend();
inpop();
errflag &= ~ERRFLAG_ERROR;
+ if (s && trackpos) {
+ /* cmdwb and cmdwe are indices in zlemetaline, but we need indices
+ * into zleline, so do a little trick: use cmdwe as the length and
+ * cmdwb as the 'cursor position', this gives us both conversions
+ * in a single call to stringaszleline */
+ char *prefix = zalloc(cmdwe + 1);
+ memcpy(prefix, zlemetaline, cmdwe);
+ prefix[cmdwe] = '\0';
+ free(stringaszleline(prefix, cmdwb, &cmdwe, NULL, &cmdwb));
+ free(prefix);
+ }
unmetafy_line();
zcontext_restore();
@@ -2974,7 +2990,7 @@ processcmd(UNUSED(char **args))
int m = zmult, na = noaliases;
noaliases = 1;
- s = getcurcmd();
+ s = getcurcmd(0);
noaliases = na;
if (!s)
return 1;
@@ -3005,7 +3021,7 @@ expandcmdpath(UNUSED(char **args))
ZLE_STRING_T zlestr;
noaliases = 1;
- s = getcurcmd();
+ s = getcurcmd(1);
noaliases = na;
if (!s)
return 1;
@@ -3026,8 +3042,8 @@ expandcmdpath(UNUSED(char **args))
ZS_strncpy(zleline + zlecs, zlestr, strll);
free(zlestr);
zlecs = oldcs;
- if (zlecs >= cmdwe - 1)
- zlecs += cmdwe - cmdwb + strlen(str);
+ if (zlecs >= cmdwb)
+ zlecs += strll - (cmdwe - cmdwb);
if (zlecs > zlell)
zlecs = zlell;
return 0;
diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index 6e2456b1f..ff799369f 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -68,21 +68,24 @@ sizeline(int sz)
{
int cursz = (zlemetaline != NULL) ? metalinesz : linesz;
+ if (cursz >= sz)
+ return;
+
while (sz > cursz) {
if (cursz < 256)
cursz = 256;
else
cursz *= 4;
+ }
- if (zlemetaline != NULL) {
- /* One spare character for the NULL */
- zlemetaline = realloc(zlemetaline, cursz + 1);
- } else {
- /* One spare character for the NULL, one for the newline */
- zleline =
- (ZLE_STRING_T)realloc(zleline,
- (cursz + 2) * ZLE_CHAR_SIZE);
- }
+ if (zlemetaline != NULL) {
+ /* One spare character for the NULL */
+ zlemetaline = realloc(zlemetaline, cursz + 1);
+ } else {
+ /* One spare character for the NULL, one for the newline */
+ zleline =
+ (ZLE_STRING_T)realloc(zleline,
+ (cursz + 2) * ZLE_CHAR_SIZE);
}
if (zlemetaline != NULL)
@@ -367,7 +370,8 @@ zlelineasstring(ZLE_STRING_T instr, int inll, int incs, int *outllp,
*
* Memory for the returned string is permanently allocated. *outsz may
* be longer than the *outll returned. Hence it should be freed with
- * zfree(outstr, *outsz) or free(outstr), not zfree(outstr, *outll).
+ * zfree(outstr, (*outsz + 2) * ZLE_CHAR_SIZE) or free(outstr),
+ * not zfree(outstr, *outll).
*/
/**/
@@ -511,6 +515,7 @@ stringaszleline(char *instr, int incs, int *outll, int *outsz, int *outcs)
if (outcs && inptr <= instr + incs)
*outcs = outptr - outstr;
*outll = outptr - outstr;
+ outstr[*outll] = ZWC('\0');
} else {
*outstr = ZWC('\0');
*outll = 0;
@@ -571,6 +576,7 @@ free_region_highlights_memos(void)
rhp < region_highlights + n_region_highlights;
rhp++) {
zfree((char*) rhp->memo, 0);
+ rhp->memo = NULL;
}
}
@@ -700,8 +706,8 @@ zle_restore_positions(void)
oldrhp;
nreg++, oldrhp = oldrhp->next)
;
+ free_region_highlights_memos();
if (nreg + N_SPECIAL_HIGHLIGHTS != n_region_highlights) {
- free_region_highlights_memos();
n_region_highlights = nreg + N_SPECIAL_HIGHLIGHTS;
region_highlights = (struct region_highlight *)
zrealloc(region_highlights,
@@ -753,6 +759,7 @@ zle_free_positions(void)
oldrhp = oldpos->regions;
while (oldrhp) {
struct zle_region *nextrhp = oldrhp->next;
+ zsfree((char *)oldrhp->memo);
zfree(oldrhp, sizeof(*oldrhp));
oldrhp = nextrhp;
}
@@ -1107,7 +1114,7 @@ foredel(int ct, int flags)
if (flags & CUT_RAW) {
if (zlemetaline != NULL) {
shiftchars(zlemetacs, ct);
- } else if (flags & CUT_RAW) {
+ } else {
shiftchars(zlecs, ct);
CCRIGHT();
}
@@ -1328,7 +1335,7 @@ showmsg(char const *msg)
p++;
putc('\n', shout);
- up += 1 + cc / zterm_columns;
+ up += 1 + (cc - 1) / zterm_columns;
cc = 0;
} else {
/*
@@ -1379,7 +1386,7 @@ showmsg(char const *msg)
c = *++p ^ 32;
if(c == '\n') {
putc('\n', shout);
- up += 1 + cc / zterm_columns;
+ up += 1 + (cc - 1) / zterm_columns;
cc = 0;
} else {
char const *n = nicechar(c);
@@ -1388,7 +1395,7 @@ showmsg(char const *msg)
}
}
#endif
- up += cc / zterm_columns;
+ up += (cc - 1) / zterm_columns;
if (clearflag) {
putc('\r', shout);
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 667063774..783b49fb2 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -233,9 +233,10 @@ getvirange(int wf)
/* It is an error to use a non-movement command to delimit the *
* range. We here reject the case where the command modified *
* the line, or selected a different history line. */
- if (histline != hist1 || zlell != lastll || memcmp(zleline, lastline, zlell)) {
+ if (histline != hist1 || zlell != lastll || ZS_memcmp(zleline, lastline, zlell)) {
histline = hist1;
ZS_memcpy(zleline, lastline, zlell = lastll);
+ zleline[zlell] = ZWC('\0');
zlecs = pos;
mark = mpos;
virangeflag = 0;
@@ -360,7 +361,7 @@ viinsert(UNUSED(char **args))
/*
* Go to vi insert mode when we first start the line editor.
- * Iniialises some other stuff.
+ * Initialises some other stuff.
*/
/**/
@@ -836,11 +837,12 @@ viindent(UNUSED(char **args))
}
oldcs = zlecs;
/* add a tab to the beginning of each line within range */
- while (zlecs <= c2 + 1) {
+ while (zlecs <= c2) {
if (zleline[zlecs] == '\n') { /* leave blank lines alone */
++zlecs;
} else {
spaceinline(1);
+ c2++;
zleline[zlecs] = '\t';
zlecs = findeol() + 1;
}
@@ -873,8 +875,10 @@ viunindent(UNUSED(char **args))
oldcs = zlecs;
/* remove a tab from the beginning of each line within range */
while (zlecs < c2) {
- if (zleline[zlecs] == '\t')
+ if (zleline[zlecs] == '\t') {
foredel(1, 0);
+ c2--;
+ }
zlecs = findeol() + 1;
}
/* go back to the first line of the range */
@@ -1001,11 +1005,12 @@ viswapcase(UNUSED(char **args))
int
vicapslockpanic(UNUSED(char **args))
{
+ ZLE_INT_T ch;
clearlist = 1;
zbeep();
statusline = "press a lowercase key to continue";
zrefresh();
- while (!ZC_ilower(getfullchar(0)));
+ while (!ZC_ilower(ch = getfullchar(0)) && ch != ZLEEOF);
statusline = NULL;
return 0;
}
diff --git a/Src/Zle/zle_word.c b/Src/Zle/zle_word.c
index 89959b20c..575bb628a 100644
--- a/Src/Zle/zle_word.c
+++ b/Src/Zle/zle_word.c
@@ -356,7 +356,7 @@ vibackwardwordend(char **args)
zmult = n;
return ret;
}
- while (n-- && zlecs > 1) {
+ while (n-- && zlecs) {
int cc = wordclass(zleline[zlecs]);
DECCS();
while (zlecs) {
diff --git a/Src/builtin.c b/Src/builtin.c
index 26de1ab53..f1d0b606f 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -58,7 +58,7 @@ static struct builtin builtins[] =
BUILTIN("declare", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "AE:%F:%HL:%R:%TUZ:%afghi:%klmnp:%rtuxz", NULL),
BUILTIN("dirs", 0, bin_dirs, 0, -1, 0, "clpv", NULL),
BUILTIN("disable", 0, bin_enable, 0, -1, BIN_DISABLE, "afmprs", NULL),
- BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, NULL, NULL),
+ BUILTIN("disown", 0, bin_fg, 0, -1, BIN_DISOWN, "a", NULL),
BUILTIN("echo", BINF_SKIPINVALID, bin_print, 0, -1, BIN_ECHO, "neE", "-"),
BUILTIN("emulate", 0, bin_emulate, 0, -1, 0, "lLR", NULL),
BUILTIN("enable", 0, bin_enable, 0, -1, BIN_ENABLE, "afmprs", NULL),
@@ -76,7 +76,7 @@ static struct builtin builtins[] =
BUILTIN("float", BINF_PLUSOPTS | BINF_MAGICEQUALS | BINF_PSPECIAL | BINF_ASSIGN, (HandlerFunc)bin_typeset, 0, -1, 0, "E:%F:%HL:%R:%Z:%ghlp:%rtux", "E"),
BUILTIN("functions", BINF_PLUSOPTS, bin_functions, 0, -1, 0, "ckmMstTuUWx:z", NULL),
BUILTIN("getln", 0, bin_read, 0, -1, 0, "ecnAlE", "zr"),
- BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, NULL, NULL),
+ BUILTIN("getopts", 0, bin_getopts, 2, -1, 0, "p", NULL),
BUILTIN("hash", BINF_MAGICEQUALS, bin_hash, 0, -1, 0, "Ldfmrv", NULL),
#ifdef ZSH_HASH_DEBUG
@@ -387,9 +387,8 @@ execbuiltin(LinkList args, LinkList assigns, Builtin bn)
/* The above loop may have exited on an invalid option. (We *
* assume that any option requiring metafication is invalid.) */
if (*arg) {
- if(*arg == Meta)
- *++arg ^= 32;
- zwarnnam(name, "bad option: %c%c", "+-"[sense], *arg);
+ convchar_t warg = unmeta_one(arg, NULL);
+ zwarnnam(name, "bad option: %c%c", "+-"[sense], warg);
return 1;
}
arg = *++argv;
@@ -619,18 +618,20 @@ bin_set(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
hadplus |= !action;
if(!args[0][1])
*args = "--";
- while (*++*args) {
- if(**args == Meta)
- *++*args ^= 32;
- if(**args != '-' || action)
+ ++*args;
+ while (**args) {
+ int sz;
+ convchar_t arg = unmeta_one(*args, &sz);
+ *args += sz;
+ if(arg != '-' || action)
hadopt = 1;
/* The pseudo-option `--' signifies the end of options. */
- if (**args == '-') {
+ if (arg == '-') {
hadend = 1;
args++;
goto doneoptions;
- } else if (**args == 'o') {
- if (!*++*args)
+ } else if (arg == 'o') {
+ if (!**args)
args++;
if (!*args) {
printoptionstates(hadplus);
@@ -642,8 +643,8 @@ bin_set(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
else if(dosetopt(optno, action, 0, opts))
zerrnam(nam, "can't change option: %s", *args);
break;
- } else if(**args == 'A') {
- if(!*++*args)
+ } else if(arg == 'A') {
+ if(!**args)
args++;
array = action ? 1 : -1;
arrayname = *args;
@@ -655,13 +656,13 @@ bin_set(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
goto doneoptions;
}
break;
- } else if (**args == 's')
+ } else if (arg == 's')
sort = action ? 1 : -1;
else {
- if (!(optno = optlookupc(**args)))
- zerrnam(nam, "bad option: -%c", **args);
+ if (!(optno = optlookupc(arg)))
+ zerrnam(nam, "bad option: -%c", arg);
else if(dosetopt(optno, action, 0, opts))
- zerrnam(nam, "can't change option: -%c", **args);
+ zerrnam(nam, "can't change option: -%c", arg);
}
}
args++;
@@ -803,13 +804,13 @@ set_pwd_env(void)
/* update the PWD and OLDPWD shell parameters */
- pm = (Param) paramtab->getnode(paramtab, "PWD");
+ pm = (Param) realparamtab->getnode2(realparamtab, "PWD");
if (pm && PM_TYPE(pm->node.flags) != PM_SCALAR) {
pm->node.flags &= ~PM_READONLY;
unsetparam_pm(pm, 0, 1);
}
- pm = (Param) paramtab->getnode(paramtab, "OLDPWD");
+ pm = (Param) realparamtab->getnode2(realparamtab, "OLDPWD");
if (pm && PM_TYPE(pm->node.flags) != PM_SCALAR) {
pm->node.flags &= ~PM_READONLY;
unsetparam_pm(pm, 0, 1);
@@ -818,10 +819,10 @@ set_pwd_env(void)
assignsparam("PWD", ztrdup(pwd), 0);
assignsparam("OLDPWD", ztrdup(oldpwd), 0);
- pm = (Param) paramtab->getnode(paramtab, "PWD");
+ pm = (Param) realparamtab->getnode2(realparamtab, "PWD");
if (!(pm->node.flags & PM_EXPORTED))
addenv(pm, pwd);
- pm = (Param) paramtab->getnode(paramtab, "OLDPWD");
+ pm = (Param) realparamtab->getnode2(realparamtab, "OLDPWD");
if (!(pm->node.flags & PM_EXPORTED))
addenv(pm, oldpwd);
}
@@ -841,10 +842,6 @@ bin_cd(char *nam, char **argv, Options ops, int func)
{
LinkNode dir;
- if (isset(RESTRICTED)) {
- zwarnnam(nam, "restricted");
- return 1;
- }
doprintdir = (doprintdir == -1);
chasinglinks = OPT_ISSET(ops,'P') ||
@@ -2042,13 +2039,8 @@ typeset_single(char *cname, char *pname, Param pm, int func,
(on & ~(PM_NAMEREF|PM_LOCAL|PM_READONLY))) {
/* Changing type of PM_SPECIAL|PM_AUTOLOAD is a fatal error. *
* Should this be a fatal error as well, rather than warning? */
- if (pm->width)
- zwarnnam(cname,
- "%s: can't change type via subscript reference",
- pm->u.str);
- else
- zwarnnam(cname, "%s: can't change type of a named reference",
- pname);
+ zwarnnam(cname, "%s: can't change type of a named reference",
+ pname);
return NULL;
}
}
@@ -2250,10 +2242,6 @@ typeset_single(char *cname, char *pname, Param pm, int func,
paramtab->printnode(&pm->node, PRINT_INCLUDEVALUE|with_ns);
return pm;
}
- if ((pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerrnam(cname, "%s: restricted", pname);
- return pm;
- }
if ((pm->node.flags & PM_READONLY) && !(off & PM_READONLY) &&
/* It seems as though these checks should not be specific to
* PM_NAMEREF, but changing that changes historic behavior */
@@ -2288,17 +2276,12 @@ typeset_single(char *cname, char *pname, Param pm, int func,
paramtab->printnode(&pm->node, PRINT_TYPESET|PRINT_WITH_NAMESPACE);
return pm;
}
- if (usepm == 2) /* do not change the PM_UNSET flag */
- pm->node.flags = (pm->node.flags | (on & ~PM_READONLY)) & ~off;
- else {
- /*
- * Keep unset if using readonly in POSIX mode.
- */
- if (!(on & PM_READONLY) || !isset(POSIXBUILTINS))
- off |= PM_UNSET;
- pm->node.flags = (pm->node.flags |
- (on & ~PM_READONLY)) & ~off;
- }
+ /*
+ * Keep unset if using readonly in POSIX mode unless specified otherwise.
+ */
+ if ((usepm != 2) && !((on & PM_READONLY) && isset(POSIXBUILTINS)))
+ off |= PM_UNSET;
+ pm->node.flags = (pm->node.flags | (on & ~PM_READONLY)) & ~off;
if (on & (PM_LEFT | PM_RIGHT_B | PM_RIGHT_Z)) {
if (typeset_setwidth(cname, pm, ops, on, 0))
return NULL;
@@ -2388,10 +2371,6 @@ typeset_single(char *cname, char *pname, Param pm, int func,
if (newspecial != NS_NONE) {
Param tpm, pm2;
- if ((pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerrnam(cname, "%s: restricted", pname);
- return pm;
- }
if (pm->node.flags & PM_SINGLE) {
zerrnam(cname, "%s: can only have a single instance", pname);
return pm;
@@ -2633,12 +2612,7 @@ typeset_single(char *cname, char *pname, Param pm, int func,
pm->gsu.s->setfn(pm, ztrdup(""));
break;
case PM_INTEGER:
- /*
- * Restricted integers are dangerous to initialize to 0,
- * so don't do that.
- */
- if (!(pm->old->node.flags & PM_RESTRICTED))
- pm->gsu.i->setfn(pm, 0);
+ pm->gsu.i->setfn(pm, 0);
break;
case PM_EFLOAT:
case PM_FFLOAT:
@@ -3098,8 +3072,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
for (i = 0; i < paramtab->hsize; i++) {
for (pm = (Param) paramtab->nodes[i]; pm;
pm = (Param) pm->node.next) {
- if (((pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) ||
- (pm->node.flags & PM_UNSET))
+ if (pm->node.flags & PM_UNSET)
continue;
if (pattry(pprog, pm->node.nam))
addlinknode(pmlist, pm);
@@ -3186,11 +3159,11 @@ eval_autoload(Shfunc shf, char *name, Options ops, int func)
if (!(shf->node.flags & PM_UNDEFINED))
return 1;
- if (shf->funcdef) {
- freeeprog(shf->funcdef);
- shf->funcdef = &dummy_eprog;
- }
if (OPT_MINUS(ops,'X')) {
+ if (shf->funcdef) {
+ freeeprog(shf->funcdef);
+ shf->funcdef = &dummy_eprog;
+ }
char *fargv[3];
fargv[0] = quotestring(name, QT_SINGLE_OPTIONAL);
fargv[1] = "\"$@\"";
@@ -3316,7 +3289,7 @@ add_autoload_function(Shfunc shf, char *funcname)
Shfunc shf2;
Funcstack fs;
const char *calling_f = NULL;
- char buf[PATH_MAX+1];
+ char buf[PATH_MAX*4];
/* Find calling function */
for (fs = funcstack; fs; fs = fs->prev) {
@@ -3333,10 +3306,11 @@ add_autoload_function(Shfunc shf, char *funcname)
&& (shf2->node.flags & PM_LOADDIR) && (shf2->node.flags & PM_ABSPATH_USED)
&& shf2->filename)
{
- if (snprintf(buf, PATH_MAX, "%s/%s", shf2->filename, funcname) < PATH_MAX)
+ if (snprintf(buf, sizeof(buf), "%s/%s", shf2->filename, funcname) < sizeof(buf))
{
/* Set containing directory if the function file
* exists (do normal FPATH processing otherwise) */
+ unmetafy(buf, NULL);
if (!access(buf, R_OK)) {
dircache_set(&shf->filename, NULL);
dircache_set(&shf->filename, shf2->filename);
@@ -3413,7 +3387,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
(OPT_MINUS(ops,'X') && (OPT_ISSET(ops,'m') || !scriptname)) ||
(OPT_ISSET(ops,'c') && (OPT_ISSET(ops,'x') || OPT_ISSET(ops,'X') ||
OPT_ISSET(ops,'m')))) {
- zwarnnam(name, "invalid option(s)");
+ zwarnnam(name, "bad option(s)");
return 1;
}
@@ -3490,7 +3464,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
*/
if (on || off || pflags || OPT_ISSET(ops,'X') || OPT_ISSET(ops,'u')
|| OPT_ISSET(ops,'U') || OPT_ISSET(ops,'w')) {
- zwarnnam(name, "invalid option(s)");
+ zwarnnam(name, "bad option(s)");
return 1;
}
if (!*argv) {
@@ -3857,13 +3831,10 @@ bin_unset(char *name, char **argv, Options ops, int func)
for (pm = (Param) paramtab->nodes[i]; pm; pm = next) {
/* record pointer to next, since we may free this one */
next = (Param) pm->node.next;
- if ((!(pm->node.flags & PM_RESTRICTED) ||
- unset(RESTRICTED)) &&
- pattry(pprog, pm->node.nam)) {
- if (!OPT_ISSET(ops,'n') &&
- (pm->node.flags & PM_NAMEREF) && pm->u.str)
- unsetparam(pm->u.str);
- else
+ if (pattry(pprog, pm->node.nam)) {
+ if (OPT_ISSET(ops,'n') ||
+ ((pm = resolve_nameref(pm)) &&
+ !(pm->node.flags & PM_NAMEREF)))
unsetparam_pm(pm, 0, 1);
match++;
}
@@ -3912,12 +3883,8 @@ bin_unset(char *name, char **argv, Options ops, int func)
*/
if (!pm)
continue;
- else if ((pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerrnam(name, "%s: restricted", pm->node.nam);
- returnval = 1;
- } else if (ss) {
- if ((pm->node.flags & PM_NAMEREF) &&
- (!(pm = resolve_nameref(pm)) || pm->width)) {
+ else if (ss) {
+ if ((pm->node.flags & PM_NAMEREF) && !(pm = resolve_nameref(pm))) {
/* warning? */
continue;
}
@@ -3959,22 +3926,11 @@ bin_unset(char *name, char **argv, Options ops, int func)
zerrnam(name, "%s: invalid element for unset", s);
returnval = 1;
}
- } else {
- if (!OPT_ISSET(ops,'n')) {
- int ref = (pm->node.flags & PM_NAMEREF);
- if (!(pm = resolve_nameref(pm)))
- continue;
- if (ref && pm->level < locallevel &&
- !(pm->node.flags & PM_READONLY)) {
- /* Just mark unset, do not remove from table */
- stdunsetfn(pm, 0);
- pm->node.flags |= PM_DECLARED;
- continue;
- }
- }
+ } else if (OPT_ISSET(ops,'n') ||
+ ((pm = resolve_nameref(pm)) &&
+ !(pm->node.flags & PM_NAMEREF)))
if (unsetparam_pm(pm, 0, 1))
returnval = 1;
- }
if (ss)
*ss = '[';
}
@@ -4317,34 +4273,28 @@ bin_hash(char *name, char **argv, Options ops, UNUSED(int func))
returnval = 1;
break;
} else if (ASG_VALUEP(asg)) {
- if(isset(RESTRICTED)) {
- zwarnnam(name, "restricted: %s", asg->value.scalar);
- returnval = 1;
- } else {
- /* The argument is of the form foo=bar, *
- * so define an entry for the table. */
- if(OPT_ISSET(ops,'d')) {
- /* shouldn't return NULL if asg->name is not NULL */
- if (*itype_end(asg->name, IUSER, 0)) {
- zwarnnam(name,
- "invalid character in directory name: %s",
- asg->name);
- returnval = 1;
- continue;
- } else {
- Nameddir nd = hn = zshcalloc(sizeof *nd);
- nd->node.flags = 0;
- nd->dir = ztrdup(asg->value.scalar);
- }
+ /* The argument is of the form foo=bar, *
+ * so define an entry for the table. */
+ if (OPT_ISSET(ops, 'd')) {
+ /* shouldn't return NULL if asg->name is not NULL */
+ if (*itype_end(asg->name, IUSER, 0)) {
+ zwarnnam(name, "invalid character in directory name: %s",
+ asg->name);
+ returnval = 1;
+ continue;
} else {
- Cmdnam cn = hn = zshcalloc(sizeof *cn);
- cn->node.flags = HASHED;
- cn->u.cmd = ztrdup(asg->value.scalar);
+ Nameddir nd = hn = zshcalloc(sizeof *nd);
+ nd->node.flags = 0;
+ nd->dir = ztrdup(asg->value.scalar);
}
- ht->addnode(ht, ztrdup(asg->name), hn);
- if(OPT_ISSET(ops,'v'))
- ht->printnode(hn, 0);
+ } else {
+ Cmdnam cn = hn = zshcalloc(sizeof *cn);
+ cn->node.flags = HASHED;
+ cn->u.cmd = ztrdup(asg->value.scalar);
}
+ ht->addnode(ht, ztrdup(asg->name), hn);
+ if (OPT_ISSET(ops, 'v'))
+ ht->printnode(hn, 0);
} else if (!(hn = ht->getnode2(ht, asg->name))) {
/* With no `=value' part to the argument, *
* work out what it ought to be. */
@@ -4492,7 +4442,7 @@ bin_alias(char *name, char **argv, Options ops, UNUSED(int func))
OPT_ISSET(ops, 's');
if (type_opts) {
if (type_opts > 1) {
- zwarnnam(name, "illegal combination of options");
+ zwarnnam(name, "invalid combination of options");
return 1;
}
if (OPT_ISSET(ops,'g'))
@@ -5644,7 +5594,7 @@ bin_shift(char *name, char **argv, Options ops, UNUSED(int func))
for (; *argv; argv++)
if ((s = getaparam(*argv))) {
if (arrlen_lt(s, num)) {
- zwarnnam(name, "shift count must be <= $#");
+ zwarnnam(name, "shift count must be <= ${#%s}", *argv);
ret++;
continue;
}
@@ -5698,12 +5648,18 @@ int optcind;
/**/
int
-bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int func))
+bin_getopts(UNUSED(char *name), char **argv, Options ops, UNUSED(int func))
{
- int lenstr, lenoptstr, quiet, lenoptbuf;
+ int lenstr, lenoptstr, quiet, lenoptbuf, posix;
char *optstr = unmetafy(*argv++, &lenoptstr), *var = *argv++;
char **args = (*argv) ? argv : pparams;
char *str, optbuf[2] = " ", *p, opch;
+ convchar_t wopch;
+
+ // note that resetting + restoring OPTIND happens in doshfunc(), so using -p
+ // or enabling POSIX_BUILTINS inside a function that calls getopts is not
+ // exactly the same as enabling POSIX_BUILTINS before the function is called
+ posix = isset(POSIXBUILTINS) || OPT_ISSET(ops, 'p');
/* zoptind keeps count of the current argument number. The *
* user can set it to zero to start a new option parse. */
@@ -5732,7 +5688,7 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun
str = unmetafy(dupstring(args[zoptind - 1]), &lenstr);
}
if(!optcind) {
- if(lenstr < 2 || (*str != '-' && *str != '+'))
+ if (lenstr < 2 || (*str != '-' && (posix || *str != '+')))
return 1;
if(lenstr == 2 && str[0] == '-' && str[1] == '-') {
zoptind++;
@@ -5740,7 +5696,9 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun
}
optcind++;
}
- opch = str[optcind++];
+ opch = str[optcind];
+ MB_CHARINIT();
+ optcind += MB_CHARLENCONV(str + optcind, lenstr - optcind, &wopch);
if(str[0] == '+') {
optbuf[0] = '+';
lenoptbuf = 2;
@@ -5752,7 +5710,7 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun
if(opch == ':' || !(p = memchr(optstr, opch, lenoptstr))) {
p = "?";
/* Keep OPTIND correct if the user doesn't return after the error */
- if (isset(POSIXBUILTINS)) {
+ if (posix) {
optcind = 0;
zoptind++;
}
@@ -5762,7 +5720,7 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun
zoptarg = metafy(optbuf, lenoptbuf, META_DUP);
} else {
zwarn("bad option: %c%c",
- "?-+"[lenoptbuf], opch);
+ "?-+"[lenoptbuf], wopch);
zoptarg=ztrdup("");
}
return 0;
@@ -5773,7 +5731,7 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun
if(optcind == lenstr) {
if(!args[zoptind]) {
/* Fix OPTIND as above */
- if (isset(POSIXBUILTINS)) {
+ if (posix) {
optcind = 0;
zoptind++;
}
@@ -5785,7 +5743,7 @@ bin_getopts(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int fun
setsparam(var, ztrdup("?"));
zoptarg = ztrdup("");
zwarn("argument expected after %c%c option",
- "?-+"[lenoptbuf], opch);
+ "?-+"[lenoptbuf], wopch);
}
return 0;
}
@@ -6596,6 +6554,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
#endif
if (isatty(readfd)) {
struct ttyinfo ti;
+ memset(&ti, 0, sizeof(struct ttyinfo));
fdgettyinfo(readfd, &ti);
if (! resettty) {
saveti = ti;
@@ -6614,8 +6573,7 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
if (OPT_ISSET(ops,'t')) {
zlong timeout = 0;
if (OPT_HASARG(ops,'t')) {
- mnumber mn = zero_mnumber;
- mn = matheval(OPT_ARG(ops,'t'));
+ mnumber mn = matheval(OPT_ARG(ops,'t'));
if (errflag)
return 1;
if (mn.type == MN_FLOAT) {
diff --git a/Src/exec.c b/Src/exec.c
index 7a928a316..17899262d 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -35,8 +35,6 @@
enum {
/* Export the variable for "VAR=val cmd ..." */
ADDVAR_EXPORT = 1 << 0,
- /* Apply restrictions for variable */
- ADDVAR_RESTRICT = 1 << 1,
/* Variable list is being restored later */
ADDVAR_RESTORE = 1 << 2
};
@@ -265,6 +263,11 @@ static int doneps4;
static char *STTYval;
static char *blank_env[] = { NULL };
+/* total allocated elements in zsh_eval_context array */
+static int zsh_eval_context_len;
+/* number of in-use elements in zsh_eval_context array */
+static int zsh_eval_context_alen;
+
/* Execution functions. */
static int (*execfuncs[WC_COUNT-WC_CURSH]) (Estate, int) = {
@@ -506,7 +509,7 @@ static int
zexecve(char *pth, char **argv, char **newenvp)
{
int eno;
- static char buf[PATH_MAX * 2+1];
+ static char buf[PATH_MAX * 2+2+1+1]; /* enough room if pwd fits in PATH_MAX */
char **eep;
unmetafy(pth, NULL);
@@ -518,7 +521,8 @@ zexecve(char *pth, char **argv, char **newenvp)
if (*pth == '/')
strcpy(buf + 2, pth);
else
- sprintf(buf + 2, "%s/%s", unmeta(pwd), pth);
+ /* not checking for truncation because what would we do? */
+ snprintf(buf + 2, sizeof(buf) - 2, "%s/%s", unmeta(pwd), pth);
zputenv(buf);
#ifndef FD_CLOEXEC
closedumps();
@@ -694,7 +698,7 @@ search_defpath(char *cmd, char *pbuf, int plen)
{
char *ps = DEFAULT_PATH, *pe = NULL, *s;
- for (ps = DEFAULT_PATH; ps; ps = pe ? pe+1 : NULL) {
+ for (; ps; ps = pe ? pe+1 : NULL) {
pe = strchr(ps, ':');
if (*ps == '/') {
s = pbuf;
@@ -725,16 +729,12 @@ static void
execute(LinkList args, int flags, int defpath)
{
Cmdnam cn;
- char buf[MAXCMDLEN+1], buf2[MAXCMDLEN+1];
+ char buf[MAXCMDLEN], buf2[MAXCMDLEN];
char *s, *z, *arg0;
char **argv, **pp, **newenvp = NULL;
int eno = 0, ee;
arg0 = (char *) peekfirst(args);
- if (isset(RESTRICTED) && (strchr(arg0, '/') || defpath)) {
- zerr("%s: restricted", arg0);
- _exit(1);
- }
/* If the parameter STTY is set in the command's environment, *
* we first run the stty command with the value of this *
@@ -753,10 +753,12 @@ execute(LinkList args, int flags, int defpath)
zsfree(s);
}
+ argv = makecline(args, flags & BINF_DASH);
+
/* If ARGV0 is in the commands environment, we use *
* that as argv[0] for this external command */
- if (unset(RESTRICTED) && (z = zgetenv("ARGV0"))) {
- setdata(firstnode(args), (void *) ztrdup(z));
+ if ((z = zgetenv("ARGV0"))) {
+ argv[0] = ztrdup(z);
/*
* Note we don't do anything with the parameter structure
* for ARGV0: that's OK since we're about to exec or exit
@@ -771,10 +773,9 @@ execute(LinkList args, int flags, int defpath)
/* Else if the pre-command `-' was given, we add `-' *
* to the front of argv[0] for this command. */
sprintf(buf2, "-%s", arg0);
- setdata(firstnode(args), (void *) ztrdup(buf2));
+ argv[0] = ztrdup(buf2);
}
- argv = makecline(args);
if (flags & BINF_CLEARENV)
newenvp = blank_env;
@@ -790,9 +791,9 @@ execute(LinkList args, int flags, int defpath)
}
#endif
child_unblock();
- if ((int) strlen(arg0) >= PATH_MAX) {
+ if ((int) ztrlen(arg0) >= PATH_MAX) {
zerr("command too long: %s", arg0);
- _exit(1);
+ _exit(127);
}
for (s = arg0; *s; s++)
if (*s == '/') {
@@ -808,10 +809,10 @@ execute(LinkList args, int flags, int defpath)
/* for command -p, search the default path */
if (defpath) {
- char pbuf[PATH_MAX+1];
+ char pbuf[MAXCMDLEN];
char *dptr;
- if (!search_defpath(arg0, pbuf, PATH_MAX)) {
+ if (!search_defpath(arg0, pbuf, MAXCMDLEN)) {
if (commandnotfound(arg0, args) == 0)
_realexit();
zerr("command not found: %s", arg0);
@@ -828,28 +829,43 @@ execute(LinkList args, int flags, int defpath)
} else {
if ((cn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, arg0))) {
- char nn[PATH_MAX+1], *dptr;
+ char nn[MAXCMDLEN], *dptr;
- if (cn->node.flags & HASHED)
- strcpy(nn, cn->u.cmd);
- else {
- for (pp = path; pp < cn->u.name; pp++)
+ if (cn->node.flags & HASHED) {
+ if (snprintf(nn, sizeof(nn), "%s", cn->u.cmd) >= (int)sizeof(nn) ||
+ ztrlen(nn) >= PATH_MAX)
+ {
+ zerr("command too long: %s", arg0);
+ _exit(127);
+ }
+ } else {
+ for (pp = path; pp < cn->u.name; pp++) {
if (!**pp || (**pp == '.' && (*pp)[1] == '\0')) {
ee = zexecve(arg0, argv, newenvp);
if (isgooderr(ee, *pp))
eno = ee;
} else if (**pp != '/') {
z = buf;
- strucpy(&z, *pp);
+ struncpy(&z, *pp, sizeof(buf) - 1);
*z++ = '/';
+ if ((z - buf) + strlen(arg0) >= sizeof(buf))
+ continue;
strcpy(z, arg0);
+ if (ztrlen(buf) >= PATH_MAX)
+ continue;
ee = zexecve(buf, argv, newenvp);
if (isgooderr(ee, *pp))
eno = ee;
}
- strcpy(nn, cn->u.name ? *(cn->u.name) : "");
- strcat(nn, "/");
- strcat(nn, cn->node.nam);
+ }
+ if (snprintf(nn, sizeof(nn), "%s/%s",
+ cn->u.name ? *(cn->u.name) : "",
+ cn->node.nam) >= (int)sizeof(nn) ||
+ ztrlen(nn) >= PATH_MAX)
+ {
+ eno = ENAMETOOLONG;
+ goto execute_skip_exec;
+ }
}
ee = zexecve(nn, argv, newenvp);
@@ -858,6 +874,7 @@ execute(LinkList args, int flags, int defpath)
if (isgooderr(ee, *nn ? nn : "/"))
eno = ee;
}
+execute_skip_exec:
for (pp = path; *pp; pp++)
if (!(*pp)[0] || ((*pp)[0] == '.' && !(*pp)[1])) {
ee = zexecve(arg0, argv, newenvp);
@@ -865,9 +882,13 @@ execute(LinkList args, int flags, int defpath)
eno = ee;
} else {
z = buf;
- strucpy(&z, *pp);
+ struncpy(&z, *pp, sizeof(buf) - 1);
*z++ = '/';
+ if ((z - buf) + strlen(arg0) >= sizeof(buf))
+ continue;
strcpy(z, arg0);
+ if (ztrlen(buf) >= PATH_MAX)
+ continue;
ee = zexecve(buf, argv, newenvp);
if (isgooderr(ee, *pp))
eno = ee;
@@ -913,9 +934,9 @@ findcmd(char *arg0, int docopy, int default_path)
return NULL;
}
cn = (Cmdnam) cmdnamtab->getnode(cmdnamtab, arg0);
- if (!cn && isset(HASHCMDS) && !isrelative(arg0))
+ if (!cn && isset(HASHCMDS))
cn = hashcmd(arg0, path);
- if ((int) strlen(arg0) > PATH_MAX)
+ if ((int) ztrlen(arg0) >= PATH_MAX)
return NULL;
if ((s = strchr(arg0, '/'))) {
RET_IF_COM(arg0);
@@ -925,32 +946,42 @@ findcmd(char *arg0, int docopy, int default_path)
}
}
if (cn) {
- char nn[PATH_MAX+1];
+ char nn[MAXCMDLEN];
- if (cn->node.flags & HASHED)
- strcpy(nn, cn->u.cmd);
- else {
- for (pp = path; pp < cn->u.name; pp++)
+ if (cn->node.flags & HASHED) {
+ if (snprintf(nn, sizeof(nn), "%s", cn->u.cmd) >= (int)sizeof(nn)) {
+ nn[0] = '\0';
+ }
+ } else {
+ for (pp = path; pp < cn->u.name; pp++) {
if (**pp != '/') {
z = buf;
if (**pp) {
- strucpy(&z, *pp);
+ struncpy(&z, *pp, sizeof(buf) - 1);
*z++ = '/';
+ if ((z - buf) + strlen(arg0) >= sizeof(buf))
+ continue;
}
strcpy(z, arg0);
RET_IF_COM(buf);
}
- strcpy(nn, cn->u.name ? *(cn->u.name) : "");
- strcat(nn, "/");
- strcat(nn, cn->node.nam);
+ }
+ if (snprintf(nn, sizeof(nn), "%s/%s",
+ cn->u.name ? *(cn->u.name) : "",
+ cn->node.nam) >= (int)sizeof(nn))
+ {
+ nn[0] = '\0';
+ }
}
RET_IF_COM(nn);
}
for (pp = path; *pp; pp++) {
z = buf;
if (**pp) {
- strucpy(&z, *pp);
+ struncpy(&z, *pp, sizeof(buf) - 1);
*z++ = '/';
+ if ((z - buf) + strlen(arg0) >= sizeof(buf))
+ continue;
}
strcpy(z, arg0);
RET_IF_COM(buf);
@@ -980,14 +1011,16 @@ isreallycom(Cmdnam cn)
{
char fullnam[MAXCMDLEN];
- if (cn->node.flags & HASHED)
- strcpy(fullnam, cn->u.cmd);
- else if (!cn->u.name)
+ if (cn->node.flags & HASHED) {
+ if (snprintf(fullnam, sizeof(fullnam), "%s", cn->u.cmd)
+ >= (int)sizeof(fullnam))
+ return 0;
+ } else if (!cn->u.name) {
return 0;
- else {
- strcpy(fullnam, *(cn->u.name));
- strcat(fullnam, "/");
- strcat(fullnam, cn->node.nam);
+ } else {
+ if (snprintf(fullnam, sizeof(fullnam), "%s/%s",
+ *(cn->u.name), cn->node.nam) >= (int)sizeof(fullnam))
+ return 0;
}
return iscom(fullnam);
}
@@ -1016,17 +1049,17 @@ mod_export Cmdnam
hashcmd(char *arg0, char **pp)
{
Cmdnam cn;
- char *s, buf[PATH_MAX+1];
+ char *s, buf[MAXCMDLEN];
char **pq;
- if (*arg0 == '/')
+ if ((*arg0 == '/') || !strncmp(arg0, "./", 2) || !strncmp(arg0, "../", 3))
return NULL;
for (; *pp; pp++)
if (**pp == '/') {
s = buf;
- struncpy(&s, *pp, PATH_MAX);
+ struncpy(&s, *pp, sizeof(buf) - 1);
*s++ = '/';
- if ((s - buf) + strlen(arg0) >= PATH_MAX)
+ if ((s - buf) + strlen(arg0) >= sizeof(buf))
continue;
strcpy(s, arg0);
if (iscom(buf))
@@ -1246,30 +1279,44 @@ execstring(char *s, int dont_change_job, int exiting, char *context)
popheap();
}
+/* append a context to the zsh_eval_context array */
+
/**/
mod_export void
-execode(Eprog p, int dont_change_job, int exiting, char *context)
+zsh_eval_context_push(char *context)
{
- struct estate s;
- static int zsh_eval_context_len;
- int alen;
-
if (!zsh_eval_context_len) {
zsh_eval_context_len = 16;
- alen = 0;
+ zsh_eval_context_alen = 0;
zsh_eval_context = (char **)zalloc(zsh_eval_context_len *
sizeof(*zsh_eval_context));
- } else {
- alen = arrlen(zsh_eval_context);
- if (zsh_eval_context_len == alen + 1) {
- zsh_eval_context_len *= 2;
- zsh_eval_context = zrealloc(zsh_eval_context,
- zsh_eval_context_len *
- sizeof(*zsh_eval_context));
- }
+ } else if (zsh_eval_context_len == zsh_eval_context_alen + 1) {
+ zsh_eval_context_len *= 2;
+ zsh_eval_context = zrealloc(zsh_eval_context,
+ zsh_eval_context_len *
+ sizeof(*zsh_eval_context));
}
- zsh_eval_context[alen] = context;
- zsh_eval_context[alen+1] = NULL;
+ zsh_eval_context[zsh_eval_context_alen] = context;
+ zsh_eval_context[++zsh_eval_context_alen] = NULL;
+}
+
+/* remove the last context from the zsh_eval_context array */
+
+/**/
+mod_export void
+zsh_eval_context_pop(void)
+{
+ if (zsh_eval_context_alen)
+ zsh_eval_context[--zsh_eval_context_alen] = NULL;
+}
+
+/**/
+mod_export void
+execode(Eprog p, int dont_change_job, int exiting, char *context)
+{
+ struct estate s;
+
+ zsh_eval_context_push(context);
s.prog = p;
s.pc = p->prog;
@@ -1284,7 +1331,7 @@ execode(Eprog p, int dont_change_job, int exiting, char *context)
* zsh_eval_context may have been altered by a recursive
* call, but that's OK since we're using the global value.
*/
- zsh_eval_context[alen] = NULL;
+ zsh_eval_context_pop();
}
/* Execute a simplified command. This is used to execute things that
@@ -1505,9 +1552,9 @@ execlist(Estate state, int dont_change_job, int exiting)
case WC_SUBLIST_AND:
/* If the return code is non-zero, we skip pipelines until *
* we find a sublist followed by ORNEXT. */
- if ((ret = ((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_SIMPLE) ?
+ if (((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_SIMPLE) ?
execsimple(state) :
- execpline(state, code, Z_SYNC, 0))) || breaks) {
+ execpline(state, code, Z_SYNC, 0)) || breaks) {
state->pc = next;
code = *state->pc++;
next = state->pc + WC_SUBLIST_SKIP(code);
@@ -1538,7 +1585,7 @@ execlist(Estate state, int dont_change_job, int exiting)
case WC_SUBLIST_OR:
/* If the return code is zero, we skip pipelines until *
* we find a sublist followed by ANDNEXT. */
- if (!(ret = ((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_SIMPLE) ?
+ if (!(((WC_SUBLIST_FLAGS(code) & WC_SUBLIST_SIMPLE) ?
execsimple(state) :
execpline(state, code, Z_SYNC, 0))) || breaks) {
state->pc = next;
@@ -1604,7 +1651,10 @@ sublist_done:
if (!this_noerrexit && !donetrap && !this_donetrap) {
if (sigtrapped[SIGZERR] && lastval &&
!(noerrexit & NOERREXIT_EXIT)) {
+ int eflag = errflag;
+ errflag = 0;
dotrap(SIGZERR);
+ errflag = eflag;
donetrap = 1;
}
if (lastval) {
@@ -2049,7 +2099,7 @@ execpline2(Estate state, wordcode pcode,
/**/
static char **
-makecline(LinkList list)
+makecline(LinkList list, int dash)
{
LinkNode node;
char **argv, **ptr;
@@ -2062,6 +2112,7 @@ makecline(LinkList list)
if (!doneps4)
printprompt4();
+ if (dash) fputs("- ", xtrerr);
for (node = firstnode(list); node; incnode(node)) {
*ptr++ = (char *)getdata(node);
quotedzputs(getdata(node), xtrerr);
@@ -2588,14 +2639,6 @@ addvars(Estate state, Wordcode pc, int addflags)
fputc(' ', xtrerr);
}
if ((addflags & ADDVAR_EXPORT) && !strchr(name, '[')) {
- if ((addflags & ADDVAR_RESTRICT) && isset(RESTRICTED) &&
- (pm = (Param) paramtab->removenode(paramtab, name)) &&
- (pm->node.flags & PM_RESTRICTED)) {
- zerr("%s: restricted", pm->node.nam);
- zsfree(val);
- state->pc = opc;
- return;
- }
if (strcmp(name, "STTY") == 0) {
zsfree(STTYval);
STTYval = ztrdup(val);
@@ -2604,7 +2647,7 @@ addvars(Estate state, Wordcode pc, int addflags)
opts[ALLEXPORT] = 1;
if (isset(KSHARRAYS))
unsetparam(name);
- pm = assignsparam(name, val, myflags);
+ pm = assignsparam(name, val, myflags);
opts[ALLEXPORT] = allexp;
} else
pm = assignsparam(name, val, myflags);
@@ -2699,11 +2742,8 @@ execsubst(LinkList strs)
{
if (strs) {
prefork(strs, esprefork, NULL);
- if (esglob && !errflag) {
- LinkList ostrs = strs;
+ if (esglob && !errflag)
globlist(strs, 0);
- strs = ostrs;
- }
}
}
@@ -3260,14 +3300,17 @@ execcmd_exec(Estate state, Execcmd_params eparams,
cflags |= BINF_DASH;
break;
default:
- zerr("unknown exec flag -%c", *cmdopt);
- lastval = 1;
- errflag |= ERRFLAG_ERROR;
- if (forked)
- _realexit();
- if (how & Z_TIMED)
- shelltime(&shti, &chti, &then, 1);
- return;
+ {
+ convchar_t opt = unmeta_one(cmdopt, NULL);
+ zerr("unknown exec flag -%c", opt);
+ lastval = 1;
+ errflag |= ERRFLAG_ERROR;
+ if (forked)
+ _realexit();
+ if (how & Z_TIMED)
+ shelltime(&shti, &chti, &then, 1);
+ return;
+ }
}
}
if (!argnode)
@@ -3418,15 +3461,6 @@ execcmd_exec(Estate state, Execcmd_params eparams,
shelltime(&shti, &chti, &then, 1);
return;
}
- } else if (isset(RESTRICTED) && (cflags & BINF_EXEC) && do_exec) {
- zerrnam("exec", "%s: restricted",
- (char *) getdata(firstnode(args)));
- lastval = 1;
- if (forked)
- _realexit();
- if (how & Z_TIMED)
- shelltime(&shti, &chti, &then, 1);
- return;
}
/*
@@ -3783,10 +3817,6 @@ execcmd_exec(Estate state, Execcmd_params eparams,
fixfds(save);
execerr();
}
- if (isset(RESTRICTED) && IS_WRITE_FILE(fn->type)) {
- zwarn("writing redirection not allowed in restricted mode");
- execerr();
- }
if (unset(EXECOPT))
continue;
switch(fn->type) {
@@ -4314,7 +4344,7 @@ execcmd_exec(Estate state, Execcmd_params eparams,
}
if (type == WC_SIMPLE || type == WC_TYPESET) {
if (varspc) {
- int addflags = ADDVAR_EXPORT|ADDVAR_RESTRICT;
+ int addflags = ADDVAR_EXPORT;
if (forked)
addflags |= ADDVAR_RESTORE;
addvars(state, varspc, addflags);
@@ -4463,8 +4493,7 @@ save_params(Estate state, Wordcode pc, LinkList *restore_p, LinkList *remove_p)
tpm = (Param) zshcalloc(sizeof *tpm);
tpm->node.nam = ztrdup(pm->node.nam);
copyparam(tpm, pm, 0);
- } else if (!(pm->node.flags & PM_READONLY) &&
- (unset(RESTRICTED) || !(pm->node.flags & PM_RESTRICTED))) {
+ } else if (!(pm->node.flags & PM_READONLY)) {
/*
* In this case we're just saving parts of
* the parameter in a temporary, so use heap allocation
@@ -4598,7 +4627,8 @@ char *
gethere(char **strp, int typ)
{
char *buf;
- int bsiz, qt = 0, strip = 0;
+ int qt = 0, strip = 0;
+ size_t bsiz;
char *s, *t, *bptr, c;
char *str = *strp;
@@ -4625,7 +4655,7 @@ gethere(char **strp, int typ)
if (bptr >= buf + bsiz - 2) {
ptrdiff_t toff = t - buf;
ptrdiff_t bptroff = bptr - buf;
- char *newbuf = realloc(buf, 2 * bsiz);
+ char *newbuf = (bsiz <= SIZE_MAX / 2 ) ? realloc(buf, 2 * bsiz) : NULL;
if (!newbuf) {
/* out of memory */
zfree(buf, bsiz);
@@ -5263,7 +5293,7 @@ static int
execarith(Estate state, UNUSED(int do_exec))
{
char *e;
- mnumber val = zero_mnumber;
+ mnumber val;
int htok = 0;
if (isset(XTRACE)) {
@@ -5755,16 +5785,17 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
prog->flags |= EF_RUN;
freeeprog(shf->funcdef);
- if (prog->flags & EF_MAP)
- shf->funcdef = prog;
- else
+ if (prog->flags & EF_HEAP)
shf->funcdef = dupeprog(prog, 0);
+ else
+ shf->funcdef = prog;
shf->node.flags &= ~PM_UNDEFINED;
loadautofnsetfile(shf, fdir);
} else {
VARARR(char, n, strlen(shf->node.nam) + 1);
strcpy(n, shf->node.nam);
execode(prog, 1, 0, "evalautofunc");
+ freeeprog(prog);
shf = (Shfunc) shfunctab->getnode(shfunctab, n);
if (!shf || (shf->node.flags & PM_UNDEFINED)) {
/* We're not actually in the function; decrement locallevel */
@@ -5779,8 +5810,10 @@ loadautofn(Shfunc shf, int fksh, int autol, int current_fpath)
freeeprog(shf->funcdef);
if (prog->flags & EF_MAP)
shf->funcdef = stripkshdef(prog, shf->node.nam);
- else
+ else {
shf->funcdef = dupeprog(stripkshdef(prog, shf->node.nam), 0);
+ freeeprog(prog);
+ }
shf->node.flags &= ~PM_UNDEFINED;
loadautofnsetfile(shf, fdir);
}
@@ -5919,6 +5952,7 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
Shfunc shcopy = (Shfunc)zhalloc(sizeof(struct shfunc));
memcpy(shcopy, shfunc, sizeof(struct shfunc));
shcopy->node.nam = dupstring(shfunc->node.nam);
+ shcopy->filename = dupstring(shfunc->filename);
shfunc = shcopy;
name = shfunc->node.nam;
}
@@ -6114,9 +6148,8 @@ doshfunc(Shfunc shfunc, LinkList doshargs, int noreturnval)
/* take care of SUNKEYBOARDHACK but not of EMACS/VI */
if (funcsave->opts[SUNKEYBOARDHACK] != opts[SUNKEYBOARDHACK])
keyboardhackchar = funcsave->opts[SUNKEYBOARDHACK] ? '`' : '\0';
- /* restore all shell options except PRIVILEGED and RESTRICTED */
+ /* restore all shell options except PRIVILEGED */
funcsave->opts[PRIVILEGED] = opts[PRIVILEGED];
- funcsave->opts[RESTRICTED] = opts[RESTRICTED];
memcpy(opts, funcsave->opts, sizeof(opts));
emulation = funcsave->emulation;
if (init_typtab)
@@ -6247,29 +6280,34 @@ runshfunc(Eprog prog, FuncWrap wrap, char *name)
Eprog
getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only)
{
- char **pp, buf[PATH_MAX+1];
+ char **pp, buf[PATH_MAX];
off_t len;
off_t rlen;
char *d;
Eprog r;
int fd;
+ char *su = unmeta(s);
+ if (su != s) su = dupstring(su);
pp = alt_path ? alt_path : fpath;
+ char *ppu = "";
for (; *pp; pp++) {
if (**pp) {
- if (snprintf(buf, PATH_MAX, "%s/%s", *pp, s) >= PATH_MAX)
+ ppu = unmeta(*pp);
+ if (ppu != *pp) ppu = dupstring(ppu);
+ if (snprintf(buf, PATH_MAX, "%s/%s", ppu, su) >= PATH_MAX)
continue;
- } else if (strlen(s) >= PATH_MAX) {
+ } else if (strlen(su) >= PATH_MAX) {
continue;
} else {
- strcpy(buf, s);
+ strcpy(buf, su);
+ ppu = "";
}
- if ((r = try_dump_file(*pp, s, buf, ksh, test_only))) {
+ if ((r = try_dump_file(ppu, s, buf, ksh, test_only))) {
if (fdir)
- *fdir = *pp;
+ *fdir = ppu;
return r;
}
- unmetafy(buf, NULL);
if (!access(buf, R_OK) && (fd = open(buf, O_RDONLY | O_NOCTTY)) != -1) {
struct stat st;
if (!fstat(fd, &st) && S_ISREG(st.st_mode) &&
@@ -6277,7 +6315,7 @@ getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only)
if (test_only) {
close(fd);
if (fdir)
- *fdir = *pp;
+ *fdir = ppu;
return &dummy_eprog;
}
d = (char *) zalloc(len + 1);
@@ -6294,7 +6332,7 @@ getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only)
scriptname = oldscriptname;
if (fdir)
- *fdir = *pp;
+ *fdir = ppu;
zfree(d, len + 1);
@@ -6403,7 +6441,7 @@ cancd(char *s)
char *t;
if (*s != '/') {
- char sbuf[PATH_MAX+1], **cp;
+ char sbuf[MAXCMDLEN], **cp;
if (cancd2(s))
return s;
@@ -6412,9 +6450,9 @@ cancd(char *s)
if (!nocdpath)
for (cp = cdpath; *cp; cp++) {
if (**cp) {
- if (snprintf(sbuf, PATH_MAX, "%s/%s", *cp, s) >= PATH_MAX)
+ if (snprintf(sbuf, sizeof(sbuf), "%s/%s", *cp, s) >= sizeof(sbuf))
continue;
- } else if (strlen(s) >= PATH_MAX) {
+ } else if (ztrlen(s) >= PATH_MAX) {
continue;
} else {
strcpy(sbuf, s);
diff --git a/Src/glob.c b/Src/glob.c
index e13481955..0b516d226 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -849,7 +849,6 @@ qgetmodespec(char **s)
if ((c = *p) == '=' || c == Equals || c == '+' || c == '-' ||
c == '?' || c == Quest || (c >= '0' && c <= '7')) {
end = 0;
- c = 0;
} else {
end = (c == '<' ? '>' :
(c == '[' ? ']' :
@@ -1756,10 +1755,13 @@ zglob(LinkList list, LinkNode np, int nountok)
break;
}
default:
- untokenize(--s);
- zerr("unknown file attribute: %c", *s);
- restore_globstate(saved);
- return;
+ {
+ untokenize(--s);
+ convchar_t attr = unmeta_one(s, NULL);
+ zerr("unknown file attribute: %c", attr);
+ restore_globstate(saved);
+ return;
+ }
}
}
if (func) {
@@ -1931,6 +1933,7 @@ zglob(LinkList list, LinkNode np, int nountok)
/* Parsed OK, execute for each name */
for (tmpptr = matchbuf; tmpptr < matchptr; tmpptr++) {
+ unsetparam("REPLY");
setsparam("REPLY", ztrdup(tmpptr->name));
execode(prog, 1, 0, "globsort");
if (!errflag)
@@ -2324,12 +2327,8 @@ xpandbraces(LinkList list, LinkNode *np)
do {
char *ncptr;
int nclen;
-#ifdef MULTIBYTE_SUPPORT
- mb_charinit();
- ncptr = wcs_nicechar(cend, NULL, NULL);
-#else
- ncptr = nicechar(cend);
-#endif
+ MB_CHARINIT();
+ ncptr = MB_NICECHAR(cend);
nclen = strlen(ncptr);
p = zhalloc(lenalloc + nclen);
memcpy(p, str3, strp);
@@ -2488,7 +2487,7 @@ xpandbraces(LinkList list, LinkNode *np)
cnt++;
else if (*str == Outbrace)
cnt--;
- DPUTS(!*str, "BUG: illegal brace expansion");
+ DPUTS(!*str, "BUG: invalid brace expansion");
}
/* Concatenate the string before the braces (str3), the section *
* just found (str4) and the text after the braces (str2) */
@@ -3021,6 +3020,9 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
imd.repllist = (fl & SUB_LIST) ? znewlinklist() : newlinklist();
if (repllistp)
*repllistp = imd.repllist;
+ else {
+ DPUTS((fl & SUB_LIST), "leaking a linklist");
+ }
}
ioff = 0; /* offset into string */
umlen = umltot;
@@ -3348,13 +3350,23 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
/* Largest possible match at tail of string: *
* move forward along string until we get a match. *
* Again there's no optimisation. */
- for (ioff = 0, t = s, umlen = uml; t <= send;
- ioff++, t++, umlen--) {
+ for (ioff = 0, t = s, umlen = uml; t <= send; ioff++) {
set_pat_start(p, t-s);
if (pattrylen(p, t, send - t, umlen, &patstralloc, ioff)) {
*sp = get_match_ret(&imd, t-s, uml);
return 1;
}
+ if (fl & SUB_START)
+ break;
+ if (t == send)
+ break;
+ t++;
+ umlen--;
+ }
+ if (!(fl & SUB_START) && pattrylen(p, send, 0, 0,
+ &patstralloc, ioff)) {
+ *sp = get_match_ret(&imd, uml, uml);
+ return 1;
}
break;
@@ -3913,6 +3925,7 @@ qualsheval(char *name, UNUSED(struct stat *buf), UNUSED(off_t days), char *str)
int cshglob = badcshglob;
unsetparam("reply");
+ unsetparam("REPLY");
setsparam("REPLY", ztrdup(name));
badcshglob = 0;
diff --git a/Src/hist.c b/Src/hist.c
index ce5f7c20e..de21a4ff6 100644
--- a/Src/hist.c
+++ b/Src/hist.c
@@ -410,7 +410,7 @@ iaddtoline(int c)
excs = zlemetacs;
}
exlast = inbufct;
- zleentry(ZLE_CMD_ADD_TO_LINE, itok(c) ? ztokens[c - Pound] : c);
+ zleentry(ZLE_CMD_ADD_TO_LINE, c);
}
@@ -946,7 +946,7 @@ histsubchar(int c)
break;
default:
herrflush();
- zerr("illegal modifier: %c", c);
+ zerr("invalid modifier: %c", c);
return -1;
}
} else {
diff --git a/Src/init.c b/Src/init.c
index 20b8cc7fd..f36bc332b 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -35,6 +35,14 @@
#include "init.pro"
#include "version.h"
+#ifdef CUSTOM_PATCHLEVEL
+#define ZSH_PATCHLEVEL CUSTOM_PATCHLEVEL
+#else
+#include "patchlevel.h"
+#ifndef ZSH_PATCHLEVEL
+#define ZSH_PATCHLEVEL "unknown"
+#endif
+#endif
#if defined(HAVE_SYS_SYSCTL_H) && !defined(__linux)
#include <sys/sysctl.h>
@@ -127,7 +135,7 @@ loop(int toplevel, int justonce)
if (isset(SHINSTDIN)) {
setblock_stdin();
if (interact && toplevel) {
- int hstop = stophist;
+ int hstop = stophist, q;
stophist = 3;
/*
* Reset all errors including the interrupt error status
@@ -136,6 +144,9 @@ loop(int toplevel, int justonce)
* precaution to ensure we get back to the command line
* no matter what.
*/
+ q = queue_signal_level();
+ dont_queue_signals();
+ restore_queue_signals(q);
errflag = 0;
preprompt();
if (stophist != 3)
@@ -179,7 +190,7 @@ loop(int toplevel, int justonce)
non_empty = 1;
if (toplevel &&
(getshfunc("preexec") ||
- paramtab->getnode(paramtab, "preexec" HOOK_SUFFIX))) {
+ realparamtab->getnode2(realparamtab, "preexec" HOOK_SUFFIX))) {
LinkList args;
char *cmdstr;
@@ -255,8 +266,6 @@ loop(int toplevel, int justonce)
return LOOP_OK;
}
-static int restricted;
-
/* original argv[0]. This is already metafied */
static char *argv0;
@@ -434,8 +443,15 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp,
/* GNU-style long options */
++*argv;
if (!strcmp(*argv, "version")) {
- printf("zsh %s (%s-%s-%s)\n",
- ZSH_VERSION, MACHTYPE, VENDOR, OSTYPE);
+ // omit patchlevel for a tagged release, which looks like:
+ // zsh-x.y.z-0-gabcdef
+ static const char *pfx = "zsh-" ZSH_VERSION "-0-";
+ if (strncmp(ZSH_PATCHLEVEL, pfx, strlen(pfx)))
+ printf("zsh %s [%s] (%s-%s-%s)\n",
+ ZSH_VERSION, ZSH_PATCHLEVEL, MACHTYPE, VENDOR, OSTYPE);
+ else
+ printf("zsh %s (%s-%s-%s)\n",
+ ZSH_VERSION, MACHTYPE, VENDOR, OSTYPE);
LAST_OPTION(0);
}
if (!strcmp(*argv, "help")) {
@@ -494,8 +510,6 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp,
if (!(optno = optlookup(*argv))) {
WARN_OPTION("no such option: %s", *argv);
return 1;
- } else if (optno == RESTRICTED && toplevel) {
- restricted = action;
} else if ((optno == EMACSMODE || optno == VIMODE) && !toplevel) {
WARN_OPTION("can't change option: %s", *argv);
} else {
@@ -524,8 +538,6 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp,
if (!(optno = optlookupc(**argv))) {
WARN_OPTION("bad option: -%c", **argv);
return 1;
- } else if (optno == RESTRICTED && toplevel) {
- restricted = action;
} else if ((optno == EMACSMODE || optno == VIMODE) &&
!toplevel) {
WARN_OPTION("can't change option: %s", *argv);
@@ -551,10 +563,8 @@ parseopts(char *nam, char ***argvp, char *new_opts, char **cmdp,
}
doneargv:
*argvp = argv;
- if (emulate_required) {
+ if (emulate_required)
parseopts_setemulate(top_emulation, flags);
- emulate_required = 0;
- }
return 0;
}
@@ -1278,6 +1288,23 @@ setupvals(char *cmd, char *runscript, char *zsh_name)
condtab = NULL;
wrappers = NULL;
+ zterm_columns_preserve = zterm_lines_preserve = 0;
+
+ // preserve COLUMNS and LINES from environment when non-interactive
+ if (!isset(INTERACTIVE)) {
+ char *e, *p;
+ zlong v;
+
+ if ((e = zgetenv("COLUMNS")) && (v = zstrtol(e, &p, 10)) > 0 && !*p) {
+ zterm_columns = v;
+ zterm_columns_preserve = 1;
+ }
+ if ((e = zgetenv("LINES")) && (v = zstrtol(e, &p, 10)) > 0 && !*p) {
+ zterm_lines = v;
+ zterm_lines_preserve = 1;
+ }
+ }
+
#ifdef TIOCGWINSZ
adjustwinsize(0);
#else
@@ -1529,12 +1556,10 @@ run_init_scripts(void)
void
init_misc(char *cmd, char *zsh_name)
{
-#ifndef RESTRICTED_R
- if ( restricted )
-#else
- if (*zsh_name == 'r' || restricted)
-#endif
- dosetopt(RESTRICTED, 1, 0, opts);
+ if (*zsh_name == 'r') {
+ zerrnam(zsh_name, "no support for restricted mode");
+ exit(1);
+ }
if (cmd) {
if (SHIN >= 10)
close(SHIN);
diff --git a/Src/jobs.c b/Src/jobs.c
index 4905ae925..657d62ea0 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -324,7 +324,10 @@ handle_sub(int job, int fg)
deletejob(jn, 1);
}
}
- curjob = jn - jobtab;
+ if (fg)
+ /* don't change curjob if we got here from a signal handler, the superjob
+ * might not be the current job at all then */
+ curjob = jn - jobtab;
} else if (sj->stat & STAT_STOPPED) {
struct process *p;
@@ -523,6 +526,10 @@ update_job(Job jn)
* fg/bg is the superjob) a SIGCONT if we need it.
*/
sjn->stat |= STAT_CHANGED | STAT_STOPPED;
+ if (!(sjn->stat & STAT_DONE)) {
+ prevjob = curjob;
+ curjob = i;
+ }
if (isset(NOTIFY) && (sjn->stat & STAT_LOCKED) &&
!(sjn->stat & STAT_NOPRINT)) {
/*
@@ -701,13 +708,15 @@ setprevjob(void)
for (i = maxjob; i; i--)
if ((jobtab[i].stat & STAT_INUSE) && (jobtab[i].stat & STAT_STOPPED) &&
- !(jobtab[i].stat & STAT_SUBJOB) && i != curjob && i != thisjob) {
+ !(jobtab[i].stat & (STAT_SUBJOB | STAT_NOPRINT)) &&
+ i != curjob && i != thisjob) {
prevjob = i;
return;
}
for (i = maxjob; i; i--)
- if ((jobtab[i].stat & STAT_INUSE) && !(jobtab[i].stat & STAT_SUBJOB) &&
+ if ((jobtab[i].stat & STAT_INUSE) &&
+ !(jobtab[i].stat & (STAT_SUBJOB | STAT_NOPRINT)) &&
i != curjob && i != thisjob) {
prevjob = i;
return;
@@ -1896,21 +1905,19 @@ spawnjob(void)
Process pn;
DPUTS(thisjob == -1, "No valid job in spawnjob.");
- /* if we are not in a subshell */
- if (!subsh) {
- if (curjob == -1 || !(jobtab[curjob].stat & STAT_STOPPED)) {
- curjob = thisjob;
- setprevjob();
- } else if (prevjob == -1 || !(jobtab[prevjob].stat & STAT_STOPPED))
- prevjob = thisjob;
- if (jobbing && jobtab[thisjob].procs) {
- FILE *fout = shout ? shout : stdout;
- fprintf(fout, "[%d]", thisjob);
- for (pn = jobtab[thisjob].procs; pn; pn = pn->next)
- fprintf(fout, " %ld", (long) pn->pid);
- fprintf(fout, "\n");
- fflush(fout);
- }
+ if (curjob == -1 || !(jobtab[curjob].stat & STAT_STOPPED)) {
+ curjob = thisjob;
+ setprevjob();
+ } else if (prevjob == -1 || !(jobtab[prevjob].stat & STAT_STOPPED))
+ prevjob = thisjob;
+
+ if (!subsh && jobbing && jobtab[thisjob].procs) {
+ FILE *fout = shout ? shout : stdout;
+ fprintf(fout, "[%d]", thisjob);
+ for (pn = jobtab[thisjob].procs; pn; pn = pn->next)
+ fprintf(fout, " %ld", (long) pn->pid);
+ fprintf(fout, "\n");
+ fflush(fout);
}
if (!hasprocs(thisjob))
deletejob(jobtab + thisjob, 0);
@@ -2075,7 +2082,7 @@ getjob(const char *s, const char *prog)
if (*s == '%' || *s == '+' || !*s) {
if (curjob == -1) {
if (prog && !isset(POSIXBUILTINS))
- zwarnnam(prog, "no current job");
+ zwarnnam(prog, "%%%c: no such job", *s ? *s : '%');
returnval = -1;
goto done;
}
@@ -2086,7 +2093,7 @@ getjob(const char *s, const char *prog)
if (*s == '-') {
if (prevjob == -1) {
if (prog && !isset(POSIXBUILTINS))
- zwarnnam(prog, "no previous job");
+ zwarnnam(prog, "%%-: no such job");
returnval = -1;
goto done;
}
@@ -2421,14 +2428,16 @@ int
bin_fg(char *name, char **argv, Options ops, int func)
{
int job, lng, firstjob = -1, retval = 0, ofunc = func;
+ int disown_all = (func == BIN_DISOWN && OPT_ISSET(ops, 'a'));
+
+ if (disown_all && *argv) {
+ zwarnnam(name, "argument not meaningful with -a: %s", *argv);
+ return 1;
+ }
if (OPT_ISSET(ops,'Z')) {
int len;
- if(isset(RESTRICTED)) {
- zwarnnam(name, "-Z is restricted");
- return 1;
- }
if(!argv[0] || argv[1]) {
zwarnnam(name, "-Z requires one argument");
return 1;
@@ -2464,7 +2473,7 @@ bin_fg(char *name, char **argv, Options ops, int func)
if ((func == BIN_FG || func == BIN_BG) && !jobbing) {
/* oops... maybe bg and fg should have been disabled? */
- zwarnnam(name, "no job control in this shell.");
+ zwarnnam(name, "no job control in this shell");
return 1;
}
@@ -2489,10 +2498,12 @@ bin_fg(char *name, char **argv, Options ops, int func)
* will prevent zexit from complaining about stopped jobs */
stopmsg = 2;
if (!*argv) {
+ if (disown_all) {
+ firstjob = 0;
/* This block handles all of the default cases (no arguments). bg,
fg and disown act on the current job, and jobs and wait act on all the
jobs. */
- if (func == BIN_FG || func == BIN_BG || func == BIN_DISOWN) {
+ } else if (func == BIN_FG || func == BIN_BG || func == BIN_DISOWN) {
/* W.r.t. the above comment, we'd better have a current job at this
point or else. */
if (curjob == -1 || (jobtab[curjob].stat & STAT_NOPRINT)) {
@@ -2580,7 +2591,7 @@ bin_fg(char *name, char **argv, Options ops, int func)
}
/* The only type of argument allowed now is a job spec. Check it. */
job = (*argv) ? getjob(*argv, name) : firstjob;
- firstjob = -1;
+ firstjob = (disown_all && job <= maxjob) ? job + 1 : -1;
if (job == -1) {
retval = 127;
break;
@@ -2588,6 +2599,8 @@ bin_fg(char *name, char **argv, Options ops, int func)
jstat = oldjobtab ? oldjobtab[job].stat : jobtab[job].stat;
if (!(jstat & STAT_INUSE) ||
(jstat & STAT_NOPRINT)) {
+ if (disown_all)
+ continue;
if (!isset(POSIXBUILTINS))
zwarnnam(name, "%s: no such job", *argv);
unqueue_signals();
@@ -2634,12 +2647,20 @@ bin_fg(char *name, char **argv, Options ops, int func)
}
/* It's time to shuffle the jobs around! Reset the current job,
and pick a sensible secondary job. */
- if (curjob == job) {
+ if (func != BIN_BG && curjob == job) {
curjob = prevjob;
- prevjob = (func == BIN_BG) ? -1 : job;
+ prevjob = job;
}
- if (prevjob == job || prevjob == -1)
+ if (prevjob == job) {
+ int saved_thisjob = thisjob;
+ if (func != BIN_BG && curjob != -1)
+ /* Exclude this job from setprevjob() consideration. */
+ thisjob = job;
+ setprevjob();
+ thisjob = saved_thisjob;
+ } else if (prevjob == -1) {
setprevjob();
+ }
if (curjob == -1) {
curjob = prevjob;
setprevjob();
@@ -2840,8 +2861,9 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
}
}
#if defined(SIGRTMIN) && defined(SIGRTMAX)
- if (sig > SIGCOUNT && (sig = rtsigno(signame))) {
- printf("%d\n", sig);
+ int rtsig;
+ if (sig > SIGCOUNT && (rtsig = rtsigno(signame))) {
+ printf("%d\n", rtsig);
} else
#endif
if (sig > SIGCOUNT) {
@@ -2852,6 +2874,7 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
printf("%d\n", sig);
} else {
if (*signame) {
+ signame = casemodify(*argv, CASMOD_UPPER);
zwarnnam(nam, "unknown signal: SIG%s",
signame);
returnval++;
@@ -3013,7 +3036,7 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
killjb(jobtab + p, SIGCONT);
}
} else if (!isanum(*argv)) {
- zwarnnam("kill", "illegal pid: %s", *argv);
+ zwarnnam("kill", "invalid pid: %s", *argv);
returnval++;
} else {
int pid = atoi(*argv);
diff --git a/Src/lex.c b/Src/lex.c
index efbb62b66..35f1e8dc2 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -1198,7 +1198,7 @@ gettokstr(int c, int sub)
break;
}
hungetc(e);
- if(isnumglob()) {
+ if (!in_brace_param && isnumglob()) {
add(Inang);
while ((c = hgetc()) != '>')
add(c);
diff --git a/Src/loop.c b/Src/loop.c
index db78f00c7..351edde89 100644
--- a/Src/loop.c
+++ b/Src/loop.c
@@ -377,13 +377,13 @@ selectlist(LinkList l, size_t start)
do {
#ifdef MB_METASTRWIDTH
size_t t2 = MB_METASTRWIDTH(*ap) + 2;
- (void) unmetafy(*ap, NULL);
#else
size_t t2 = strlen(*ap) + 2;
#endif
- int t3;
+ int t3 = ap - arr + 1;
- fprintf(stderr, "%d) %s", t3 = ap - arr + 1, *ap);
+ fprintf(stderr, "%d) ", t3);
+ zputs(*ap, stderr);
while (t3)
t2++, t3 /= 10;
for (; t2 < fw; t2++)
diff --git a/Src/math.c b/Src/math.c
index d97dae238..517c18118 100644
--- a/Src/math.c
+++ b/Src/math.c
@@ -1100,8 +1100,10 @@ callmathfunc(char *o)
break;
}
}
- if (*a && !errflag)
- zerr("bad math expression: illegal character: %c", *a);
+ if (*a && !errflag) {
+ convchar_t wa = unmeta_one(a, NULL);
+ zerr("bad math expression: invalid character: %c", wa);
+ }
if (!errflag) {
if (argc >= f->minargs && (f->maxargs < 0 ||
argc <= f->maxargs)) {
@@ -1493,10 +1495,14 @@ matheval(char *s)
x.u.l = 0;
return x;
}
+ zsh_eval_context_push("math");
x = mathevall(s, MPREC_TOP, &junk);
+ zsh_eval_context_pop();
mtok = xmtok;
- if (*junk)
- zerr("bad math expression: illegal character: %c", *junk);
+ if (*junk) {
+ convchar_t j = unmeta_one(junk, NULL);
+ zerr("bad math expression: invalid character: %c", j);
+ }
return x;
}
@@ -1531,7 +1537,9 @@ mathevalarg(char *s, char **ss)
zerr("bad math expression: empty string");
return (zlong)0;
}
+ zsh_eval_context_push("math");
x = mathevall(s, MPREC_ARG, ss);
+ zsh_eval_context_pop();
if (mtok == COMMA)
(*ss)--;
mtok = xmtok;
diff --git a/Src/mkmakemod.sh b/Src/mkmakemod.sh
index 3ccf9c5e5..5e5adc070 100644
--- a/Src/mkmakemod.sh
+++ b/Src/mkmakemod.sh
@@ -28,6 +28,7 @@
# headers extra headers for this module (default none)
# hdrdeps extra headers on which the .mdh depends (default none)
# otherincs extra headers that are included indirectly (default none)
+# libs extra libraries to link this module against (default none)
#
# The .mdd file may also include a Makefile.in fragment between lines
# `:<<\Make' and `Make' -- this will be copied into Makemod.in.
@@ -186,7 +187,7 @@ if $first_stage; then
unset name moddeps nozshdep alwayslink hasexport
unset autofeatures autofeatures_emu
- unset objects proto headers hdrdeps otherincs
+ unset objects proto headers hdrdeps otherincs libs
. $top_srcdir/$the_subdir/${mddname}.mdd
q_name=`echo $name | sed 's,Q,Qq,g;s,_,Qu,g;s,/,Qs,g'`
test -n "${moddeps+set}" || moddeps=
@@ -324,7 +325,7 @@ if $first_stage; then
echo
echo "${mddname}.\$(DL_EXT): \$(MODDOBJS_${mddname}) ${mddname}.export $exportdeps \$(@LINKMODS@_${mddname})"
echo ' rm -f $@'
- echo " \$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(MODDOBJS_${mddname}) \$(@LINKMODS@_${mddname}) \$(LIBS) "
+ echo " \$(DLLINK) \$(@E@XPIMP_$mddname) \$(@E@NTRYOPT) \$(MODDOBJS_${mddname}) \$(@LINKMODS@_${mddname}) \$(LIBS) ${libs} "
echo
fi
echo "${mddname}.mdhi: ${mddname}.mdhs \$(INCS_${mddname})"
diff --git a/Src/module.c b/Src/module.c
index 659bc3544..9577cc278 100644
--- a/Src/module.c
+++ b/Src/module.c
@@ -426,14 +426,13 @@ static int
add_autobin(const char *module, const char *bnam, int flags)
{
Builtin bn;
- int ret;
bn = zshcalloc(sizeof(*bn));
bn->node.nam = ztrdup(bnam);
bn->optstr = ztrdup(module);
if (flags & FEAT_AUTOALL)
bn->node.flags |= BINF_AUTOALL;
- if ((ret = addbuiltin(bn))) {
+ if (addbuiltin(bn)) {
builtintab->freenode(&bn->node);
if (!(flags & FEAT_IGNORE))
return 1;
@@ -1027,7 +1026,7 @@ checkaddparam(const char *nam, int opt_i)
{
Param pm;
- if (!(pm = (Param) gethashnode2(paramtab, nam)))
+ if (!(pm = (Param) realparamtab->getnode2(realparamtab, nam)))
return 0;
if (pm->level || !(pm->node.flags & PM_AUTOLOAD)) {
@@ -1071,7 +1070,7 @@ addparamdef(Paramdef d)
return 1;
}
else if (!(pm = createparam(d->name, d->flags)) &&
- !(pm = (Param) paramtab->getnode(paramtab, d->name)))
+ !(pm = (Param) realparamtab->getnode2(realparamtab, d->name)))
return 1;
d->pm = pm;
@@ -1085,6 +1084,9 @@ addparamdef(Paramdef d)
*/
switch (PM_TYPE(pm->node.flags)) {
case PM_SCALAR:
+ if (pm->node.flags & PM_TIED)
+ pm->ename = ztrdup(casemodify(pm->node.nam, CASMOD_LOWER));
+ /* fall-through */
case PM_NAMEREF:
pm->gsu.s = d->gsu ? (GsuScalar)d->gsu : &varscalar_gsu;
break;
@@ -1099,6 +1101,8 @@ addparamdef(Paramdef d)
break;
case PM_ARRAY:
+ if (pm->node.flags & PM_TIED)
+ pm->ename = ztrdup(casemodify(pm->node.nam, CASMOD_UPPER));
pm->gsu.a = d->gsu ? (GsuArray)d->gsu : &vararray_gsu;
break;
@@ -1123,7 +1127,7 @@ addparamdef(Paramdef d)
int
deleteparamdef(Paramdef d)
{
- Param pm = (Param) paramtab->getnode(paramtab, d->name);
+ Param pm = (Param) realparamtab->getnode2(realparamtab, d->name);
if (!pm)
return 1;
@@ -1142,10 +1146,10 @@ deleteparamdef(Paramdef d)
if (!searchpm)
return 1;
- paramtab->removenode(paramtab, pm->node.nam);
+ realparamtab->removenode(realparamtab, pm->node.nam);
prevpm->old = searchpm->old;
searchpm->old = pm;
- paramtab->addnode(paramtab, searchpm->node.nam, searchpm);
+ realparamtab->addnode(realparamtab, searchpm->node.nam, searchpm);
pm = searchpm;
}
@@ -1234,7 +1238,7 @@ add_autoparam(const char *module, const char *pnam, int flags)
static int
del_autoparam(UNUSED(const char *modnam), const char *pnam, int flags)
{
- Param pm = (Param) gethashnode2(paramtab, pnam);
+ Param pm = (Param) realparamtab->getnode2(realparamtab, pnam);
if (!pm) {
if (!(flags & FEAT_IGNORE))
@@ -2457,7 +2461,7 @@ bin_zmodload(char *nam, char **args, Options ops, UNUSED(int func))
if (OPT_ISSET(ops,'A') || OPT_ISSET(ops,'R')) {
if (ops_bcpf || ops_au || OPT_ISSET(ops,'d') ||
(OPT_ISSET(ops,'R') && OPT_ISSET(ops,'e'))) {
- zwarnnam(nam, "illegal flags combined with -A or -R");
+ zwarnnam(nam, "invalid flags combined with -A or -R");
return 1;
}
if (!OPT_ISSET(ops,'e'))
@@ -2755,7 +2759,7 @@ bin_zmodload_auto(char *nam, char **args, Options ops)
} else if (OPT_ISSET(ops,'p')) {
if (!*args) {
/* list autoloaded parameters */
- scanhashtable(paramtab, 1, 0, 0, printautoparams,
+ scanhashtable(realparamtab, 1, 0, 0, printautoparams,
OPT_ISSET(ops,'L'));
return 0;
}
@@ -3523,7 +3527,7 @@ autofeatures(const char *cmdnam, const char *module, char **features,
}
if (strchr(fnam, '/')) {
- zwarnnam(cmdnam, "%s: `/' is illegal in a %s", fnam, typnam);
+ zwarnnam(cmdnam, "%s: `/' is invalid in a %s", fnam, typnam);
ret = 1;
continue;
}
diff --git a/Src/options.c b/Src/options.c
index 8b13f0c5d..9bf56cf81 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -240,7 +240,6 @@ static struct optname optns[] = {
{{NULL, "rcs", OPT_ALL}, RCS},
{{NULL, "recexact", 0}, RECEXACT},
{{NULL, "rematchpcre", 0}, REMATCHPCRE},
-{{NULL, "restricted", OPT_SPECIAL}, RESTRICTED},
{{NULL, "rmstarsilent", OPT_BOURNE}, RMSTARSILENT},
{{NULL, "rmstarwait", 0}, RMSTARWAIT},
{{NULL, "sharehistory", OPT_KSH}, SHAREHISTORY},
@@ -357,7 +356,7 @@ static short zshletters[LAST_OPT - FIRST_OPT + 1] = {
/* o */ 0, /* long option name follows */
/* p */ PRIVILEGED,
/* q */ 0,
- /* r */ RESTRICTED,
+ /* r */ 0, /* formerly RESTRICTED */
/* s */ SHINSTDIN,
/* t */ SINGLECOMMAND,
/* u */ -UNSET,
@@ -434,7 +433,7 @@ static short kshletters[LAST_OPT - FIRST_OPT + 1] = {
/* o */ 0,
/* p */ PRIVILEGED,
/* q */ 0,
- /* r */ RESTRICTED,
+ /* r */ 0,
/* s */ SHINSTDIN,
/* t */ SINGLECOMMAND,
/* u */ -UNSET,
@@ -592,24 +591,26 @@ bin_setopt(char *nam, char **args, UNUSED(Options ops), int isun)
/* loop through command line options (begins with "-" or "+") */
while (*args && (**args == '-' || **args == '+')) {
action = (**args == '-') ^ isun;
- if(!args[0][1])
+ if (!args[0][1])
*args = "--";
- while (*++*args) {
- if(**args == Meta)
- *++*args ^= 32;
+ ++*args;
+ while (**args) {
+ int sz;
+ convchar_t arg = unmeta_one(*args, &sz);
+ *args += sz;
/* The pseudo-option `--' signifies the end of options. */
- if (**args == '-') {
+ if (arg == '-') {
args++;
goto doneoptions;
- } else if (**args == 'o') {
- if (!*++*args)
+ } else if (arg == 'o') {
+ if (!**args)
args++;
if (!*args) {
zwarnnam(nam, "string expected after -o");
inittyptab();
return 1;
}
- if(!(optno = optlookup(*args))) {
+ if (!(optno = optlookup(*args))) {
zwarnnam(nam, "no such option: %s", *args);
retval |= 1;
} else if (dosetopt(optno, action, 0, opts)) {
@@ -617,14 +618,14 @@ bin_setopt(char *nam, char **args, UNUSED(Options ops), int isun)
retval |= 1;
}
break;
- } else if(**args == 'm') {
+ } else if (arg == 'm') {
match = 1;
} else {
- if (!(optno = optlookupc(**args))) {
- zwarnnam(nam, "bad option: -%c", **args);
+ if (!(optno = optlookupc(arg))) {
+ zwarnnam(nam, "bad option: -%c", arg);
retval |= 1;
} else if (dosetopt(optno, action, 0, opts)) {
- zwarnnam(nam, "can't change option: -%c", **args);
+ zwarnnam(nam, "can't change option: -%c", arg);
retval |= 1;
}
}
@@ -719,7 +720,7 @@ optlookup(char const *name)
/**/
int
-optlookupc(char c)
+optlookupc(convchar_t c)
{
if(c < FIRST_OPT || c > LAST_OPT)
return 0;
@@ -727,25 +728,6 @@ optlookupc(char c)
return optletters[c - FIRST_OPT];
}
-/**/
-static void
-restrictparam(char *nam)
-{
- Param pm = (Param) paramtab->getnode(paramtab, nam);
-
- if (pm) {
- pm->node.flags |= PM_SPECIAL | PM_RESTRICTED;
- return;
- }
- createparam(nam, PM_SCALAR | PM_UNSET | PM_SPECIAL | PM_RESTRICTED);
-}
-
-/* list of restricted parameters which are not otherwise special */
-static char *rparams[] = {
- "SHELL", "HISTFILE", "LD_LIBRARY_PATH", "LD_AOUT_LIBRARY_PATH",
- "LD_PRELOAD", "LD_AOUT_PRELOAD", NULL
-};
-
/* Set or unset an option, as a result of user request. The option *
* number may be negative, indicating that the sense is reversed *
* from the usual meaning of the option. */
@@ -760,16 +742,7 @@ dosetopt(int optno, int value, int force, char *new_opts)
optno = -optno;
value = !value;
}
- if (optno == RESTRICTED) {
- if (isset(RESTRICTED))
- return value ? 0 : -1;
- if (value) {
- char **s;
-
- for (s = rparams; *s; s++)
- restrictparam(*s);
- }
- } else if(!force && optno == EXECOPT && !value && interact) {
+ if (!force && optno == EXECOPT && !value && interact) {
/* cannot set noexec when interactive */
return -1;
} else if(!force && (optno == INTERACTIVE || optno == SHINSTDIN ||
diff --git a/Src/params.c b/Src/params.c
index 001d89788..e111b28c7 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -107,6 +107,11 @@ mod_export zlong
ppid, /* $PPID */
zsh_subshell; /* $ZSH_SUBSHELL */
+// whether COLUMNS and LINES should be preserved because they were imported from
+// the environment into a non-interactive shell
+/**/
+mod_export int zterm_columns_preserve, zterm_lines_preserve;
+
/* $FUNCNEST */
/**/
mod_export
@@ -224,6 +229,8 @@ static const struct gsu_integer ttyidle_gsu =
static const struct gsu_scalar argzero_gsu =
{ argzerogetfn, argzerosetfn, nullunsetfn };
+static const struct gsu_scalar argn_gsu =
+{ argngetfn, argnsetfn, argnunsetfn };
static const struct gsu_scalar username_gsu =
{ usernamegetfn, usernamesetfn, stdunsetfn };
static const struct gsu_scalar dash_gsu =
@@ -296,18 +303,18 @@ static initparam special_params[] ={
#define IPDEF1(A,B,C) {{NULL,A,PM_INTEGER|PM_SPECIAL|C},BR(NULL),GSU(B),10,0,NULL,NULL,NULL,0}
IPDEF1("#", pound_gsu, PM_READONLY_SPECIAL),
IPDEF1("ERRNO", errno_gsu, PM_UNSET),
-IPDEF1("GID", gid_gsu, PM_DONTIMPORT | PM_RESTRICTED),
-IPDEF1("EGID", egid_gsu, PM_DONTIMPORT | PM_RESTRICTED),
-IPDEF1("HISTSIZE", histsize_gsu, PM_RESTRICTED),
+IPDEF1("GID", gid_gsu, PM_DONTIMPORT),
+IPDEF1("EGID", egid_gsu, PM_DONTIMPORT),
+IPDEF1("HISTSIZE", histsize_gsu, 0),
IPDEF1("RANDOM", random_gsu, 0),
-IPDEF1("SAVEHIST", savehist_gsu, PM_RESTRICTED),
+IPDEF1("SAVEHIST", savehist_gsu, 0),
IPDEF1("SECONDS", intseconds_gsu, 0),
-IPDEF1("UID", uid_gsu, PM_DONTIMPORT | PM_RESTRICTED),
-IPDEF1("EUID", euid_gsu, PM_DONTIMPORT | PM_RESTRICTED),
+IPDEF1("UID", uid_gsu, PM_DONTIMPORT),
+IPDEF1("EUID", euid_gsu, PM_DONTIMPORT),
IPDEF1("TTYIDLE", ttyidle_gsu, PM_READONLY_SPECIAL),
#define IPDEF2(A,B,C) {{NULL,A,PM_SCALAR|PM_SPECIAL|C},BR(NULL),GSU(B),0,0,NULL,NULL,NULL,0}
-IPDEF2("USERNAME", username_gsu, PM_DONTIMPORT|PM_RESTRICTED),
+IPDEF2("USERNAME", username_gsu, PM_DONTIMPORT),
IPDEF2("-", dash_gsu, PM_READONLY_SPECIAL),
IPDEF2("histchars", histchars_gsu, PM_DONTIMPORT),
IPDEF2("HOME", home_gsu, PM_UNSET),
@@ -315,7 +322,7 @@ IPDEF2("TERM", term_gsu, PM_UNSET),
IPDEF2("TERMINFO", terminfo_gsu, PM_UNSET),
IPDEF2("TERMINFO_DIRS", terminfodirs_gsu, PM_UNSET),
IPDEF2("WORDCHARS", wordchars_gsu, 0),
-IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT | PM_RESTRICTED),
+IPDEF2("IFS", ifs_gsu, PM_DONTIMPORT),
IPDEF2("_", underscore_gsu, PM_DONTIMPORT),
IPDEF2("KEYBOARD_HACK", keyboard_hack_gsu, PM_DONTIMPORT),
IPDEF2("0", argzero_gsu, 0),
@@ -396,12 +403,12 @@ IPDEF8("CDPATH", &cdpath, "cdpath", PM_TIED),
IPDEF8("FIGNORE", &fignore, "fignore", PM_TIED),
IPDEF8("FPATH", &fpath, "fpath", PM_TIED),
IPDEF8("MAILPATH", &mailpath, "mailpath", PM_TIED),
-IPDEF8("PATH", &path, "path", PM_RESTRICTED|PM_TIED),
+IPDEF8("PATH", &path, "path", PM_TIED),
IPDEF8("PSVAR", &psvar, "psvar", PM_TIED),
IPDEF8("ZSH_EVAL_CONTEXT", &zsh_eval_context, "zsh_eval_context", PM_READONLY_SPECIAL|PM_TIED),
/* MODULE_PATH is not imported for security reasons */
-IPDEF8("MODULE_PATH", &module_path, "module_path", PM_DONTIMPORT|PM_RESTRICTED|PM_TIED),
+IPDEF8("MODULE_PATH", &module_path, "module_path", PM_DONTIMPORT|PM_TIED),
#define IPDEF10(A,B) {{NULL,A,PM_ARRAY|PM_SPECIAL},BR(NULL),GSU(B),10,0,NULL,NULL,NULL,0}
@@ -430,8 +437,8 @@ IPDEF9("psvar", &psvar, "PSVAR", PM_TIED),
IPDEF9("zsh_eval_context", &zsh_eval_context, "ZSH_EVAL_CONTEXT", PM_TIED|PM_READONLY_SPECIAL),
-IPDEF9("module_path", &module_path, "MODULE_PATH", PM_TIED|PM_RESTRICTED),
-IPDEF9("path", &path, "PATH", PM_TIED|PM_RESTRICTED),
+IPDEF9("module_path", &module_path, "MODULE_PATH", PM_TIED),
+IPDEF9("path", &path, "PATH", PM_TIED),
/* These are known to zsh alone. */
@@ -449,12 +456,12 @@ IPDEF8("CDPATH", &cdpath, NULL, 0),
IPDEF8("FIGNORE", &fignore, NULL, 0),
IPDEF8("FPATH", &fpath, NULL, 0),
IPDEF8("MAILPATH", &mailpath, NULL, 0),
-IPDEF8("PATH", &path, NULL, PM_RESTRICTED),
+IPDEF8("PATH", &path, NULL, 0),
IPDEF8("PSVAR", &psvar, NULL, 0),
IPDEF8("ZSH_EVAL_CONTEXT", &zsh_eval_context, NULL, PM_READONLY_SPECIAL),
/* MODULE_PATH is not imported for security reasons */
-IPDEF8("MODULE_PATH", &module_path, NULL, PM_DONTIMPORT|PM_RESTRICTED),
+IPDEF8("MODULE_PATH", &module_path, NULL, PM_DONTIMPORT),
{{NULL,NULL,0},BR(NULL),NULL_GSU,0,0,NULL,NULL,NULL,0},
};
@@ -484,6 +491,8 @@ static initparam argvparam_pm = IPDEF9("", &pparams, NULL, \
(zsfree((PM)->u.str), (PM)->u.str = (S)))
static Param argvparam;
+static Param *argnparams;
+static size_t argnparams_size;
/*
* Lists of references to nested variables ("Param" instances) indexed
@@ -499,6 +508,16 @@ static Param argvparam;
* times in the same list. Non of that is harmful as long as only
* instances that are still references referring to the ending scope
* are updated when the scope ends.
+ *
+ * The list corresponding to the global scope never receives any of
+ * the named references described above. Instead, it's used to track
+ * global parameters that were unset via a named reference while in a
+ * scope where they were hidden by a nested parameter with the same
+ * name. In such cases, the global parameter's Param instance can't be
+ * deleted as usual. Instead, it's marked as unset and added to the
+ * global scope's list. Each time a scope ends, the list is traversed
+ * and parameters that are still unset but no longer hidden are
+ * deleted.
*/
static LinkList *scoperefs = NULL;
static int scoperefs_num = 0;
@@ -846,6 +865,9 @@ createparamtable(void)
}
argvparam = (Param) &argvparam_pm;
+ argnparams = zshcalloc(8 * sizeof(Param));
+ argnparams_size = 8;
+ argnparams[0] = (Param) paramtab->getnode(paramtab, "0");
noerrs = 2;
@@ -935,7 +957,7 @@ createparamtable(void)
* For native emulation we always set the variable home
* (see setupvals()).
*/
- pm = (Param) paramtab->getnode(paramtab, "HOME");
+ pm = (Param) realparamtab->getnode2(realparamtab, "HOME");
if (EMULATION(EMULATE_ZSH))
{
pm->node.flags &= ~PM_UNSET;
@@ -943,10 +965,10 @@ createparamtable(void)
addenv(pm, home);
} else if (!home)
pm->node.flags |= PM_UNSET;
- pm = (Param) paramtab->getnode(paramtab, "LOGNAME");
+ pm = (Param) realparamtab->getnode2(realparamtab, "LOGNAME");
if (!(pm->node.flags & PM_EXPORTED))
addenv(pm, pm->u.str);
- pm = (Param) paramtab->getnode(paramtab, "SHLVL");
+ pm = (Param) realparamtab->getnode2(realparamtab, "SHLVL");
sprintf(buf, "%d", (int)++shlvl);
/* shlvl value in environment needs updating unconditionally */
addenv(pm, buf);
@@ -1110,10 +1132,6 @@ createparam(char *name, int flags)
zerr("read-only variable: %s", name);
return NULL;
}
- if ((oldpm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerr("%s: restricted", name);
- return NULL;
- }
if (!(oldpm->node.flags & PM_UNSET) ||
(oldpm->node.flags & PM_SPECIAL) ||
/* POSIXBUILTINS horror: we need to retain 'export' flags */
@@ -1135,7 +1153,6 @@ createparam(char *name, int flags)
pm = oldpm;
pm->base = pm->width = 0;
- oldpm = pm->old;
} else {
pm = (Param) zshcalloc(sizeof *pm);
if ((pm->old = oldpm)) {
@@ -1604,15 +1621,15 @@ getarg(char **str, int *inv, Value v, int a2, zlong *w,
}
if (word && !v->scanflags) {
s = t = getstrvalue(v);
+ if (!s || !*s)
+ return 0;
+
i = wordcount(s, sep, 0);
if (r < 0)
r += i + 1;
- if (r < 1)
- r = 1;
- if (r > i)
- r = i;
- if (!s || !*s)
+ if (r < 1 || r > i)
return 0;
+
while ((d = findword(&s, sep)) && --r);
if (!d)
return 0;
@@ -2230,7 +2247,6 @@ fetchvalue(Value v, char **pptr, int bracks, int scanflags)
} else {
Param pm;
int isvarat;
- int isrefslice = 0;
isvarat = (t[0] == '@' && !t[1]);
if (scanflags & SCANPM_NONAMEREF)
@@ -2248,32 +2264,6 @@ fetchvalue(Value v, char **pptr, int bracks, int scanflags)
if (!pm || ((pm->node.flags & PM_UNSET) &&
!(pm->node.flags & PM_DECLARED)))
return NULL;
- if ((pm->node.flags & PM_NAMEREF) && !(scanflags & SCANPM_NONAMEREF)) {
- char *refname = GETREFNAME(pm);
- if (refname && *refname) {
- /* only happens for namerefs pointing to array elements */
- char *ref = dupstring(refname);
- char *ss = pm->width ? ref + pm->width : NULL;
- if (ss) {
- sav = *ss;
- *ss = 0;
- }
- Param p1 = (Param)gethashnode2(paramtab, ref);
- if (p1)
- pm = loadparamnode(paramtab, upscope(p1, pm), ref);
- if (!(p1 && pm) ||
- ((pm->node.flags & PM_UNSET) &&
- !(pm->node.flags & PM_DECLARED)))
- return NULL;
- if (ss) {
- scanflags |= SCANPM_NOEXEC;
- *ss = sav;
- s = dyncat(ss,*pptr);
- isrefslice = 1;
- } else
- s = *pptr;
- }
- }
if (!v)
v = (Value) zhalloc(sizeof *v);
memset(v, 0, sizeof(*v));
@@ -2287,8 +2277,6 @@ fetchvalue(Value v, char **pptr, int bracks, int scanflags)
v->scanflags = SCANPM_ARRONLY;
}
v->pm = pm;
- if (isrefslice)
- v->valflags = VALFLAG_REFSLICE;
v->end = -1;
if (bracks > 0 && (*s == '[' || *s == Inbrack)) {
if (getindex(&s, v, scanflags)) {
@@ -2702,11 +2690,6 @@ assignstrvalue(Value v, char *val, int flags)
zsfree(val);
return;
}
- if ((v->pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerr("%s: restricted", v->pm->node.nam);
- zsfree(val);
- return;
- }
if ((v->pm->node.flags & PM_HASHED) &&
(v->scanflags & (SCANPM_MATCHMANY|SCANPM_ARRONLY))) {
zerr("%s: attempt to set slice of associative array", v->pm->node.nam);
@@ -2728,31 +2711,30 @@ assignstrvalue(Value v, char *val, int flags)
!v->pm->width)
v->pm->width = strlen(val);
} else {
- char *z, *x;
- int zlen, vlen, newsize;
-
- z = v->pm->gsu.s->getfn(v->pm);
- zlen = strlen(z);
+ char *const old = v->pm->gsu.s->getfn(v->pm);
+ char *new;
+ const int oldlen = strlen(old), vallen = strlen(val);
+ int newlen;
if ((v->valflags & VALFLAG_INV) && unset(KSHARRAYS))
v->start--, v->end--;
if (v->start < 0) {
- v->start += zlen;
+ v->start += oldlen;
if (v->start < 0)
v->start = 0;
}
- if (v->start > zlen)
- v->start = zlen;
+ if (v->start > oldlen)
+ v->start = oldlen;
if (v->end < 0) {
- v->end += zlen;
+ v->end += oldlen;
if (v->end < 0) {
v->end = 0;
- } else if (v->end >= zlen) {
- v->end = zlen;
+ } else if (v->end >= oldlen) {
+ v->end = oldlen;
} else {
#ifdef MULTIBYTE_SUPPORT
if (isset(MULTIBYTE)) {
- v->end += MB_METACHARLEN(z + v->end);
+ v->end += MB_METACHARLEN(old + v->end);
} else {
v->end++;
}
@@ -2761,36 +2743,35 @@ assignstrvalue(Value v, char *val, int flags)
#endif
}
}
- else if (v->end > zlen)
- v->end = zlen;
+ if (v->end < v->start)
+ v->end = v->start;
+ else if (v->end > oldlen)
+ v->end = oldlen;
- vlen = strlen(val);
- /* Characters preceding start index +
- characters of what is assigned +
- characters following end index */
- newsize = v->start + vlen + (zlen - v->end);
+ /* Chars before slice + chars from val + chars after slice */
+ newlen = v->start + vallen + (oldlen - v->end);
- /* Does new size differ? */
- if (newsize != zlen || v->pm->gsu.s->setfn != strsetfn) {
- x = (char *) zalloc(newsize + 1);
- strncpy(x, z, v->start);
- strcpy(x + v->start, val);
- strcat(x + v->start, z + v->end);
- v->pm->gsu.s->setfn(v->pm, x);
- } else {
- Param pm = v->pm;
- /* Size doesn't change, can limit actions to only
- * overwriting bytes in already allocated string */
- memcpy(z + v->start, val, vlen);
- /* Implement remainder of strsetfn */
- if (!(pm->node.flags & PM_HASHELEM) &&
- ((pm->node.flags & PM_NAMEDDIR) ||
- isset(AUTONAMEDIRS))) {
- pm->node.flags |= PM_NAMEDDIR;
- adduserdir(pm->node.nam, z, 0, 0);
- }
- }
- zsfree(val);
+ if (v->pm->gsu.s->setfn == strsetfn && old == v->pm->u.str) {
+ v->pm->u.str = NULL; /* Steal the old string */
+ /* If the string shrinks, move left chars after the slice */
+ if (newlen < oldlen && v->end < oldlen)
+ memmove(old + v->start + vallen, old + v->end,
+ oldlen - v->end);
+ /* If the string shrinks or expands, reallocate it */
+ new = oldlen == newlen ? old : (char *) zrealloc(old, newlen + 1);
+ /* If the string expands, move right chars after the slice */
+ if (newlen > oldlen && v->end < oldlen)
+ memmove(new + v->start + vallen, new + v->end,
+ oldlen - v->end);
+ } else {
+ new = (char *) zalloc(newlen + 1);
+ strncpy(new, old, v->start);
+ strncpy(new + v->start + vallen, old + v->end, oldlen - v->end);
+ }
+ strncpy(new + v->start, val, vallen);
+ zsfree(val);
+ new[newlen] = '\0';
+ v->pm->gsu.s->setfn(v->pm, new);
}
break;
case PM_INTEGER:
@@ -2872,10 +2853,6 @@ setnumvalue(Value v, mnumber val)
zerr("read-only variable: %s", v->pm->node.nam);
return;
}
- if ((v->pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerr("%s: restricted", v->pm->node.nam);
- return;
- }
switch (PM_TYPE(v->pm->node.flags)) {
case PM_SCALAR:
case PM_NAMEREF:
@@ -2914,11 +2891,6 @@ setarrvalue(Value v, char **val)
freearray(val);
return;
}
- if ((v->pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerr("%s: restricted", v->pm->node.nam);
- freearray(val);
- return;
- }
if (!(PM_TYPE(v->pm->node.flags) & (PM_ARRAY|PM_HASHED))) {
freearray(val);
zerr("%s: attempt to assign array value to non-array",
@@ -2946,13 +2918,9 @@ setarrvalue(Value v, char **val)
return;
} else {
char **const old = v->pm->gsu.a->getfn(v->pm);
- char **new;
- char **p, **q, **r; /* index variables */
- const int pre_assignment_length = arrlen(old);
- int post_assignment_length;
- int i;
-
- q = old;
+ char **new, **p, **q;
+ const int oldlen = arrlen(old), vallen = arrlen(val);
+ int newlen, i;
if ((v->valflags & VALFLAG_INV) && unset(KSHARRAYS)) {
if (v->start > 0)
@@ -2960,98 +2928,55 @@ setarrvalue(Value v, char **val)
v->end--;
}
if (v->start < 0) {
- v->start += pre_assignment_length;
+ v->start += oldlen;
if (v->start < 0)
v->start = 0;
}
if (v->end < 0) {
- v->end += pre_assignment_length + 1;
+ v->end += oldlen + 1;
if (v->end < 0)
v->end = 0;
}
- if (v->end < v->start)
+ if (v->end < v->start || v->start > oldlen)
v->end = v->start;
+ else if (v->end > oldlen)
+ v->end = oldlen;
- post_assignment_length = v->start + arrlen(val);
- if (v->end < pre_assignment_length) {
- /*
- * Allocate room for array elements between the end of the slice `v'
- * and the original array's end.
- */
- post_assignment_length += pre_assignment_length - v->end;
- }
+ /* Strings before slice + strings from val + strings after slice */
+ newlen = v->start + vallen + MAX(0, oldlen - v->end);
- if (pre_assignment_length == post_assignment_length
- && v->pm->gsu.a->setfn == arrsetfn
- /* ... and isn't something that arrsetfn() treats specially */
- && 0 == (v->pm->node.flags & (PM_SPECIAL|PM_UNIQUE))
- && NULL == v->pm->ename)
- {
- /* v->start is 0-based */
- p = old + v->start;
- for (r = val; *r;) {
- /* Free previous string */
- zsfree(*p);
- /* Give away ownership of the string */
- *p++ = *r++;
- }
+ if (v->pm->gsu.a->setfn == arrsetfn && old == v->pm->u.arr) {
+ v->pm->u.arr = NULL; /* Steal the old array */
+ /* Free strings that are part of the slice */
+ for (q = old + v->start, i = v->end - v->start; i > 0; i--)
+ zsfree(*q++);
+ /* If the array shrinks, move left strings after the slice */
+ if (newlen < oldlen && v->end < oldlen)
+ memmove(old + v->start + vallen, old + v->end,
+ sizeof(char *) * (oldlen - v->end));
+ /* If the array shrinks or expands, reallocate it */
+ new = oldlen == newlen ? old :
+ (char **) zrealloc(old, sizeof(char *) * (newlen + 1));
+ /* If the array expands, move right strings after the slice */
+ if (newlen > oldlen && v->end < oldlen)
+ memmove(new + v->start + vallen, new + v->end,
+ sizeof(char *) * (oldlen - v->end));
} else {
- /* arr+=( ... )
- * arr[${#arr}+x,...]=( ... ) */
- if (post_assignment_length > pre_assignment_length &&
- pre_assignment_length <= v->start &&
- pre_assignment_length > 0 &&
- v->pm->gsu.a->setfn == arrsetfn)
- {
- p = new = (char **) zrealloc(old, sizeof(char *)
- * (post_assignment_length + 1));
-
- p += pre_assignment_length; /* after old elements */
-
- /* Consider 1 < 0, case for a=( 1 ); a[1,..] =
- * 1 < 1, case for a=( 1 ); a[2,..] = */
- if (pre_assignment_length < v->start) {
- for (i = pre_assignment_length; i < v->start; i++) {
- *p++ = ztrdup("");
- }
- }
-
- for (r = val; *r;) {
- /* Give away ownership of the string */
- *p++ = *r++;
- }
-
- /* v->end doesn't matter:
- * a=( 1 2 ); a[4,100]=( a b ); echo "${(q@)a}"
- * 1 2 '' a b */
- *p = NULL;
-
- v->pm->u.arr = NULL;
- v->pm->gsu.a->setfn(v->pm, new);
- } else {
- p = new = (char **) zalloc(sizeof(char *)
- * (post_assignment_length + 1));
- for (i = 0; i < v->start; i++)
- *p++ = i < pre_assignment_length ? ztrdup(*q++) : ztrdup("");
- for (r = val; *r;) {
- /* Give away ownership of the string */
- *p++ = *r++;
- }
- if (v->end < pre_assignment_length)
- for (q = old + v->end; *q;)
- *p++ = ztrdup(*q++);
- *p = NULL;
-
- v->pm->gsu.a->setfn(v->pm, new);
- }
-
- DPUTS2(p - new != post_assignment_length, "setarrvalue: wrong allocation: %d 1= %lu",
- post_assignment_length, (unsigned long)(p - new));
+ new = (char **) zalloc(sizeof(char *) * (newlen + 1));
+ for (p = new, q = old, i = MIN(v->start, oldlen); i > 0; i--)
+ *p++ = ztrdup(*q++);
+ if (v->end < oldlen)
+ for (p = new + v->start + vallen, q = old + v->end; *q;)
+ *p++ = ztrdup(*q++);
}
-
- /* Ownership of all strings has been
- * given away, can plainly free */
+ /* Copy and give away ownership of the strings from val */
+ memcpy(new + v->start, val, sizeof(char *) * vallen);
free(val);
+ /* Fill any gap between the old array end and the slice start */
+ for (p = new + oldlen, i = v->start - oldlen; i > 0; i--)
+ *p++ = ztrdup("");
+ new[newlen] = NULL;
+ v->pm->gsu.a->setfn(v->pm, new);
}
}
@@ -3252,7 +3177,6 @@ assignsparam(char *s, char *val, int flags)
createparam(t, PM_SCALAR);
created = 1;
} else if ((((v->pm->node.flags & PM_ARRAY) &&
- !(v->valflags & VALFLAG_REFSLICE) &&
!(flags & ASSPM_AUGMENT)) ||
(v->pm->node.flags & PM_HASHED)) &&
!(v->pm->node.flags & (PM_SPECIAL|PM_TIED)) &&
@@ -3275,7 +3199,7 @@ assignsparam(char *s, char *val, int flags)
}
if (*val && (v->pm->node.flags & PM_NAMEREF)) {
if (!valid_refname(val, v->pm->node.flags)) {
- zerr("invalid name reference: %s", val);
+ zerr("invalid variable name: %s", val);
zsfree(val);
unqueue_signals();
errflag |= ERRFLAG_ERROR;
@@ -3415,7 +3339,6 @@ assignaparam(char *s, char **val, int flags)
unqueue_signals();
return NULL;
} else if (!(PM_TYPE(v->pm->node.flags) & (PM_ARRAY|PM_HASHED)) &&
- !(v->valflags & VALFLAG_REFSLICE) &&
!(v->pm->node.flags & (PM_SPECIAL|PM_TIED))) {
int uniq = v->pm->node.flags & PM_UNIQUE;
if ((flags & ASSPM_AUGMENT) && !(v->pm->node.flags & PM_UNSET)) {
@@ -3642,8 +3565,7 @@ sethparam(char *s, char **val)
if (!(v = fetchvalue(&vbuf, &s, 1, SCANPM_ASSIGNING))) {
createparam(t, PM_HASHED);
checkcreate = 1;
- } else if (!(PM_TYPE(v->pm->node.flags) & PM_HASHED) &&
- !(v->valflags & VALFLAG_REFSLICE)) {
+ } else if (!(PM_TYPE(v->pm->node.flags) & PM_HASHED)) {
if (!(v->pm->node.flags & PM_SPECIAL)) {
if (resetparam(v->pm, PM_HASHED)) {
unqueue_signals();
@@ -3867,10 +3789,6 @@ unsetparam_pm(Param pm, int altflag, int exp)
pm->node.nam);
return 1;
}
- if ((pm->node.flags & PM_RESTRICTED) && isset(RESTRICTED)) {
- zerr("%s: restricted", pm->node.nam);
- return 1;
- }
if (pm->ename && !altflag)
altremove = ztrdup(pm->ename);
@@ -3934,17 +3852,30 @@ unsetparam_pm(Param pm, int altflag, int exp)
(pm->node.flags & (PM_SPECIAL|PM_REMOVABLE)) == PM_SPECIAL)
return 0;
+ /*
+ * Global variables can only be deleted if they aren't hidden by a
+ * local one with the same name.
+ */
+ if (!pm->level &&
+ pm != (Param) (paramtab == realparamtab ?
+ /* getnode2() to avoid autoloading */
+ paramtab->getnode2(paramtab, pm->node.nam) :
+ paramtab->getnode(paramtab, pm->node.nam))) {
+ LinkList refs;
+ if (!scoperefs)
+ scoperefs = zshcalloc((scoperefs_num = 8) * sizeof(refs));
+ if (!scoperefs[0])
+ scoperefs[0] = znewlinklist();
+ zpushnode(scoperefs[0], pm);
+ return 0;
+ }
+
/* remove parameter node from table */
paramtab->removenode(paramtab, pm->node.nam);
if (pm->old) {
oldpm = pm->old;
paramtab->addnode(paramtab, oldpm->node.nam, oldpm);
- if ((PM_TYPE(oldpm->node.flags) == PM_SCALAR) &&
- !(pm->node.flags & PM_HASHELEM) &&
- (oldpm->node.flags & PM_NAMEDDIR) &&
- oldpm->gsu.s == &stdscalar_gsu)
- adduserdir(oldpm->node.nam, oldpm->u.str, 0, 0);
if (oldpm->node.flags & PM_EXPORTED) {
/*
* Re-export the old value which we removed in typeset_single().
@@ -4044,7 +3975,7 @@ floatsetfn(Param pm, double x)
pm->u.dval = x;
}
-/* Function to get value of a scalar (string) parameter */
+/* Function to get value of a scalar (string) or nameref parameter */
/**/
mod_export char *
@@ -4053,21 +3984,22 @@ strgetfn(Param pm)
return pm->u.str ? pm->u.str : (char *) hcalloc(1);
}
-/* Function to set value of a scalar (string) parameter */
+/* Function to set value of a scalar (string) or nameref parameter */
/**/
mod_export void
strsetfn(Param pm, char *x)
{
- zsfree(pm->u.str);
- pm->u.str = x;
- if (!(pm->node.flags & PM_HASHELEM) &&
+ if (pm->u.str != x) {
+ if (pm->u.str) zsfree(pm->u.str);
+ pm->u.str = x;
+ }
+ if (!(pm->node.flags & PM_HASHELEM) && !pm->level &&
+ (PM_TYPE(pm->node.flags) == PM_SCALAR) &&
((pm->node.flags & PM_NAMEDDIR) || isset(AUTONAMEDIRS))) {
pm->node.flags |= PM_NAMEDDIR;
adduserdir(pm->node.nam, x, 0, 0);
}
- /* If you update this function, you may need to update the
- * `Implement remainder of strsetfn' block in assignstrvalue(). */
}
/* Function to get value of an array parameter */
@@ -4087,16 +4019,15 @@ arrgetfn(Param pm)
mod_export void
arrsetfn(Param pm, char **x)
{
- if (pm->u.arr && pm->u.arr != x)
- freearray(pm->u.arr);
+ if (pm->u.arr != x) {
+ if (pm->u.arr) freearray(pm->u.arr);
+ pm->u.arr = x;
+ }
if (pm->node.flags & PM_UNIQUE)
uniqarray(x);
- pm->u.arr = x;
/* Arrays tied to colon-arrays may need to fix the environment */
if (pm->ename && x)
arrfixenv(pm->ename, x);
- /* If you extend this function, update the list of conditions in
- * setarrvalue(). */
}
/* Function to get value of an association parameter */
@@ -4980,6 +4911,49 @@ argzerogetfn(UNUSED(Param pm))
return argzero;
}
+/* Function to get value for positional parameters */
+
+/**/
+static char *
+argngetfn(Param pm)
+{
+ return arrlen_gt(pparams, pm->u.val - 1) ?
+ pparams[pm->u.val - 1] : (char *) hcalloc(1);
+}
+
+/* Function to set value for positional parameters */
+
+/**/
+static void
+argnsetfn(Param pm, char *x)
+{
+ int len = arrlen(pparams);
+ int ppar = pm->u.val;
+ if (ppar <= len)
+ zsfree(pparams[ppar - 1]);
+ else if (x) {
+ int i;
+ pparams = (char **) zrealloc(pparams, sizeof(char *) * ppar + 1);
+ for (i = len; i < ppar - 1; i++)
+ pparams[i] = ztrdup("");
+ pparams[ppar] = 0;
+ }
+ if (x) {
+ pparams[ppar - 1] = ztrdup(x);
+ zsfree(x);
+ } else if (ppar <= len)
+ memmove(pparams + ppar - 1, pparams + ppar, (len - ppar + 1) * sizeof(char *));
+}
+
+/* Function to unset positional parameters */
+
+/**/
+static void
+argnunsetfn(Param pm, UNUSED(int exp))
+{
+ argnsetfn(pm, NULL);
+}
+
/* Function to get value for special parameter `HISTSIZE' */
/**/
@@ -5914,6 +5888,15 @@ endparamscope(void)
setscope(pm);
}
}
+ /* Delete unset global variables that were hidden at unset time */
+ if ((refs = scoperefs ? scoperefs[0] : NULL)) {
+ scoperefs[0] = NULL;
+ for (Param pm; refs && (pm = (Param)getlinknode(refs));) {
+ if ((pm->node.flags & PM_UNSET) && !(pm->node.flags & PM_DECLARED))
+ unsetparam_pm(pm, 1, 0);
+ }
+ freelinklist(refs, NULL);
+ }
unqueue_signals();
}
@@ -6356,22 +6339,29 @@ resolve_nameref_rec(Param pm, const Param stop, int keep_lastref)
Param ref = pm;
char *refname;
if (!pm || !(pm->node.flags & PM_NAMEREF) || (pm->node.flags & PM_UNSET)
- /* pm->width is the offset of any subscript */
- /* If present, it has to be the end of any chain, see fetchvalue() */
- || pm->width || !(refname = GETREFNAME(pm)) || !*refname)
+ || !(refname = GETREFNAME(pm)) || !*refname)
return pm;
- if (pm->node.flags & PM_TAGGED) {
- zerr("%s: invalid self reference", pm->node.nam);
- return NULL;
- }
queue_signals();
if ((pm = (Param)gethashnode2(realparamtab, refname))) {
if ((pm = loadparamnode(paramtab, upscope(pm, ref), refname)) &&
- pm != stop && !(pm->node.flags & PM_UNSET)) {
- /* user can't tag a nameref, safe for loop detection */
- ref->node.flags |= PM_TAGGED;
+ pm != stop && !(pm->node.flags & PM_UNSET))
pm = resolve_nameref_rec(pm, stop, keep_lastref);
- ref->node.flags &= ~PM_TAGGED;
+ } else if (idigit(*refname)) {
+ int ppar = zstrtol(refname, NULL, 10);
+ if (ppar >= argnparams_size) {
+ size_t old_size = argnparams_size;
+ size_t new_size = argnparams_size = MAX(2 * old_size, ppar);
+ argnparams = zrealloc(argnparams, new_size * sizeof(Param));
+ memset(argnparams + old_size, 0,
+ (new_size - old_size) * sizeof(Param));
+ }
+ if (!(pm = argnparams[ppar])) {
+ pm = argnparams[ppar] = zshcalloc(sizeof(*pm));
+ pm->node.nam = zalloc(snprintf(NULL, 0, "%d", ppar) + 1);
+ sprintf(pm->node.nam, "%d", ppar);
+ pm->node.flags = PM_SCALAR | PM_SPECIAL;
+ pm->u.val = ppar;
+ pm->gsu.s = &argn_gsu;
}
} else if (keep_lastref)
pm = ref;
@@ -6391,7 +6381,11 @@ setloopvar(char *name, char *value)
zerr("read-only reference: %s", pm->node.nam);
return;
}
- pm->base = pm->width = 0;
+ if (!valid_refname(value, pm->node.flags)) {
+ zerr("invalid variable name: %s", value);
+ return;
+ }
+ pm->base = 0;
SETREFNAME(pm, ztrdup(value));
pm->node.flags &= ~PM_UNSET;
setscope(pm);
@@ -6407,21 +6401,8 @@ setscope(Param pm)
if (pm->node.flags & PM_NAMEREF) {
Param basepm = NULL;
char *refname = GETREFNAME(pm);
- char *t = refname ? itype_end(refname, INAMESPC, 0) : NULL;
int q = queue_signal_level();
- /* Compute pm->width */
- /* Temporarily change nameref to array parameter itself */
- if (t && *t == '[')
- *t = 0;
- else
- t = 0;
- if (t) {
- pm->width = t - refname;
- *t = '[';
- refname = dupstrpfx(refname, pm->width);
- }
-
/* Compute pm->base */
if (!(pm->node.flags & PM_UPPER) && refname &&
(basepm = (Param)gethashnode2(realparamtab, refname)) &&
@@ -6440,7 +6421,7 @@ setscope(Param pm)
}
/* Check for self references */
- if (refname && *refname && !pm->width && basepm != pm) {
+ if (refname && *refname && basepm != pm) {
dont_queue_signals(); /* Prevent unkillable loops */
basepm = resolve_nameref_rec(pm, pm, 0);
restore_queue_signals(q);
@@ -6487,47 +6468,14 @@ upscope(Param pm, const Param ref)
static int
valid_refname(char *val, int flags)
{
- char *t;
-
if (flags & PM_UPPER) {
/* Upward reference to positionals is doomed to fail */
- if (idigit(*val))
- return 0;
- t = itype_end(val, INAMESPC, 0);
- if ((t - val == 4) &&
- (!strncmp(val, "argv", 4) ||
- !strncmp(val, "ARGC", 4)))
- return 0;
- } else if (idigit(*val)) {
- t = val;
- while (*++t)
- if (!idigit(*t))
- break;
- if (*t && *t != '[') /* Need to test Inbrack here too? */
+ if (idigit(*val) || !strcmp(val, "argv") || !strcmp(val, "ARGC"))
return 0;
- } else
- t = itype_end(val, INAMESPC, 0);
-
- if (t == val) {
- if (!(*t == '!' || *t == '?' ||
- *t == '$' || *t == '-' ||
- *t == '_'))
- return 0;
- ++t;
- }
- if (*t == '[') {
- /* Another bit of isident() to emulate */
- tokenize(t = dupstring(t+1));
- while ((t = parse_subscript(t, 0, ']')) && *t++ == Outbrack) {
- if (*t == Inbrack)
- ++t;
- else
- break;
- }
- if (t && *t) {
- /* zwarn("%s: stuff after subscript: %s", val, t); */
- return 0;
- }
}
- return !!t;
+
+ if (*val == '!' || *val == '?' || *val == '$' || *val == '-')
+ return !*(++val);
+
+ return !*itype_end(val, INAMESPC, 0) && isident(val);
}
diff --git a/Src/parse.c b/Src/parse.c
index 2b7f8bb59..beb9be059 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -3187,7 +3187,7 @@ bin_zcompile(char *nam, char **args, Options ops, UNUSED(int func))
(OPT_ISSET(ops,'c') &&
(OPT_ISSET(ops,'U') || OPT_ISSET(ops,'k') || OPT_ISSET(ops,'z'))) ||
(!(OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a')) && OPT_ISSET(ops,'m'))) {
- zwarnnam(nam, "illegal combination of options");
+ zwarnnam(nam, "invalid combination of options");
return 1;
}
if ((OPT_ISSET(ops,'c') || OPT_ISSET(ops,'a')) && isset(KSHAUTOLOAD))
@@ -3350,7 +3350,7 @@ write_dump(int dfd, LinkList progs, int map, int hlen, int tlen)
fdmagic(pre) = (other ? FD_OMAGIC : FD_MAGIC);
fdsetflags(pre, ((map ? FDF_MAP : 0) | other));
fdsetother(pre, tlen);
- strcpy(fdversion(pre), ZSH_VERSION);
+ strncpy(fdversion(pre), ZSH_VERSION, sizeof(wordcode) * (FD_PRELEN - 2) - 1);
write_loop(dfd, (char *)pre, FD_PRELEN * sizeof(wordcode));
for (node = firstnode(progs); node; incnode(node)) {
@@ -3882,10 +3882,16 @@ check_dump_file(char *file, struct stat *sbuf, char *name, int *ksh,
#ifdef USE_MMAP
if (f) {
- Eprog prog = (Eprog) zalloc(sizeof(*prog));
+ Eprog prog;
Patprog *pp;
- int np;
+ size_t np;
+ if (h->npats > h->len / sizeof(wordcode)) {
+ zwarn("%s: invalid description: %s", file, name);
+ return NULL;
+ }
+
+ prog = (Eprog) zalloc(sizeof(*prog));
prog->flags = EF_MAP;
prog->len = h->len;
prog->npats = np = h->npats;
@@ -3917,7 +3923,15 @@ check_dump_file(char *file, struct stat *sbuf, char *name, int *ksh,
{
Eprog prog;
Patprog *pp;
- int np, fd, po = h->npats * sizeof(Patprog);
+ int fd;
+ size_t np, po;
+
+ if (h->npats > h->len / sizeof(wordcode)) {
+ zwarn("%s: invalid description: %s", file, name);
+ return NULL;
+ }
+
+ po = h->npats * sizeof(Patprog);
if ((fd = open(file, O_RDONLY)) < 0 ||
lseek(fd, ((h->start * sizeof(wordcode)) +
diff --git a/Src/pattern.c b/Src/pattern.c
index 1e0ae88d9..017c20a1e 100644
--- a/Src/pattern.c
+++ b/Src/pattern.c
@@ -1369,6 +1369,11 @@ patcomppiece(int *flagp, int paren)
}
}
slen = (patparse - str0) - nmeta;
+#ifdef MULTIBYTE_SUPPORT
+ if ((patglobflags & GF_MULTIBYTE) && slen > 1)
+ /* for multibyte single characters, treat x# as (x)# */
+ flags &= ~P_SIMPLE;
+#endif
/* First add length, which is a long */
patadd((char *)&slen, 0, sizeof(long), 0);
/*
@@ -3348,10 +3353,14 @@ patmatch(Upat prog)
return 0;
/* Yes, just position appropriately and test. */
patinput += ptlen - P_LS_LEN(next);
- /*
- * Here we will need to be careful that patinput is not
- * in the middle of a multibyte character.
- */
+#ifdef MULTIBYTE_SUPPORT
+ /* Make sure we aren't in the middle of
+ * a multibyte character */
+ if ((patglobflags & GF_MULTIBYTE) &&
+ ptlen < P_LS_LEN(next) &&
+ !charstart[patinput - start])
+ return 0;
+#endif
/* Continue loop with P_EXACTLY test. */
break;
}
diff --git a/Src/prompt.c b/Src/prompt.c
index 8325bfe2c..7db074da8 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1956,7 +1956,7 @@ truecolor_terminal(void)
mod_export zattr
match_colour(const char **teststrp, int is_fg, int colour)
{
- int shft, named = 0, tc;
+ int shft, tc;
zattr on;
if (is_fg) {
@@ -1997,7 +1997,7 @@ match_colour(const char **teststrp, int is_fg, int colour)
} else if (colour <= -2) {
return TXT_ERROR;
}
- } else if ((named = ialpha(**teststrp))) {
+ } else if (ialpha(**teststrp)) {
colour = match_named_colour(teststrp);
if (colour == 8) /* default */
return 0;
diff --git a/Src/signals.c b/Src/signals.c
index 2257f862f..ff9797f35 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -451,7 +451,7 @@ zhandler(int sig)
case SIGINT:
if (!handletrap(SIGINT)) {
- if ((isset(PRIVILEGED) || isset(RESTRICTED)) &&
+ if (isset(PRIVILEGED) &&
isset(INTERACTIVE) && (noerrexit & NOERREXIT_SIGNAL))
zexit(SIGINT, ZEXIT_SIGNAL);
errflag |= ERRFLAG_INT;
diff --git a/Src/sort.c b/Src/sort.c
index ce2b4bbc3..224741b00 100644
--- a/Src/sort.c
+++ b/Src/sort.c
@@ -255,7 +255,7 @@ strmetasort(char **array, int sortwhat, int *unmetalenp)
for (arrptr = array, sortptrarrptr = sortptrarr, sortarrptr = sortarr;
*arrptr; arrptr++, sortptrarrptr++, sortarrptr++) {
char *metaptr;
- int needlen, needalloc;
+ int needlen;
*sortptrarrptr = sortarrptr;
sortarrptr->orig = *arrptr;
@@ -286,8 +286,7 @@ strmetasort(char **array, int sortwhat, int *unmetalenp)
* Either we're going to need to copy it to transform it,
* or we need to unmetafy it.
*/
- if ((needalloc = (sortwhat &
- (SORTIT_IGNORING_CASE|SORTIT_IGNORING_BACKSLASHES)))
+ if ((sortwhat & (SORTIT_IGNORING_CASE|SORTIT_IGNORING_BACKSLASHES))
|| *metaptr == Meta) {
char *s, *t, *src = *arrptr, *dst;
int len;
diff --git a/Src/subst.c b/Src/subst.c
index 56c1ad6dd..eef713a8c 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -242,7 +242,7 @@ stringsubst(LinkList list, LinkNode node, int pf_flags, int *ret_flags,
char *str = str3, c;
while (!errflag && (c = *str)) {
- if (((c = *str) == Inang || c == OutangProc ||
+ if ((c == Inang || c == OutangProc ||
(str == str3 && c == Equals))
&& str[1] == Inpar) {
char *subst, *rest, *snew, *sptr;
@@ -1494,6 +1494,8 @@ substevalchar(char *ptr)
int saved_errflag = errflag;
errflag = 0;
+ ptr = dupstring(ptr);
+ untokenize(ptr);
ires = mathevali(ptr);
if (errflag) { /* not a valid numerical expression */
@@ -2348,7 +2350,6 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
postmul = untok_and_escape(s + arglen, escapes,
tok_arg);
*t = sav;
- sav = *s;
s = t + arglen;
/* again, continue only if another start delimiter */
if (memcmp(del0, s, dellen)) {
@@ -3301,13 +3302,35 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
Param pm = sethparam(idbeg, a);
if (pm)
aval = paramvalarr(pm->gsu.h->getfn(pm), hkeys|hvals);
- } else
- setaparam(idbeg, a);
+ } else {
+ Param pm = setaparam(idbeg, a);
+ if (pm) {
+ struct value vbuf = { 0 };
+ char *p = idbeg;
+ Value v = getvalue(&vbuf, &p, 1);
+ if (v) {
+ aval = getarrvalue(v);
+ }
+ }
+ }
isarr = 1;
arrasg = 0;
} else {
untokenize(val);
- setsparam(idbeg, ztrdup(val));
+ Param pm = setsparam(idbeg, ztrdup(val));
+ if (pm) {
+ /* this check isn't needed for correctness, but array values
+ * aren't affected by SUBST flags anyway */
+ if ((PM_TYPE(pm->node.flags) & (PM_HASHED|PM_ARRAY)) == 0) {
+ struct value vbuf = { 0 };
+ char *p = idbeg;
+ Value v = getvalue(&vbuf, &p, 1);
+ if (v) {
+ v->valflags = VALFLAG_SUBST;
+ val = ztrdup(getstrvalue(v));
+ }
+ }
+ }
}
*idend = sav;
copied = 1;
@@ -3381,7 +3404,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int pf_flags,
if (haserr)
shtokenize(s);
} else if (haserr || errflag) {
- zerr("parse error in ${...%c...} substitution", s[-1]);
+ zerr("parse error in ${...%c...} substitution", s[-1] == Pound ? '#' : s[-1]);
return NULL;
}
}
@@ -3844,7 +3867,7 @@ colonsubscript:
*/
if (getlen) {
long len = 0;
- char buf[14];
+ char buf[DIGBUFSIZE];
if (isarr) {
char **ctr;
@@ -4728,7 +4751,6 @@ modify(char **str, char **ptr, int inbrace)
*e = '\0';
if (c != 'l' && c != 'u')
copy = dupstring(tt);
- *e = tc;
switch (c) {
case 'a':
chabspath(&copy);
@@ -4795,6 +4817,7 @@ modify(char **str, char **ptr, int inbrace)
copy = xsymlink(copy, 1);
break;
}
+ *e = tc;
tc = *tt;
*tt = '\0';
nl = al + strlen(t) + strlen(copy);
diff --git a/Src/utils.c b/Src/utils.c
index a1d7c8cc2..1130415db 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -313,12 +313,12 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
switch (*fmt++) {
case 's':
str = va_arg(ap, const char *);
- nicezputs(str, file);
+ nicezputs(str ? str : "(null)", file);
break;
case 'l': {
str = va_arg(ap, const char *);
num = va_arg(ap, int);
- fwrite(str, num, 1, file);
+ fwrite(str ? str : "(null)", num, 1, file);
break;
}
case 'L':
@@ -342,12 +342,8 @@ zerrmsg(FILE *file, const char *fmt, va_list ap)
break;
case 'c':
num = va_arg(ap, int);
-#ifdef MULTIBYTE_SUPPORT
- mb_charinit();
- zputs(wcs_nicechar(num, NULL, NULL), file);
-#else
- zputs(nicechar(num), file);
-#endif
+ MB_CHARINIT();
+ zputs(MB_NICECHAR(num), file);
break;
case 'e':
/* print the corresponding message for this errno */
@@ -760,12 +756,13 @@ zwcwidth(wint_t wc)
char *
pathprog(char *prog, char **namep)
{
- char **pp, ppmaxlen = 0, *buf, *funmeta;
+ char **pp, *buf, *funmeta;
+ size_t ppmaxlen = 0;
struct stat st;
for (pp = path; *pp; pp++)
{
- int len = strlen(*pp);
+ size_t len = strlen(*pp);
if (len > ppmaxlen)
ppmaxlen = len;
}
@@ -1257,7 +1254,8 @@ getnameddir(char *name)
/* Check if there is a scalar parameter with this name whose value *
* begins with a `/'. If there is, add it to the hash table and *
* return the new value. */
- if ((pm = (Param) paramtab->getnode(paramtab, name)) &&
+ if ((pm = (Param) realparamtab->getnode2(realparamtab, name)) &&
+ !pm->level &&
(PM_TYPE(pm->node.flags) == PM_SCALAR) &&
(str = getsparam(name)) && *str == '/') {
pm->node.flags |= PM_NAMEDDIR;
@@ -1645,7 +1643,9 @@ checkmailpath(char **s)
char buf[PATH_MAX * 2 + 1], **arr, **ap;
int buflen, ct = 1;
- if (lock) {
+ if (!lock)
+ zerr("%e: %s", errno, *s);
+ else {
char *fn;
pushheap();
@@ -1833,7 +1833,7 @@ adjustlines(int signalled)
int oldlines = zterm_lines;
#ifdef TIOCGWINSZ
- if (signalled || zterm_lines <= 0)
+ if ((signalled && !zterm_lines_preserve) || zterm_lines <= 0)
zterm_lines = shttyinfo.winsize.ws_row;
else
shttyinfo.winsize.ws_row = zterm_lines;
@@ -1858,7 +1858,7 @@ adjustcolumns(int signalled)
int oldcolumns = zterm_columns;
#ifdef TIOCGWINSZ
- if (signalled || zterm_columns <= 0)
+ if ((signalled && !zterm_columns_preserve) || zterm_columns <= 0)
zterm_columns = shttyinfo.winsize.ws_col;
else
shttyinfo.winsize.ws_col = zterm_columns;
@@ -7429,8 +7429,7 @@ lchdir(char const *path, struct dirsav *d, int hard)
#endif
} else {
level = 0;
- if (!d->dev && !d->ino) {
- stat(".", &st1);
+ if (!d->dev && !d->ino && !stat(".", &st1)) {
d->dev = st1.st_dev;
d->ino = st1.st_ino;
}
diff --git a/Src/zsh.h b/Src/zsh.h
index dd58c0816..1f1ecc3e6 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -758,7 +758,6 @@ enum {
VALFLAG_INV = 0x0001, /* We are performing inverse subscripting */
VALFLAG_EMPTY = 0x0002, /* Subscripted range is empty */
VALFLAG_SUBST = 0x0004, /* Substitution, so apply padding, case flags */
- VALFLAG_REFSLICE= 0x0008 /* Value is a reference to an array slice */
};
#define MAX_ARRLEN 262144
@@ -1301,8 +1300,8 @@ enum {
struct cmdnam {
struct hashnode node;
union {
- char **name; /* full pathname for external commands */
- char *cmd; /* file name for hashed commands */
+ char **name; /* pointer into path array for external commands */
+ char *cmd; /* file name for hashed commands */
}
u;
};
@@ -2518,7 +2517,6 @@ enum {
RCS,
RECEXACT,
REMATCHPCRE,
- RESTRICTED,
RMSTARSILENT,
RMSTARWAIT,
SHAREHISTORY,
@@ -3287,6 +3285,8 @@ typedef wint_t convchar_t;
#define MB_CHARLENCONV(str, len, cp) mb_charlenconv((str), (len), (cp))
#define MB_CHARLEN(str, len) mb_charlenconv((str), (len), NULL)
+#define MB_NICECHAR(cp) wcs_nicechar((cp), NULL, NULL)
+
/*
* We replace broken implementations with one that uses Unicode
* characters directly as wide characters. In principle this is only
@@ -3366,6 +3366,8 @@ typedef int convchar_t;
#define MB_CHARLENCONV(str, len, cp) charlenconv((str), (len), (cp))
#define MB_CHARLEN(str, len) ((len) ? 1 : 0)
+#define MB_NICECHAR(cp) nicechar((cp))
+
#define WCWIDTH_WINT(c) (1)
/* Leave character or string as is. */
diff --git a/Src/zsh.mdd b/Src/zsh.mdd
index da8d58322..9a5e9daab 100644
--- a/Src/zsh.mdd
+++ b/Src/zsh.mdd
@@ -41,7 +41,7 @@ signames.c: signames1.awk signames2.awk ../config.h @SIGNAL_H@
sigcount.h: signames.c
grep 'define.*SIGCOUNT' signames.c > $@
-init.o: bltinmods.list zshpaths.h zshxmods.h
+init.o: bltinmods.list zshpaths.h zshxmods.h patchlevel.h
init.o params.o parse.o: version.h
diff --git a/Test/.cvsignore b/Test/.cvsignore
deleted file mode 100644
index 855d72909..000000000
--- a/Test/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-Makefile
-*.tmp
-*.swp
diff --git a/Test/A01grammar.ztst b/Test/A01grammar.ztst
index a65dc57f1..eea6ede2b 100644
--- a/Test/A01grammar.ztst
+++ b/Test/A01grammar.ztst
@@ -128,11 +128,11 @@
0:`exec' with -l option
>-zsh
- (exec -a /bin/SPLATTER /bin/sh -c 'echo $0')
+ (exec -a /bin/SPLATTER $ZTST_testdir/../Src/zsh -fc 'echo $0')
0:`exec' with -a option
>/bin/SPLATTER
- (exec -a/bin/SPLOOSH /bin/sh -c 'echo $0')
+ (exec -a/bin/SPLOOSH $ZTST_testdir/../Src/zsh -fc 'echo $0')
0:`exec' with -a option, no space
>/bin/SPLOOSH
@@ -144,7 +144,7 @@
(
opts=(-a /bin/WHOOOSH)
- exec $opts /bin/sh -c 'echo $0'
+ exec $opts $ZTST_testdir/../Src/zsh -fc 'echo $0'
)
0:`exec' with -a option from expansion
>/bin/WHOOOSH
diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index 1c6969e74..f866ab4d1 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -58,30 +58,26 @@
>And this too
>And aliases are expanded
- $ZTST_testdir/../Src/zsh -fis <<<'
- unsetopt PROMPT_SP
- PROMPT="" PS2="" PS3="" PS4="" RPS1="" RPS2=""
- exec 2>&1
- alias \{=echo
- { begin
- {end
- fc -l -2' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ alias \{=echo
+ { begin
+ {end
+ fc -l -2
+ '
0:Aliasing reserved tokens
>begin
>end
-*>*5*{ begin
-*>*6*{end
+*>*2*{ begin
+*>*3*{end
- $ZTST_testdir/../Src/zsh -fis <<<'
- unsetopt PROMPT_SP
- PROMPT="" PS2="" PS3="" PS4="" RPS1="" RPS2=""
- exec 2>&1
- alias -g S=\"
- echo S a string S "
- fc -l -1' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ alias -g S=\"
+ echo S a string S "
+ fc -l -1
+ '
0:Global aliasing quotes
> a string S
-*>*5*echo S a string S "
+*>*2*echo S a string S "
# "
# Note there is a trailing space on the "> a string S " line
diff --git a/Test/A05execution.ztst b/Test/A05execution.ztst
index 07a24f9c8..57d6b402e 100644
--- a/Test/A05execution.ztst
+++ b/Test/A05execution.ztst
@@ -375,7 +375,7 @@ F:anonymous function, and a descriptor leak when backgrounding a pipeline
?(eval):wait:13: job not found: ?bar
# Test 'wait' for unknown job/process ID (POSIX mode).
- (setopt POSIX_BUILTINS
+ () { setopt localoptions POSIX_BUILTINS
wait 1
echo $?
wait %%
@@ -388,16 +388,15 @@ F:anonymous function, and a descriptor leak when backgrounding a pipeline
echo $?
wait %foo
echo $?
- wait %\?bar)
+ wait %\?bar
+ }
127:'wait' exit status for unknown ID (POSIX mode)
>127
->0
>127
>127
>127
>127
-# TBD: the 0 above is believed to be bogus and should also be turned
-# into 127 when the ccorresponding bug is fixed in the main shell.
+>127
sleep 2 & pid=$!
kill -STOP $pid
diff --git a/Test/A06assign.ztst b/Test/A06assign.ztst
index 9f779b9a8..d653d75b3 100644
--- a/Test/A06assign.ztst
+++ b/Test/A06assign.ztst
@@ -133,6 +133,12 @@
>1 2 42 43 44 5
>1 2 42 100 99 5
+ array=(1 2 3 4 5)
+ array[4,2]=(42 43 44)
+ print $array
+0:Replacement of slice with end index preceding start index
+>1 2 3 42 43 44 4 5
+
# (subsection: append to array)
array=( )
@@ -708,6 +714,12 @@
0:overwrite [-2,-1] characters in short string
>ax
+ a="abcdefgh"
+ a[6,3]="xyz"
+ print $a
+0:overwrite [6,3] characters in short string
+>abcdexyzfgh
+
a="a"
a[-1]="xx"
print $a
@@ -750,3 +762,24 @@
)
0:regression workers/53033: assigning $! to array element
*>typeset -g -a x=\( <-> \)
+
+ (
+ typeset -a a
+ a[1]=()
+ a=( a b c )
+ )
+0:regression workers/54340
+
+ (
+ typeset s # Creates a string with pm->u.str = NULL
+ s[1]="" # Value from pm->gsu.s->getfn() may not be stored in pm->u.str
+ s="abcde" # Frees pm->u.str => Crashes if it contained value from pm->gsu.s->getfn()
+ )
+0:string assignments don't take ownership of non-freeable pointers
+
+ (
+ typeset -a a # Creates an array with pm->u.arr = NULL
+ a[1]=() # Value from pm->gsu.a->getfn() may not be stored in pm->u.arr
+ a=( a b c ) # Frees pm->u.arr => Crashes if it contained value from pm->gsu.a->getfn()
+ )
+0:array assignments don't take ownership of non-freeable pointers
diff --git a/Test/A09zwc.ztst b/Test/A09zwc.ztst
new file mode 100644
index 000000000..be180db1e
--- /dev/null
+++ b/Test/A09zwc.ztst
@@ -0,0 +1,39 @@
+# tests for .zwc loading
+
+%prep
+
+ mkdir zwc.tmp
+ print 'print victim ran' >zwc.tmp/victim
+ zcompile zwc.tmp/victim
+ cp zwc.tmp/{victim,orig}.zwc
+ chmod u+w zwc.tmp/*.zwc
+ # on little-endian systems, the first magic number will be \x07\x06\x05\x04;
+ # on big-endian ones, the reverse
+ zwc_order=little
+ () {
+ local LC_ALL=C
+ [[ ${${"$( < zwc.tmp/orig.zwc )"}[1]} == $'\x07' ]] || zwc_order=big
+ }
+
+%test
+
+ ( cp zwc.tmp/{orig,victim}.zwc
+ source zwc.tmp/victim )
+0:Unmodified .zwc loads and runs
+>victim ran
+
+# FDHead.npats sits at byte offset FD_PRELEN*4 + sizeof(wordcode)*2 = 56.
+# 0x40000000 (npats ~= 1 billion) is the value from the original
+# crash report; with the bound check in check_dump_file it must be
+# rejected, rather than triggering an out-of-bounds write or absurd allocation.
+ ( cp zwc.tmp/{orig,victim}.zwc
+ if [[ $zwc_order == little ]]; then
+ printf '\x00\x00\x00\x40'
+ else
+ printf '\x40\x00\x00\x00'
+ fi |
+ dd of=zwc.tmp/victim.zwc bs=1 seek=56 count=4 conv=notrunc 2>/dev/null
+ source zwc.tmp/victim )
+0:workers/54571: Malformed .zwc with implausible npats does not crash the shell
+?(eval):8: zwc.tmp/victim.zwc: invalid description: victim
+>victim ran
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 8839e3891..32e79ced2 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -18,7 +18,7 @@
# Function tracing (typeset -ft) E02xtrace
# Not yet tested:
-# Assorted illegal flag combinations
+# Assorted invalid flag combinations
# For a few tests, we include a
# typeset -p param
diff --git a/Test/B06fc.ztst b/Test/B06fc.ztst
index 922b0010f..31ec27087 100644
--- a/Test/B06fc.ztst
+++ b/Test/B06fc.ztst
@@ -10,16 +10,13 @@
1:Checking that fc -l foo doesn't core dump when history is empty
?./fcl:fc:1: event not found: foo
- PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:'
+ PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:'
0:Checking that fc -p doesn't core dump when history size is zero
-*?*%*
- PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0'
+ PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0'
1:Checking that fc -p rejects non-integer history size
-*?*% fc: HISTSIZE must be an integer
-*?*%*
+?fc: HISTSIZE must be an integer
- PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a'
+ PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a'
1:Checking that fc -p rejects non-integer history save size
-*?*% fc: SAVEHIST must be an integer
-*?*%*
+?fc: SAVEHIST must be an integer
diff --git a/Test/B08shift.ztst b/Test/B08shift.ztst
index 0aa922673..a01128e4f 100644
--- a/Test/B08shift.ztst
+++ b/Test/B08shift.ztst
@@ -31,3 +31,21 @@
>mether pip azer sezar akker conter dick
>mether pip azer sezar
>mether pip azer
+
+ () { local -a arr=( a b c ); shift 9 arr }
+ () { local -a .tmp.arr=( a b c ); shift 9 .tmp.arr }
+ () { shift 9 argv } a b c
+ () { shift 9 } a b c
+1:shifting more elements than exist in array
+?(anon):shift: shift count must be <= ${#arr}
+?(anon):shift: shift count must be <= ${#.tmp.arr}
+?(anon):shift: shift count must be <= ${#argv}
+?(anon):shift: shift count must be <= $#
+
+ () { local -i i=3; shift 9 i; print -r - $i }
+ () { local s=x; shift 9 s; print -r - $s }
+ () { local -A h=( a b ); shift 9 h; print -r - ${(kv)h} }
+0:shifting non-array
+>3
+>x
+>a b
diff --git a/Test/B10getopts.ztst b/Test/B10getopts.ztst
index e50d177c7..4e1893fc4 100644
--- a/Test/B10getopts.ztst
+++ b/Test/B10getopts.ztst
@@ -73,11 +73,11 @@
>test_getopts:3: argument expected after +c option
test_getopts -x
-1:one illegal option
+1:one invalid option
>test_getopts:3: bad option: -x
test_getopts +x
-1:one illegal option, + variant
+1:one invalid option, + variant
>test_getopts:3: bad option: +x
set -- -x
@@ -125,3 +125,64 @@
0:OPTIND calculation with and without POSIX_BUILTINS (workers/42248)
>no_posix_builtins: <1><1><2><1><1><3><5><7><6>
>posix_builtins: <1><1><2><2><2><3><6><7><7>
+
+ for 1 in no_posix_builtins posix_builtins; do (
+ setopt $1
+ print -rn - $1:
+ set -- -a -b +b -c
+ while getopts :abc opt; do
+ case $opt in
+ a|b|+b|c) print -rn - " $opt" ;;
+ ?) print -rn - " ?$OPTARG" ;;
+ esac
+ done
+ print
+ ); done
+0:POSIX_BUILTINS disables '+' variant handling
+>no_posix_builtins: a b +b c
+>posix_builtins: a b
+
+ (
+ setopt no_posix_builtins
+ for 1 in -a +a -x +x; do
+ () { local opt; getopts :abc opt; print -r - $opt } $1
+ done
+ for 1 in -a +a -x +x; do
+ () { local opt; getopts -p :abc opt; print -r - $opt } $1
+ done
+ )
+0:-p works like POSIX_BUILTINS
+>a
+>+a
+>?
+>?
+>a
+>
+>?
+>
+
+ # not enough arguments
+ () { getopts }
+ () { getopts '' }
+ () { getopts x }
+ () { getopts - x }
+ () { getopts -p - x }
+ () { getopts -p -- x }
+ # invalid option to getopts
+ () { getopts -x x }
+ () { getopts -x x y }
+ () { getopts -x - x y }
+ # guarded spec
+ () { getopts - -x y }
+ # argv on command line
+ () { getopts x y a b c }
+-:option parsing
+?(anon):getopts: not enough arguments
+?(anon):getopts: not enough arguments
+?(anon):getopts: not enough arguments
+?(anon):getopts: not enough arguments
+?(anon):getopts: not enough arguments
+?(anon):getopts: not enough arguments
+?(anon):getopts: bad option: -x
+?(anon):getopts: bad option: -x
+?(anon):getopts: bad option: -x
diff --git a/Test/B11kill.ztst b/Test/B11kill.ztst
index dc6bf9b89..655e00c80 100644
--- a/Test/B11kill.ztst
+++ b/Test/B11kill.ztst
@@ -35,17 +35,17 @@
kill a b c
)
3:kill with multiple wrong inputs should increment status
-?(eval):kill:2: illegal pid: a
-?(eval):kill:2: illegal pid: b
-?(eval):kill:2: illegal pid: c
+?(eval):kill:2: invalid pid: a
+?(eval):kill:2: invalid pid: b
+?(eval):kill:2: invalid pid: c
(
kill -INT a b c
)
3:kill with sigspec and wrong inputs should increment status
-?(eval):kill:2: illegal pid: a
-?(eval):kill:2: illegal pid: b
-?(eval):kill:2: illegal pid: c
+?(eval):kill:2: invalid pid: a
+?(eval):kill:2: invalid pid: b
+?(eval):kill:2: invalid pid: c
(
kill
@@ -75,12 +75,35 @@
kill -URG ''
)
1:kill with empty pid and sigspec should not send signal to current process group
-?(eval):kill:3: illegal pid:
+?(eval):kill:3: invalid pid:
(
trap 'exit 19' TERM
kill ''
)
1:Plain kill with empty pid should not send signal to current process group
-?(eval):kill:3: illegal pid:
+?(eval):kill:3: invalid pid:
+# posix doesn't actually define which numbers map to which signals, but the
+# first three seem pretty universal so we'll trust them
+ kill -l
+ kill -l HUP
+ kill -l sighup
+ kill -l 1
+ kill -l 137
+ kill -l 9009
+ kill -l 6term
+ kill -l sig6term
+1:kill -l
+*>HUP INT QUIT *
+*>1
+*>1
+*>HUP
+*>KILL
+*>9009
+*?*: SIG6TERM
+*?*: SIG6TERM
+
+ print -r - ${(f)${ kill -L }}
+0:kill -L
+*>*1*HUP*2*INT*3*QUIT*
diff --git a/Test/B12limit.ztst b/Test/B12limit.ztst
index 9dce59824..bc73d660a 100644
--- a/Test/B12limit.ztst
+++ b/Test/B12limit.ztst
@@ -1,6 +1,7 @@
%prep
+ ZSH_TEST_LANG=$(ZTST_find_UTF8)
if ! zmodload zsh/rlimits 2>/dev/null
then
ZTST_unimplemented="the zsh/rlimits module was disabled by configure (see config.modules)"
@@ -26,3 +27,27 @@ F:report this to zsh-workers mailing list.
}
0:check if limit option letters are unique
+ ulimit -z
+1:bad option letter
+?(eval):ulimit:1: bad option: -z
+
+ ulimit -N
+1:missing number after -N
+?(eval):ulimit:1: number required after -N
+
+ ulimit -N abc
+1:invalid number after -N
+?(eval):ulimit:1: invalid number: abc
+
+ ulimit -at
+1:resource option combined with -a
+?(eval):ulimit:1: no limits allowed with -a
+
+ if [[ -z $ZSH_TEST_LANG ]]; then
+ ZTST_skip='no UTF-8 locale'
+ else
+ LANG=$ZSH_TEST_LANG
+ ulimit -の
+ fi
+1:bad multibyte option letter
+?(eval):ulimit:5: bad option: -の
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
index 3910f705f..bc565e8b6 100644
--- a/Test/C02cond.ztst
+++ b/Test/C02cond.ztst
@@ -142,14 +142,23 @@
# can't be bothered with -S
- print -ru $ZTST_fd 'This test may take two seconds...'
- touch $newnewnew
- if (( isnfs )); then
+ zmodload -s zsh/datetime && {
+ t= &&
+ strftime -s t %m%d%H%M.%S $(( EPOCHSECONDS + 2 )) &&
+ touch -t $t -- $newnewnew &&
+ touch -at $t -- $unmodified
+ } 2> /dev/null || {
+ print -ru $ZTST_fd 'This test will take two seconds...' &&
+ sleep 2 &&
+ touch -- $newnewnew &&
+ touch -a -- $unmodified
+ }
+ if (( $? )); then
+ ZTST_skip='[[ -N file ]] not tested; touch failed'
+ elif (( isnfs )); then
ZTST_skip="[[ -N file ]] not supported with NFS"
elif ! zmodload -F zsh/stat b:zstat 2> /dev/null; then
ZTST_skip='[[ -N file ]] not tested; zsh/stat not available'
- elif ! { sleep 2; touch -a $unmodified 2> /dev/null }; then
- ZTST_skip='[[ -N file ]] not tested; touch failed'
elif [[ "$(zstat +atime $unmodified)" == "$(zstat +mtime $unmodified)" ]]; then
ZTST_skip='[[ -N file ]] not supported on this file system'
else
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 87b7fd1f7..9924e4f96 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -361,6 +361,81 @@
>trap
>Working 0
+ ok() { true } # All good
+ ko() { false } # Just a non-zero status
+ KO() { { : $KO } 2>&1 } # A Zsh error
+ fn() {
+ echo "$1"
+ set -u;
+ case $1 in
+ *-TRAP-ok) TRAPZERR() { echo "ok 1"; ok; echo "ok 2" };;
+ *-trap-ok) trap 'echo "ok 1"; ok; echo "ok 2"' ZERR;;
+ *-TRAP-KO) TRAPZERR() { echo "ok 1"; KO; echo "KO 2" };;
+ *-trap-KO) trap 'echo "ok 1"; KO; echo "KO 2"' ZERR;;
+ * ) echo "Unrecognized id: $1";
+ esac
+ case $1 in
+ ko-*-*) ko; echo "ok 3";;
+ KO-*-*) KO; echo "KO 3";;
+ * ) echo "Unrecognized id: $1";
+ esac
+ }
+ (fn ko-TRAP-ok; echo "ok 4"); echo "\$?=$?"
+ (fn ko-trap-ok; echo "ok 4"); echo "\$?=$?"
+ (fn ko-TRAP-KO; echo "ok 4"); echo "\$?=$?"
+ (fn ko-trap-KO; echo "ok 4"); echo "\$?=$?"
+ (fn KO-TRAP-ok; echo "KO 4"); echo "\$?=$?"
+ (fn KO-trap-ok; echo "KO 4"); echo "\$?=$?"
+ (fn KO-TRAP-KO; echo "KO 4"); echo "\$?=$?"
+ (fn KO-trap-KO; echo "KO 4"); echo "\$?=$?"
+0:DDD
+>ko-TRAP-ok
+>ok 1
+>ok 2
+>ok 3
+>ok 4
+>$?=0
+>ko-trap-ok
+>ok 1
+>ok 2
+>ok 3
+>ok 4
+>$?=0
+>ko-TRAP-KO
+>ok 1
+>KO: KO: parameter not set
+F:Shouldn't the error in the trap prevent any further execution?
+>ok 3
+>ok 4
+>$?=0
+>ko-trap-KO
+>ok 1
+>KO: KO: parameter not set
+F:Shouldn't the error in the trap prevent any further execution?
+>ok 3
+>ok 4
+>$?=0
+>KO-TRAP-ok
+>KO: KO: parameter not set
+>ok 1
+>ok 2
+>$?=1
+>KO-trap-ok
+>KO: KO: parameter not set
+>ok 1
+>ok 2
+>$?=1
+>KO-TRAP-KO
+>KO: KO: parameter not set
+>ok 1
+>KO: KO: parameter not set
+>$?=1
+>KO-trap-KO
+>KO: KO: parameter not set
+>ok 1
+>KO: KO: parameter not set
+>$?=1
+
{ trap 'echo This subshell is exiting' EXIT; } | cat
0: EXIT trap set in current shell at left of pipeline
>This subshell is exiting
diff --git a/Test/D03procsubst.ztst b/Test/D03procsubst.ztst
index d68db35fa..d7f57afdc 100644
--- a/Test/D03procsubst.ztst
+++ b/Test/D03procsubst.ztst
@@ -25,12 +25,9 @@
0:>(...) substitution
>SEcond ViErtE
- diff =(cat FILE1) =(cat FILE2)
-1:=(...) substitution
->1c1
->< First Second Third Fourth
->---
->> Erste Zweite Dritte Vierte
+ paste =(cut -f1 FILE1) =(cut -f3 FILE2)
+0:=(...) substitution
+>First Dritte
copycat <(print First) <(print Zweite)
0:FDs remain open for external commands called from functions
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index ed25fd7a9..583f8d28a 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -82,6 +82,58 @@
>wasnull2d
>wasnull2d
+ typeset -Z3 zerothree
+ print ${zerothree::=15}
+ zerothree=
+ print ${zerothree[1]::=2} $zerothree[1] $zerothree
+ zerothree=
+ print ${zerothree[1,2]::=34} $zerothree[1,2] $zerothree
+ zerothree=
+ print ${zerothree[2,3]::=7} $zerothree[2,3] $zerothree
+ typeset -E3 ethree
+ five=5
+ print ${ethree::=five}
+ typeset -a -U uniquearr
+ typeset -a duplicates=(1 2 1 1 2 3)
+ print ${(A)uniquearr::=$duplicates}
+ print ${(A)uniquearr[1,2]::=$duplicates}
+ typeset -a normalarray=( a b c d e )
+ print ${(A)normalarray[2,4]::=o}
+ typeset -u upper=aaaaa
+ print ${upper[2,3]::=hi} $upper $upper[2,3]
+ print ${(A)upper::=big} $upper ${(t)upper}
+0:::= respects expansion flags
+>015
+>0 0 002
+>03 03 034
+>07 07 007
+>5.00e+00
+>1 2 3
+>1 2
+>o e
+>HI AHIAA HI
+>big big array-local
+
+ local foo=xxx
+ () { echo ${2::=$foo} ${3::=$foo} ${4::=$foo}; echo $2 } yyy
+ () { echo ${11::=$foo}; echo $11 } yyy blah
+0:::= doesn't do weird things with positional arguments
+>xxx xxx xxx
+>xxx
+>xxx
+>xxx
+
+ local five=5 arr=( a b )
+ print -rl - ${arr[2]::=$five}
+ () { print -rl - ${1::=$2} } x y
+ () { print -rl - ${1::=$five} ${2::=$five} ${9::=$five} } x y
+0:regression: ::= with multiple assignments
+>5
+>y
+>5
+>5
+>5
+
unset array
print ${#${(A)=array=word}}
0:${#${(A)=array=word}} counts array elements
@@ -95,19 +147,17 @@
?(eval):1: unset1: exiting1
?(eval):2: null1: exiting2
- PROMPT="" $ZTST_testdir/../Src/zsh -fis <<<'
- unsetopt PROMPT_SP
- PS1="" PS2="" PS3="" PS4="" RPS1="" RPS2=""
- exec 2>&1
- foo() {
- print ${1:?no arguments given}
- print not reached
- }
- foo
- print reached
- ' 2>/dev/null
+ PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
+ exec 2>&1
+ foo() {
+ print ${1:?no arguments given}
+ print not reached
+ }
+ foo
+ print reached
+ '
0:interactive shell returns to top level on ${...?...} error
-*>*foo:1: 1: no arguments given
+>foo:1: 1: no arguments given
>reached
message="expand me and remove quotes"
@@ -788,6 +838,23 @@
0:${(r...)...}
>why?! in?!! goodn name? am?!! I?!!! doing this?
+ print -r - ${(l<3><->):-}
+ print -r - ${(l<3><1->):-}
+ # these cases weren't affected by the fix for this, but just in case
+ str=abc123xyz
+ print -r - ${str//<->/.}
+ print -r - ${str//<1->/.}
+ arr=( abc 123 xyz )
+ print -r - ${arr[(r)<->]}
+ print -r - ${arr[(r)<1->]}
+0:regression test for <-> in flags
+>---
+>-1-
+>abc.xyz
+>abc.xyz
+>123
+>123
+
array=(I\'m simply putting a brave face on)
print ${(j:--:)array}
0:${(j)...}
@@ -1632,11 +1699,97 @@
print $zsh_eval_context[1]
[[ $ZSH_EVAL_CONTEXT = ${(j.:.)zsh_eval_context} ]] || print Not equal!
(( icontext = ${#zsh_eval_context} + 1 ))
- contextfn() { print $(print $zsh_eval_context[icontext,-1]); }
+ contextfn() { print -r - $zsh_eval_context[icontext,-1] }
+ functions -M contextfn
contextfn
+ () { contextfn }
+ () { trap contextfn EXIT }
+ eval contextfn
+ print -r - $( contextfn )
+ print -r - ${ contextfn }
+ : ${| contextfn }
+ (( contextfn(0) ))
+ : $(( contextfn(0) ))
+ let 'contextfn(0)'
+ : /(e*contextfn*)
+ : /(o+contextfn)
+ cat <( contextfn )
+ cat < <( contextfn )
+ cat =( contextfn )
+ # ': >( contextfn )' would hang if FIFO is used for process substitution
+ () { echo > $1 } >( contextfn )
+ : > >( contextfn )
+ source <( <<< contextfn )
+ $ZTST_testdir/../Src/zsh -fc 'print -r - $zsh_eval_context'
+ () { () { print -r - $( : $(( contextfn(0) )) ) } }
0:$ZSH_EVAL_CONTEXT and $zsh_eval_context
>toplevel
->shfunc cmdsubst
+>shfunc
+>shfunc shfunc
+>trap shfunc
+>eval shfunc
+>cmdsubst shfunc
+>cmdsubst shfunc
+>cmdsubst shfunc
+>math shfunc
+>math shfunc
+>math shfunc
+>globqual shfunc
+>globsort shfunc
+>outsubst shfunc
+>outsubst shfunc
+>equalsubst shfunc
+>insubst shfunc
+>insubst shfunc
+>file shfunc
+>cmdarg
+>shfunc shfunc cmdsubst math shfunc
+
+ (( icontext = ${#zsh_eval_context} + 1 ))
+ contextfn() {
+ print -r - $#zsh_eval_context[icontext,-1] $zsh_eval_context[icontext,-1]
+ }
+ cmd='() { eval contextfn }'
+ repeat 48 cmd="() { $cmd }"
+ eval $cmd
+0:zsh_eval_context resizing
+*>52 eval shfunc * shfunc eval shfunc
+
+ (( icontext = ${#zsh_eval_context} + 1 ))
+ context1() {
+ print -r - $zsh_eval_context[icontext,-1]
+ context2
+ }
+ context2() {
+ print -r - $zsh_eval_context[icontext,-1]
+ }
+ functions -M context1
+ functions -M context2
+ echo '((...))'
+ (( context1(context2()) ))
+ echo '$((...))'
+ : $(( context1(context2()) ))
+ echo let
+ let 'context1(context2())'
+ echo subscript
+ arr=( ) exp='context1()+2'
+ : $arr[$exp]
+0:more math context
+>((...))
+>math shfunc
+>math shfunc
+>math shfunc shfunc
+>$((...))
+>math shfunc
+>math shfunc
+>math shfunc shfunc
+>let
+>math shfunc
+>math shfunc
+>math shfunc shfunc
+>subscript
+>math shfunc
+>math shfunc shfunc
foo="123456789"
print ${foo:3}
@@ -1796,6 +1949,14 @@
>
>
+ wu='aa bb cc'
+ echo $wu:wu
+ W=FOOBAR
+ echo $W:W_B_l
+0:repeated upper/lowercase modifiers
+>AA BB CC
+>fooBar
+
# This used to cause uncontrolled behaviour, but at best
# you got the wrong output so the check is worth it.
args() { print $#; }
@@ -2306,13 +2467,13 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
(
IFS=$'\x80'
if [[ $IFS = $' \t\n\0' ]]; then
- echo OK # if $'\x80' is illegal (e.g. Linux)
+ echo OK # if $'\x80' is invalid (e.g. Linux)
else # otherwise (e.g. macOS), it should work as a separator
s=$'foo\x80\bar'
[[ ${${=s}[1]} = foo ]] && echo OK
fi
)
-0D:reset IFS to default if it contains illegal character
+0D:reset IFS to default if it contains invalid character
>OK
(
@@ -2358,6 +2519,27 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
>different
>string
+ foo="abcdef"
+ print 1${foo/#abc/REPLACED}
+ print 2${foo/%abc/REPLACED}
+ print 3${foo/#%abc/REPLACED}
+ print 4${foo/#def/REPLACED}
+ print 5${foo/%def/REPLACED}
+ print 6${foo/#%def/REPLACED}
+ print 7${foo/#bc/REPLACED}
+ print 8${foo/%bc/REPLACED}
+ print 9${foo/#%bc/REPLACED}
+0:Respect anchors
+>1REPLACEDdef
+>2abcdef
+>3abcdef
+>4abcdef
+>5abcREPLACED
+>6abcdef
+>7abcdef
+>8abcdef
+>9abcdef
+
my_width=6
my_index=1
my_options=Option1
@@ -2811,7 +2993,7 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
: ${(#X):-@}
1:${(#X)...}: bad math expression
-?(eval):1: bad math expression: illegal character: @
+?(eval):1: bad math expression: invalid character: @
echo a${(#):-@}z
0:${(#)...}: bad math expression
@@ -2864,3 +3046,41 @@ F:behavior, see http://austingroupbugs.net/view.php?id=888
0:regression for workers/53179 unicode ZDOTDIR
F:output ignorable as long as not an error
*>*
+
+ argv0=/not/a/real/path
+ exepath=$(
+ ARGV0=$argv0 $ZTST_testdir/../Src/zsh -fc 'print -r - $ZSH_EXEPATH'
+ )
+ if
+ [[ $OSTYPE == (darwin|dragonfly|freebsd|netbsd)* ]] || # via library call
+ [[ $OSTYPE == (cygwin|linux|solaris)* && -e /proc/self ]] # via procfs
+ then
+ [[ $exepath == (/*)#/Src/zsh ]] && print -rn 'match: '
+ print -r - $exepath
+ # on any other system without procfs, we should have argv[0] verbatim since
+ # it's already absolute
+ elif [[ ! -e /proc/$$ ]]; then
+ [[ $exepath == $argv0 ]] && print -rn 'match: '
+ print -r - $exepath
+ else
+ ZTST_skip='ZSH_EXEPATH not reliable'
+ fi
+-:ZSH_EXEPATH
+*>match: /*
+
+ for 1 in '' -m; do
+ COLUMNS=47 LINES=47 $ZTST_testdir/../Src/zsh $1 -fc '
+ echo $COLUMNS $LINES
+ COLUMNS=74 LINES=74
+ echo $COLUMNS $LINES
+ command true
+ echo $COLUMNS $LINES
+ '
+ done
+-:COLUMNS and LINES preserved from environment when non-interactive
+>47 47
+>74 74
+>74 74
+>47 47
+>74 74
+>74 74
diff --git a/Test/D06subscript.ztst b/Test/D06subscript.ztst
index 57cdc027c..42748577d 100644
--- a/Test/D06subscript.ztst
+++ b/Test/D06subscript.ztst
@@ -308,3 +308,18 @@ F:In math, (($i)) should be the same as ((i)), see workers/47748.
F:Regression test for inconsistency of failed (i) on zero-length string
>2
>1
+
+ string='foo bar baz'
+ for 1 in 0 1 2 3 4 -1 -2 -3 -4; do
+ print -r - $1 $string[(w)$1]
+ done
+0:(w)
+>0
+>1 foo
+>2 bar
+>3 baz
+>4
+>-1 baz
+>-2 bar
+>-3 foo
+>-4
diff --git a/Test/D07multibyte.ztst b/Test/D07multibyte.ztst
index 413c4fe73..28cb9d907 100644
--- a/Test/D07multibyte.ztst
+++ b/Test/D07multibyte.ztst
@@ -556,6 +556,23 @@ F:This is considered a bugfix in zsh
[[ $'\xe3\x83\x9b' = ? ]] || print fail 4
0:Testing incomplete and invalid multibyte character components
+ [[ é != *$'\xc3'* ]] || print fail 1
+ [[ é != *$'\xa9'* ]] || print fail 2
+ [[ Stéphane != *$'\xc3'* ]] || print fail 3
+ [[ Stéphane != *$'\xa9'* ]] || print fail 4
+ [[ é != $'\xc3'* ]] || print fail 5
+ [[ é != *$'\xa9' ]] || print fail 6
+0:Raw bytes don't match multibyte characters in * patterns
+
+ [[ éé != é#$'\xa9' ]] || print fail 1
+ [[ é != [aé]#$'\xa9' ]] || print fail 2
+ [[ é != [^x]#$'\xa9' ]] || print fail 3
+ [[ aé != [aé]#$'\xa9' ]] || print fail 4
+ [[ aé != [^x]#$'\xa9' ]] || print fail 5
+ [[ aé != [aé]##$'\xa9' ]] || print fail 6
+ [[ aé != [^x]##$'\xa9' ]] || print fail 7
+0:Raw bytes don't match multibyte characters part 2
+
print -r -- ${(q+):-ホ}
foo='She said "ホ". I said "You can'\''t '\''ホ'\'' me!'
print -r -- ${(q+)foo}
@@ -643,3 +660,15 @@ F:support character sets outside the portable 7-bit range.
0:(workers/50150) zsh/stat with Unicode and metafication
>50150-Ą 0
>50150-é 0
+
+ (
+ COLUMNS=80 LINES=3 PS3='> '
+ select REPLY in ⚃; do # U+2683
+ print -r - ${(V)REPLY}
+ done
+ )
+0:workers/54583: select with multi-byte word
+<1
+?1) ⚃
+?> >
+>⚃
diff --git a/Test/E01options.ztst b/Test/E01options.ztst
index 969bd42d5..bcca69db7 100644
--- a/Test/E01options.ztst
+++ b/Test/E01options.ztst
@@ -5,7 +5,6 @@
# APPEND_HISTORY (history not maintained)
# AUTO_LIST
# AUTO_MENU
-# AUTO_NAME_DIRS (named directory table not maintained)
# AUTO_PARAM_KEYS
# AUTO_PARAM_SLASH
# AUTO_REMOVE_SLASH
@@ -96,6 +95,15 @@
%test
+# --version is technically an option
+ v=$( $ZTST_testdir/../Src/zsh --version )
+ print -r - $v
+ # patchlevel should appear in output if different from version
+ [[ $ZSH_PATCHLEVEL == zsh-$ZSH_VERSION-0-* ]] ||
+ [[ $v == *\[$ZSH_PATCHLEVEL\]* ]]
+0:zsh --version output
+*>zsh * \(*\)
+
# setopt should move on to the next operation in the face of an error, but
# preserve the >0 return code
unsetopt aliases
@@ -1013,24 +1021,6 @@
>one'quoted'expression
>anotherquotedexpression
-# too lazy to test jobs -Z and ARGV0.
- (setopt restricted; cd /)
- (setopt restricted; PATH=/bin:/usr/bin)
- (setopt restricted; /bin/ls)
- (setopt restricted; hash ls=/bin/ls)
- (setopt restricted; print ha >outputfile)
- (setopt restricted; exec ls)
- (setopt restricted; unsetopt restricted)
- :
-0:RESTRICTED option
-?(eval):cd:1: restricted
-?(eval):2: PATH: restricted
-?(eval):3: /bin/ls: restricted
-?(eval):hash:4: restricted: /bin/ls
-?(eval):5: writing redirection not allowed in restricted mode
-?(eval):exec:6: ls: restricted
-?(eval):unsetopt:7: can't change option: restricted
-
# ' emacs deconfusion
fn() {
@@ -1546,3 +1536,17 @@ F:compare E03posix.ztst
foo
"
42:ERR_RETURN inside 'source' and 'if'
+
+ $ZTST_testdir/../Src/zsh --autonamedirs +Z -fic '
+ b=/bin; hash -d | grep "^b="
+ '
+0:AUTO_NAME_DIRS
+>b=/bin
+
+ $ZTST_testdir/../Src/zsh --autonamedirs +Z -fic '
+ () { local b=/bin; hash -d | grep "^b=" }
+ c=/bin
+ () { local c=/sbin; hash -d | grep "^c=" }
+ '
+0:workers/54309: AUTO_NAME_DIRS: local parameter not considered
+>c=/bin
diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst
index 0b4475827..952bbd30c 100644
--- a/Test/K01nameref.ztst
+++ b/Test/K01nameref.ztst
@@ -33,44 +33,44 @@
}
function g() {
- if (($2)); then local -n $1 rs ra rs1 ra1;
- else local -n $1 rs=s ra=a rs1="s[1]" ra1="a[1]"; fi;
- if (($2 == 1)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi;
- echo "$0:1: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ if (($2)); then local -n $1 rs ra;
+ else local -n $1 rs=s ra=a; fi;
+ if (($2 == 1)); then rs=s; ra=a; fi;
+ echo "$0:1: rs=$rs - ra=$ra";
local s=$0 a=($0);
- if (($2 == 2)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi;
- echo "$0:2: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ if (($2 == 2)); then rs=s; ra=a; fi;
+ echo "$0:2: rs=$rs - ra=$ra";
h "$@";
- echo "$0:3: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ echo "$0:3: rs=$rs - ra=$ra";
}
function h() {
- if (($2 == 3)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi;
- echo "$0:1: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ if (($2 == 3)); then rs=s; ra=a; fi;
+ echo "$0:1: rs=$rs - ra=$ra";
local s=$0 a=($0);
- if (($2 == 4)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi;
- echo "$0:2: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ if (($2 == 4)); then rs=s; ra=a; fi;
+ echo "$0:2: rs=$rs - ra=$ra";
i "$@";
- echo "$0:3: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ echo "$0:3: rs=$rs - ra=$ra";
# Check that re-entering the same scope doesn't undo scope exit
k "$@"
}
function i() {
- if (($2 == 5)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi;
- echo "$0:1: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ if (($2 == 5)); then rs=s; ra=a; fi;
+ echo "$0:1: rs=$rs - ra=$ra";
local s=$0 a=($0);
- if (($2 == 6)); then rs=s; ra=a; rs1="s[1]"; ra1="a[1]"; fi;
- echo "$0:2: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ if (($2 == 6)); then rs=s; ra=a; fi;
+ echo "$0:2: rs=$rs - ra=$ra";
j "$@";
- echo "$0:3: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ echo "$0:3: rs=$rs - ra=$ra";
k "$@";
}
function j() {
- echo "$0:1: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ echo "$0:1: rs=$rs - ra=$ra";
local s=$0 a=($0);
- echo "$0:2: rs=$rs - ra=$ra - rs1=$rs1 - ra1=$ra1";
+ echo "$0:2: rs=$rs - ra=$ra";
}
functions -c j k
@@ -276,93 +276,197 @@ F:note this causes "var" to become set
>typeset -n ptr=var
>typeset -t var
- typeset -n ptr=var[2]
- typeset -t ptr
-1:change type of referenced array element
-*?*var\[2\]: can't change type via subscript reference
-
typeset -n ptr[1]=var
-1:illegal nameref name
+1:invalid nameref name
*?*reference variable cannot be an array
typeset var=value
typeset -n ptr=var
print $ptr
-0:basic nameref expansion, no braces
+ print $ptr[2,4]
+0:nameref expansion, no braces
>value
+>alu
typeset var=value
typeset -n ptr=var
print ${ptr}
-0:basic nameref expansion, braces
+ print ${(U)ptr}
+ print ${ptr[2,5][1,3]}
+ print ${(U)ptr[2,5][1,3]}
+0:nameref expansion, braces
>value
+>VALUE
+>alu
+>ALU
typeset var=(val1 val2)
typeset -n ptr=var
print $ptr
-0:nameref array expansion
+ print $ptr[2]
+0:nameref array expansion, no braces
>val1 val2
+>val2
- typeset -A var=(val1 val2)
+ typeset var=(val1 val2)
typeset -n ptr=var
- print ${(kv)ptr}
-0:nameref hash expansion
+ print ${ptr}
+ print ${(O)ptr}
+ print ${ptr[2]}
+ print ${(U)ptr[2]}
+ print ${ptr[2][2,4]}
+ print ${(U)ptr[2][2,4]}
+0:nameref array expansion, braces
+>val1 val2
+>val2 val1
+>val2
+>VAL2
+>al2
+>AL2
+
+ typeset -A var=(key1 val1 key2 val2)
+ typeset -n ptr=var
+ print $ptr
+ print $ptr[key2]
+0:nameref hash expansion, no braces
>val1 val2
+>val2
+ typeset -A var=(key1 val1 key2 val2)
typeset -n ptr=var
+ print ${ptr}
+ print ${(kv)ptr}
+ print ${ptr[key2]}
+ print ${(U)ptr[key2]}
+ print ${ptr[key2][2,4]}
+ print ${(U)ptr[key2][2,4]}
+0:nameref hash expansion, braces
+>val1 val2
+>key1 val1 key2 val2
+>val2
+>VAL2
+>al2
+>AL2
+
typeset var=value
- typeset -p ptr var
+ typeset -n ptr=var
ptr=newvalue
- typeset -p ptr var
-0:assign existing scalar via nameref
->typeset -n ptr=var
->typeset var=value
->typeset -n ptr=var
+ typeset -p var
+ ptr[3]=xt
+ typeset -p var
+ typeset ptr=newvalue
+ typeset -p var
+ typeset ptr[3]=xt
+ typeset -p var
+0:assign/typeset existing scalar via nameref
+>typeset var=newvalue
+>typeset var=nextvalue
>typeset var=newvalue
+>typeset var=nextvalue
+
+ typeset var=(val1 val2)
+ typeset -n ptr=var
+ ptr=(new1 new2 new3 new4 new5)
+ typeset -p var
+ ptr[3]=new6
+ typeset -p var
+ ptr[2,4]=(new7 new8)
+ typeset -p var
+ typeset ptr=(new1 new2 new3 new4 new5)
+ typeset -p var
+ typeset ptr[3]=new6
+ typeset -p var
+ typeset ptr[2,4]=(new7 new8)
+ typeset -p var
+0:assign/typeset existing array via nameref
+>typeset -a var=( new1 new2 new3 new4 new5 )
+>typeset -a var=( new1 new2 new6 new4 new5 )
+>typeset -a var=( new1 new7 new8 new5 )
+>typeset -a var=( new1 new2 new3 new4 new5 )
+>typeset -a var=( new1 new2 new6 new4 new5 )
+>typeset -a var=( new1 new7 new8 new5 )
+ typeset -A var=(key1 val1)
typeset -n ptr=var
+ ptr=(key2 val2 key3 val3)
+ typeset -p var
+ ptr[key3]=VAL3
+ ptr[key4]=val4
+ typeset -p var
+ typeset ptr=(key2 val2 key3 val3)
+ typeset -p var
+ typeset ptr[key3]=VAL3
+ typeset ptr[key4]=val4
+ typeset -p var
+0:assign/typeset existing array via nameref
+>typeset -A var=( [key2]=val2 [key3]=val3 )
+>typeset -A var=( [key2]=val2 [key3]=VAL3 [key4]=val4 )
+>typeset -A var=( [key2]=val2 [key3]=val3 )
+>typeset -A var=( [key2]=val2 [key3]=VAL3 [key4]=val4 )
+
+ () {
+ unset var
+ typeset -n ptr=var
+ ptr=value
+ typeset -p var
+ unset var
+ typeset ptr=value
+ typeset -p var
+ }
+ typeset -p var
+1:assign/typeset new scalar via nameref
+>typeset -g var=value
+>typeset var=value
+*?*no such variable: var
+
+ () {
+ unset var
+ typeset -n ptr=var
+ ptr=(val1 val2)
+ typeset -p var
+ unset var
+ typeset ptr=(val1 val2)
+ typeset -p var
+ }
+ typeset -p var
+1:assign/typeset new array via nameref
+>typeset -g -a var=( val1 val2 )
+>typeset -a var=( val1 val2 )
+*?*no such variable: var
+
typeset var=value
+ typeset -n ptr=var
+ unset "ptr[3]"
+ typeset -p var
+ unset "ptr[2,3]"
+ typeset -p var
+ unset ptr
+ typeset -p var
+ typeset var=(val1 val2 val3 val4 val5)
+ unset "ptr[3]"
+ typeset -p var
+ unset "ptr[2,4]"
+ typeset -p var
+ unset ptr
+ typeset -p var
+ typeset -A var=(key1 val1 key2 val2)
+ unset "ptr[key2]"
+ typeset -p var
unset ptr
typeset -p var
0:unset via nameref
+>typeset var=vaue
+>typeset var=ve
+>typeset -a var=( val1 val2 '' val4 val5 )
+>typeset -a var=( val1 '' val5 )
+>typeset -A var=( [key1]=val1 )
- typeset -n ptr=var
typeset var=value
+ typeset -n ptr=var
unset -n ptr
typeset -p var ptr
0:unset of the nameref itself
-F:If earlier tests change, might get "no such variable" here
->typeset var=value
-
- typeset -n ptr=var
- typeset var=value
- typeset -p ptr var
- typeset ptr=newvalue
- typeset -p ptr var
-0:typeset existing scalar via nameref
->typeset -n ptr=var
>typeset var=value
->typeset -n ptr=var
->typeset var=newvalue
-
- typeset -n ptr=var
- ptr=value
- typeset -p var ptr
-0:assign new scalar via nameref
->typeset -g var=value
->typeset -n ptr=var
-
- unset var
- typeset -n ptr=var
- typeset var=(val1 val2)
- typeset -p ptr var
- ptr=(new1 new2)
- typeset -p ptr var
-0:assign existing array via nameref
->typeset -n ptr=var
->typeset -a var=( val1 val2 )
->typeset -n ptr=var
->typeset -a var=( new1 new2 )
typeset -p ptr ptr1 ptr2 var
1:check state of paramtab ONE
@@ -372,13 +476,6 @@ F:unexpected side-effects of previous tests
*?*no such variable: ptr2
*?*no such variable: var
- typeset -n ptr=var
- ptr=(val1 val2)
- typeset -p var ptr
-0:assign new array via nameref
->typeset -g -a var=( val1 val2 )
->typeset -n ptr=var
-
unset var
typeset -n ptr2=var
typeset -n ptr1=ptr2
@@ -540,81 +637,10 @@ F:unexpected side-effects of previous tests
}
0:regression: not a self reference (test 3)
-
- unset -n ptr2
- typeset -n ptr2='path[2]'
- print -r -- $ptr2
-0q:nameref to array element, no braces
->${path[2]}
-
- unset -n ptr2
- typeset -n ptr2='path[2]'
- print -r -- ${ptr2}
-0q:nameref to array element, with braces
->${path[2]}
-
- unset -n ptr1
- typeset -A hash=(x MISS y HIT)
- typeset -n ptr1='hash[y]'
- print -r -- $ptr1
-0:nameref to hash element, no braces
->HIT
-
- unset -n ptr1
- typeset -A hash=(x MISS y HIT)
- typeset -n ptr1='hash[y]'
- print -r -- ${ptr1}
-0:nameref to hash element, with braces
->HIT
-
- unset -n ptr2
- typeset -a ary=(1 2)
- typeset -n ptr2='ary[2]'
- ptr2=TWO
- typeset -p ary
-0:assign array element by nameref
->typeset -a ary=( 1 TWO )
-
- unset -n ptr2
- typeset -n ptr2='ary[2]'
- ptr2=TWO
- typeset -p ary
-0f:create array element by nameref
-F:ksh93 does not implement this either
->typeset -a ary=( '' TWO )
-
- unset -n ptr1
- typeset -A hash=(x MISS y MISS)
- typeset -n ptr1='hash[y]'
- ptr1=HIT
- typeset -p hash
-0:assign to hash element by nameref
->typeset -A hash=( [x]=MISS [y]=HIT )
-
- unset -n ptr1
- typeset -A hash
- typeset -n ptr1='hash[y]'
- ptr1=HIT
- typeset -p hash
-0f:create hash by element nameref
-F:ksh93 does not implement this either
->typeset -A hash=( [y]=HIT )
-
unset -n ptr1
typeset -n ptr1='not[2]good'
1:invalid nameref
-*?*invalid name reference: not\[2\]good
-
- unset -n ptr1
- unset hash
- typeset -A hash
- typeset -n ptr1='hash[y]'
- print ${ptr1::=HIT}
- typeset -p ptr1 hash
-0f:create hash by element substitution
->HIT
->typeset -n ptr1='hash[y]'
->typeset -A hash=( [y]=HIT )
+*?*invalid variable name: not\[2\]good
unset -n ptr
unset gval
@@ -683,9 +709,9 @@ F:unexpected side-effects of previous tests
typeset -A var=(myself outside)
() {
- typeset -n myself=var[myself]
+ typeset -n myself=var
local -h var
- print -r -- $myself
+ print -r -- $myself[myself]
typeset -p var
}
0:up-reference part 3, hidden global
@@ -800,15 +826,15 @@ F:Same test, should part 5 output look like this?
if zmodload zsh/parameter; then
() {
zmodload -u zsh/parameter
- typeset -n myself=parameters[myself]
+ typeset -n myself=parameters
local -h parameters
- print -r -- $myself
+ print -r -- $myself[myself]
typeset -p parameters
}
else ZTST_skip='Cannot zmodload zsh/parameter, skipping autoload test'
fi
0:up-reference part 9, autoloading with hidden special
->nameref-local-nameref-local
+>nameref-local-association-readonly-hide-hideval-special
>typeset -h parameters
(
@@ -909,15 +935,6 @@ F:Checking for a bug in zmodload that affects later tests
0:named references with (P), as ${(P)nameref}
>value
- ary=( 'bry[1]' 'bry[2]' )
- bry=( lorem ipsum )
- typeset -n ptr='ary[2]'
- print -r -- ${ptr}
- print -r -- ${(P)ptr}
-0:named references with (P), array element to array element
->bry[2]
->ipsum
-
unset -n ref
unset var
typeset -n ref=var
@@ -1026,15 +1043,15 @@ F:Checking for a bug in zmodload that affects later tests
typeset -p .K01.{scalar,assoc,array,integer,double,float,readonly}
unset .K01.{scalar,assoc,array,integer,double,float}
0:unset various types via nameref, including a readonly special
->typeset -g .K01.scalar
->typeset -g -A .K01.assoc
->typeset -g -a .K01.array
->typeset -g -i .K01.integer
->typeset -g -E .K01.double
->typeset -g -F .K01.float
>typeset -g -r .K01.readonly=RO
*?*read-only variable: ARGC
*?*read-only variable: .K01.readonly
+*?*no such variable: .K01.scalar
+*?*no such variable: .K01.assoc
+*?*no such variable: .K01.array
+*?*no such variable: .K01.integer
+*?*no such variable: .K01.double
+*?*no such variable: .K01.float
unset -n ref
unset one
@@ -1053,6 +1070,19 @@ F:Checking for a bug in zmodload that affects later tests
>
*?*reference ref*to local variable one
+ typeset -n ref=var
+ {
+ for ref in valid1 inv@lid valid2; do typeset -p ref; done
+ } always { TRY_BLOCK_ERROR=0 }
+ typeset -nr ref=var
+ {
+ for ref in valid3 valid4; do typeset -p ref; done
+ } always { TRY_BLOCK_ERROR=0 }
+1:for-loop variable is a reference, part 5, errors
+>typeset -n ref=valid1
+*?*invalid variable name: inv@lid
+*?*read-only reference: ref
+
unset -n ref
typeset -n ref
() {
@@ -1065,13 +1095,6 @@ F:Checking for a bug in zmodload that affects later tests
>typeset -n ref=inner
*?*reference ref*to local variable inner
- typeset -n ptr='ary[$(echo 2)]'
- typeset -a ary=(one two three)
- print $ptr
-1:attempt deferred command substitution in subscript
-F:runs in `setopt noexec` so $(...) returns nothing
-*?*bad math expression: empty string
-
unset -n ref
typeset -n ref=GLOBAL
() {
@@ -1155,93 +1178,93 @@ F:previously this could create an infinite recursion and crash
e -u 0
0:assignment at different scope than declaration, -u 0
->g:1: rs=f - ra=f - rs1=f - ra1=f
->g:2: rs=f - ra=f - rs1=f - ra1=f
->h:1: rs=f - ra=f - rs1=f - ra1=f
->h:2: rs=f - ra=f - rs1=f - ra1=f
->i:1: rs=f - ra=f - rs1=f - ra1=f
->i:2: rs=f - ra=f - rs1=f - ra1=f
->j:1: rs=f - ra=f - rs1=f - ra1=f
->j:2: rs=f - ra=f - rs1=f - ra1=f
->i:3: rs=f - ra=f - rs1=f - ra1=f
->k:1: rs=f - ra=f - rs1=f - ra1=f
->k:2: rs=f - ra=f - rs1=f - ra1=f
->h:3: rs=f - ra=f - rs1=f - ra1=f
->k:1: rs=f - ra=f - rs1=f - ra1=f
->k:2: rs=f - ra=f - rs1=f - ra1=f
->g:3: rs=f - ra=f - rs1=f - ra1=f
+>g:1: rs=f - ra=f
+>g:2: rs=f - ra=f
+>h:1: rs=f - ra=f
+>h:2: rs=f - ra=f
+>i:1: rs=f - ra=f
+>i:2: rs=f - ra=f
+>j:1: rs=f - ra=f
+>j:2: rs=f - ra=f
+>i:3: rs=f - ra=f
+>k:1: rs=f - ra=f
+>k:2: rs=f - ra=f
+>h:3: rs=f - ra=f
+>k:1: rs=f - ra=f
+>k:2: rs=f - ra=f
+>g:3: rs=f - ra=f
e '' 0
0:assignment at different scope than declaration, '' 0
->g:1: rs=f - ra=f - rs1=f - ra1=f
->g:2: rs=f - ra=f - rs1=f - ra1=f
->h:1: rs=f - ra=f - rs1=f - ra1=f
->h:2: rs=f - ra=f - rs1=f - ra1=f
->i:1: rs=f - ra=f - rs1=f - ra1=f
->i:2: rs=f - ra=f - rs1=f - ra1=f
->j:1: rs=f - ra=f - rs1=f - ra1=f
->j:2: rs=f - ra=f - rs1=f - ra1=f
->i:3: rs=f - ra=f - rs1=f - ra1=f
->k:1: rs=f - ra=f - rs1=f - ra1=f
->k:2: rs=f - ra=f - rs1=f - ra1=f
->h:3: rs=f - ra=f - rs1=f - ra1=f
->k:1: rs=f - ra=f - rs1=f - ra1=f
->k:2: rs=f - ra=f - rs1=f - ra1=f
->g:3: rs=f - ra=f - rs1=f - ra1=f
+>g:1: rs=f - ra=f
+>g:2: rs=f - ra=f
+>h:1: rs=f - ra=f
+>h:2: rs=f - ra=f
+>i:1: rs=f - ra=f
+>i:2: rs=f - ra=f
+>j:1: rs=f - ra=f
+>j:2: rs=f - ra=f
+>i:3: rs=f - ra=f
+>k:1: rs=f - ra=f
+>k:2: rs=f - ra=f
+>h:3: rs=f - ra=f
+>k:1: rs=f - ra=f
+>k:2: rs=f - ra=f
+>g:3: rs=f - ra=f
e -u 2
0:assignment at different scope than declaration, -u 2
->g:1: rs= - ra= - rs1= - ra1=
->g:2: rs=f - ra=f - rs1=f - ra1=f
->h:1: rs=f - ra=f - rs1=f - ra1=f
->h:2: rs=f - ra=f - rs1=f - ra1=f
->i:1: rs=f - ra=f - rs1=f - ra1=f
->i:2: rs=f - ra=f - rs1=f - ra1=f
->j:1: rs=f - ra=f - rs1=f - ra1=f
->j:2: rs=f - ra=f - rs1=f - ra1=f
->i:3: rs=f - ra=f - rs1=f - ra1=f
->k:1: rs=f - ra=f - rs1=f - ra1=f
->k:2: rs=f - ra=f - rs1=f - ra1=f
->h:3: rs=f - ra=f - rs1=f - ra1=f
->k:1: rs=f - ra=f - rs1=f - ra1=f
->k:2: rs=f - ra=f - rs1=f - ra1=f
->g:3: rs=f - ra=f - rs1=f - ra1=f
+>g:1: rs= - ra=
+>g:2: rs=f - ra=f
+>h:1: rs=f - ra=f
+>h:2: rs=f - ra=f
+>i:1: rs=f - ra=f
+>i:2: rs=f - ra=f
+>j:1: rs=f - ra=f
+>j:2: rs=f - ra=f
+>i:3: rs=f - ra=f
+>k:1: rs=f - ra=f
+>k:2: rs=f - ra=f
+>h:3: rs=f - ra=f
+>k:1: rs=f - ra=f
+>k:2: rs=f - ra=f
+>g:3: rs=f - ra=f
e -u 6
0:assignment at different scope than declaration, -u 6
->g:1: rs= - ra= - rs1= - ra1=
->g:2: rs= - ra= - rs1= - ra1=
->h:1: rs= - ra= - rs1= - ra1=
->h:2: rs= - ra= - rs1= - ra1=
->i:1: rs= - ra= - rs1= - ra1=
->i:2: rs=f - ra=f - rs1=f - ra1=f
->j:1: rs=f - ra=f - rs1=f - ra1=f
->j:2: rs=f - ra=f - rs1=f - ra1=f
->i:3: rs=f - ra=f - rs1=f - ra1=f
->k:1: rs=f - ra=f - rs1=f - ra1=f
->k:2: rs=f - ra=f - rs1=f - ra1=f
->h:3: rs=f - ra=f - rs1=f - ra1=f
->k:1: rs=f - ra=f - rs1=f - ra1=f
->k:2: rs=f - ra=f - rs1=f - ra1=f
->g:3: rs=f - ra=f - rs1=f - ra1=f
+>g:1: rs= - ra=
+>g:2: rs= - ra=
+>h:1: rs= - ra=
+>h:2: rs= - ra=
+>i:1: rs= - ra=
+>i:2: rs=f - ra=f
+>j:1: rs=f - ra=f
+>j:2: rs=f - ra=f
+>i:3: rs=f - ra=f
+>k:1: rs=f - ra=f
+>k:2: rs=f - ra=f
+>h:3: rs=f - ra=f
+>k:1: rs=f - ra=f
+>k:2: rs=f - ra=f
+>g:3: rs=f - ra=f
e '' 6
0:assignment at different scope than declaration, '' 6
->g:1: rs= - ra= - rs1= - ra1=
->g:2: rs= - ra= - rs1= - ra1=
->h:1: rs= - ra= - rs1= - ra1=
->h:2: rs= - ra= - rs1= - ra1=
->i:1: rs= - ra= - rs1= - ra1=
->i:2: rs=i - ra=i - rs1=i - ra1=i
->j:1: rs=i - ra=i - rs1=i - ra1=i
->j:2: rs=i - ra=i - rs1=i - ra1=i
->i:3: rs=i - ra=i - rs1=i - ra1=i
->k:1: rs=i - ra=i - rs1=i - ra1=i
->k:2: rs=i - ra=i - rs1=i - ra1=i
->h:3: rs=h - ra=h - rs1=h - ra1=h
->k:1: rs=h - ra=h - rs1=h - ra1=h
->k:2: rs=h - ra=h - rs1=h - ra1=h
->g:3: rs=g - ra=g - rs1=g - ra1=g
+>g:1: rs= - ra=
+>g:2: rs= - ra=
+>h:1: rs= - ra=
+>h:2: rs= - ra=
+>i:1: rs= - ra=
+>i:2: rs=i - ra=i
+>j:1: rs=i - ra=i
+>j:2: rs=i - ra=i
+>i:3: rs=i - ra=i
+>k:1: rs=i - ra=i
+>k:2: rs=i - ra=i
+>h:3: rs=h - ra=h
+>k:1: rs=h - ra=h
+>k:2: rs=h - ra=h
+>g:3: rs=g - ra=g
f1
0:Transitive references with scoping changes
@@ -1333,125 +1356,253 @@ F:previously this could create an infinite recursion and crash
>B8: ref1=l2 ref2=l2
>B9: ref1=l1 ref2=l1
-#
-# The following two tests are linked, do not separate
-#
+ check-valid-referent-name() {
+ local -n ref=$1
+ [[ $ref = $2 ]] || echo "Unexpected expansion result: ref=$1, \$ref=$ref != $2"
+ }
+ check-invalid-variable-name() {
+ {
+ local -- $1=value-$1 2>/dev/null
+ echo "Unexpected valid variable name: $1"
+ } always {
+ TRY_BLOCK_ERROR=0
+ }
+ }
+ check-invalid-referent-name() {
+ {
+ local -n -- ref=$1 2>/dev/null
+ echo "Unexpected valid referent name: $1"
+ } always {
+ TRY_BLOCK_ERROR=0
+ }
+ }
+ local name value;
+ # Test valid variable names.
+ for name in \
+ foo foo. foo.bar foo.456 foo.4ar \
+ .foo .foo.bar .foo.456
+ do
+ local $name=value-$name
+ check-valid-referent-name "$name" value-$name
+ check-invalid-referent-name "$name"@
+ check-invalid-referent-name "$name""[1]"
+ done
+ # Test valid builtin variable names
+ for name value in 123 "" \! 0 \? 0 \$ $$ - 569X _ -n; do
+ check-valid-referent-name "$name" $value
+ check-invalid-referent-name "$name"@
+ check-invalid-referent-name "$name""[1]"
+ done
+ # Test invalid variable names.
+ for name in \
+ .foo. .foo.4ar . foo.. \
+ 123. 123.bar 123.456 123.4ar .. .foo.. \
+ .123 .123. .123.bar .123.456 .123.4ar \
+ 1oo 1oo. 1oo.bar 1oo.456 1oo.4ar \
+ .1oo .1oo. .1oo.bar .1oo.456 .1oo.4ar
+ do
+ check-invalid-variable-name "$name"
+ check-invalid-referent-name "$name"
+ check-invalid-referent-name "$name"@
+ check-invalid-referent-name "$name""[1]"
+ done
+ # Any variable name with more than one non-leading '.' is invalid.
+ for name in {,.}{foo,123,1oo}.{bar,456,4ar}.{,baz,789,7az}; do
+ check-invalid-variable-name "$name"
+ check-invalid-referent-name "$name"
+ done
+ unfunction check-valid-referent-name
+ unfunction check-invalid-variable-name
+ unfunction check-invalid-referent-name
+ unset name value
+0:references to invalid variable names
edgelocal() ( local -n x=$1; typeset -p x; print -r $x )
edgeupper() ( local -nu x=$1; typeset -p x; print -r $x )
- for edge in argv ARGC \@ \* \# 0 1 01 \! \? - _
+ for edge in argv ARGC \@ \* \# 0 00 2 02 \! \? \$ - _
do
- edgelocal $edge
- edgelocal "$edge""[1]"
- edgeupper $edge
+ edgelocal $edge foo
+ edgeupper $edge foo
done
-0:references to builtin specials
-F:Subscripting on 1 01 ! ? - should print first character but do not
+ unfunction edgelocal edgeupper
+0q:references to builtin specials
>typeset -n x=argv
->argv
->typeset -n x='argv[1]'
->argv[1]
+>argv foo
>typeset -n x=ARGC
->1
->typeset -n x='ARGC[1]'
->1
+>2
>typeset -n x=0
>edgelocal
->typeset -n x='0[1]'
->e
->typeset -n x=1
->
->typeset -n x='1[1]'
->
->typeset -n x=01
->
->typeset -n x='01[1]'
->
+>typeset -n x=00
+>edgelocal
+>typeset -n x=2
+>foo
+>typeset -n x=02
+>foo
>typeset -n x=!
>0
->typeset -n x='![1]'
->
>typeset -un x=!
>0
>typeset -n x='?'
>0
->typeset -n x='?[1]'
->
>typeset -un x='?'
>0
+>typeset -n x='$'
+>$$
+>typeset -un x='$'
+>$$
>typeset -n x=-
>569X
->typeset -n x='-[1]'
->
>typeset -un x=-
>569X
>typeset -n x=_
>x
->typeset -n x='_[1]'
->x
>typeset -un x=_
>x
-?edgeupper: invalid name reference: argv
-?edgeupper: invalid name reference: ARGC
-?edgelocal: invalid name reference: @
-?edgelocal: invalid name reference: @[1]
-?edgeupper: invalid name reference: @
-?edgelocal: invalid name reference: *
-?edgelocal: invalid name reference: *[1]
-?edgeupper: invalid name reference: *
-?edgelocal: invalid name reference: #
-?edgelocal: invalid name reference: #[1]
-?edgeupper: invalid name reference: #
-?edgeupper: invalid name reference: 0
-?edgeupper: invalid name reference: 1
-?edgeupper: invalid name reference: 01
+?edgeupper: invalid variable name: argv
+?edgeupper: invalid variable name: ARGC
+?edgelocal: invalid variable name: @
+?edgeupper: invalid variable name: @
+?edgelocal: invalid variable name: *
+?edgeupper: invalid variable name: *
+?edgelocal: invalid variable name: #
+?edgeupper: invalid variable name: #
+?edgeupper: invalid variable name: 0
+?edgeupper: invalid variable name: 00
+?edgeupper: invalid variable name: 2
+?edgeupper: invalid variable name: 02
- edgelocal \$
- edgelocal '$[1]'
- edgeupper \$
- unfunction edgelocal edgeupper
-0qf:references to $$
-F:$$[1] reference should print the first digit of $$ but prints nothing
->typeset -n x='$'
->$$
->typeset -n x='\$[1]'
->$$[1]
->$$
+ tst() {
+ typeset -n ref0=0 2>&1
+ typeset -n ref00=00 2>&1
+ typeset -n ref2=2 2>&1
+ typeset -n ref02=02 2>&1
+ echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02
+ ref0=TST
+ ref2=BBB
+ echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02
+ ref00=Tst
+ ref02=Bbb
+ echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02; typeset -p -- 0 00 2 02 2>&1
+ unset ref0
+ unset ref2
+ echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02; typeset -p -- 0 00 2 02 2>&1
+ ref0=tst
+ ref2=bbb
+ echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02; typeset -p -- 0 00 2 02 2>&1
+ { ref0=(TST TST) 2>&1 } always { TRY_BLOCK_ERROR=0 }
+ { ref2=(BBB BBB) 2>&1 } always { TRY_BLOCK_ERROR=0 }
+ echo ${(q)0} ${(q)*} - $ref0 - $ref00 - $ref2 - $ref02; typeset -p -- 0 00 2 02 2>&1
+ typeset -n ref5=5 2>&1
+ ref5=zzz
+ echo ${(q)0} ${(q)*}
+ unset ref2
+ echo ${(q)0} ${(q)*}
+ unset ref2
+ echo ${(q)0} ${(q)*}
+ unset ref2
+ echo ${(q)0} ${(q)*}
+ unset ref2
+ echo ${(q)0} ${(q)*}
+ unset ref2
+ echo ${(q)0} ${(q)*}
+ }
+ tst aaa bbb ccc
+ unfunction tst
+0:references to positional parameters
+>tst aaa bbb ccc - tst - tst - bbb - bbb
+>TST aaa BBB ccc - TST - TST - BBB - BBB
+>Tst aaa Bbb ccc - Tst - Tst - Bbb - Bbb
+>tst:typeset:11: no such variable: 00
+>tst:typeset:11: no such variable: 2
+>tst:typeset:11: no such variable: 02
+>typeset -g 0=Tst
+>Tst aaa ccc - Tst - Tst - ccc - ccc
+>tst:typeset:14: no such variable: 00
+>tst:typeset:14: no such variable: 2
+>tst:typeset:14: no such variable: 02
+>typeset -g 0=Tst
+>tst aaa bbb - tst - tst - bbb - bbb
+>tst:typeset:17: no such variable: 00
+>tst:typeset:17: no such variable: 2
+>tst:typeset:17: no such variable: 02
+>typeset -g 0=tst
+>tst:18: 0: attempt to assign array value to non-array
+>tst:19: 2: attempt to assign array value to non-array
+>tst aaa bbb - tst - tst - bbb - bbb
+>tst:typeset:20: no such variable: 00
+>tst:typeset:20: no such variable: 2
+>tst:typeset:20: no such variable: 02
+>typeset -g 0=tst
+>tst aaa bbb '' '' zzz
+>tst aaa '' '' zzz
+>tst aaa '' zzz
+>tst aaa zzz
+>tst aaa
+>tst aaa
#
-# The following tests are run in interactive mode, using PS1 as an
+# The following tests are run in interactive mode, using PS3 as an
# assignable special with side-effects. This crashed at one time.
#
# Note bypassing TYPESET_TO_UNSET here
- $ZTST_testdir/../Src/zsh -fis <<<$'
- typeset -n p=PS1
- () {
- typeset -p p
- local p
- typeset -p p
- p=xx
- typeset -p p
- }
+ PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
+ typeset -n p=PS3
+ () {
+ typeset -p p
+ local p
+ typeset -p p
+ p=xx
+ typeset -p p
+ }
'
0:regression: assign to local that shadows global named reference
->typeset -g -n p=PS1
+>typeset -g -n p=PS3
>typeset p=''
>typeset p=xx
-*?*
# Note bypassing TYPESET_TO_UNSET here
- $ZTST_testdir/../Src/zsh -fis <<<$'
- () {
- typeset p=PS1
- typeset -n p
- p=zz
- }
- typeset -p PS1
+ PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
+ () {
+ typeset p=PS3
+ typeset -n p
+ p=zz
+ }
+ typeset -p PS3
'
0:regression - converting a string into a named reference
->typeset PS1=zz
-*?*
+>typeset PS3=zz
+
+# Testing named directories requires to run in interactive mode
+
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ [[ -d Modules/zsh ]] && module_path=( $PWD/Modules )
+ typeset v1=/1 v2
+ typeset -n r1=v1 r2
+ { echo "~v1:" ~v1 } 2>&1
+ { echo "~r1:" ~r1 } 2>&1
+ echo "nameddirs=( ${(kv)nameddirs} )"
+ r1=/A
+ echo "nameddirs=( ${(kv)nameddirs} )"
+ hash -d v2=/2 r2=/R
+ echo "nameddirs=( ${(kv)nameddirs} )"
+ setopt autonamedirs
+ v2=V2
+ echo "nameddirs=( ${(kv)nameddirs} )"
+ r2=v2
+ echo "nameddirs=( ${(kv)nameddirs} )"
+ r2=/B
+ echo "nameddirs=( ${(kv)nameddirs} )"
+ '
+0:Only string parameters are promoted to named directories
+>~v1: /1
+>zsh: no such user or named directory: r1
+>nameddirs=( v1 /1 )
+>nameddirs=( v1 /A )
+>nameddirs=( v1 /A v2 /2 r2 /R )
+>nameddirs=( v1 /A r2 /R )
+>nameddirs=( v1 /A r2 /R )
+>nameddirs=( v1 /A v2 /B r2 /R )
unset var1 var2
typeset -n ref1=var1
@@ -1485,22 +1636,7 @@ F:$$[1] reference should print the first digit of $$ but prints nothing
zmodload -u zsh/random
echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*}
echo v=${ref/<->/integer}
-0:Referring and dereferring an autoload variable loads it (direct)
->z=SRANDOM (zsh/random)
->z=
->v=integer
->z=SRANDOM (zsh/random)
->v=integer
-
- zmodload -u zsh/random
- echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*}
- typeset -n ref=SRANDOM[1,20]
- echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*}
- echo v=${ref/<->/integer}
- zmodload -u zsh/random
- echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*}
- echo v=${ref/<->/integer}
-0:Referring and dereferring an autoload variable loads it (subscript)
+0:Referring and dereferring an autoload variable loads it
>z=SRANDOM (zsh/random)
>z=
>v=integer
@@ -1514,21 +1650,7 @@ F:$$[1] reference should print the first digit of $$ but prints nothing
typeset -h SRANDOM=local-variable
echo v=${ref/<->/integer}
echo NOT REACHED
-1:Dereferring an autoload variable fails to load it if its hidden (direct)
->v=integer
->z=SRANDOM (zsh/random)
-?(eval):6: Can't add module parameter `SRANDOM': local parameter exists
-?(eval):zsh/random:6: error when adding parameter `SRANDOM'
-?(eval):6: autoloading module zsh/random failed to define parameter: SRANDOM
-
- typeset -n ref=SRANDOM[1,20]
- echo v=${ref/<->/integer}
- zmodload -u zsh/random
- echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*}
- typeset -h SRANDOM=local-variable
- echo v=${ref/<->/integer}
- echo NOT REACHED
-1:Dereferring an autoload variable fails to load it if its hidden (subscript)
+1:Dereferring an autoload variable fails to load it if its hidden
>v=integer
>z=SRANDOM (zsh/random)
?(eval):6: Can't add module parameter `SRANDOM': local parameter exists
@@ -1747,10 +1869,6 @@ F:converting from association/array to string should work here too
1:regression: reference loop with same name enclosing variable
?(anon):3: ptr2: invalid self reference
- typeset -n ref=ref[1]
-1:self reference with subscript
-*?*: ref: invalid self reference
-
typeset var=foo
typeset -n ref=var
() {
@@ -1933,6 +2051,220 @@ F:converting from association/array to string should work here too
># d:reference to not-yet-defined - local - ref1
>typeset -i var=42
+ test-unset() {
+ typeset var0=foo
+ typeset -n ref1=var0 ref2=ref1
+ typeset cmd=(unset $@); echo "#" $cmd; $cmd
+ typeset -p var0 ref1 ref2
+ }
+ test-unset -n ref1
+ test-unset -n ref2
+ test-unset -n -m ref1
+ test-unset -n -m ref2
+ unfunction test-unset
+0:unsetting references with -n unsets the references
+># unset -n ref1
+>typeset var0=foo
+>typeset -n ref2=ref1
+># unset -n ref2
+>typeset var0=foo
+>typeset -n ref1=var0
+># unset -n -m ref1
+>typeset var0=foo
+>typeset -n ref2=ref1
+># unset -n -m ref2
+>typeset var0=foo
+>typeset -n ref1=var0
+
+ test-unset() {
+ typeset var0=foo
+ typeset -n ref1=var0 ref2=ref1
+ typeset cmd=(unset $@); echo "#" $cmd; $cmd
+ typeset -p var0 ref1 ref2
+ }
+ test-unset ref1
+ test-unset ref2
+ test-unset -m ref1
+ test-unset -m ref2
+ unfunction test-unset
+0:unsetting references without -n unsets the referred parameters
+># unset ref1
+>typeset -n ref1=var0
+>typeset -n ref2=ref1
+># unset ref2
+>typeset -n ref1=var0
+>typeset -n ref2=ref1
+># unset -m ref1
+>typeset -n ref1=var0
+>typeset -n ref2=ref1
+># unset -m ref2
+>typeset -n ref1=var0
+>typeset -n ref2=ref1
+
+ test-unset() {
+ typeset var0=12345
+ typeset -n ref1=var0 ref2=ref1
+ typeset cmd=(unset $@); echo "#" $cmd; $cmd
+ typeset -p var0
+ }
+ test-unset ref1"[3]"
+ test-unset ref2"[3]"
+ test-unset -n ref1"[3]"
+ test-unset -n ref2"[3]"
+ unfunction test-unset
+0:unsetting subscripted references unsets the referred elements
+># unset ref1[3]
+>typeset var0=1245
+># unset ref2[3]
+>typeset var0=1245
+># unset -n ref1[3]
+>typeset var0=1245
+># unset -n ref2[3]
+>typeset var0=1245
+
+ test-unset() {
+ typeset -r var=foo
+ typeset -n ref=var
+ typeset cmd=(unset $@); echo "#" $cmd; { $cmd 2>&1 } always { TRY_BLOCK_ERROR=0 }
+ typeset -p var
+ }
+ test-unset var
+ test-unset -m var
+ test-unset ref
+ test-unset -m ref
+ test-unset var"[2]"
+ test-unset ref"[2]"
+ test-unset -n ref"[2]"
+ unfunction test-unset
+0:unsetting read-only parameter triggers an error
+># unset var
+>test-unset:3: read-only variable: var
+>typeset -r var=foo
+># unset -m var
+>test-unset:3: read-only variable: var
+>typeset -r var=foo
+># unset ref
+>test-unset:3: read-only variable: var
+>typeset -r var=foo
+># unset -m ref
+>test-unset:3: read-only variable: var
+>typeset -r var=foo
+># unset var[2]
+>test-unset:3: read-only variable: var
+>typeset -r var=foo
+># unset ref[2]
+>test-unset:3: read-only variable: var
+>typeset -r var=foo
+># unset -n ref[2]
+>test-unset:3: read-only variable: var
+>typeset -r var=foo
+
+ test-unset() {
+ typeset -n ref1 ref2=ref1
+ typeset cmd=(unset $@); echo "#" $cmd; $cmd
+ typeset -p ref1 ref2
+ }
+ test-unset ref1
+ test-unset ref2
+ test-unset -m ref1
+ test-unset -m ref2
+ unfunction test-unset
+0:unsetting placeholder references or their referents has no effect
+># unset ref1
+>typeset -n ref1
+>typeset -n ref2=ref1
+># unset ref2
+>typeset -n ref1
+>typeset -n ref2=ref1
+># unset -m ref1
+>typeset -n ref1
+>typeset -n ref2=ref1
+># unset -m ref2
+>typeset -n ref1
+>typeset -n ref2=ref1
+
+ test-unset() {
+ typeset -n ref1=undefined ref2=ref1
+ typeset cmd=(unset $@); echo "#" $cmd; $cmd
+ typeset -p ref1 ref2
+ }
+ typeset -p undefined 2>&1
+ test-unset ref1
+ test-unset ref2
+ test-unset -m ref1
+ test-unset -m ref2
+ unfunction test-unset
+0:unsetting references to not-yet-defined variables or their referents has no effect
+>(eval):typeset:6: no such variable: undefined
+># unset ref1
+>typeset -n ref1=undefined
+>typeset -n ref2=ref1
+># unset ref2
+>typeset -n ref1=undefined
+>typeset -n ref2=ref1
+># unset -m ref1
+>typeset -n ref1=undefined
+>typeset -n ref2=ref1
+># unset -m ref2
+>typeset -n ref1=undefined
+>typeset -n ref2=ref1
+
+ test-unset() {
+ typeset -n refg1=g1 refl1=l1
+ () {
+ typeset -g g1=glb1 g2=glb2
+ typeset l1=lcl1 l2=lcl2
+ () {
+ typeset -n refg2=g2 refl2=l2
+ typeset cmd=(unset $@ refg1 refg2 refl1 refl2); echo "#" $cmd; $cmd
+ } $@
+ typeset -p g1 g2 l1 l2 2>&1
+ } $@
+ unset g1 g2
+ }
+ test-unset
+ test-unset -m
+ unfunction test-unset
+0:unsetting references referring to parameters in enclosing scopes unsets the parameters
+># unset refg1 refg2 refl1 refl2
+>(anon):typeset:7: no such variable: g1
+>(anon):typeset:7: no such variable: g2
+># unset -m refg1 refg2 refl1 refl2
+>(anon):typeset:7: no such variable: g1
+>(anon):typeset:7: no such variable: g2
+
+ test-unset() {
+ typeset -g g=glb
+ typeset l=lcl
+ typeset -n refg=g refl=l
+ () {
+ typeset g=hide-g
+ typeset l=hide-l
+ typeset cmd=(unset $@ refg refl); echo "#" $cmd; $cmd
+ echo "# inner scope"
+ typeset -p g l 2>&1
+ } $@
+ echo "# outer scope"
+ typeset -p g l 2>&1
+ unset g
+ }
+ test-unset
+ test-unset -m
+ unfunction test-unset
+0:unsetting references referring to hidden parameters unsets the hidden parameters
+># unset refg refl
+># inner scope
+>typeset g=hide-g
+>typeset l=hide-l
+># outer scope
+>test-unset:typeset:12: no such variable: g
+># unset -m refg refl
+># inner scope
+>typeset g=hide-g
+>typeset l=hide-l
+># outer scope
+>test-unset:typeset:12: no such variable: g
+
typeset -n ref1
typeset -n ref2
typeset -n ref3=ref2
diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst
index daf49cd72..ec55e0f95 100644
--- a/Test/V01zmodload.ztst
+++ b/Test/V01zmodload.ztst
@@ -236,6 +236,17 @@
fi
0d:Autoload a module via a math function
+ if [[ $mods[(r)zsh/watch] == zsh/watch ]]; then
+ zmodload -u zsh/watch
+ WATCH=foo:bar
+ typeset -p WATCH watch
+ else
+ ZTST_skip="zsh/watch module not available"
+ fi
+0:Autoload tied parameters
+>typeset -g -T WATCH watch=( foo bar )
+>typeset -g -aT WATCH watch=( foo bar )
+
# Test module aliases
zmodload -A example=zsh/example
diff --git a/Test/V06parameter.ztst b/Test/V06parameter.ztst
index 27d587852..c1f47a9dc 100644
--- a/Test/V06parameter.ztst
+++ b/Test/V06parameter.ztst
@@ -92,6 +92,25 @@
>foo
>bar
+ for 1 in hash_cmds no_hash_cmds; do
+ (
+ setopt no_hash_list_all $1
+ : > ls
+ chmod +x ls
+ rm=$commands[rm]
+ path=( $PWD )
+ rehash
+ a=$commands[ls]
+ $rm ls
+ b=$commands[ls]
+ [[ $a == $b ]]
+ print -r - $? $a:$b
+ )
+ done
+-:workers/54617: $commands look-up with no_hash_list_all
+*>0 */ls:*/ls
+*>1 */ls:
+
%clean
rm -f autofn functrace.zsh rocky3.zsh sourcedfile myfunc
diff --git a/Test/V09datetime.ztst b/Test/V09datetime.ztst
index 0eae31687..cbf6967b0 100644
--- a/Test/V09datetime.ztst
+++ b/Test/V09datetime.ztst
@@ -79,8 +79,8 @@
>1973^@03^@03
# We assume '%@' is not a valid format on any OSs.
-# The result can be '%@' (Linux), '@' (BSDs) or an error (Cygwin).
- [[ $(strftime '%@' 0 2> /dev/null) == (%|)@ || $? != 0 ]]
+# The result can be '%@' (Linux), '@' (BSDs), '' (musl), or an error (Cygwin).
+ [[ $(strftime '%@' 0 2> /dev/null) == ((%|)@|) || $? != 0 ]]
0:bad format specifier
# This test may fail at 23:59:59.xxx on New Year's Eve :/
diff --git a/Test/V11db_gdbm.ztst b/Test/V11db_gdbm.ztst
index 6d74cef2c..1ac9fc0c2 100644
--- a/Test/V11db_gdbm.ztst
+++ b/Test/V11db_gdbm.ztst
@@ -204,34 +204,67 @@
local -a dbase
dbase=( fromarray )
() {
- local -a dbase
+ local dbase
+ () {
ztie -d db/gdbm -f $dbfile dbase
- echo ${(t)dbase}
- zuntie dbase
+ echo "Connected:" $dbase[a]
+ }
+ echo "Still connected:" $dbase[a]
}
echo $dbase[1]
ztie -d db/gdbm -f $dbfile dbase2
echo "Can connect, so untie happened:" $dbase2[a]
zuntie dbase2
0:Test of automatic untie (use of local scope) and of scoping
->association-local-special
+>Connected: b
+>Still connected: b
>fromarray
>Can connect, so untie happened: b
+ local dbase
+ () {
+ local -n rbase=dbase
+ local dbase=not-a-dbase
+ ztie -d db/gdbm -f $dbfile rbase
+ echo $dbase
+ echo "Connected:" $rbase[a]
+ zuntie rbase
+ echo "Disconnected:" $rbase[a]
+ ztie -d db/gdbm -f $dbfile rbase
+ echo "Reconnected:" $rbase[a]
+ echo $dbase
+ }
+ echo "Still connected:" $dbase[a]
+ zuntie dbase
+0:Test of tie to hidden local via named reference
+>not-a-dbase
+>Connected: b
+>Disconnected:
+>Reconnected: b
+>not-a-dbase
+>Still connected: b
+
echo $zgdbm_tied ${#zgdbm_tied}
ztie -r -d db/gdbm -f $dbfile dbase
echo $zgdbm_tied ${#zgdbm_tied}
ztie -d db/gdbm -f ${dbfile}2 dbase2
echo $zgdbm_tied ${#zgdbm_tied}
+ local -n rbase3=dbase3
+ ztie -d db/gdbm -f ${dbfile}3 rbase3
+ echo $zgdbm_tied ${#zgdbm_tied}
zuntie -u dbase
echo $zgdbm_tied ${#zgdbm_tied}
zuntie dbase2
echo $zgdbm_tied ${#zgdbm_tied}
+ zuntie rbase3
+ echo $zgdbm_tied ${#zgdbm_tied}
0:zgdbm_tied parameter
>0
>dbase 1
>dbase dbase2 2
->dbase2 1
+>dbase dbase2 dbase3 3
+>dbase2 dbase3 2
+>dbase3 1
>0
unset zgdbm_tied 2>/dev/null
@@ -311,9 +344,15 @@
zgdbmpath dbase
[[ $REPLY = */Test/db.gdbm ]] && echo correct
zuntie -u dbase
+ local -n rbase=dbase
+ ztie -r -d db/gdbm -f $dbfile rbase
+ zgdbmpath rbase
+ [[ $REPLY = */Test/db.gdbm ]] && echo correct
+ zuntie -u rbase
0:zgdbmpath builtin
>correct
>correct
+>correct
ztie -d db/gdbm -f $dbfile dbase
fun() { while read line; do echo $line; done }
diff --git a/Test/V12zparseopts.ztst b/Test/V12zparseopts.ztst
index 5736dd3a1..ede45eb7e 100644
--- a/Test/V12zparseopts.ztst
+++ b/Test/V12zparseopts.ztst
@@ -17,6 +17,35 @@
%test
+ () { zparseopts -D -F ''; print -r - ${(q+)@} } - foo
+ () { zparseopts -D -F ''; print -r - ${(q+)@} } -x
+ () { zparseopts -D -F - ''; print -r - ${(q+)@} } - foo
+ () { zparseopts -D -F - ''; print -r - ${(q+)@} } -x
+ () { zparseopts -D -F - -; print -r - ${(q+)@} } - foo
+ () { zparseopts -D -F - -; print -r - ${(q+)@} } -x
+0:zparseopts with empty option spec (no options recognised)
+>foo
+?(anon): bad option: -x
+>-x
+>foo
+?(anon): bad option: -x
+>-x
+>foo
+?(anon): bad option: -x
+>-x
+
+ () { zparseopts -F -- } -x
+ () { zparseopts -F - } -x
+ () { zparseopts -F - a } -x
+ () { zparseopts -F - a } -x
+ () { zparseopts -F a } -x
+1:zparseopts without option specs, without array
+?(anon):zparseopts: missing option descriptions
+?(anon):zparseopts: missing option descriptions
+?(anon):zparseopts: no default array defined: a
+?(anon):zparseopts: no default array defined: a
+?(anon):zparseopts: no default array defined: a
+
() {
local -a optv
zparseopts -a optv - a b: c:- z
@@ -65,15 +94,15 @@
} $=1
done
0:zparseopts -F
-?(anon):zparseopts:2: bad option: -x
+?(anon): bad option: -x
>ret: 1, optv: , argv: -a -x -z
-?(anon):zparseopts:2: bad option: -x
+?(anon): bad option: -x
>ret: 1, optv: , argv: -ax -z
-?(anon):zparseopts:2: bad option: --x
+?(anon): bad option: --x
>ret: 1, optv: , argv: -a --x -z
-?(anon):zparseopts:2: bad option: -x
+?(anon): bad option: -x
>ret: 1, optv: , argv: -axy
-?(anon):zparseopts:2: bad option: --
+?(anon): bad option: --
>ret: 1, optv: , argv: -a-xy
for 1 in '-a 1 2 3' '1 2 3'; do
@@ -98,13 +127,20 @@
>ret: 0, opts: -a '' -b 1 -z '', argv: 1 2 3
>ret: 0, opts: -b 1 -z '', argv: 1 2 3
- () {
+ fn() {
local -a optv
local -A opts
zparseopts -D -M -a optv -A opts - a:=-aaa -aaa:
print -r - ret: $?, optv: $optv, opts: "$( order_assoc opts )", argv: $argv
- } --aaa foo -a bar 1 2 3
+ }
+ fn -a foo 1 2 3
+ fn --aaa foo 1 2 3
+ fn --aaa foo -a bar 1 2 3
+ fn -a foo --aaa bar 1 2 3
0:zparseopts -M
+>ret: 0, optv: -a foo, opts: --aaa foo, argv: 1 2 3
+>ret: 0, optv: --aaa foo, opts: --aaa foo, argv: 1 2 3
+>ret: 0, optv: -a bar, opts: --aaa bar, argv: 1 2 3
>ret: 0, optv: --aaa bar, opts: --aaa bar, argv: 1 2 3
() {
@@ -218,7 +254,7 @@
print -r - ret: $?, optv: $optv, argv: $argv
} -ab1 -c
0:missing optarg
-?(anon):zparseopts:2: missing argument for option: -c
+?(anon): missing argument for option: -c
>ret: 1, optv: , argv: -ab1 -c
for spec in -foo: -foo:- -foo::; do
@@ -253,11 +289,11 @@
} --foobar 1 2 3
done
0:zparseopts -G, single parameter, without =
-?(anon):zparseopts:2: bad option: --foobar
+?(anon): bad option: --foobar
>ret: 1, optv: , argv: --foobar 1 2 3
-?(anon):zparseopts:2: bad option: --foobar
+?(anon): bad option: --foobar
>ret: 1, optv: , argv: --foobar 1 2 3
-?(anon):zparseopts:2: bad option: --foobar
+?(anon): bad option: --foobar
>ret: 1, optv: , argv: --foobar 1 2 3
for spec in -foo: -foo:- -foo::; do
@@ -352,15 +388,15 @@
>ret: 0, gopt: , optv: -foobar, argv: 1 2 3
>ret: 0, gopt: , optv: -foo=bar, argv: 1 2 3
>ret: 0, gopt: , optv: -foobar, argv: 1 2 3
-?(anon):zparseopts:2: bad option: -f
+?(anon): bad option: -f
>ret: 1, gopt: -G, optv: , argv: -foobar 1 2 3
>ret: 0, gopt: -G, optv: -foo bar, argv: 1 2 3
>ret: 0, gopt: -G, optv: -foo bar, argv: 1 2 3
-?(anon):zparseopts:2: bad option: -f
+?(anon): bad option: -f
>ret: 1, gopt: -G, optv: , argv: -foobar 1 2 3
>ret: 0, gopt: -G, optv: -foo=bar, argv: 1 2 3
>ret: 0, gopt: -G, optv: -foo=bar, argv: 1 2 3
-?(anon):zparseopts:2: bad option: -f
+?(anon): bad option: -f
>ret: 1, gopt: -G, optv: , argv: -foobar 1 2 3
>ret: 0, gopt: -G, optv: -foo=bar, argv: 1 2 3
>ret: 0, gopt: -G, optv: -foo=, argv: bar 1 2 3
@@ -382,10 +418,78 @@
done
done
0:only -- acts as explicit parsing terminator with -G
-?(anon):zparseopts:2: bad option: --baz
+?(anon): bad option: --baz
>ret: 1, term: -, optv: , argv: --foo x --bar - --baz
>ret: 0, term: -, gopt: , optv: --foo, argv: --bar
>ret: 0, term: -, gopt: -G, optv: --foo, argv: - --bar
>ret: 0, term: --, optv: --foo --bar, argv: x -- --baz
>ret: 0, term: --, gopt: , optv: --foo, argv: --bar
>ret: 0, term: --, gopt: -G, optv: --foo, argv: --bar
+
+ fn1() {
+ zparseopts -F - a
+ }
+ fn2() {
+ local -a optv
+ zparseopts -a optv -F - a
+ }
+ fn3() {
+ local -a optv
+ zparseopts -a optv -nprog -F - a
+ zparseopts -a optv -n prog -F - a
+ }
+ fn1 -x
+ fn2 -x
+ fn3 -x
+1:zparseopts -n, internal vs external usage errors
+?fn1:zparseopts:1: no default array defined: a
+?fn2: bad option: -x
+?prog: bad option: -x
+?prog: bad option: -x
+
+ () { zparseopts -DF - '' } -x
+ () {
+ local -a optv
+ zparseopts -DFa optv - a
+ typeset -p optv
+ } -a
+0:zparseopts option stacking
+?(anon): bad option: -x
+>typeset -a optv=( -a )
+
+ () {
+ local -a optv
+ zparseopts -DFa optv -x
+ }
+ () {
+ local -a optv
+ zparseopts -DFa optv - -D
+ typeset -p optv
+ } --D
+ () {
+ local -a optv
+ zparseopts -DFa optv - -DFa
+ typeset -p optv
+ } --DFa
+0:zparseopts long-option spec guarding
+?(anon):zparseopts:2: bad option: -x
+>typeset -a optv=( --D )
+>typeset -a optv=( --DFa )
+
+ () { zparseopts -a }
+ () { zparseopts -A }
+ () { zparseopts -n }
+ () { zparseopts -v }
+ () { zparseopts -a '' }
+ () { zparseopts -A '' }
+ () { zparseopts -n '' }
+ () { zparseopts -v '' }
+1:zparseopts missing/empty optargs
+?(anon):zparseopts: argument expected: -a
+?(anon):zparseopts: argument expected: -A
+?(anon):zparseopts: argument expected: -n
+?(anon):zparseopts: argument expected: -v
+?(anon):zparseopts: missing array name for -a
+?(anon):zparseopts: missing array name for -A
+?(anon):zparseopts: missing program name for -n
+?(anon):zparseopts: missing array name for -v
diff --git a/Test/V13zformat.ztst b/Test/V13zformat.ztst
index 035a0a495..72c4229a1 100644
--- a/Test/V13zformat.ztst
+++ b/Test/V13zformat.ztst
@@ -89,3 +89,251 @@
>ipsum.bar
>bazbaz
>\esc:ape
+
+ zformat REPLY ''
+ zformat REPLY '' x:
+1:one of -f -F -a required
+?(eval):zformat:1: one of -afF expected
+?(eval):zformat:2: one of -afF expected
+
+ zformat -fff REPLY ''
+ zformat -FFF REPLY ''
+ zformat -aaa reply .
+0:duplicate -f -F -a ignored
+
+ zformat -af REPLY ''
+ zformat -fF REPLY '' x:
+1:more than one of -f -F -a not allowed
+?(eval):zformat:1: only one of -afF allowed
+?(eval):zformat:2: only one of -afF allowed
+
+ zformat -f
+ zformat -f REPLY
+ zformat -F
+ zformat -F REPLY
+1:-f and -F: param and format string required
+?(eval):zformat:1: not enough arguments
+?(eval):zformat:2: not enough arguments
+?(eval):zformat:3: not enough arguments
+?(eval):zformat:4: not enough arguments
+
+ zformat -a
+ zformat -a reply
+1:-a: param and separator required
+?(eval):zformat:1: not enough arguments
+?(eval):zformat:2: not enough arguments
+
+ zformat -a reply '' a:b && print -rl - $reply
+0:-a with empty separator
+>ab
+
+ zformat -F REPLY '<%1d>' 'd:é' && print -r - $REPLY
+ zformat -F REPLY '<%2d>' 'd:é' && print -r - $REPLY
+ zformat -F REPLY '<%3d>' 'd:é' && print -r - $REPLY
+ zformat -F REPLY '<%.1d>' 'd:é' && print -r - $REPLY
+ zformat -F REPLY '<%.2d>' 'd:é' && print -r - $REPLY
+ zformat -F REPLY '<%.3d>' 'd:é' && print -r - $REPLY
+0f:width specifier is multi-byte-aware
+><é>
+><é >
+><é >
+><é>
+><é>
+><é>
+
+ zformat -F REPLY %B && print -r - $REPLY
+ zformat -F REPLY %3B && print -r - $REPLY
+0:sequence with no matching spec falls through
+>%B
+>%3B
+
+ for 1 in - . 0 9; do
+ REPLY1= REPLY2=
+ zformat -F REPLY1 %$1
+ zformat -F REPLY2 %1$1
+ zformat -F REPLY3 %1%$1
+ print -r - $REPLY1 $REPLY2 $REPLY3
+ done
+0:impossible spec in format string
+>%- %1- %1%-
+>%. %1. %1%.
+>%0 %10 %1%0
+>%9 %19 %1%9
+
+ # extra char at end to avoid triggering premature eos condition
+ zformat -F REPLY '%% %3% %) %3) x'
+ print -r - $REPLY
+0:%% and %) in format string
+>% %3% ) %3) x
+
+ for 1 in % %% %%% %%%% %%%%% %%%%%%; do
+ zformat -F REPLY $1 &&
+ print -r - $REPLY
+ done
+0:more literal % in format string
+>%
+>%
+>%%
+>%%
+>%%%
+>%%%
+
+ for 1 in % \) - . 0 9 ''; do
+ zformat -F REPLY '' $1:
+ done
+1:spec with invalid char
+?(eval):zformat:2: invalid spec: %:
+?(eval):zformat:2: invalid spec: ):
+?(eval):zformat:2: invalid spec: -:
+?(eval):zformat:2: invalid spec: .:
+?(eval):zformat:2: invalid spec: 0:
+?(eval):zformat:2: invalid spec: 9:
+?(eval):zformat:2: invalid spec: :
+
+ zformat -F REPLY '' ab:
+ zformat -F REPLY '' é:
+-:spec char longer than 1 byte
+?(eval):zformat:1: invalid spec: ab:
+?(eval):zformat:2: invalid spec: \M-C\M-):
+
+ for 1 in ! $ + , : \; \\ $'\a' $'\xff'; do
+ zformat -F REPLY "<%$1>" $1:$1 &&
+ print -r - ${(V)REPLY}
+ done
+0:weird spec char
+><!>
+><$>
+><+>
+><,>
+><:>
+><;>
+><\>
+><^G>
+><\M-^?>
+
+ zformat -F REPLY '%(' &&
+ print -r - $REPLY
+0:%( at end of format string
+>%(
+
+ zformat -F REPLY '%(.'
+ zformat -F REPLY '%()'
+ zformat -F REPLY '%(..)'
+ zformat -F REPLY '<%(>'
+1:incomplete ternary expression
+?(eval):zformat:1: malformed format string: %(.
+?(eval):zformat:2: malformed format string: %()
+?(eval):zformat:3: malformed format string: %(..)
+?(eval):zformat:4: malformed format string: <%(>
+
+ for 1 in % - . 0 9; do
+ zformat -F REPLY "%($1.true.false)" &&
+ print -r - $REPLY
+ done
+1:ternary expression with impossible spec char
+>false
+?(eval):zformat:2: malformed format string: %(-.true.false)
+>false
+?(eval):zformat:2: malformed format string: %(0.true.false)
+?(eval):zformat:2: malformed format string: %(9.true.false)
+
+ for 1 in ! / : @; do
+ zformat -F REPLY "%(x${1}true${1}false)" &&
+ print -r - $REPLY
+ done
+0:ternary expression with alternate delimiters
+>false
+>false
+>false
+>false
+
+ zformat -F REPLY '%(x.%t.%f)' x:123 t:true f:false && print -r - $REPLY
+ zformat -F REPLY '%(X.%t.%f)' x:123 t:true f:false && print -r - $REPLY
+0:ternary expression returning matching spec
+>true
+>false
+
+ zformat -F REPLY '%(x.%T.%F)' x:123 && print -r - $REPLY
+ zformat -F REPLY '%(X.%T.%F)' x:123 && print -r - $REPLY
+0:ternary expression returning non-matching spec
+>%T
+>%F
+
+ zformat -F REPLY '%(x/%../%--)' x:123 && print -r - $REPLY
+ zformat -F REPLY '%(X/%../%--)' x:123 && print -r - $REPLY
+ zformat -F REPLY '%(X.%1%-.%2%-)' x:123 && print -r - $REPLY
+0:ternary expression returning impossible spec
+>%..
+>%--
+>%2%-
+
+ zformat -F REPLY '%(x.%%.%))' x:123 && print -r - $REPLY
+ zformat -F REPLY '%(X.%%.%))' x:123 && print -r - $REPLY
+0:ternary expression returning literal % or )
+>%
+>)
+
+ zformat -qa reply .
+ zformat -aq reply .
+ zformat -aQ reply .
+1:-a + -qQ not allowed
+?(eval):zformat:1: -qQ not allowed with -a
+?(eval):zformat:2: -qQ not allowed with -a
+?(eval):zformat:3: -qQ not allowed with -a
+
+ zformat -Fq REPLY F && print -r - $REPLY
+ zformat -qF REPLY F && print -r - $REPLY
+ zformat -FqF REPLY F && print -r - $REPLY
+ zformat -qqF REPLY F && print -r - $REPLY
+ zformat -qQF REPLY F && print -r - $REPLY
+1:more than one of -qQ not allowed
+>F
+>F
+>F
+>F
+?(eval):zformat:5: only one of -qQ allowed
+
+ for 1 in -F -FQ -Fq; do
+ zformat $1 REPLY '%a, %b, %c, %d, %%e' a:%aaa% %b:%bbb% %%c:%ccc%
+ print -r - $REPLY
+ done
+0:spec quoting indicators, -Q vs -q
+>%aaa%, %%bbb%%, %ccc%, %d, %e
+>%%aaa%%, %%bbb%%, %ccc%, %d, %e
+>%%aaa%%, %%bbb%%, %ccc%, %d, %%e
+
+ zformat -Fq REPLY '%(x.%%/%d.%%/%D)' x:1 d:%foo% D:%bar% && print -r - $REPLY
+ zformat -Fq REPLY '%(X.%%/%d.%%/%D)' x:1 d:%foo% D:%bar% && print -r - $REPLY
+0:-q with ternary expression
+>%%/%%foo%%
+>%%/%%bar%%
+
+ zformat -Fq REPLY '<%1d>' d:%foo% && print -r - $REPLY
+ zformat -Fq REPLY '<%5d>' d:%foo% && print -r - $REPLY
+ zformat -Fq REPLY '<%6d>' d:%foo% && print -r - $REPLY
+ zformat -Fq REPLY '<%7d>' d:%foo% && print -r - $REPLY
+ zformat -Fq REPLY '<%-7d>' d:%foo% && print -r - $REPLY
+ zformat -Fq REPLY '<%-7d>' d:foo && print -r - $REPLY
+0:-q: min-width specifier ignores extra %s
+><%%foo%%>
+><%%foo%%>
+><%%foo%% >
+><%%foo%% >
+>< %%foo%%>
+>< foo>
+
+ zformat -Fq REPLY '%.1d' d:foo && print -r - $REPLY
+ zformat -Fq REPLY '%.1d' d:%foo% && print -r - $REPLY
+ zformat -Fq REPLY '%.4d' d:%foo% && print -r - $REPLY
+ zformat -Fq REPLY '%.5d' d:%foo% && print -r - $REPLY
+0:-q: max-width specifier ignores extra %s
+>f
+>%%
+>%%foo
+>%%foo%%
+
+ zformat -Fq REPLY '%4(d.t.f) %5(d.t.f) %6(d.t.f)' d:%foo% && print -r - $REPLY
+ zformat -Fq REPLY '%-6(d.t.f) %-5(d.t.f) %-4(d.t.f)' d:%foo% && print -r - $REPLY
+0:-q: ternary width test ignores extra %s
+>t f f
+>t t f
diff --git a/Test/V15nearcolor.ztst b/Test/V15nearcolor.ztst
new file mode 100644
index 000000000..52c6ab2f1
--- /dev/null
+++ b/Test/V15nearcolor.ztst
@@ -0,0 +1,100 @@
+# tests for the zsh/nearcolor module
+
+%prep
+
+ if ! zmodload -s zsh/nearcolor; then
+ ZTST_unimplemented='the zsh/nearcolor module is not available'
+ elif ! zmodload -s zsh/terminfo; then
+ ZTST_unimplemented='the zsh/terminfo module is not available'
+ fi
+
+ term88= term256=
+ local t
+ for t in xterm-88color rxvt-unicode rxvt-88color; do
+ if ( TERM=$t; [[ $terminfo[colors] == 88 ]] ) 2> /dev/null; then
+ term88=$t
+ break
+ fi
+ done
+ for t in xterm-256color rxvt-256color; do
+ if ( TERM=$t; [[ $terminfo[colors] == 256 ]] ) 2> /dev/null; then
+ term256=$t
+ break
+ fi
+ done
+ if [[ -z $term88 && -z $term256 ]]; then
+ ZTST_unimplemented='no 88- and 256-color terminals'
+ else
+ print -u $ZTST_fd "88-color terminal: ${term88:-not found}"
+ print -u $ZTST_fd "256-color terminal: ${term256:-not found}"
+ fi
+
+%test
+
+ for 1 in $term88 $term256; do
+ for 2 in '' -truecolor; do (
+ TERM=$1
+ typeset -a .term.extensions=( $2 )
+ zmodload -iu zsh/nearcolor
+ zmodload | grep -q zsh/nearcolor && echo unexpectedly loaded
+ : ${(%):-'%F{#123456}'}
+ zmodload | grep -q zsh/nearcolor || echo not autoloaded
+ ); done
+ done
+0:automatically loaded without truecolor extension
+
+ for 1 in $term88 $term256; do (
+ TERM=$1
+ typeset -a .term.extensions=( truecolor )
+ zmodload -iu zsh/nearcolor
+ zmodload | grep -q zsh/nearcolor && echo unexpectedly loaded
+ : ${(%):-'%F{#123456}'}
+ zmodload | grep -q zsh/nearcolor && echo unexpectedly loaded
+ ); done
+1:not automatically loaded with truecolor extension
+
+# see https://github.com/exg/rxvt-unicode/blob/5865a435983be27c/src/init.C#L213
+ if [[ -z $term88 ]]; then
+ ZTST_skip='88-color conversion (no 88-color terminal)'
+ else
+ (
+ TERM=$term88
+ for 1 in 123456 654321 8a6cb4 8bffcd a5e02d cccccc d0d0d0 f00 0f0 00f; do
+ print -r - $1 ${(V)${(%):-"%F{#$1}"}}
+ done
+ )
+ fi
+0:88-colour conversion
+>123456 ^[[38;5;80m
+>654321 ^[[38;5;81m
+>8a6cb4 ^[[38;5;38m
+>8bffcd ^[[38;5;46m
+>a5e02d ^[[38;5;40m
+>cccccc ^[[38;5;58m
+>d0d0d0 ^[[38;5;86m
+>f00 ^[[38;5;64m
+>0f0 ^[[38;5;28m
+>00f ^[[38;5;19m
+
+# see https://github.com/exg/rxvt-unicode/blob/5865a435983be27c/src/init.C#L293
+ if [[ -z $term256 ]]; then
+ ZTST_skip='256-color conversion (no 256-color terminal)'
+ else
+ (
+ TERM=$term256
+ for 1 in 123456 654321 87af5f 8a6cb4 a5e02d cccccc d0d0d0 f00 0f0 00f; do
+ print -r - $1 ${(V)${(%):-"%F{#$1}"}}
+ done
+ )
+ fi
+0:256-colour conversion
+>123456 ^[[38;5;24m
+>654321 ^[[38;5;95m
+>87af5f ^[[38;5;107m
+>8a6cb4 ^[[38;5;97m
+>a5e02d ^[[38;5;148m
+>cccccc ^[[38;5;252m
+>d0d0d0 ^[[38;5;252m
+>f00 ^[[38;5;196m
+>0f0 ^[[38;5;46m
+>00f ^[[38;5;21m
diff --git a/Test/W01history.ztst b/Test/W01history.ztst
index 1d3f3cf6f..665a37f2c 100644
--- a/Test/W01history.ztst
+++ b/Test/W01history.ztst
@@ -6,26 +6,26 @@
%test
- $ZTST_testdir/../Src/zsh -fis <<<'
- print one two three four five six seven eight nine ten
- print !:$ !:10 !:9 !:1 !:0
- print one two three four five six seven eight nine ten
- print !:0-$ !:1-2
- ' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ print one two three four five six seven eight nine ten
+ print !:$ !:10 !:9 !:1 !:0
+ print one two three four five six seven eight nine ten
+ print !:0-$ !:1-2
+ '
0:History word references
>one two three four five six seven eight nine ten
>ten ten nine one print
>one two three four five six seven eight nine ten
>print one two three four five six seven eight nine ten one two
- $ZTST_testdir/../Src/zsh -fis <<<'
- print line one of an arbitrary series
- print issue two for some mystery sequence
- print !-1:5-$
- print !1:2
- print !2:2
- print !-3:1-$
- ' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ print line one of an arbitrary series
+ print issue two for some mystery sequence
+ print !-1:5-$
+ print !1:2
+ print !2:2
+ print !-3:1-$
+ '
0:History line numbering
>line one of an arbitrary series
>issue two for some mystery sequence
@@ -34,12 +34,12 @@
>two
>mystery sequence
- $ZTST_testdir/../Src/zsh -fis <<<'
- print All metaphor, Malachi, stilts and all
- print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/
- print !1:2:&
- print -l !1:2-3:gs/a/o/
- ' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ print All metaphor, Malachi, stilts and all
+ print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/
+ print !1:2:&
+ print -l !1:2-3:gs/a/o/
+ '
0:History substitution
>All metaphor, Malachi, stilts and all
>metaphor? shmetaphor!
@@ -47,10 +47,11 @@
>metophor,
>Molochi,
- $ZTST_testdir/../Src/zsh -fis <<<'
- echo foo bar
- echo $(!!) again
- echo more $( !! )' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ echo foo bar
+ echo $(!!) again
+ echo more $( !! )
+ '
0:Regression test for history references in command substitution
>foo bar
>foo bar again
@@ -59,17 +60,18 @@
F:Check that a history bug introduced by workers/34160 is working again.
# Discarded line of error output consumes prompts printed by "zsh -i".
- $ZTST_testdir/../Src/zsh -fis <<<'
- echo /my/path/for/testing
- echo !1:1:h10
- echo !1:1:h3
- echo !1:1:h2
- echo !1:1:h1
- echo !1:1:t10
- echo !1:1:t3
- echo !1:1:t2
- echo !1:1:t1
- echo !1:1:t3:h2' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ echo /my/path/for/testing
+ echo !1:1:h10
+ echo !1:1:h3
+ echo !1:1:h2
+ echo !1:1:h1
+ echo !1:1:t10
+ echo !1:1:t3
+ echo !1:1:t2
+ echo !1:1:t1
+ echo !1:1:t3:h2
+ '
0:Modifiers :h and :t with arguments
>/my/path/for/testing
>/my/path/for/testing
@@ -82,26 +84,28 @@ F:Check that a history bug introduced by workers/34160 is working again.
>testing
>path/for
- $ZTST_testdir/../Src/zsh -fis <<<'
- echo /my/path/for/testing
- echo !1:1:P' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
+ echo /my/path/for/testing
+ echo !1:1:P
+ '
0:Modifier :P
>/my/path/for/testing
>/my/path/for/testing
- $ZTST_testdir/../Src/zsh -fgis <<<'
- SAVEHIST=7
- print -rs "one\\"
- print -rs "two\\\\"
- print -rs "three\\\\\\"
- print -rs "four\\\\\\\\"
- print -rs "five\\\\\\\\\\"
- print -s "while false\ndo\ntrue\\\\\n && break\ndone"
- print -s "echo one\\\\\ntwo"
- fc -W hist
- fc -p -R hist
- fc -l
- rm hist' 2>/dev/null
+ PS1= $ZTST_testdir/../Src/zsh -fgis <<<'
+ SAVEHIST=7
+ print -rs "one\\"
+ print -rs "two\\\\"
+ print -rs "three\\\\\\"
+ print -rs "four\\\\\\\\"
+ print -rs "five\\\\\\\\\\"
+ print -s "while false\ndo\ntrue\\\\\n && break\ndone"
+ print -s "echo one\\\\\ntwo"
+ fc -W hist
+ fc -p -R hist
+ fc -l
+ rm hist
+ '
0:Lines ending in backslash saved and restored to history
> 1 one\
> 2 two\\
diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst
index d52888dd9..1faac0c44 100644
--- a/Test/W02jobs.ztst
+++ b/Test/W02jobs.ztst
@@ -7,6 +7,7 @@
export PS1= PS2=
zpty -d
zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
+ zpty -w zsh 'alias sleep="sleep </dev/null >/dev/null 2>&1"'
}
zpty_input() {
zpty -w zsh "${(F)@}" $'\n'
@@ -22,8 +23,7 @@
zpty_stop() {
# exit twice in case of check_jobs
zpty -w zsh $'exit\nexit\n'
- # zpty gives no output when piped without these braces (?)
- { zpty -r zsh } | sed $'/[^[:space:]]/!d; s/\r$//;'
+ zpty -r zsh | sed $'/[^[:space:]]/!d; s/\r$//;'
zpty -d
:
}
@@ -193,6 +193,143 @@
*>\[2] ? interrupt*sleep*
*>\[1] ? kill*sleep*
+ zpty_start
+ zpty_input jobs
+ zpty_input '( jobs ); :'
+ zpty_stop
+0:jobs with no jobs
+
+ zpty_start
+ zpty_input 'sleep 2 &; ( jobs ); disown'
+ zpty_stop
+0:jobs in sub-shell with job in parent shell
+*>\[1] <->
+*>\[1] + * sleep 2*
+
+ zpty_start
+ zpty_input '( sleep 2 &; jobs ); :'
+ zpty_stop
+0:jobs in sub-shell with job in same shell
+*>\[2] + * sleep 2*
+
+ zpty_start
+ zpty_input 'sleep 2 &; jobs; ( sleep 3 &; jobs ); jobs; disown'
+ zpty_stop
+0:jobs in sub-shell with job in parent + same shell
+*>\[1] <->
+*>\[1] + * sleep 2*
+*>\[2] + * sleep 3*
+*>\[1] + * sleep 2*
+
+ zpty_start
+ zpty_input '( sleep 2 &; sleep 3 &; jobs ); :'
+ zpty_stop
+0:jobs in sub-shell with two jobs in same shell
+*>\[2] - * sleep 2*
+*>\[3] + * sleep 3*
+
+ zpty_start
+ zpty_input 'sleep 2 &; sleep 3 &; disown; jobs; disown'
+ zpty_stop
+0:disown current job
+*>\[1] <->
+*>\[2] <->
+*>\[1] + * sleep 2*
+
+ zpty_start
+ zpty_input disown
+ zpty_stop
+0:disown with no jobs
+>disown: no current job
+
+ zpty_start
+ zpty_input 'sleep 2 &; ( disown ); jobs; disown'
+ zpty_stop
+0:disown in sub-shell with job in parent shell
+*>\[1] <->
+*>disown: can't manipulate jobs in subshell
+*>\[1] + * sleep 2*
+
+ zpty_start
+ zpty_input '( sleep 3 &; disown; jobs ); :'
+ zpty_stop
+0:disown in sub-shell with job in same shell
+
+ zpty_start
+ zpty_input 'sleep 2 &; ( sleep 3 &; disown; jobs ); jobs; disown'
+ zpty_stop
+0:disown in sub-shell with job in parent + same shell
+*>\[1] <->
+*>\[1] + * sleep 2*
+
+# @todo apparently testing suspended jobs with zpty is error-prone. see above
+# zpty_start
+# zpty_input 'sleep 3 &'
+# zpty_input 'kill -STOP ${${=${ jobs -p }}[3]}'
+# zpty_input 'disown'
+# zpty_stop
+#0:disown with stopped job
+#*>\[1] <->
+#*>\[1] * suspended * sleep 3
+#*>disown: warning: job is suspended*
+
+ zpty_start
+ zpty_input 'sleep 2 &; sleep 3 &; sleep 4 &; disown -a; jobs'
+ zpty_stop
+0:disown -a
+*>\[1] <->
+*>\[2] <->
+*>\[3] <->
+
+ zpty_start
+ zpty_input '( sleep 2 &; sleep 3 &; sleep 4 &; disown -a; jobs ); :'
+ zpty_stop
+0:disown -a in sub-shell
+
+ zpty_start
+ zpty_input 'sleep 2 &; sleep 3 &|; jobs; disown'
+ zpty_input 'sleep 2 &; sleep 3 &!; jobs; disown'
+ zpty_stop
+0:background and disown with &| and &!
+*>\[1] <->
+*>\[1] * sleep 2*
+*>\[1] <->
+*>\[1] * sleep 2*
+
+ zpty_start
+ zpty_input '( fg ); :'
+ zpty_input '( bg ); :'
+ zpty_stop
+0:fg + bg in sub-shell
+*>fg: no job control in this shell
+*>bg: no job control in this shell
+
+# The following test exercises a bug where setprevjob() could pick an
+# internal NOPRINT job (e.g. a builtin's own job entry) as the previous
+# job. This happened when a function superjob was involved, because the
+# superjob's subjob was excluded but the builtin job was not.
+# The function's child stops itself, triggering the superjob mechanism.
+# Then fg %- resumes the superjob (which exits since the child is done).
+# Afterwards, the remaining sleep job should still be accessible.
+ zpty_start
+ zpty_input "f() { sh -c 'kill -TSTP 0' }"
+ zpty_input 'f'
+ zpty_line # consume stopped message from f
+ zpty_input 'sleep 100 &'
+ zpty_line # consume [N] PID
+ zpty_input 'kill -STOP %sleep'
+ zpty_line # consume stopped message from kill
+ zpty_input 'fg %-'
+ zpty_line # consume continued message
+ zpty_input 'jobs'
+ zpty_stop
+0:fg %- with function superjob does not pick internal job as previous
+*>zsh:*(stopped|suspended)*
+*>\[[0-9]##\] [0-9]##
+*>\[[0-9]##\] + (stopped|suspended)*sleep*
+*>\[[0-9]##\] continued*
+*>\[[0-9]##\] + (stopped|suspended)*sleep*
+
%clean
zmodload -ui zsh/zpty
diff --git a/Test/W03jobparameters.ztst b/Test/W03jobparameters.ztst
index a6f7a09b1..6b2b80d54 100644
--- a/Test/W03jobparameters.ztst
+++ b/Test/W03jobparameters.ztst
@@ -50,8 +50,7 @@
*>zsh:*SIGHUPed*
# $jobstates refers to a job started in the main shell unless
-# one has been started in the subshell. In the latter case,
-# the subshell has no job control so the job is not marked as current.
+# one has been started in the subshell.
zpty_start
zpty_input "MODULE_PATH=${(q)MODULE_PATH}"
zpty_input 'sleep 3 &'
@@ -63,7 +62,7 @@
>main
*>running:+:*=running
>sub
-*>running::*=running
+*>running:+:*=running
*>zsh:*SIGHUPed*
# output from zpty removes empty lines
@@ -75,4 +74,4 @@
0:$jobstate shows no job started in main shell but one started in subshell
>main
>sub
-*>running::*=running
+*>running:+:*=running
diff --git a/Test/X06termquery.ztst b/Test/X06termquery.ztst
index 5f3a81aae..701cd625b 100644
--- a/Test/X06termquery.ztst
+++ b/Test/X06termquery.ztst
@@ -5,6 +5,7 @@
termresp() {
setopt localoptions extendedglob
export PS1= PS2= COLORTERM= TERM=
+ typeset +x TERM_PROGRAM
typeset +x -m .term.\*
zpty -d
zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index d7215f381..f6e0d2133 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -144,15 +144,40 @@ F:regression test workers/51641
>line: {: ~[name/1}{]}
>line: {: ~[name2}{]}
- comptest $'echo ;:\C-b\C-b\t'
+ comptest $'ls ;:\C-b\C-b\t'
0:directories and files before separator
->line: {echo }{;:}
+>line: {ls }{;:}
>DESCRIPTION:{file}
>DI:{dir1}
>DI:{dir2}
>FI:{file1}
>FI:{file2}
+ comptesteval '_tst() { compadd -V grp -S /a foo bar; compadd -V grp -S /b foo baz }'
+ comptest $'tst \t'
+0:nosort dedup hides same-string non-duplicate matches
+>line: {tst }{}
+>NO:{foo}
+>NO:{bar}
+>NO:{baz}
+
+ comptesteval '_tst() { local disp1=(Foo Bar); compadd -V grp -d disp1 -S /a foo bar; local disp2=(Foo Baz); compadd -V grp -d disp2 -S /b foo baz; }'
+ comptest $'tst \t'
+0:nosort dedup with display strings does not hide same-string non-duplicate matches
+>line: {tst }{}
+>NO:{Foo}
+>NO:{Bar}
+>NO:{Foo}
+>NO:{Baz}
+
+ comptesteval '_tst() { compadd -V grp -S /a foo; compadd -V grp -S /b foo; compadd -V grp -S /c foo; compadd -V grp bar baz }'
+ comptest $'tst \t'
+0:nosort dedup with three same-string non-duplicates
+>line: {tst }{}
+>NO:{foo}
+>NO:{bar}
+>NO:{baz}
+
# Temporarily modify format set in comptest
comptesteval 'zstyle -s ":completion:*:descriptions" format oldfmt'
comptesteval 'zstyle ":completion:*:descriptions" format \
@@ -393,6 +418,11 @@ F:regression test workers/31611
>NO:{y}
>NO:{z}
+ comptesteval '_tst() { _message "%foo %BAR" }'
+ comptest $'tst \t'
+0:% in message
+>line: {tst }{}
+>MESSAGE:{%foo %BAR}
%clean
diff --git a/Test/Y03arguments.ztst b/Test/Y03arguments.ztst
index 200c83e8c..6ff9bf0a5 100644
--- a/Test/Y03arguments.ztst
+++ b/Test/Y03arguments.ztst
@@ -373,20 +373,35 @@
tst_arguments -S -x ':word:()'
comptest $'tst -- -\t'
-0:disallowed option after --
+0:-S: disallowed option after --
>line: {tst -- -}{}
tst_arguments -S -x ':word:()'
+ comptest $'tst - -\t'
+0:-S: allowed option after -
+>line: {tst - -x }{}
+
+ tst_arguments -S -x ':word:()'
comptest $'tst - --\eB\C-b\t'
-0:allowed option before --
+0:-S: allowed option before --
>line: {tst -x }{ --}
tst_arguments -S '1:one' '2:two'
comptest $'tst -- -- \t'
-0:only first of duplicate -- is ignored
+0:-S: only first of duplicate -- is ignored
>line: {tst -- -- }{}
>DESCRIPTION:{two}
+ tst_arguments -S -S -x ':word:()'
+ comptest $'tst -- -\t'
+0:-S -S: disallowed option after --
+>line: {tst -- -}{}
+
+ tst_arguments -S -S -x ':word:()'
+ comptest $'tst - -\t'
+0:-S -S: disallowed option after -
+>line: {tst - -}{}
+
tst_arguments -x :word
comptest $'tst word -\t'
0:option after a word
@@ -641,16 +656,75 @@ F:shouldn't offer -b as it is already on the command-line
>NO:{-b}
>NO:{-c}
+ tst_arguments : -a:arg -b -c --d
+ comptest $'tst -a -b -\t'
+ comptest $'tst -a --d -\t'
+0:single optarg that looks like an option
+>line: {tst -a -b -}{}
+>DESCRIPTION:{option}
+>NO:{--d}
+>NO:{-b}
+>NO:{-c}
+>line: {tst -a --d -}{}
+>DESCRIPTION:{option}
+>NO:{--d}
+>NO:{-b}
+>NO:{-c}
+
+ tst_arguments : -a:arg1::arg2::arg3 -b -c -d: --e --f --g:
+ comptest $'tst -a -b -c -d -\t'
+ comptest $'tst -a --e --f --g -\t'
+0:multiple optargs that look like options
+>line: {tst -a -b -c -d -}{}
+>DESCRIPTION:{option}
+>NO:{--e}
+>NO:{--f}
+>NO:{--g}
+>NO:{-b}
+>NO:{-c}
+>NO:{-d}
+>line: {tst -a --e --f --g -}{}
+>DESCRIPTION:{option}
+>NO:{--e}
+>NO:{--f}
+>NO:{--g}
+>NO:{-b}
+>NO:{-c}
+>NO:{-d}
+
+ tst_arguments : - set1 -a: -b -c - set2 -d: -e -f
+ comptest $'tst -a -b -\t'
+ comptest $'tst -d -e -\t'
+0:optarg that look like an option in a set
+>line: {tst -a -b -}{}
+>DESCRIPTION:{option}
+>NO:{-b}
+>NO:{-c}
+>line: {tst -d -e -}{}
+>DESCRIPTION:{option}
+>NO:{-e}
+>NO:{-f}
+
+ tst_arguments -S -S : -a: -b -c
+ comptest $'tst -a - -\t'
+ comptest $'tst -a -- -\t'
+0:optarg that looks like a terminator
+>line: {tst -a - -}{}
+>DESCRIPTION:{option}
+>NO:{-b}
+>NO:{-c}
+>line: {tst -a -- -}{}
+>DESCRIPTION:{option}
+>NO:{-b}
+>NO:{-c}
+
tst_arguments '-a:arg' -b '(-b)-c'
comptest $'tst -a -c -\t'
0:exclusion with option argument that looks like an option
>line: {tst -a -c -}{}
->MESSAGE:{no arguments}
-F:The current behaviour is wrong; the correct expected output is:
-F:>line: {tst -a -c -}{}
-F:>DESCRIPTION:{option}
-F:>NO:{-b}
-F:>NO:{-c}
+>DESCRIPTION:{option}
+>NO:{-b}
+>NO:{-c}
tst_arguments + grp1 -a -b - onlyset '(-a grp3--y grp2 grp4--)-m' -n + grp2 -u -v + grp3 -x -y + grp4 -0 ':rest'
comptest $'tst -m -\t'
@@ -713,6 +787,35 @@ F:should offer both sets of arguments in first case
>NO:{-d}
F:shouldn't offer -t in the first case (with stacked options)
+ tst_arguments -s : - set1 -a -b -c+: --d=: - set2 -e -f
+ comptest $'tst -ab -\t' # stack with known options
+ comptest $'tst -ax -\t' # stack with unknown option
+ comptest $'tst -cx -\t' # short option with same-word optarg
+ comptest $'tst --d=x -\t' # long option with same-word optarg
+0:detection of foreign-set option in stack or with same-word optarg
+>line: {tst -ab -}{}
+>DESCRIPTION:{option}
+>NO:{--d}
+>NO:{-c}
+>line: {tst -ax -}{}
+>DESCRIPTION:{option}
+>NO:{--d}
+>NO:{-a}
+>NO:{-b}
+>NO:{-c}
+>NO:{-e}
+>NO:{-f}
+>line: {tst -cx -}{}
+>DESCRIPTION:{option}
+>NO:{--d}
+>NO:{-a}
+>NO:{-b}
+>line: {tst --d=x -}{}
+>DESCRIPTION:{option}
+>NO:{-a}
+>NO:{-b}
+>NO:{-c}
+
tst_arguments -s '(set-a set--b grp-a grp--b grp-)-a' - set-a -s - set--b -t + grp-a -g + grp--b -h + grp- -i
comptest $'tst -a\t'
0:sets and groups with - in their name
@@ -796,6 +899,25 @@ F:shouldn't offer -t in the first case (with stacked options)
>DESCRIPTION:{option}
>NO:{-b}
+ tst_arguments : '-x+[%2Fxdesc%f]:%2Fxargdesc%f' -y '1:%2F1desc%f'
+ comptest $'tst -\t'
+ comptest $'tst -x\t'
+0:% in descriptions
+>line: {tst -}{}
+>DESCRIPTION:{%2F1desc%f}
+>DESCRIPTION:{option}
+>NO:{-x -- %2Fxdesc%f}
+>NO:{-y}
+>line: {tst -x}{}
+>DESCRIPTION:{%2Fxargdesc%f}
+
+ tst_arguments : -x '-y[]'
+ comptest $'tst -\t'
+0:empty description
+>line: {tst -}{}
+>DESCRIPTION:{option}
+>NO:{-x}
+>NO:{-y}
%clean
diff --git a/Test/Y04regexargs.ztst b/Test/Y04regexargs.ztst
new file mode 100644
index 000000000..d204fd312
--- /dev/null
+++ b/Test/Y04regexargs.ztst
@@ -0,0 +1,111 @@
+# Tests for _regex_arguments.
+
+%prep
+ if [[ $OSTYPE = cygwin ]]; then
+ ZTST_unimplemented="the zsh/zpty module does not work on Cygwin"
+ elif ( zmodload zsh/zpty 2>/dev/null ); then
+ . $ZTST_srcdir/comptest
+ mkdir comp.tmp
+ cd comp.tmp
+ comptestinit -z $ZTST_testdir/../Src/zsh &&
+ {
+ word=$'[^\0]#\0'
+ comptesteval \
+ 'compdef _tst tst' \
+ 'setopt extended_glob' # running _regex_arguments outside of completion below
+ tst_regex() { comptesteval "_regex_arguments _tst /$'[^\0]#\0'/ ${${(@q)*}}" }
+ }
+ else
+ ZTST_unimplemented="the zsh/zpty module is not available"
+ fi
+
+%test
+ tst_regex /one/ ':first:first:(one)'
+ comptesteval "functions _tst >/tmp/hello"
+ comptest $'tst \t'
+0:standalone spec
+>line: {tst one }{}
+
+ tst_regex \( /'one '/ ':fixed:fixed:(one)' \| /'two '/ ':second:second:compadd two' \| /'[0-9]## '/ ': _message -e numbers number' \| /'0x[0-9a-f]## '/ ':hex:hex:' \)
+ comptest $'tst \t'
+0:simple alternation, use of _message for description with no matches
+>line: {tst }{}
+>DESCRIPTION:{fixed}
+>NO:{one}
+>DESCRIPTION:{second}
+>NO:{two}
+>DESCRIPTION:{number}
+
+ tst_regex /$'rpc\0'/ \
+ \(\
+ /"$word"/ ':programs:program:compadd -qS, mountd nisd' \
+ \|\
+ /$'[^,\0]##,[^,\0]##,'/ /$'[^,\0]##\0'/ ':procedures:procedure:' \
+ \|\
+ /$'[^,\0]##,'/ /$'[^,\0]##\0'/ ':versions:version:' \
+ \)
+ comptest $'tst rpc m\t\t1,\t'
+0:optional fields after a suffix
+>line: {tst rpc mountd,}{}
+>line: {tst rpc mountd,}{}
+>DESCRIPTION:{version}
+>line: {tst rpc mountd,1,}{}
+>DESCRIPTION:{procedure}
+
+ tst_regex \( /$'[0-9]##,'/ ':numbers:number:compadd -qS, 1 2' \) \# /$'end\0'/ ':end:end:(end)' /next/ ':next:next:(next)'
+ comptest $'tst \t1\t2,e\t\t'
+0:simple repetition, note zero repititions allowed
+>line: {tst }{}
+>DESCRIPTION:{number}
+>NO:{1}
+>NO:{2}
+>DESCRIPTION:{end}
+>NO:{end}
+>line: {tst 1,}{}
+>line: {tst 1,2,end }{}
+>line: {tst 1,2,end next }{}
+
+ tst_regex \( /--/+ /$'(on|fix)='/ $'/[^\0]##\0/' ':names:boolean value:(false true)' \|\
+ /"[]"/ ':options:option:compadd -qS= - --on --fix' \) \# /next/ ':next:next:(next)'
+ comptest $'tst --\ton=t\t\t'
+0:non-matching pattern to separate matches from consuming patterns
+>line: {tst --}{}
+>DESCRIPTION:{option}
+>NO:{--fix}
+>NO:{--on}
+>line: {tst --on=true }{}
+>line: {tst --on=true --}{}
+
+ tst_regex \
+ \(\
+ /$'(true|false)\0'/ -'last=bool' ':names:boolean:(false true)' \
+ \|\
+ /$'(val|opt)\0'/ -'last=${match[1]%?}' ':opts:option:(val opt)' \
+ \) \# \
+ /$'[^\0]##\0'/ ':last:last:compadd - $last'
+ comptest $'tst true \tv\t \tfalse f\t'
+0:use guard and $match to reference prior argument
+>line: {tst true }{}
+>DESCRIPTION:{boolean}
+>NO:{false}
+>NO:{true}
+>DESCRIPTION:{option}
+>NO:{opt}
+>NO:{val}
+>DESCRIPTION:{last}
+>NO:{bool}
+>line: {tst true val }{}
+>line: {tst true val }{}
+>DESCRIPTION:{boolean}
+>NO:{false}
+>NO:{true}
+>DESCRIPTION:{option}
+>NO:{opt}
+>NO:{val}
+>DESCRIPTION:{last}
+>NO:{val}
+>line: {tst true val false false }{}
+
+%clean
+
+ zmodload -ui zsh/zpty
diff --git a/Test/Y05describe.ztst b/Test/Y05describe.ztst
new file mode 100644
index 000000000..72953af7c
--- /dev/null
+++ b/Test/Y05describe.ztst
@@ -0,0 +1,105 @@
+# tests for _describe
+
+%prep
+
+ if ( zmodload -s zsh/zpty ); then
+ source $ZTST_srcdir/comptest
+ mkdir comp.tmp
+ cd comp.tmp
+ comptestinit -z $ZTST_testdir/../Src/zsh && {
+ comptesteval 'compdef _tst tst'
+ tst_describe() { comptesteval "_tst() { _describe ${${(@q+)@}} }" }
+ }
+ else
+ ZTST_unimplemented='the zsh/zpty module is not available'
+ fi
+
+%test
+
+ tst_describe desc '(a b:descb "c\:c:descc")'
+ comptest $'tst \t'
+0:name1 as (...), description, escaped colon in name
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{b -- descb}
+>NO:{c:c -- descc}
+>NO:{a}
+
+ tst_describe desc '(( a b:descb "c\:c:descc" ))'
+ comptest $'tst \t'
+0:name1 as ((...)) not supported
+>line: {tst }{}
+
+ tst_describe desc '(a b:descb "c\:c:descc")' '(ax bx:descbx "cx\:cx:desccx")'
+ comptest $'tst \t\t'
+0:name2 as (...)
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{b -- descb}
+>NO:{c:c -- descc}
+>NO:{a}
+>line: {tst bx}{}
+
+ tst_describe desc '(a b c)' -- '(x y z)'
+ comptest $'tst \t'
+0:multiple groups
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{a}
+>NO:{b}
+>NO:{c}
+>NO:{x}
+>NO:{y}
+>NO:{z}
+
+ comptesteval '_tst() {
+ local -a name1=( a b:descb "c\:c:descc" )
+ local -a name2=( ax bx:descbx "cx\:cx:desccx" )
+ _describe desc name1 name2
+ }'
+ comptest $'tst \t\t'
+0:arrays by name
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{b -- descb}
+>NO:{c:c -- descc}
+>NO:{a}
+>line: {tst bx}{}
+
+ tst_describe desc '(b c a)' -oreverse
+ comptest $'tst \t'
+0:compadd options, basic
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{c}
+>NO:{b}
+>NO:{a}
+
+ tst_describe desc \
+ '(b c a)' '(bx cx ax)' -oreverse \
+ -- \
+ '(y z x)' '(yx zx xx)' -onosort
+ comptest $'tst \t\t'
+0:compadd options, complex
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{c}
+>NO:{b}
+>NO:{a}
+>DESCRIPTION:{desc}
+>NO:{y}
+>NO:{z}
+>NO:{x}
+>line: {tst cx}{}
+
+ tst_describe %2Fdesc%f '(a:adesc b:%2Fbdesc%f)'
+ comptest $'tst \t'
+0:% in descriptions
+>line: {tst }{}
+>DESCRIPTION:{%2Fdesc%f}
+>NO:{a -- adesc}
+>NO:{b -- %2Fbdesc%f}
+
+%clean
+
+ zmodload -ui zsh/zpty
diff --git a/Test/Y06values.ztst b/Test/Y06values.ztst
new file mode 100644
index 000000000..720f990a5
--- /dev/null
+++ b/Test/Y06values.ztst
@@ -0,0 +1,246 @@
+# tests for _values
+
+%prep
+
+ if ( zmodload -s zsh/zpty ); then
+ source $ZTST_srcdir/comptest
+ mkdir comp.tmp
+ cd comp.tmp
+ comptestinit -z $ZTST_testdir/../Src/zsh && {
+ comptesteval 'compdef _tst tst'
+ tst_values() { comptesteval "_tst() { _values ${${(@q+)@}} }" }
+ }
+ else
+ ZTST_unimplemented='the zsh/zpty module is not available'
+ fi
+
+%test
+
+ tst_values desc a b
+ comptest $'tst \t'
+0:basic value
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{a}
+>NO:{b}
+
+ tst_values desc a b
+ comptest $'tst a \t'
+0:basic value, next word
+>line: {tst a }{}
+>DESCRIPTION:{desc}
+>NO:{a}
+>NO:{b}
+
+ tst_values desc 'a[adesc]' 'b[bdesc]'
+ comptest $'tst \t'
+0:basic value with description
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{a -- adesc}
+>NO:{b -- bdesc}
+
+ tst_values desc 'a\[b' '\!x' '\*y' '\(z' '\\\.\:\]\&'
+ comptest $'tst \t'
+0:display of escaped char in value name
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{!x}
+>NO:{(z}
+>NO:{*y}
+>NO:{\.:]&}
+>NO:{a[b}
+
+ tst_values desc '!a' b c
+ comptest $'tst \t'
+0:display of hidden value
+>line: {tst }{}
+>DESCRIPTION:{desc}
+>NO:{b}
+>NO:{c}
+
+ tst_values -s, desc a b c
+ comptest $'tst b,\t'
+0:basic sequence
+>line: {tst b,}{}
+>DESCRIPTION:{desc}
+>NO:{a}
+>NO:{c}
+
+ tst_values -s, desc a b c d e
+ comptest $'tst \'a,b,c,\t'
+ comptest $'tst "a,b,c,\t'
+0:sequence in quotes
+>line: {tst 'a,b,c,}{}
+>DESCRIPTION:{desc}
+>NO:{d}
+>NO:{e}
+>line: {tst "a,b,c,}{}
+>DESCRIPTION:{desc}
+>NO:{d}
+>NO:{e}
+
+ tst_values -s, desc '!a' b c
+ comptest $'tst a,\t'
+0:sequence continues after hidden value
+>line: {tst a,}{}
+>DESCRIPTION:{desc}
+>NO:{b}
+>NO:{c}
+
+ tst_values -s, desc '\*a' b c
+ comptest $'tst \\*a,\t'
+0:sequence continues after value with escaped meta char
+>line: {tst \*a,}{}
+>DESCRIPTION:{desc}
+>NO:{b}
+>NO:{c}
+
+ tst_values -s, desc '\:a' b c
+ comptest $'tst :a,\t'
+0:sequence continues after value with escaped non-meta char
+>line: {tst :a,}{}
+>DESCRIPTION:{desc}
+>NO:{b}
+>NO:{c}
+
+ tst_values -s, desc '*a' b c
+ comptest $'tst a,a,\t'
+0:multi value offered again
+>line: {tst a,a,}{}
+>DESCRIPTION:{desc}
+>NO:{a}
+>NO:{b}
+>NO:{c}
+
+ tst_values -s, desc '(b c)a' b c d e
+ comptest $'tst a,\t'
+0:xor value not offered
+>line: {tst a,}{}
+>DESCRIPTION:{desc}
+>NO:{d}
+>NO:{e}
+
+ tst_values -s, desc '(d\:e)a' b c 'd\:e'
+ comptest $'tst a,\t'
+0:xor value with escaped char not offered
+>line: {tst a,}{}
+>DESCRIPTION:{desc}
+>NO:{b}
+>NO:{c}
+
+ tst_values desc 'a:val'
+ comptest $'tst a=\t'
+ tst_values desc 'a:val:'
+ comptest $'tst a=\t'
+0:value with argument not enumerated
+>line: {tst a=}{}
+>DESCRIPTION:{val}
+>line: {tst a=}{}
+>DESCRIPTION:{val}
+
+ tst_values desc 'a:val:(x y z)'
+ comptest $'tst a=\t'
+0:value with argument enumerated
+>line: {tst a=}{}
+>DESCRIPTION:{val}
+>NO:{x}
+>NO:{y}
+>NO:{z}
+
+# _arguments requires the ':'s to be escaped but i guess it's unnecessary here
+ tst_values desc 'a:val:((x:descx y:descy z:descz))'
+ comptest $'tst a=\t'
+0:value with argument enumerated with description
+>line: {tst a=}{}
+>DESCRIPTION:{val}
+>NO:{x -- descx}
+>NO:{y -- descy}
+>NO:{z -- descz}
+
+# this is the syntax required by _arguments (see above)
+ tst_values desc 'a:val:((x\:descx y\:descy z\:descz))'
+ comptest $'tst a=\t'
+0:value with argument enumerated with description, escaped colon
+>line: {tst a=}{}
+>DESCRIPTION:{val}
+>NO:{x -- descx}
+>NO:{y -- descy}
+>NO:{z -- descz}
+
+# should be the same as above
+ tst_values desc 'a:val:((x\\:descx y\\:descy z\\:descz))'
+ comptest $'tst a=\t'
+0:value with argument enumerated with description, escaped colon with \\
+>line: {tst a=}{}
+>DESCRIPTION:{val}
+>NO:{x -- descx}
+>NO:{y -- descy}
+>NO:{z -- descz}
+
+ tst_values desc 'a:val:(("x\\:x":descx y\:descy z\:descz))'
+ comptest $'tst a=\t'
+0:value with argument enumerated with description, escaped colon in arg name
+>line: {tst a=}{}
+>DESCRIPTION:{val}
+>NO:{x:x -- descx}
+>NO:{y -- descy}
+>NO:{z -- descz}
+
+ tst_values desc 'a:val:((x:x:descx y\:descy z\:descz))'
+ comptest $'tst a=\t'
+0:value with argument enumerated with description, un-escaped colon in arg desc
+>line: {tst a=}{}
+>DESCRIPTION:{val}
+>NO:{x -- x:descx}
+>NO:{y -- descy}
+>NO:{z -- descz}
+
+ tst_values desc 'a: :{ _message msg }'
+ comptest $'tst a=\t'
+0:value with argument eval string, braces
+>line: {tst a=}{}
+>MESSAGE:{msg}
+
+ tst_values desc 'a: : _message msg'
+ comptest $'tst a=\t'
+0:value with argument eval string, leading space
+>line: {tst a=}{}
+>MESSAGE:{msg}
+
+ tst_values -s: -S. desc 'a:val:(x y z)' b c
+ comptest $'tst b:a.\t'
+0:-s and -S
+>line: {tst b:a.}{}
+>DESCRIPTION:{val}
+>NO:{x}
+>NO:{y}
+>NO:{z}
+
+ tst_values -w desc a b c
+ comptest $'tst b \t'
+0:-w without -s
+>line: {tst b }{}
+>DESCRIPTION:{desc}
+>NO:{a}
+>NO:{c}
+
+ tst_values -ws, desc a b c d
+ comptest $'tst b,c \t'
+0:-w with -s
+>line: {tst b,c }{}
+>DESCRIPTION:{desc}
+>NO:{a}
+>NO:{d}
+
+ tst_values %2Fdesc%f 'a[adesc]' 'b[%2Fbdesc%f]'
+ comptest $'tst \t'
+0:% in descriptions
+>line: {tst }{}
+>DESCRIPTION:{%2Fdesc%f}
+>NO:{a -- adesc}
+>NO:{b -- %2Fbdesc%f}
+
+%clean
+
+ zmodload -ui zsh/zpty
diff --git a/Test/Z01is-at-least.ztst b/Test/Z01is-at-least.ztst
index 039b3e737..57fb92696 100644
--- a/Test/Z01is-at-least.ztst
+++ b/Test/Z01is-at-least.ztst
@@ -16,12 +16,27 @@
done
0:is-at-least smoke test
- is-at-least 5.8.0.2 5.8
-1f:regression test: Two trailing zeroes are filled in
-# TODO: When fixing this, extend the smoke test to cover this.
+# versions in v1 should be equal
+# versions in v2 should be newer than those in v1
+ v1=( 1 1.0 1.0.0 1.0.0.0 1-b 1.X-0 )
+ v2=( 1.0.0.1 1.0.1 1.0.1.0 1.0.1.1 1-a-0-1 1-0-a.1)
+ for (( i = 1; i < $#v1; ++i )); do
+ for (( j = 1; j < $#v1; ++j )); do
+ is-at-least $v1[i] $v1[j] || echo "$v1[i] ≰ $v1[j]"
+ done
+ done
+ for (( i = 1; i < $#v1; ++i )); do
+ for (( j = 1; j < $#v2; ++j )); do
+ is-at-least $v1[i] $v2[j] || echo "$v1[i] ≰ $v2[j]"
+ { ! is-at-least $v2[j] $v1[i] } || echo "$v2[j] ≤ $v1[i]"
+ done
+ done
+0:trailing zeroes are filled in, text-only segments are ignored
- is-at-least 5.8.0.2 5.8.0.0
-1:regression test: Two trailing zeroes are filled in
-# TODO: Extend the smoke test to cover this.
+ local min cur
+ for min cur in 1.2 1.12 1.2b 1.12a 1-a3 1-b1; do
+ is-at-least $min $cur || echo "$min ≰ $cur"
+ done
+0:numerical or lexical order
%clean
diff --git a/Test/Z04zgetopt.ztst b/Test/Z04zgetopt.ztst
new file mode 100644
index 000000000..a0546990f
--- /dev/null
+++ b/Test/Z04zgetopt.ztst
@@ -0,0 +1,222 @@
+%prep
+
+ if ! zmodload -s zsh/zutil; then
+ ZTST_unimplemented='the zsh/zutil module is not available'
+ else
+ autoload -Uz zgetopt
+ fi
+
+%test
+
+ zgetopt -A '' -o '' -- a b c
+ zgetopt -A '' -l '' -- a b c
+ zgetopt -A '' -- a b c
+2:-o or -l required (usage error)
+>-- a b c
+>-- a b c
+?(eval):zgetopt: missing option spec
+
+ zgetopt -A '' -o - -- a b c
+ zgetopt -A '' -o -a -- a b c
+ zgetopt -A '' -o a- -- a b c
+ zgetopt -A '' -o a+ -- a b c
+ zgetopt -A '' -o a= -- a b c
+ zgetopt -A '' -o a\\ -- a b c
+ zgetopt -A '' -o :a -- a b c
+ zgetopt -A '' -o a::: -- a b c
+ zgetopt -A '' -o '' -- a b c
+ zgetopt -A '' -o + -- a b c
+0:weird short-option specs
+?(eval):zgetopt: optspec with leading - (disable operand collection) not supported
+?(eval):zgetopt: optspec with leading - (disable operand collection) not supported
+?(eval):zgetopt: invalid short-option name: -
+?(eval):zgetopt: invalid short-option name: +
+?(eval):zgetopt: invalid short-option name: =
+?(eval):zgetopt: invalid short-option name: \
+?(eval):zgetopt: invalid short-option name: :
+?(eval):zgetopt: invalid short-option name: :
+>-- a b c
+>-- a b c
+
+ zgetopt -A '' -l a,+ -- a b c
+ zgetopt -A '' -l a,= -- a b c
+ zgetopt -A '' -l a,\\ -- a b c
+ zgetopt -A '' -l a,: -- a b c
+ zgetopt -A '' -l a,:b -- a b c
+ zgetopt -A '' -l a,b:b -- a b c
+ zgetopt -A '' -l a,b::: -- a b c
+ zgetopt -A '' -l '' -- a b c
+ zgetopt -A '' -l , -- a b c
+ zgetopt -A '' -l a,,,,,b -- a b c
+ zgetopt -A '' -l - -- a b c ---
+0:weird long-option specs
+?(eval):zgetopt: invalid long-option spec: +
+?(eval):zgetopt: invalid long-option spec: =
+?(eval):zgetopt: invalid long-option spec: \
+?(eval):zgetopt: invalid long-option spec: :
+?(eval):zgetopt: invalid long-option spec: :b
+?(eval):zgetopt: invalid long-option spec: b:b
+?(eval):zgetopt: invalid long-option spec: b:::
+>-- a b c
+>-- a b c
+>-- a b c
+>--- -- a b c
+
+ zgetopt -A '' -o ab:c:: -- a b c
+ zgetopt -A '' -o ab:c:: -- -a
+ zgetopt -A '' -o ab:c:: -- -a a b c
+ zgetopt -A '' -o ab:c:: -- -a a -b c
+ zgetopt -A '' -o ab:c:: -- -a a -b -c
+ zgetopt -A '' -o ab:c:: -- -a a -b -c d
+ zgetopt -A '' -o ab:c:: -- -a a -b -c -c
+ zgetopt -A '' -o ab:c:: -- -a a -b -c -c d
+ zgetopt -A '' -o ab:c:: -- -a a -b -c -cd
+0:short options
+>-- a b c
+>-a --
+>-a -- a b c
+>-a -b c -- a
+>-a -b -c -- a
+>-a -b -c -- a d
+>-a -b -c -c '' -- a
+>-a -b -c -c '' -- a d
+>-a -b -c -c d -- a
+
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- a b c
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a b c
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a --bbb c
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a --bbb=c
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a --bbb --ccc
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a --bbb --ccc d
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a --bbb --ccc --ccc
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a --bbb --ccc --ccc d
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a --bbb --ccc --ccc= d
+ zgetopt -A '' -l aaa,bbb:,ccc:: -- --aaa a --bbb --ccc --ccc=d
+0:long options
+>-- a b c
+>--aaa --
+>--aaa -- a b c
+>--aaa --bbb c -- a
+>--aaa --bbb c -- a
+>--aaa --bbb --ccc -- a
+>--aaa --bbb --ccc -- a d
+>--aaa --bbb --ccc --ccc '' -- a
+>--aaa --bbb --ccc --ccc '' -- a d
+>--aaa --bbb --ccc --ccc '' -- a d
+>--aaa --bbb --ccc --ccc d -- a
+
+ zgetopt -A '' -o ''
+0:zero args to parse
+>--
+
+ zgetopt -A '' -o '' -- -- a b c
+ zgetopt -A '' -o '' -- a b -- c
+ zgetopt -A '' -o '' -- a b c --
+ zgetopt -A '' -o c -- a b -- -c
+ zgetopt -A '' -o c -- a b - -c
+0:parsing terminator
+>-- a b c
+>-- a b c
+>-- a b c
+>-- a b -c
+>-c -- a b -
+
+ zgetopt -A '' -o a -- a -a b
+ zgetopt -A '' -o +a -- a -a b
+ POSIXLY_CORRECT=1 zgetopt -A '' -o a -- a -a b
+0:POSIXLY_CORRECT
+>-a -- a b
+>-- a -a b
+>-- a -a b
+
+ zgetopt -A '' -o '' -- 'foo bar' $'bar\tbaz' $'\a\'\a'
+0:function-mode quoting style
+>-- 'foo bar' $'bar\tbaz' $'\C-G\'\C-G'
+
+ zgetopt -A '' -o '' -- a -a b
+ zgetopt -A '' -o '' -- a --a b
+1:bad options
+?(eval): bad option: -a
+?(eval): bad option: --a
+
+ zgetopt -A '' -o a: -- a -a
+ zgetopt -A '' -l a: -- a --a
+1:missing optargs
+?(eval): missing argument for option: -a
+?(eval): missing argument for option: --a
+
+ zgetopt -A '' ; echo $? # missing spec
+ zgetopt -A '' -o '' -x ; echo $? # bad option to zgetopt
+ zgetopt -A '' -o '' -- -y; echo $? # bad option to parse
+-:return status
+*?\(eval\):zgetopt: missing option spec
+*>2
+*?\(eval\):zgetopt: bad option: -x
+*?usage:*
+*>2
+*?\(eval\): bad option: -y
+*>1
+
+ () { zgetopt -o a -- "$@"; typeset -p argv } -a b c
+ () { local -a v; zgetopt -A v -o a -- "$@"; typeset -p argv v } -a b c
+0:array output
+>typeset -g -a argv=( -a -- b c )
+>typeset -g -a argv=( -a b c )
+>typeset -a v=( -a -- b c )
+
+ zgetopt -A '' -o a: -- -x
+ zgetopt -A '' -o a: -- -a
+ () { zgetopt -A '' -o a: -- "$@"; : } -x
+ func() { zgetopt -A '' -o a: -- "$@"; : }; func -x
+ f1() { zgetopt -A '' -o a: -- "$@"; : }; f2() { f1 "$@" }; f2 -x
+0:automatic name
+?(eval): bad option: -x
+?(eval): missing argument for option: -a
+?(anon): bad option: -x
+?func: bad option: -x
+?f1: bad option: -x
+
+ zgetopt -n aaa -A '' -o a: -- -x
+ zgetopt -n aaa -A '' -o a: -- -a
+ () { zgetopt -n bbb -A '' -o a: -- "$@"; : } -x
+ func() { zgetopt -n ccc -A '' -o a: -- "$@"; : }; func -x
+ f1() { zgetopt -n ddd -A '' -o a: -- "$@"; : }; f2() { f1 "$@" }; f2 -x
+0:manual name with -n
+?aaa: bad option: -x
+?aaa: missing argument for option: -a
+?bbb: bad option: -x
+?ccc: bad option: -x
+?ddd: bad option: -x
+
+ () {
+ zgetopt -A '' -n example.bash -o ab:c:: -l a-long,b-long:,c-long:: -- "$@"
+ } \
+ -a --a-long \
+ -barg_bs1 -b arg_bs2 --b-long=arg_bl1 --b-long arg_bl2 \
+ -carg_cs1 -c not_arg_cs1 --c-long=arg_cl1 --c-long not_arg_cl2 \
+ arg_p "string with quotes and space: '' \"\" "
+0:example from util-linux's getopt-example.bash
+>-a --a-long -b arg_bs1 -b arg_bs2 --b-long arg_bl1 --b-long arg_bl2 -c arg_cs1 -c '' --c-long arg_cl1 --c-long '' -- not_arg_cs1 not_arg_cl2 arg_p 'string with quotes and space: '\'\'' "" '
+
+ (
+ unfunction zgetopt
+ autoload -Uz zgetopt
+ zgetopt
+ )
+ (
+ unfunction zgetopt
+ autoload -Uz zgetopt
+ zgetopt -o abc -- -ab
+ print -r - ${(q+)argv}
+ )
+-:result immediately after auto-load
+?(eval):zgetopt: missing option spec
+>-a -b --
+
+ (
+ setopt no_function_argzero
+ zgetopt
+ )
+-:error name with no_function_argzero
+?(eval):zgetopt: missing option spec
diff --git a/Test/comptest b/Test/comptest
index 39ad14768..31de475e5 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -21,7 +21,7 @@ comptestinit () {
export PS1="<PROMPT>"
zpty zsh "$comptest_zsh -f +Z"
- zpty -r zsh log1 "*<PROMPT>*" || {
+ zpty_read log1 "*<PROMPT>*" || {
print "first prompt hasn't appeared."
return 1
}
@@ -99,20 +99,47 @@ bindkey -a "^X" zle-finish
'
}
+# Reads output until the pattern $2 is matched or the end is reached.
+# Detects, prints, and removes any DPUTS messages found in the output.
+# Stores the result in the parameter named $1. Returns 0 iff the
+# pattern was matched.
+zpty_read() {
+ local logvar=$1 pattern=$2
+ zpty -r -m zsh $logvar $pattern
+ local -i result=$?
+ zpty_handle_dputs $logvar
+ return result
+}
+
zpty_flush() {
local junk
if zpty -r -t zsh junk \*; then
+ zpty_handle_dputs junk
(( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "$*: ${(V)junk}"
while zpty -r -t zsh junk \* ; do
+ zpty_handle_dputs junk
(( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "${(V)junk}"
done
(( ZTST_verbose > 2 )) && print -u $ZTST_fd ''
fi
}
+# Detects, prints as "DPUTS:{<message>}\n", and removes any DPUTS
+# messages found in the parameter named $1.
+zpty_handle_dputs() {
+ local -nu log=$1
+ local -i lastend=0
+ while (( ${(N)${log[lastend+1,-1]}#*(#b)((<->:|) *.c:<->: *[$'\r\n'])} )); do
+ print -u2 -r "DPUTS:{${match[1][1,-2]}}"
+ log[lastend+$mbegin[1],lastend+$mend[1]]=""
+ [[ $log[lastend+$mbegin[1]] != $'\n' ]] || log[lastend+$mbegin[1]]=""
+ lastend+=$mbegin[1]
+ done
+}
+
zpty_run() {
zpty -w zsh "$*"
- zpty -r -m zsh log "*<PROMPT>*" || {
+ zpty_read log "*<PROMPT>*" || {
print "prompt hasn't appeared."
return 1
}
@@ -130,7 +157,7 @@ comptesteval () {
# zpty_flush Before comptesteval
zpty -w zsh ". ${(q)tmp}"
- zpty -r -m zsh log_eval "*<PROMPT>*" || {
+ zpty_read log_eval "*<PROMPT>*" || {
print "prompt hasn't appeared."
return 1
}
@@ -144,7 +171,7 @@ comptesteval () {
comptest () {
input="$*"
zpty -n -w zsh "$input"$'\C-Z'
- zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+ zpty_read log "*<WIDGET><finish>*<PROMPT>*" || {
print "failed to invoke finish widget."
return 1
}
@@ -184,7 +211,7 @@ zletest () {
zpty -n -w zsh "$input"
done
zpty -n -w zsh $'\C-X'
- zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+ zpty_read log "*<WIDGET><finish>*<PROMPT>*" || {
print "failed to invoke finish widget."
return 1
}
diff --git a/Test/runtests.zsh b/Test/runtests.zsh
index 538663f50..9fe694a60 100644
--- a/Test/runtests.zsh
+++ b/Test/runtests.zsh
@@ -8,21 +8,55 @@ emulate zsh
# We could probably do that with subshells instead.
integer success=0 failure=0 skipped=0 retval
+typeset resln rule col
+typeset -a ffiles res
+
+# colour to use for ztst failure messages. also used as a signal that colours
+# are available generally
+[[ -t 1 ]] &&
+(( ! $+ZTST_failcolour )) &&
+[[ -z $NO_COLOR ]] &&
+[[ $TERM == *color* || "$( tput colors 2> /dev/null )" == <8-> ]] &&
+typeset -x ZTST_failcolour=red
+
for file in "${(f)ZTST_testlist}"; do
+ file=${file#./}
$ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh $file
retval=$?
if (( $retval == 2 )); then
(( skipped++ ))
elif (( $retval )); then
(( failure++ ))
- (( $retval > 128 )) && print "$file: failed: SIG$signals[$retval - 127]."
+ (( $retval > 128 )) && print -r - "$file: failed: SIG$signals[$retval - 127]."
+ ffiles+=( $file )
else
(( success++ ))
fi
+ print
done
-print "**************************************
-$success successful test script${${success:#1}:+s}, \
-$failure failure${${failure:#1}:+s}, \
-$skipped skipped
-**************************************"
+
+res=(
+ "$success successful test script${${success:#1}:+s}"
+ "$failure failure${${failure:#1}:+s}"
+ "$skipped skipped"
+)
+resln=${(j<, >)res}
+rule=${resln//?/\*}
+
+[[ -n $ZTST_failcolour ]] &&
+if (( failure )); then
+ col=red
+elif (( success )); then
+ col=green
+else
+ col=yellow
+fi
+
+(( $#col )) && print -rnP - "%F{$col}"
+print -rl - $rule $resln
+(( $#ffiles )) &&
+print -rl - '' "failing test script${${#ffiles:#1}:+s}:" ${(@)ffiles/#/ }
+print -rl - $rule
+(( $#col )) && print -rnP - %f
+
return $(( failure ? 1 : 0 ))
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index aeb02cd54..ae5133e4d 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -148,7 +148,9 @@ ZTST_testfailed() {
if [[ -n $ZTST_message ]]; then
print -r "Was testing: $ZTST_message"
fi
+ [[ -n $ZTST_failcolour ]] && print -rnP "%F{$ZTST_failcolour}"
print -r "$ZTST_testname: test failed."
+ [[ -n $ZTST_failcolour ]] && print -rnP %f
if [[ -n $ZTST_failmsg ]]; then
print -r "The following may (or may not) help identifying the cause:
$ZTST_failmsg"
@@ -165,7 +167,9 @@ ZTST_testxpassed() {
if [[ -n $ZTST_message ]]; then
print -r "Was testing: $ZTST_message"
fi
+ [[ -n $ZTST_failcolour ]] && print -rnP "%F{$ZTST_failcolour}"
print -r "$ZTST_testname: test XPassed."
+ [[ -n $ZTST_failcolour ]] && print -rnP %f
if [[ -n $ZTST_failmsg ]]; then
print -r "The following may (or may not) help identifying the cause:
$ZTST_failmsg"
@@ -326,7 +330,6 @@ ZTST_diff() {
emulate -L zsh
setopt extendedglob
- local -a diff_arg
local diff_out
integer diff_pat diff_ret
@@ -343,8 +346,38 @@ ZTST_diff() {
;;
esac
shift
- [[ $OSTYPE != (aix|solaris)* ]] && diff_arg=( -a )
-
+
+ (( $+functions[ZTST_do_diff] )) ||
+ ZTST_do_diff() {
+ local MATCH MBEGIN MEND ret
+ local -a out cmd
+
+ cmd=( command diff -u )
+ [[ $OSTYPE != (aix|solaris)* ]] && cmd+=( -a )
+
+ out=( ${(f)"$( $cmd "$@" )"} ) || ret=$?
+
+ # massage + colourise diff
+ (( ret )) && {
+ local B=${(%):-%B} b=${(%):-%b} f=${(%):-%f}
+ local Fr=${(%):-'%F{red}'} Fg=${(%):-'%F{green}'} Fc=${(%):-'%F{cyan}'}
+
+ [[ -n $ZTST_failcolour ]] || B= b= Fr= Fg= Fc= f=
+
+ out[1]=${out[1]/#---*/$B--- expected$b}
+ out[2]=${out[2]/#+++*/$B+++ actual$b}
+
+ (( $#B )) && {
+ out=( ${(@)out/#(#m)@@*/$Fc$MATCH$f} )
+ out=( ${(@)out/#(#m)-*/$Fr$MATCH$f} )
+ out=( ${(@)out/#(#m)+*/$Fg$MATCH$f} )
+ }
+ }
+
+ print -rl - $out
+ return ret
+ }
+
if (( diff_pat )); then
local -a diff_lines1 diff_lines2
integer failed i l
@@ -365,30 +398,19 @@ ZTST_diff() {
done
fi
if (( failed )); then
- for (( l = 1; l <= ${#diff_lines1}; ++l )); do
- if (( l == i )); then
- p="-"
- else
- p=" "
- fi
- print -r -- "$p<${diff_lines1[l]}"
- done
- for (( l = 1; l <= ${#diff_lines2}; ++l )); do
- if (( l == i )); then
- p="+"
- else
- p=" "
- fi
- print -r -- "$p>${diff_lines2[l]}"
- done
+ diff_out=$( ZTST_do_diff \
+ <( print -rl - "${(@)diff_lines1}" ) \
+ <( print -rl - "${(@)diff_lines2}" )
+ )
diff_ret=1
fi
else
- diff_out=$(diff $diff_arg "$@")
+ diff_out=$(ZTST_do_diff "$@")
diff_ret="$?"
- if [[ "$diff_ret" != "0" ]]; then
- print -r -- "$diff_out"
- fi
+ fi
+
+ if [[ "$diff_ret" != "0" ]]; then
+ print -r -- "$diff_out"
fi
return "$diff_ret"
@@ -526,7 +548,7 @@ $(<$ZTST_terr)"
rm -rf $ZTST_out
print -r -- "${(e)substlines}" >$ZTST_out
fi
- if [[ $ZTST_flags != *d* ]] && ! $ZTST_diff $diff_out -u $ZTST_out $ZTST_tout; then
+ if [[ $ZTST_flags != *d* ]] && ! $ZTST_diff $diff_out $ZTST_out $ZTST_tout; then
if (( expected_to_fail )); then
ZTST_verbose 1 "Test failed, as expected."
continue
@@ -542,7 +564,7 @@ $(<$ZTST_terr)}"
rm -rf $ZTST_err
print -r -- "${(e)substlines}" >$ZTST_err
fi
- if [[ $ZTST_flags != *D* ]] && ! $ZTST_diff $diff_err -u $ZTST_err $ZTST_terr; then
+ if [[ $ZTST_flags != *D* ]] && ! $ZTST_diff $diff_err $ZTST_err $ZTST_terr; then
if (( expected_to_fail )); then
ZTST_verbose 1 "Test failed, as expected."
continue
diff --git a/Util/zsh-merge-changelog b/Util/zsh-merge-changelog
new file mode 100755
index 000000000..053f02184
--- /dev/null
+++ b/Util/zsh-merge-changelog
@@ -0,0 +1,125 @@
+#!/usr/bin/env zsh
+
+# this is a git merge driver that magically fixes conflicts in the ChangeLog
+# file (for simple additions at least). useful for back-porting
+#
+# to use, add this to your .git/config:
+#
+# [merge "zsh-merge-changelog"]
+# name = merge the zsh changelog somewhat reasonably
+# driver = Util/zsh-merge-changelog %O %A %B %L %P
+#
+# and add this to your .git/info/attributes:
+#
+# /ChangeLog merge=zsh-merge-changelog
+#
+# note: currently the ChangeLog is still updated even when the rest of the merge
+# would be a no-op
+#
+# original script written by Mikachu
+
+emulate -L zsh -o extended_glob -o warn_create_global
+
+eputs() {
+ [[ $1 == (-|--) ]] && shift
+ print -rlu2 - "${ZSH_ARGZERO:t}: $1" "${@[2,-1]}"
+}
+
+main() {
+ local tmp=${TMPDIR:-/tmp}/${ZSH_ARGZERO:t}.$$.$RANDOM
+ local diff line ctx_after header data datb idx color
+ local -a out orig
+
+ diff=$( git diff --no-index -U200 -- $1 $3 )
+
+ for line in ${${(f)diff}[5,-1]}; do
+ case $line in
+ @@*) ;;
+ ' '*)
+ (( $#out )) && ctx_after=1
+ # commit header from context (entry added under existing header)
+ (( ! $#out )) && [[ $line == ' '<->-<->-<->* ]] && header=$line[2,-1]
+ ;;
+ +*)
+ (( ctx_after )) && {
+ eputs 'unable to handle non-consecutive addition'
+ return 1
+ }
+ [[ -n $header ]] && {
+ out+=( $header '' )
+ header=
+ }
+ out+=( "$line[2,-1]" )
+ ;;
+ -*)
+ eputs 'unable to handle deletion'
+ return 1
+ ;;
+ *)
+ eputs 'unexpected line in diff:' $line
+ return 1
+ ;;
+ esac
+ done
+
+ (( $#out )) || {
+ eputs 'no changed lines found'
+ return 1
+ }
+ [[ $out[1] == <->-<->-<->* && $out[2] == '' ]] || {
+ eputs 'commit header not found'
+ return 1
+ }
+
+ trap "rm -f -- ${(q+)tmp}" EXIT HUP INT
+
+ orig=( "${(@f)"$( < $2 )"}" )
+
+ data=${(M)orig[1]##<->-<->-<->}
+ [[ -n $data ]] || {
+ eputs 'failed to get latest date in original change log'
+ return 1
+ }
+ datb=${(M)out[1]##<->-<->-<->}
+
+ # new entry later than last -- just prepend
+ if [[ $datb > $data ]]; then
+ print -rl - "${(@)out}" "${(@)orig}" > $tmp || return
+
+ # header already present in file -- re-use it. this always inserts above the
+ # existing entries, so it might not be the same order it was in originally.
+ # but it's fine
+ elif [[ -n ${(M)orig:#$out[1]} ]]; then
+ idx=$orig[(ie)$out[1]]
+ print -rl - \
+ "${(@)orig[1,idx]}" \
+ "${(@)out[2,-1]}" \
+ "${(@)orig[idx+2,-1]}" \
+ > $tmp || return
+
+ # insert in the middle somewhere
+ else
+ for (( idx = 1; idx <= $#orig; idx++ )); do
+ data=${(M)orig[idx]##<->-<->-<->}
+ [[ -n $data && $datb > $data ]] || continue
+ print -rl - \
+ "${(@)orig[1,idx-1]}" \
+ "${(@)out}" \
+ "${(@)orig[idx,-1]}" \
+ > $tmp || return
+ break
+ done
+ fi
+
+ [[ -t 2 ]] && color=--color=always
+ out=( "${(@f)"$( git diff --no-index $color -U4 -- $2 $tmp )"}" )
+ out=( "${(@)out[3,-1]}" )
+ out[1]=${out[1]/a\/[^[:cntrl:]]##/a/$5}
+ out[2]=${out[2]/b\/[^[:cntrl:]]##/b/$5}
+ eputs 'fixed ChangeLog entry:' "${(F)out}"
+
+ [[ -n $ZMC_FAIL ]] && return 1 # for testing
+ cp -- $tmp $2
+}
+
+main "$@"
diff --git a/aczsh.m4 b/aczsh.m4
index b31236020..3b2dbe37b 100644
--- a/aczsh.m4
+++ b/aczsh.m4
@@ -472,7 +472,7 @@ fi
])
dnl
-dnl zsh_SYS_DYNAMIC_STRIP_EXE
+dnl zsh_SYS_DYNAMIC_STRIP_LIB
dnl Check whether it is safe to strip dynamically loaded libraries.
dnl
diff --git a/config.guess b/config.guess
index 11fda528b..c7f4c3294 100755
--- a/config.guess
+++ b/config.guess
@@ -1,12 +1,14 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright 1992-2020 Free Software Foundation, Inc.
+# Copyright 1992-2026 Free Software Foundation, Inc.
-timestamp='2020-04-26'
+# shellcheck disable=SC2006,SC2268 # see below for rationale
+
+timestamp='2026-05-17'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -27,17 +29,25 @@ timestamp='2020-04-26'
# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
#
# You can get the latest version of this script from:
-# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
#
# Please send patches to <config-patches@gnu.org>.
+# The "shellcheck disable" line above the timestamp inhibits complaints
+# about features and limitations of the classic Bourne shell that were
+# superseded or lifted in POSIX. However, this script identifies a wide
+# variety of pre-POSIX systems that do not have POSIX shells at all, and
+# even some reasonably current systems (Solaris 10 as case-in-point) still
+# have a pre-POSIX /bin/sh.
+
+
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
Usage: $0 [OPTION]
-Output the configuration name of the system \`$me' is run on.
+Output the configuration name of the system '$me' is run on.
Options:
-h, --help print this help, then exit
@@ -50,13 +60,13 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
-Copyright 1992-2020 Free Software Foundation, Inc.
+Copyright 1992-2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
-Try \`$me --help' for more information."
+Try '$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
@@ -84,13 +94,16 @@ if test $# != 0; then
exit 1
fi
+# Just in case it came from the environment.
+GUESS=
+
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
# compiler to aid in system detection is discouraged as it requires
# temporary files to be created and, as you can see below, it is a
# headache to deal with in a portable fashion.
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
+# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
+# use 'HOST_CC' if defined, but it is deprecated.
# Portable tmp directory creation inspired by the Autoconf team.
@@ -102,7 +115,7 @@ set_cc_for_build() {
# prevent multiple calls if $tmp is already set
test "$tmp" && return 0
: "${TMPDIR=/tmp}"
- # shellcheck disable=SC2039
+ # shellcheck disable=SC2039,SC3028
{ tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
@@ -110,9 +123,9 @@ set_cc_for_build() {
dummy=$tmp/dummy
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
,,) echo "int x;" > "$dummy.c"
- for driver in cc gcc c89 c99 ; do
+ for driver in cc gcc c17 c99 c89 ; do
if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
- CC_FOR_BUILD="$driver"
+ CC_FOR_BUILD=$driver
break
fi
done
@@ -133,40 +146,59 @@ fi
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
-UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
-case "$UNAME_SYSTEM" in
-Linux|GNU|GNU/*)
- # If the system lacks a compiler, then just pick glibc.
- # We could probably try harder.
- LIBC=gnu
+case $UNAME_SYSTEM in
+Ironclad|Linux|GNU|GNU/*)
+ LIBC=unknown
set_cc_for_build
cat <<-EOF > "$dummy.c"
+ #if defined(__ANDROID__)
+ LIBC=android
+ #else
#include <features.h>
#if defined(__UCLIBC__)
LIBC=uclibc
#elif defined(__dietlibc__)
LIBC=dietlibc
- #else
+ #elif defined(__GLIBC__)
LIBC=gnu
+ #elif defined(__LLVM_LIBC__)
+ LIBC=llvm
+ #elif defined(__mlibc__)
+ LIBC=mlibc
+ #else
+ #include <stdarg.h>
+ /* First heuristic to detect musl libc. */
+ #ifdef __DEFINED_va_list
+ LIBC=musl
+ #endif
+ #endif
#endif
EOF
- eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+ cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+ eval "$cc_set_libc"
- # If ldd exists, use it to detect musl libc.
- if command -v ldd >/dev/null && \
- ldd --version 2>&1 | grep -q ^musl
- then
- LIBC=musl
+ # Second heuristic to detect musl libc.
+ if [ "$LIBC" = unknown ] &&
+ command -v ldd >/dev/null &&
+ ldd --version 2>&1 | grep -q ^musl; then
+ LIBC=musl
+ fi
+
+ # If the system lacks a compiler, then just pick glibc.
+ # We could probably try harder.
+ if [ "$LIBC" = unknown ]; then
+ LIBC=gnu
fi
;;
esac
# Note: order is significant - the case branches are not exclusive.
-case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
+case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
@@ -178,12 +210,12 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
#
# Note: NetBSD doesn't particularly care about the vendor
# portion of the name. We always set it to "unknown".
- sysctl="sysctl -n hw.machine_arch"
UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
- "/sbin/$sysctl" 2>/dev/null || \
- "/usr/sbin/$sysctl" 2>/dev/null || \
+ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
+ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
echo unknown)`
- case "$UNAME_MACHINE_ARCH" in
+ case $UNAME_MACHINE_ARCH in
+ aarch64eb) machine=aarch64_be-unknown ;;
armeb) machine=armeb-unknown ;;
arm*) machine=arm-unknown ;;
sh3el) machine=shl-unknown ;;
@@ -192,13 +224,13 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
earmv*)
arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
- machine="${arch}${endian}"-unknown
+ machine=${arch}${endian}-unknown
;;
- *) machine="$UNAME_MACHINE_ARCH"-unknown ;;
+ *) machine=$UNAME_MACHINE_ARCH-unknown ;;
esac
# The Operating System including object format, if it has switched
# to ELF recently (or will in the future) and ABI.
- case "$UNAME_MACHINE_ARCH" in
+ case $UNAME_MACHINE_ARCH in
earm*)
os=netbsdelf
;;
@@ -219,7 +251,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
;;
esac
# Determine ABI tags.
- case "$UNAME_MACHINE_ARCH" in
+ case $UNAME_MACHINE_ARCH in
earm*)
expr='s/^earmv[0-9]/-eabi/;s/eb$//'
abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
@@ -230,7 +262,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# thus, need a distinct triplet. However, they do not need
# kernel version information, so it can be replaced with a
# suitable tag, in the style of linux-gnu.
- case "$UNAME_VERSION" in
+ case $UNAME_VERSION in
Debian*)
release='-gnu'
;;
@@ -241,51 +273,57 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
# contains redundant information, the shorter form:
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
- echo "$machine-${os}${release}${abi-}"
- exit ;;
+ GUESS=$machine-${os}${release}${abi-}
+ ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
- echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
+ ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
- echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
+ ;;
+ *:SecBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
+ GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
+ ;;
*:LibertyBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
- echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
+ ;;
*:MidnightBSD:*:*)
- echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
+ ;;
*:ekkoBSD:*:*)
- echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
+ ;;
*:SolidBSD:*:*)
- echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
+ ;;
*:OS108:*:*)
- echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
+ ;;
macppc:MirBSD:*:*)
- echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
+ ;;
*:MirBSD:*:*)
- echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
+ ;;
*:Sortix:*:*)
- echo "$UNAME_MACHINE"-unknown-sortix
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-sortix
+ ;;
*:Twizzler:*:*)
- echo "$UNAME_MACHINE"-unknown-twizzler
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-twizzler
+ ;;
*:Redox:*:*)
- echo "$UNAME_MACHINE"-unknown-redox
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-redox
+ ;;
mips:OSF1:*.*)
- echo mips-dec-osf1
- exit ;;
+ GUESS=mips-dec-osf1
+ ;;
alpha:OSF1:*:*)
+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+ trap '' 0
case $UNAME_RELEASE in
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -299,7 +337,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# covers most systems running today. This code pipes the CPU
# types through head -n 1, so we only detect the type of CPU 0.
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
- case "$ALPHA_CPU_TYPE" in
+ case $ALPHA_CPU_TYPE in
"EV4 (21064)")
UNAME_MACHINE=alpha ;;
"EV4.5 (21064)")
@@ -336,117 +374,121 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# A Tn.n version is a released field test version.
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
- echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
- # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
- exitcode=$?
- trap '' 0
- exit $exitcode ;;
+ OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+ GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
+ ;;
Amiga*:UNIX_System_V:4.0:*)
- echo m68k-unknown-sysv4
- exit ;;
+ GUESS=m68k-unknown-sysv4
+ ;;
*:[Aa]miga[Oo][Ss]:*:*)
- echo "$UNAME_MACHINE"-unknown-amigaos
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-amigaos
+ ;;
*:[Mm]orph[Oo][Ss]:*:*)
- echo "$UNAME_MACHINE"-unknown-morphos
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-morphos
+ ;;
*:OS/390:*:*)
- echo i370-ibm-openedition
- exit ;;
+ GUESS=i370-ibm-openedition
+ ;;
*:z/VM:*:*)
- echo s390-ibm-zvmoe
- exit ;;
+ GUESS=s390-ibm-zvmoe
+ ;;
*:OS400:*:*)
- echo powerpc-ibm-os400
- exit ;;
+ GUESS=powerpc-ibm-os400
+ ;;
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
- echo arm-acorn-riscix"$UNAME_RELEASE"
- exit ;;
+ GUESS=arm-acorn-riscix$UNAME_RELEASE
+ ;;
arm*:riscos:*:*|arm*:RISCOS:*:*)
- echo arm-unknown-riscos
- exit ;;
+ GUESS=arm-unknown-riscos
+ ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
- echo hppa1.1-hitachi-hiuxmpp
- exit ;;
+ GUESS=hppa1.1-hitachi-hiuxmpp
+ ;;
Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
- if test "`(/bin/universe) 2>/dev/null`" = att ; then
- echo pyramid-pyramid-sysv3
- else
- echo pyramid-pyramid-bsd
- fi
- exit ;;
+ case `(/bin/universe) 2>/dev/null` in
+ att) GUESS=pyramid-pyramid-sysv3 ;;
+ *) GUESS=pyramid-pyramid-bsd ;;
+ esac
+ ;;
NILE*:*:*:dcosx)
- echo pyramid-pyramid-svr4
- exit ;;
+ GUESS=pyramid-pyramid-svr4
+ ;;
DRS?6000:unix:4.0:6*)
- echo sparc-icl-nx6
- exit ;;
+ GUESS=sparc-icl-nx6
+ ;;
DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
case `/usr/bin/uname -p` in
- sparc) echo sparc-icl-nx7; exit ;;
- esac ;;
+ sparc) GUESS=sparc-icl-nx7 ;;
+ esac
+ ;;
s390x:SunOS:*:*)
- echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
+ ;;
sun4H:SunOS:5.*:*)
- echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-hal-solaris2$SUN_REL
+ ;;
sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
- echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-sun-solaris2$SUN_REL
+ ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
- echo i386-pc-auroraux"$UNAME_RELEASE"
- exit ;;
+ GUESS=i386-pc-auroraux$UNAME_RELEASE
+ ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
set_cc_for_build
SUN_ARCH=i386
# If there is a compiler, see if it is configured for 64-bit objects.
# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
# This test works for both compilers.
- if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
- (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
SUN_ARCH=x86_64
fi
fi
- echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
+ ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# SunOS6. Hard to guess exactly what SunOS6 will be like, but
# it's likely to be more like Solaris than SunOS4.
- echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=sparc-sun-solaris3$SUN_REL
+ ;;
sun4*:SunOS:*:*)
- case "`/usr/bin/arch -k`" in
+ case `/usr/bin/arch -k` in
Series*|S4*)
UNAME_RELEASE=`uname -v`
;;
esac
- # Japanese Language versions have a version number like `4.1.3-JL'.
- echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
- exit ;;
+ # Japanese Language versions have a version number like '4.1.3-JL'.
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
+ GUESS=sparc-sun-sunos$SUN_REL
+ ;;
sun3*:SunOS:*:*)
- echo m68k-sun-sunos"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-sun-sunos$UNAME_RELEASE
+ ;;
sun*:*:4.2BSD:*)
UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
- case "`/bin/arch`" in
+ case `/bin/arch` in
sun3)
- echo m68k-sun-sunos"$UNAME_RELEASE"
+ GUESS=m68k-sun-sunos$UNAME_RELEASE
;;
sun4)
- echo sparc-sun-sunos"$UNAME_RELEASE"
+ GUESS=sparc-sun-sunos$UNAME_RELEASE
;;
esac
- exit ;;
+ ;;
aushp:SunOS:*:*)
- echo sparc-auspex-sunos"$UNAME_RELEASE"
- exit ;;
+ GUESS=sparc-auspex-sunos$UNAME_RELEASE
+ ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
# "atarist" or "atariste" at least should have a processor
@@ -456,41 +498,41 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
# MiNT. But MiNT is downward compatible to TOS, so this should
# be no problem.
atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
- echo m68k-atari-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
*falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
- echo m68k-atari-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-atari-mint$UNAME_RELEASE
+ ;;
milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
- echo m68k-milan-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-milan-mint$UNAME_RELEASE
+ ;;
hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
- echo m68k-hades-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-hades-mint$UNAME_RELEASE
+ ;;
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
- echo m68k-unknown-mint"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-unknown-mint$UNAME_RELEASE
+ ;;
m68k:machten:*:*)
- echo m68k-apple-machten"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-apple-machten$UNAME_RELEASE
+ ;;
powerpc:machten:*:*)
- echo powerpc-apple-machten"$UNAME_RELEASE"
- exit ;;
+ GUESS=powerpc-apple-machten$UNAME_RELEASE
+ ;;
RISC*:Mach:*:*)
- echo mips-dec-mach_bsd4.3
- exit ;;
+ GUESS=mips-dec-mach_bsd4.3
+ ;;
RISC*:ULTRIX:*:*)
- echo mips-dec-ultrix"$UNAME_RELEASE"
- exit ;;
+ GUESS=mips-dec-ultrix$UNAME_RELEASE
+ ;;
VAX*:ULTRIX*:*:*)
- echo vax-dec-ultrix"$UNAME_RELEASE"
- exit ;;
+ GUESS=vax-dec-ultrix$UNAME_RELEASE
+ ;;
2020:CLIX:*:* | 2430:CLIX:*:*)
- echo clipper-intergraph-clix"$UNAME_RELEASE"
- exit ;;
+ GUESS=clipper-intergraph-clix$UNAME_RELEASE
+ ;;
mips:*:*:UMIPS | mips:*:*:RISCos)
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
@@ -518,82 +560,84 @@ EOF
dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
{ echo "$SYSTEM_NAME"; exit; }
- echo mips-mips-riscos"$UNAME_RELEASE"
- exit ;;
+ GUESS=mips-mips-riscos$UNAME_RELEASE
+ ;;
Motorola:PowerMAX_OS:*:*)
- echo powerpc-motorola-powermax
- exit ;;
+ GUESS=powerpc-motorola-powermax
+ ;;
Motorola:*:4.3:PL8-*)
- echo powerpc-harris-powermax
- exit ;;
+ GUESS=powerpc-harris-powermax
+ ;;
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
- echo powerpc-harris-powermax
- exit ;;
+ GUESS=powerpc-harris-powermax
+ ;;
Night_Hawk:Power_UNIX:*:*)
- echo powerpc-harris-powerunix
- exit ;;
+ GUESS=powerpc-harris-powerunix
+ ;;
m88k:CX/UX:7*:*)
- echo m88k-harris-cxux7
- exit ;;
+ GUESS=m88k-harris-cxux7
+ ;;
m88k:*:4*:R4*)
- echo m88k-motorola-sysv4
- exit ;;
+ GUESS=m88k-motorola-sysv4
+ ;;
m88k:*:3*:R3*)
- echo m88k-motorola-sysv3
- exit ;;
+ GUESS=m88k-motorola-sysv3
+ ;;
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
+ if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
then
- if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
- [ "$TARGET_BINARY_INTERFACE"x = x ]
+ if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
+ test "$TARGET_BINARY_INTERFACE"x = x
then
- echo m88k-dg-dgux"$UNAME_RELEASE"
+ GUESS=m88k-dg-dgux$UNAME_RELEASE
else
- echo m88k-dg-dguxbcs"$UNAME_RELEASE"
+ GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
fi
else
- echo i586-dg-dgux"$UNAME_RELEASE"
+ GUESS=i586-dg-dgux$UNAME_RELEASE
fi
- exit ;;
+ ;;
M88*:DolphinOS:*:*) # DolphinOS (SVR3)
- echo m88k-dolphin-sysv3
- exit ;;
+ GUESS=m88k-dolphin-sysv3
+ ;;
M88*:*:R3*:*)
# Delta 88k system running SVR3
- echo m88k-motorola-sysv3
- exit ;;
+ GUESS=m88k-motorola-sysv3
+ ;;
XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
- echo m88k-tektronix-sysv3
- exit ;;
+ GUESS=m88k-tektronix-sysv3
+ ;;
Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
- echo m68k-tektronix-bsd
- exit ;;
+ GUESS=m68k-tektronix-bsd
+ ;;
*:IRIX*:*:*)
- echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
- exit ;;
+ IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
+ GUESS=mips-sgi-irix$IRIX_REL
+ ;;
????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
- echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
- exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ ;; # Note that: echo "'`uname -s`'" gives 'AIX '
i*86:AIX:*:*)
- echo i386-ibm-aix
- exit ;;
+ GUESS=i386-ibm-aix
+ ;;
ia64:AIX:*:*)
- if [ -x /usr/bin/oslevel ] ; then
+ if test -x /usr/bin/oslevel ; then
IBM_REV=`/usr/bin/oslevel`
else
- IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
fi
- echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
- exit ;;
+ GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
+ ;;
*:AIX:2:3)
if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h>
- main()
+ int
+ main ()
{
if (!__power_pc())
exit(1);
@@ -603,16 +647,16 @@ EOF
EOF
if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
then
- echo "$SYSTEM_NAME"
+ GUESS=$SYSTEM_NAME
else
- echo rs6000-ibm-aix3.2.5
+ GUESS=rs6000-ibm-aix3.2.5
fi
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
- echo rs6000-ibm-aix3.2.4
+ GUESS=rs6000-ibm-aix3.2.4
else
- echo rs6000-ibm-aix3.2
+ GUESS=rs6000-ibm-aix3.2
fi
- exit ;;
+ ;;
*:AIX:*:[4567])
IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
@@ -620,56 +664,56 @@ EOF
else
IBM_ARCH=powerpc
fi
- if [ -x /usr/bin/lslpp ] ; then
- IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
+ if test -x /usr/bin/lslpp ; then
+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
else
- IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
fi
- echo "$IBM_ARCH"-ibm-aix"$IBM_REV"
- exit ;;
+ GUESS=$IBM_ARCH-ibm-aix$IBM_REV
+ ;;
*:AIX:*:*)
- echo rs6000-ibm-aix
- exit ;;
+ GUESS=rs6000-ibm-aix
+ ;;
ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
- echo romp-ibm-bsd4.4
- exit ;;
+ GUESS=romp-ibm-bsd4.4
+ ;;
ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
- echo romp-ibm-bsd"$UNAME_RELEASE" # 4.3 with uname added to
- exit ;; # report: romp-ibm BSD 4.3
+ GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to
+ ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
- echo rs6000-bull-bosx
- exit ;;
+ GUESS=rs6000-bull-bosx
+ ;;
DPX/2?00:B.O.S.:*:*)
- echo m68k-bull-sysv3
- exit ;;
+ GUESS=m68k-bull-sysv3
+ ;;
9000/[34]??:4.3bsd:1.*:*)
- echo m68k-hp-bsd
- exit ;;
+ GUESS=m68k-hp-bsd
+ ;;
hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
- echo m68k-hp-bsd4.4
- exit ;;
+ GUESS=m68k-hp-bsd4.4
+ ;;
9000/[34678]??:HP-UX:*:*)
- HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
- case "$UNAME_MACHINE" in
+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
+ case $UNAME_MACHINE in
9000/31?) HP_ARCH=m68000 ;;
9000/[34]??) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
- if [ -x /usr/bin/getconf ]; then
+ if test -x /usr/bin/getconf; then
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
- case "$sc_cpu_version" in
+ case $sc_cpu_version in
523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
- case "$sc_kernel_bits" in
+ case $sc_kernel_bits in
32) HP_ARCH=hppa2.0n ;;
64) HP_ARCH=hppa2.0w ;;
'') HP_ARCH=hppa2.0 ;; # HP-UX 10.20
esac ;;
esac
fi
- if [ "$HP_ARCH" = "" ]; then
+ if test "$HP_ARCH" = ""; then
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
@@ -677,7 +721,8 @@ EOF
#include <stdlib.h>
#include <unistd.h>
- int main ()
+ int
+ main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
@@ -708,7 +753,7 @@ EOF
test -z "$HP_ARCH" && HP_ARCH=hppa
fi ;;
esac
- if [ "$HP_ARCH" = hppa2.0w ]
+ if test "$HP_ARCH" = hppa2.0w
then
set_cc_for_build
@@ -729,12 +774,12 @@ EOF
HP_ARCH=hppa64
fi
fi
- echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
- exit ;;
+ GUESS=$HP_ARCH-hp-hpux$HPUX_REV
+ ;;
ia64:HP-UX:*:*)
- HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
- echo ia64-hp-hpux"$HPUX_REV"
- exit ;;
+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
+ GUESS=ia64-hp-hpux$HPUX_REV
+ ;;
3050*:HI-UX:*:*)
set_cc_for_build
sed 's/^ //' << EOF > "$dummy.c"
@@ -764,36 +809,36 @@ EOF
EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
{ echo "$SYSTEM_NAME"; exit; }
- echo unknown-hitachi-hiuxwe2
- exit ;;
+ GUESS=unknown-hitachi-hiuxwe2
+ ;;
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
- echo hppa1.1-hp-bsd
- exit ;;
+ GUESS=hppa1.1-hp-bsd
+ ;;
9000/8??:4.3bsd:*:*)
- echo hppa1.0-hp-bsd
- exit ;;
+ GUESS=hppa1.0-hp-bsd
+ ;;
*9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
- echo hppa1.0-hp-mpeix
- exit ;;
+ GUESS=hppa1.0-hp-mpeix
+ ;;
hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
- echo hppa1.1-hp-osf
- exit ;;
+ GUESS=hppa1.1-hp-osf
+ ;;
hp8??:OSF1:*:*)
- echo hppa1.0-hp-osf
- exit ;;
+ GUESS=hppa1.0-hp-osf
+ ;;
i*86:OSF1:*:*)
- if [ -x /usr/sbin/sysversion ] ; then
- echo "$UNAME_MACHINE"-unknown-osf1mk
+ if test -x /usr/sbin/sysversion ; then
+ GUESS=$UNAME_MACHINE-unknown-osf1mk
else
- echo "$UNAME_MACHINE"-unknown-osf1
+ GUESS=$UNAME_MACHINE-unknown-osf1
fi
- exit ;;
+ ;;
parisc*:Lites*:*:*)
- echo hppa1.1-hp-lites
- exit ;;
+ GUESS=hppa1.1-hp-lites
+ ;;
C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
- echo c1-convex-bsd
- exit ;;
+ GUESS=c1-convex-bsd
+ ;;
C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
if getsysinfo -f scalar_acc
then echo c32-convex-bsd
@@ -801,17 +846,18 @@ EOF
fi
exit ;;
C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
- echo c34-convex-bsd
- exit ;;
+ GUESS=c34-convex-bsd
+ ;;
C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
- echo c38-convex-bsd
- exit ;;
+ GUESS=c38-convex-bsd
+ ;;
C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
- echo c4-convex-bsd
- exit ;;
+ GUESS=c4-convex-bsd
+ ;;
CRAY*Y-MP:*:*:*)
- echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=ymp-cray-unicos$CRAY_REL
+ ;;
CRAY*[A-Z]90:*:*:*)
echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
@@ -819,112 +865,153 @@ EOF
-e 's/\.[^.]*$/.X/'
exit ;;
CRAY*TS:*:*:*)
- echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=t90-cray-unicos$CRAY_REL
+ ;;
CRAY*T3E:*:*:*)
- echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=alphaev5-cray-unicosmk$CRAY_REL
+ ;;
CRAY*SV1:*:*:*)
- echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=sv1-cray-unicos$CRAY_REL
+ ;;
*:UNICOS/mp:*:*)
- echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
- exit ;;
+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
+ GUESS=craynv-cray-unicosmp$CRAY_REL
+ ;;
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
- echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
+ GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
+ ;;
5000:UNIX_System_V:4.*:*)
FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
- echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
- exit ;;
+ GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
+ ;;
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
- echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
+ ;;
sparc*:BSD/OS:*:*)
- echo sparc-unknown-bsdi"$UNAME_RELEASE"
- exit ;;
+ GUESS=sparc-unknown-bsdi$UNAME_RELEASE
+ ;;
*:BSD/OS:*:*)
- echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
+ ;;
arm:FreeBSD:*:*)
UNAME_PROCESSOR=`uname -p`
set_cc_for_build
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
- echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabi
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
else
- echo "${UNAME_PROCESSOR}"-unknown-freebsd"`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`"-gnueabihf
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
fi
- exit ;;
+ ;;
*:FreeBSD:*:*)
- UNAME_PROCESSOR=`/usr/bin/uname -p`
- case "$UNAME_PROCESSOR" in
+ UNAME_PROCESSOR=`uname -p`
+ case $UNAME_PROCESSOR in
amd64)
UNAME_PROCESSOR=x86_64 ;;
i386)
UNAME_PROCESSOR=i586 ;;
esac
- echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
- exit ;;
+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
+ ;;
i*:CYGWIN*:*)
- echo "$UNAME_MACHINE"-pc-cygwin
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-cygwin
+ ;;
*:MINGW64*:*)
- echo "$UNAME_MACHINE"-pc-mingw64
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-mingw64
+ ;;
*:MINGW*:*)
- echo "$UNAME_MACHINE"-pc-mingw32
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-mingw32
+ ;;
*:MSYS*:*)
- echo "$UNAME_MACHINE"-pc-msys
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-msys
+ ;;
i*:PW*:*)
- echo "$UNAME_MACHINE"-pc-pw32
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-pw32
+ ;;
+ *:SerenityOS:*:*)
+ GUESS=$UNAME_MACHINE-pc-serenity
+ ;;
*:Interix*:*)
- case "$UNAME_MACHINE" in
+ case $UNAME_MACHINE in
x86)
- echo i586-pc-interix"$UNAME_RELEASE"
- exit ;;
+ GUESS=i586-pc-interix$UNAME_RELEASE
+ ;;
authenticamd | genuineintel | EM64T)
- echo x86_64-unknown-interix"$UNAME_RELEASE"
- exit ;;
+ GUESS=x86_64-unknown-interix$UNAME_RELEASE
+ ;;
IA64)
- echo ia64-unknown-interix"$UNAME_RELEASE"
- exit ;;
+ GUESS=ia64-unknown-interix$UNAME_RELEASE
+ ;;
esac ;;
i*:UWIN*:*)
- echo "$UNAME_MACHINE"-pc-uwin
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-uwin
+ ;;
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
- echo x86_64-pc-cygwin
- exit ;;
+ GUESS=x86_64-pc-cygwin
+ ;;
prep*:SunOS:5.*:*)
- echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
- exit ;;
+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
+ GUESS=powerpcle-unknown-solaris2$SUN_REL
+ ;;
*:GNU:*:*)
# the GNU system
- echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
- exit ;;
+ GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
+ GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
+ ;;
*:GNU/*:*:*)
# other systems with GNU libc and userland
- echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
- exit ;;
+ GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
+ ;;
+ x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
+ GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
+ ;;
+ *:[Mm]anagarm:*:*)
+ GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
+ ;;
*:Minix:*:*)
- echo "$UNAME_MACHINE"-unknown-minix
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-minix
+ ;;
aarch64:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ set_cc_for_build
+ CPU=$UNAME_MACHINE
+ LIBCABI=$LIBC
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
+ ABI=64
+ sed 's/^ //' << EOF > "$dummy.c"
+ #ifdef __ARM_EABI__
+ #ifdef __ARM_PCS_VFP
+ ABI=eabihf
+ #else
+ ABI=eabi
+ #endif
+ #endif
+EOF
+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
+ eval "$cc_set_abi"
+ case $ABI in
+ eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
+ esac
+ fi
+ GUESS=$CPU-unknown-linux-$LIBCABI
+ ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
EV5) UNAME_MACHINE=alphaev5 ;;
@@ -937,60 +1024,72 @@ EOF
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
- arc:Linux:*:* | arceb:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
arm*:Linux:*:*)
set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
else
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
else
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf
+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
fi
fi
- exit ;;
+ ;;
avr32*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
cris:Linux:*:*)
- echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC
+ ;;
crisv32:Linux:*:*)
- echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC
+ ;;
e2k:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
frv:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
hexagon:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
i*86:Linux:*:*)
- echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-linux-$LIBC
+ ;;
ia64:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
k1om:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ kvx:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ kvx:cos:*:*)
+ GUESS=$UNAME_MACHINE-unknown-cos
+ ;;
+ kvx:mbr:*:*)
+ GUESS=$UNAME_MACHINE-unknown-mbr
+ ;;
+ loongarch32:Linux:*:* | loongarch64:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
m32r*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
m68*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
mips:Linux:*:* | mips64:Linux:*:*)
set_cc_for_build
IS_GLIBC=0
@@ -1035,113 +1134,138 @@ EOF
#endif
#endif
EOF
- eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`"
+ cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
+ eval "$cc_set_vars"
test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
;;
mips64el:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
openrisc*:Linux:*:*)
- echo or1k-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=or1k-unknown-linux-$LIBC
+ ;;
or32:Linux:*:* | or1k*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
padre:Linux:*:*)
- echo sparc-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=sparc-unknown-linux-$LIBC
+ ;;
parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=hppa64-unknown-linux-$LIBC
+ ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
- PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
- PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
- *) echo hppa-unknown-linux-"$LIBC" ;;
+ PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
+ PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
+ *) GUESS=hppa-unknown-linux-$LIBC ;;
esac
- exit ;;
+ ;;
ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=powerpc64-unknown-linux-$LIBC
+ ;;
ppc:Linux:*:*)
- echo powerpc-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=powerpc-unknown-linux-$LIBC
+ ;;
ppc64le:Linux:*:*)
- echo powerpc64le-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=powerpc64le-unknown-linux-$LIBC
+ ;;
ppcle:Linux:*:*)
- echo powerpcle-unknown-linux-"$LIBC"
- exit ;;
- riscv32:Linux:*:* | riscv64:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=powerpcle-unknown-linux-$LIBC
+ ;;
+ riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
s390:Linux:*:* | s390x:Linux:*:*)
- echo "$UNAME_MACHINE"-ibm-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
+ ;;
sh64*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
sh*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
sparc:Linux:*:* | sparc64:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
+ sw_64:Linux:*:*)
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
tile*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
vax:Linux:*:*)
- echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-dec-linux-$LIBC
+ ;;
x86_64:Linux:*:*)
- echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
- exit ;;
+ set_cc_for_build
+ CPU=$UNAME_MACHINE
+ LIBCABI=$LIBC
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
+ ABI=64
+ sed 's/^ //' << EOF > "$dummy.c"
+ #ifdef __i386__
+ ABI=x86
+ #else
+ #ifdef __ILP32__
+ ABI=x32
+ #endif
+ #endif
+EOF
+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
+ eval "$cc_set_abi"
+ case $ABI in
+ x86) CPU=i686 ;;
+ x32) LIBCABI=${LIBC}x32 ;;
+ esac
+ fi
+ GUESS=$CPU-pc-linux-$LIBCABI
+ ;;
xtensa*:Linux:*:*)
- echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+ ;;
i*86:DYNIX/ptx:4*:*)
# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
# earlier versions are messed up and put the nodename in both
# sysname and nodename.
- echo i386-sequent-sysv4
- exit ;;
+ GUESS=i386-sequent-sysv4
+ ;;
i*86:UNIX_SV:4.2MP:2.*)
# Unixware is an offshoot of SVR4, but it has its own version
# number series starting with 2...
# I am not positive that other SVR4 systems won't match this,
# I just have to hope. -- rms.
# Use sysv4.2uw... so that sysv4* matches it.
- echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION"
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
+ ;;
i*86:OS/2:*:*)
- # If we were able to find `uname', then EMX Unix compatibility
+ # If we were able to find 'uname', then EMX Unix compatibility
# is probably installed.
- echo "$UNAME_MACHINE"-pc-os2-emx
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-os2-emx
+ ;;
i*86:XTS-300:*:STOP)
- echo "$UNAME_MACHINE"-unknown-stop
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-stop
+ ;;
i*86:atheos:*:*)
- echo "$UNAME_MACHINE"-unknown-atheos
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-atheos
+ ;;
i*86:syllable:*:*)
- echo "$UNAME_MACHINE"-pc-syllable
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-syllable
+ ;;
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
- echo i386-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=i386-unknown-lynxos$UNAME_RELEASE
+ ;;
i*86:*DOS:*:*)
- echo "$UNAME_MACHINE"-pc-msdosdjgpp
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-msdosdjgpp
+ ;;
i*86:*:4.*:*)
UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
- echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
+ GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
else
- echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL"
+ GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
fi
- exit ;;
+ ;;
i*86:*:5:[678]*)
# UnixWare 7.x, OpenUNIX and OpenServer 6.
case `/bin/uname -X | grep "^Machine"` in
@@ -1149,12 +1273,12 @@ EOF
*Pentium) UNAME_MACHINE=i586 ;;
*Pent*|*Celeron) UNAME_MACHINE=i686 ;;
esac
- echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ ;;
i*86:*:3.2:*)
if test -f /usr/options/cb.name; then
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
- echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
+ GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
elif /bin/uname -X 2>/dev/null >/dev/null ; then
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
@@ -1164,11 +1288,11 @@ EOF
&& UNAME_MACHINE=i686
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
&& UNAME_MACHINE=i686
- echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL"
+ GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
else
- echo "$UNAME_MACHINE"-pc-sysv32
+ GUESS=$UNAME_MACHINE-pc-sysv32
fi
- exit ;;
+ ;;
pc:*:*:*)
# Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
@@ -1176,31 +1300,31 @@ EOF
# Note: whatever this is, it MUST be the same as what config.sub
# prints for the "djgpp" host, or else GDB configure will decide that
# this is a cross-build.
- echo i586-pc-msdosdjgpp
- exit ;;
+ GUESS=i586-pc-msdosdjgpp
+ ;;
Intel:Mach:3*:*)
- echo i386-pc-mach3
- exit ;;
+ GUESS=i386-pc-mach3
+ ;;
paragon:*:*:*)
- echo i860-intel-osf1
- exit ;;
+ GUESS=i860-intel-osf1
+ ;;
i860:*:4.*:*) # i860-SVR4
if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
- echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
+ GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4
else # Add other i860-SVR4 vendors below as they are discovered.
- echo i860-unknown-sysv"$UNAME_RELEASE" # Unknown i860-SVR4
+ GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4
fi
- exit ;;
+ ;;
mini*:CTIX:SYS*5:*)
# "miniframe"
- echo m68010-convergent-sysv
- exit ;;
+ GUESS=m68010-convergent-sysv
+ ;;
mc68k:UNIX:SYSTEM5:3.51m)
- echo m68k-convergent-sysv
- exit ;;
+ GUESS=m68k-convergent-sysv
+ ;;
M680?0:D-NIX:5.3:*)
- echo m68k-diab-dnix
- exit ;;
+ GUESS=m68k-diab-dnix
+ ;;
M68*:*:R3V[5678]*:*)
test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
@@ -1225,113 +1349,119 @@ EOF
/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
&& { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
- echo m68k-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-unknown-lynxos$UNAME_RELEASE
+ ;;
mc68030:UNIX_System_V:4.*:*)
- echo m68k-atari-sysv4
- exit ;;
+ GUESS=m68k-atari-sysv4
+ ;;
TSUNAMI:LynxOS:2.*:*)
- echo sparc-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=sparc-unknown-lynxos$UNAME_RELEASE
+ ;;
rs6000:LynxOS:2.*:*)
- echo rs6000-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
+ ;;
PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
- echo powerpc-unknown-lynxos"$UNAME_RELEASE"
- exit ;;
+ GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
+ ;;
SM[BE]S:UNIX_SV:*:*)
- echo mips-dde-sysv"$UNAME_RELEASE"
- exit ;;
+ GUESS=mips-dde-sysv$UNAME_RELEASE
+ ;;
RM*:ReliantUNIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
+ GUESS=mips-sni-sysv4
+ ;;
RM*:SINIX-*:*:*)
- echo mips-sni-sysv4
- exit ;;
+ GUESS=mips-sni-sysv4
+ ;;
*:SINIX-*:*:*)
if uname -p 2>/dev/null >/dev/null ; then
UNAME_MACHINE=`(uname -p) 2>/dev/null`
- echo "$UNAME_MACHINE"-sni-sysv4
+ GUESS=$UNAME_MACHINE-sni-sysv4
else
- echo ns32k-sni-sysv
+ GUESS=ns32k-sni-sysv
fi
- exit ;;
- PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ ;;
+ PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
- echo i586-unisys-sysv4
- exit ;;
+ GUESS=i586-unisys-sysv4
+ ;;
*:UNIX_System_V:4*:FTX*)
# From Gerald Hewes <hewes@openmarket.com>.
# How about differentiating between stratus architectures? -djm
- echo hppa1.1-stratus-sysv4
- exit ;;
+ GUESS=hppa1.1-stratus-sysv4
+ ;;
*:*:*:FTX*)
# From seanf@swdc.stratus.com.
- echo i860-stratus-sysv4
- exit ;;
+ GUESS=i860-stratus-sysv4
+ ;;
i*86:VOS:*:*)
# From Paul.Green@stratus.com.
- echo "$UNAME_MACHINE"-stratus-vos
- exit ;;
+ GUESS=$UNAME_MACHINE-stratus-vos
+ ;;
*:VOS:*:*)
# From Paul.Green@stratus.com.
- echo hppa1.1-stratus-vos
- exit ;;
+ GUESS=hppa1.1-stratus-vos
+ ;;
mc68*:A/UX:*:*)
- echo m68k-apple-aux"$UNAME_RELEASE"
- exit ;;
+ GUESS=m68k-apple-aux$UNAME_RELEASE
+ ;;
news*:NEWS-OS:6*:*)
- echo mips-sony-newsos6
- exit ;;
+ GUESS=mips-sony-newsos6
+ ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
- if [ -d /usr/nec ]; then
- echo mips-nec-sysv"$UNAME_RELEASE"
+ if test -d /usr/nec; then
+ GUESS=mips-nec-sysv$UNAME_RELEASE
else
- echo mips-unknown-sysv"$UNAME_RELEASE"
+ GUESS=mips-unknown-sysv$UNAME_RELEASE
fi
- exit ;;
+ ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
- echo powerpc-be-beos
- exit ;;
+ GUESS=powerpc-be-beos
+ ;;
BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
- echo powerpc-apple-beos
- exit ;;
+ GUESS=powerpc-apple-beos
+ ;;
BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
- echo i586-pc-beos
- exit ;;
+ GUESS=i586-pc-beos
+ ;;
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
- echo i586-pc-haiku
- exit ;;
- x86_64:Haiku:*:*)
- echo x86_64-unknown-haiku
- exit ;;
+ GUESS=i586-pc-haiku
+ ;;
+ ppc:Haiku:*:*) # Haiku running on Apple PowerPC
+ GUESS=powerpc-apple-haiku
+ ;;
+ *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)
+ GUESS=$UNAME_MACHINE-unknown-haiku
+ ;;
SX-4:SUPER-UX:*:*)
- echo sx4-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx4-nec-superux$UNAME_RELEASE
+ ;;
SX-5:SUPER-UX:*:*)
- echo sx5-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx5-nec-superux$UNAME_RELEASE
+ ;;
SX-6:SUPER-UX:*:*)
- echo sx6-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx6-nec-superux$UNAME_RELEASE
+ ;;
SX-7:SUPER-UX:*:*)
- echo sx7-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx7-nec-superux$UNAME_RELEASE
+ ;;
SX-8:SUPER-UX:*:*)
- echo sx8-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx8-nec-superux$UNAME_RELEASE
+ ;;
SX-8R:SUPER-UX:*:*)
- echo sx8r-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sx8r-nec-superux$UNAME_RELEASE
+ ;;
SX-ACE:SUPER-UX:*:*)
- echo sxace-nec-superux"$UNAME_RELEASE"
- exit ;;
+ GUESS=sxace-nec-superux$UNAME_RELEASE
+ ;;
Power*:Rhapsody:*:*)
- echo powerpc-apple-rhapsody"$UNAME_RELEASE"
- exit ;;
+ GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
+ ;;
*:Rhapsody:*:*)
- echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
+ ;;
+ arm64:Darwin:*:*)
+ GUESS=aarch64-apple-darwin$UNAME_RELEASE
+ ;;
*:Darwin:*:*)
UNAME_PROCESSOR=`uname -p`
case $UNAME_PROCESSOR in
@@ -1346,7 +1476,7 @@ EOF
else
set_cc_for_build
fi
- if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
+ if test "$CC_FOR_BUILD" != no_compiler_found; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
@@ -1367,109 +1497,125 @@ EOF
# uname -m returns i386 or x86_64
UNAME_PROCESSOR=$UNAME_MACHINE
fi
- echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
+ ;;
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = x86; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
- echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
+ ;;
*:QNX:*:4*)
- echo i386-pc-qnx
- exit ;;
+ GUESS=i386-pc-qnx
+ ;;
NEO-*:NONSTOP_KERNEL:*:*)
- echo neo-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=neo-tandem-nsk$UNAME_RELEASE
+ ;;
NSE-*:NONSTOP_KERNEL:*:*)
- echo nse-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=nse-tandem-nsk$UNAME_RELEASE
+ ;;
NSR-*:NONSTOP_KERNEL:*:*)
- echo nsr-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=nsr-tandem-nsk$UNAME_RELEASE
+ ;;
NSV-*:NONSTOP_KERNEL:*:*)
- echo nsv-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=nsv-tandem-nsk$UNAME_RELEASE
+ ;;
NSX-*:NONSTOP_KERNEL:*:*)
- echo nsx-tandem-nsk"$UNAME_RELEASE"
- exit ;;
+ GUESS=nsx-tandem-nsk$UNAME_RELEASE
+ ;;
*:NonStop-UX:*:*)
- echo mips-compaq-nonstopux
- exit ;;
+ GUESS=mips-compaq-nonstopux
+ ;;
BS2000:POSIX*:*:*)
- echo bs2000-siemens-sysv
- exit ;;
+ GUESS=bs2000-siemens-sysv
+ ;;
DS/*:UNIX_System_V:*:*)
- echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
+ ;;
*:Plan9:*:*)
# "uname -m" is not consistent, so use $cputype instead. 386
# is converted to i386 for consistency with other x86
# operating systems.
- # shellcheck disable=SC2154
- if test "$cputype" = 386; then
+ if test "${cputype-}" = 386; then
UNAME_MACHINE=i386
- else
- UNAME_MACHINE="$cputype"
+ elif test "x${cputype-}" != x; then
+ UNAME_MACHINE=$cputype
fi
- echo "$UNAME_MACHINE"-unknown-plan9
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-plan9
+ ;;
*:TOPS-10:*:*)
- echo pdp10-unknown-tops10
- exit ;;
+ GUESS=pdp10-unknown-tops10
+ ;;
*:TENEX:*:*)
- echo pdp10-unknown-tenex
- exit ;;
+ GUESS=pdp10-unknown-tenex
+ ;;
KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
- echo pdp10-dec-tops20
- exit ;;
+ GUESS=pdp10-dec-tops20
+ ;;
XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
- echo pdp10-xkl-tops20
- exit ;;
+ GUESS=pdp10-xkl-tops20
+ ;;
*:TOPS-20:*:*)
- echo pdp10-unknown-tops20
- exit ;;
+ GUESS=pdp10-unknown-tops20
+ ;;
*:ITS:*:*)
- echo pdp10-unknown-its
- exit ;;
+ GUESS=pdp10-unknown-its
+ ;;
SEI:*:*:SEIUX)
- echo mips-sei-seiux"$UNAME_RELEASE"
- exit ;;
+ GUESS=mips-sei-seiux$UNAME_RELEASE
+ ;;
*:DragonFly:*:*)
- echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
- exit ;;
+ DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
+ GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
+ ;;
*:*VMS:*:*)
UNAME_MACHINE=`(uname -p) 2>/dev/null`
- case "$UNAME_MACHINE" in
- A*) echo alpha-dec-vms ; exit ;;
- I*) echo ia64-dec-vms ; exit ;;
- V*) echo vax-dec-vms ; exit ;;
+ case $UNAME_MACHINE in
+ A*) GUESS=alpha-dec-vms ;;
+ I*) GUESS=ia64-dec-vms ;;
+ V*) GUESS=vax-dec-vms ;;
esac ;;
*:XENIX:*:SysV)
- echo i386-pc-xenix
- exit ;;
+ GUESS=i386-pc-xenix
+ ;;
i*86:skyos:*:*)
- echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
- exit ;;
+ SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
+ GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
+ ;;
i*86:rdos:*:*)
- echo "$UNAME_MACHINE"-pc-rdos
- exit ;;
- i*86:AROS:*:*)
- echo "$UNAME_MACHINE"-pc-aros
- exit ;;
+ GUESS=$UNAME_MACHINE-pc-rdos
+ ;;
+ i*86:Fiwix:*:*)
+ GUESS=$UNAME_MACHINE-pc-fiwix
+ ;;
+ *:AROS:*:*)
+ GUESS=$UNAME_MACHINE-unknown-aros
+ ;;
x86_64:VMkernel:*:*)
- echo "$UNAME_MACHINE"-unknown-esx
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-esx
+ ;;
amd64:Isilon\ OneFS:*:*)
- echo x86_64-unknown-onefs
- exit ;;
+ GUESS=x86_64-unknown-onefs
+ ;;
*:Unleashed:*:*)
- echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE"
- exit ;;
+ GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
+ ;;
+ x86_64:[Ii]ronclad:*:*|i?86:[Ii]ronclad:*:*)
+ GUESS=$UNAME_MACHINE-pc-ironclad-$LIBC
+ ;;
+ *:[Ii]ronclad:*:*)
+ GUESS=$UNAME_MACHINE-unknown-ironclad-$LIBC
+ ;;
esac
+# Do we have a guess based on uname results?
+if test "x$GUESS" != x; then
+ echo "$GUESS"
+ exit
+fi
+
# No uname command or uname output not recognized.
set_cc_for_build
cat > "$dummy.c" <<EOF
@@ -1485,6 +1631,7 @@ cat > "$dummy.c" <<EOF
#endif
#endif
#endif
+int
main ()
{
#if defined (sony)
@@ -1601,7 +1748,7 @@ main ()
}
EOF
-$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
{ echo "$SYSTEM_NAME"; exit; }
# Apollos put the system type in the environment.
@@ -1609,7 +1756,7 @@ test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
echo "$0: unable to guess system type" >&2
-case "$UNAME_MACHINE:$UNAME_SYSTEM" in
+case $UNAME_MACHINE:$UNAME_SYSTEM in
mips:Linux | mips64:Linux)
# If we got here on MIPS GNU/Linux, output extra information.
cat >&2 <<EOF
@@ -1626,14 +1773,16 @@ This script (version $timestamp), has failed to recognize the
operating system you are using. If your script is old, overwrite *all*
copies of config.guess and config.sub with the latest versions from:
- https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
+ https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
and
- https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+ https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
EOF
-year=`echo $timestamp | sed 's,-.*,,'`
+our_year=`echo $timestamp | sed 's,-.*,,'`
+thisyear=`date +%Y`
# shellcheck disable=SC2003
-if test "`expr "\`date +%Y\`" - "$year"`" -lt 3 ; then
+script_age=`expr "$thisyear" - "$our_year"`
+if test "$script_age" -lt 3 ; then
cat >&2 <<EOF
If $0 has already been updated, send the following data and any
@@ -1667,8 +1816,8 @@ fi
exit 1
# Local variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-format: "%Y-%02m-%02d"
# time-stamp-end: "'"
# End:
diff --git a/config.sub b/config.sub
index 973a2980a..404aa0824 100755
--- a/config.sub
+++ b/config.sub
@@ -1,12 +1,14 @@
#! /bin/sh
# Configuration validation subroutine script.
-# Copyright 1992-2020 Free Software Foundation, Inc.
+# Copyright 1992-2026 Free Software Foundation, Inc.
-timestamp='2020-05-04'
+# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
+
+timestamp='2026-05-17'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -33,7 +35,7 @@ timestamp='2020-05-04'
# Otherwise, we print the canonical config type on stdout and succeed.
# You can get the latest version of this script from:
-# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
+# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
# This file is supposed to be the same for all GNU packages
# and recognize all the CPU types, system types and aliases
@@ -50,6 +52,13 @@ timestamp='2020-05-04'
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
+# The "shellcheck disable" line above the timestamp inhibits complaints
+# about features and limitations of the classic Bourne shell that were
+# superseded or lifted in POSIX. However, this script identifies a wide
+# variety of pre-POSIX systems that do not have POSIX shells at all, and
+# even some reasonably current systems (Solaris 10 as case-in-point) still
+# have a pre-POSIX /bin/sh.
+
me=`echo "$0" | sed -e 's,.*/,,'`
usage="\
@@ -67,13 +76,13 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
-Copyright 1992-2020 Free Software Foundation, Inc.
+Copyright 1992-2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
help="
-Try \`$me --help' for more information."
+Try '$me --help' for more information."
# Parse command line
while test $# -gt 0 ; do
@@ -111,75 +120,154 @@ case $# in
esac
# Split fields of configuration type
-# shellcheck disable=SC2162
+saved_IFS=$IFS
IFS="-" read field1 field2 field3 field4 <<EOF
$1
EOF
+IFS=$saved_IFS
# Separate into logical components for further validation
case $1 in
*-*-*-*-*)
- echo Invalid configuration \`"$1"\': more than four components >&2
+ echo "Invalid configuration '$1': more than four components" >&2
exit 1
;;
*-*-*-*)
basic_machine=$field1-$field2
- os=$field3-$field4
+ basic_os=$field3-$field4
;;
*-*-*)
# Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
# parts
maybe_os=$field2-$field3
case $maybe_os in
- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \
- | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
- | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
- | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
- | storm-chaos* | os2-emx* | rtmk-nova*)
+ cloudabi*-eabi* \
+ | kfreebsd*-gnu* \
+ | knetbsd*-gnu* \
+ | kopensolaris*-gnu* \
+ | ironclad-* \
+ | linux-* \
+ | managarm-* \
+ | netbsd*-eabi* \
+ | netbsd*-gnu* \
+ | nto-qnx* \
+ | os2-emx* \
+ | rtmk-nova* \
+ | storm-chaos* \
+ | uclinux-gnu* \
+ | uclinux-uclibc* \
+ | windows-* )
basic_machine=$field1
- os=$maybe_os
+ basic_os=$maybe_os
;;
android-linux)
basic_machine=$field1-unknown
- os=linux-android
+ basic_os=linux-android
;;
*)
basic_machine=$field1-$field2
- os=$field3
+ basic_os=$field3
;;
esac
;;
*-*)
- # A lone config we happen to match not fitting any pattern
case $field1-$field2 in
+ # Shorthands that happen to contain a single dash
+ convex-c[12] | convex-c3[248])
+ basic_machine=$field2-convex
+ basic_os=
+ ;;
decstation-3100)
basic_machine=mips-dec
- os=
+ basic_os=
;;
*-*)
# Second component is usually, but not always the OS
case $field2 in
- # Prevent following clause from handling this valid os
+ # Do not treat sunos as a manufacturer
sun*os*)
basic_machine=$field1
- os=$field2
+ basic_os=$field2
;;
# Manufacturers
- dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
- | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
- | unicom* | ibm* | next | hp | isi* | apollo | altos* \
- | convergent* | ncr* | news | 32* | 3600* | 3100* \
- | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
- | ultra | tti* | harris | dolphin | highlevel | gould \
- | cbm | ns | masscomp | apple | axis | knuth | cray \
- | microblaze* | sim | cisco \
- | oki | wec | wrs | winbond)
+ 3100* \
+ | 32* \
+ | 3300* \
+ | 3600* \
+ | 7300* \
+ | acorn \
+ | altos* \
+ | apollo \
+ | apple \
+ | atari \
+ | att* \
+ | axis \
+ | be \
+ | bull \
+ | cbm \
+ | ccur \
+ | cisco \
+ | commodore \
+ | convergent* \
+ | convex* \
+ | cray \
+ | crds \
+ | dec* \
+ | delta* \
+ | dg \
+ | digital \
+ | dolphin \
+ | encore* \
+ | gould \
+ | harris \
+ | highlevel \
+ | hitachi* \
+ | hp \
+ | ibm* \
+ | intergraph \
+ | isi* \
+ | knuth \
+ | masscomp \
+ | microblaze* \
+ | mips* \
+ | motorola* \
+ | ncr* \
+ | news \
+ | next \
+ | ns \
+ | oki \
+ | omron* \
+ | pc533* \
+ | rebel \
+ | rom68k \
+ | rombug \
+ | semi \
+ | sequent* \
+ | sgi* \
+ | siemens \
+ | sim \
+ | sni \
+ | sony* \
+ | stratus \
+ | sun \
+ | sun[234]* \
+ | tektronix \
+ | tti* \
+ | ultra \
+ | unicom* \
+ | wec \
+ | winbond \
+ | wrs)
basic_machine=$field1-$field2
- os=
+ basic_os=
+ ;;
+ tock* | zephyr*)
+ basic_machine=$field1-unknown
+ basic_os=$field2
;;
*)
basic_machine=$field1
- os=$field2
+ basic_os=$field2
;;
esac
;;
@@ -191,447 +279,431 @@ case $1 in
case $field1 in
386bsd)
basic_machine=i386-pc
- os=bsd
+ basic_os=bsd
;;
a29khif)
basic_machine=a29k-amd
- os=udi
+ basic_os=udi
;;
adobe68k)
basic_machine=m68010-adobe
- os=scout
+ basic_os=scout
;;
alliant)
basic_machine=fx80-alliant
- os=
+ basic_os=
;;
altos | altos3068)
basic_machine=m68k-altos
- os=
+ basic_os=
;;
am29k)
basic_machine=a29k-none
- os=bsd
+ basic_os=bsd
;;
amdahl)
basic_machine=580-amdahl
- os=sysv
+ basic_os=sysv
;;
amiga)
basic_machine=m68k-unknown
- os=
+ basic_os=
;;
amigaos | amigados)
basic_machine=m68k-unknown
- os=amigaos
+ basic_os=amigaos
;;
amigaunix | amix)
basic_machine=m68k-unknown
- os=sysv4
+ basic_os=sysv4
;;
apollo68)
basic_machine=m68k-apollo
- os=sysv
+ basic_os=sysv
;;
apollo68bsd)
basic_machine=m68k-apollo
- os=bsd
+ basic_os=bsd
;;
aros)
basic_machine=i386-pc
- os=aros
+ basic_os=aros
;;
aux)
basic_machine=m68k-apple
- os=aux
+ basic_os=aux
;;
balance)
basic_machine=ns32k-sequent
- os=dynix
+ basic_os=dynix
;;
blackfin)
basic_machine=bfin-unknown
- os=linux
+ basic_os=linux
;;
cegcc)
basic_machine=arm-unknown
- os=cegcc
- ;;
- convex-c1)
- basic_machine=c1-convex
- os=bsd
- ;;
- convex-c2)
- basic_machine=c2-convex
- os=bsd
- ;;
- convex-c32)
- basic_machine=c32-convex
- os=bsd
- ;;
- convex-c34)
- basic_machine=c34-convex
- os=bsd
- ;;
- convex-c38)
- basic_machine=c38-convex
- os=bsd
+ basic_os=cegcc
;;
cray)
basic_machine=j90-cray
- os=unicos
+ basic_os=unicos
;;
crds | unos)
basic_machine=m68k-crds
- os=
+ basic_os=
;;
da30)
basic_machine=m68k-da30
- os=
+ basic_os=
;;
decstation | pmax | pmin | dec3100 | decstatn)
basic_machine=mips-dec
- os=
+ basic_os=
;;
delta88)
basic_machine=m88k-motorola
- os=sysv3
+ basic_os=sysv3
;;
dicos)
basic_machine=i686-pc
- os=dicos
+ basic_os=dicos
;;
djgpp)
basic_machine=i586-pc
- os=msdosdjgpp
+ basic_os=msdosdjgpp
;;
ebmon29k)
basic_machine=a29k-amd
- os=ebmon
+ basic_os=ebmon
;;
es1800 | OSE68k | ose68k | ose | OSE)
basic_machine=m68k-ericsson
- os=ose
+ basic_os=ose
;;
gmicro)
basic_machine=tron-gmicro
- os=sysv
+ basic_os=sysv
;;
go32)
basic_machine=i386-pc
- os=go32
+ basic_os=go32
;;
h8300hms)
basic_machine=h8300-hitachi
- os=hms
+ basic_os=hms
;;
h8300xray)
basic_machine=h8300-hitachi
- os=xray
+ basic_os=xray
;;
h8500hms)
basic_machine=h8500-hitachi
- os=hms
+ basic_os=hms
;;
harris)
basic_machine=m88k-harris
- os=sysv3
+ basic_os=sysv3
;;
hp300 | hp300hpux)
basic_machine=m68k-hp
- os=hpux
+ basic_os=hpux
;;
hp300bsd)
basic_machine=m68k-hp
- os=bsd
+ basic_os=bsd
;;
hppaosf)
basic_machine=hppa1.1-hp
- os=osf
+ basic_os=osf
;;
hppro)
basic_machine=hppa1.1-hp
- os=proelf
+ basic_os=proelf
;;
i386mach)
basic_machine=i386-mach
- os=mach
+ basic_os=mach
;;
isi68 | isi)
basic_machine=m68k-isi
- os=sysv
+ basic_os=sysv
;;
m68knommu)
basic_machine=m68k-unknown
- os=linux
+ basic_os=linux
;;
magnum | m3230)
basic_machine=mips-mips
- os=sysv
+ basic_os=sysv
;;
merlin)
basic_machine=ns32k-utek
- os=sysv
+ basic_os=sysv
;;
mingw64)
basic_machine=x86_64-pc
- os=mingw64
+ basic_os=mingw64
;;
mingw32)
basic_machine=i686-pc
- os=mingw32
+ basic_os=mingw32
;;
mingw32ce)
basic_machine=arm-unknown
- os=mingw32ce
+ basic_os=mingw32ce
;;
monitor)
basic_machine=m68k-rom68k
- os=coff
+ basic_os=coff
;;
morphos)
basic_machine=powerpc-unknown
- os=morphos
+ basic_os=morphos
;;
moxiebox)
basic_machine=moxie-unknown
- os=moxiebox
+ basic_os=moxiebox
;;
msdos)
basic_machine=i386-pc
- os=msdos
+ basic_os=msdos
;;
msys)
basic_machine=i686-pc
- os=msys
+ basic_os=msys
;;
mvs)
basic_machine=i370-ibm
- os=mvs
+ basic_os=mvs
;;
nacl)
basic_machine=le32-unknown
- os=nacl
+ basic_os=nacl
;;
ncr3000)
basic_machine=i486-ncr
- os=sysv4
+ basic_os=sysv4
;;
netbsd386)
basic_machine=i386-pc
- os=netbsd
+ basic_os=netbsd
;;
netwinder)
basic_machine=armv4l-rebel
- os=linux
+ basic_os=linux
;;
news | news700 | news800 | news900)
basic_machine=m68k-sony
- os=newsos
+ basic_os=newsos
;;
news1000)
basic_machine=m68030-sony
- os=newsos
+ basic_os=newsos
;;
necv70)
basic_machine=v70-nec
- os=sysv
+ basic_os=sysv
;;
nh3000)
basic_machine=m68k-harris
- os=cxux
+ basic_os=cxux
;;
nh[45]000)
basic_machine=m88k-harris
- os=cxux
+ basic_os=cxux
;;
nindy960)
basic_machine=i960-intel
- os=nindy
+ basic_os=nindy
;;
mon960)
basic_machine=i960-intel
- os=mon960
+ basic_os=mon960
;;
nonstopux)
basic_machine=mips-compaq
- os=nonstopux
+ basic_os=nonstopux
;;
os400)
basic_machine=powerpc-ibm
- os=os400
+ basic_os=os400
;;
OSE68000 | ose68000)
basic_machine=m68000-ericsson
- os=ose
+ basic_os=ose
;;
os68k)
basic_machine=m68k-none
- os=os68k
+ basic_os=os68k
;;
paragon)
basic_machine=i860-intel
- os=osf
+ basic_os=osf
;;
parisc)
basic_machine=hppa-unknown
- os=linux
+ basic_os=linux
+ ;;
+ psp)
+ basic_machine=mipsallegrexel-sony
+ basic_os=psp
;;
pw32)
basic_machine=i586-unknown
- os=pw32
+ basic_os=pw32
;;
rdos | rdos64)
basic_machine=x86_64-pc
- os=rdos
+ basic_os=rdos
;;
rdos32)
basic_machine=i386-pc
- os=rdos
+ basic_os=rdos
;;
rom68k)
basic_machine=m68k-rom68k
- os=coff
+ basic_os=coff
;;
sa29200)
basic_machine=a29k-amd
- os=udi
+ basic_os=udi
;;
sei)
basic_machine=mips-sei
- os=seiux
+ basic_os=seiux
;;
sequent)
basic_machine=i386-sequent
- os=
+ basic_os=
;;
sps7)
basic_machine=m68k-bull
- os=sysv2
+ basic_os=sysv2
;;
st2000)
basic_machine=m68k-tandem
- os=
+ basic_os=
;;
stratus)
basic_machine=i860-stratus
- os=sysv4
+ basic_os=sysv4
;;
sun2)
basic_machine=m68000-sun
- os=
+ basic_os=
;;
sun2os3)
basic_machine=m68000-sun
- os=sunos3
+ basic_os=sunos3
;;
sun2os4)
basic_machine=m68000-sun
- os=sunos4
+ basic_os=sunos4
;;
sun3)
basic_machine=m68k-sun
- os=
+ basic_os=
;;
sun3os3)
basic_machine=m68k-sun
- os=sunos3
+ basic_os=sunos3
;;
sun3os4)
basic_machine=m68k-sun
- os=sunos4
+ basic_os=sunos4
;;
sun4)
basic_machine=sparc-sun
- os=
+ basic_os=
;;
sun4os3)
basic_machine=sparc-sun
- os=sunos3
+ basic_os=sunos3
;;
sun4os4)
basic_machine=sparc-sun
- os=sunos4
+ basic_os=sunos4
;;
sun4sol2)
basic_machine=sparc-sun
- os=solaris2
+ basic_os=solaris2
;;
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
- os=
+ basic_os=
;;
sv1)
basic_machine=sv1-cray
- os=unicos
+ basic_os=unicos
;;
symmetry)
basic_machine=i386-sequent
- os=dynix
+ basic_os=dynix
;;
t3e)
basic_machine=alphaev5-cray
- os=unicos
+ basic_os=unicos
;;
t90)
basic_machine=t90-cray
- os=unicos
+ basic_os=unicos
;;
toad1)
basic_machine=pdp10-xkl
- os=tops20
+ basic_os=tops20
;;
tpf)
basic_machine=s390x-ibm
- os=tpf
+ basic_os=tpf
;;
udi29k)
basic_machine=a29k-amd
- os=udi
+ basic_os=udi
;;
ultra3)
basic_machine=a29k-nyu
- os=sym1
+ basic_os=sym1
;;
v810 | necv810)
basic_machine=v810-nec
- os=none
+ basic_os=none
;;
vaxv)
basic_machine=vax-dec
- os=sysv
+ basic_os=sysv
;;
vms)
basic_machine=vax-dec
- os=vms
+ basic_os=vms
;;
vsta)
basic_machine=i386-pc
- os=vsta
+ basic_os=vsta
;;
vxworks960)
basic_machine=i960-wrs
- os=vxworks
+ basic_os=vxworks
;;
vxworks68)
basic_machine=m68k-wrs
- os=vxworks
+ basic_os=vxworks
;;
vxworks29k)
basic_machine=a29k-wrs
- os=vxworks
+ basic_os=vxworks
;;
xbox)
basic_machine=i686-pc
- os=mingw32
+ basic_os=mingw32
;;
ymp)
basic_machine=ymp-cray
- os=unicos
+ basic_os=unicos
;;
*)
basic_machine=$1
- os=
+ basic_os=
;;
esac
;;
@@ -683,27 +755,38 @@ case $basic_machine in
bluegene*)
cpu=powerpc
vendor=ibm
- os=cnk
+ basic_os=cnk
;;
decsystem10* | dec10*)
cpu=pdp10
vendor=dec
- os=tops10
+ basic_os=tops10
;;
decsystem20* | dec20*)
cpu=pdp10
vendor=dec
- os=tops20
+ basic_os=tops20
;;
- delta | 3300 | motorola-3300 | motorola-delta \
- | 3300-motorola | delta-motorola)
+ delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300)
cpu=m68k
vendor=motorola
;;
- dpx2*)
+ # This used to be dpx2*, but that gets the RS6000-based
+ # DPX/20 and the x86-based DPX/2-100 wrong. See
+ # https://oldskool.silicium.org/stations/bull_dpx20.htm
+ # https://www.feb-patrimoine.com/english/bull_dpx2.htm
+ # https://www.feb-patrimoine.com/english/unix_and_bull.htm
+ dpx2 | dpx2[23]00 | dpx2[23]xx)
cpu=m68k
vendor=bull
- os=sysv3
+ ;;
+ dpx2100 | dpx21xx)
+ cpu=i386
+ vendor=bull
+ ;;
+ dpx20)
+ cpu=rs6000
+ vendor=bull
;;
encore | umax | mmax)
cpu=ns32k
@@ -712,7 +795,7 @@ case $basic_machine in
elxsi)
cpu=elxsi
vendor=elxsi
- os=${os:-bsd}
+ basic_os=${basic_os:-bsd}
;;
fx2800)
cpu=i860
@@ -725,7 +808,7 @@ case $basic_machine in
h3050r* | hiux*)
cpu=hppa1.1
vendor=hitachi
- os=hiuxwe2
+ basic_os=hiuxwe2
;;
hp3k9[0-9][0-9] | hp9[0-9][0-9])
cpu=hppa1.0
@@ -768,36 +851,36 @@ case $basic_machine in
i*86v32)
cpu=`echo "$1" | sed -e 's/86.*/86/'`
vendor=pc
- os=sysv32
+ basic_os=sysv32
;;
i*86v4*)
cpu=`echo "$1" | sed -e 's/86.*/86/'`
vendor=pc
- os=sysv4
+ basic_os=sysv4
;;
i*86v)
cpu=`echo "$1" | sed -e 's/86.*/86/'`
vendor=pc
- os=sysv
+ basic_os=sysv
;;
i*86sol2)
cpu=`echo "$1" | sed -e 's/86.*/86/'`
vendor=pc
- os=solaris2
+ basic_os=solaris2
;;
j90 | j90-cray)
cpu=j90
vendor=cray
- os=${os:-unicos}
+ basic_os=${basic_os:-unicos}
;;
iris | iris4d)
cpu=mips
vendor=sgi
- case $os in
+ case $basic_os in
irix*)
;;
*)
- os=irix4
+ basic_os=irix4
;;
esac
;;
@@ -808,28 +891,16 @@ case $basic_machine in
*mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
cpu=m68k
vendor=atari
- os=mint
+ basic_os=mint
;;
news-3600 | risc-news)
cpu=mips
vendor=sony
- os=newsos
+ basic_os=newsos
;;
next | m*-next)
cpu=m68k
vendor=next
- case $os in
- openstep*)
- ;;
- nextstep*)
- ;;
- ns2*)
- os=nextstep2
- ;;
- *)
- os=nextstep3
- ;;
- esac
;;
np1)
cpu=np1
@@ -838,12 +909,12 @@ case $basic_machine in
op50n-* | op60c-*)
cpu=hppa1.1
vendor=oki
- os=proelf
+ basic_os=proelf
;;
pa-hitachi)
cpu=hppa1.1
vendor=hitachi
- os=hiuxwe2
+ basic_os=hiuxwe2
;;
pbd)
cpu=sparc
@@ -880,12 +951,12 @@ case $basic_machine in
sde)
cpu=mipsisa32
vendor=sde
- os=${os:-elf}
+ basic_os=${basic_os:-elf}
;;
simso-wrs)
cpu=sparclite
vendor=wrs
- os=vxworks
+ basic_os=vxworks
;;
tower | tower-32)
cpu=m68k
@@ -902,7 +973,7 @@ case $basic_machine in
w89k-*)
cpu=hppa1.1
vendor=winbond
- os=proelf
+ basic_os=proelf
;;
none)
cpu=none
@@ -918,12 +989,13 @@ case $basic_machine in
;;
*-*)
- # shellcheck disable=SC2162
+ saved_IFS=$IFS
IFS="-" read cpu vendor <<EOF
$basic_machine
EOF
+ IFS=$saved_IFS
;;
- # We use `pc' rather than `unknown'
+ # We use 'pc' rather than 'unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
@@ -951,15 +1023,19 @@ unset -v basic_machine
# Decode basic machines in the full and proper CPU-Company form.
case $cpu-$vendor in
- # Here we handle the default manufacturer of certain CPU types in canonical form. It is in
- # some cases the only manufacturer, in others, it is the most popular.
+ # Here we handle the default manufacturer of certain CPU types in canonical form.
+ # It is in some cases the only manufacturer, in others, it is the most popular.
+ c[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown)
+ vendor=convex
+ basic_os=${basic_os:-bsd}
+ ;;
craynv-unknown)
vendor=cray
- os=${os:-unicosmp}
+ basic_os=${basic_os:-unicosmp}
;;
c90-unknown | c90-cray)
vendor=cray
- os=${os:-unicos}
+ basic_os=${basic_os:-unicos}
;;
fx80-unknown)
vendor=alliant
@@ -1000,10 +1076,33 @@ case $cpu-$vendor in
;;
# Here we normalize CPU types with a missing or matching vendor
- dpx20-unknown | dpx20-bull)
- cpu=rs6000
- vendor=bull
- os=${os:-bosx}
+ armh-unknown | armh-alt)
+ cpu=armv7l
+ vendor=alt
+ basic_os=${basic_os:-linux-gnueabihf}
+ ;;
+
+ # Normalized CPU+vendor pairs that imply an OS, if not otherwise specified
+ m68k-isi)
+ basic_os=${basic_os:-sysv}
+ ;;
+ m68k-sony)
+ basic_os=${basic_os:-newsos}
+ ;;
+ m68k-tektronix)
+ basic_os=${basic_os:-bsd}
+ ;;
+ m88k-harris)
+ basic_os=${basic_os:-sysv3}
+ ;;
+ i386-bull | m68k-bull)
+ basic_os=${basic_os:-sysv3}
+ ;;
+ rs6000-bull)
+ basic_os=${basic_os:-bosx}
+ ;;
+ mips-sni)
+ basic_os=${basic_os:-sysv4}
;;
# Here we normalize CPU types irrespective of the vendor
@@ -1012,7 +1111,7 @@ case $cpu-$vendor in
;;
blackfin-*)
cpu=bfin
- os=linux
+ basic_os=${basic_os:-linux}
;;
c54x-*)
cpu=tic54x
@@ -1025,7 +1124,7 @@ case $cpu-$vendor in
;;
e500v[12]-*)
cpu=powerpc
- os=$os"spe"
+ basic_os=${basic_os}"spe"
;;
mips3*-*)
cpu=mips64
@@ -1035,7 +1134,7 @@ case $cpu-$vendor in
;;
m68knommu-*)
cpu=m68k
- os=linux
+ basic_os=${basic_os:-linux}
;;
m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
cpu=s12z
@@ -1045,12 +1144,12 @@ case $cpu-$vendor in
;;
parisc-*)
cpu=hppa
- os=linux
+ basic_os=${basic_os:-linux}
;;
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
cpu=i586
;;
- pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
cpu=i686
;;
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
@@ -1059,9 +1158,6 @@ case $cpu-$vendor in
pentium4-*)
cpu=i786
;;
- pc98-*)
- cpu=i386
- ;;
ppc-* | ppcbe-*)
cpu=powerpc
;;
@@ -1095,17 +1191,17 @@ case $cpu-$vendor in
tx39el-*)
cpu=mipstx39el
;;
- x64-*)
- cpu=x86_64
- ;;
xscale-* | xscalee[bl]-*)
cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
;;
+ arm64-* | aarch64le-* | arm64_32-*)
+ cpu=aarch64
+ ;;
# Recognize the canonical CPU Types that limit and/or modify the
# company names they are paired with.
cr16-*)
- os=${os:-elf}
+ basic_os=${basic_os:-elf}
;;
crisv32-* | etraxfs*-*)
cpu=crisv32
@@ -1116,7 +1212,7 @@ case $cpu-$vendor in
vendor=axis
;;
crx-*)
- os=${os:-elf}
+ basic_os=${basic_os:-elf}
;;
neo-tandem)
cpu=neo
@@ -1138,123 +1234,245 @@ case $cpu-$vendor in
cpu=nsx
vendor=tandem
;;
- s390-*)
- cpu=s390
- vendor=ibm
- ;;
- s390x-*)
- cpu=s390x
- vendor=ibm
+ mipsallegrexel-sony)
+ cpu=mipsallegrexel
+ vendor=sony
;;
tile*-*)
- os=${os:-linux-gnu}
+ basic_os=${basic_os:-linux-gnu}
;;
*)
# Recognize the canonical CPU types that are allowed with any
# company name.
case $cpu in
- 1750a | 580 \
+ 1750a \
+ | 580 \
+ | [cjt]90 \
| a29k \
- | aarch64 | aarch64_be \
+ | aarch64 \
+ | aarch64_be \
+ | aarch64c \
| abacus \
- | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
- | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
- | alphapca5[67] | alpha64pca5[67] \
+ | alpha \
+ | alpha64 \
+ | alpha64ev56 \
+ | alpha64ev6[78] \
+ | alpha64ev[4-8] \
+ | alpha64pca5[67] \
+ | alphaev56 \
+ | alphaev6[78] \
+ | alphaev[4-8] \
+ | alphapca5[67] \
| am33_2.0 \
| amdgcn \
- | arc | arceb \
- | arm | arm[lb]e | arme[lb] | armv* \
- | avr | avr32 \
+ | arc \
+ | arc32 \
+ | arc64 \
+ | arceb \
+ | arm \
+ | arm64e \
+ | arm64ec \
+ | arm[lb]e \
+ | arme[lb] \
+ | armv* \
| asmjs \
+ | avr \
+ | avr32 \
| ba \
- | be32 | be64 \
- | bfin | bpf | bs2000 \
- | c[123]* | c30 | [cjt]90 | c4x \
- | c8051 | clipper | craynv | csky | cydra \
- | d10v | d30v | dlx | dsp16xx \
- | e2k | elxsi | epiphany \
- | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
- | h8300 | h8500 \
- | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | be32 \
+ | be64 \
+ | bfin \
+ | bpf \
+ | bs2000 \
+ | c30 \
+ | c4x \
+ | c8051 \
+ | c[123]* \
+ | clipper \
+ | craynv \
+ | csky \
+ | cydra \
+ | d10v \
+ | d30v \
+ | dlx \
+ | dsp16xx \
+ | e2k \
+ | elxsi \
+ | epiphany \
+ | f30[01] \
+ | f700 \
+ | fido \
+ | fr30 \
+ | frv \
+ | ft32 \
+ | fx80 \
+ | h8300 \
+ | h8500 \
| hexagon \
- | i370 | i*86 | i860 | i960 | ia16 | ia64 \
- | ip2k | iq2000 \
+ | hppa \
+ | hppa1.[01] \
+ | hppa2.0 \
+ | hppa2.0[nw] \
+ | hppa64 \
+ | i*86 \
+ | i370 \
+ | i860 \
+ | i960 \
+ | ia16 \
+ | ia64 \
+ | intelgt \
+ | ip2k \
+ | iq2000 \
+ | javascript \
| k1om \
- | le32 | le64 \
+ | kvx \
+ | le32 \
+ | le64 \
| lm32 \
- | m32c | m32r | m32rle \
- | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
- | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
- | m88110 | m88k | maxq | mb | mcore | mep | metag \
- | microblaze | microblazeel \
- | mips | mipsbe | mipseb | mipsel | mipsle \
- | mips16 \
- | mips64 | mips64eb | mips64el \
- | mips64octeon | mips64octeonel \
- | mips64orion | mips64orionel \
- | mips64r5900 | mips64r5900el \
- | mips64vr | mips64vrel \
- | mips64vr4100 | mips64vr4100el \
- | mips64vr4300 | mips64vr4300el \
- | mips64vr5000 | mips64vr5000el \
- | mips64vr5900 | mips64vr5900el \
- | mipsisa32 | mipsisa32el \
- | mipsisa32r2 | mipsisa32r2el \
- | mipsisa32r6 | mipsisa32r6el \
- | mipsisa64 | mipsisa64el \
- | mipsisa64r2 | mipsisa64r2el \
- | mipsisa64r6 | mipsisa64r6el \
- | mipsisa64sb1 | mipsisa64sb1el \
- | mipsisa64sr71k | mipsisa64sr71kel \
- | mipsr5900 | mipsr5900el \
- | mipstx39 | mipstx39el \
+ | loongarch32 \
+ | loongarch64 \
+ | m32c \
+ | m32r \
+ | m32rle \
+ | m5200 \
+ | m68000 \
+ | m680[012346]0 \
+ | m6811 \
+ | m6812 \
+ | m68360 \
+ | m683?2 \
+ | m68hc11 \
+ | m68hc12 \
+ | m68hcs12x \
+ | m68k \
+ | m88110 \
+ | m88k \
+ | maxq \
+ | mb \
+ | mcore \
+ | mep \
+ | metag \
+ | microblaze \
+ | microblazeel \
+ | mips* \
| mmix \
- | mn10200 | mn10300 \
+ | mn10200 \
+ | mn10300 \
| moxie \
- | mt \
| msp430 \
- | nds32 | nds32le | nds32be \
+ | mt \
+ | nanomips* \
+ | nds32 \
+ | nds32be \
+ | nds32le \
| nfp \
- | nios | nios2 | nios2eb | nios2el \
- | none | np1 | ns16k | ns32k | nvptx \
+ | nios \
+ | nios2 \
+ | nios2eb \
+ | nios2el \
+ | none \
+ | np1 \
+ | ns16k \
+ | ns32k \
+ | nvptx \
| open8 \
| or1k* \
| or32 \
| orion \
+ | pdp10 \
+ | pdp11 \
| picochip \
- | pdp10 | pdp11 | pj | pjl | pn | power \
- | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
+ | pj \
+ | pjl \
+ | pn \
+ | power \
+ | powerpc \
+ | powerpc64 \
+ | powerpc64le \
+ | powerpcle \
+ | powerpcspe \
| pru \
| pyramid \
- | riscv | riscv32 | riscv64 \
- | rl78 | romp | rs6000 | rx \
+ | riscv \
+ | riscv32 \
+ | riscv32be \
+ | riscv64 \
+ | riscv64be \
+ | rl78 \
+ | romp \
+ | rs6000 \
+ | rx \
+ | s390 \
+ | s390x \
| score \
- | sh | shl \
- | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
- | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
- | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
+ | sh \
+ | sh64 \
+ | sh64le \
+ | sh[12345][lb]e \
+ | sh[1234] \
+ | sh[1234]e[lb] \
+ | sh[23]e \
+ | sh[23]ele \
+ | sh[24]a \
+ | sh[24]ae[lb] \
+ | sh[lb]e \
+ | she[lb] \
+ | shl \
+ | sparc \
+ | sparc64 \
+ | sparc64b \
+ | sparc64v \
+ | sparc86x \
+ | sparclet \
| sparclite \
- | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
+ | sparcv8 \
+ | sparcv9 \
+ | sparcv9b \
+ | sparcv9v \
| spu \
+ | sv1 \
+ | sw_64 \
+ | sx* \
| tahoe \
- | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
+ | thumbv7* \
+ | tic30 \
+ | tic4x \
+ | tic54x \
+ | tic55x \
+ | tic6x \
+ | tic80 \
| tron \
| ubicom32 \
- | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
+ | v70 \
+ | v810 \
+ | v850 \
+ | v850e \
+ | v850e1 \
+ | v850e2 \
+ | v850e2v3 \
+ | v850es \
| vax \
+ | vc4 \
| visium \
| w65 \
- | wasm32 | wasm64 \
+ | wasm32 \
+ | wasm64 \
| we32k \
- | x86 | x86_64 | xc16x | xgate | xps100 \
- | xstormy16 | xtensa* \
+ | x86 \
+ | x86_64 \
+ | xc16x \
+ | xgate \
+ | xps100 \
+ | xstormy16 \
+ | xtensa* \
| ymp \
- | z8k | z80)
+ | z80 \
+ | z8k)
;;
*)
- echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
+ echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
exit 1
;;
esac
@@ -1275,8 +1493,57 @@ esac
# Decode manufacturer-specific aliases for certain operating systems.
-if [ x$os != x ]
+if test x"$basic_os" != x
then
+
+# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
+# set os.
+obj=
+case $basic_os in
+ gnu/linux*)
+ kernel=linux
+ os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`
+ ;;
+ os2-emx)
+ kernel=os2
+ os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`
+ ;;
+ nto-qnx*)
+ kernel=nto
+ os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
+ ;;
+ *-*)
+ saved_IFS=$IFS
+ IFS="-" read kernel os <<EOF
+$basic_os
+EOF
+ IFS=$saved_IFS
+ ;;
+ # Default OS when just kernel was specified
+ nto*)
+ kernel=nto
+ os=`echo "$basic_os" | sed -e 's|nto|qnx|'`
+ ;;
+ ironclad*)
+ kernel=ironclad
+ os=`echo "$basic_os" | sed -e 's|ironclad|gnu|'`
+ ;;
+ linux*)
+ kernel=linux
+ os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
+ ;;
+ managarm*)
+ kernel=managarm
+ os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
+ ;;
+ *)
+ kernel=
+ os=$basic_os
+ ;;
+esac
+
+# Now, normalize the OS (knowing we just have one component, it's not a kernel,
+# etc.)
case $os in
# First match some system type aliases that might get confused
# with valid system types.
@@ -1288,7 +1555,7 @@ case $os in
os=cnk
;;
solaris1 | solaris1.*)
- os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ os=`echo "$os" | sed -e 's|solaris1|sunos4|'`
;;
solaris)
os=solaris2
@@ -1296,8 +1563,22 @@ case $os in
unixware*)
os=sysv4.2uw
;;
- gnu/linux*)
- os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ # The marketing names for NeXT's operating systems were
+ # NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is
+ # mapped to 'openstep3', but 'openstep1' and 'openstep2' are
+ # mapped to 'nextstep' and 'nextstep2', consistent with the
+ # treatment of SunOS/Solaris.
+ ns | ns1 | nextstep | nextstep1 | openstep1)
+ os=nextstep
+ ;;
+ ns2 | nextstep2 | openstep2)
+ os=nextstep2
+ ;;
+ ns3 | nextstep3 | openstep | openstep3)
+ os=openstep3
+ ;;
+ ns4 | nextstep4 | openstep4)
+ os=openstep4
;;
# es1800 is here to avoid being matched by es* (a different OS)
es1800*)
@@ -1320,12 +1601,9 @@ case $os in
os=sco3.2v4
;;
sco3.2.[4-9]*)
- os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`
;;
- sco3.2v[4-9]* | sco5v6*)
- # Don't forget version if it is 3.2v4 or newer.
- ;;
- scout)
+ sco*v* | scout)
# Don't match below
;;
sco*)
@@ -1334,78 +1612,25 @@ case $os in
psos*)
os=psos
;;
- # Now accept the basic system types.
- # The portable systems comes first.
- # Each alternative MUST end in a * to match a version number.
- # sysv* is not here because it comes later, after sysvr4.
- gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
- | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
- | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
- | sym* | kopensolaris* | plan9* \
- | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
- | aos* | aros* | cloudabi* | sortix* | twizzler* \
- | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
- | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
- | knetbsd* | mirbsd* | netbsd* \
- | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \
- | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
- | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
- | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
- | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \
- | chorusrdb* | cegcc* | glidix* \
- | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
- | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \
- | linux-newlib* | linux-musl* | linux-uclibc* \
- | uxpv* | beos* | mpeix* | udk* | moxiebox* \
- | interix* | uwin* | mks* | rhapsody* | darwin* \
- | openstep* | oskit* | conix* | pw32* | nonstopux* \
- | storm-chaos* | tops10* | tenex* | tops20* | its* \
- | os2* | vos* | palmos* | uclinux* | nucleus* \
- | morphos* | superux* | rtmk* | windiss* \
- | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
- | skyos* | haiku* | rdos* | toppers* | drops* | es* \
- | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
- | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
- | nsk* | powerunix* | genode*)
- # Remember, each alternative MUST END IN *, to match a version number.
- ;;
qnx*)
- case $cpu in
- x86 | i*86)
- ;;
- *)
- os=nto-$os
- ;;
- esac
+ os=qnx
;;
hiux*)
os=hiuxwe2
;;
- nto-qnx*)
- ;;
- nto*)
- os=`echo $os | sed -e 's|nto|nto-qnx|'`
- ;;
- sim | xray | os68k* | v88r* \
- | windows* | osx | abug | netware* | os9* \
- | macos* | mpw* | magic* | mmixware* | mon960* | lnews*)
- ;;
- linux-dietlibc)
- os=linux-dietlibc
- ;;
- linux*)
- os=`echo $os | sed -e 's|linux|linux-gnu|'`
- ;;
lynx*178)
os=lynxos178
;;
lynx*5)
os=lynxos5
;;
+ lynxos*)
+ # don't get caught up in next wildcard
+ ;;
lynx*)
os=lynxos
;;
- mac*)
+ mac[0-9]*)
os=`echo "$os" | sed -e 's|mac|macos|'`
;;
opened*)
@@ -1425,6 +1650,7 @@ case $os in
;;
utek*)
os=bsd
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'`
;;
dynix*)
os=bsd
@@ -1441,21 +1667,25 @@ case $os in
386bsd)
os=bsd
;;
- ctix* | uts*)
+ ctix*)
os=sysv
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|convergent|'`
;;
- nova*)
- os=rtmk-nova
+ uts*)
+ os=sysv
;;
- ns2)
- os=nextstep2
+ nova*)
+ kernel=rtmk
+ os=nova
;;
# Preserve the version number of sinix5.
sinix5.*)
- os=`echo $os | sed -e 's|sinix|sysv|'`
+ os=`echo "$os" | sed -e 's|sinix|sysv|'`
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
;;
sinix*)
os=sysv4
+ vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
;;
tpf*)
os=tpf
@@ -1475,18 +1705,12 @@ case $os in
sysvr4)
os=sysv4
;;
- # This must come after sysvr4.
- sysv*)
- ;;
ose*)
os=ose
;;
*mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
os=mint
;;
- zvmoe)
- os=zvmoe
- ;;
dicos*)
os=dicos
;;
@@ -1499,23 +1723,21 @@ case $os in
os=eabi
;;
*)
- os=elf
+ os=
+ obj=elf
;;
esac
;;
- nacl*)
- ;;
- ios)
- ;;
- none)
- ;;
- *-eabi)
+ aout* | coff* | elf* | pe*)
+ # These are machine code file formats, not OSes
+ obj=$os
+ os=
;;
*)
- echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
- exit 1
+ # No normalization, but not necessarily accepted, that comes below.
;;
esac
+
else
# Here we handle the default operating systems that come with various machines.
@@ -1528,42 +1750,54 @@ else
# will signal an error saying that MANUFACTURER isn't an operating
# system, and we'll never get to this point.
+kernel=
+obj=
case $cpu-$vendor in
score-*)
- os=elf
+ os=
+ obj=elf
;;
spu-*)
- os=elf
+ os=
+ obj=elf
;;
*-acorn)
os=riscix1.2
;;
arm*-rebel)
- os=linux
+ kernel=linux
+ os=gnu
;;
arm*-semi)
- os=aout
+ os=
+ obj=aout
;;
c4x-* | tic4x-*)
- os=coff
+ os=
+ obj=coff
;;
c8051-*)
- os=elf
+ os=
+ obj=elf
;;
clipper-intergraph)
os=clix
;;
hexagon-*)
- os=elf
+ os=
+ obj=elf
;;
tic54x-*)
- os=coff
+ os=
+ obj=coff
;;
tic55x-*)
- os=coff
+ os=
+ obj=coff
;;
tic6x-*)
- os=coff
+ os=
+ obj=coff
;;
# This must come before the *-dec entry.
pdp10-*)
@@ -1585,28 +1819,43 @@ case $cpu-$vendor in
os=sunos3
;;
m68*-cisco)
- os=aout
+ os=
+ obj=aout
;;
mep-*)
- os=elf
+ os=
+ obj=elf
+ ;;
+ # The -sgi and -siemens entries must be before the mips- entry
+ # or we get the wrong os.
+ *-sgi)
+ os=irix
+ ;;
+ *-siemens)
+ os=sysv4
;;
mips*-cisco)
- os=elf
+ os=
+ obj=elf
;;
- mips*-*)
- os=elf
+ mips*-*|nanomips*-*)
+ os=
+ obj=elf
;;
or32-*)
- os=coff
+ os=
+ obj=coff
;;
- *-tti) # must be before sparc entry or we get the wrong os.
+ # This must be before the sparc-* entry or we get the wrong os.
+ *-tti)
os=sysv3
;;
sparc-* | *-sun)
os=sunos4.1.1
;;
pru-*)
- os=elf
+ os=
+ obj=elf
;;
*-be)
os=beos
@@ -1630,7 +1879,7 @@ case $cpu-$vendor in
os=hpux
;;
*-hitachi)
- os=hiux
+ os=hiuxwe2
;;
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
os=sysv
@@ -1674,12 +1923,6 @@ case $cpu-$vendor in
*-encore)
os=bsd
;;
- *-sgi)
- os=irix
- ;;
- *-siemens)
- os=sysv4
- ;;
*-masscomp)
os=rtu
;;
@@ -1687,10 +1930,12 @@ case $cpu-$vendor in
os=uxpv
;;
*-rom68k)
- os=coff
+ os=
+ obj=coff
;;
*-*bug)
- os=coff
+ os=
+ obj=coff
;;
*-apple)
os=macos
@@ -1705,89 +1950,416 @@ case $cpu-$vendor in
os=none
;;
esac
+
fi
+# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
+
+case $os in
+ # Sometimes we do "kernel-libc", so those need to count as OSes.
+ llvm* | musl* | newlib* | relibc* | uclibc*)
+ ;;
+ # Likewise for "kernel-abi"
+ eabi* | gnueabi*)
+ ;;
+ # VxWorks passes extra cpu info in the 4th filed.
+ simlinux | simwindows | spe)
+ ;;
+ # See `case $cpu-$os` validation below
+ ghcjs)
+ ;;
+ # Now accept the basic system types.
+ # Each alternative MUST end in a * to match a version number.
+ abug \
+ | aix* \
+ | amdhsa* \
+ | amigados* \
+ | amigaos* \
+ | android* \
+ | aof* \
+ | aos* \
+ | aros* \
+ | atheos* \
+ | auroraux* \
+ | aux* \
+ | banan_os* \
+ | beos* \
+ | bitrig* \
+ | bme* \
+ | bosx* \
+ | bsd* \
+ | cegcc* \
+ | chorusos* \
+ | chorusrdb* \
+ | clix* \
+ | cloudabi* \
+ | cnk* \
+ | conix* \
+ | cos* \
+ | cxux* \
+ | cygwin* \
+ | darwin* \
+ | dgux* \
+ | dicos* \
+ | dnix* \
+ | domain* \
+ | dragonfly* \
+ | drops* \
+ | ebmon* \
+ | ecoff* \
+ | ekkobsd* \
+ | emscripten* \
+ | emx* \
+ | es* \
+ | fiwix* \
+ | freebsd* \
+ | fuchsia* \
+ | genix* \
+ | genode* \
+ | glidix* \
+ | gnu* \
+ | go32* \
+ | haiku* \
+ | hcos* \
+ | hiux* \
+ | hms* \
+ | hpux* \
+ | ieee* \
+ | interix* \
+ | ios* \
+ | iris* \
+ | irix* \
+ | isc* \
+ | its* \
+ | l4re* \
+ | libertybsd* \
+ | lites* \
+ | lnews* \
+ | luna* \
+ | lynxos* \
+ | mach* \
+ | macos* \
+ | magic* \
+ | mbr* \
+ | midipix* \
+ | midnightbsd* \
+ | mingw32* \
+ | mingw64* \
+ | minix* \
+ | mint* \
+ | mirbsd* \
+ | mks* \
+ | mlibc* \
+ | mmixware* \
+ | mon960* \
+ | morphos* \
+ | moss* \
+ | moxiebox* \
+ | mpeix* \
+ | mpw* \
+ | msdos* \
+ | msys* \
+ | mvs* \
+ | nacl* \
+ | netbsd* \
+ | netware* \
+ | newsos* \
+ | nextstep* \
+ | nindy* \
+ | nonstopux* \
+ | nova* \
+ | nsk* \
+ | nucleus* \
+ | nx6 \
+ | nx7 \
+ | oabi* \
+ | ohos* \
+ | onefs* \
+ | openbsd* \
+ | openedition* \
+ | openstep* \
+ | os108* \
+ | os2* \
+ | os400* \
+ | os68k* \
+ | os9* \
+ | ose* \
+ | osf* \
+ | oskit* \
+ | osx* \
+ | palmos* \
+ | phoenix* \
+ | plan9* \
+ | powermax* \
+ | powerunix* \
+ | proelf* \
+ | psos* \
+ | psp* \
+ | ptx* \
+ | pw32* \
+ | qnx* \
+ | rdos* \
+ | redox* \
+ | rhapsody* \
+ | riscix* \
+ | riscos* \
+ | rtems* \
+ | rtmk* \
+ | rtu* \
+ | scout* \
+ | secbsd* \
+ | sei* \
+ | serenity* \
+ | sim* \
+ | skyos* \
+ | solaris* \
+ | solidbsd* \
+ | sortix* \
+ | storm-chaos* \
+ | sunos \
+ | sunos[34]* \
+ | superux* \
+ | syllable* \
+ | sym* \
+ | sysv* \
+ | tenex* \
+ | tirtos* \
+ | tock* \
+ | toppers* \
+ | tops10* \
+ | tops20* \
+ | tpf* \
+ | tvos* \
+ | twizzler* \
+ | uclinux* \
+ | udi* \
+ | udk* \
+ | ultrix* \
+ | unicos* \
+ | uniplus* \
+ | unleashed* \
+ | unos* \
+ | uwin* \
+ | uxpv* \
+ | v88r* \
+ |*vms* \
+ | vos* \
+ | vsta* \
+ | vxsim* \
+ | vxworks* \
+ | wasi* \
+ | watchos* \
+ | wince* \
+ | windiss* \
+ | windows* \
+ | winnt* \
+ | xenix* \
+ | xray* \
+ | zephyr* \
+ | zvmoe* )
+ ;;
+ # This one is extra strict with allowed versions
+ sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ ;;
+ # This refers to builds using the UEFI calling convention
+ # (which depends on the architecture) and PE file format.
+ # Note that this is both a different calling convention and
+ # different file format than that of GNU-EFI
+ # (x86_64-w64-mingw32).
+ uefi)
+ ;;
+ none)
+ ;;
+ kernel* | msvc* )
+ # Restricted further below
+ ;;
+ '')
+ if test x"$obj" = x
+ then
+ echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
+ fi
+ ;;
+ *)
+ echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
+ exit 1
+ ;;
+esac
+
+case $obj in
+ aout* | coff* | elf* | pe*)
+ ;;
+ '')
+ # empty is fine
+ ;;
+ *)
+ echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we handle the constraint that a (synthetic) cpu and os are
+# valid only in combination with each other and nowhere else.
+case $cpu-$os in
+ # The "javascript-unknown-ghcjs" triple is used by GHC; we
+ # accept it here in order to tolerate that, but reject any
+ # variations.
+ javascript-ghcjs)
+ ;;
+ javascript-* | *-ghcjs)
+ echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
+ exit 1
+ ;;
+esac
+
+# As a final step for OS-related things, validate the OS-kernel combination
+# (given a valid OS), if there is a kernel.
+case $kernel-$os-$obj in
+ linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
+ | linux-mlibc*- | linux-musl*- | linux-newlib*- \
+ | linux-relibc*- | linux-uclibc*- | linux-ohos*- )
+ ;;
+ uclinux-uclibc*- | uclinux-gnu*- )
+ ;;
+ ironclad-gnu*- | ironclad-mlibc*- )
+ ;;
+ managarm-mlibc*- | managarm-kernel*- )
+ ;;
+ windows*-msvc*-)
+ ;;
+ -dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
+ | -uclibc*- )
+ # These are just libc implementations, not actual OSes, and thus
+ # require a kernel.
+ echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
+ exit 1
+ ;;
+ -kernel*- )
+ echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
+ exit 1
+ ;;
+ *-kernel*- )
+ echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
+ exit 1
+ ;;
+ *-msvc*- )
+ echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
+ exit 1
+ ;;
+ kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-)
+ ;;
+ vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
+ ;;
+ nto-qnx*-)
+ ;;
+ os2-emx-)
+ ;;
+ rtmk-nova-)
+ ;;
+ *-eabi*- | *-gnueabi*-)
+ ;;
+ ios*-simulator- | tvos*-simulator- | watchos*-simulator- )
+ ;;
+ none--*)
+ # None (no kernel, i.e. freestanding / bare metal),
+ # can be paired with an machine code file format
+ ;;
+ -*-)
+ # Blank kernel with real OS is always fine.
+ ;;
+ --*)
+ # Blank kernel and OS with real machine code file format is always fine.
+ ;;
+ *-*-*)
+ echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
+ exit 1
+ ;;
+esac
+
# Here we handle the case where we know the os, and the CPU type, but not the
# manufacturer. We pick the logical manufacturer.
case $vendor in
unknown)
- case $os in
- riscix*)
+ case $cpu-$os in
+ *-riscix*)
vendor=acorn
;;
- sunos*)
+ *-sunos* | *-solaris*)
vendor=sun
;;
- cnk*|-aix*)
+ *-cnk* | *-aix*)
vendor=ibm
;;
- beos*)
+ *-beos*)
vendor=be
;;
- hpux*)
+ *-hpux*)
vendor=hp
;;
- mpeix*)
+ *-mpeix*)
vendor=hp
;;
- hiux*)
+ *-hiux*)
vendor=hitachi
;;
- unos*)
+ *-unos*)
vendor=crds
;;
- dgux*)
+ *-dgux*)
vendor=dg
;;
- luna*)
+ *-luna*)
vendor=omron
;;
- genix*)
+ *-genix*)
vendor=ns
;;
- clix*)
+ *-clix*)
vendor=intergraph
;;
- mvs* | opened*)
+ *-mvs* | *-opened*)
+ vendor=ibm
+ ;;
+ *-os400*)
vendor=ibm
;;
- os400*)
+ s390-* | s390x-*)
vendor=ibm
;;
- ptx*)
+ *-ptx*)
vendor=sequent
;;
- tpf*)
+ *-tpf*)
vendor=ibm
;;
- vxsim* | vxworks* | windiss*)
+ *-vxsim* | *-vxworks* | *-windiss*)
vendor=wrs
;;
- aux*)
+ *-aux*)
vendor=apple
;;
- hms*)
+ *-hms*)
vendor=hitachi
;;
- mpw* | macos*)
+ *-mpw* | *-macos*)
vendor=apple
;;
- *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+ *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)
vendor=atari
;;
- vos*)
+ *-vos*)
vendor=stratus
;;
esac
;;
esac
-echo "$cpu-$vendor-$os"
+echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
exit
# Local variables:
-# eval: (add-hook 'before-save-hook 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
# time-stamp-start: "timestamp='"
-# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-format: "%Y-%02m-%02d"
# time-stamp-end: "'"
# End:
diff --git a/configure.ac b/configure.ac
index dee62dd5e..3d8e98a83 100644
--- a/configure.ac
+++ b/configure.ac
@@ -248,20 +248,6 @@ AC_ARG_ENABLE(dynamic,
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
-ifdef([restricted-r],[undefine([restricted-r])])dnl
-AH_TEMPLATE([RESTRICTED_R],
-[Undefine this if you don't want to get a restricted shell
- when zsh is exec'd with basename that starts with r.
- By default this is defined.])
-AC_ARG_ENABLE(restricted-r,
-AS_HELP_STRING([--disable-restricted-r],[turn off r* invocation for restricted shell]),
-[if test x$enableval = xyes; then
- AC_DEFINE(RESTRICTED_R)
-fi],
-AC_DEFINE(RESTRICTED_R)
-)
-
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.])
@@ -452,8 +438,15 @@ AS_HELP_STRING([--enable-cap],[enable the search for POSIX capabilities (may req
# Default off for licensing reasons
AC_ARG_ENABLE(gdbm,
-AS_HELP_STRING([--enable-gdbm],[enable the search for the GDBM library (see the zsh/db/gdbm module)]),
-[gdbm="$enableval"], [gdbm=no])
+AS_HELP_STRING([--enable-gdbm],[enable the search for the GDBM library (see the zsh/db/gdbm module)]))
+
+dnl
+dnl link all libraries in main shell
+dnl
+AC_ARG_ENABLE(link-all-libs,
+AS_HELP_STRING([--disable-link-all-libs],
+ [do not link module-only libraries into the main binary]),
+[enable_link_all_libs=$enableval], [enable_link_all_libs=yes])
dnl ------------------
dnl CHECK THE COMPILER
@@ -690,10 +683,10 @@ fi
AH_TEMPLATE([WINSIZE_IN_PTEM],
[Define if your should include sys/stream.h and sys/ptem.h.])
AC_CACHE_CHECK(for streams headers including struct winsize,
-ac_cv_winsize_in_ptem,
+zsh_cv_winsize_in_ptem,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/stream.h>
-#include <sys/ptem.h>]], [[struct winsize wsz]])],[ac_cv_winsize_in_ptem=yes],[ac_cv_winsize_in_ptem=no])])
-if test x$ac_cv_winsize_in_ptem = xyes; then
+#include <sys/ptem.h>]], [[struct winsize wsz]])],[zsh_cv_winsize_in_ptem=yes],[zsh_cv_winsize_in_ptem=no])])
+if test x$zsh_cv_winsize_in_ptem = xyes; then
AC_DEFINE(WINSIZE_IN_PTEM)
fi
@@ -733,7 +726,6 @@ AC_ARG_WITH(term-lib,
AS_HELP_STRING([--with-term-lib=LIBS],[search space-separated LIBS for terminal handling]),
[if test "x$withval" != xno && test "x$withval" != x ; then
termcap_curses_order="$withval"
- AC_SEARCH_LIBS(tigetstr, [$termcap_curses_order])
else
termcap_curses_order="$ncursesw_test $ncurses_test tinfow tinfo termcap curses"
fi],
@@ -778,11 +770,11 @@ This is probably a library called 'curses' or 'ncurses'. You may
need to install a package called 'curses-devel' or 'ncurses-devel' on your
system."], 255))
AC_CHECK_HEADERS(curses.h, [],
-[AC_CACHE_CHECK(for Solaris 8 curses.h mistake, ac_cv_header_curses_solaris,
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[]])],[ac_cv_header_curses_h=yes
-ac_cv_header_curses_solaris=yes],[ac_cv_header_curses_h=no
-ac_cv_header_curses_solaris=no]))
-if test x$ac_cv_header_curses_solaris = xyes; then
+[AC_CACHE_CHECK(for Solaris 8 curses.h mistake, zsh_cv_header_curses_solaris,
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <curses.h>]], [[]])],
+ [zsh_cv_header_curses_solaris=yes],
+ [zsh_cv_header_curses_solaris=no]))
+if test x$zsh_cv_header_curses_solaris = xyes; then
AC_DEFINE(HAVE_CURSES_H)
fi])
@@ -843,10 +835,19 @@ AC_CACHE_CHECK(if we need to ignore ncurses, zsh_cv_ignore_ncurses,
zsh_cv_ignore_ncurses=yes
;;
esac
+ LIBS="$LIBS_save"
esac
;;
esac])
+dnl Ensure the ncurses library is in LIBS on cached runs where the above code was skipped
+if test x$zsh_cv_ignore_ncurses = xno; then
+ case $LIBS in
+ *-lncurses*|*-lcurses*) ;;
+ *) AC_SEARCH_LIBS(initscr, [ncursesw ncurses curses]) ;;
+ esac
+fi
+
AC_SEARCH_LIBS(getpwnam, nsl)
if test "x$dynamic" = xyes; then
@@ -945,9 +946,18 @@ elif test x$zsh_cv_decl_ospeed_must_define = xyes; then
AC_DEFINE(MUST_DEFINE_OSPEED)
fi
-if test x$gdbm != xno; then
+if test x$enable_gdbm = xyes; then
AC_CHECK_HEADERS(gdbm.h)
+ save_LIBS=$LIBS
+ LIBS=
AC_CHECK_LIB(gdbm, gdbm_open)
+ GDBM_LIBS=$LIBS
+ LIBS=$save_LIBS
+ if test x$enable_link_all_libs = xyes; then
+ LIBS="$GDBM_LIBS $LIBS"
+ GDBM_LIBS=
+ fi
+ AC_SUBST(GDBM_LIBS)
fi
AC_CHECK_HEADERS(sys/xattr.h)
@@ -1282,7 +1292,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
grantpt unlockpt ptsname \
htons ntohs \
regcomp regexec regerror regfree \
- gdbm_open getxattr \
+ getxattr \
realpath canonicalize_file_name \
symlink getcwd \
cygwin_conv_path \
@@ -1298,23 +1308,27 @@ AC_CHECK_DECLS([fpurge])
# isinf() and isnan() can exist as either functions or macros.
AH_TEMPLATE([HAVE_ISINF],
[Define to 1 if you have the `isinf' macro or function.])
-AC_MSG_CHECKING([for isinf])
-AC_LINK_IFELSE([AC_LANG_SOURCE(
+AC_CACHE_CHECK([for isinf], zsh_cv_func_isinf,
+[AC_LINK_IFELSE([AC_LANG_SOURCE(
[[#include <math.h>
int main () { return (isinf(1.0) != 0); }]])],
- [AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_ISINF])],
- [AC_MSG_RESULT([no])])
+ [zsh_cv_func_isinf=yes],
+ [zsh_cv_func_isinf=no])])
+if test x$zsh_cv_func_isinf = xyes; then
+ AC_DEFINE([HAVE_ISINF])
+fi
AH_TEMPLATE([HAVE_ISNAN],
[Define to 1 if you have the `isnan' macro or function.])
-AC_MSG_CHECKING([for isnan])
-AC_LINK_IFELSE([AC_LANG_SOURCE([[
+AC_CACHE_CHECK([for isnan], zsh_cv_func_isnan,
+[AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <math.h>
int main () { return (isnan(1.0) != 0); }]])],
- [AC_MSG_RESULT([yes])
- AC_DEFINE([HAVE_ISNAN])],
- [AC_MSG_RESULT([no])])
+ [zsh_cv_func_isnan=yes],
+ [zsh_cv_func_isnan=no])])
+if test x$zsh_cv_func_isnan = xyes; then
+ AC_DEFINE([HAVE_ISNAN])
+fi
AH_TEMPLATE([REALPATH_ACCEPTS_NULL],
[Define if realpath() accepts NULL as its second argument.])
@@ -1334,8 +1348,16 @@ if test x$zsh_cv_func_realpath_accepts_null = xyes; then
fi
if test x$enable_pcre = xyes; then
- LIBS="`$PCRE_CONFIG --libs8` $LIBS"
+ save_LIBS=$LIBS
+ PCRE_LIBS="`$PCRE_CONFIG --libs8`"
+ LIBS="$PCRE_LIBS $LIBS"
AC_CHECK_FUNCS(pcre2_compile_8)
+ LIBS=$save_LIBS
+ if test x$enable_link_all_libs = xyes; then
+ LIBS="$PCRE_LIBS $LIBS"
+ PCRE_LIBS=
+ fi
+ AC_SUBST(PCRE_LIBS)
fi
if test x$enable_cap = xyes; then
@@ -1697,38 +1719,52 @@ if test x$zsh_cv_path_term_header != xnone; then
term_includes="#include <$zsh_cv_path_term_header>"
fi
- AC_MSG_CHECKING(if boolcodes is available)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolcodes; puts(*test);]])],[AC_DEFINE(HAVE_BOOLCODES) boolcodes=yes],[boolcodes=no])
- AC_MSG_RESULT($boolcodes)
+ AC_CACHE_CHECK(if boolcodes is available, zsh_cv_terminfo_boolcodes,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolcodes; puts(*test);]])],[zsh_cv_terminfo_boolcodes=yes],[zsh_cv_terminfo_boolcodes=no])])
+ if test x$zsh_cv_terminfo_boolcodes = xyes; then
+ AC_DEFINE(HAVE_BOOLCODES)
+ fi
- AC_MSG_CHECKING(if numcodes is available)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numcodes; puts(*test);]])],[AC_DEFINE(HAVE_NUMCODES) numcodes=yes],[numcodes=no])
- AC_MSG_RESULT($numcodes)
+ AC_CACHE_CHECK(if numcodes is available, zsh_cv_terminfo_numcodes,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numcodes; puts(*test);]])],[zsh_cv_terminfo_numcodes=yes],[zsh_cv_terminfo_numcodes=no])])
+ if test x$zsh_cv_terminfo_numcodes = xyes; then
+ AC_DEFINE(HAVE_NUMCODES)
+ fi
- AC_MSG_CHECKING(if strcodes is available)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strcodes; puts(*test);]])],[AC_DEFINE(HAVE_STRCODES) strcodes=yes],[strcodes=no])
- AC_MSG_RESULT($strcodes)
+ AC_CACHE_CHECK(if strcodes is available, zsh_cv_terminfo_strcodes,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strcodes; puts(*test);]])],[zsh_cv_terminfo_strcodes=yes],[zsh_cv_terminfo_strcodes=no])])
+ if test x$zsh_cv_terminfo_strcodes = xyes; then
+ AC_DEFINE(HAVE_STRCODES)
+ fi
- AC_MSG_CHECKING(if boolnames is available)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolnames; puts(*test);]])],[AC_DEFINE(HAVE_BOOLNAMES) boolnames=yes],[boolnames=no])
- AC_MSG_RESULT($boolnames)
+ AC_CACHE_CHECK(if boolnames is available, zsh_cv_terminfo_boolnames,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)boolnames; puts(*test);]])],[zsh_cv_terminfo_boolnames=yes],[zsh_cv_terminfo_boolnames=no])])
+ if test x$zsh_cv_terminfo_boolnames = xyes; then
+ AC_DEFINE(HAVE_BOOLNAMES)
+ fi
- AC_MSG_CHECKING(if numnames is available)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numnames; puts(*test);]])],[AC_DEFINE(HAVE_NUMNAMES) numnames=yes],[numnames=no])
- AC_MSG_RESULT($numnames)
+ AC_CACHE_CHECK(if numnames is available, zsh_cv_terminfo_numnames,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)numnames; puts(*test);]])],[zsh_cv_terminfo_numnames=yes],[zsh_cv_terminfo_numnames=no])])
+ if test x$zsh_cv_terminfo_numnames = xyes; then
+ AC_DEFINE(HAVE_NUMNAMES)
+ fi
- AC_MSG_CHECKING(if strnames is available)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strnames; puts(*test);]])],[AC_DEFINE(HAVE_STRNAMES) strnames=yes],[strnames=no])
- AC_MSG_RESULT($strnames)
+ AC_CACHE_CHECK(if strnames is available, zsh_cv_terminfo_strnames,
+ [AC_LINK_IFELSE([AC_LANG_PROGRAM([[$term_includes]], [[char **test = (char **)strnames; puts(*test);]])],[zsh_cv_terminfo_strnames=yes],[zsh_cv_terminfo_strnames=no])])
+ if test x$zsh_cv_terminfo_strnames = xyes; then
+ AC_DEFINE(HAVE_STRNAMES)
+ fi
dnl There are apparently defective terminal library headers on some
dnl versions of Solaris before 11.
- AC_MSG_CHECKING(if tgoto prototype is missing)
- tgoto_includes="$term_includes
+ AC_CACHE_CHECK(if tgoto prototype is missing, zsh_cv_terminfo_tgoto_proto_missing,
+ [tgoto_includes="$term_includes
/* guaranteed to clash with any valid tgoto prototype */
extern void tgoto(int **stuff, float **more_stuff);"
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[$tgoto_includes]], [[int *stuff; float *more_stuff; tgoto(&stuff, &more_stuff);]])],[AC_DEFINE(TGOTO_PROTO_MISSING) tgotoprotomissing=yes],[tgotoprotomissing=no])
- AC_MSG_RESULT($tgotoprotomissing)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[$tgoto_includes]], [[int *stuff; float *more_stuff; tgoto(&stuff, &more_stuff);]])],[zsh_cv_terminfo_tgoto_proto_missing=yes],[zsh_cv_terminfo_tgoto_proto_missing=no])])
+ if test x$zsh_cv_terminfo_tgoto_proto_missing = xyes; then
+ AC_DEFINE(TGOTO_PROTO_MISSING)
+ fi
else
ZSH_TERM_H=
fi
@@ -2265,11 +2301,11 @@ dnl We need to open it read/write, so make sure it is writeable.
dnl Yet another test which won't work when cross-compiling.
dnl ---------------
AC_CACHE_CHECK(if your system has /dev/ptmx,
-ac_cv_have_dev_ptmx,
+zsh_cv_have_dev_ptmx,
[if test -w /dev/ptmx; then
- ac_cv_have_dev_ptmx=yes
+ zsh_cv_have_dev_ptmx=yes
else
- ac_cv_have_dev_ptmx=no
+ zsh_cv_have_dev_ptmx=no
fi])
dnl --------
@@ -2284,18 +2320,18 @@ dnl these is by defining _GNU_SOURCE.
dnl -------
AH_TEMPLATE([USE_DEV_PTMX],
[Define to 1 if all the kit for using /dev/ptmx for ptys is available.])
-if test x$ac_cv_have_dev_ptmx = xyes -o x$ac_cv_func_posix_openpt = xyes && \
+if test x$zsh_cv_have_dev_ptmx = xyes -o x$ac_cv_func_posix_openpt = xyes && \
test x$ac_cv_func_grantpt = xyes && \
test x$ac_cv_func_unlockpt = xyes && \
test x$ac_cv_func_ptsname = xyes; then
AC_CACHE_CHECK([if /dev/ptmx is usable],
- ac_cv_use_dev_ptmx,
+ zsh_cv_use_dev_ptmx,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#if defined(__linux) || defined(__CYGWIN__)
#define _GNU_SOURCE 1
#endif
#include <stdlib.h>
-int ptsname();]], [[]])],[ac_cv_use_dev_ptmx=no],[ac_cv_use_dev_ptmx=yes])])
- if test x$ac_cv_use_dev_ptmx = xyes; then
+int ptsname();]], [[]])],[zsh_cv_use_dev_ptmx=no],[zsh_cv_use_dev_ptmx=yes])])
+ if test x$zsh_cv_use_dev_ptmx = xyes; then
AC_DEFINE(USE_DEV_PTMX)
fi
fi
@@ -2304,11 +2340,14 @@ dnl -----------------
dnl multibyte support
dnl -----------------
AC_ARG_ENABLE(multibyte,
-AS_HELP_STRING([--enable-multibyte],[support multibyte characters]),
-[zsh_cv_c_unicode_support=$enableval],
-[AC_CACHE_VAL(zsh_cv_c_unicode_support,
- AC_MSG_NOTICE([checking for functions supporting multibyte characters])
- [zfuncs_absent=
+AS_HELP_STRING([--enable-multibyte],[support multibyte characters]))
+
+if test "x$enable_multibyte" = xno; then
+ zsh_use_multibyte=no
+else
+ AC_CACHE_VAL(zsh_cv_c_unicode_capable,
+ [AC_MSG_NOTICE([checking for functions supporting multibyte characters])
+ zfuncs_absent=
dnl
dnl Note that iswblank is not included and checked separately.
dnl As iswblank() was added to C long after the others, we still
@@ -2324,14 +2363,21 @@ wmemcpy wmemmove wmemset; do
done
if test x"$zfuncs_absent" = x; then
AC_MSG_NOTICE([all functions found, multibyte support enabled])
- zsh_cv_c_unicode_support=yes
+ zsh_cv_c_unicode_capable=yes
+ zsh_cv_c_unicode_missing=
else
# Warns at the end of configure
AC_MSG_NOTICE([missing functions, multibyte support disabled])
- zsh_cv_c_unicode_support=no
+ zsh_cv_c_unicode_capable=no
+ zsh_cv_c_unicode_missing=$zfuncs_absent
fi
- ])
-])
+ ])
+ zsh_use_multibyte=$zsh_cv_c_unicode_capable
+ if test "x$enable_multibyte" = xyes && test "x$zsh_cv_c_unicode_capable" = xno; then
+ AC_MSG_ERROR([--enable-multibyte requested but required functions are missing:$zsh_cv_c_unicode_missing])
+ fi
+fi
+
AH_TEMPLATE([MULTIBYTE_SUPPORT],
[Define to 1 if you want support for multibyte character sets.])
@@ -2349,7 +2395,7 @@ fi])
AH_TEMPLATE([BROKEN_ISPRINT],
[Define to 1 if the isprint() function is broken under UTF-8 locale.])
-if test x$zsh_cv_c_unicode_support = xyes; then
+if test x$zsh_use_multibyte = xyes; then
AC_DEFINE(MULTIBYTE_SUPPORT)
dnl Test if wcwidth() and/or iswprint() is broken for
@@ -2703,11 +2749,15 @@ int main(int argc, char *argv[])
changequote([, ])
AC_CACHE_CHECK(if we can use -rdynamic, zsh_cv_rdynamic_available,
-old_LDFLAGS="$LDFLAGS"
+[old_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -rdynamic"
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[zsh_cv_rdynamic_available=yes
-EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-rdynamic}"],[zsh_cvs_rdynamic_available=no])
-LDFLAGS="$old_LDFLAGS")
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
+ [zsh_cv_rdynamic_available=yes],
+ [zsh_cv_rdynamic_available=no])
+LDFLAGS="$old_LDFLAGS"])
+if test x$zsh_cv_rdynamic_available = xyes; then
+ EXTRA_LDFLAGS="${EXTRA_LDFLAGS=-rdynamic}"
+fi
AC_CACHE_CHECK(if your dlsym() needs a leading underscore,
zsh_cv_func_dlsym_needs_underscore,
[echo failed >conftestval && cat >conftest.c <<EOM
@@ -2917,7 +2967,7 @@ dnl config.status, and only change when configure is rerun.
dnl So we need to run the autoconf tests here and store the results.
dnl We then generate config.modules, preserving any user-generated
dnl information, from config.status.
-for modfile in `cd ${srcdir}; echo */*.mdd */*/*.mdd`; do
+for modfile in `cd ${srcdir}; echo Src/*.mdd Src/*/*.mdd`; do
name=
link=
load=
@@ -3065,7 +3115,13 @@ if test "x$dynamic" = xyes; then
module linker flags : ${LDFLAGS} ${LIBLDFLAGS} ${DLLDFLAGS}"
fi
echo "\
-library flags : ${LIBS}
+library flags : ${LIBS}"
+if test x$enable_link_all_libs != xyes; then
+echo "\
+gdbm module library flags : ${GDBM_LIBS}
+pcre module library flags : ${PCRE_LIBS}"
+fi
+echo "\
installation basename : ${tzsh_name}
binary install path : ${zshbin2}
man page install path : ${zshman2}
@@ -3079,14 +3135,14 @@ fi
echo "See config.modules for installed modules and functions.
"
-if test x$zsh_cv_c_unicode_support != xyes; then
- if test "x$zfuncs_absent" = x; then
+if test x$zsh_use_multibyte != xyes; then
+ if test "x$enable_multibyte" = xno; then
# The user opted out.
AC_MSG_WARN([You have chosen to build without multibyte support.])
AC_MSG_WARN([This configuration may not be suitable for production use. It is known to cause errors in 'make test'. We strongly recommend to re-run configure with --enable-multibyte.])
else
# Some requisite functions are missing.
- AC_MSG_WARN([Multibyte support cannot be enabled: some standard library functions are missing: $zfuncs_absent])
+ AC_MSG_WARN([Multibyte support cannot be enabled: some standard library functions are missing: $zsh_cv_c_unicode_missing])
AC_MSG_WARN([This configuration may not be suitable for production use. It is known to cause errors in 'make test'. If your system provides those functions, we recommend to re-run configure appropriately.])
# If your system doesn't have those functions, consider patching the
# test suite and sending the patch to zsh-workers@ for inclusion.