From: Peter Stephenson <pws@ifh.de>
To: zsh-workers@math.gatech.edu (Zsh hackers list)
Subject: Re: Short loops?
Date: Thu, 27 Feb 1997 10:32:21 +0100 [thread overview]
Message-ID: <199702270932.KAA15453@hydra.ifh.de> (raw)
In-Reply-To: ""Bart Schaefer""'s message of "Wed, 26 Feb 1997 13:14:10 MET." <970226131410.ZM16925@candle.brasslantern.com>
"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 <pws@ifh.de> 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.
next prev parent reply other threads:[~1997-02-27 9:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-02-26 2:13 Bart Schaefer
1997-02-26 16:10 ` Zoltan T. Hidvegi
1997-02-26 17:11 ` Bart Schaefer
1997-02-26 17:26 ` Zoltan T. Hidvegi
1997-02-26 19:09 ` Bart Schaefer
1997-02-26 19:27 ` Zoltan T. Hidvegi
1997-02-26 21:14 ` Bart Schaefer
1997-02-27 9:32 ` Peter Stephenson [this message]
1997-02-27 15:06 ` Zoltan T. Hidvegi
1997-02-27 18:16 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199702270932.KAA15453@hydra.ifh.de \
--to=pws@ifh.de \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).