0

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?

Hugh Wang
  • 1
  • 2

1 Answers1

0

you are replacing what should be a pipe with an argument

cat xxx SP xxx

means that cat now has 3 arguments

alias -g SP='sponge'

and

cat xxx | SP

Should give you desired results

Calvin Taylor
  • 664
  • 4
  • 15