help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: is there a way to save stdout and stderr to two bash variables?


From: Chet Ramey
Subject: Re: is there a way to save stdout and stderr to two bash variables?
Date: Tue, 12 May 2020 14:20:29 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.8.0

On 5/12/20 1:52 PM, Peng Yu wrote:
>> You have to turn that memory into a file descriptor. There are a few ways
>> to do that: a temp file, a pipe, and mmap-style file mapping (which
>> requires a file and file descriptor anyway). The devel branch uses pipes
>> if the here document or here string is smaller than the pipe size,
> 
> So on Linux, if a string is less than 65,536 byte, pipe is used
> instead of a tempfile?

Pretty much, but the actual pipe capacity is computed at build time. Also,
since Linux processes can reduce the pipe capacity, there's a run-time
check to ensure that the expanded document is shorter than the current
capacity. Look at redir.c:here_document_to_fd().


>> and
>> a temp file otherwise.
> 
> Is the tempfile location affected by environment variables like TMPDIR?

Yes. Look at lib/sh/tmpfile.c.


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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]