Re: Bash – ”Sourcing” script from another script

Johnny Rosenberg gurus.knugum at
Mon Jan 5 17:16:11 UTC 2015

2015-01-04 23:50 GMT+01:00 Karl Auer <kauer at>:

> 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
> follow.
> If possible, I would refactor the scripts into three - one script
> that calculates the variable values, then two separate scripts
> and that each source

Another idea I had, before I read this, was four scripts: would look something like this:
MoreStuff here or where ever suitable.

Could that be a reasonable approach? and could have commants that tells the reader that
variables are declared and/or calculated in and that starts all the other scripts, just to make it easier to

Kind regards

Johnny Rosenberg

> 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
> quite
> > 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
> 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
> Modify settings or unsubscribe at:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ubuntu-users mailing list