zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users <zsh-users@sunsite.dk>
Subject: Re: e:: with an array ?
Date: Tue, 22 Aug 2006 20:26:16 -0700	[thread overview]
Message-ID: <060822202616.ZM7566@torch.brasslantern.com> (raw)
In-Reply-To: <20060822204536.GA11639@ulpmm.u-strasbg.fr>

On Aug 22, 10:45pm, Marc Chantreux wrote:
} 
} print -l *(e:true:)
} 
} works but 
} 
} x=(*); print -l ${(e:true:)x}
} 
} is an error.

In general there's no correlation between glob qualifiers and parameter
expansion flags, so you shouldn't expect that.  E.g. ${(U)x} means to
convert $x to uppercase, but *(U) means to match files owned by the
current effective user ID.

One could argue that given (N) to turn on NULL_GLOB and (D) to turn
on GLOB_DOTS, there should also be a way to turn on NO_NOMATCH so that
one could force an (e::) qualifier to be applied to nonexistent files.
However, NO_NOMATCH normally means that the entire pattern _including_
qualifiers must be preserved unchanged on a match failure, so turning
it off within the qualifiers is a logical quandary.  Note also that
even with NO_NOMATCH, *(e:false:) fails with "no such file."

} I haven't found an alternative in the doc so i wonder again
} (http://www.zsh.org/mla/users//2006/msg00193.html) if there is a kinda
} perl grep :-)

If you mean
  grep { func } @x
as in
  map { if (func) { $_ } else { () } } @x
then no, there is no direct zsh equivalent, except in the special case
where func is the zsh equivalent of m/pattern/.

With extendedglob set, zsh does have ${x/(#b)(*)/$(func $match)},
which can be made to behave mostly like perl map.  If func is limited
to things that can be expressed as parameter expansion operations, you
can change $(...) to ${...}, save a fork, and annoy Matthias Kopferman.


  reply	other threads:[~2006-08-23  3:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-22 20:45 Marc Chantreux
2006-08-23  3:26 ` Bart Schaefer [this message]
2006-08-23  8:48   ` Marc Chantreux

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=060822202616.ZM7566@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /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).