zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: Is quoting of the assigned value needed?
Date: Fri, 22 Nov 2019 14:31:46 +0000	[thread overview]
Message-ID: <1574433106.4702.19.camel@samsung.com> (raw)
In-Reply-To: <948D905A-5446-4B89-8F47-74FF6A2B1B95@easesoftware.com>

On Fri, 2019-11-22 at 08:07 -0600, Perry Smith wrote:
> It surprised me that this:
> 
> var2=$var1
> 
> worked as it does but bash does the same thing.

It's much clearer like this as you can instantly see if you're doing an
array assignment or not.

If you like unclarity, the original zsh behaviour (changed in very
early days) is still available as an option...


       GLOB_ASSIGN <C>
If  this  option  is  set, filename generation (globbing) is per‐
formed on the right hand side of scalar parameter assignments  of
the  form  `name=pattern  (e.g. `foo=*').  If the result has more
than one word the parameter will become an array with those words
as arguments. This option is provided for backwards compatibility
only: globbing is always performed on  the  right  hand  side  of
array assignments of the form `name=(value)' (e.g. `foo=(*)') and
this form is recommended for clarity; with this option set, it is
not  possible to predict whether the result will be an array or a
scalar.


What you appear to be suggesting is unsurprising (I think, I'm guessing
somewhat) is even less clear: look at the details of what's in $var1 and
decide based on that if you need an array.  Obviously it can't *always*
assign an array as there would be no way of assigning scalar values.

pws

  reply	other threads:[~2019-11-22 14:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20191122020437eucas1p128174332018d20a266f55007fcf271ba@eucas1p1.samsung.com>
2019-11-22  2:03 ` Sebastian Gniazdowski
2019-11-22 10:45   ` Peter Stephenson
2019-11-22 14:07     ` Perry Smith
2019-11-22 14:31       ` Peter Stephenson [this message]
2019-11-22 14:59         ` Perry Smith
2019-11-22 15:01     ` Sebastian Gniazdowski
2019-11-22 15:06       ` Peter Stephenson
2019-11-22 16:26         ` Sebastian Gniazdowski
2019-11-23 18:01           ` Sebastian Gniazdowski

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=1574433106.4702.19.camel@samsung.com \
    --to=p.stephenson@samsung.com \
    --cc=zsh-users@zsh.org \
    /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).