You are not logged in.

#1 2011-01-13 08:32:41

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

[solved]How to remove sourced file in bash

I want to source some file in bash script first,then to remove it and source another file with same variables but different values.
I know how to source file,but how to remove it, after variables are read?

Last edited by na12 (2011-01-13 10:09:22)

Offline

#2 2011-01-13 08:40:49

cactus
Taco Eater
From: t͈̫̹ͨa͖͕͎̱͈ͨ͆ć̥̖̝o̫̫̼s͈̭̱̞͍̃!̰
Registered: 2004-05-25
Posts: 4,622
Website

Re: [solved]How to remove sourced file in bash

Just source the second file. The variables will overwrite those of the first if they are the same name.


"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍

Offline

#3 2011-01-13 08:43:32

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

Re: [solved]How to remove sourced file in bash

Well,that's great.Thanks

Offline

#4 2011-01-13 09:06:09

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: [solved]How to remove sourced file in bash

If you want to be extra careful and there aren't too many variables, you can (should?) unset them before sourcing the second file:

unset var1 var2 var3 varA varB varC
source file2

This way, if file2 (for whatever reason) is missing any of the variables, it won't "inherit" the value from the previous file.

Offline

#5 2011-01-13 10:16:03

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

Re: [solved]How to remove sourced file in bash

No,if one variable is missing from file2 it needs to be replaced with variable from file1.

Offline

#6 2011-01-13 21:49:10

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,231
Website

Re: [solved]How to remove sourced file in bash

na12 wrote:

No,if one variable is missing from file2 it needs to be replaced with variable from file1.

Fair enough... I guess you don't want to remove the first sourced file then? wink

Offline

#7 2011-01-14 08:03:37

na12
Member
From: /home/serbia
Registered: 2008-12-23
Posts: 752

Re: [solved]How to remove sourced file in bash

Yes,but I thought it would be a conflict between these two files.

Offline

Board footer

Powered by FluxBB