bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug: incorrect variable values when reading from file with 0d0a as newli


From: Sergey Skripnick
Subject: bug: incorrect variable values when reading from file with 0d0a as newlines
Date: Tue, 17 Dec 2013 15:18:31 +0200
User-agent: Opera Mail/12.16 (Linux)


Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include -I../bash/lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall uname output: Linux sskripnick-pc 3.11.0-14-generic #21-Ubuntu SMP Tue Nov 12 17:04:55 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 45
Release Status: release

Description:
When executed script (by `source' or by dot syntax) which have 0d0a characters as a newlines, readed variables have incorrect values. As you can see below, 0d character is included, but there is no 0d character between the quotes.

Repeat-By:
    Here the script for reproduce (dos2unix required)

---------------------------------------
cat > data<<EOF
VAR1="ok" # unused
VAR="ok"
VAR3="ok" # unused
EOF

cp data data-unix
mv data data-dos
unix2dos data-dos

. data-dos
echo $VAR | hexdump -C
[ $VAR = "ok" ] && echo "eq" || echo "ne"

. data-unix
echo $VAR | hexdump -C
[ $VAR = "ok" ] && echo "eq" || echo "ne"

---------------------------------------

The output is:
unix2dos: converting file data-dos to DOS format ...
00000000  6f 6b 0d 0a                                       |ok..|
00000004
ne
00000000  6f 6b 0a                                          |ok.|
00000003
eq




reply via email to

[Prev in Thread] Current Thread [Next in Thread]