Variable value inconsistency on BASH and CSH

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.

no offense, but i've been working on solaris for 20 years. it works fine.

your logic and implementation of this problem is a little obscure.

to me, it looks like your output ~should~ be this:

123a123b123c

since it looks like you're appending data AND input each time.

the problem may be that using the HERE document creates a subshell,
wherein variable changes are not exported.

So. I think a better sample of your input data and expected output would
be in order and really help us to find a solution.

Quirkasaurus,
$data="123"
I want this to be concatenated with $input:
So the expected output would be:

"123abc".

This is happening as expected on BASH and also on KSH. CSH, like you said is creating a subshell and hence the variable value is not reflected.

I was hoping for inputs on some other approach to replace the current so that I can loop on the contents of a variable, line by line.