Question : What does "(or .)" mean in the statement "script0 will see the variables only if it calls script1 with source (or .)"

There are three scripts: script0.sh, script1.sh and script2.sh

script0.sh calls script1.sh and script1.sh calls script2.sh using source

script1.sh and script2.sh can use and modify each other's variables

The statement above "script0 will see the variables only if it calls script1 with source (or .)" was in answer to under what circumstances can script0.sh (which calls script1.sh) see the variables in script1.sh and script2sh.

I understand the if it calls script1.sh with source it will see the variables but what does the dot mean? I tried ./script1.sh and that did not work (to my relief actually).

An example please of the dot in script0.sh causing it to see script1.sh and script2.sh variables.

Thank you.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
== script0.sh ==
(some code NOT source that calls script1.sh so it can see script1.sh variables)
 
== script1.sh == 
#!/bin/bash
_name="script1.sh via source"
source script2.sh $*
echo The user is $_user and the password is $_password
 
== script2.sh ==
#!/bin/bash
echo script2.sh was called from $_name
echo The parameters are $1 $2 $3 $4 $5 $6 $7 $8 $9
read -p "User name?" _user
read -p "Password?" _password
 
== Example of script1.sh calling script2.sh ==
$ ./script1.sh All your base are belong to us
script2.sh was called from script1.sh via source
The parameters are All your base are belong to us
User name?WHAT
Password?HAPPEN
The user is WHAT and the password is HAPPEN
Open in New Window Select All

Answer : What does "(or .)" mean in the statement "script0 will see the variables only if it calls script1 with source (or .)"


it's used as an alias to source.  It is a command so there is a space after it

.  file.foo

or with a absolute or relative path

. ./file.foo
. /path/to/foo

Random Solutions  
 
programming4us programming4us