zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh workers <zsh-workers@zsh.org>
Subject: Re: Unexpected foo==bar errors
Date: Sun, 7 Feb 2016 11:16:38 -0800	[thread overview]
Message-ID: <160207111638.ZM30626@torch.brasslantern.com> (raw)
In-Reply-To: <CAHYJk3QRVQ893fMP+4CmdapK10vx5gP581pY358KSQdR1-sZuQ@mail.gmail.com>

On Feb 7,  4:57pm, Mikael Magnusson wrote:
}
} I always thought of EQUALS expansion as a form of globbing; should it
} be enabled in these contexts even though regular globbing isn't?

It's expansion, like with a leading tilde, not globbing, so GLOB_ASSIGN
doesn't apply here at all.

MAGIC_EQUAL_SUBST has never controlled expansion occurring in parameter
assignments, it only controls whether expansion occurs in normal command
arguments that LOOK LIKE assignments.

torch% bar==echo
torch% print $bar
/bin/echo
torch% print foo==echo
foo==echo
torch% setopt magicequalsubst
torch% print foo==echo       
foo=/bin/echo
torch% setopt no_equals
torch% print foo==echo    
foo==echo
torch% bar==echo
torch% print $bar
=echo
torch% 

} _tar:70 is
} tf=${~words[3]}

Ooh, that's a fun one: (foo) is being taken as glob qualifiers, which is
a larger problem in this case than the expansion of "=".  Then because
globassign is off, the equals expansion (on the empty string) is done,
but the qualifiers are never applied to the result.

If you "setopt shfileexpansion" so that equals applies after globbing
instead of before, the assignment behaves more sensibly, but:

The only use of $tf as far as I can see is to do lookups in the cache.
The apparent intent is to canonicalize the cache name to avoid "tar -tf"
of the same tar file more than once.  That optimization may not be worth
the buggy attempt at expansion, and caching the result of =(command) may
not be the best idea in the first place.

I'm not sure exactly what fix to suggest.


  parent reply	other threads:[~2016-02-07 19:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-07 15:57 Mikael Magnusson
2016-02-07 19:06 ` Peter Stephenson
2016-02-08  7:09   ` Bart Schaefer
2016-02-08  9:49     ` Peter Stephenson
2016-02-07 19:16 ` Bart Schaefer [this message]
2016-02-08  3:52   ` Mikael Magnusson
2016-02-08 18:45     ` Bart Schaefer
2016-02-08 19:16       ` Mikael Magnusson
2016-02-14 20:10         ` Failed process substitution on x=$~y (Re: Unexpected foo==bar errors) 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=160207111638.ZM30626@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@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).