zsh-workers
 help / color / mirror / code / Atom feed
From: Richard Coleman <coleman@math.gatech.edu>
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 15:19:40 -0400	[thread overview]
Message-ID: <199608181919.PAA20716@redwood.skiles.gatech.edu> (raw)
In-Reply-To: Your message of "Sun, 18 Aug 1996 13:55:20 CDT." <17552567901167@asan.com>

> #!/bin/zsh
> 
> list="a b c d"
> 
> for character in $list
> do
>    echo "Character is $character"
> done
>  
> The expected output (Exactly what I wish to accomplish):
> 
> Character is a
> Character is b
> Character is c
> Character is d
> 
> Actual output (Not what I want to accomplish):
> 
> Character is a b c d

This is a feature and not a bug.  It is discussed in the FAQ.
If you want to split the word, you can either turn on the option
shwordsplit which will make zsh work like other shells with
respect to word splitting, or you can use

list="a b c d"
for character in ${=list}
do
    echo "Character is $character"
done

which tells zsh to split the variable when it is evaluated.
With zsh, you get to choose whether to split the variable, rather
than it happening by default.

> A similar script using the /bin/bash shell produces the "expected" output, 
> however, using the /bin/zsh shell produces the "actual", i.e., 
> unwanted, output
> 
> 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?)

Initially, zsh 2.6 was the beta version for 2.7.  Since there was plenty
of changes, the major version has now been moved to 3.  I suggest you
upgrade to 3.0.

rc


      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
1996-08-18 19:19 ` Richard Coleman [this message]

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=199608181919.PAA20716@redwood.skiles.gatech.edu \
    --to=coleman@math.gatech.edu \
    --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).