export passes variables to subprocesses, but that doesn't help getting the data back to the parent:
Code:
$ export x=fish |
Another way to fix the problem is to place the input into a file,
then redirection to have the while loop process the file i.e. ----------------------------------------------------------- Doesn't work due to pipe causing subprocess being created: ----------------------------------------------------------- export conflict=0 cat $filename | while read inline do conflict=1 done echo $conflict # get 0 -------------------- WORKS! -------------------- export conflict=0 while read inline do conflict=1 done < $filename echo $conflict # get 1 ! Since no pipe, no subprocess created, values in while loop retained |
All times are GMT -5. The time now is 04:01 PM. |