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

Re: Is there a way to make global aliases more available?



> On 18/01/2023 14:54 Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> I define a global alias:
> 
> alias -g EMPTYSTR='[[:space:][:INCOMPLETE:][:INVALID:]$'\e']#'
> 
> to then use it in [[ "" == EMPTYSTR ]]. It works, however any addition to the alias name makes it inactive, e.g.:
> 
> [[ "" == (EMPTYSTR) ]]
> [[ "" == (#b)(EMPTYSTR) ]]
> 
> won't work. Is there any way to somehow improve the alias recognizability?

No, aliases are by design very limited things that get replaced on input
before any parsing is done.

It would be far simpler to use a variable; the following seems to work.

EMPTYSTR='[[:space:][:INCOMPLETE:][:INVALID:]$'\e']#'
[[ " " = (#b)(${~EMPTYSTR}) ]]

pws




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