about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-06-18 17:40:52 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-06-18 17:40:52 +0000
commitd1fa8106b43e1d7eac0fbbd4741a8fd7107914b2 (patch)
tree387f5de311b9e6ba48135a47793aad8eff6fc7f5
parent619d2d4b64d807b12dc6e37482db76a4102c1f48 (diff)
downloadzsh-d1fa8106b43e1d7eac0fbbd4741a8fd7107914b2.tar.gz
zsh-d1fa8106b43e1d7eac0fbbd4741a8fd7107914b2.tar.xz
zsh-d1fa8106b43e1d7eac0fbbd4741a8fd7107914b2.zip
Merge assorted fixes from the development version.
-rw-r--r--ChangeLog92
-rw-r--r--Completion/Redhat/Command/_rpm278
-rw-r--r--Doc/Zsh/builtins.yo392
-rw-r--r--README86
-rw-r--r--Src/Modules/termcap.c430
-rw-r--r--Src/Zle/computil.c4
-rw-r--r--Src/prompt.c4
-rw-r--r--Test/C02cond.ztst185
-rw-r--r--Test/comptest151
-rw-r--r--zshconfig.ac9
10 files changed, 1364 insertions, 267 deletions
diff --git a/ChangeLog b/ChangeLog
index 2ed7fc960..6efdf59c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2001-06-18  Bart Schaefer  <schaefer@zsh.org>
+
+	* 14965: Src/Zle/computil.c: Silence compiler warnings.
+
 2001-06-18  Sven Wischnowsky  <wischnow@zsh.org>
 
 	* 14962: Completion/Unix/Type/_path_files: make special-dirs
@@ -18,16 +22,16 @@
 	* 14951: Src/signals.c, Src/signals.h: rename handler() to
 	zhandler() because it's now exported to modules
 
+2001-06-17  Bart Schaefer  <schaefer@zsh.org>
+
+	* Jason Began: 3931 (see cvs.netbsd.org): zshconfig.ac: Use
+	-fPIC for gcc dynamic linking rather than -fpic.
+
 2001-06-14  Peter Stephenson  <pws@csr.com>
 
 	* 14921: Completion/Zsh/_zftp: autoload zfcd_match and zfget_match
 	if necessary.
 
-2001-06-13  Oliver Kiddle  <opk@zsh.org>
-
-	* 14896: Completion/Zsh/Type/_command_names: don't complete read-only
-	parameters on the left side of an assignment
-
 2001-06-13  Sven Wischnowsky  <wischnow@zsh.org>
 
 	* 14903: Src/Zle/complist.c, Src/Zle/zle_tricky.c: fixes for
