zsh-workers
 help / color / mirror / code / Atom feed
* Where is this =(:) construct documented?
@ 2021-06-11 19:17 Zach Riggle
  2021-06-11 19:18 ` Zach Riggle
  2021-06-11 19:53 ` Stephane Chazelas
  0 siblings, 2 replies; 8+ messages in thread
From: Zach Riggle @ 2021-06-11 19:17 UTC (permalink / raw)
  To: zsh-workers

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-06-14 14:33 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-11 19:17 Where is this =(:) construct documented? Zach Riggle
2021-06-11 19:18 ` Zach Riggle
2021-06-11 19:53 ` Stephane Chazelas
2021-06-11 19:58   ` Roman Perepelitsa
2021-06-11 20:04   ` Stephane Chazelas
2021-06-11 20:39     ` Zach Riggle
2021-06-14 12:44       ` Vincent Lefevre
2021-06-14 14:32         ` Stephane Chazelas

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).