spacecodeur
spacecodeur

Reputation: 2406

Sourcing bash script, how don't display the output?

I have two scripts, the 'main' script, script A and a script B which contains some variables. In script A, I include script B for use the variable defined in the script B like so:

scriptA:

. ./scriptb
...
echo $toto

scriptB:

export toto="hello !"

When I run my script A, I get the output:

$./scriptA
/home/user/scriptb
hello !

My question is how to remove the undesired /home/user/scriptb from output.

Upvotes: 0

Views: 86

Answers (1)

Vicente Olivert Riera
Vicente Olivert Riera

Reputation: 1220

The code you provided in your question doesn't have any problem:

$ cat scripta
. ./scriptb
echo $toto

$ cat scriptb 
export toto="hello!"

$ ./scripta 
hello!

Upvotes: 1

Related Questions