On Sun, Jun 18, 2017 at 07:17:46PM -0700, L A Walsh wrote: > Oh? I want to read in a value from the registry where something may > have zeros > after the data. Please tell me the mechanism to read this in w/no warnings > that won't silence more serious cases of zero's other than at the end of > line.
IFS= read -rd '' regvalue < <(regcommand) This will read the content from the stream provided by regcommand, up to the first NUL, where it will stop. This is the general method used to read a NUL-delimited value from a command or pseudo-file. A command substitution is NOT preferred, because it converts the stream to a string (by dropping all NUL bytes, including those that are in between two separate values). An analogous common use-case on Linux: wooledg:~$ hd /proc/$$/cmdline 00000000 62 61 73 68 00 |bash.| 00000005 wooledg:~$ IFS= read -rd '' foo < /proc/$$/cmdline wooledg:~$ declare -p foo declare -- foo="bash" If your regcommand produces a stream with multiple items in it, like this: foo\0bar\0quux\0 Then the IFS= read -rd '' regvalue command will read "foo" (the first value) and stop, whereas a command substitution will give you the string "foobarquux" which is nonsense. (And in bash 4.4, you also get a warning, because doing that is bad. You should stop doing that.) Now, most of us on this mailing list do not use Microsoft Windows, and do not know what commands you are using, or what output they produce. So, if you want any more specific advice, you'll have to go back a step and explain what you're doing, what input you're dealing with, and what results you expect to achieve. It also helps if you use standard bash commands, and not your idiosyncratic aliases like "my" and "int". Some of us may remember that you do things like alias my=declare, but others will not. When reporting a bug, you want your report to be easily understandable and reproducible, without external references or guessing.