zsh-users
 help / color / mirror / code / Atom feed
* e:: with an array ?
@ 2006-08-22 20:45 Marc Chantreux
  2006-08-23  3:26 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Marc Chantreux @ 2006-08-22 20:45 UTC (permalink / raw)
  To: zsh-users

Hi all, 

print -l *(e:true:)

works but 

x=(*); print -l ${(e:true:)x}

is an error. 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 :-)

regards
mc  

-- 
téléphone : 03.90.24.00.19
courriel  : marc.chantreux@ulpmm.u-strasbg.fr
---------------------------------------


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: e:: with an array ?
  2006-08-22 20:45 e:: with an array ? Marc Chantreux
@ 2006-08-23  3:26 ` Bart Schaefer
  2006-08-23  8:48   ` Marc Chantreux
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2006-08-23  3:26 UTC (permalink / raw)
  To: zsh-users

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.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: e:: with an array ?
  2006-08-23  3:26 ` Bart Schaefer
@ 2006-08-23  8:48   ` Marc Chantreux
  0 siblings, 0 replies; 3+ messages in thread
From: Marc Chantreux @ 2006-08-23  8:48 UTC (permalink / raw)
  To: zsh-users

le 22/08/2006,
Bart Schaefer nous écrivait :
> On Aug 22, 10:45pm, Marc Chantreux wrote:
> 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.

In general .. but this correlation can be very usefull so i've tried
something that smells logical for me :-)

> } 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

this grep, yes. 

> 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/.

something like python yield, so ? 

no ... i'm kidding!

Thanks for enligthenment, Bart.

regards
mc

-- 
téléphone : 03.90.24.00.19
courriel  : marc.chantreux@ulpmm.u-strasbg.fr
---------------------------------------


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-08-23  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-22 20:45 e:: with an array ? Marc Chantreux
2006-08-23  3:26 ` Bart Schaefer
2006-08-23  8:48   ` Marc Chantreux

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).