Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between running the script as ./script.sh and . ./script.sh [duplicate]

Tags:

bash

Possible Duplicate:
Difference between launching a script with ./script.sh and . ./script.sh

What is difference between running the script as ./script.sh and . ./script.sh

like image 967
Ravi Avatar asked Jan 28 '26 16:01

Ravi


1 Answers

The sourced in (. ./script.sh) script runs in the same shell. Meaning that if it issues exit, your shell exits, if it sets environment variable, your shell is affected, etc. Normally, you want to run scripts in isolated subprocess (./script.sh).

like image 181
Michael Krelin - hacker Avatar answered Jan 31 '26 07:01

Michael Krelin - hacker