On 1/2/14, 2:35 PM, P Fudd wrote: > Here's some more oddities: > > =====failing.sh: > #!/bin/bash > R="1|2" > IFS='|' read -r A B <<< $R > echo A=$A, B=$B > ==== > Expected: "A=1, B=2" > Actual: "A=1 2, B="
This is a bug in bash-4.2. The expansion of $R is not supposed to be subject to the value of IFS. You can read a discussion of the issue here: http://lists.gnu.org/archive/html/bug-bash/2013-01/msg00041.html > ====fail2.sh: > #!/bin/bash > R="1|2" > while IFS='|' read -r A B; do > echo 1:A=$A, B=$B > done <<< $R > echo 2:A=$A, B=$B A and B will be unset when the second `read' hits EOF and returns failure, breaking the loop. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/