News for hackers. Stuff that matters.
Re:Fish 4.0: The Fish of Theseus by arp242 on Sunday December 29, 2024 @02:46PM (#42542423)
They don't work in zsh; they're bash issues.
Re:Fish 4.0: The Fish of Theseus by faho on Sunday December 29, 2024 @02:54PM (#42542488)
No, they work in zsh, with one extremely small change: The referenced variable needs to exist.

Try this (tested with zsh 5.9 on archlinux):

    foo='PWD[$(echo hahaha >&2)0]+42'
    [[ "$foo" -eq 5 ]]
In bash, this would also print "hahaha" with "a" (or any other possible variable name) instead of "PWD", that's why many think it doesn't work at all in zsh.

I'm pretty sure zsh has an optimization where it skips the indexing if the variable doesn't exist, which happens to sometimes stop this. But since you can just reference variables like PWD, that you know exist, it's not really a security improvement.