Configuration: OS: Fedora 11 - with all updates applied Bash: version 4.0.23(1)-release
Problem description: When stdin is a pipeline to 'mapfile', 'readarray', and 'read -a' shell built-in commands, they fail to assign any values to the target array. The array is neither unset nor altered in any way. No error message is produced, and $? == 0. None of the available options have any effect on this behavior. Oddly, when input is provided via keyboard or redirection (<), these commands function properly. This last point seems really weird to me and points to the built-ins' or shell's internal handling of a pipeline. mapfile/readarray example (mapfile behaves identically to readarray): $ ls -a | readarray # using the default MAPFILE array $ echo $? 0 $ echo "${#mapfi...@]}" 0 $ Other forms of mapfile/readarray that fail: $ ls -a | readarray -u0 # specified input file descriptor $ echo "${#mapfi...@]}" 0 $ $ declare -a myArray # (optional) Declaring myArray has no effect $ ls -a | readarray myArray $ echo "${#myarr...@]}" 0 $ read -a example: $ ls -a | read -a myArray $ echo "${#myarr...@]}" 0 $ The other ways of using stdin (i.e. keyboard, file redirection) work fine. For example: mapfile/readarray keyboard: $ readarray myArray # input from keyboard 1 line 2 3 [cntl-D] $ echo "${#myarr...@]}" 3 $ mapfile/readarray redirection: $ ls -a > foo $ readarray myArray < foo $ echo "${#myarr...@]}" 6 $ read -a redirection: $ ls -a > foo $ read -a myArray < foo $ echo "${#myarr...@]}" 1 $ Rob Robason r...@robason.net 925-825-1512