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


Groups > gnu.bash.bug > #14272

Re: Directing into a variable doesn't work

Path csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail
From Peter Passchier <peter@passchier.net>
Newsgroups gnu.bash.bug
Subject Re: Directing into a variable doesn't work
Date Sun, 24 Jun 2018 22:26:52 +0700
Lines 53
Approved bug-bash@gnu.org
Message-ID <mailman.2499.1529854025.1292.bug-bash@gnu.org> (permalink)
References <634e501a-5db1-d9ae-ae0b-bb3b414a2def@passchier.net> <acc5bff9-868a-31be-7439-c014fc517122@inlv.org>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Trace usenet.stanford.edu 1529854025 19670 208.118.235.17 (24 Jun 2018 15:27:05 GMT)
X-Complaints-To action@cs.stanford.edu
To Martijn Dekker <martijn@inlv.org>, bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=passchier.net; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:To:Subject:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=U+T4kCbFZ0rXDWrtn0sjz9REOjxZkemzYZtXLEZUhkc=; b=Ym5V2q+sO5mqkR7XdNeOxfcgS/ uTm4ARR3U/q19cAZiuiqOP5qHmMPAsbh9f/QgaRmmiKUPhhgAGp6sh/bAe2NG5k3g/TyKvR+e92bQ TMRbUyZmE0e4hx0OJx9S5I9//L7Ry/H39UDfFCYWxeUU1+E1BUEsQFzbY/dFjMMyzHTWiHGW8Mj6/ 99TEo8UQ+X5AZviMbvu6W0/TXXTJ5v65SPv49xMoKYYDmN2xO4gRwlth4gUUt8Sx+K79J545oGuXK cHyDRqgdDI/VY4ASQcUwz81bagE1ypOVbibU746mKVVI8kH9KgGJW1SONTnocZ25pgeKF9SSQCmz3 hzlo0+mg==;
Openpgp preference=signencrypt
Autocrypt addr=peter@passchier.net; keydata= xsFNBFjfL8gBEACS/gbEHElY/U03Z70OrsYstUl/0LlFWI3iJxn81XkFA7xN8ni02FWoVA9b lBB1mKmxDiGwsMVYpXAirGZGpkTKWdMFJOw4e7/Vq6SDWif3L4TaFFHquHenROlqRxjPVlHM ZEu94Nt+t+mnvSmiXNmFeL1Rlryuzj8u+9qFkaiUecvUacEaKbF0sJwG51uaCLTUE/HFiJeH vNNTD+Hlo7d4wNCg1lY5CFHOeRcyJ1IhamAsjliew+yuN3l4KxG1V5GAbKHf2O72m36HStRl LL6pGa7VYvOAwstw35dK1Rc8bRW0f9ICdIipc7ijNgE+NFD6gRdbmWPhHI7C0+3DejFUhTwu iMCsUoD5h1u0z/0V28rjBcVcpXLjUVFdAt+JhjBebB1RFVpmqw4D6D0TwahoX/8ixYe3zRTa 2A/lLcdPCFOdqw3d7vv+txbSw7lJNeayoId7P1ZmiSga5zs+mnl+RQch8P5ihIygfZlIOn44 DJx7xScMm5ixcygp1EGWqKePrMsjl71fo6p4S0j+81yuW0U5Q4/WAxBZSzeNq4/CduBKn9fW FIuZfYeSZjy1bxsPyOYLxnt2TE+ldgGIMl5GW6MEtz3FwRPMgtNpSy1Eo07ec899rNUOxeb2 e3FtfLzAcxRoxc5SY9PnfttJvESACBiCAShU4LMMLJKEMfsCIQARAQABzSVQZXRlciBQYXNz Y2hpZXIgPHBldGVyQHBhc3NjaGllci5uZXQ+wsF9BBMBCAAnBQJY3y/IAhsjBQkJZgGABQsJ CAcCBhUICQoLAgQWAgMBAh4BAheAAAoJEA5oUwj0rP2e8aIP/31WesFGDSIzaRFoqXBv9gPx uhMi3pcnfag20a76035E2TohSzQlWQ84gR6Ts5HfbFnazly0/UP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FJLQxhyri9wxCYIkMIIwHW7Q8C iNFHG5bHAuU6IYe2fG5g/37U6i/2mExX7k2aM8TQk0XraezhKbd9dvYKoweGLpnFNpapIXWZ hjwSH1emfPQ4OZ2T8jHnI1oJfJz00BIMRzwDnVUOfD9+35BEAJZJhTRGOXV2HTzBCXXenWSO 37xglYrJGpsWjQBEgPhRtdHv6TFrbKEFFZOXN1VHi9Qwhw2dBdZLK+CypSNH1wARAQABwsFl BBgBCAAPBQJY3y/IAhsMBQkJZgGAAAoJEA5oUwj0rP2e6vUP/Aw6/gSe6cVl3djCJBut3Sfh ixxV53VzDcb5fMQHx/5D1XqDSAwgFP8FhTYjUTWjZ5MzFleLuv8Q3ZPY4OAztJk95byToGpS xJkBJCzciH5pYpQ7RZmkFLXlux5YLnAao8DMqQdqhcIvINIHOZx8s24K89K6xxOXidg4ZIbN Py53tMZDB18baiD1n4/3X4z/06Ux4wPOB4j3zR0CdGjKECv9l4Dwf1EAKFupvN9ttwQF/4UB W5eQZkGBdwAFXPZ90Z/WMxgeCAkzQ2oWTUS3s19TYbeqCIR+1TBlQZx1g0iHrnGvj5gZH7YG ntDw+cvyF+72thtbyhEjIzqlAE65RyWSoRgfdEDzx0KLl7flv77eK58p7+/9yFtVZ5lj9ckt yrm9okNLnHOwzQhNScqL8MTL3OkHchZe8YxnwMPwx421khVMeQH8kwID/pAbXwagdm3rkHPs 8mOP29kfzk5aOWxYETmTO5AreFhps8D9fIYYk1oUQNqjuiT0TEPIVp9YkUULZwRj34CYbxVA FTQu9ykyJofZsBgj+KCEkenZqamx7ISuOomCu3LsFMaQP7AQbWWUgYPZYSRKqP+ziZBbIQRk pkEeXXNtjfST0zR0rcM9E/Wp9eJLHvUSKGmzkfrOFXA4InSwGvwhNxkDFRgVkK0nAOwn3/BY ehXgcjIoeiMn
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0
In-Reply-To <acc5bff9-868a-31be-7439-c014fc517122@inlv.org>
Content-Language en-US
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - cp-am01.wswcp.net
X-AntiAbuse Original Domain - gnu.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - passchier.net
X-Get-Message-Sender-Via cp-am01.wswcp.net: authenticated_id: mailcollector@passchier.net
X-Authenticated-Sender cp-am01.wswcp.net: mailcollector@passchier.net
X-Source
X-Source-Args
X-Source-Dir
X-detected-operating-system by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From 209.200.61.138
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14272

