Current Shell & subshell & separate invocations

Source: Internet
Author: User

1. "Current Shell"
Commands enclosed in {} are executed in the current shell. there must be whitespace after the opening {, or else you get a syntax error. one more restriction: commands within the {}'s must be terminated with a semicolon when given on one line.

2. "subshell"
Commands enclosed in () are executed in a subshell.
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.

3. "separate invocations"
By default, things like variables, aliases, and functions from the current environment are not available to separate invocations of the Korn shell unless explicitly exported or exported in the environment file.
As with subshells, environment settings are not passed back to the parent Korn shell.

By default, KoRn shell scripts are run in a separate environment. this means that variables from the current environment are not available to Korn shell scripts unless explicitly exported, and variables defined in Korn shell scripts are not passed back to the parent shell.

4. ". command "
. command reads in a complete file, then executes the commands in it as if they were typed in at the prompt. this is done in the current shell, so any variable, alias, or function settings stay in effect. it is typically used to read in and execute a profile, environment, alias, or functions file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.