Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11884 > unrolled thread
| Started by | Linda Walsh <bash@tlinx.org> |
|---|---|
| First post | 2015-11-15 05:26 -0800 |
| Last post | 2015-11-15 05:26 -0800 |
| Articles | 1 — 1 participant |
Back to article view | Back to gnu.bash.bug
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: redirecting a file descriptor to an array variable? Possible? How? RFE? Linda Walsh <bash@tlinx.org> - 2015-11-15 05:26 -0800
| From | Linda Walsh <bash@tlinx.org> |
|---|---|
| Date | 2015-11-15 05:26 -0800 |
| Subject | Re: redirecting a file descriptor to an array variable? Possible? How? RFE? |
| Message-ID | <mailman.2373.1447656452.7904.bug-bash@gnu.org> |
Greg Wooledge wrote: > On Thu, Nov 12, 2015 at 04:45:49PM -0800, Linda Walsh wrote: >> I'm coming up with a null-record in my brain when I think >> about this: 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. > > There is no way to do this currently. Storing stdout and stderr > separately requires at least one temp file. (Actually in the most > general case, where those output streams may contain NUL bytes, > it requires two temp files, because you can't store arbitrary data > streams in bash variables at all.) ---- In the simple case, presume there are no NUL bytes. In the more complex case, presume readarray has a "-0" switch which uses null bytes (trimmed) as line separators. Note that printf *can* print out nul bytes: > printf "\"%c\"\n" $'\x00' |hexdump -C 00000000 22 00 22 0a |".".| 00000004 But contrary to the manpage under printf: " The -v option causes the output to be assigned to the variable var rather than being printed to the standard output. " printf does not print the output of the above into a var instead of stdout. Seems like that would be a bug? If I am in a locale using UTF-16, there will be lots of 'NUL' chars if I view that output as binary -- so there has to be one or more ways to encode NUL bytes in a var such that they don't terminate the string. Nevertheless, printf doesn't follow the documented behavior on the manpage and print stdout to the variable. If the issue of varables being able to contain any sequence of binary bytescould be solved, it might make it easier to solve the problem of streaming std[out/err] to a variable or an array. No?
Back to top | Article view | gnu.bash.bug
csiph-web