"for loop" problem in bash-3.2 on Freebsd-4.11release

2007-12-19 Thread showrun . lee
Machine: i386
OS: freebsd4.11
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='
freebsd4.11' -DCONF_MACHTYPE='i386-unknown-freebsd4.11'
-DCONF_VENDOR='unknown'
-DLOCALEDIR='/home/lihongliang/libiconv/share/locale' -DPACKAGE='bash'
-DSHELL  -DHAVE_CONFIG_H   -I.  -I. -
I./include -I./lib -I./lib/intl -I/usr/home/lihongliang/bash-3.2/lib/intl
-I/home/lihongliang/libiconv//include -g -O2
uname output: FreeBSD dev1.corp.qihoo.net 4.11-RELEASE-p14 FreeBSD
4.11-RELEASE-p14 #0: Wed Apr  5 14:46:54 CST 2006 [EMAIL PROTECTED]
orp.qihoo.net:/usr/src/sys/compile/GENERIC  i386
Machine Type: i386-unknown-freebsd4.11

Bash Version: 3.2
Patch Level: 0
Release Status: release

Description:
I got a problem when i upgrade bash to 3.2。
I have a shell script,for example:
#cat test.sh
files=  switches=
for arg
do
case "$arg" in
-*) switches="$switches $arg" ;;
*)  files="$files $arg" ;;
esac
done

echo $switches
echo $files

if I use the /bin/sh,or bash-2.0.5b,and on freebsd6.2 with
bash-3.2,everything is ok。but got problem with bash-3.2 on freebsd4.11。
#sh ./test1.sh -a -b a
-a -b
a

bash-3.2$ ./bash ./test1.sh -a -b a




I think the problem is the "for loop",in every loop, $arg can't be $1 $2 $3
respectly。

perhaps,this is a bug or others.

thanks


bash incompatible with sh,maybe this is a bug

2007-12-24 Thread showrun . lee
Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: freebsd6.2
Compiler: cc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' -DCONF_OSTYPE='
freebsd6.2' -DCONF_MACHTYPE='i386-portbld-freebsd6.2' -D
CONF_VENDOR='portbld' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash'
-DSHELL  -DHAVE_CONFIG_H   -I.  -I. -I./include -I./lib
  -I/usr/local/include -O2 -fno-strict-aliasing -pipe
uname output: FreeBSD log1.ops.lfc.qihoo.net 6.2-RELEASE FreeBSD
6.2-RELEASE#0: Thu Dec  6 15:15:26 CST 2007
[EMAIL PROTECTED]
qihoo.net:/usr/obj/usr/src/sys/GENERIC  i386
Machine Type: i386-portbld-freebsd6.2

Bash Version: 3.1
Patch Level: 17
Release Status: release


Description:
for example,I have a shell script test.sh

#cat test.sh
test="mama";
test1="";
echo "test is $test";

[  !  "$test"  -a "$test1"  ] && test="papa";

echo "test is $test";
###script end

if i use sh,the result which is I wanted,is :
[EMAIL PROTECTED] sh test1.sh
test is mama
test is mama

if i use bash, the result is :
[EMAIL PROTECTED] bash test1.sh
test is mama
test is papa

I think ,this is a bug in bash.and i test it on many freebsd release 4.11,
6.1,6.2 with default bash version,this is same.