@@ -51,50 +55,87 @@
 	`document' comparguments and compvalues with some comments in
 	computil.c
 
+2001-06-13  Oliver Kiddle  <opk@zsh.org>
+
+	* 14896: Completion/Zsh/Type/_command_names: don't complete read-only
+	parameters on the left side of an assignment
+
+2001-06-13  Peter Stephenson  <pws@csr.com>
+
+	* unposted: Completion/compinstall: spotted by Bart: assignments
+	when finding $fpath if not set in current shell were completely
+	garbled.
+
+2001-06-13  Sven Wischnowsky  <wischnow@zsh.org>
+
 	* 14883 (Jos Backus): Completion/Unix/Command/_mount: add code for
 	BSDish systems
 
+2001-06-12  Bart Schaefer  <schaefer@zsh.org>
+
+	* 14849: README: Request "reporter" output only if a bug cannot
+	be reproduced with 'zsh -f'.
+
+2001-06-11  Sven Wischnowsky  <wischnow@zsh.org>
+
 	* 14841: Completion/Base/Utility/_values, Src/Zle/computil.c:
 	new word parsing for compvalues; this should now handle empty
 	separators correctly, as far as it is possible
 
-2001-06-13  Wayne Davison  <wayned@users.sourceforge.net>
+2001-06-11  Peter Stephenson  <pws@csr.com>
 
-        * 14793: Src/hist.c: Don't mark a HIST_TMPSTORE entry with HIST_OLD
-	so that the HFILE_FAST algorithm in savehistfile() will recheck this
-	histnum later.
+	* 14840: Doc/Zsh/options.yo: document search behaviour with
+	PATH_DIRS option.
 
-2001-06-13  Andrej Borsenkow <bor@zsh.org>
+2001-06-10  Clint Adams  <clint@zsh.org>
 
-	* 14766: Src/prompt.c: uniform %l substitution
+	* 14830: config.guess, config.sub:
+	upgrade to GNU's June 5 and 8 versions,
+	respectively.
 
-2001-06-13  Peter Stephenson  <pws@csr.com>
+2001-06-09  Bart Schaefer  <schaefer@zsh.org>
 
-	* unposted: Completion/compinstall: spotted by Bart: assignments
-	when finding $fpath if not set in current shell were completely
-	garbled.
+	* unposted (see 14826): Test/C02cond.ztst: Force group of new
+	directory created for file-mode tests to be owned by the current
+	effective group.
 
-2001-06-11  Peter Stephenson  <pws@csr.com>
+	* 14824: Test/comptest: Avoid echotc (improvement on 14792).
 
-	* 14840: Doc/Zsh/options.yo: document search behaviour with
-	PATH_DIRS option.
+2001-06-08  Bart Schaefer  <schaefer@zsh.org>
 
-2001-06-10  Clint Adams <clint@zsh.org>
+	* 14796: zshconfig.ac: More reliable BROKEN_KILL_ESRCH test.
 
-	* 14830: config.guess, config.sub:
-	upgrade to modern versions.
+2001-06-07  Bart Schaefer  <schaefer@zsh.org>
+
+	* 14792: Test/comptest: Don't import the current terminal type for
+	the zpty terminal, because the current terminal might not be able
+	to run ZLE (e.g., emacs shell mode).
+
+	* 14712: Doc/Zsh/builtins.yo: Improve appearance of long hanging
+	paragraph tag for the "read" builtin.
+
+	* 14578: Src/Modules/termcap.c: Handle vagaries of tgetflag()
+	return value in new function ztgetflag().
 
-2001-06-06  Andrej Borsenkow <bor@zsh.org>
+2001-06-07  Wayne Davison  <wayned@users.sourceforge.net>
+
+	* 14793: Src/hist.c: Don't mark a HIST_TMPSTORE entry with HIST_OLD
+	so that the HFILE_FAST algorithm in savehistfile() will recheck this
+	histnum later.
+
+2001-06-06  Andrej Borsenkow  <bor@zsh.org>
 
 	* 14772: David Lebel <lebel@lebel.org>: zshconfig.ac: patch
 	for dynamic linking on OpenBSD
 
+	* 14766: Src/prompt.c: uniform %l substitution
+
 	* 14679, Bart 14693, 14758, 14760: configure.ac, zshconfig.ac,
 	.distfiles, Makefile.in, configure.in, Src/mkmakemod.sh: Allow
 	processing by both autoconf-2.13 and autoconf-2.50; remove
 	config.status hack for autoconf-2.50
 
-2001-06-06  Sven Wischnowsky <wischnow@zsh.org>
+2001-06-06  Sven Wischnowsky  <wischnow@zsh.org>
 
 	* 14736: Doc/Zsh/compsys.yo: make docs for _wanted and
 	_requested clearer (command has to allow options passed to it)
@@ -103,9 +144,10 @@
 	actions that have to be tried (but only once), execute actions
 	if we aren't after an option already (in the same word)
 
-2001-06-04  Peter Stephenson  <pws@csr.com>
+2001-06-05  Chmouel Boudjnah  <chmouel@mandrakesoft.com>
 
-	* Config/version.mk: relabelled this version 4.0.1-dev-0
+	* 14550: Completion/Redhat/Command/_rpm: Add --nobuild and --nogpg
+	to rpm completion
 
 2001-06-01  Peter Stephenson  <pws@csr.com>
 
diff --git a/Completion/Redhat/Command/_rpm b/Completion/Redhat/Command/_rpm
new file mode 100644
index 000000000..a174f1aa6
--- /dev/null
+++ b/Completion/Redhat/Command/_rpm
@@ -0,0 +1,278 @@
+#compdef rpm
+
+# This uses `_arguments' in a state-machine kind of way. These states
+# have names and before executing the default action for such a state
+# we try to call a function with the name `_rpm_<state>'. If such a
+# function exists, we return with its return status immediately. This
+# allows users to override the default completions by simply defining
+# these functions.
+# The states (and possible values for the `<state>' above) are:
+#
+#  query
+#    complete for `rpm -q' query
+#  verify
+#    complete for `rpm --verify'
+#  install
+#    complete for `rpm -i' or `rpm --install'
+#  upgrade
+#    complete for `rpm -U' or `rpm --upgrade'
+#  uninstall
+#    complete for `rpm -e' or `rpm --erase'
+#  build_b
+#    complete for `rpm -bx' (the stage `x' is already completed)
+#  build_t
+#    complete for `rpm -tx' (the stage `x' is already completed)
+#  sigcheck
+#    complete for `rpm --sigcheck'
+#  rebuild
+#    complete for `rpm --rebuild'
+#  package
+#    complete a RPM package name
+#  package_file
+#    complete a RPM package file name
+#  package_or_file
+#    the previous two together
+#  tags
+#    complete a tag name
+#  capability
+#    complete a capability
+#  relocate
+#    complete a `old=new' pair of paths
+
+# Used by `_arguments', made local here.
+
+_rpm () {
+  local curcontext="$curcontext" state lstate line nm="$compstate[nmatches]"
+  typeset -A opt_args
+  
+  state=''
+  
+  local ret=1
+  local -a tmp expl commonopts packageopts
+  commonopts=(
+    '*-v[verbose mode]'
+    '--rcfile:resource file:_files'
+    '--ftpproxy:FTP proxy server:_hosts'
+    '--ftpport:FTP port number:'
+    '--httpproxy:HTTP proxy server:_hosts'
+    '--httpport:HTTP port number:'
+  )
+  packageopts=(
+    '-a[query all packages]'
+    '-p[query uninstalled package file]:*:RPM package file:->package_file'
+    '-f[specify file to query owner of]:file:_files'
+    '--triggeredby:RPM package:->package'
+    '--whatprovides:RPM capability:->capability'
+    '--whatrequires:RPM capability:->capability'
+  )
+  pathopts=(
+    '--root:RPM root directory:_files -/'
+    '--dbpath:RPM database path:_files -/'
+  )
+  
+  # Do simple completions or get the first state.
+  
+  _arguments -C -s \
+    '--help[print help message]' \
+    '--version[print version number]' \
+    "${commonopts[@]}" \
+    '-q+[query mode]:*:query:->query' \
+    --{querytags,initdb,showrc} \
+    '--pipe:pipe command:_command_names -e' \
+    -{V,y}'[verify mode]:*:verify:->verify' \
+    '--verify[verify mode]:*:verify:->verify' \
+    '--setperms[set file permissions]:*:package:->setattrs' \
+    '--setugids[set file owner/group]:*:package:->setattrs' \
+    '(--install)-i+[install mode]:*:install:->install' \
+    '(-i)--install:*:install:->install' \
+    '(--upgrade)-U+[upgrade mode]:*:upgrade:->upgrade' \
+    '(-U)--upgrade:*:upgrade:->upgrade' \
+    '(--freshen)-F+[freshen mode]:*:upgrade:->upgrade' \
+    '(-F)--freshen:*:upgrade:->upgrade' \
+    '(--erase)-e+[uninstall mode]:*:uninstall:->uninstall' \
+    '(-e)--erase:*:uninstall:->uninstall' \
+    '-b+[build mode (spec file)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_b' \
+    '(-b)-t+[build mode (tar file)]:build stage:((p\:execute\ \%prep\ stage l\:do\ a\ list\ check c\:execute\ build\ stage i\:execute\ install\ stage b\:build\ a\ binary\ package a\:build\ binary\ and\ source\ packages)):*:build:->build_t' \
+    --{resign,addsign}':*:RPM package:->package_file' \
+    '--rmsource:*:spec file:->spec_file' \
+    --{rebuild,recompile}':*:Src RPM files:->package_src' \
+    '(--checksig)-K+[signature check mode]:*:sigcheck:->sigcheck' \
+    '(-K)--checksig:*:sigcheck:->sigcheck' \
+    '--rebuilddb:*:rebuild:->rebuild' && ret=0
+  
+  # As long as we have a state name...
+  
+  while [[ -n "$state" ]]; do
+  
+    # First try to call a user-defined function.
+  
+    _call_function ret _rpm_$state && return ret
+  
+    # Copy the state and reset `state', to simplify the test above.
+  
+    lstate="$state"
+    state=''
+    tmp=()
+  
+    # Dispatch...
+  
+    case "$lstate" in
+    query)
+      # --dump requires on of -{l,c,d}
+      # --triggers requires --script
+      _arguments -s \
+        -q "${commonopts[@]}" "${packageopts[@]}" "${pathopts[@]}" \
+        '--queryformat:RPM query format:->tags' \
+        '-i[display package information]' \
+        '--changelog[display change log]' \
+        '-l[display package file list]' \
+        '-s[show file states]' \
+        '-d[documentation files only]' \
+        '-c[configuration files only]' \
+        '--dump[show all information]' \
+        --provides \
+        -{R,-requires}'[list dependencies]' \
+        '--scripts[show (un)install scripts]' \
+        '--triggers[show trigger scripts]' \
+        '*:RPM package:->package_or_file' && ret=0
+      ;;
+    setattrs)
+      _arguments -s --set{perm,ugids} "${packageopts[@]}" && ret = 0
+      ;;
+    verify)
+      _arguments -s \
+        '(-y --verify)-V' '(-V --verify)-y' '(-y -V)--verify' \
+        "${commonopts[@]}" "${pathopts[@]}" \
+        --no{deps,md5,files} \
+        '*:RPM package:->package' && ret=0
+      ;;
+    upgrade)
+      tmp=( '(--upgrade)-U' '(-U)--upgrade' '(--force)--oldpackage' )
+      ;&
+    install)
+      (( $#tmp )) || tmp=( '(--install)-i' '(-i)--install' )
+      _arguments -s "$tmp[@]" \
+        "${commonopts[@]}" "${pathopts[@]}" \
+        '--excludepath:exclude files in following path:_files -/' \
+        '--relocate:relocate:->relocate' \
+        '--prefix:package prefix directory:_files -/' \
+        '(-h)--hash' '(--hash)-h' \
+        '(--replacepkgs --replacefiles --oldpackage)--force' \
+        '(--force)--'{replacefiles,replacepkgs} \
+        --{badreloc,excludedocs,allfiles,ignorearch,ignoreos,includedocs,justdb,nodeps,noorder,noscripts,notriggers,percent,test} \
+        '*:pkg file:->package_file' && ret=0
+      ;;
+    uninstall)
+      _arguments -s \
+        '(-e)--erase' '(--erase)-e' \
+        "${commonopts[@]}" "${pathopts[@]}" \
+        --{allmatches,justdb,nodeps,noorder,noscripts,notriggers} \
+        '*:RPM package:->package' && ret=0
+      ;;
+    build_b)
+      tmp=( '*:spec file:_files -g \*.spec' )
+      ;&
+    build_t)
+      (( $#tmp )) || tmp=( '*:tar file:_files -g \*.\(\#i\)tar\(.\*\|\)' )
+  
+      _arguments -s \
+        "${commonopts[@]}" "${pathopts[@]}" \
+        --{short-circuit,clean,nobuild,rmsource,sign,test} \
+        '--target:specify a build target:->target'\
+        '--buildroot:build root directory:_files -/' \
+        '--buildarch:architecture for which to build:->target' \
+        '--buildos:operating system for which to build:' \
+        '--timecheck:time check (seconds):' "$tmp[1]" && ret=0
+      ;;
+    sigcheck)
+      _arguments -s \
+        '(-K)--checksig' '(--checksig)-K' \
+        "${commonopts[@]}" \
+        --no{gpg,pgp,md5} \
+        '*:RPM package file:->package_file' && ret=0
+      ;;
+    rebuild)
+      _arguments -s \
+        "${commonopts[@]}" "${pathopts[@]}" \
+        '*:RPM source package file:->package_file' && ret=0
+      ;;
+    target)
+      _wanted target expl 'Target platforms' \
+          compadd $(_call_program target rpm --showrc 2> /dev/null |grep 'compatible archs'|sed 's/.*: //') && ret=0
+      ;;
+    package_or_file)
+      state=package_file
+      ;&
+    package)
+      if ( [[ ${+_rpms} -eq 0 ]] || _cache_invalid RPMs ) &&
+         ! _retrieve_cache RPMs;
+      then
+        _rpms=( $(_call_program packages rpm -qa 2>/dev/null) )
+        _store_cache RPMs _rpms
+      fi
+      _wanted packages expl 'RPM package' \
+          compadd -M 'r:|-=* r:|=*' - "$_rpms[@]" && ret=0
+      ;;
+    spec_file)
+      _wanted specfiles expl 'spec file' \
+          _files -g \*.spec && ret=0
+      ;;
+    package_file)
+      _wanted files expl 'RPM package file' \
+          _files -g '*.(#i)rpm' && ret=0
+      if [[ -prefix 1 (f|ht)tp:// ]]; then
+        _wanted urls expl 'URL of RPM package file' \
+            _urls -f -g '*.(#i)rpm' "${expl[@]}" && ret=0
+      else
+        _wanted urls expl 'URL of RPM package file' \
+            compadd -S '' "${expl[@]}" ftp:// http:// && ret=0
+      fi
+      ;;
+    package_src)
+      _files -g \*.src\(\#i\).rpm
+     ;&
+    tags)
+      if compset -P '*%*\{'; then
+        _wanted tags expl 'RPM tag' \
+            compadd -M 'm:{a-z}={A-Z}' -S '\}' - \
+                    "${(@)${(@f)$(_call_program tags rpm --querytags 2> /dev/null)}#RPMTAG_}" && ret=0
+      else
+        _message 'RPM format'
+      fi
+      ;;
+    capability)
+      _message 'RPM capability'
+      ;;
+    relocate)
+      if compset -P '*='; then
+        _description directories expl 'new path'
+      else
+        _description directories expl 'old path'
+      fi
+  
+      _files "$expl[@]" -/ && ret=0
+      ;;
+    esac
+  
+    [[ ret -eq 0 || $nm -ne $compstate[nmatches] ]] && return 0
+  done
+  
+  return ret
+}
+
+# set a sensible default caching policy
+local update_policy
+zstyle -s ":completion:*:*:rpm:*" cache-policy update_policy
+if [[ -z "$update_policy" ]]; then
+  zstyle ":completion:*:*:rpm:*" cache-policy _rpms_caching_policy
+fi
+
+_rpms_caching_policy () {
+  # rebuild if cache is more than a week old
+  oldp=( "$1"(mw+1) )
+  (( $#oldp )) && return 0
+
+  [[ /var/lib/rpm/packages.rpm -nt "$1" ]]
+}
+
+_rpm "$@"
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 167ea356d..fbea91ee2 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -17,6 +17,12 @@ item(tt(ARG1))(
 Same as tt(ARG2).
 )\
 )\
+def(module)(2)(\
+item(tt(ARG1))(
+See ifzman(the section `The ARG2 Module' in zmanref(zshmodules))\
+ifnzman(noderef(The ARG2 Module)).
+)\
+)\
 startitem()
 prefix(-)
 findex(.)
@@ -74,9 +80,9 @@ which no alias has been defined.
 findex(autoload)
 cindex(functions, autoloading)
 cindex(autoloading functions)
-item(tt(autoload) [ {tt(PLUS())|tt(-)}tt(UXmt) ] [ tt(-w) ] [ var(name) ... ])(
-Equivalent to tt(functions -u), with the exception of tt(-X)/tt(+X)
-and tt(-w).
+item(tt(autoload) [ {tt(PLUS())|tt(-)}tt(UXmt) ] [ tt(-wkz) ] [ var(name) ... ])(
+Equivalent to tt(functions -u), with the exception of tt(-X)/tt(+X),
+tt(-w), tt(-k) and tt(-z).
 
 The flag tt(-X) may be used only inside a shell function, and may not be
 followed by a var(name).  It causes the calling function to be marked for
@@ -93,8 +99,18 @@ exit status is nonzero (failure) if the function was already defined or
 when no definition was found.  In the latter case the function remains
 undefined and marked for autoloading.
 
-With the tt(-w) flag, the var(name)s are taken as names of wordcode
-files and all functions defined in them are marked for autoloading.
+The flag tt(+X) may be combined with either tt(-k) or tt(-z) to make
+the function be loaded using ksh-style or zsh-style autoloading,
+respectively. If neither is given, the current setting of the
+tt(KSH_AUTOLOAD) options determines how the function is loaded. With
+ksh-style autoloading, the contents of the file will not be executed
+immediately. Instead, the function created will contain the contents of 
+the file plus a call to the function itself appended to it, thus given 
+normal ksh autoloading behaviour on the first call to the function.
+
+With the tt(-w) flag, the var(name)s are taken as names of files compiled
+with the tt(zcompile) builtin, and all functions defined in them are
+marked for autoloading.
 )
 findex(bg)
 cindex(jobs, backgrounding)
@@ -103,6 +119,7 @@ item(var(job) ... tt(&))(
 Put each specified var(job) in the background,
 or the current job if none is specified.
 )
+module(bindkey)(zsh/zle)
 findex(break)
 cindex(exiting loops)
 cindex(loops, exiting)
@@ -116,6 +133,7 @@ item(tt(builtin) var(name) [ var(args) ... ])(
 Executes the builtin var(name), with the given var(args).
 )
 alias(bye)(exit)
+module(cap)(zsh/cap)
 findex(cd)
 cindex(directories, changing)
 xitem(tt(cd) [ tt(-sLP) ] [ var(arg) ])
@@ -152,7 +170,18 @@ to their true values.  If the tt(-L) option is given symbolic links are
 followed regardless of the state of the tt(CHASE_LINKS) option.
 )
 alias(chdir)(cd)
+module(clone)(zsh/clone)
 prefix(command)
+module(comparguments)(zsh/computil)
+module(compcall)(zsh/compctl)
+module(compctl)(zsh/compctl)
+module(compdescribe)(zsh/computil)
+module(compfiles)(zsh/computil)
+module(compgroups)(zsh/computil)
+module(compquote)(zsh/computil)
+module(comptags)(zsh/computil)
+module(comptry)(zsh/computil)
+module(compvalues)(zsh/computil)
 findex(continue)
 cindex(loops, continuing)
 cindex(continuing loops)
@@ -229,12 +258,8 @@ The tt(-E) flag, or the tt(BSD_ECHO) option, can be used to disable
 these escape sequences.  In the latter case, tt(-e) flag can be used to
 enable them.
 )
-findex(echotc)
-cindex(termcap string, printing)
-item(tt(echotc) var(cap) [ var(arg) ... ])(
-Output the termcap string corresponding to the capability
-var(cap), with optional arguments.
-)
+module(echotc)(zsh/termcap)
+module(echoti)(zsh/terminfo)
 findex(emulate)
 cindex(compatibility, sh)
 cindex(compatibility, ksh)
@@ -380,6 +405,7 @@ findex(functions)
 item(tt(functions) [ {tt(PLUS())|tt(-)}tt(UXmtu) ] [ var(name) ... ])(
 Equivalent to tt(typeset -f).
 )
+module(getcap)(zsh/cap)
 findex(getln)
 cindex(line, reading)
 cindex(reading a line)
@@ -424,7 +450,7 @@ an error message when an option is invalid.  The exit status is
 nonzero when there are no more options.
 )
 findex(hash)
-item(tt(hash) [ tt(-dfmrv) ] [ var(name)[tt(=)var(value)] ] ...)(
+item(tt(hash) [ tt(-Ldfmrv) ] [ var(name)[tt(=)var(value)] ] ...)(
 tt(hash) can be used to directly modify the contents of the command
 hash table, and the named directory hash table.  Normally one would
 modify these tables by modifying one's tt(PATH)
@@ -466,10 +492,13 @@ the hash table will be unchanged.
 
 The tt(-v) option causes hash table entries to be listed as they are
 added by explicit specification.  If has no effect if used with tt(-f).
+
+If the tt(-L) flag is present, then each hash table entry is printed in
+the form of a call to hash.
 )
 alias(history)(fc -l)
 findex(integer)
-item(tt(integer) [ {tt(PLUS())|tt(-)}tt(ghlrtux) ] [ var(name)[tt(=)var(value)] ... ])(
+item(tt(integer) [ {tt(PLUS())|tt(-)}tt(ghilrtux) ] [ var(name)[tt(=)var(value)] ... ])(
 Equivalent to tt(typeset -i), except that options irrelevant to
 integers are not permitted.
 )
@@ -567,9 +596,10 @@ sitem([var(mm)tt(:)]var(ss))(minutes and seconds)
 endsitem()
 )
 findex(local)
-item(tt(local) [ {tt(PLUS())|tt(-)}tt(AEFLRUZahilrtu) [var(n)]] [ var(name)[tt(=)var(value)] ] ...)(
-Same as tt(typeset), except that the options tt(-g), tt(-x) and
-tt(-f) are not permitted.
+item(tt(local) [ {tt(PLUS())|tt(-)}tt(AEFLRUZahilrtux) [var(n)]] [ var(name)[tt(=)var(value)] ] ...)(
+Same as tt(typeset), except that the options tt(-g), and
+tt(-f) are not permitted.  In this case the tt(-x) option does not force
+the use of tt(-g), i.e. exported variables will be local to functions.
 )
 findex(log)
 vindex(watch, use of)
@@ -668,7 +698,10 @@ Treat the arguments as directory names, replacing prefixes with tt(~)
 expressions, as appropriate.
 )
 item(tt(-P))(
-Perform prompt expansion (see noderef(Prompt Expansion)).
+Perform prompt expansion (see
+ifzman(zmanref(zshmisc))\
+ifnzman(noderef(Prompt Expansion))\
+).
 )
 enditem()
 )
@@ -716,18 +749,23 @@ contain symbolic links.
 alias(r)(fc -e -)
 findex(read)
 vindex(IFS, use of)
-item(tt(read) [ tt(-rzpqAclneE) ] [ tt(-k) [ var(num) ] ] \
-[ tt(-u)var(n) ] [ var(name)[tt(?)var(prompt)] ] [ var(name) ...  ])(
+ifzman(xitem(tt(read) [ tt(-rzpqAclneEt) ] [ tt(-k) [ var(num) ] ]))
+item(ifnzman(tt(read) [ tt(-rzpqAclneEt) ] [ tt(-k) [ var(num) ] ]) [ tt(-u)var(n) ] [ var(name)[tt(?)var(prompt)] ] [ var(name) ...  ])(
+vindex(REPLY, use of)
+vindex(reply, use of)
 Read one line and break it into fields using the characters
 in tt($IFS) as separators, except as noted below.
 The first field is assigned to the first var(name), the second field
 to the second var(name), etc., with leftover
 fields assigned to the last var(name).
+If var(name) is omitted then
+tt(REPLY) is used for scalars and tt(reply) for arrays.
 
 startitem()
 item(tt(-r))(
 Raw mode: a `tt(\)' at the end of a line does not signify line
-continuation.
+continuation and backslashes in the line don't quote the following
+character and are not removed.
 )
 item(tt(-q))(
 Read only one character from the terminal and set var(name) to
@@ -770,8 +808,7 @@ function used for completion (specified with the tt(-K) flag to
 tt(compctl)).  If the tt(-c) flag is given, the words of the
 current command are read. If the tt(-l) flag is given, the whole
 line is assigned as a scalar.  If both flags are present, tt(-l)
-is used and tt(-c) is ignored.  If var(name) is omitted then
-tt(REPLY) is used for scalars and tt(reply) for arrays.
+is used and tt(-c) is ignored.
 )
 item(tt(-n))(
 Together with tt(-c), the number of the word the cursor is on is
@@ -787,8 +824,23 @@ digit and must em(not) be separated from tt(-u) by any whitespace.
 item(tt(-p))(
 Input is read from the coprocess.
 )
+item(tt(-t))(
+Test if input is available before attempting to read; if none is, return
+status 1 and do not set any variables.  This is not available when reading
+from the editor buffer with tt(-z), when called from within completion
+with tt(-c) or tt(-l), with tt(-q) which clears the input queue before
+reading, or within zle where other mechanisms should be used to test for
+input.
+ifzman( )
+Note that read does not attempt to alter the input processing mode.  The
+default mode is canonical input, in which an entire line is read at a time,
+so usually `tt(read -t)' will not read anything until an entire line has
+been typed.  However, when reading from the terminal with tt(-k)
+this is automatically handled; note that only availability of the first
+character is tested, so that e.g. `tt(read -t -k 2)' can still block on the
+second character.
+)
 enditem()
-
 If the first argument contains a `tt(?)', the remainder of this
 word is used as a var(prompt) on standard error when the shell
 is interactive.
@@ -821,11 +873,12 @@ the effect is different for zero and non-zero return status.  With zero
 status (or after an implicit return at the end of the trap), the shell
 will return to whatever it was previously processing; with a non-zero
 status, the shell will behave as interrupted except that the return
-status of the trap is retained.  Note that the signal which caused the
-trap is passed as the first argument, so the statement `tt(return
-$((128PLUS()$1)))' will return the same status as if the signal had not
-been trapped.
+status of the trap is retained.  Note that the numeric value of the signal
+which caused the trap is passed as the first argument, so the statement
+`tt(return $((128PLUS()$1)))' will return the same status as if the signal
+had not been trapped.
 )
+module(sched)(zsh/sched)
 findex(set)
 cindex(parameters, listing)
 cindex(parameters, positional)
@@ -850,6 +903,7 @@ given, then the names and values of all parameters are printed on the
 standard output.  If the only argument is `tt(PLUS())',
 the names of all parameters are printed.
 )
+module(setcap)(zsh/cap)
 findex(setopt)
 cindex(options, setting)
 item(tt(setopt) [ {tt(PLUS())|tt(-)}var(options) | \
@@ -875,6 +929,7 @@ item(tt(source) var(file) [ var(arg) ... ])(
 Same as tt(.), except that the current directory is always searched and
 is always searched first, before directories in tt($path).
 )
+module(stat)(zsh/stat)
 findex(suspend)
 cindex(shell, suspending)
 cindex(suspending the shell)
@@ -972,20 +1027,18 @@ var(name) (even those that already exist), and is unset again when the
 function completes.  See
 ifzman(`Local Parameters' in zmanref(zshparam))\
 ifnzman(noderef(Local Parameters))\
-.  Local parameters are not exported unless tt(ALL_EXPORT) is set, in
-which case the parameter is exported em(only) when var(name) does not
-already exist.  The same rules apply to special shell parameters, which
+.  The same rules apply to special shell parameters, which
 retain their special attributes when made local.
 
 For each var(name)tt(=)var(value) assignment, the parameter
-var(name) set to var(value).  Note that arrays currently cannot be
+var(name) is set to var(value).  Note that arrays currently cannot be
 assigned in tt(typeset) expressions, only scalars and integers.
 
 For each remaining var(name) that refers to a parameter that is set, the
 name and value of the parameter are printed in the form of an assignment.
-Nothing is printed for newly-created parameters, or if any attribute flags
-listed below are given.  Using `tt(PLUS())' instead of minus to introduce
-an attribute turns it off.
+Nothing is printed for newly-created parameters, or when any attribute
+flags listed below are given along with the var(name).  Using `tt(PLUS())'
+instead of minus to introduce an attribute turns it off.
 
 If the tt(-T) option is given, exactly two (or zero) var(name)
 arguments must be present.  They represent a scalar and an array (in
@@ -996,31 +1049,43 @@ the former.  Only the scalar may have an initial value.  Both the
 scalar and the array may otherwise be manipulated as normal.  If one
 is unset, the other will automatically be unset too.  There is no way
 of untying the variables without unsetting them, or converting the
-type of one them with another tt(typeset) command; tt(+T) does not work,
-assigning an array to var(SCALAR) is an error, and assigning a scalar
-to var(array) sets it to be a single-element array.  Note that
-both tt(typeset -xT ...) and tt(export -T ...) work, but only the
+type of one of them with another tt(typeset) command; tt(+T) does not
+work, assigning an array to var(SCALAR) is an error, and assigning a
+scalar to var(array) sets it to be a single-element array.  Note that
+both `tt(typeset -xT ...)' and `tt(export -T ...)' work, but only the
 scalar will be marked for export.
 
-The flag tt(-g) (global) flag is treated specially: it means that any
+The tt(-g) (global) flag is treated specially: it means that any
 resulting parameter will not be restricted to local scope.  Note that this
 does not necessarily mean that the parameter will be global, as the flag
 will apply to any existing parameter (even if unset) from an enclosing
 function.  This flag does not affect the parameter after creation, hence it
 has no effect when listing existing parameters, nor does the flag tt(+g)
-have any effect.
+have any effect except in combination with tt(-m) (see below).
 
 If no var(name) is present, the names and values of all parameters are
 printed.  In this case the attribute flags restrict the display to only
 those parameters that have the specified attributes, and using `tt(PLUS())'
 rather than `tt(-)' to introduce the flag suppresses printing of the values
-of parameters when there is no parameter name.  Also, if the option list
-ends with `tt(PLUS())', values will not be printed.  If only the tt(-m)
-flag is given the arguments are taken as patterns (which should be quoted)
-and all parameters (or functions with the tt(-f) flag) with matching names
-are printed.  If no attribute flags and no tt(-m) flag is present, the
-parameter names will be preceded by a list of any attributes (tt(array),
-tt(association), tt(exported), tt(integer), tt(readonly)).
+of parameters when there is no parameter name.  Also, if the last option
+is the word `tt(PLUS())', then names are printed but values are not.
+
+If the tt(-m) flag is given the var(name) arguments are taken as patterns
+(which should be quoted).  With no attribute flags, all parameters (or
+functions with the tt(-f) flag) with matching names are printed.  Note that
+tt(-m) is ignored if no patterns are given.  If the tt(+g) flag is combined
+with tt(-m), a new local parameter is created for every matching parameter
+that is not already local.  Otherwise tt(-m) applies all other flags or
+assignments to the existing parameters.  Except when assignments are made
+with var(name)tt(=)var(value), using tt(+m) forces the matching parameters
+to be printed, even inside a function.
+
+If no attribute flags are given and either no tt(-m) flag is present or
+the tt(+m) form was used, each parameter name printed is preceded by a
+list of the attributes of that parameter (tt(array), tt(association),
+tt(exported), tt(integer), tt(readonly)).  If tt(+m) is used with attribute
+flags, and all those flags are introduced with tt(PLUS()), the matching
+parameter names are printed but their values are not.
 
 The following attribute flags may be specified:
 
@@ -1080,7 +1145,7 @@ is first referenced; see noderef(Functions).
 item(tt(-h))(
 Hide: only useful for special parameters (those marked `<S>' in the table in
 ifzman(zmanref(zshparams))\
-ifnzman(noderef(Parameters))\
+ifnzman(noderef(Parameters Set By The Shell))\
 ), and for local parameters with the same name as a special parameter,
 though harmless for others.  A special parameter with this attribute will
 not retain its special effect when made local.  Thus after `tt(typeset -h
@@ -1092,9 +1157,19 @@ special tt(PATH) parameter is not altered in any way.  It is also possible
 to create a local parameter using `tt(typeset +h )var(special)', where the
 local copy of var(special) will retain its special properties regardless of
 having the tt(-h) attribute.  Global special parameters loaded from shell
-modules (currently those in tt(mapfile) and tt(parameter)) are
+modules (currently those in tt(zsh/mapfile) and tt(zsh/parameter)) are
 automatically given the tt(-h) attribute to avoid name clashes.
 )
+item(tt(-H))(
+Hide value: specifies that tt(typeset) will not display the value of the
+parameter when listing parameters; the display for such parameters is
+always as if the `tt(PLUS())' flag had been given.  Use of the parameter is
+in other respects normal, and the option does not apply if the parameter is
+specified by name, or by pattern with the tt(-m) option.  This is on by
+default for the parameters in the tt(zsh/parameter) and tt(zsh/mapfile)
+modules.  Note, however, that unlike the tt(-h) flag this is also useful
+for non-special parameters.
+)
 item(tt(-i))(
 Use an internal integer representation.  If var(n) is nonzero it
 defines the output arithmetic base, otherwise it is determined by the
@@ -1130,7 +1205,10 @@ This flag has a different meaning when used with tt(-f); see above.
 )
 item(tt(-x))(
 Mark for automatic export to the environment of subsequently
-executed commands.
+executed commands.  If the option tt(GLOBAL_EXPORT) is set, this implies
+the option tt(-g), unless tt(+g) is also explicitly given; in other words
+the parameter is not made local to the enclosing function.  This is for
+compatibility with previous versions of zsh.
 )
 enditem()
 )
@@ -1226,6 +1304,7 @@ If the tt(-m) flag is given the arguments are taken as patterns
 (which should be quoted to preserve them from being interpreted as glob
 patterns), and all options with names matching these patterns are unset.
 )
+module(vared)(zsh/zle)
 findex(wait)
 cindex(waiting for jobs)
 cindex(jobs, waiting for)
@@ -1291,55 +1370,74 @@ item(tt(which) [ tt(-wpams) ] var(name) ...)(
 Equivalent to tt(whence -c).
 )
 findex(zcompile)
-cindex(wordcode, creation)
+cindex(.zwc files, creation)
 cindex(compilation)
-xitem(tt(zcompile) [ tt(-U) ] [ tt(-z) | tt(-k) ] [ tt(-r) | tt(-m) ] var(file) [ var(name) ... ])
-xitem(tt(zcompile) tt(-c) [ tt(-M) ] [ tt(-z) | tt(-k) ] [ tt(-r) | tt(-m) ] var(file) [ var(name) ... ])
+xitem(tt(zcompile) [ tt(-U) ] [ tt(-z) | tt(-k) ] [ tt(-R) | tt(-M) ] var(file) [ var(name) ... ])
+xitem(tt(zcompile) tt(-ca) [ tt(-m) ] [ tt(-R) | tt(-M) ] var(file) [ var(name) ... ])
 item(tt(zcompile -t) var(file) [ var(name) ... ])(
-This builtin command can be used to compile functions or scripts and
-store the compiled form in a file, and to examine files containing
+This builtin command can be used to compile functions or scripts,
+storing the compiled form in a file, and to examine files containing
 the compiled form.  This allows faster autoloading of functions and
 execution of scripts by avoiding parsing of the text when the files
 are read.
 
-The first form (without the tt(-c) or tt(-t) options) creates a
-compiled file.  If only the var(file) argument is provided, the
+The first form (without the tt(-c), tt(-a) or tt(-t) options) creates a
+compiled file.  If only the var(file) argument is given, the
 output file has the name `var(file)tt(.zwc)' and will be placed in
-the same directory as the var(file).  This will make the compiled
-file be loaded instead of the normal function file when the function
-is autoloaded (see
+the same directory as the var(file).  The shell will load the compiled
+file instead of the normal function file when the function
+is autoloaded; see
 ifzman(\
 the section `Autoloading Functions' in zmanref(zshfunc)
 )\
 ifnzman(\
 noderef(Functions)
 )\
-for a description of how autoloaded functions are searched).  The
-extension tt(.zwc) stands for `zsh word codes'.
-
-If there is at least one var(name) argument, all those named files
-are compiled into one output var(file).  If var(file) does not end
-in tt(.zwc), this extension is automatically appended.  Files
-containing multiple compiled functions are called `digest' files,
-and are intended to be used as elements of the tt(FPATH)/tt(fpath)
+for a description of how autoloaded functions are searched.  The
+extension tt(.zwc) stands for `zsh word code'.
+
+If there is at least one var(name) argument, all the named files
+are compiled into the output var(file) given as the first argument.  If
+var(file) does not end in tt(.zwc), this extension is automatically
+appended.  Files containing multiple compiled functions are called `digest'
+files, and are intended to be used as elements of the tt(FPATH)/tt(fpath)
 special array.
 
-The second form, with the tt(-c) option, writes the definitions for
-all the named functions into var(file).  The names must be functions
-currently defined in the shell or marked for autoloading.  If the
-tt(-M) option is given, too, the var(name)s are used as patterns and
-all functions whose names match one of these patterns will be
-written. If no var(name) is given, the definitions of all functions
-currently defined or marked as autoloaded will be written.
+The second form, with the tt(-c) or tt(-a) options, writes the compiled
+definitions for all the named functions into var(file).  For tt(-c), the
+names must be functions currently defined in the shell, not those marked
+for autoloading.  Undefined functions that are marked for autoloading
+may be written by using the tt(-a) option, in which case the tt(fpath)
+is searched and the contents of the definition files for those
+functions, if found, are compiled into var(file).  If both tt(-c) and
+tt(-a) are given, names of both defined functions and functions marked
+for autoloading may be given.  In either case, the functions in files
+written with the tt(-c) or tt(-a) option will be autoloaded as if the
+tt(KSH_AUTOLOAD) option were unset.
+
+The reason for handling loaded and not-yet-loaded functions with
+different options is that some definition files for autoloading define
+multiple functions, including the function with the same name as the
+file, and, at the end, call that function.  In such cases the output of
+`tt(zcompile -c)' does not include the additional functions defined in
+the file, and any other initialization code in the file is lost.  Using
+`tt(zcompile -a)' captures all this extra information.
+
+If the tt(-m) option is combined with tt(-c) or tt(-a),
+the var(name)s are used as patterns and all functions whose names
+match one of these patterns will be written. If no var(name) is given,
+the definitions of all functions currently defined or marked as
+autoloaded will be written.
 
 The third form, with the tt(-t) option, examines an existing
 compiled file.  Without further arguments, the names of the original
-files compiled into it are listed.  The first line of output tells
+files compiled into it are listed.  The first line of output shows
 the version of the shell which compiled the file and how the file
-will be used (mapping or reading the file).  With arguments, nothing
-is output and the return value is set to zero if em(all) var(name)s
-name files contained in the wordcode file, and non-zero if at least
-one var(name) is not contained in it.
+will be used (i.e. by reading it directly or by mapping it into memory).
+With arguments, nothing is output and the return value is set to zero if
+definitions for em(all) var(name)s were found in the compiled
+file, and non-zero if the definition for at least one var(name) was not
+found.
 
 Other options:
 
@@ -1347,67 +1445,76 @@ startitem()
 item(tt(-U))(
 Aliases are not expanded when compiling the var(name)d files.
 )
-item(tt(-r))(
+item(tt(-R))(
 When the compiled file is read, its contents are copied into the
-shell's memory, rather than memory-mapped (see tt(-m)).  This
+shell's memory, rather than memory-mapped (see tt(-M)).  This
 happens automatically on systems that do not support memory mapping.
 
 When compiling scripts instead of autoloadable functions, it is
-often desirable to use this option. Otherwise the whole file will
-remain mapped if the script has defined one or more functions, even
-if the rest of the file will not be used again.
+often desirable to use this option; otherwise the whole file, including the
+code to define functions which have already been defined, will
+remain mapped, consequently wasting memory.
 )
-item(tt(-m))(
+item(tt(-M))(
 The compiled file is mapped into the shell's memory when read. This
 is done in such a way that multiple instances of the shell running
-on the same host will share this mapped file.  If neither tt(-r) nor
-tt(-m) is given, the tt(zcompile) builtin decides what to do based
+on the same host will share this mapped file.  If neither tt(-R) nor
+tt(-M) is given, the tt(zcompile) builtin decides what to do based
 on the size of the compiled file.
 )
 xitem(tt(-k))
 item(tt(-z))(
-These options are used when the compiled file contains functions and
-those functions are to be autoloaded. If tt(-z) is given, the
-function will be autoloaded as if the tt(KSHAUTOLOAD) option is
+These options are used when the compiled file contains functions which
+are to be autoloaded. If tt(-z) is given, the
+function will be autoloaded as if the tt(KSH_AUTOLOAD) option is
 em(not) set, even if it is set at the time the compiled file is
-read. The tt(-k) makes the function be loaded as if tt(KASHAUTOLOAD)
-em(is) set.  If neither of these options is given, the function will
-be loaded as determined by the setting of the tt(KSHAUTOLOAD) option
-at the time the compiled file is read.
-
-These options may also be repeated among the listed var(name)s to
-specify the loading style of all following functions, up to the next
-tt(-k) or tt(-z).
+read, while if the tt(-k) is given, the function will be loaded as if
+tt(KSH_AUTOLOAD) em(is) set.  If neither of these options is given, the
+function will be loaded as determined by the setting of the
+tt(KSH_AUTOLOAD) option at the time the compiled file is read.
+ifzman( )
+These options may also appear as many times as necessary between the listed
+var(name)s to specify the loading style of all following functions, up to
+the next tt(-k) or tt(-z).
+)
+ifnzman(enditem()
 )
-enditem()
-
 The created file always contains two versions of the compiled
 format, one for big-endian machines and one for small-endian
-machines. The upshot of this is that the compiled file is machine
+machines.  The upshot of this is that the compiled file is machine
 independent and if it is read or mapped, only one half of the file
 is actually used (and mapped).
+ifzman(enditem())
 )
+module(zformat)(zsh/zutil)
+module(zftp)(zsh/zftp)
+module(zle)(zsh/zle)
 findex(zmodload)
 cindex(modules, loading)
 cindex(loading modules)
 xitem(tt(zmodload) [ tt(-dL) ] [ ... ])
-xitem(tt(zmodload -e) [ ... ])
+xitem(tt(zmodload -e) [ tt(-A) ] [ ... ])
 xitem(tt(zmodload) [ tt(-a) [ tt(-bcpf) [ tt(-I) ] ] ] [ tt(-iL) ] ...)
-item(tt(zmodload) tt(-u) [ tt(-abcdpf) [ tt(-I) ] ] [ tt(-iL) ] ...)(
-tt(zmodload) performs operations relating to zsh's loadable modules.
-This feature is not available on all operating systems,
-or on all installations on a particular operating system.
-
-Without arguments all currently loaded binary modules are printed.
-The tt(-L) option causes this list to be in the form of a series of
-tt(zmodload) commands.  Forms with arguments are:
+xitem(tt(zmodload) tt(-u) [ tt(-abcdpf) [ tt(-I) ] ] [ tt(-iL) ] ...)
+xitem(tt(zmodload) tt(-A) [ tt(-L) ] [ var(modalias)[tt(=)var(module)] ... ])
+item(tt(zmodload) tt(-R) var(modalias) ... )(
+Performs operations relating to zsh's loadable modules.
+Loading of modules while the shell is running (`dynamical loading') is not
+available on all operating systems, or on all installations on a particular
+operating system, although the tt(zmodload) command itself is always
+available and can be used to manipulate modules built into versions of the
+shell executable without dynamical loading.
+
+Without arguments the names of all currently loaded binary modules are
+printed.  The tt(-L) option causes this list to be in the form of a
+series of tt(zmodload) commands.  Forms with arguments are:
 
 startitem()
 xitem(tt(zmodload) [ tt(-i) ] var(name) ... )
 item(tt(zmodload) tt(-u) [ tt(-i) ] var(name) ...)(
 In the simplest case, tt(zmodload) loads a binary module.  The module must
 be in a file with a name consisting of the specified var(name) followed by
-a standard suffix, usually `tt(.so)'.
+a standard suffix, usually `tt(.so)' (`tt(.sl)' on HPUX).
 If the module to be loaded is
 already loaded and the tt(-i) option is given, the duplicate module is
 ignored.  Otherwise tt(zmodload) prints an error message.
@@ -1484,7 +1591,7 @@ tt(zmodload) work on autoloaded parameters instead.
 xitem(tt(zmodload) tt(-af) [ tt(-L) ])
 xitem(tt(zmodload) tt(-af) [ tt(-i) ] var(name) [ var(function) ... ])
 item(tt(zmodload) tt(-uf) [ tt(-i) ] var(function) ...)(
-The tt(-p) option is like the tt(-b), tt(-p), and tt(-c) options, but
+The tt(-f) option is like the tt(-b), tt(-p), and tt(-c) options, but
 makes tt(zmodload) work on autoloaded math functions instead. 
 )
 xitem(tt(zmodload) tt(-a) [ tt(-L) ])
@@ -1492,21 +1599,66 @@ xitem(tt(zmodload) tt(-a) [ tt(-i) ] var(name) [ var(builtin) ... ])
 item(tt(zmodload) tt(-ua) [ tt(-i) ] var(builtin) ...)(
 Equivalent to tt(-ab) and tt(-ub).
 )
-item(tt(zmodload -e) [ var(string) ... ])(
-The tt(-e) option without arguments lists all loaded modules loaded.
-With arguments only the return status is set to zero
+item(tt(zmodload -e) [ tt(-A) ] [ var(string) ... ])(
+The tt(-e) option without arguments lists all loaded modules; if the tt(-A)
+option is also given, module aliases corresponding to loaded modules are
+also shown.  With arguments only the return status is set to zero
 if all var(string)s given as arguments are names of loaded modules
 and to one if at least on var(string) is not the name of a
-loaded module. This can be used to test for the availability 
-of things implemented by modules.
+loaded module.  This can be used to test for the availability 
+of things implemented by modules.  In this case, any aliases are
+automatically resolved and the tt(-A) flag is not used.
+)
+item(tt(zmodload) tt(-A) [ tt(-L) ] [ var(modalias)[tt(=)var(module)] ... ])(
+For each argument, if both var(modalias) and var(module) are given,
+define var(modalias) to be an alias for the module var(module).
+If the module var(modalias) is ever subsequently requested, either via a
+call to tt(zmodload) or implicitly, the shell will attempt to load
+var(module) instead.  If var(module) is not given, show the definition of
+var(modalias).  If no arguments are given, list all defined module aliases.
+When listing, if the tt(-L) flag was also given, list the definition as a
+tt(zmodload) command to recreate the alias.
+
+The existence of aliases for modules is completely independent of whether
+the name resolved is actually loaded as a module: while the alias exists,
+loading and unloading the module under any alias has exactly the same
+effect as using the resolved name, and does not affect the connection
+between the alias and the resolved name which can be removed either by
+tt(zmodload -R) or by redefining the alias.  Chains of aliases (i.e. where
+the first resolved name is itself an alias) are valid so long as these are
+not circular.  As the aliases take the same format as module names, they
+may include path separators:  in this case, there is no requirement for any
+part of the path named to exist as the alias will be resolved first.  For
+example, `tt(any/old/alias)' is always a valid alias.
+
+Dependencies added to aliased modules are actually added to the resolved
+module; these remain if the alias is removed.  It is valid to create an
+alias whose name is one of the standard shell modules and which resolves to
+a different module.  However, if a module has dependencies, it
+will not be possible to use the module name as an alias as the module will
+already be marked as a loadable module in its own right.
+
+Apart from the above, aliases can be used in the tt(zmodload) command
+anywhere module names are required.  However, aliases will not be
+shown in lists of loaded modules with a bare `tt(zmodload)'.
+)
+item(tt(zmodload) tt(-R) var(modalias) ... )(
+For each var(modalias) argument that was previously defined as a module
+alias via tt(zmodload -A), delete the alias.  If any was not defined, an
+error is caused and the remainder of the line is ignored.
 )
 enditem()
 
-Note that tt(zsh) makes no difference between modules that were linked 
+Note that tt(zsh) makes no distinction between modules that were linked 
 into the shell and modules that are loaded dynamically. In both cases
 this builtin command has to be used to make available the builtins and
 other things defined by modules (unless the module is autoloaded on
-these definitions). This is even true for systems that don't support
+these definitions). This is true even for systems that don't support
 dynamic loading of modules.
 )
+module(zparseopts)(zsh/zutil)
+module(zprof)(zsh/zprof)
+module(zpty)(zsh/zpty)
+module(zregexparse)(zsh/zutil)
+module(zstyle)(zsh/zutil)
 enditem()
diff --git a/README b/README
index 6b47a99ce..a5bfeac9b 100644
--- a/README
+++ b/README
@@ -5,9 +5,7 @@ THE Z SHELL (ZSH)
 Version
 -------
 
-This is zsh version 3.1 (beta)
-
-Note that this is a beta version.  The latest stable version is zsh-3.0.6.
+This is zsh version 4.0.  This is a stable release.
 
 Installing Zsh
 --------------
@@ -19,35 +17,45 @@ are any special instructions for your particular architecture.
 Features
 --------
 
-Zsh is a shell with lots of features.  For a list of these, see the
+Zsh is a shell with lots of features.  For a list of some of these, see the
 file Etc/FEATURES, and for the latest changes see Etc/NEWS.  For more
 details, see the documentation.
 
-Possibile incompatibilities
+Possible incompatibilities
 ---------------------------
 
-If you have been using recent versions of zsh 3.1, the following changes in
-the shell may affect you:
-- The traditional bindings of \M-n (history-search-backward) and
-  \M-p (history-search-forward) in older versions of zsh have returned,
-  as has the traditional behaviour of those functions and the functions
-  up-line-or-search and down-line-or-search.  In 3.1.5, the functions
-  behaved differently and \M-n and \M-p were bound by default to
-  history-beginning-search-backward and history-beginning-search-forward.
-- Prompt truncation behaviour via %<...< and %>...> (or %[<...] etc.) has
-  changed slightly:  the string to be truncated runs to the end of the
-  prompt or to the next truncation sequence; %<< will turn off truncation.
-  Previously it only covered individual prompt escapes.  So for example the
-  prompt `%10<...<%~%% ' will now include the `%% ' in the string to be
-  truncated, and you should change the prompt to `%10<...<%~%<<%% ' to turn
-  off truncation immediately after the `%~'.
-- If for some reason you have `setopt norcs' or `unsetopt rcs' anywhere in
-  your startup files (e.g. to stop .zlogout being run), this will now
-  take effect immediately, preventing later startup files from being
-  run.  It is safe to put `setopt norcs' in .zlogin as this is always
-  the last run.
-
-See the FAQ for a discussion of changes over the longer term.
+Some particular differences you may notice between version 3.0 and 4.0
+(mostly based on 3.0.8; there are other differences from earlier versions):
+
+  o  The options ALWAYS_LAST_PROMPT (return to the line you were
+     editing after displaying completion lists) and LIST_AMBIGUOUS
+     (don't do AUTO_LIST if there was an unambiguous prefix that could be
+     inserted, i.e. only list if it is ambiguous what to insert next) are
+     now set by default.  This is in response to complaints that too many
+     zsh features are never noticed by many users.  To turn them off,
+     just put `unsetopt alwayslastprompt listambiguous' in your
+     .zshrc file.
+  o  The editor commands history-search-{forward,backward} are implemented
+     slightly differently, as are {up,down}-line-or-search.  You may
+     well not notice this, however.
+  o  Cursor keys are now usually bound in both vi command and insert
+     mode.  In the latter case, this may result in a slight delay after
+     hitting ESCAPE to exit insert mode.  Purists who object to this can
+     unbind the appropriate key sequences (see zshzle(1)).  Most beginning
+     users of zsh apparently find the current behaviour preferable.
+  o  History file format is incompatible with versions older than 3.0.6,
+     but this should only affect people who try to share history files
+     between the two versions -- 4.0 can read the old format, 3.0.6 and
+     later can read the new format.  Just beware of INC_APPEND_HISTORY,
+     which could conceivably mix the two.
+  o  Default compctl completions have been removed for some builtin
+     commands.  Either use the new compinit-derived system, use the
+     improved compctls from Misc/compctl-examples, or restore these
+     equivalents yourself:
+	 compctl -b bindkey
+	 compctl -v export typeset vared
+	 compctl -o setopt unsetopt
+         compctl -c which
 
 Documentation
 -------------
@@ -59,7 +67,7 @@ Doc/Zsh/*.yo	The master source for the zsh documentation is written in
 		It is not required by zsh but but it is a nice program so
 		you might want to get it anyway, especially if you are a
 		zsh developer.  It can be downloaded from
-		ftp://ftp.icce.rug.nl/pub/unix/yodl*
+		ftp://ftp.lilypond.org/pub/yodl/
 
 Doc/zsh*.1	Man pages in nroff format.  These will be installed
 		by "make install.man" or "make install".  By default,
@@ -84,9 +92,11 @@ Doc/intro.ms	An introduction to zsh in troff format using the ms
 		may not work without changes but it is still a good
 		introduction.
 
+For more information, see the website, as described in the META-FAQ.
+
 If you do not have the necessary tools to process these documents,
 PostScript, ASCII, Info and DVI versions are available in the separate
-file zsh-beta-doc.tar.gz at the archive sites listed in the META-FAQ.
+file zsh-doc.tar.gz at the archive sites listed in the META-FAQ.
 
 The distribution also contains a Perl script in Utils/helpfiles which
 can be used to extract the descriptions of builtin commands from the
@@ -95,7 +105,7 @@ script about its usage.  The files created by this script can be used
 by example function run-help located in the subdirectory Functions/Misc to
 show information about zsh builtins and run `man' on external commands.
 For this the shell variable HELPDIR should point to a directory containing
-the fileles generated by the helpfiles script.  run-help should be
+the files generated by the helpfiles script.  run-help should be
 unaliased before loading the run-help function.  After that this function
 will be executed by the run-help ZLE function which is by default bound
 to ESC-h in emacs mode.
@@ -128,19 +138,19 @@ Zsh Maintenance and Bug Reports
 -------------------------------
 
 Zsh is currently maintained by the members of the zsh-workers mailing list
-and coordinated by Peter Stephenson <pws@zsh.org>.  Please send
-any feedback and bugs reports to <zsh-workers@sunsite.auc.dk>.
+and coordinated by Peter Stephenson <coordinator@zsh.org>.  Please send
+any feedback and bugs reports to <zsh-workers@sunsite.dk>.
 
-There is a script "reporter" in the subdirectory Util which will print
-out your current shell environment/setup.  If you report a bug, please
-use this script and include the output from sourcing this file.  This way,
-the problem you are reporting can be recreated.
-
-You can help even more if you can reproduce the bug starting zsh with
+Reports are most helpful if you can reproduce the bug starting zsh with
 the -f option.  This skips the execution of local startup files except
 /etc/zshenv.  If a bug occurs only when some options set try to locate
 the option which triggers the bug.
 
+There is a script "reporter" in the subdirectory Util which will print out
+your current shell environment/setup.  If you cannot reproduce the bug
+with "zsh -f", use this script and include the output from sourcing this
+file.  This way, the problem you are reporting can be recreated.
+
 The known bugs in zsh are listed in the file Etc/BUGS.  Check this as
 well as the Frequently Asked Questions (FAQ) list before sending a bug
 report.  Note that zsh has some features which are not compatible with
diff --git a/Src/Modules/termcap.c b/Src/Modules/termcap.c
new file mode 100644
index 000000000..8ec8919d9
--- /dev/null
+++ b/Src/Modules/termcap.c
@@ -0,0 +1,430 @@
+/*
+ * termcap.c - termcap manipulation through curses
+ *
+ * This file is part of zsh, the Z shell.
+ *
+ * Copyright (c) 1992-1997 Paul Falstad
+ * All rights reserved.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and to distribute modified versions of this software for any
+ * purpose, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ *
+ * In no event shall Paul Falstad or the Zsh Development Group be liable
+ * to any party for direct, indirect, special, incidental, or consequential
+ * damages arising out of the use of this software and its documentation,
+ * even if Paul Falstad and the Zsh Development Group have been advised of
+ * the possibility of such damage.
+ *
+ * Paul Falstad and the Zsh Development Group specifically disclaim any
+ * warranties, including, but not limited to, the implied warranties of
+ * merchantability and fitness for a particular purpose.  The software
+ * provided hereunder is on an "as is" basis, and Paul Falstad and the
+ * Zsh Development Group have no obligation to provide maintenance,
+ * support, updates, enhancements, or modifications.
+ *
+ */
+
+/*
+ * We need to include the zsh headers later to avoid clashes with
+ * the definitions on some systems, however we need the configuration
+ * file to decide whether we should avoid curses.h, which clashes
+ * with several zsh constants on some systems (e.g. SunOS 4).
+ */
+#include "../../config.h"
+
+#ifdef HAVE_TGETENT
+# if defined(HAVE_CURSES_H) && defined(HAVE_TERM_H)
+#  define USES_TERM_H 1
+# else
+#  ifdef HAVE_TERMCAP_H
+#   define USES_TERMCAP_H 1
+#  endif
+# endif
+#endif
+
+#include "termcap.mdh"
+#include "termcap.pro"
+
+static char termcap_nam[] = "termcap";
+
+#ifdef HAVE_TGETENT
+# ifdef USES_TERM_H
+#  ifdef HAVE_TERMIO_H
+#   include <termio.h>
+#  endif
+#  ifdef TERM_H_NEEDS_CURSES_H
+#   include <curses.h>
+#  endif
+#  include <term.h>
+# else
+#  ifdef USES_TERMCAP_H
+#   include <termcap.h>
+#  endif
+# endif
+
+static Param termcap_pm;
+
+#ifndef HAVE_BOOLCODES
+static char *boolcodes[] = {
+    "bw", "am", "ut", "cc", "xs", "YA", "YF", "YB", "xt", "xn", "eo",
+    "gn", "hc", "HC", "km", "YC", "hs", "hl", "in", "YG", "da", "db",
+    "mi", "ms", "nx", "xb", "NP", "ND", "NR", "os", "5i", "YD", "YE",
+    "es", "hz", "ul", "xo", NULL};
+#endif
+
+/**/
+static int
+ztgetflag(char *s)
+{
+    char **b;
+
+    /* ncurses can tell if an existing boolean capability is *
+     * 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)) {
+    case -1:
+	break;
+    case 0:
+	for (b = (char **)boolcodes; *b; ++b)
+	    if (s[0] == (*b)[0] && s[1] == (*b)[1])
+		return 0;
+	break;
+    default:
+	return 1;
+    }
+    return -1;
+}
+
+/* echotc: output a termcap */
+
+/**/
+static int
+bin_echotc(char *name, char **argv, char *ops, 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;
+    /* if the specified termcap has a numeric value, display it */
+    if ((num = tgetnum(s)) != -1) {
+	printf("%d\n", num);
+	return 0;
+    }
+    /* if the specified termcap is boolean, and set, say so  */
+    switch (ztgetflag(s)) {
+    case -1:
+	break;
+    case 0:
+	puts("no");
+	return 0;
+    default:
+	puts("yes");
+	return 0;
+    }
+    /* get a string-type capability */
+    u = buf;
+    t = tgetstr(s, &u);
+    if (t == (char *)-1 || !t || !*t) {
+	/* capability doesn't exist, or (if boolean) is off */
+	zwarnnam(name, "no such capability: %s", s, 0);
+	return 1;
+    }
+    /* count the number of arguments required */
+    for (argct = 0, u = t; *u; u++)
+	if (*u == '%') {
+	    if (u++, (*u == 'd' || *u == '2' || *u == '3' || *u == '.' ||
+		      *u == '+'))
+		argct++;
+	}
+    /* check that the number of arguments provided is correct */
+    if (arrlen(argv) != argct) {
+	zwarnnam(name, (arrlen(argv) < argct) ? "not enough arguments" :
+		 "too many arguments", NULL, 0);
+	return 1;
+    }
+    /* output string, through the proper termcap functions */
+    if (!argct)
+	tputs(t, 1, putraw);
+    else {
+	num = (argv[1]) ? atoi(argv[1]) : atoi(*argv);
+	tputs(tgoto(t, atoi(*argv), num), num, putraw);
+    }
+    return 0;
+}
+
+#else /* ! HAVE_TGETENT */
+
+#define bin_echotc bin_notavail
+
+#endif /* HAVE_TGETENT */
+
+static struct builtin bintab[] = {
+    BUILTIN("echotc", 0, bin_echotc, 1, -1, 0, NULL, NULL),
+};
+
+/**/
+#ifdef HAVE_TGETENT
+
+/* Empty dummy function for special hash parameters. */
+
+/**/
+static void
+shempty(void)
+{
+}
+
+/* Create a simple special hash parameter. */
+
+/**/
+static Param
+createtchash()
+{
+    Param pm;
+    HashTable ht;
+
+    unsetparam(termcap_nam);
+
+    if (!(pm = createparam(termcap_nam, PM_SPECIAL|PM_HIDE|PM_HIDEVAL|
+			   PM_REMOVABLE|PM_HASHED)))
+	return NULL;
+
+    pm->level = pm->old ? locallevel : 0;
+    pm->gets.hfn = hashgetfn;
+    pm->sets.hfn = hashsetfn;
+    pm->unsetfn = stdunsetfn;
+    pm->u.hash = ht = newhashtable(7, termcap_nam, NULL);
+
+    ht->hash        = hasher;
+    ht->emptytable  = (TableFunc) shempty;
+    ht->filltable   = NULL;
+    ht->addnode     = (AddNodeFunc) shempty;
+    ht->getnode     = ht->getnode2 = gettermcap;
+    ht->removenode  = (RemoveNodeFunc) shempty;
+    ht->disablenode = NULL;
+    ht->enablenode  = NULL;
+    ht->freenode    = (FreeNodeFunc) shempty;
+    ht->printnode   = printparamnode;
+    ht->scantab     = scantermcap;
+
+    return (termcap_pm = pm);
+}
+
+/**/
+static HashNode
+gettermcap(HashTable ht, char *name)
+{
+    int len, num;
+    char *tcstr, buf[2048], *u;
+    Param pm = NULL;
+
+    /* This depends on the termcap stuff in init.c */
+    if (termflags & TERM_BAD)
+	return NULL;
+    if ((termflags & TERM_UNKNOWN) && (isset(INTERACTIVE) || !init_term()))
+	return NULL;
+
+    unmetafy(name, &len);
+
+    pm = (Param) zhalloc(sizeof(struct param));
+    pm->nam = dupstring(name);
+    pm->flags = PM_READONLY;
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+    pm->sets.ifn = NULL;
+    pm->gets.ifn = intgetfn;
+    pm->unsetfn = NULL;
+    pm->ct = 0;
+    pm->env = NULL;
+    pm->ename = NULL;
+    pm->old = NULL;
+    pm->level = 0;
+    u = buf;
+
+    /* logic in the following cascade copied from echotc, above */
+
+    if ((num = tgetnum(name)) != -1) {
+	pm->u.val = num;
+	pm->flags |= PM_INTEGER;
+	return (HashNode) pm;
+    }
+    switch (ztgetflag(name)) {
+    case -1:
+	break;
+    case 0:
+	pm->u.str = dupstring("no");
+	pm->flags |= PM_SCALAR;
+	return (HashNode) pm;
+    default:
+	pm->u.str = dupstring("yes");
+	pm->flags |= PM_SCALAR;
+	return (HashNode) pm;
+    }
+    if ((tcstr = tgetstr(name, &u)) != NULL && tcstr != (char *)-1)
+    {
+	pm->u.str = dupstring(tcstr);
+	pm->flags |= PM_SCALAR;
+    }
+    else
+    {
+	/* zwarn("no such capability: %s", name, 0); */
+	pm->u.str = dupstring("");
+	pm->flags |= PM_UNSET;
+    }
+    return (HashNode) pm;
+}
+
+/**/
+static void
+scantermcap(HashTable ht, ScanFunc func, int flags)
+{
+    Param pm = NULL;
+    int num;
+    char **capcode, *tcstr, buf[2048], *u;
+
+#ifndef HAVE_NUMCODES
+    static char *numcodes[] = {
+	"co", "it", "lh", "lw", "li", "lm", "sg", "ma", "Co", "pa", "MW",
+	"NC", "Nl", "pb", "vt", "ws", "Yo", "Yp", "Ya", "BT", "Yc", "Yb",
+	"Yd", "Ye", "Yf", "Yg", "Yh", "Yi", "Yk", "Yj", "Yl", "Ym", "Yn",
+	NULL};
+#endif
+
+#ifndef HAVE_STRCODES
+    static char *strcodes[] = {
+	"ac", "bt", "bl", "cr", "ZA", "ZB", "ZC", "ZD", "cs", "rP", "ct",
+	"MC", "cl", "cb", "ce", "cd", "ch", "CC", "CW", "cm", "do", "ho",
+	"vi", "le", "CM", "ve", "nd", "ll", "up", "vs", "ZE", "dc", "dl",
+	"DI", "ds", "DK", "hd", "eA", "as", "SA", "mb", "md", "ti", "dm",
+	"mh", "ZF", "ZG", "im", "ZH", "ZI", "ZJ", "ZK", "ZL", "mp", "mr",
+	"mk", "ZM", "so", "ZN", "ZO", "us", "ZP", "SX", "ec", "ae", "RA",
+	"me", "te", "ed", "ZQ", "ei", "ZR", "ZS", "ZT", "ZU", "se", "ZV",
+	"ZW", "ue", "ZX", "RX", "PA", "fh", "vb", "ff", "fs", "WG", "HU",
+	"i1", "is", "i3", "if", "iP", "Ic", "Ip", "ic", "al", "ip", "K1",
+	"K3", "K2", "kb", "@1", "kB", "K4", "K5", "@2", "ka", "kC", "@3",
+	"@4", "@5", "@6", "kt", "kD", "kL", "kd", "kM", "@7", "@8", "kE",
+	"kS", "@9", "k0", "k1", "k;", "F1", "F2", "F3", "F4", "F5", "F6",
+	"F7", "F8", "F9", "k2", "FA", "FB", "FC", "FD", "FE", "FF", "FG",
+	"FH", "FI", "FJ", "k3", "FK", "FL", "FM", "FN", "FO", "FP", "FQ",
+	"FR", "FS", "FT", "k4", "FU", "FV", "FW", "FX", "FY", "FZ", "Fa",
+	"Fb", "Fc", "Fd", "k5", "Fe", "Ff", "Fg", "Fh", "Fi", "Fj", "Fk",
+	"Fl", "Fm", "Fn", "k6", "Fo", "Fp", "Fq", "Fr", "k7", "k8", "k9",
+	"@0", "%1", "kh", "kI", "kA", "kl", "kH", "%2", "%3", "%4", "%5",
+	"kN", "%6", "%7", "kP", "%8", "%9", "%0", "&1", "&2", "&3", "&4",
+	"&5", "kr", "&6", "&9", "&0", "*1", "*2", "*3", "*4", "*5", "*6",
+	"*7", "*8", "*9", "kF", "*0", "#1", "#2", "#3", "#4", "%a", "%b",
+	"%c", "%d", "%e", "%f", "kR", "%g", "%h", "%i", "%j", "!1", "!2",
+	"kT", "!3", "&7", "&8", "ku", "ke", "ks", "l0", "l1", "la", "l2",
+	"l3", "l4", "l5", "l6", "l7", "l8", "l9", "Lf", "LF", "LO", "mo",
+	"mm", "ZY", "ZZ", "Za", "Zb", "Zc", "Zd", "nw", "Ze", "oc", "op",
+	"pc", "DC", "DL", "DO", "Zf", "IC", "SF", "AL", "LE", "Zg", "RI",
+	"Zh", "SR", "UP", "Zi", "pk", "pl", "px", "pn", "ps", "pO", "pf",
+	"po", "PU", "QD", "RC", "rp", "RF", "r1", "r2", "r3", "rf", "rc",
+	"cv", "sc", "sf", "sr", "Zj", "sa", "Sb", "Zk", "Zl", "SC", "sp",
+	"Sf", "ML", "Zm", "MR", "Zn", "st", "Zo", "Zp", "wi", "Zq", "Zr",
+	"Zs", "Zt", "Zu", "Zv", "ta", "Zw", "ts", "TO", "uc", "hu", "u0",
+	"u1", "u2", "u3", "u4", "u5", "u6", "u7", "u8", "u9", "WA", "XF",
+	"XN", "Zx", "S8", "Yv", "Zz", "Xy", "Zy", "ci", "Yw", "Yx", "dv",
+	"S1", "Yy", "S2", "S4", "S3", "S5", "Gm", "Km", "Mi", "S6", "xl",
+	"RQ", "S7", "s0", "s1", "s2", "s3", "AB", "AF", "Yz", "ML", "YZ",
+	"MT", "Xh", "Xl", "Xo", "Xr", "Xt", "Xv", "sA", "sL", NULL};
+#endif
+
+    pm = (Param) zhalloc(sizeof(struct param));
+    pm->sets.cfn = NULL;
+    pm->gets.cfn = strgetfn;
+    pm->sets.ifn = NULL;
+    pm->gets.ifn = intgetfn;
+    pm->unsetfn = NULL;
+    pm->ct = 0;
+    pm->env = NULL;
+    pm->ename = NULL;
+    pm->old = NULL;
+    u = buf;
+
+    pm->flags = PM_READONLY | PM_SCALAR;
+    for (capcode = (char **)boolcodes; *capcode; capcode++) {
+	if ((num = ztgetflag(*capcode)) != -1) {
+	    pm->u.str = num ? dupstring("yes") : dupstring("no");
+	    pm->nam = dupstring(*capcode);
+	    func((HashNode) pm, flags);
+	}
+    }
+
+    pm->flags = PM_READONLY | PM_INTEGER;
+    for (capcode = (char **)numcodes; *capcode; capcode++) {
+	if ((num = tgetnum(*capcode)) != -1) {
+	    pm->u.val = num;
+	    pm->nam = dupstring(*capcode);
+	    func((HashNode) pm, flags);
+	}
+    }
+
+    pm->flags = PM_READONLY | PM_SCALAR;
+    for (capcode = (char **)strcodes; *capcode; capcode++) {
+	if ((tcstr = (char *)tgetstr(*capcode,&u)) != NULL &&
+	    tcstr != (char *)-1) {
+	    pm->u.str = dupstring(tcstr);
+	    pm->nam = dupstring(*capcode);
+	    func((HashNode) pm, flags);
+	}
+    }
+}
+
+/**/
+#endif /* HAVE_TGETENT */
+
+/**/
+int
+setup_(Module m)
+{
+    return 0;
+}
+
+/**/
+int
+boot_(Module m)
+{
+#ifdef HAVE_TGETENT
+# ifdef HAVE_SETUPTERM
+    setupterm((char *)0, 1, (int *)0);
+# endif
+
+    if (!createtchash())
+    	return 1;
+#else
+    unsetparam(termcap_nam);
+#endif
+    return  !addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+}
+
+/**/
+int
+cleanup_(Module m)
+{
+#ifdef HAVE_TGETENT
+    Param pm;
+
+    if ((pm = (Param) paramtab->getnode(paramtab, termcap_nam)) &&
+	pm == termcap_pm) {
+	pm->flags &= ~PM_READONLY;
+	unsetparam_pm(pm, 0, 1);
+    }
+#endif
+    deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+    return 0;
+}
+
+/**/
+int
+finish_(Module m)
+{
+    return 0;
+}
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 4d795c815..9937e8215 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -2399,7 +2399,7 @@ cv_next(Cvdef d, char **sp, char **ap)
         return r;
 
     } else if (d->hassep) {
-        char *ns = strchr(s, d->sep), *as, *sap, sav;
+        char *ns = strchr(s, d->sep), *as = 0, *sap, sav = 0;
         int skip = 0;
 
         if (d->argsep && (as = strchr(s, d->argsep)) && (!ns || as <= ns)) {
@@ -2425,7 +2425,7 @@ cv_next(Cvdef d, char **sp, char **ap)
 
         return r;
     } else {
-        char *as = strchr(s, d->argsep), *sap, sav;
+        char *as = strchr(s, d->argsep), *sap, sav = 0;
 
         *sp = NULL;
 
diff --git a/Src/prompt.c b/Src/prompt.c
index ebd6508cf..47c8af797 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -515,8 +515,8 @@ putpromptchar(int doprint, int endchar)
 		break;
 	    case 'l':
 		if (*ttystrname) {
-                   ss = (strncmp(ttystrname, "/dev/", 5) ?
-                           ttystrname : ttystrname + 5);
+		    ss = (strncmp(ttystrname, "/dev/", 5) ?
+			    ttystrname : ttystrname + 5);
 		    stradd(ss);
 		} else
 		    stradd("()");
diff --git a/Test/C02cond.ztst b/Test/C02cond.ztst
new file mode 100644
index 000000000..fd9f1205b
--- /dev/null
+++ b/Test/C02cond.ztst
@@ -0,0 +1,185 @@
+# Tests corresponding to the texinfo node `Conditional Expressions'
+
+%prep
+
+  umask 077
+
+  mkdir cond.tmp
+
+  cd cond.tmp
+
+  touch	unmodified
+
+  touch zerolength
+  chgrp $EGID zerolength
+  print 'Garbuglio' >nonzerolength
+
+  mkdir modish
+  chgrp $EGID modish
+  chmod g+xs modish
+  chmod u+s modish
+  chmod +t modish
+
+  touch unmodish
+  chmod 000 unmodish
+
+  print 'MZ' > cmd.exe
+  chmod +x cmd.exe
+%test
+
+  [[ -a zerolength && ! -a nonexistent ]]
+0:-a cond
+
+  # Find a block special file system.  This is a little tricky.
+  block=$(find /dev(|ices)/ -type b -print)
+  if [[ -n $block ]]; then
+    [[ -b $block[(f)1] && ! -b zerolength ]]
+  else
+    print -u8 'Warning: Not testing [[ -b blockdevice ]] (no devices found)'
+    [[ ! -b zerolength ]]
+  fi
+0D:-b cond
+
+  # Use hardcoded /dev/tty because globbing inside /dev fails on Cygwin
+  char=/dev/tty
+  [[ -c $char && ! -c $zerolength ]]
+0:-c cond
+
+  [[ -d . && ! -d zerolength ]]
+0:-d cond
+
+  [[ -e zerolength && ! -e nonexistent ]]
+0:-e cond
+
+  [[ -f zerolength && ! -f cond && ! -f $char && ! -f $block && ! -f . ]]
+0:-f cond
+
+  [[ -g modish && ! -g zerolength ]]
+0:-g cond
+
+  ln -s zerolength link
+  [[ -h link && ! -h zerolength ]]
+0:-h cond
+
+  [[ -k modish && ! -k zerolength ]]
+0:-k cond
+
+  foo=foo
+  bar=
+  [[ -n $foo && ! -n $bar && ! -n '' ]]
+0:-n cond
+
+  [[ -o rcs && ! -o norcs && -o noerrexit && ! -o errexit ]]
+0:-o cond
+
+  if ! grep '#define HAVE_FIFOS' $ZTST_testdir/../config.h; then
+    print -u8 'Warning: Not testing [[ -p pipe ]] (FIFOs not supported)'
+    [[ ! -p zerolength ]]
+  else
+    if whence mkfifo && mkfifo pipe || mknod pipe p; then
+      [[ -p pipe && ! -p zerolength ]]
+    else
+      print -u8 'Warning: Not testing [[ -p pipe ]] (cannot create FIFO)'
+      [[ ! -p zerolength ]]
+    fi
+  fi
+0dD:-p cond
+
+  [[ -r zerolength && ! -r unmodish ]]
+0:-r cond
+
+  [[ -s nonzerolength && ! -s zerolength ]]
+0:-s cond
+
+# no simple way of guaranteeing test for -t
+
+  [[ -u modish && ! -u zerolength ]]
+0:-u cond
+
+  [[ -x cmd.exe && ! -x zerolength ]]
+0:-x cond
+
+  [[ -z $bar && -z '' && ! -z $foo ]]
+0:-z cond
+
+  [[ -L link && ! -L zerolength ]]
+0:-L cond
+
+# hard to guarantee a file not owned by current uid
+  [[ -O zerolength ]]
+0:-O cond
+
+  [[ -G zerolength ]]
+0:-G cond
+
+# can't be bothered with -S
+
+  sleep 1
+  cat unmodified
+  touch newnewnew
+  if [[ $OSTYPE == "cygwin" ]]; then
+    print -u8 "Warning: not testing [[ -N file ]] (not supported on Cygwin)"
+    true
+  else
+    [[ -N newnewnew && ! -N unmodified ]]
+  fi
+0:-N cond
+
+  [[ newnewnew -nt zerolength && ! (unmodified -nt zerolength) ]]
+0:-nt cond
+
+  [[ zerolength -ot newnewnew && ! (zerolength -ot unmodified) ]]
+0:-ot cond
+
+  [[ link -ef zerolength && ! (link -ef nonzerolength) ]]
+0:-ef cond
+
+  [[ foo = foo && foo != bar && foo == foo && foo != '' ]]
+0:=, == and != conds
+
+  [[ bar < foo && foo > bar ]]
+0:< and > conds
+
+  [[ $(( 3 + 4 )) -eq 0x07 && $(( 5 * 2 )) -ne 0x10 ]]
+0:-eq and -ne conds
+
+  [[ 3 -lt 04 && 05 -gt 2 ]]
+0:-lt and -gt conds
+
+  [[ 3 -le 3 && ! (4 -le 3) ]]
+0:-le cond
+
+  [[ 3 -ge 3 && ! (3 -ge 4) ]]
+0:-ge cond
+
+  [[ 1 -lt 2 || 2 -lt 2 && 3 -gt 4 ]]
+0:|| and && in conds
+
+  if ! grep '#define PATH_DEV_FD' $ZTST_testdir/../config.h; then
+    print -u8 "Warning: not testing [[ -e /dev/fd/0 ]] (/dev/fd not supported)"
+    true
+  else
+    [[ -e /dev/fd/0 ]]
+  fi
+0dD:/dev/fd support in conds handled by access
+
+  if ! grep '#define PATH_DEV_FD' $ZTST_testdir/../config.h; then
+    print -u8 "Warning: not testing [[ -O /dev/fd/0 ]] (/dev/fd not supported)"
+    true
+  else
+    [[ -O /dev/fd/0 ]]
+  fi
+0dD:/dev/fd support in conds handled by stat
+
+  [[ ( -z foo && -z foo ) || -z foo ]]
+1:complex conds with skipping
+
+  [ '' != bar -a '' = '' ]
+0:strings with `[' builtin
+
+  [ `echo 0` -lt `echo 1` ]
+0:substituion in `[' builtin
+
+%clean
+  # This works around a bug in rm -f in some versions of Cygwin
+  chmod 644 unmodish
diff --git a/Test/comptest b/Test/comptest
index 012ad788c..d65ea351a 100644
--- a/Test/comptest
+++ b/Test/comptest
@@ -1,54 +1,54 @@
-#!/usr/local/bin/zsh -f
+comptestinit () {
+  setopt extendedglob
+  [[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
+  fpath=( $ZTST_srcdir/../Functions/*~*/CVS(/)
+          $ZTST_srcdir/../Completion
+          $ZTST_srcdir/../Completion/*/*~*/CVS(/) )
 
-[[ -d $ZTST_testdir/Modules/zsh ]] && module_path=( $ZTST_testdir/Modules )
+  zmodload -i zsh/zpty
 
-zmodload -i zsh/zpty
-setopt extendedglob
+  comptest_zsh=${ZSH:-zsh}
 
-fpath=( $ZTST_srcdir/../(Completion|Functions)/*~*/CVS(/) )
-
-debug=
-dump=(-D)
-code=
-zsh=${ZSH:-zsh}
-termcap_ce="$(echotc ce)"
-
-while getopts Dd:c:z: opt; do
-  case $opt in
-    D) debug=yes;;
-    d) dump=(-d "$OPTARG");;
-    c) code="$OPTARG";;
-    z) zsh="$OPTARG";;
-  esac
-done
-(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
+  while getopts z: opt; do
+    case $opt in
+      z) comptest_zsh="$OPTARG";;
+    esac
+  done
+  (( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
 
-input="$*"
+  export PS1="<PROMPT>"
+  zpty zsh "$comptest_zsh -f +Z"
 
-tmp=/tmp/comptest.$$
+  zpty -r zsh log1 "*<PROMPT>*" || { 
+    print "first prompt hasn't appeared."
+    return 1
+  }
 
-cat <<End >$tmp
-module_path=( $module_path )
-fpath=( $fpath )
+  comptesteval \
+"export ZDOTDIR=$ZTST_testdir" \
+"module_path=( $module_path )" \
+"fpath=( $fpath )" \
+'LISTMAX=10000000
+TERM=vt100
 stty columns 80 rows 24
-LISTMAX=10000000
-ZLS_COLORS='no=<NO>:fi=<FI>:di=<DI>:ln=<LN>:pi=<PI>:so=<SO>:bd=<BD>:cd=<CD>:ex=<EX>:mi=<MI>:tc=<TC>:sp=<SP>:lc=<LC>:ec=<EC>\n:rc=<RC>'
+setopt zle
 bindkey -e
 autoload -U compinit
-compinit $dump
+compinit -u
+zstyle ":completion:*:default" list-colors "no=<NO>" "fi=<FI>" "di=<DI>" "ln=<LN>" "pi=<PI>" "so=<SO>" "bd=<BD>" "cd=<CD>" "ex=<EX>" "mi=<MI>" "tc=<TC>" "sp=<SP>" "lc=<LC>" "ec=<EC>\n" "rc=<RC>"
 zstyle ":completion:*" group-name ""
-zstyle ":completion*:messages" format "<MESSAGE>%d</MESSAGE>
+zstyle ":completion:*:messages" format "<MESSAGE>%d</MESSAGE>
 "
-zstyle ":completion*:descriptions" format "<DESCRIPTION>%d</DESCRIPTION>
+zstyle ":completion:*:descriptions" format "<DESCRIPTION>%d</DESCRIPTION>
 "
-zstyle ":completion*:options" verbose yes
-zstyle ":completion*:values" verbose yes
+zstyle ":completion:*:options" verbose yes
+zstyle ":completion:*:values" verbose yes
 setopt noalwayslastprompt listrowsfirst completeinword
 zmodload zsh/complist
 expand-or-complete-with-report () {
   print -lr "<WIDGET><expand-or-complete>"
   zle expand-or-complete
-  print -lr - "<LBUFFER>\$LBUFFER</LBUFFER>" "<RBUFFER>\$RBUFFER</RBUFFER>"
+  print -lr - "<LBUFFER>$LBUFFER</LBUFFER>" "<RBUFFER>$RBUFFER</RBUFFER>"
   zle clear-screen
   zle -R
 }
@@ -60,8 +60,9 @@ list-choices-with-report () {
 }
 finish () {
   print "<WIDGET><finish>"
-  sleep 1
-  exit 0
+  zle kill-whole-line
+  zle clear-screen
+  zle -R
 }
 zle -N expand-or-complete-with-report
 zle -N list-choices-with-report
@@ -69,51 +70,51 @@ zle -N finish
 bindkey "^I" expand-or-complete-with-report
 bindkey "^D" list-choices-with-report
 bindkey "^Z" finish
-$code
-End
-
-export PS1="<PROMPT>"
-zpty zsh "$zsh" -f
-
-zpty -r zsh log1 "*<PROMPT>*" || { 
-  print first prompt doesn\'t appered.
-  exit 1
+'
 }
 
-zpty -w zsh ". $tmp"
-zpty -r zsh log2 "*<PROMPT>*" || {
-  print second prompt doesn\'t appered.
-  exit 1
-}
-rm $tmp
+comptesteval () {
+  local tmp=/tmp/comptest.$$
 
-zpty -n -w zsh "$input"$'\C-Z'
-zpty -r zsh log "*<WIDGET><finish>*" || {
-  print finish widget doesn\'t invoked.
-  exit 1
+  print -lr - "$@" > $tmp
+  zpty -w zsh ". $tmp"
+  zpty -r zsh log_eval "*<PROMPT>*" || {
+    print "prompt hasn't appeared."
+    return 1
+  }
+  rm $tmp
 }
 
-if [[ -n "$debug" ]]; then
-  print -lr - "$log" > /tmp/comptest.debug
-fi
+comptest () {
+  input="$*"
+  zpty -n -w zsh "$input"$'\C-Z'
+  zpty -r zsh log "*<WIDGET><finish>*<PROMPT>*" || {
+    print "failed to invoke finish widget."
+    return 1
+  }
 
-logs=(${(s:<WIDGET>:)log})
-shift logs
+  logs=(${(s:<WIDGET>:)log})
+  shift logs
 
-for log in "$logs[@]"; do
-  if [[ "$log" = (#b)*$'<LBUFFER>'(*)$'</LBUFFER>\r\n<RBUFFER>'(*)$'</RBUFFER>'* ]]; then
-    print -lr "line: {$match[1]}{$match[2]}"
-  fi
-  while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>)} )); do
-    log="${log[$mend[1]+1,-1]}"
-    if (( 0 <= $mbegin[2] )); then
-      if [[ $match[2] != TC && $match[3] != \ # ]]; then
-	print -lr "$match[2]:{${match[3]%$termcap_ce}}"
-      fi
-    elif (( 0 <= $mbegin[4] )); then
-      print -lr "DESCRIPTION:{$match[4]}"
-    elif (( 0 <= $mbegin[5] )); then
-      print -lr "MESSAGE:{$match[5]}"
+  for log in "$logs[@]"; do
+    if [[ "$log" = (#b)*$'<LBUFFER>'(*)$'</LBUFFER>\r\n<RBUFFER>'(*)$'</RBUFFER>'* ]]; then
+      print -lr "line: {$match[1]}{$match[2]}"
     fi
+    while (( ${(N)log#*(#b)(<LC><(??)><RC>(*)<EC>|<DESCRIPTION>(*)</DESCRIPTION>|<MESSAGE>(*)</MESSAGE>|<COMPADD>(*)</COMPADD>|<INSERT_POSITIONS>(*)</INSERT_POSITIONS>)} )); do
+      log="${log[$mend[1]+1,-1]}"
+      if (( 0 <= $mbegin[2] )); then
+	if [[ $match[2] != TC && $match[3] != \ # ]]; then
+	  print -lr "$match[2]:{${match[3]%${(%):-%E}}}"
+	fi
+      elif (( 0 <= $mbegin[4] )); then
+	print -lr "DESCRIPTION:{$match[4]}"
+      elif (( 0 <= $mbegin[5] )); then
+	print -lr "MESSAGE:{$match[5]}"
+      elif (( 0 <= $mbegin[6] )); then
+        print -lr "COMPADD:{${${match[6]}//[$'\r\n']/}}"
+      elif (( 0 <= $mbegin[7] )); then
+        print -lr "INSERT_POSITIONS:{${${match[7]}//[$'\r\n']/}}"
+      fi
+    done
   done
-done
+}
diff --git a/zshconfig.ac b/zshconfig.ac
index c3befe031..0f6250cd8 100644
--- a/zshconfig.ac
+++ b/zshconfig.ac
@@ -1377,10 +1377,9 @@ zsh_cv_sys_killesrch,
 #include <errno.h>
 main()
 {
-    int pid, ret;
-    pid=getpid() + 10000;
-    ret=kill(pid, 0);
-    exit(ret<0 && errno!=ESRCH);
+    int pid = (getpid() + 10000) & 0xffffff;
+    while (pid && (kill(pid, 0) == 0 || errno != ESRCH)) pid >>= 1;
+    exit(errno!=ESRCH);
 }
 ],
   zsh_cv_sys_killesrch=yes,
@@ -1608,7 +1607,7 @@ char *argv[];
     DLLDARG=""
   fi
   if test -n "$GCC"; then
-    DLCFLAGS="${DLCFLAGS=-fpic}"
+    DLCFLAGS="${DLCFLAGS=-fPIC}"
   else
     case "$host_os" in
       hpux*)                 DLCFLAGS="${DLCFLAGS=+z}" ;;