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

Yet another silly zsh-ism



I was thinking about the question of simulating anonymous functions in an
older version of zsh, and stumbled upon this:  You can create a function
whose name is the empty string.

torch% setopt functionargzero
torch% ""() { print Hi, my name is ${(qqqq)0} }
torch% ''
Hi, my name is $''
torch% print $functions[]
        print Hi, my name is ${(qqqq)0}
torch% typeset -f ""
'' () {
        print Hi, my name is ${(qqqq)0}
}

Other shells complain that the empty string is not a valid identifier.



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