home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / ap / zsh / zsh-2.4 / zsh-2 / zsh-2.4.306 / FAQ < prev    next >
Text File  |  1994-01-30  |  36KB  |  777 lines

  1. Archive-Name: unix-faq/shell/zsh
  2. Last-Modified: 1994/1/25
  3. Submitted-By: pws@s-a.amtp.liv.ac.uk (Peter Stephenson)
  4. Version: $Id: zsh.FAQ,v 1.21 1994/01/25 11:10:29 pws Exp pws $
  5. Frequency: Monthly
  6.  
  7. This document contains a list of frequently-asked (or otherwise
  8. significant) questions concerning the Z-shell, a command interpreter for
  9. many UNIX systems which is freely available to anyone with FTP access.
  10. Zsh is more powerful than every other common shell (sh, ksh, csh, tcsh
  11. and bash) put together.
  12.  
  13. If you have never heard of `sh', `csh' or `ksh', then you are probably
  14. better off to start by reading a general introduction to UNIX rather
  15. than this document.
  16.  
  17. Another useful source of information is the collection of FAQ articles
  18. posted frequently to the Usenet news groups comp.unix.questions,
  19. comp.unix.shells and comp.answers with answers to general questions
  20. about UNIX.  The fifth of the seven articles deals with shells,
  21. including zsh, with a brief description of differences.  (This article
  22. also talks about shell startup files which would otherwise rate a
  23. mention here.)
  24.  
  25. If you just want to know how to get your hands on the latest version,
  26. skip to question 4); if you want to know what to do with insoluble
  27. problems, go to 21).
  28.  
  29. To encourage you to read on, if you don't know about zsh but are
  30. familiar with other UNIX shells, here are some things that zsh is
  31. particularly good at.  No claim of exclusivity is made, especially as
  32. shells copy one another, though in the areas of command line editing and
  33. globbing zsh is well ahead of the competition.  I am not aware of a
  34. major feature in any other freely-available shell which zsh does not
  35. also have.
  36.   Command line editing:
  37.     programmable completion: incorporates the ability to use
  38.       the full power of zsh globbing (compctl -g),
  39.     multi-line commands editable as a single buffer (even files!),
  40.     variable editing (vared),
  41.     command buffer stack,
  42.     print text straight into the buffer for immediate editing (print -z),
  43.     execution of unbound commands,
  44.     menu completion,
  45.     variable, editing function and option name completion,
  46.     inline expansion of variables, history commands.
  47.   Globbing --- extremely powerful, including:
  48.     recursive globbing (cf. find),
  49.     file attribute qualifiers (size, type, etc. also cf. find),
  50.     full alternation and negation of patterns.
  51.   Handling of multiple redirections (simpler than tee).
  52.   Large number of options for tailoring.
  53.   Path expansion (=foo -> /usr/bin/foo).
  54.   Adaptable messages for spelling, watch, time as well as prompt
  55.     (now including conditional expressions).
  56.   Named directories.
  57.   Comprehensive integer arithmetic.
  58.   Manipulation of arrays (including reverse subscripting).
  59.   Spelling correction.
  60.  
  61.  
  62. Notation: Quotes `like this' are ordinary textual quotation
  63. marks.  Other uses of quotation marks are input to the shell.
  64.  
  65. Contents:
  66. 1) What is it?
  67. 2) On what machines will it run?
  68. 3) What's the latest version?
  69. 4) Where do I get it?
  70. 5) How does zsh differ from sh, ksh, csh, tcsh, bash?
  71. 6) Why do my csh aliases not work?  (Plus other alias pitfalls.)
  72. 7) How do I turn off spelling correction for an indvidual command?
  73. 8) How do I get the meta key to work on my xterm?
  74. 9) Why does my terminal act funny in way x?
  75. 10) Why does `$var' where var="foo bar" not do what I expect?
  76. 11) My PATH, (MANPATH, ...) sometimes doesn't handle tildes.  What gives?
  77. 12) How does base arithmetic work?
  78. 13) How do I get a newline in my prompt?
  79. 14) Why does `bindkey ^a command-name' or 'stty intr ^-' do something funny?
  80. 15) How do I execute command `foo' within function `foo'?
  81. 16) Why can't I get zsh to work with SGI's `userenv'?
  82. 17) Why do history substitutions with single bangs do something funny?
  83. 18) Why does zsh kill off all my background jobs when I logout?
  84. 19) I don't have root access: how do I make zsh my login shell?
  85. 20) Shouldn't zsh be more/less like ksh/(t)csh?
  86. 21) What bugs are currently known and unfixed?
  87. 22) Where do I report bugs, get more info / who's working on zsh?
  88. 23) What's on the wish-list?
  89. --- End of Contents ---
  90.  
  91.  
  92. 1) What is it?
  93.  
  94.   Zsh is a UNIX command interpreter (shell) which of the standard shells
  95.   most resembles the Korn shell (ksh), although it is not completely
  96.   compatible.  It includes enhancements of many types, notably in the
  97.   command-line editor, options for customising its behaviour, filename
  98.   globbing, features to make C-shell (csh) users feel more at home and
  99.   extra features drawn from tcsh (another `custom' shell).
  100.  
  101.   It was written by Paul Falstad <pf@z-code.com> when a student at
  102.   Princeton; however, Paul doesn't maintain it any more and enquiries
  103.   should be sent to the mailing list (see question 20).  It is freely
  104.   available to anyone under unrestrictive conditions.
  105.  
  106.   For more information, the files doc/intro.txt or doc/intro.troff
  107.   included with the source distribution are highly recommended.  A list
  108.   of features is given in FEATURES, also with the source.
  109.  
  110.  
  111. 2) On what machines will it run?
  112.  
  113.   Zsh was written for machines of the Berkeley UNIX family; most such
  114.   machines (and all the most popular) will run it without major surgery.
  115.   Modifications have been made so that it should work under SYSVR4-based
  116.   operating systems such as Solaris 2.x and OSF/1.  This best thing is
  117.   to suck it and see.  You may not have to change too much: if you do
  118.   change anything, arrange for the shell script `buildzsh' to set the
  119.   necessary #define's, etc., without human intervention.  Recent
  120.   additions include Convex, Unicos and Linux support; there is a project
  121.   to allow POSIX.1 compilation (but note that that zsh is not itself
  122.   particularly POSIX-compliant at the moment).  Success has been
  123.   obtained on older SYSVR3 systems, but you may need to modify the code.
  124.   
  125.   If you add support for a new machine, it would be appreciated if you
  126.   could alter buildzsh to configure zsh automatically and send the
  127.   required context diffs to the list (see question 20).
  128.  
  129.  
  130. 3) What's the latest version?
  131.   
  132.   The latest production version is 2.3.1.  The current beta version is
  133.   2.4.  New patches occur frequently and are added to the archive (next
  134.   question).  At the time of writing the latest patch level was 291.
  135.   Note that this `open' development system does mean bugs are sometimes
  136.   introduced into the most recent archived version.  These are usually
  137.   fixed quickly.
  138.  
  139.   The next production version will be 2.5 (2.4 will not be released, so
  140.   as to minimise confusion over version numbers).  It is expected that
  141.   no new features will be added before the release.
  142.  
  143.  
  144. 4) Where do I get it?
  145.  
  146.   Bas de Bakker (bas@phys.uva.nl) is in charge of the archive and the
  147.   latest version is available for users east of the Atlantic from:
  148.     carlo.phys.uva.nl(145.18.218.21):/pub/bas/zsh/zsh-2.4beta.tar.gz
  149.   The latest full release is in zsh-2.3.1.tar.gz in the same directory.
  150.   Note that this is in gzip format: you will need GNU gzip from your
  151.   nearest GNU archive to unpack it.  There is also a version under RCS
  152.   control which may be more suitable for source hackers.
  153.  
  154.   Rick Ohnemus has a reflector site in the USA:
  155.         ftp.sterling.com (192.124.9.1):/zsh
  156.  
  157.   The 2.3.1 distribution is also available from ftp.uu.net and mirrors
  158.   in the directory pub/shells/zsh.
  159.  
  160.  
  161. 5) How does zsh differ from sh, ksh, csh, tcsh, bash?
  162.  
  163.   As has already been mentioned, zsh is most similar to ksh, while many
  164.   of the additions are to please csh users.
  165.  
  166.   i) ksh:
  167.  
  168.   Most features of ksh (and hence also of sh) are implemented in zsh;
  169.   problems can arise because the implementation is slightly different.
  170.   Note also that not all ksh's are the same either.  I have based this
  171.   on the 11/16/88f version of ksh.
  172.  
  173.   Various options can be turned on which will increase ksh
  174.   compatibility, though decrease zsh's abilities: see the manual entries
  175.   for IGNORE_BRACES (though brace expansion occurs in some versions of
  176.   ksh), KSH_OPTION_PRINT, NO_BANG_HIST, NO_EQUALS, NO_HUP, NO_RCS,
  177.   NO_SHORT_LOOPS, PROMPT_SUBST, RM_STAR_SILENT, SH_WORD_SPLIT (see
  178.   question 14) and SINGLE_LINE_ZLE.  Note that you can also disable any
  179.   built-in commands which get in your way.  If invoked as `ksh', the
  180.   shell will try and set suitable options.
  181.  
  182.   Here are some differences from ksh which might prove significant for
  183.   ksh programmers, some of which may be interpreted as bugs; there must
  184.   be more.  Note that this list is deliberately rather full and that
  185.   most of the items are fairly minor.  Those marked `*' perform in a
  186.   ksh-like manner if the shell is invoked as ksh.
  187.   
  188.   Syntax:
  189.   * Shell word splitting: see question 9).  (This is particularly
  190.       frequently asked about.)
  191.     Arrays are more csh-like than ksh-like:
  192.       subscripts start at 1, not 0; array[0] refers to array[1];
  193.       `$array' refers to the whole array, not $array[0];
  194.       braces are unnecessary: $a[1] == ${a[1]}, etc.
  195.     Coprocesses are established by `coproc'; `|&' behaves like csh.
  196.   Command line substitutions, globbing etc.:
  197.     The results of parameter substitutions are treated as plain text:
  198.       `foo="*"; print $foo' prints all files in ksh but * in zsh.
  199.     The $((...)) version of numeric evaluation is not implemented; use $[...].
  200.     Treatment of backslashes within backquotes is different.
  201.     $PSn do not do parameter substitution by default (use promptsubst option).
  202.     Globbing does not allow ksh-style `pattern-lists'.  Equivalents:
  203.       -------------------------------------------------------------------
  204.              ksh             zsh          Meaning
  205.             -----           -----        ---------
  206.            !(foo)            ^foo        Anything but foo.
  207.                       or   foo1~foo2     Anything matching foo1 but foo2.
  208.       @(foo1|foo2|...)  (foo1|foo2|...)  One of foo1 or foo2 or ...
  209.            ?(foo)           (foo|)       Zero or one occurrences of foo.
  210.            *(foo)           (foo)#       Zero or more occurrences of foo.
  211.            +(foo)         foo(foo)#      One or more occurrences of foo.
  212.       -------------------------------------------------------------------
  213.       The last two (with `#') require the EXTENDED_GLOB option.
  214.     Unquoted assignments do file expansion after ':'s (intended for PATHs).
  215.     `integer' does not allow -i; integers in bases other than 10 do not
  216.       have "base#" prefixed to them when printed.
  217.   Command execution:
  218.     There is no ENV variable (use /etc/zshrc, ~/.zshrc; note also ZDOTDIR).
  219.     The PATH is not searched for commands specified at invocation without -c.
  220.   Aliases and functions:
  221.     The order in which aliases and functions are defined is significant
  222.       (function definitions with () expand aliases -- see question 6).
  223.     Aliases and functions cannot be exported.
  224.     There are no tracked aliases: command hashing replaces these.
  225.     The use of aliases for key bindings is replaced by `bindkey'.
  226.   Traps and signals:
  227.     By default, background jobs are killed when you log out:  see 17).
  228.     Traps and options are not local to functions; traps are not reset
  229.       automatically when called; traps are called as functions themselves
  230.       (this is a bug for the `trap "..." NAL' form of trap setting).
  231.     TRAPERR has become TRAPZERR (this was forced by UNICOS which has SIGERR).
  232.   Editing:
  233.     The options emacs, gmacs, privileged, trackall, viraw are not supported.
  234.       Use bindkey to change the editing behaviour: `set -o {emacs,vi}' 
  235.       become `bindkey -{e,v}'; for gmacs, go to emacs mode and use
  236.       `bindkey \^t gosmacs-transpose-characters'.  `Trackall' is replaced
  237.       by `hashcmds'.
  238.     The `keyword' option does not exist and -k is instead interactivecomments.
  239.       (`keyword' will not be in the next ksh release either.)
  240.     Management of histories in multiple shells is different:
  241.       the history list is not saved and restored after each command.
  242.     \ does not escape editing chars (use ^V).
  243.     Not all ksh bindings are set (e.g. `<ESC>#'; try <ESC>q).
  244.   * # in an interactive shell is not treated as a comment by default.
  245.   Built-in commands:
  246.     Some built-ins (r, autoload, history, integer ...) were aliases in ksh.
  247.     There is no built-in command newgrp: use a shell function, e.g.
  248.       newgrp () { ((SHLVL--)) ; exec command newgrp $* }
  249.     `jobs' has no `-n' flag.
  250.     `read' has no `-s' flag.
  251.     In `let "i = foo"', foo is evaluated as a number, not an expression
  252.       (although in `let "i = $foo"' it is treated as an expression).
  253.   Other idiosyncracies:
  254.     `select' always redisplays the list of selections on each loop.
  255.  
  256.   ii) csh:
  257.  
  258.   Although certain features aim to ease the withdrawal symptoms of csh
  259.   (ab)users, the syntax is in general rather different and you should
  260.   certainly not try to run scripts without modification.  The c2z script
  261.   is provided with the source (in scripts/c2z) to help convert .cshrc
  262.   and .login files; see also the next question concerning aliases,
  263.   particularly those with arguments.
  264.  
  265.   Csh-compatibility additions include:
  266.     Logout, rehash, source, (un)limit built-in commands.
  267.     *rc file for interactive shells.
  268.     Directory stacks.
  269.     Cshjunkie*, ignoreeof options.
  270.     The nonomatch option.
  271.     >&, |& etc. redirection.
  272.     foreach ... loops; alternate syntax for other loops.
  273.     $PROMPT as well as $PS1, $status as well as $?, $#argv as well as $#, ....
  274.     Escape sequences via % for prompts.
  275.     Special array variables $PATH etc. are colon-separated, $path are arrays.
  276.     !-type history (which may be turned off via `setopt nobanghist').
  277.     Arrays have csh-like features (see i)).
  278.  
  279.   iii) tcsh:
  280.  
  281.   (The previous section applies too, of course.)  Certain features have
  282.   been borrowed from tcsh, including $watch, run-help, $savehist,
  283.   $histlit, periodic commands etc., extended prompts, sched and
  284.   which/where built-ins.  Programmable completion was inspired by, but
  285.   is entirely different to, tcsh's `complete'. (There is a perl script
  286.   called lete2ctl in the scripts directory of the source distribution to
  287.   convert `complete' to `compctl' statements.)  This list is not
  288.   definitive: some features have gone in the other direction.
  289.  
  290.   If you're missing the editor function run-fg-editor, try something
  291.   with bindkey -s (which binds a string to a keystroke), e.g.
  292.     bindkey -s '^z' '\eqfg %$EDITOR:t\n'
  293.   which pushes the current line onto the stack and tries to bring a job
  294.   with the basename of your editor into the foreground.  Bindkey -s
  295.   allows limitless possibilities along these lines.
  296.  
  297.   iv) bash:
  298.   
  299.   Zsh has almost all the features that bash has (and much more); in
  300.   addition it is about twice as fast, though this is less impressive
  301.   than it sounds.  With the new malloc by Sven Wischnowsky (only used if
  302.   you arranged for USE_ZSH_MALLOC to be defined in config.h when
  303.   compiling zsh), zsh uses about the same amount of heap memory as bash,
  304.   which was previously the biggest gripe.  The only feature I am aware
  305.   of that zsh doesn't have is setting a numerical value for ignoreeof
  306.   --- it's always 10 --- but of course I don't use bash :-).
  307.  
  308.   However, zsh has no claims towards Posix compliancy and will not use
  309.   GNU readline (zle is more powerful).  In fact, bash is intended more
  310.   as an enhanced sh than a ksh work-alike; it doesn't handle [[ ... ]],
  311.   for example.
  312.  
  313.  
  314. 6) Why do my csh aliases not work?  (Plus other alias pitfalls.)
  315.  
  316.   First of all, check you are using the syntax
  317.     alias newcmd='list of commands'
  318.   and not
  319.     alias newcmd 'list of commands'
  320.   which won't work. (It tells you if `newcmd' and `list of commands' are
  321.   already defined as aliases.)
  322.  
  323.   Otherwise, your aliases probably contain references to the command
  324.   line of the form `\!*', etc.  Zsh does not handle this behaviour as it
  325.   has shell functions which provide a way of solving this problem more
  326.   consistent with other forms of argument handling.  For example, the
  327.   csh alias
  328.     alias cd 'cd \!*; echo $cwd'
  329.   can be replaced by the zsh function,
  330.     cd() { builtin cd $*; echo $PWD; }
  331.   (the `builtin' tells zsh to use its own `cd', avoiding an infinite loop)
  332.   or, perhaps better,
  333.     cd() { builtin cd $*; print -D $PWD; }
  334.   (which converts your home directory to a ~).  In fact, this problem is
  335.   better solved by defining the special function chpwd() (see the manual).
  336.   Note also that the `;' at the end of the function is optional in zsh,
  337.   but not in ksh or sh (for sh's where it exists).
  338.  
  339.   Here is Bart Schaefer's guide to converting csh aliases for zsh.
  340.  
  341.     1.  If the csh alias references "parameters" (\!:1 \!* etc.),
  342.         then in zsh you need a function (referencing $1 $* etc.).
  343.         Otherwise, you can use a zsh alias.
  344.  
  345.     2.  If you use a zsh function, you need to refer _at_least_ to
  346.         $* in the body (inside the { }).  Parameters don't magically
  347.         appear inside the { } the way they get appended to an alias.
  348.     
  349.     3.  If the csh alias references its own name (alias rm "rm -i"),
  350.         then in a zsh function you need the "command" keyword
  351.         (function rm() { command rm -i $* }), but in a zsh alias
  352.         you don't (alias rm="rm -i").
  353.  
  354.     4.  If you have aliases that refer to each other (alias ls "ls -C";
  355.         alias lf "ls -F" ==> lf == ls -C -F) then you must either:
  356.         a.  convert all of them to zsh functions; or
  357.         b.  after converting, be sure your .zshrc defines all of your
  358.             aliases before it defines any of your functions.
  359.  
  360.     Those first four are all you really need, but here are four more for
  361.     heavy csh alias junkies:
  362.  
  363.     5.  Mapping from csh alias "parameter referencing" into zsh function
  364.         (assuming shwordsplit is NOT set in zsh):
  365.              csh                   zsh
  366.             =====               ==========
  367.             \!*                 $*              (or $argv)
  368.             \!^                 $1              (or $argv[1])
  369.             \!:1                $1
  370.             \!:2                $2              (or $argv[2], etc.)
  371.             \!$                 $*[$#]          (or $argv[$#], or $*[-1])
  372.             \!:1-4              $*[1,4]
  373.             \!:1-               $*[1,$#-1]      (or $*[1,-2])
  374.             \!^-                $*[1,$#-1]
  375.             \!*:q               "$@"            ($*:q doesn't work (yet))
  376.             \!*:x               $=*             ($*:x doesn't work (yet))
  377.  
  378.     6.  Remember that it is NOT a syntax error in a zsh function to
  379.         refer to a position ($1, $2, etc.) greater than the number of
  380.         parameters. (E.g., in a csh alias, a reference to \!:5 will
  381.         cause an error if 4 or fewer arguments are given; in a zsh
  382.     function, $5 is the empty string if there are 4 or fewer
  383.     parameters.)
  384.  
  385.     7.  To begin a zsh alias with a - (dash, hyphen) character, use
  386.         "alias --":
  387.                  csh                            zsh
  388.             ===============             ==================
  389.             alias - "fg %-"             alias -- -="fg %-"
  390.  
  391.     8.  Stay away from "alias -g" in zsh until you REALLY know what
  392.         you're doing.
  393.  
  394.   There is one other serious problem with aliases: consider
  395.         alias l='/bin/ls -F'
  396.         l() { /bin/ls -la $* | more }
  397.   `l' in the function definition is in command position and is expanded
  398.   as an alias, defining `/bin/ls' and `-F' as functions which call
  399.   `/bin/ls', which gets a bit recursive.  This can be avoided if you use
  400.   `function' to define a function, which doesn't expand aliases.  It is
  401.   possible to argue for extra warnings somewhere in this mess.  Luckily,
  402.   it is not possible to define `function' as an alias.
  403.  
  404.  
  405. 7) How do I turn off spelling correction for an individual command?
  406.  
  407.   You presumably have `setopt correctall' in an initialisation file, so
  408.   that zsh checks the spelling of each word in the command line.  You
  409.   probably do not want this behaviour for commands which do not operate
  410.   on existing files.
  411.   
  412.   The answer is to alias the offending command to itself with
  413.   `nocorrect' stuck on the front, e.g.
  414.        alias mkdir='nocorrect mkdir'
  415.  
  416.  
  417. 8) How do I get the meta key to work on my xterm?
  418.  
  419.   As stated in the manual, zsh needs to be told about the meta key by
  420.   using `bindkey -me' or `bindkey -mv' in your .zshrc or on the command
  421.   line.  You probably also need to tell the terminal driver to allow the
  422.   `meta' bit of the character through; `stty pass8' is the usual
  423.   incantation.  Sample .zshrc entry:
  424.     [[ $TERM = "xterm" ]] && stty pass8 && bindkey -me
  425.   or, on SYSVR4-ish systems without pass8,
  426.     [[ $TERM = "xterm" ]] && stty -parenb -istrip cs8 && bindkey -me
  427.   (disable parity detection, don't strip high bit, use 8-bit characters).
  428.   Make sure this comes *before* any bindkey entries in your .zshrc which
  429.   redefine keys normally defined in the emacs/vi keymap.
  430.  
  431.  
  432. 9) Why does my terminal act funny in way x?
  433.  
  434.   If you are using an OpenWindows cmdtool as your terminal, any
  435.   escape sequences (such as those produced by cursor keys) will be
  436.   swallowed up and never reach zsh.  Either use shelltool or avoid
  437.   commands with escape sequences.  You can also disable scrolling from
  438.   the cmdtool pane menu (which effectively turns it into a shelltool).
  439.   If you still want scrolling, try using an xterm with the scrollbar
  440.   activated.
  441.  
  442.   If that's not the problem, and you are using stty to change some tty
  443.   settings, make sure you haven't asked zsh to freeze the tty settings:
  444.   type
  445.     ttyctl -u
  446.   before any stty commands you use.
  447.  
  448.   On the other hand, if you aren't using stty and have problems you may
  449.   need the opposite:  `ttyctl -f' freezes the terminal to protect it
  450.   from hiccups introduced by other programmes (kermit has been known to
  451.   do this).
  452.  
  453.   If _that's_ not the problem, and you are having difficulties with
  454.   external commands (not part of zsh), and you think some terminal
  455.   setting is wrong (e.g. ^V is getting interpreted as `literal next
  456.   character' when you don't want it to be), try
  457.     ttyctl -u
  458.     STTY='lnext "^-"' commandname
  459.   (in this example), or just export STTY for all commands to see.  Note
  460.   that zsh doesn't reset the terminal completely afterwards: just the
  461.   modes it uses itself and a number of special processing characters
  462.   (see the stty(1) manual page).
  463.  
  464.   After the release of version 2.5, there is likely to be an overhaul
  465.   which allows the terminal modes used by the shell to be modified
  466.   separately from those seen by external programmes.  This is partially
  467.   implemented already:  in 2.5, the shell will be less susceptible to
  468.   mode changes inherited from programmes.
  469.  
  470.  
  471. 10) Why does `$var' where var="foo bar" not do what I expect?
  472.  
  473.   In most Bourne-shell derivatives, multi-word variables such as
  474.     var="foo bar"
  475.   are split into words when passed to a command or used in a `for foo in
  476.   $var' loop.  By default, zsh does not have that behaviour: the
  477.   variable remains intact.  (This is not a bug!  See below.)  An option
  478.   (shwordsplit) exists to provide compatibility.
  479.   
  480.   For example, defining the function args to show the number of its
  481.   arguments:
  482.     args() { echo $#; }
  483.   and with our definition of vble,
  484.     args $vble
  485.   produces the output `1'.  After
  486.     setopt shwordsplit
  487.   the same function produces the output `2', as with sh and ksh.
  488.   
  489.   Unless you need strict sh/ksh compatibility, you should ask yourself
  490.   whether you really want this behaviour, as it can produce unexpected
  491.   effects for variables with entirely innocuous embedded spaces.  The
  492.   natural way to produce word-splitting behaviour in zsh is via arrays.
  493.   For example,
  494.     set -A array one two three twenty
  495.   (or
  496.         array=(one two three twenty)
  497.   if you prefer), followed by
  498.     args $array
  499.   produces the output `4', regardless of the setting of shwordsplit.
  500.   Arrays are also much more versatile than single strings.
  501.  
  502.   Note also the "$@" method of word splitting is always available in zsh
  503.   functions and scripts (though strictly this does array splitting, not
  504.   word splitting), also the substitution ${=foo} to toggle word
  505.   splitting on variable `foo'.
  506.  
  507.   Shwordsplit is set when zsh is invoked with the name `ksh'.
  508.  
  509.  
  510. 11) My PATH, (MANPATH, ...) sometimes doesn't handle tildes.  What gives?
  511.  
  512.   The code has recently been overhauled, so take a look at the latest
  513.   version of 2.4beta.  This guarantees that no ~user expansion (or
  514.   =command expansion, which takes place at the same time) will happen if
  515.   the tilde is quoted, and also rationalises PATH-type variables by
  516.   expanding all unquoted assignments as if they are colon-separated
  517.   lists (so you may need to add or subtract a few extra quotes, but the
  518.   results are more predictable).  In addition typeset, etc., now should
  519.   behave like ordinary assignments in this respect; previously tildes in
  520.   typeset assignments were unquotable.
  521.  
  522.  
  523. 12) How does base arithmetic work?
  524.  
  525.   The syntax (e.g. using the `let' builtin is)
  526.     let 'foo = [16]ff'
  527.   (note this is different from ksh, which uses `16#ff'), or equivalently
  528.     (( foo = [16]ff ))
  529.   Then
  530.     echo $foo
  531.   gives the answer `255'.  It is possible to declare variables explicitly
  532.   to be integers, via
  533.     typeset -i foo
  534.   which has a different effect: namely the base used in the first
  535.   assignment (hexadecimal in the example) is subsequently used whenever
  536.   `foo' is displayed (although the internal representation is unchanged).
  537.   To ensure foo is always displayed in decimal, declare it as
  538.     typeset -i 10 foo
  539.   which requests base 10 for output.  You can change the output base of an
  540.   existing variable in this fashion.  Using the `$[ ... ]' method will
  541.   always display in decimal.
  542.  
  543.  
  544. 13) How do I get a newline in my prompt?
  545.  
  546.   You can place a literal newline in quotes, i.e.
  547.     PROMPT="Hi Joe,
  548.     what now?%# "
  549.   If you have the bad taste to set the option cshjunkiequotes, which
  550.   inhibits such behaviour, you will have to bracket this with 
  551.   `unsetopt cshjunkiequotes' and `setopt cshjunkiequotes', or put it in
  552.   your .zshrc before the option is set.
  553.   
  554.   Arguably the prompt code should handle `print'-like escapes.  Feel
  555.   free to right this :-).
  556.  
  557.  
  558. 14) Why does `bindkey ^a command-name' or 'stty intr ^-' do something funny?
  559.  
  560.   You probably have the extendedglob option set in which case ^ and #
  561.   are metacharacters.  ^a matches any file except one called a, so the
  562.   line is interpreted as bindkey followed by a list of files.  Quote the
  563.   ^ with a backslash or put quotation marks around ^a.
  564.  
  565.  
  566. 15) How do I execute command `foo' within function `foo'?
  567.  
  568.   The command `command foo' does just that.  You don't need this with
  569.   aliases, but you do with functions.  Note that error messages like
  570.         zsh: job table full or recursion limit exceeded
  571.   are a good sign that you tried calling `foo' in function `foo' without
  572.   using `command'.
  573.  
  574.  
  575. 16) Why can't I get zsh to work with SGI's `userenv'?
  576.  
  577.   It seems the Silicon Graphics `userenv' command interacts weirdly with
  578.   the line editor (zsh is not unique in this respect).  Add this line to
  579.   the top of your .zshenv file:
  580.         if [[ "${ENVONLY:-0}" -eq 1 ]]; then unsetopt zle; fi
  581.   --- which will turn the line editor off if it sees a `userenv' coming.
  582.   Don't turn zle back on with setopt until [[ $ENVONLY -ne 1 ]].
  583.  
  584.  
  585. 17) Why do history substitutions with single bangs do something funny?
  586.  
  587.   If you have a command like "echo !-2:$ !$", the first history
  588.   substitution then sets a default to which later history substitutions
  589.   with single unqualified bangs refer, so that !$ becomes equivalent to
  590.   !-2:$.  The option CSH_JUNKIE_HISTORY makes all single bangs refer
  591.   to the last command.
  592.  
  593.  
  594. 18) Why does zsh kill off all my background jobs when I logout?
  595.  
  596.   Simple answer: you haven't asked it not to.  Zsh (unlike [t]csh) gives
  597.   you the option of having background jobs killed or not: the `nohup'
  598.   option exists if you don't want them killed.  Note that you can always
  599.   run programs with `nohup' in front of the pipeline whether or not the
  600.   option is set, which will prevent that job from being killed on
  601.   logout.  (Nohup is actually an external command.)
  602.  
  603.   The `disown' builtin is very useful in this respect: if zsh informs
  604.   you that you have background jobs when you try to logout, you can
  605.   `disown' all the ones you don't want killed when you exit.  This is
  606.   also a good way of making jobs you don't need the shell to know about
  607.   (such as commands which create new windows) invisible to the shell.
  608.  
  609.  
  610. 19) I don't have root access: how do I make zsh my login shell?
  611.  
  612.   Unfortunately, on many machines you can't use `chsh' to change your
  613.   shell unless the name of the shell is contained in /etc/shells, so if
  614.   you have your own copy of zsh you need some sleight-of-hand to use it
  615.   when you log on.  (Simply typing `zsh' is not really a solution since
  616.   you still have your original login shell waiting for when you exit.)
  617.   
  618.   The basic idea is to use `exec <zsh-path>' to replace the current
  619.   shell with zsh.  Often you can do this in a login file such as
  620.   .profile (if your shell is sh or ksh) or .login (if it's csh).  Make
  621.   sure you have some way of altering the file (e.g. via FTP) before you
  622.   try this as `exec' is often rather unforgiving.
  623.  
  624.   If you have zsh in a subdirectory `bin' of your home directory,
  625.   put this in .profile:
  626.     [ -f $HOME/bin/zsh ] && exec $HOME/bin/zsh -l
  627.   or if your login shell is csh or tcsh, put this in .login:
  628.     if ( -f ~/bin/zsh ) exec ~/bin/zsh -l
  629.   (in each case the -l tells zsh it is a login shell).  
  630.  
  631.   It's not a good idea to put this (even without the -l) into .cshrc, at
  632.   least without some tests on what the csh is supposed to be doing, as
  633.   that will cause _every_ instance of csh to turn into a zsh and will
  634.   cause csh scripts (yes, unfortunately some people write these) which
  635.   do not call `csh -f' to fail.  If you want to tell xterm to run zsh,
  636.   change the SHELL environment variable to the full path of zsh at the
  637.   same time as you exec zsh.  If you have to exec zsh from your .cshrc,
  638.   a minimum safety check is `if ($?prompt) exec zsh'.
  639.  
  640.   If you like your login shell to appear in the process list as '-zsh',
  641.   you can link zsh to -zsh (e.g. by `ln -s ~/bin/zsh ~/bin/-zsh') and
  642.   change the exec to `exec -zsh'.  (Make sure -zsh is in your path.)
  643.   This has the same effect as the `-l' option.
  644.  
  645.   Footnote: if you DO have root access, make sure zsh goes in
  646.   /etc/shells on all appropriate machines, including NIS clients, or you
  647.   may have problems with FTP to that machine.
  648.  
  649.  
  650. 20) Shouldn't zsh be more/less like ksh/(t)csh?
  651.  
  652.   People often ask why zsh has all these `unnecesary' csh-like features,
  653.   or alternatively why zsh doesn't understand more csh syntax.  This is
  654.   far from a definitive answer and the debate will no doubt continue.
  655.  
  656.   Paul's object in writing zsh was to produce a ksh-like shell which
  657.   would have features familiar to csh users.  For a long time, csh was
  658.   the preferred interactive shell and there is a strong resistance to
  659.   changing to something unfamiliar, hence the additional syntax and
  660.   csh_junkie options.  This argument still holds.  On the other hand,
  661.   the arguments for having what is close to a plug-in replacement for ksh
  662.   are, if anything, even more powerful:  the deficiencies of csh as a
  663.   programming language are well known (FTP convex.com:pub/csh.whynot
  664.   if you are in any doubt) and zsh is able to run many standard scripts
  665.   such as /etc/rc.
  666.   
  667.   Of course, this makes zsh rather large and quite messy so that it
  668.   seems to appeal mainly to hackers.  The only answer, perhaps not
  669.   entirely satisfactory, is that you have to ignore the bits you don't
  670.   want.
  671.  
  672.  
  673. 21) What bugs are currently known and unfixed?
  674.  
  675.   Here are some of the more well-known ones, very roughly in decreasing
  676.   order of significance.  A fuller bug list is now maintained by Carlos
  677.   Carvalho <carlos@snfep1.if.usp.br>.  Many of these can also be counted
  678.   against differences from ksh in question 5); note that this applies to
  679.   the latest beta version and that simple bugs are often fixed quite
  680.   quickly.
  681.  
  682.   Pipelines ending in a while/until/for loop are uninterruptible.
  683.   Certain built-ins won't allow the `VAR=value command ...' assignment;
  684.     the ones that do don't unset VAR after use (may not really be a bug).
  685.     (N.B.: `exec foo=bar command' is a workaround for exec.)
  686.   The `histlit' option adds newlines to lines in the history
  687.     (and is broken in several other ways, e.g. !:x word selection;
  688.     it may be removed).
  689.   `time' is ignored with builtins and can't be used with {...} or (...);
  690.     in shells with no job control the command name is blank.
  691.   `set -x' (`setopt xtrace') doesn't show as much as it should.
  692.   The line number of errors inside control structures is always given
  693.     as the end of the structure (i.e. at `fi', `done', etc.).
  694.   $_ returns the last unexpanded word from the previous line (not command).
  695.   The :q modifier doesn't split words and -q and -x don't work for variables.
  696.   In vi mode, `u' can go past the original modification point.
  697.   Autocd won't use globbed filenames.
  698.   Linked directories can sometimes confuse zsh's idea of its cwd.
  699.   Still problems under SCO Unix (a patch exists but hasn't been merged yet).
  700.   The singlelinezle option has problems with prompts containing escapes.
  701.   SIGHUP cannot be trapped.
  702.  
  703.   Note that a few recent changes introduce incompatibilities (these are
  704.   not bugs): the -h option to compctl has been removed (use `-k hosts'
  705.   for the same effect); automatic handling of hosts after '@' has been
  706.   removed (use e.g. `compctl -u -x "n[-1,@]" -k hosts -- finger');
  707.   handling of backslashes in `echo' and `print' has changed.
  708.  
  709.   There is at least one common bug which is not due to zsh.  If you have
  710.   abnormal behaviour with file descriptor 4, it's because your password
  711.   database is being read from the Network Information System and
  712.   getpwent() left this fd open.
  713.  
  714.  
  715. 22) Where do I report bugs, get more info / who's working on zsh?
  716.  
  717.   The shell is being maintained by various (entirely self-appointed)
  718.   subscribers to the mailing list,
  719.     zsh-list@sterling.com so any suggestions, complaints,
  720.   questions and matters for discussion should be sent there.  If you
  721.   want someone to mail you directly, say so.  Most patches to zsh appear
  722.   there first.
  723.   
  724.   A lower-volume list,
  725.     zsh-announce@sterling.com
  726.   exists for announcements of new features and proposed changes
  727.   requiring some decisions.
  728.  
  729.   Both lists are handled by an automated server.  The instructions for
  730.   zsh-announce are the same as for zsh-list: just change zsh-list to
  731.   zsh-announce everywhere in the following.
  732.  
  733.   To join zsh-list, send email to
  734.     Majordomo@sterling.com
  735.   containing
  736.     subscribe zsh-list <optional-address>
  737.   where <optional-address> can be blank if you want to subscribe from
  738.   your current email address.  Send the message `help' to the same
  739.   address for help on the list server; `unsubscribe zsh-list' also
  740.   works. (Don't send this to the list!) The list manager, Rick Ohnemus,
  741.   can be reached at
  742.     owner-zsh-list@sterling.com
  743.   (or `rick' at the same adress).
  744.  
  745.   The list (everything since May 1992) is archived in
  746.     ftp.sterling.com:zsh/zsh-list/YY-MM
  747.   where YY-MM are the year and month in digits.
  748.  
  749.  
  750. 23) What's on the wish-list?
  751.  
  752.   Ksh/sh compatibility could be improved if required.  This would
  753.     be a useful long term goal.
  754.   Option for glob qualifiers to follow perl syntax.
  755.   Option to quote !-history lexically via '' but not "".
  756.   Binding of shell functions (or commands?) to key strokes --
  757.     requires some way of accessing the editing buffer from functions
  758.     and probably of executing zle functions as a command.
  759.   trap '...' FOO should be eval'd rather than called as a function.
  760.   `PATH=' should clear the PATH:  it inserts `.'; use `unset PATH' or
  761.     `path=()' for the time being.  This is not really a bug as the .
  762.     would be used internally in any case (cf. ksh).
  763.   Users should be able to create their own foopath/FOOPATH array/path
  764.     combinations.
  765.   The introduction to zsh (intro.*) could do with an update to reflect
  766.     extended completion (in particular) and other recent additions.
  767.  
  768.  
  769. Acknowledgments:
  770.  
  771. Thanks to zsh-list, in particular Bart Schaefer, for suggestions
  772. regarding this document; thanks to Jim Mattson and more recently Bas de
  773. Bakker for their hard work as archivists, and to Peter Gray for
  774. maintaining the mailing list, without which zsh might easily have died,
  775. and to the latest list maintainer, Rick Ohnemus.  The world is eternally
  776. in the debt of Paul Falstad for inventing zsh in the first place.
  777.