From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3693 invoked by alias); 20 Apr 2016 04:03:30 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21460 Received: (qmail 5052 invoked from network); 20 Apr 2016 04:03:29 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 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=5KM7k06nS6cHcnJmj2q/BUY5+bxUOEWSsVA7VNvsbms=; b=neTPGWX0rg+hh3d5EsLIv7KkMrWyP3lfh5QGr9Drxum7ZlO0X3gG2E5rU2YM9EuG7Q IhLCArXjWO2jjTd/OMJn3CWTsY9vSUwvI0QisT8ZcBUT5gd/7toPpXrCQySSlfZ83SDi fhHABqDLkQgDhewJD6s8cr4vOlNpOlCEO1ZGlWKoLP8LthmfHGTpJJIEwNlDTezFLg5E jpd98ZmlZWSCu873ReAVcDv5Kj2v7RoYQrT7rnoMkrc6hZiAQCJ/0YOXbDumzxaw0jPK doIFnEgj3hKO4WZSNn+HuPUjhr6fICYmuZen1NXk0U1ybshmCmLYsPFSEh2PgN5d/ZSG qleg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=5KM7k06nS6cHcnJmj2q/BUY5+bxUOEWSsVA7VNvsbms=; b=ULG2TNXwC1oesYfkvRasDHMSaFrQgjQtSJiK5dv4968EJ9mqqBtRdUZNpCdVhO6X7o KGbtU9SDM9h5TZLNv1Q2BnjZ9VAmDfKfDE1mTdQUiOp5X5VuYHvox++KquuPJDbZ9KZ5 /3sdy5z9pGsBHA+gJYSfWMwgU4kSWK/z0RqkS6DQYiX9lUcwWzZlalOVSuAzDB2ghqOz f9w2yncSMGtzpGIHzd6HV+mQPyYARLRtv6Aal6cGjbsaOv2HjDa/pCDFPfEY98XlmzKq 5fuQBvORnFoe/TY+MfOmCHxqMXTuTYf6cGOxNp1W+OWrenT71lUSOP9Nq277ljtLQWGf QeqQ== X-Gm-Message-State: AOPr4FWTMCUiqKlBeSGafgOruxo/oKBf9nvEpQzf3B6Yw/MaalPlZxX3SZWsIN1lgC59tA== X-Received: by 10.98.42.150 with SMTP id q144mr9231817pfq.73.1461125005117; Tue, 19 Apr 2016 21:03:25 -0700 (PDT) From: Bart Schaefer Message-Id: <160419210337.ZM11236@torch.brasslantern.com> Date: Tue, 19 Apr 2016 21:03:37 -0700 In-Reply-To: <87zispqb9m.fsf@student.uu.se> Comments: In reply to Emanuel Berg "Re: virtual files?" (Apr 20, 2:12am) References: <8760vdrt5y.fsf@student.uu.se> <1302351461115632@web4o.yandex.ru> <87zispqb9m.fsf@student.uu.se> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: virtual files? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Apr 20, 2:12am, Emanuel Berg wrote: } } Obviously creating a normal file just to remove it } last thing doesn't score you any hacker points... } } So I think this is a good idea for you to contemplate } incorporating in zsh! The problem is that implementing something like this in the shell is fairly useless, because none of the other tools that the shell might invoke would know what to do with it. This is why you need something operating-system-level like FUSE (as Nikolay mentioned), which can make the virtual object "look like" an ordinary file or descriptor to anything using the ordinary libraries/interfaces. Also as Nikolay sort of mentioned in passing, you can replace local result_file=result wget -q $link -O $result_file grep \"answer\" $result_file | ... rm $result_file with grep \"answer\" =(wget -q $link -O -) | ... and zsh will take care of creating/removing the temp file for you. You can further do exec {result_fd}< =(wget -q $link -O -) and now $result_fd is a descriptor holding open an unlinked file. If you load the zsh/system module, you can grep \"answer\" <&$result_fd | ... sysseek -u $result_id 0 If all you're wanting is to capture output in a variable, you can use the "read" command (or use "sysread" from zsh/system). Zsh arranges for "read" at the tail of a pipe to execute in the current shell (unlike most other shells that put the pipe tail in a subshell) so wget -q $link -O - | read -d '' result loads the output of wget directly into $result. There are other things you can do e.g. with the zsh/mapfile module or the zsh/db/gdbm module (I recommend a very recent zsh if you plan to do anything serious with the latter), but I've rambled enough.