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

Re: Aliasing assignment-ish words (aliases[x=y]=z)

On Jan 1, 12:37am, Daniel Shahaf wrote:
} Subject: Aliasing assignment-ish words (aliases[x=y]=z)
}     2	% aliases[x=y]=z 
}     9	% x=y
} Shouldn't line 9 have interpreted the word 'x=y' as an alias?

No; alias expansion operates on shell words, and in that position
on the command line "x" "=" and "y" are separate words because of
assignment syntax rules.  The new treatment of "typeset" as keyword
extends this to global aliases and "typeset x=y".

There's more to it than this because "=" and "y" are not subject to
global alias expansion when they appear in "x=y" but that's the basic

} Or perhaps line 2 should have signaled an error.

It's long-standing practice that you can create alias table entries for
things that it's not actually possible to later interpret as aliases.
This is especially true when assigning to the parameter as you did.

Basically in this case the rule is that if you break it you get to keep
the pieces.

} Also, the 'alias -L' output for that alias won't work as the code
} producing the output intended.

There is no correct output possible in this instance, the alias command
provides no way to escape the equal sign.  I don't see any reasonable
alternative except to add a csh-style alias command where the word and
its expansion can be separate arguments.

That still doesn't help with the assignment-syntax conflict.

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