"./somescript.sh"和"./somescript.sh"之间有什么区别?和". ./somescript.sh" [英] What is the difference between "./somescript.sh" and ". ./somescript.sh"

查看:89
本文介绍了"./somescript.sh"和"./somescript.sh"之间有什么区别?和". ./somescript.sh"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天,我按照一些说明在Linux中安装软件.有一个脚本需要首先运行.它设置一些环境变量.

Today I was following some instructions to install a software in Linux. There was a script that needs to be run first. It sets some environment variables.

该指令告诉我执行. ./setup.sh,但是我通过执行./setup.sh犯了一个错误.因此未设置环境.最后,我注意到了这一点并继续进行.

The instruction told me to execute . ./setup.sh, but I made a mistake by executing ./setup.sh. So the env was not set. Finally I noticed this and proceeded.

我想知道这两种调用脚本方法之间的区别.我对Linux完全陌生,因此请尽可能详细.

I want to know the difference between these two methods of invoking a script. I am completely new to Linux so please be as elaborate as possible.

推荐答案

./setup.sh运行该脚本,将启动一个新的运行该脚本的shell.新的外壳程序不会影响启动脚本的父外壳程序.

./setup.sh runs the script, a new shell will be started that runs the script. That new shell cannot affect the parent shell that started the script.

. ./setup.shsource ./setup.sh的简写,它将在当前shell中运行该脚本,而不是启动一个新的shell来运行它.这意味着脚本可以更改当前shell的行为,例如设置新的环境变量.

. ./setup.sh is a shorthand for source ./setup.sh and it will run the script in the current shell, instead of starting a new shell to run it. This means the script can alter the behavior of the current shell, e.g. set new environment variables.

这篇关于"./somescript.sh"和"./somescript.sh"之间有什么区别?和". ./somescript.sh"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