zsh-workers
 help / color / mirror / code / Atom feed
From: Zefram <A.Main@dcs.warwick.ac.uk>
To: dpd@asan.com
Cc: zsh-workers@math.gatech.edu
Subject: Re: Unable to process a for loop as expected??
Date: Sun, 18 Aug 1996 19:45:45 +0100 (BST)	[thread overview]
Message-ID: <13286.199608181845@stone.dcs.warwick.ac.uk> (raw)
In-Reply-To: <17552567901167@asan.com> from "dpd@asan.com" at Aug 18, 96 01:55:20 pm

>list="a b c d"
>for character in $list

You're trying to have word splitting done on $list, in order to
generate multiple words for the for loop.  By default zsh does no field
splitting.  There are three main approaches to this problem.

1. In order to get sh behaviour in this regard, use "setopt
sh_word_split".  ("emulate sh" will do this, among other things, and
zsh will have this option set by default if invoked as sh.)

2. In order to do field splitting here only, leaving the default
behaviour unchanged, use $=list instead of $list.

3. In order to make the script use idiomatic zsh, rewrite it using an
array:

list=(a b c d)
for character in $list

This last method has the advantage that the values to be looped over
can contain whitespace:

list=(a b c 'd and some more text with spaces')

>BTW, according to the extracted sources, I am using zsh version zsh-2.6-beta19.
>However, according to the man pages, I am using zsh version 2.7.  (Why 
>the discrepancy?)

For a while the man pages said 2.7 because that was expected to be the
next public release, and it would be too much trouble to change the man
pages every version.  The latest release is 3.0.0, and the man pages
say 3.0.

>I am running the LINUX operating system, version 1.3.91.

Not a terribly stable version, AFAIK.  Apparently 1.3.98 and 1.3.100
are much better.  (I'm still running 1.3.80 -- very stable.)

-zefram


  parent reply	other threads:[~1996-08-18 19:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-18 18:55 dpd
1996-08-18 18:06 ` Tom Kaczmarski
1996-08-18 18:45 ` Zefram [this message]
1996-08-18 19:19 ` Richard Coleman

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=13286.199608181845@stone.dcs.warwick.ac.uk \
    --to=a.main@dcs.warwick.ac.uk \
    --cc=dpd@asan.com \
    --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).