read <<<$(myfunc) behavior differs between bash 4.2 and 4.4 -


i have code below read array list

#!/usr/local/bin/bash  function getlist {     printf "%q/\n" "foo"     printf "%q/\n" "bar" }  ifs="$(printf ' \n\t')" # ifs=" "  while read -r tmp;     echo "test"     echo $tmp done <<< $(getlist) 

4.2 bash output

$ ./test.sh test foo/ bar/ 

4.4 output

$ ./test.sh test foo/ test bar/ 

however, if change ifs=" ", behave same 4.4 (but delimiter \n, right?). wonder change has been made between these 2 versions

the issue isn't read it's not quoting herestring. if quote 4.4 results in both cases:

#!/usr/local/bin/bash  function getlist {     printf "%q/\n" "foo"     printf "%q/\n" "bar" }  ifs="$(printf ' \n\t')" # ifs=" "  while read -r tmp;     echo "test"     echo $tmp done <<< "$(getlist)" 

it's different in bash 4.4 because fixed deviation documentation found in release notes in:

z. bash no longer splits expansion of here-strings, documentation has said.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -