problem with for loop in subshell

problem with for loop in subshell

Post by Josh Blo » Sun, 11 Feb 1996 04:00:00

If anyone can help I would be appreciative. I am writing a bourne shell script
 that contains a function which contains a for loop. the for for loop
processes various thing of no concern to this issue. the problem is that the
for loop spawns a subshell and is effectively sent the backround. The rest of
the program continues to execute before the for loop within the function has a
chance to finish. For my purposes this isn't going to work. I tried using the
'wait $!' command, but to no avail. I am currently using sleep 20, but this is
weak. How do I get the script to wait until the for loop has finished before
the rest of the script is executed?
Please reply by e-mail as well as to the group.


1. 'While' loop starting a subshell?

Using the Bourne shell provided with SCO Unix 3.2.4 the following program
fails to retain a variable set in a 'while' loop:



while input=`line`
done <temp

echo "Variable is set to $variable"

In the above example 'temp' is just the name of any non-empty file.

The 'echo' command returns the value of 'old'.

This routine was to be used to load in lines from a config file, one
at a time so that variables could be set up in memory. It has turned
out to be of no use as the variables are lost when the 'while' ends.

Is there a simple way to read in lines of a file one at a time?

BTW: This does NOT happen using the Korn shell

Julian Hayward

2. Is it possible to...?

3. getting variables out of while loop subshells

4. Job Control on SGI 3130

5. `Nested (`Nested Subshells`) Subshells`

6. How do I install Linux????

7. tcsh - to subshell or not to subshell

8. WWW-Offline-reader for Unix?

9. Problem with subshell - execv on Aix 4.1.5

10. trap problem in subshell

11. problem exporting variable to subshells

12. find vs. $FIND, perhaps subshell problem

13. supraexpress modems (28.8) problems w/dial-ins