Re: Bash – ”Sourcing” script from another script
gurus.knugum at gmail.com
Mon Jan 5 17:16:11 UTC 2015
2015-01-04 23:50 GMT+01:00 Karl Auer <kauer at biplane.com.au>:
> On Sun, 2015-01-04 at 23:09 +0100, Johnny Rosenberg wrote:
> > I'm pretty sure it will work, but is this a good practice?
> It'll work, but it introduces dependencies that are a bit hard to
> If possible, I would refactor the scripts into three - one script
> calc.sh that calculates the variable values, then two separate scripts
> script1.sh and script2.sh that each source calc.sh.
Another idea I had, before I read this, was four scripts:
MainScript.sh would look something like this:
MoreStuff here or where ever suitable.
Could that be a reasonable approach?
Script1.sh and Script2.sh could have commants that tells the reader that
variables are declared and/or calculated in CalculateVariable.sh and that
MainScript.sh starts all the other scripts, just to make it easier to
> It depends on how complicated/expensive those variables are to
> calculate, and whether calculating them has side-effects.
> > Is it better to keep everything in one file even if that file will be
> > big?
> If two scripts have a section that does the same thing in each script,
> and that thing is non-trivila, it's generally a good idea to separate it
> out and get it right once. Then if changes are ever needed, you only
> have to change one place and it will be corrected in all the places that
> use it.
> Regards, K.
> Karl Auer (kauer at biplane.com.au)
> GPG fingerprint: 3C41 82BE A9E7 99A1 B931 5AE7 7638 0147 2C3C 2AC4
> Old fingerprint: EC67 61E2 C2F6 EB55 884B E129 072B 0AF0 72AA 9882
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ubuntu-users