O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Subshells

Subshells are generated whenever you enclose commands in ()'s, perform command substitution, for background processes, and for co-processes (discussed later in Chapter 8). A subshell is a separate copy of the parent shell, so variables, functions, and aliases from the parent shell are available to the subshell. However, subshells cannot change the value of parent shell variables, functions, or aliases. So if we set LOCALVAR to a value in the current shell:

					$ LOCALVAR="This is the original value"
				

then check the value in a subshell, we see that it is defined:

					$ (print $LOCALVAR)
					This is the original value
				

If we set it in the subshell to another value:

					$ (LOCALVAR="This is the new value")
				

then check the value in the parent shell, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required