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

Re: Test for features?



On Mon, 25 Jan 2010, Bart Schaefer wrote:

> On Jan 25,  1:16am, Benjamin R. Haskell wrote:
> } Subject: Re: Test for features?
> }
> } On Mon, 25 Jan 2010, Benjamin R. Haskell wrote:
> } 
> } > Is there a good way to test for features in Zsh?
> 
> The best way, as you discovered, is simply to try using the feature -- 
> in a subshell if its absence causes a shell exit -- and check for 
> success or failure of that attempt.  E.g., I have in my startup files 
> things like:
> 
> # Subshell because some versions of zsh stop sourcing on "bad option";
> # braces because some versions do "if ( )" like csh and don't subshell.
> if { (autoload -U >& /dev/null) }
> then
>    ...
> fi
> 
> where the "..." does things like set up the fpath.

Just to be sure I'm following, you're saying: the '...' does things that 
depend on 'autoload -U' being functional?


> Rearranging things a bit ...
> 
> } [*] I still always mix up my terminology for:
> } 
> } {glob,history,expansion,file\ generation}\ {modifiers,flags,parameters}
> 
> There's no such thing as a "glob parameter" -- "parameters" belong in 
> the left braces, not the right.  Maybe you're thinking of 
> "qualifiers"?

Yes, I meant "qualifiers", but thinko'ed it to "parameters".


> Also "globbing" and "file[name] generation" are the same thing.

Yeah, but it's hard to search 'zshall' sometimes thanks to that fact.


>  
> } Are the correct terms: (1) file expansion modifier and (2) history modifier?
> 
> The correct term is just "modifier" -- there's only one set of them.  
> The distinction is that all the modifiers apply to history, but only a 
> subset of them apply to each of globbing or parameter expansion.

Okay, so syntactically, 'globbing modifiers' would refer to the subclass 
of 'history modifiers' (== 'modifiers') that work for globbing.  But 
they aren't really a special class of thing, and in my examples, :A is 
just a modifier.  Guess I'm just confusing myself.

> Generally, "flags" appear in parens as a prefix of the context to which 
> they're applied, and "modifiers" appear as a suffix with a colon.  There 
> wasn't any conscious effort to make this distinction that I know of, it 
> just sort of worked out that way.  "Qualifiers" apply only to globbing, 
> and in that context modifiers are a subset of qualifiers.

Good summation, thanks.

> } Hmm... interesting side note: only one kind of ':A' modifier* doesn't 
> } work.
> } 
> } This works (1): p=( ~(:A) )
> 
> Well, no, it doesn't.  It doesn't cause an error, but it doesn't do 
> anything either.

Yeah, realized after I sent.

> Unrecognized modifiers used as glob qualifiers are silently discarded.  
> I'm not sure why.

Just to keep things fun. :-)

> 
> You can see this better if you try *(:A) instead.
> 



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