From: Zach Riggle <zachriggle@gmail.com>
To: zsh-workers@zsh.org
Subject: Re: Where is this =(:) construct documented?
Date: Fri, 11 Jun 2021 14:18:40 -0500 [thread overview]
Message-ID: <CAMP9c5mx5cEXY3rymJtZTsfYd+hjcT0ZhxDp2gzWWW02_JG-mg@mail.gmail.com> (raw)
In-Reply-To: <CAMP9c5n+K-UYHaEC7fOo0AtL5RFhmWs31aDeiwSGn_BrFan_4A@mail.gmail.com>
Formatting fix, I accidentally a newline.
# wat.zsh ####
wat() {
>&2 echo IN WAT
>&2 ls -la "$1"
echo "$1"
}
ls -la $(wat =(:))
#############
Zach Riggle
On Fri, Jun 11, 2021 at 2:17 PM Zach Riggle <zachriggle@gmail.com> wrote:
>
> 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
next prev parent reply other threads:[~2021-06-11 19:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-11 19:17 Zach Riggle
2021-06-11 19:18 ` Zach Riggle [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAMP9c5mx5cEXY3rymJtZTsfYd+hjcT0ZhxDp2gzWWW02_JG-mg@mail.gmail.com \
--to=zachriggle@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).