From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11118 invoked from network); 27 Feb 1997 09:39:09 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by coral.primenet.com.au with SMTP; 27 Feb 1997 09:39:09 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id EAA05569; Thu, 27 Feb 1997 04:30:03 -0500 (EST) Resent-Date: Thu, 27 Feb 1997 04:30:03 -0500 (EST) Message-Id: <199702270932.KAA15453@hydra.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: Re: Short loops? In-reply-to: ""Bart Schaefer""'s message of "Wed, 26 Feb 1997 13:14:10 MET." <970226131410.ZM16925@candle.brasslantern.com> Date: Thu, 27 Feb 1997 10:32:21 +0100 From: Peter Stephenson Resent-Message-ID: <"b1tz7.0.yM1.QGL5p"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/2933 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu "Bart Schaefer" wrote: > Peter, how about adding something about this to the FAQ as well? It looks like I should be adding two things to the FAQ. This is the deyodled text. 3.6: Why does zsh not work in an Emacs shell mode any more? (The following is from Bart Schaefer again): Emacs 19.29 or thereabouts stopped using a terminal type of "emacs" in shell buffers, and instead sets it to "dumb". Zsh only kicks in its special I'm-inside-emacs initialization when the terminal type is "emacs". Placing a (setenv "TERM" "emacs") in your ~/.emacs file seems to fix this. If that confuses other programs that are run from within emacs, you can instead use (setenv "ESHELL" "~/bin/eshell") and then put `TERM=emacs exec zsh' in the file ~/bin/eshell. 3.16: How does the alternative loop syntax, e.g. `while {...} {...}' work? Zsh provides an alternative to the traditional sh-like forms with `do', while TEST; do COMMANDS; done allowing you to have the COMMANDS delimited with some other command structure, often `{...}'. However, to make this work you must make sure the TEST itself is clearly delimited. For example, this works: while (( i++ < 10 )) { echo i is $i; } but this does _not_: while let "i++ < 10"; { echo i is $i; } # Wrong! The reason is that after `while', any sort of command list is valid. This includes the whole list `let "i++ < 10"; { echo i $i; }'; the parser simply doesn't know when to stop. Furthermore, it is wrong to miss out the semicolon, as this makes the `{...}' part of the argument to `let'. So when using this syntax, the test following the `while' must be wrapped up: any of `((...))', `[[...]]', `{...}' or `(...)' will have this effect. (They have their usual syntactic meanings too, of course; they are not interchangeable.) Note that here too it is wrong to put in the semicolon, as then the case becomes identical to the preceding one: while (( i++ < 10 )); { echo i is $i; } # Wrong! The same is true of the `if' and `until' constructs: if { true } { echo yes } else { echo no } but with `for', which only needs a list of words, you can get away with it: for foo in a b; { echo foo is $a; bar=$foo; } since the parser knows it only needs everything up to the first semicolon. For the same reason, there is no problem with the `repeat', `case' or `select' constructs; in fact, `repeat' doesn't even need the semicolon since it knows the repeat count is just one word. This is independent of the behaviour of the SHORTLOOPS option (see manual), which you are in any case encouraged not to use in programs as it can be very confusing. -- Peter Stephenson Tel: +49 33762 77366 WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77413 Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen DESY-IfH, 15735 Zeuthen, Germany.