Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Z-Shell (zsh) FAQ changes this month



This file contains general information on how to find out about zsh,
(the first part of the FAQ up to item 1.1), then any other items which
have changed since last month's posting, then the differences in the
text version of the FAQ.  If you would like a complete individual
copy, email me and I will add you to the list.


Changes since issue posted December 1998:

2.1  Finally point out function definitions are not local to
     functions (they never were).
5.2  Mailing list location has changed.

This document contains a list of frequently-asked (or otherwise
significant) questions concerning the Z-shell, a command interpreter
for many UNIX systems which is freely available to anyone with FTP
access.  Zsh is among the most powerful freely available Bourne-like
shell for interactive use.

If you have never heard of `sh', `csh' or `ksh', then you are
probably better off to start by reading a general introduction to UNIX
rather than this document.

If you just want to know how to get your hands on the latest version,
skip to question 1.6; if you want to know what to do with
insoluble problems, go to 5.2.

Notation: Quotes `like this' are ordinary textual quotation
marks.  Other uses of quotation marks are input to the shell.

Contents:
Chapter 1:  Introducing zsh and how to install it
1.1. Sources of information
1.2. What is it?
1.3. What is it good at?
1.4. On what machines will it run?  (Plus important compilation notes)
1.5. What's the latest version?
1.6. Where do I get it?
1.7. I don't have root access: how do I make zsh my login shell?

Chapter 2:  How does zsh differ from...?
2.1. sh and ksh?
2.2. csh?
2.3. Why do my csh aliases not work?  (Plus other alias pitfalls.)
2.4. tcsh?
2.5. bash?
2.6. Shouldn't zsh be more/less like ksh/(t)csh?

Chapter 3:  How to get various things to work
3.1. Why does `$var' where `var="foo bar"' not do what I expect?
3.2. What is the difference between `export' and the ALL_EXPORT option?
3.3. How do I turn off spelling correction/globbing for a single command?
3.4. How do I get the meta key to work on my xterm?
3.5. How do I automatically display the directory in my xterm title bar?
3.6. How do I make the completion list use eight bit characters?
3.7. Why do the cursor (arrow) keys not work?
3.8. Why does my terminal act funny in some way?
3.9. Why does zsh not work in an Emacs shell mode any more?
3.10. Why do my autoloaded functions not autoload [the first time]?
3.11. How does base arithmetic work?
3.12. How do I get a newline in my prompt?
3.13. Why does `bindkey ^a command-name' or 'stty intr ^-' do something funny?
3.14. Why can't I bind \C-s and \C-q any more?
3.15. How do I execute command `foo' within function `foo'?
3.16. Why do history substitutions with single bangs do something funny?
3.17. Why does zsh kill off all my background jobs when I logout?
3.18. How do I list all my history entries?
3.19. How does the alternative loop syntax, e.g. `while {...} {...}' work?
3.20. Why is my history not being saved?

Chapter 4:  The mysteries of completion
4.1. What is completion?
4.2. What sorts of things can be completed?
4.3. How does zsh deal with ambiguous completions?
4.4. How do I complete in the middle of words / just what's before the cursor?
4.5. How do I get started with programmable completion?
4.6. And if programmable completion isn't good enough?

Chapter 5:  The future of zsh
5.1. What bugs are currently known and unfixed? (Plus recent important changes)
5.2. Where do I report bugs, get more info / who's working on zsh?
5.3. What's on the wish-list?
5.4. Will zsh have problems in the year 2000?

Acknowledgments

Copyright
--- End of Contents ---

Chapter 1: Introducing zsh and how to install it

1.1: Sources of information

  Information on zsh is available via the World Wide Web.  The URL
  is http://sunsite.auc.dk/zsh/ (note the change of address from the
  end of April 1998).  The server provides this FAQ and much else and is
  now maintained by Karsten Thygesen and others (mail zsh@xxxxxxxxxxxxxx
  with any related messages).  The FAQ is at http://sunsite.auc.dk/zsh/FAQ/ .
  The site also contains some contributed zsh scripts and functions;
  we are delighted to add more, or simply links to your own collection.

  This document was originally written in YODL, allowing it to be
  converted easily into various other formats.  The master source
  file lives at http://sunsite.auc.dk/zsh/FAQ/zshfaq.yo .

  Another useful source of information is the collection of FAQ articles
  posted frequently to the Usenet news groups comp.unix.questions,
  comp.unix.shells and comp.answers with answers to general questions
  about UNIX.  The fifth of the seven articles deals with shells,
  including zsh, with a brief description of differences.  (This article
  also talks about shell startup files which would otherwise rate a
  mention here.)  There is also a separate FAQ on shell differences
  and how to change your shell.  Usenet FAQs are available via FTP
  from rtfm.mit.edu and mirrors and also on the World Wide Web; see

    USA         http://www.cis.ohio-state.edu/hypertext/faq/usenet/top.html
    UK          http://www.lib.ox.ac.uk/internet/news/faq/comp.unix.shell.html
    Netherlands http://www.cs.uu.nl/wais/html/na-dir/unix-faq/shell/.html

  You can also get it via email by emailing mail-server@xxxxxxxxxxxx
  with, in the body of the message, `send faqs/unix-faq/shell/zsh'.

  The latest version of this FAQ is also available directly from any
  of the zsh archive sites listed in question 1.6.

  There is now a preliminary version of a reference card for
  zsh 3.0, which you can find (while it's being developed) at
    http://www.ifh.de/~pws/computing/refcard.ps
  This is optimised for A4 paper. The LaTeX source is in the
  same place with the extension .tex.  It is not a good place
  from which to learn zsh for the first time.

  (As a method of reading the following in Emacs, you can type \M-2
  \C-x $ to make all the indented text vanish, then \M-0 \C-x $
  when you are on the title you want.)

  For any more eclectic information, you should contact the mailing
  list:  see question 5.2.

--- End of general information, changed items follow in full ---

2.1: Differences from sh and ksh

  Most features of ksh (and hence also of sh) are implemented in zsh;
  problems can arise because the implementation is slightly different.
  Note also that not all ksh's are the same either.  I have based this
  on the 11/16/88f version of ksh; differences from ksh93 will be more
  substantial.

  As a summary of the status:

  1) because of all the options it is not safe to assume a general
     zsh run by a user will behave as if sh or ksh compatible;
  2) invoking zsh as sh or ksh (or if either is a symbolic link to
     zsh) sets appropriate options and improves compatibility (from
     within zsh itself, calling `ARGV0=sh zsh' will also work);
  3) from version 3.0 onward the degree of compatibility with sh
     under these circumstances is very high:  zsh can now be used
     with GNU configure or perl's Configure, for example;
  4) the degree of compatibility with ksh is also high, but a few
     things are missing:  for example the more sophisticated
     pattern-matching expressions are different for versions before
     3.1.3 --- see the detailed list below;
  5) also from 3.0, the command `emulate' is available: `emulate
     ksh' and `emulate sh' set various options as well as changing the
     effect of single-letter option flags as if the shell had been
     invoked with the appropriate name.  Including the commands
     `emulate sh; setopt localoptions' in a shell function will
     turn on sh emulation for that function only.

  The classic difference is word splitting, discussed in 3.1; this
  catches out very many beginning zsh users.  As explained there, this
  is actually a bug in every other shell.  The answer is to set
  SH_WORD_SPLIT for backward compatibility.  The next most classic
  difference is that unmatched glob patterns cause the command to
  abort; set NO_NOMATCH for those.

  Here is a list of various options which will increase ksh
  compatibility, though maybe decrease zsh's abilities: see the manual
  entries for GLOB_SUBST, IGNORE_BRACES (though brace expansion occurs
  in some versions of ksh), KSH_ARRAYS, KSH_GLOB, KSH_OPTION_PRINT,
  LOCAL_OPTIONS, NO_BAD_PATTERN, NO_BANG_HIST, NO_EQUALS, NO_HUP,
  NO_NOMATCH, NO_RCS, NO_SHORT_LOOPS, PROMPT_SUBST, RM_STAR_SILENT,
  POSIX_BUILTINS, SH_FILE_EXPANSION, SH_GLOB, SH_OPTION_LETTERS,
  SH_WORD_SPLIT (see question 3.1) and SINGLE_LINE_ZLE.
  Note that you can also disable any built-in commands which get in
  your way.  If invoked as `ksh', the shell will try and set suitable
  options.

  Here are some differences from ksh which might prove significant for
  ksh programmers, some of which may be interpreted as bugs; there
  must be more.  Note that this list is deliberately rather full and
  that most of the items are fairly minor.  Those marked `*' perform
  in a ksh-like manner if the shell is invoked with the name `ksh', or
  if `emulate ksh' is in effect.  Capitalised words with underlines
  refer to shell options. 

  o  Syntax:

    o * Shell word splitting: see question 3.1.
    o * Arrays are (by default) more csh-like than ksh-like:
        subscripts start at 1, not 0; array[0] refers to array[1];
        `$array' refers to the whole array, not $array[0];
        braces are unnecessary: $a[1] == ${a[1]}, etc.
        The KSH_ARRAYS option is now available.
    o   Coprocesses are established by `coproc'; `|&' behaves like
        csh.  Handling of coprocess file descriptors is also different.
    o   In `cmd1 && cmd2 &', only `cmd2' instead of the whole
        expression is run in the background in zsh.  The manual implies
        this is a bug.  Use `{ cmd1 && cmd2 } &' as a workaround.

  o  Command line substitutions, globbing etc.:

    o * Failure to match a globbing pattern causes an error (use
        NO_NOMATCH).
    o * The results of parameter substitutions are treated as plain text:
        `foo="*"; print $foo' prints all files in ksh but `*' in zsh.
        (GLOB_SUBST has been added to fix this.)
    o   The backslash in $(echo '\$x') is treated differently:  in ksh, it
        is not stripped, in zsh it is.  (The `...` form gives the same in
        both shells.)
    o * $PSn do not do parameter substitution by default (use PROMPT_SUBST).
    o * Standard globbing does not allow ksh-style `pattern-lists'.
        Equivalents:

----------------------------------------------------------------------
      ksh             zsh          Meaning
      -----           -----        ---------
     !(foo)            ^foo        Anything but foo.
                or   foo1~foo2     Anything matching foo1 but foo2[1].
@(foo1|foo2|...)  (foo1|foo2|...)  One of foo1 or foo2 or ...
     ?(foo)           (foo|)       Zero or one occurrences of foo.
     *(foo)           (foo)#       Zero or more occurrences of foo.
     +(foo)           (foo)##      One or more occurrences of foo.
----------------------------------------------------------------------

      The `^', `~' and `#' (but not `|')forms require EXTENDED_GLOB.
      From version 3.1.3, the ksh forms are fully supported when the
      option KSH_GLOB is in effect; for previous versions you
      must use the table above.

      [1] Note that `~' is the only globbing operator to have a lower
        precedence than `/'.  For example, `**/foo~*bar*' matches any
        file in a subdirectory called `foo', except where `bar'
        occurred somewhere in the path (e.g. `users/barstaff/foo' will
        be excluded by the `~' operator).  As the `**' operator cannot
        be grouped (inside parentheses it is treated as `*'), this is
        the way to exclude some subdirectories from matching a `**'.
    o   Unquoted assignments do file expansion after `:'s (intended for
        PATHs). 
    o   `integer' does not allow `-i'.
    o   `typeset' and `integer' have special behaviour for
        assignments in ksh, but not in zsh.  For example, this doesn't
        work in zsh:

          integer k=$(wc -l ~/.zshrc)

        because the return value from wc includes leading
        whitespace which causes wordsplitting.  Ksh handles the
        assignment specially as a single word.

  o  Command execution:

    o * There is no $ENV variable (use /etc/zshrc, ~/.zshrc; 
        note also $ZDOTDIR).
    o   $PATH is not searched for commands specified
        at invocation without -c.

  o  Aliases and functions:

    o   The order in which aliases and functions are defined is significant:
        function definitions with () expand aliases -- see question 2.3.
    o   Aliases and functions cannot be exported.
    o   There are no tracked aliases: command hashing replaces these.
    o   The use of aliases for key bindings is replaced by `bindkey'.
    o * Options are not local to functions (use LOCAL_OPTIONS; note this
        may always be unset locally to propagate options settings from a
        function to the calling level).
    o   Function definitions themselves are not local to functions.

    o  Traps and signals:

    o   Traps are not local to functions.
    o   TRAPERR has become TRAPZERR (this was forced by UNICOS which
        has SIGERR).

  o  Editing:

    o   The options emacs, gmacs, viraw are not supported.
        Use bindkey to change the editing behaviour: `set -o {emacs,vi}'
        becomes `bindkey -{e,v}'; for gmacs, go to emacs mode and use
        `bindkey \^t gosmacs-transpose-characters'.
    o   The `keyword' option does not exist and `-k' is instead
        interactivecomments.  (`keyword' will not be in the next ksh
        release either.)
    o   Management of histories in multiple shells is different:
        the history list is not saved and restored after each command.
    o   `\' does not escape editing chars (use `^V').
    o   Not all ksh bindings are set (e.g. `<ESC>#'; try `<ESC>q').
    o * `#' in an interactive shell is not treated as a comment by
        default. 

  o  Built-in commands:

    o   Some built-ins (r, autoload, history, integer ...)
        were aliases in ksh. 
    o   There is no built-in command newgrp: use e.g. `alias
        newgrp="exec newgrp"'
    o   `jobs' has no `-n' flag.
    o   `read' has no `-s' flag.

  o  Other idiosyncrasies:

    o   `select' always redisplays the list of selections on each loop.


5.2: Where do I report bugs, get more info / who's working on zsh?

  The shell is being maintained by various (entirely self-appointed)
  subscribers to the mailing list,

    zsh-workers@xxxxxxxxxxxxxx

  so mail on any issues (bug reports, suggestions, complaints...)
  related to the development of the shell should be sent there.  If
  you want someone to mail you directly, say so.  Most patches to zsh
  appear there first.

  Note that this location has just changed (January 1999), and the
  instructions to go with it are slightly different --- in particular,
  if you are already subscribed, the instructions about how to
  unsubscribe are different.

  Please note when reporting bugs that many exist only on certain
  architectures, which the developers may not have access to.  In
  this case debugging information, as detailed as possible, is
  particularly welcome.

  Two progressively lower volume lists exist, one with messages
  concerning the use of zsh,

    zsh-users@xxxxxxxxxxxxxx

  and one just containing announcements:  about releases, about major
  changes in the shell, or this FAQ, for example,

    zsh-announce@xxxxxxxxxxxxxx

  (posting to the last one is currently restricted).

  Note that you should only join one of these lists:  people on
  zsh-workers receive all the lists, and people on zsh-users will
  also receive the announcements list.

  The lists are handled by an automated server.  The instructions for
  zsh-announce and zsh-users are the same as for zsh-workers: just
  change zsh-workers to whatever in the following.

  To join zsh-workers, send email to

    zsh-workers-subscribe@xxxxxxxxxxxxxx

  (the actual content is unimportant).  Replace subscribe with
  unsubscribe to unsubscribe.  The mailing software (ezlm) has
  various bells and whistles: you can retrieve archived messages.
  Mail zsh-workers-help@xxxxxxxxxxxxxx for detailed information.
  Adminstrative matters are best sent to
  zsh-workers-owner@xxxxxxxxxxxxxx.  The list maintainer's
  real name is Karsten Thygesen <karthy@xxxxxxxxxx>.

  The list from May 1992 to May 1995 is archived in
    ftp://ftp.sterling.com/zsh/zsh-list/YY-MM
  where YY-MM are the year and month in digits.  More recent
  mailings up to date are to be found at
    http://www.zsh.org/mla/
  at the main zsh archive in Australia.

  Of course, you can also post zsh queries to the Usenet group
  comp.unix.shell; if all else fails, you could even e-mail me.

--- End of changed items, diff from previous version follows ---
Index: zshfaq.txt
===================================================================
RCS file: /pack/anoncvs/zsh/www/FAQ/zshfaq.txt,v
retrieving revision 1.8
retrieving revision 1.9
diff -c -r1.8 -r1.9
*** zshfaq.txt	1998/12/19 13:44:46	1.8
--- zshfaq.txt	1999/01/25 09:27:49	1.9
***************
*** 1,16 ****
  
  Archive-Name: unix-faq/shell/zsh
! Last-Modified: 1998/11/19
  Submitted-By: pws@xxxxxxxxxxxxxxxxx (Peter Stephenson)
! Version: $Id: zshfaq.txt,v 1.8 1998/12/19 13:44:46 pws Exp $
  Posting-Frequency: Monthly
! Copyright: (C) P.W. Stephenson, 1995, 1996, 1997, 1998 (see end of document)
  
! Changes since issue posted November 1998:
  
! 1.1  Mention email FAQ server
! 2.3  Restore missing double quote in cd() function
! 3.1  Mention ${==*} to turn off SHWORDSPLIT
  
  This document contains a list of frequently-asked (or otherwise
  significant) questions concerning the Z-shell, a command interpreter
--- 1,16 ----
  
  Archive-Name: unix-faq/shell/zsh
! Last-Modified: 1999/01/25
  Submitted-By: pws@xxxxxxxxxxxxxxxxx (Peter Stephenson)
! Version: $Id: zshfaq.txt,v 1.9 1999/01/25 09:27:49 pws Exp $
  Posting-Frequency: Monthly
! Copyright: (C) P.W. Stephenson, 1995, 1996, 1997, 1998, 1999 (see end of document)
  
! Changes since issue posted December 1998:
  
! 2.1  Finally point out function definitions are not local to
!      functions (they never were).
! 5.2  Mailing list location has changed.
  
  This document contains a list of frequently-asked (or otherwise
  significant) questions concerning the Z-shell, a command interpreter
***************
*** 511,516 ****
--- 511,517 ----
      o * Options are not local to functions (use LOCAL_OPTIONS; note this
          may always be unset locally to propagate options settings from a
          function to the calling level).
+     o   Function definitions themselves are not local to functions.
  
      o  Traps and signals:
  
***************
*** 1697,1709 ****
    The shell is being maintained by various (entirely self-appointed)
    subscribers to the mailing list,
  
!     zsh-workers@xxxxxxxxxxxxxxx
  
    so mail on any issues (bug reports, suggestions, complaints...)
    related to the development of the shell should be sent there.  If
    you want someone to mail you directly, say so.  Most patches to zsh
    appear there first.
  
    Please note when reporting bugs that many exist only on certain
    architectures, which the developers may not have access to.  In
    this case debugging information, as detailed as possible, is
--- 1698,1715 ----
    The shell is being maintained by various (entirely self-appointed)
    subscribers to the mailing list,
  
!     zsh-workers@xxxxxxxxxxxxxx
  
    so mail on any issues (bug reports, suggestions, complaints...)
    related to the development of the shell should be sent there.  If
    you want someone to mail you directly, say so.  Most patches to zsh
    appear there first.
  
+   Note that this location has just changed (January 1999), and the
+   instructions to go with it are slightly different --- in particular,
+   if you are already subscribed, the instructions about how to
+   unsubscribe are different.
+ 
    Please note when reporting bugs that many exist only on certain
    architectures, which the developers may not have access to.  In
    this case debugging information, as detailed as possible, is
***************
*** 1712,1723 ****
    Two progressively lower volume lists exist, one with messages
    concerning the use of zsh,
  
!     zsh-users@xxxxxxxxxxxxxxx
  
    and one just containing announcements:  about releases, about major
    changes in the shell, or this FAQ, for example,
  
!     zsh-announce@xxxxxxxxxxxxxxx
  
    (posting to the last one is currently restricted).
  
--- 1718,1729 ----
    Two progressively lower volume lists exist, one with messages
    concerning the use of zsh,
  
!     zsh-users@xxxxxxxxxxxxxx
  
    and one just containing announcements:  about releases, about major
    changes in the shell, or this FAQ, for example,
  
!     zsh-announce@xxxxxxxxxxxxxx
  
    (posting to the last one is currently restricted).
  
***************
*** 1730,1749 ****
    change zsh-workers to whatever in the following.
  
    To join zsh-workers, send email to
- 
-     zsh-workers-request@xxxxxxxxxxxxxxx
- 
-   with the *subject* line (this is a change from the old list)
- 
-     subscribe <your-email-address>
- 
-   e.g.
  
!     Subject:  subscribe P.Stephenson@xxxxxxxxxxxxx
  
!   and you can unsubscribe in the same way.
!   The list maintainer, Richard Coleman, can be reached at
!   coleman@xxxxxxxxxxxxxxx.
  
    The list from May 1992 to May 1995 is archived in
      ftp://ftp.sterling.com/zsh/zsh-list/YY-MM
--- 1736,1751 ----
    change zsh-workers to whatever in the following.
  
    To join zsh-workers, send email to
  
!     zsh-workers-subscribe@xxxxxxxxxxxxxx
  
!   (the actual content is unimportant).  Replace subscribe with
!   unsubscribe to unsubscribe.  The mailing software (ezlm) has
!   various bells and whistles: you can retrieve archived messages.
!   Mail zsh-workers-help@xxxxxxxxxxxxxx for detailed information.
!   Adminstrative matters are best sent to
!   zsh-workers-owner@xxxxxxxxxxxxxx.  The list maintainer's
!   real name is Karsten Thygesen <karthy@xxxxxxxxxx>.
  
    The list from May 1992 to May 1995 is archived in
      ftp://ftp.sterling.com/zsh/zsh-list/YY-MM
***************
*** 1808,1823 ****
  Thanks to zsh-list, in particular Bart Schaefer, for suggestions
  regarding this document.  Zsh has been in the hands of archivists Jim
  Mattson, Bas de Bakker, Richard Coleman, Zoltan Hidvegi and Andrew
! Main, and the mailing list has been run by Peter Gray, Rick Ohnemus
! and Richard Coleman, all of whom deserve thanks.  The world is
! eternally in the debt of Paul Falstad for inventing zsh in the first
! place (though the wizzo extended completion is by Sven Wischnowsky).
  
  Copyright Information:
  
  This document is copyright (C) P.W. Stephenson, 1995, 1996, 1997,
! 1998. This text originates in the U.K. and the author asserts his
! moral rights under the Copyrights, Designs and Patents Act, 1988.
  
  Permission is hereby granted, without written agreement and without
  license or royalty fees, to use, copy, modify, and distribute this
--- 1810,1826 ----
  Thanks to zsh-list, in particular Bart Schaefer, for suggestions
  regarding this document.  Zsh has been in the hands of archivists Jim
  Mattson, Bas de Bakker, Richard Coleman, Zoltan Hidvegi and Andrew
! Main, and the mailing list has been run by Peter Gray, Rick Ohnemus,
! Richard Coleman and Karsten Thygesen, all of whom deserve thanks.  The
! world is eternally in the debt of Paul Falstad for inventing zsh in
! the first place (though the wizzo extended completion is by Sven
! Wischnowsky).
  
  Copyright Information:
  
  This document is copyright (C) P.W. Stephenson, 1995, 1996, 1997,
! 1998, 1999. This text originates in the U.K. and the author asserts
! his moral rights under the Copyrights, Designs and Patents Act, 1988.
  
  Permission is hereby granted, without written agreement and without
  license or royalty fees, to use, copy, modify, and distribute this

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author