May God never give you the bane of working on Solaris. Now, I am trying to run this simple shell script:
#!/bin/sh
input="a
b
c"
data="123"
while read eachline
do
data="$data$eachline"
done << EOF
$(echo "$input")
EOF
echo "$data"
exit 0
On RHEL(BASH) I receive output as expected i.e "123abc", however, on Solaris I receive just "123".
After fair bit of googling, I realized that Solaris is forking a process for code inside the while loop and hence the variable's($data) value is not reflected on the outside of while loop.
Any hope to make this code compatible on both platforms would be greatly appreciated.
And oh yes, using a temp file for redirection would not be a very elegant solution :| .