Re: Long variable value get corrupted sometimes

2022-02-16 Thread Daniel Qian
Thanks for your tips, a lot learned. Greg Wooledge 于2022年2月16日周三 20:47写道: > > On Wed, Feb 16, 2022 at 04:10:40PM +0800, Daniel Qian wrote: > > FOO=$(cat /tmp/foo.txt) > > got_md5=$(echo "$FOO" | md5sum -b | cut -d ' ' -f 1) > > In addition to what other people have said... echo is not reliable.

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Lawrence Velázquez
On Wed, Feb 16, 2022, at 8:27 PM, Daniel Qian wrote: > I'm not familiar with Bash version/release policy, I only found 5.1.8, > 5.1.12, 5.1.16 at > download page https://ftp.gnu.org/gnu/bash/ > > Is this fix included in 5.1.16 version? Yes, bash 5.1.16 is bash 5.1 with patch 16 and all previous of

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Daniel Qian
> I encountered a problem that long variable value get corrupted sometimes. > > > > OS: Alpine linux 3.15.0 (docker container) > > Bash version: GNU bash, version 5.1.8(1)-release (x86_64-alpine-linux-musl) > > > > Reproduction steps: > > > > A UT

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Chet Ramey
On 2/16/22 3:10 AM, Daniel Qian wrote: > Hi all, > > I encountered a problem that long variable value get corrupted sometimes. > > OS: Alpine linux 3.15.0 (docker container) > Bash version: GNU bash, version 5.1.8(1)-release (x86_64-alpine-linux-musl) > > Reproduc

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Greg Wooledge
On Wed, Feb 16, 2022 at 02:53:43PM +0100, Léa Gris wrote: > Le 16/02/2022 à 13:43, Greg Wooledge écrivait : > > text=$(cat /tmp/foo.txt; printf x) > > text=${text%x} > > or read -r -d '' text > witch saves a sub-shell You forgot IFS= there. Without that, it'll strip leading/trailing IFS whites

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Léa Gris
Le 16/02/2022 à 13:43, Greg Wooledge écrivait : text=$(cat /tmp/foo.txt; printf x) text=${text%x} or read -r -d '' text

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Greg Wooledge
On Wed, Feb 16, 2022 at 04:10:40PM +0800, Daniel Qian wrote: > FOO=$(cat /tmp/foo.txt) > got_md5=$(echo "$FOO" | md5sum -b | cut -d ' ' -f 1) In addition to what other people have said... echo is not reliable. It may alter your text, if you feed it backslashes, or arguments like "-e" or "-n". te

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Alex fxmbsw7 Ratchev
does the data contain \0 null bytes On Wed, Feb 16, 2022 at 11:20 AM David wrote: > On Wed, 16 Feb 2022 at 19:38, Daniel Qian wrote: > > > I encountered a problem that long variable value get corrupted sometimes. > > > A UTF-8 encoded file containing a lot of Chinese

Re: Long variable value get corrupted sometimes

2022-02-16 Thread David
On Wed, 16 Feb 2022 at 19:38, Daniel Qian wrote: > I encountered a problem that long variable value get corrupted sometimes. > A UTF-8 encoded file containing a lot of Chinese characters, file size ~35K. > FOO=$(cat /tmp/foo.txt) Hi, this looks like something that was recently fixed

Re: Long variable value get corrupted sometimes

2022-02-16 Thread Robert Elz
Date:Wed, 16 Feb 2022 16:10:40 +0800 From:Daniel Qian Message-ID: | I encountered a problem that long variable valur get corrupteds | sometimes. That looks like the bug tgat is fixed by patch 14 to bash 5.1 Your bash is only at patch 8. Get all the released pa

Long variable value get corrupted sometimes

2022-02-16 Thread Daniel Qian
Hi all, I encountered a problem that long variable value get corrupted sometimes. OS: Alpine linux 3.15.0 (docker container) Bash version: GNU bash, version 5.1.8(1)-release (x86_64-alpine-linux-musl) Reproduction steps: A UTF-8 encoded file containing a lot of Chinese characters, file size