Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14122

Re: Redirect to variable

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Redirect to variable
Date 2018-05-21 10:12 -0400
Message-ID <mailman.165.1526912169.1292.bug-bash@gnu.org> (permalink)
References <07bb0d73-b90a-1cc9-0a1d-59568a602777@passchier.net>

Show all headers | View raw


On 5/20/18 10:21 PM, PePa wrote:
> I would like to do something like this, where output gets redirected
> into a variable:
> 
> some-command >>> variablename1 2>>>variablename2
> 
> command-with-many-output-descriptors >>> var1 3>>> var3 4>>> var4
> 
> The idea is not needing files to be created but to just use memory. Half
> a year ago I posted this idea here, but didn't get any reply, maybe this
> isn't the right place? Am I blacklisted??

It's not possible, in general, to open a file descriptor to an arbitrary
block of memory, especially given file descriptor inheritance between
processes.

What you're asking for is syntactic sugar for:

some-command > temp-file
echo '#' >> temp-file
variablename=$(< temp-file)
rm -f temp-file
variablename=${variablename%?}

I would look at a sample implementation, possibly using mmap, if someone
did one.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: Redirect to variable Chet Ramey <chet.ramey@case.edu> - 2018-05-21 10:12 -0400

csiph-web