Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Test for features?



On Mon, 25 Jan 2010, Benjamin R. Haskell wrote:

> I see this came up before [1], and since it was relatively recent, I 
> assume the answer is the same, but:
> 
> Is there a good way to test for features in Zsh?
> 
> Specifically, I didn't realize that the ':a' and ':A' modifiers(sp?) 
> were recent additions, while dropping my .zshrc onto an OpenSolaris 
> box w/ SUNWzsh 4.3.9.  (Though it does make me feel less crazy for not 
> having used them the whole time.)

Hmm... interesting side note: only one kind of ':A' modifier* doesn't 
work.

This works (1): p=( ~(:A) )

This doesn't (2): p=~ ; p=${p:A}

  zsh: unrecognized modifier `A'


The upside is that further testing also revealed a far-simpler 'feature' 
test:

has_A=$(eval 'p=~ ; p=${p:A} ; echo true' 2>/dev/null || echo false)

$has_A && echo yay

-- 
Best,
Ben


[*] I still always mix up my terminology for:

{glob,history,expansion,file\ generation}\ {modifiers,flags,parameters}

Are the correct terms: (1) file expansion modifier and (2) history modifier?



Messages sorted by: Reverse Date, Date, Thread, Author