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 ~35
runme.sh
#!/bin/bash
echo $0
echo $1
echo $2
echo $3
echo $4
echo $5
echo $6
command:
./runme.sh -q -w -e -r -t -y
produced output:
./get_env.sh
-q
-w
-r
-t
-y
expected output:
./get_env.sh
-q
-w
-e
-r
-t
-y
Regards,
Viktor Korsun, bite...@gmail.com
On Feb 16 2022, Viktor Korsun wrote:
> runme.sh
> #!/bin/bash
> echo $0
> echo $1
> echo $2
> echo $3
> echo $4
> echo $5
> echo $6
Don't use echo to print unknown text. Use printf instead, which can
handle this correctly. Also, don't forget to quote properly.
printf "%s\n" "$4"
>
> command:
On Wed, Feb 16, 2022 at 9:59 AM Andreas Schwab
wrote:
> On Feb 16 2022, Viktor Korsun wrote:
>
> > runme.sh
> > #!/bin/bash
> > echo $0
> > echo $1
> > echo $2
> > echo $3
> > echo $4
> > echo $5
> > echo $6
>
> Don't use echo to print unknown text. Use printf instead, which can
> handle this co
On Feb 10 2022, Chet Ramey wrote:
> On 2/10/22 9:53 AM, Andreas Schwab wrote:
>> On Jan 21 2022, Chet Ramey wrote:
>>
>>> i. The non-incremental history searches now leave the current history offset
>>> at the position of the last matching history entry, like incremental
>>> search.
>> That
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
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, perhaps
y
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 characters, file size
> ~35
On Wed, 16 Feb 2022 at 19:51, Viktor Korsun wrote:
> produced output:
> ./get_env.sh
> -q
> -w
>
> -r
> -t
> -y
>
> expected output:
> ./get_env.sh
> -q
> -w
> -e
> -r
> -t
> -y
Hi, this behaviour is well known history and widely discussed.
You can search the web for "printf vs echo bash" and yo
Thank you guys!
Regards,
Viktor Korsun, bite...@gmail.com
On Wed, 16 Feb 2022 at 22:09, Alex fxmbsw7 Ratchev
wrote:
>
>
> On Wed, Feb 16, 2022 at 9:59 AM Andreas Schwab
> wrote:
>
>> On Feb 16 2022, Viktor Korsun wrote:
>>
>> > runme.sh
>> > #!/bin/bash
>> > echo $0
>> > echo $1
>> > echo $2
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
Le 16/02/2022 à 13:43, Greg Wooledge écrivait :
text=$(cat /tmp/foo.txt; printf x)
text=${text%x}
or read -r -d '' text
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
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)
>
> Reproduction steps:
>
> A UTF-8 encoded
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?
Chet Ramey 于2022年2月16日周三 21:59写道:
>
> On 2/16/22 3:10 AM, Daniel Qian wrote:
> > Hi all,
> >
> > I encountered a problem th
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
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.
17 matches
Mail list logo