zsh-users
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: zsh-users@zsh.org
Subject: Re: virtual files?
Date: Fri, 22 Apr 2016 00:14:07 +0200	[thread overview]
Message-ID: <878u061ufk.fsf@student.uu.se> (raw)
In-Reply-To: <160419210337.ZM11236@torch.brasslantern.com>

Bart Schaefer <schaefer@brasslantern.com> writes:

> 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.

That sure is the international superstar hitman
approach but it appears to be overkill (ha) not only
for this example but also for whatever else I've done
and am doing at the zsh and CLI tool level.

Also there is some virtue in having the software which
you use the most at some level of isolation from the
OS (or the OS below I should say). It is a good
feeling, and an efficient method, to just be able to
bring over your Emacs and zsh gear from one system to
another and virtually have the same user experience,
all but instantly. And I have actually succeeded doing
that! Sometimes...

> 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.

... :O

I can't believe I missed this the first time I read
this message! But if I hadn't, I wouldn't have learned
about the () { } =() thing so I suppose it was my
ancestors having my back, as always.

"If all you're wanting"...? :)

But yes, this is exactly what I want!

    read-test () {
        local url=http://data.bls.gov/cgi-bin/cpicalc.pl
        local result
        wget -q $url -O - | read -d '' result
        echo $result
    }

(I suppose the "delimiter" is EOF if set to nothing.)

Now I'll dig deep into all my shell programming and
see if I can prune some unnecessary creation and
removal of filesystem files. Delightful!

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 26 Blogomatic articles -                   


  parent reply	other threads:[~2016-04-21 22:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-20  1:00 Emanuel Berg
2016-04-20  1:27 ` Nikolay Aleksandrovich Pavlov (ZyX)
2016-04-20  2:12   ` Emanuel Berg
2016-04-20  2:31     ` Nikolay Aleksandrovich Pavlov (ZyX)
2016-04-20  4:03     ` Bart Schaefer
2016-04-20  6:06       ` Emanuel Berg
2016-04-21 22:14       ` Emanuel Berg [this message]
2016-04-22  1:08         ` Bart Schaefer
2016-04-20  3:32 ` Benjamin R. Haskell
2016-04-20 20:34   ` Bart Schaefer
2016-04-22  5:26     ` Benjamin R. Haskell
2016-04-21  4:12   ` Emanuel Berg
2016-04-21  6:58     ` Bart Schaefer
2016-04-21  8:05       ` Emanuel Berg
2016-04-22  5:55     ` Benjamin R. Haskell

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=878u061ufk.fsf@student.uu.se \
    --to=embe8573@student.uu.se \
    --cc=zsh-users@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).