Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: virtual files?
- X-seq: zsh-users 21463
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh-Users List <zsh-users@xxxxxxx>
- Subject: Re: virtual files?
- Date: Wed, 20 Apr 2016 13:34:46 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=jrJE21ZP5oMQlOxoL5NAKekxWn4EEwwmsRXGmVYesjQ=; b=O4EH5TrkhZn1nrD7WRR0YIV9TQ4QPtTV5pDmq2SWZof2/9FEdfds4s4kkZQLds1VSg 278rIT7KmCnonOWtybtGOj4x4Y9KCYAmLp3MFcjOl1vaygD3eaPKpA4uNa9F02g0FhMV zUOWDJjqY6DYcsfSYBjWX5saNJZMDFYN3rbgZhMxBrAAQjjfJxQYKxQvTJZHmi5lx+h+ j8BxSbdlbUSFBKk5M4J7idI0A+UpQuHJJbB73evcCRXplIXqFhKdlnEFj9hp6CkwsFYw XY4RBd4QreDsxUU845KqFysxVbUfpp/EnMkAIfROx7aGyNvrQPb+SucVa6L9RbD5d9TB cCVw==
- In-reply-to: <CAB2RFrTTibd-8FLs5GoGbMiTS2Gk8L8CVq1gC5im_8LmF3F6Zw@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <8760vdrt5y.fsf@student.uu.se> <CAB2RFrTTibd-8FLs5GoGbMiTS2Gk8L8CVq1gC5im_8LmF3F6Zw@mail.gmail.com>
On Apr 19, 11:32pm, Benjamin R. Haskell wrote:
}
} Using the `=()` substitution ZyX mentions:
}
} () {
} local tmp=$1
} wget -q $link -O $tmp
} echo -n \$
} grep \"answer\" $tmp | cut -d \$ -f 2 | cut -d \< -f 1
} } =(:)
}
} The '() { ... }' construct is an anonymous function, just for controlling
} the scope of the temporary file, and for passing it in as a positional
} parameter. It has the disadvantage that it won't remove the tmp file if
} something goes wrong.
In fact the point of using =(:) is that it WILL remove the tmp file if
something goes wrong (unless it's something completely catastrophic like
the shell itself crashing, but in that case an explicit "rm" wouldn't
work either).
Instead of exit traps, you can use "always" blocks:
() {
local tmp=$1;
{
: do stuff with $tmp
exit
} always {
rm $tmp
}
} =(:)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author