[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
read -a not generating zero length elements correctly
From: |
Neal H. Walfield |
Subject: |
read -a not generating zero length elements correctly |
Date: |
Wed, 10 Mar 2004 15:09:47 -0500 |
User-agent: |
Wanderlust/2.8.1 (Something) SEMI/1.14.3 (Ushinoya) FLIM/1.14.3 (UnebigoryĆmae) APEL/10.3 Emacs/21.2 (i386-debian-linux-gnu) MULE/5.0 (SAKAKI) |
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-pc-linux-gnu'
-DCONF_VENDOR='pc' -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include
-I../bash/lib -g -O2
uname output: Linux moore 2.4.22-1-686 #6 Sat Oct 4 14:09:08 EST 2003 i686
GNU/Linux
Machine Type: i386-pc-linux-gnu
Bash Version: 2.05b
Patch Level: 0
Release Status: release
Description:
Using read -a with IFS=: and empty strings yields unexpected
array contents.
Repeat-By:
#! /bin/bash
IFS=: read -a A <<EOF
:::
EOF
echo ${#A[@]}
echo \"${A[0]}\"
if test -z "${A[0]}"
then
echo FOO
else
echo BAR
fi
if test -z "$(echo -n \"${A[0]}\" | cat)"
then
echo FOO
else
echo BAR
fi
echo -n ${A[0]} | cat -vet
echo -n ${A[0]} | wc
Sample output:
$ bash ~/foo.sh
3
""
BAR
BAR
^? 0 0 1
$
Fix:
Unknown. I have not yet looked at the bash code.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- read -a not generating zero length elements correctly,
Neal H. Walfield <=