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

Re: Test for features?



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.

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"?
Also "globbing" and "file[name] generation" are the same thing.
 
} 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.

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.

} 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.  Unrecognized modifiers used as glob qualifiers are
silently discarded.  I'm not sure why.

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



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