shell embedding and options

shell embedding

Shells can be embedded on the command line, or in other words, the command line scan can spawn new processes containing a fork of the current shell. You can use variables to prove that new shells are created. In the screenshot below, the variable $var1 only exists in the (temporary) sub shell.

options

You can embed a shell in an embedded shell, this is called nested embedding of shells.

shellsub

backticks

Single embedding can be useful to avoid changing your current directory. The screenshot below uses backticks instead of dollar-bracket to embed.

password

You can only use the $() notation to nest embedded shells, backticks cannot do this.

backticks or single quotes

Placing the embedding between backticks uses one character less than the dollar and parenthesis combo. Be careful however, backticks are often confused with single quotes. The technical difference between ‘ and ` is significant!

timee

shell options

Both set and unset are builtin shell commands. They can be used to set options of the bash shell itself. The next example will clarify this. By default, the shell will treat unset variablesas a variable having no value. By setting the -u option, the shell will treat any reference to unset variables as an error. See the man page of bash for more information.

root

To list all the set options for your shell, use echo $-.

add

For any query or issue, feel free to discuss on http://discuss.eduguru.in