[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Problem with declare -a using a subcommand that parses data containing c
From: |
David Anderson |
Subject: |
Problem with declare -a using a subcommand that parses data containing ctrl-A characters. |
Date: |
Fri, 05 Jan 2007 15:25:40 -0700 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux
Compiler: gcc -I/usr/src/packages/BUILD/bash-3.1
-L/usr/src/packages/BUILD/bash-3.1/../readline-5.1
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux' -DCONF_MACHTYPE='x86_64-suse-linux'
-DCONF_VENDOR='suse' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O2
-fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g -D_GNU_SOURCE
-DRECYCLES_PIDS -Wall -pipe -g -fbranch-probabilities
uname output: Linux mahler 2.6.16.21-0.8-smp #1 SMP Mon Jul 3 18:25:39
UTC 2006 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux
Bash Version: 3.1
Patch Level: 17
Release Status: release
Description:
Not sure if this is a change to how things are to be done or a
bug. I've attached my test files and original bbug1 file.
I think the ctrl-as are giving my mailer a fit so bashbug didn't
send. Sorry if I'm including the same info twice.
When creating an array and populating it with a subcommands
output there has been a change between version
2.05b.0(1) and 3.1.17(1)
such that if your subcommands generate/parse ctrl-A data
the array is not populated as before.
When creating an array and populating it with a subcommands
output there has been a change between
version 2.05b.0(1) and 3.1.17(1)
such that if your subcommands generate/parse ctrl-A data
the array is not populated as before.
ie:
t='mhost110.2.2.12/10.2.2.11TCP000ALIVE200000000010.2.2.1110.2.2.121
mhost1/dev/ttyS1TTY38400349350ALIVE0020000204541645384(null)(null)99
'
declare -a COM=($(echo $t | head -n1 | awk -F '{print $1,$2,$3}'))
does not work under 3.1.17(1) but does under 2.05b.0(1)
Both version works the same without the ctrl-As
ie:
t1='mhost1:10.2.2.12/10.2.2.11:TCP:0:0:0:ALIVE:2:0:0:0:0:0:0:0:0:0:10.2.2.11:10.2.2.12:1
mhost1:/dev/ttyS1:TTY:38400:349:350:ALIVE:0:0:2:0:0:0:0:20:48892:48812:(null):(null):99'
declare -a COMC=($(echo $t1 | head -n1 | awk -F: '{print $1,$2,$3}'))
Repeat-By:
#!/bin/bash
#
# Test created by David B. Anderson dbanders @ gmail dot com
#
echo "Testing with: "
bash --version
echo " "
echo "Testing bash array declare using the output of a subshell that
contains control A characters."
t='mhost110.2.2.12/10.2.2.11TCP000ALIVE200000000010.2.2.1110.2.2.121
mhost1/dev/ttyS1TTY38400349350ALIVE0020000204541645384(null)(null)99
'
declare -a COM=($(echo $t | head -n1 | awk -F'' '{print $1,$2,$3}'))
echo "COM 0: should be 'mhost1' is '${COM[0]}'"
echo "COM 1: should be '10.2.2.12/10.2.2.11' is '${COM[1]}'"
echo "COM 2: should be 'TCP' is '${COM[2]}'"
if [ "x${COM[0]}" != "xmhost1" ]; then
echo "TEST: FAILED"
else
echo "TEST: PASSED"
fi
echo ""
echo "Testing bash array declare using the output of a subshell that
contains is the same as above with ':' instead of control A characters."
t1='mhost1:10.2.2.12/10.2.2.11:TCP:0:0:0:ALIVE:2:0:0:0:0:0:0:0:0:0:10.2.2.11:10.2.2.12:1
mhost1:/dev/ttyS1:TTY:38400:349:350:ALIVE:0:0:2:0:0:0:0:20:48892:48812:(null):(null):99'
declare -a COMC=($(echo $t1 | head -n1 | awk -F: '{print $1,$2,$3}'))
echo "COMC 0: should be 'mhost1' is '${COMC[0]}'"
echo "COMC 1: should be '10.2.2.12/10.2.2.11' is '${COMC[1]}'"
echo "COMC 2: should be 'TCP' is '${COMC[2]}'"
if [ "x${COMC[0]}" != "xmhost1" ]; then
echo "TEST: FAILED"
else
echo "TEST: PASSED"
fi
--- Begin Message ---
Subject: |
Problem with array declare using a subcommand that parses data containing ctrl-A characters. |
Date: |
Fri, 05 Jan 2007 15:24:45 -0700 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux
Compiler: gcc -I/usr/src/packages/BUILD/bash-3.1
-L/usr/src/packages/BUILD/bash-3.1/../readline-5.1
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux' -DCONF_MACHTYPE='x86_64-suse-linux' -DCONF_VENDOR='suse'
-DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I.
-I. -I./include -I./lib -O2 -fmessage-length=0 -Wall -D_FORTIFY_SOURCE=2 -g
-D_GNU_SOURCE -DRECYCLES_PIDS -Wall -pipe -g -fbranch-probabilities
uname output: Linux mahler 2.6.16.21-0.8-smp #1 SMP Mon Jul 3 18:25:39 UTC 2006
x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-suse-linux
Bash Version: 3.1
Patch Level: 17
Release Status: release
Description:
Not sure if this is a change to how things are to be done or a
bug.
When creating an array and populating it with a subcommands
output there has been a change between version
2.05b.0(1) and 3.1.17(1)
such that if your subcommands generate/parse ctrl-A data
the array is not populated as before.
When creating an array and populating it with a subcommands
output there has been a change between
version 2.05b.0(1) and 3.1.17(1)
such that if your subcommands generate/parse ctrl-A data
the array is not populated as before.
ie:
t='mhost110.2.2.12/10.2.2.11TCP000ALIVE200000000010.2.2.1110.2.2.121
mhost1/dev/ttyS1TTY38400349350ALIVE0020000204541645384(null)(null)99
'
declare -a COM=($(echo $t | head -n1 | awk -F '{print $1,$2,$3}'))
does not work under 3.1.17(1) but does under 2.05b.0(1)
Both version works the same without the ctrl-As
ie:
t1='mhost1:10.2.2.12/10.2.2.11:TCP:0:0:0:ALIVE:2:0:0:0:0:0:0:0:0:0:10.2.2.11:10.2.2.12:1
mhost1:/dev/ttyS1:TTY:38400:349:350:ALIVE:0:0:2:0:0:0:0:20:48892:48812:(null):(null):99'
declare -a COMC=($(echo $t1 | head -n1 | awk -F: '{print $1,$2,$3}'))
Repeat-By:
#!/bin/bash
#
# Test created by David B. Anderson dbanders @ gmail dot com
#
echo "Testing with: "
bash --version
echo " "
echo "Testing bash array declare using the output of a subshell that contains
control A characters."
t='mhost110.2.2.12/10.2.2.11TCP000ALIVE200000000010.2.2.1110.2.2.121
mhost1/dev/ttyS1TTY38400349350ALIVE0020000204541645384(null)(null)99
'
declare -a COM=($(echo $t | head -n1 | awk -F'' '{print $1,$2,$3}'))
echo "COM 0: should be 'mhost1' is '${COM[0]}'"
echo "COM 1: should be '10.2.2.12/10.2.2.11' is '${COM[1]}'"
echo "COM 2: should be 'TCP' is '${COM[2]}'"
if [ "x${COM[0]}" != "xmhost1" ]; then
echo "TEST: FAILED"
else
echo "TEST: PASSED"
fi
echo ""
echo "Testing bash array declare using the output of a subshell that contains
is the same as above with ':' instead of control A characters."
t1='mhost1:10.2.2.12/10.2.2.11:TCP:0:0:0:ALIVE:2:0:0:0:0:0:0:0:0:0:10.2.2.11:10.2.2.12:1
mhost1:/dev/ttyS1:TTY:38400:349:350:ALIVE:0:0:2:0:0:0:0:20:48892:48812:(null):(null):99'
declare -a COMC=($(echo $t1 | head -n1 | awk -F: '{print $1,$2,$3}'))
echo "COMC 0: should be 'mhost1' is '${COMC[0]}'"
echo "COMC 1: should be '10.2.2.12/10.2.2.11' is '${COMC[1]}'"
echo "COMC 2: should be 'TCP' is '${COMC[2]}'"
if [ "x${COMC[0]}" != "xmhost1" ]; then
echo "TEST: FAILED"
else
echo "TEST: PASSED"
fi
--- End Message ---
t1.test.sh
Description: application/shellscript