NetBSD-Bugs archive

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

bin/53548: here document of /bin/sh of today is broken



>Number:         53548
>Category:       bin
>Synopsis:       here document of /bin/sh of today is broken
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 24 11:25:00 +0000 2018
>Originator:     Ryo ONODERA
>Release:        NetBSD 8.99.24
>Organization:
	
>Environment:
	
	
System: NetBSD brownie 8.99.24 NetBSD 8.99.24 (DTRACE7) #1: Fri Aug 24 14:58:18 JST 2018 ryoon@brownie:/usr/world/8.99/amd64/obj/sys/arch/amd64/compile/DTRACE7 amd64
Architecture: x86_64
Machine: amd64
>Description:
	
Here document of /bin/sh of today on NetBSD/amd64-current is broken.
Test shell script is here:

$ cat test2.sh
#! /bin/sh

testfunc () {
all=$(echo $1)
enabled=$(echo $2)
for part in $all; do
  if $(echo $enabled | grep -q -E "(^| )$part($| )"); then
    echo "$part : enabled"
  else
    echo "$part : disabled"
  fi
done
}

items_all='A B C D'
items_enabled='B D'

cat > output.txt << EOF
$(testfunc "$items_all" "$items_enabled")
EOF

/bin/sh case:
$ /bin/sh test2.sh
$ cat output.txt
A : enabled
B : enabled
C : enabled
D : enabled

/bin/ksh case:
$ /bin/ksh test2.sh
$ cat output.txt
A : disabled
B : enabled
C : disabled
D : enabled

/bin/sh case is incorrect.

>How-To-Repeat:
See above.
	
>Fix:
	
I have no idea.

>Unformatted:
 	
 	


Home | Main Index | Thread Index | Old Index