bug-bash
[Top][All Lists]
Advanced

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

[no subject]


From: Beorn Harris
Subject:
Date: Thu, 11 Sep 2014 15:45:02 +0200

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: solaris2.10
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
-DCONF_OSTYPE='solaris2.10' -DCONF_MACHTYPE='i386-pc-solaris2.10'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/local/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H -DSOLARIS   -I.  -I. -I./include -I./lib
 -I/usr/local/include -I/usr/local/ssl/include -I/usr/local/include/ncurses
-I/usr/openwin/include -I/usr/local/rrdtool-1.4.2/include
-I/usr/local/BerkeleyDB.4.7/include -I/usr/local/include/pcap
-I/usr/local/include/freetype2 -I/usr/include/mps -O2 -march=i686
-L/usr/local/lib -R/usr/local/lib -L/usr/local/ssl/lib -R/usr/local/ssl/lib
-L/usr/openwin/lib -R/usr/openwin/lib -I/usr/local/rrdtool-1.4.2/include
-I/usr/local/BerkeleyDB.4.7/include -I/usr/local/mysql/include
uname output: SunOS mxdev01ap1 5.10 Generic_142910-17 i86pc i386 i86pc
Machine Type: i386-pc-solaris2.10

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

Description:
Under certain (specific) circumstances, the bash "read" built-in is not
receiving (or is ignoring) the IFS separator.  This behaviour is
demonstrated with the code below, along with a workaround to achieve the
expected results.
This appears to be a regression, as the issue does not occur in bash
3.00.16 - the default on the test system.

GNU bash, version 3.00.16(1)-release (i386-pc-solaris2.10)
Copyright (C) 2004 Free Software Foundation, Inc.


Repeat-By:
The following can be used to replicate the results....

function test() {
   ## The following can be used to test different combinations of
delimiters, if required.
   #local __FLDSEP='.'
   #local __RECSEP='#'
   function WriteVal() {
      ## default local variables from the global counterparts.
      declare __FLDSEP=${__FLDSEP:-;}
      declare __RECSEP=${__RECSEP:-+}
      ## Write a record that can be read by the ReadVal counterpart
      printf "%s${__FLDSEP}" "$@"
      printf "${__RECSEP}"
   }
   function ReadVal() {
      ## default local variables from the global counterparts.
      ## NOTE:- bug does not occur if the local variable is not set
      declare __FLDSEP=${__FLDSEP:-;}
      declare __RECSEP=${__RECSEP:-+}
      ## Validate that the field sep is correct
      echo "Before read, separator='$__FLDSEP'"
      ## The following is the line of code that produces the Bug
      IFS="${__FLDSEP}"  read -r -d "${__RECSEP}" "$@" dummy
      ## The following 2 lines are a workaround that will give the expected
results
      #local IFS="${__FLDSEP}"
      #read -r -d "${__RECSEP}" "$@" dummy
   }
   function testcase() {
      ## The following will give the expected results in Scenario 2,
      ## but not scenario 1
      WriteVal X Y </dev/null | {
         ReadVal f perms
         echo "testcase $1 - scenario 1>>>[[$f]]";
      }
      echo
      ## The following will give the expected results in all scenarios
      {
         ReadVal f perms
         echo "testcase $1 - scenario 2>>>[[$f]]";
      } < <( WriteVal X Y )
   }
   ## Test Case 1 - Expected results
   echo "================================="
   testcase 1
   echo "================================="
   ## Test Case 2 - Unexpected results for Scenario 1
   cat < <(
      testcase 2
   )
   echo "================================="
}


reply via email to

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