Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: virtual files?



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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 -                   



Messages sorted by: Reverse Date, Date, Thread, Author