./script creates a new shell and executes each command in the script within the new shell. When the end of the script file is encountered, the new shell exits. Any changes in the new shell caused by the script are lost when the shell exits.
For example, if the file
/home/user/sample/script/test contains...
cd /usr/games
pwd
echo hi
Then the command sequence would yield the following output:
prompt>cd /home/user/sample/script
prompt>pwd
/home/user/sample/script
prompt>chmod +x test
prompt>./test
/usr/games
hi
prompt>pwd
/home/user/sample/script
source Execution
source execute a shell script within the context of the current shell. Since execution takes place within the context of the current shell, any changes in the shell are retained following the completion of the shell.
Example:
prompt>cd /home/user/sample/script
prompt>pwd
/home/user/sample/script
prompt>source test
/usr/games
hi
prompt>pwd
/usr/games
Execing a <command> (ie. shell script or executable) means give exec <command> on the shell prompt.
The exec command will execute a command in place of the current shell, that is, it terminates the current shell and starts a new process in its place.
exec was often used to execute the last command of a shell script. This would kill the shell slightly earlier; otherwise, the shell would wait until the last command was finished. This practice saves a process and some memory.
try exec ls. you will be logged out from your login shell.
exec also manipulates file descriptors in the Bourne shell.
$exec >>logoutput
after issuing this command you will not see output of any command in your console. all output goes into logoutput file.
use exec >/dev/console to return.
$exec 2>errs.out
means that from then on, stderr goes into errs.out file
Tom's summary
1) ./set-env.sh --> start new shell, run it, the new shell exits. --> Env variables not set in the current shell.
2) source ./set-env.sh --> run it the current shell. --> Env variables are set in the current shell.
3) exec ./set-env.sh --> terminate the current shell, start new shell, run it. --> Maybe you just log off immediately.
分享到:
相关推荐
Certified Application Associate - SAP S/4HANA Sourcing and Procurement
将vendor/rela589n/doctrine-event-sourcing/config/mappings/为比您的映射具有更高优先级的学说映射目录。 入门 将事件源引入领域模型 用您的实体实现\Rela589n\DoctrineEventSourcing\Entity\AggregateRoot 。 ...
Sourcing knowledge, 行业的通用名词解释
Sourcing and Procurement-Central Procurement Sourcing and Procurement-Invoice Integration Sourcing and Procurement-Operational Purchasing Sourcing and Procurement-Procurement Analytics Sourcing and ...
Sourcing Manager英文简历模板.doc
Global Sourcing Purchasing Manager英文简历模板.doc
Guru e-Sourcing是一个完整的供应商寻源的解决方案,为企业提供了供应商入口门户,基于B/S的多层结构和XML技术,实现企业与供应商数据的双向在线传输。供应商只需要通过因特网登录,即可向企业提供其产品资料,进行...
Laravel开发-event-sourcing 活动采购包
Sourcing and Procurement-Central Procurement Sourcing and Procurement-Invoice Integration Sourcing and Procurement-Operational Purchasing Sourcing and Procurement-Procurement Analytics Sourcing and ...
Strategic Sourcing: Configuration GuideThis Business Scenario Configuration Guide for Strategic Sourcing describes the general configuration steps required to set up the strategic sourcing scenario as...
Sourcing and Procurement-Central Procurement Sourcing and Procurement-Invoice Integration Sourcing and Procurement-Operational Purchasing Sourcing and Procurement-Procurement Analytics Sourcing and ...
event-sourcing, Meteor的CQRS和事件采购基础架构 用于 Meteor的 CQRS &事件源 这个包提供了构建你的Meteor 应用程序的基础设施,以英镑 ( 命令/查询职责分离) 和英镑事件采购原则为基础。 这样可以使用强大的业务...
SAP S4HANA Sourcing and Procurement题.docx
Effective Supply@Sourcing
rails-event-sourcing-example, 带有RabbitMQ的Rails 事件 RabbitMQ事件源示例 运行示例 1确保已经安装并运行 RabbitMQ在macosx上,你可以使用 Homebrew 安装 RabbitMQ$ brew install rabbitmq开始使用$/u
Event sourcing
商务英语原文--B2b Market What Do Global Sourcing Companies Expect
同源开发相关书籍,里面有讲述什么是同源开发,如何去做同源开发。
Sourcing and Procurement-Central Procurement Sourcing and Procurement-Invoice Integration Sourcing and Procurement-Operational Purchasing Sourcing and Procurement-Procurement Analytics Sourcing and ...
Sourcing and Procurement-Central Procurement Sourcing and Procurement-Invoice Integration Sourcing and Procurement-Operational Purchasing Sourcing and Procurement-Procurement Analytics Sourcing and ...