Path: csiph.com!au2pb.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!news.glorb.com!usenet.stanford.edu!not-for-mail From: Linda Walsh Newsgroups: gnu.bash.bug Subject: Re: redirecting a file descriptor to an array variable? Possible? How? RFE? Date: Wed, 18 Nov 2015 10:46:57 -0800 Lines: 52 Approved: bug-bash@gnu.org Message-ID: References: <564532BD.60801@tlinx.org> NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: usenet.stanford.edu 1447872429 22901 208.118.235.17 (18 Nov 2015 18:47:09 GMT) X-Complaints-To: action@cs.stanford.edu Cc: bug-bash To: konsolebox Envelope-to: bug-bash@gnu.org User-Agent: Thunderbird In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 173.164.175.65 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11905 konsolebox wrote: > On Fri, Nov 13, 2015 at 8:45 AM, Linda Walsh wrote: >> I'd like to be able to record stdout and stderr >> without using any temp files into bash array files, AND >> record the status of the command executed. >> > > You can use coproc processes that would act as buffers. > Obvious Note: Avoid it if you're conservative about some undocumented > areas that would look too hacky to you. ---- More often people think my code looks hacky because I haven't used alot of Integrated GUI+Devel platforms, Re... using coprocs.... hadn't even though of those (probably since I haven't had good luck with them working the way I expected). Maybe I'll work w/that, or maybe will try a refactor of my current code to combine the output streams in 1 sub and that might make my return of the 'exit code'($?) easier. > # TODO: Not sure how a proper coproc cleanup is done. Closing > FDs does funny things. Perhaps it's automatic, but not sure how > disown affects it. We could examine the source code but not sure if > that would be reliable enough for all versions of bash including the > upcoming ones. ---- One thing I found useful is where you have 2 procs talking over a pipe, and the reader needs time to finish the pipe read before parent closes it. So instead of just closing a pipe, I open a pair of pipes w/1 going in reverse direction. Then parent can send various control commands to child while the child is generating output so the child won't end prematurely. As mentioned, was close but wasn't feeling right about it. But some things that simplify my life. I'm running commands that talk to the terminal. None of them _should_ be putting out NULs... and going off on red-herring rat-holes isn't the best way to get something that works. One thing that seems to be another problem. Greg called my attention to another printf format bug: %q causes printf to output the corresponding argument in a format that can be reused as shell input. Which it doesn't when nuls are involved.