EDIT: The example works in pure zsh. My installation with prezto won't work. Seems like a bug in prezto.
I tried to alias sponge
as SP
in zsh. But the result is pretty surprising.
Without global alias:
❯ echo xxx >! xxx
❯ cat xxx | sponge xxx
❯ cat xxx # non-empty file
xxx
With global alias:
❯ echo xxx >! xxx
❯ alias -g SP='| sponge '
❯ cat xxx SP xxx
❯ cat xxx
(empty file, no lines are shown here)
What's the cause of the strange behavior? How can I make it work?