Show key headers only | View raw


Thank you for the feedback, very insightful. Yes, scratch that first
'example'. Yay for the here-variable redirection!

I am surprised by the general internal usage of temporary files for
here-documents & here-strings, because (generally speaking) memory is
quite abundant, and here-strings and even here-documents are usually not
huge. I can see for memory-depleted systems this might be an issue, and
there are no definite guarantees about the eventual size that is
required, but (again, generally) this could all be done in memory. (And
how about storage-depleted systems??)

Peter


On 06/24/2018 05:38 PM, Martijn Dekker wrote:
> Op 24-06-18 om 05:08 schreef Peter Passchier:
>> With memory being abundant and filesystem access expensive, I want to
>> put stdout and stderr of a command into variables (without needing to
>> write to a file):
>>
>> output=$($command 2>>>errors)
> 
> This would not work even if the feature is implemented. The $(command
> substitution) forks a subshell process to execute the command in,
> because the main shell process needs a process it can set up a pipe
> with. So the 'errors' variable would only exist in that subshell process
> and would be lost as soon as the command substitution completes.
> 
>> Or:
>>
>> $command >>>output 2>>>errors
> 
> This form seems conceivable to me.
> 
> However, note that here-documents and here-strings internally use
> temporary files, so they do involve file system access. I'm not Chet,
> but I don't think that would be different for your proposed feature. So
> while this might be some nice syntactic sugar, I'm afraid you would be
> disappointed about the performance.
> 
> I still kind of like the idea, though. As far as I know, there's
> currently no way to capture more than one output stream into separate
> variables without involving rather laborious handling of temporary
> files. Your proposal would probably still involve that, but the shell
> would do the hard work for you which seems like an improvement to me.
> 
> BTW, 'reverse here-document' doesn't sound quite right. You're not
> specifying any document or string containing input, you're specifying a
> variable in which to store output. So, here-variable?
> 
> - M.
> 

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


Thread

Re: Directing into a variable doesn't work Peter Passchier <peter@passchier.net> - 2018-06-24 22:26 +0700

csiph-web