Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
scripting:processtree [2019/08/30 14:45] ersen [The process tree] |
scripting:processtree [2019/08/30 14:55] (current) ersen [Bash playing with pipes] |
||
---|---|---|---|
Line 58: | Line 58: | ||
</code> | </code> | ||
- | Note once again, ''ls'' can't influence the ''grep'' environment. ''grep'' can't influence the ''ls'' environmet, and neither ''grep'' nor ''ls'' can influence the ''bash'' environment. | + | Note once again, ''ls'' can't influence the ''grep'' environment, ''grep'' can't influence the ''ls'' environment, and neither ''grep'' nor ''ls'' can influence the ''bash'' environment. |
__**How is that related to shell programming?!?**__ | __**How is that related to shell programming?!?**__ | ||
Line 79: | Line 79: | ||
</code> | </code> | ||
- | See the relationship? The forked Bash process will count the lines like a charm. It will also set the variable ''counter'' as directed. But if everything ends, this extra process will be terminated - **your "counter" variable is gone** You see a 0 because in the main shell it was 0, and wasn't changed by the child process! | + | See the relationship? The forked Bash process will count the lines like a charm. It will also set the variable ''counter'' as directed. But if everything ends, this extra process will be terminated - **your "counter" variable is gone.** You see a 0 because in the main shell it was 0, and wasn't changed by the child process! |
__**So, how do we count the lines?**__ | __**So, how do we count the lines?**__ | ||
Line 91: | Line 91: | ||
</code> | </code> | ||
- | It's nearly self-explanitory. The ''while'' loop runs in the **current shell**, the counter is incremented in the **current shell**, everything vital happens in the **current shell**, also the ''read'' command sets the variable ''REPLY'' (the default if nothing is given), though we don't use it here. | + | It's nearly self-explanatory. The ''while'' loop runs in the **current shell**, the counter is incremented in the **current shell**, everything vital happens in the **current shell**, also the ''read'' command sets the variable ''REPLY'' (the default if nothing is given), though we don't use it here. |
===== Actions that create a subshell ===== | ===== Actions that create a subshell ===== | ||