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

Where is this =(:) construct documented?



It's insane, cool, and I can't find this documented anywhere.  It
creates a temporary file that is automatically deleted... but only
after the line / expression terminates.

( ... ) creates a subshell (terminology?)
( : ) creates a subshell that does nothing
=bash evaluates to the path to bash, e.g. /usr/bin/bash
$(...) captures the output of a subshell, e.g. x=$(echo foo)

If follows, then, that =(:) shows the path to... what? Apparently, a
scope-tracked, auto-deleting temporary file.  *Where is this
documented?*

# wat.zsh ####
wat() {
    >&2 echo IN WAT
    >&2 ls -la "$1"
    echo "$1"
}ls -la $(wat =(:))
#############

# example #####
$ zsh wat.sh
IN WAT
-rw-------  1 zachriggle  wheel  0 Jun 11 14:13 /tmp/zshfMERth
ls: /tmp/zshfMERth: No such file or directory
#############

What's more insane is that the temporary file will be auto-populated
with the output of the =() construct.  Where is THAT documented?

#############
$ (){ echo $1; cat $1 } =( echo allo )
/tmp/zshpfFAOp
allo
#############


Zach Riggle




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