<div dir="ltr">Just wondering…<div>I have a script that does two different things related to each other. I could say that the script does one thing in two distinct steps, so it feels natural to split those things into two scripts.</div><div><br></div><div>However, the second part of the script use some variables that got its values in the first part, so the second script would need to calculate those variables again, which feels redundant.</div><div><br></div><div>Seems like ”source” would do the job, since it executes the script in the same shell. I thought something like this:</div><div><br></div><div>ScriptA.sh:</div><div>SomeVariable=Something<br></div><div>AnotherVariable=SomethingElse</div><div>Do-stuff</div><div>source ScriptB.sh</div><div><br></div><div>ScriptB.sh:</div><div>source Some-function-defs.sh</div><div>SomeFunction "$SomeVariable"</div><div>AnotherFunction "$AnotherVariable"</div><div>Do-more-stuff</div><div><br></div><div>Some-function-defs.sh:<br></div><div>SomeFunction () { Some action}</div><div>AnotherFunction () { More action }</div><div><br></div><div>I'm pretty sure it will work, but is this a good practice?</div><div>Is it better to keep everything in one file even if that file will be quite big?</div><div>Or is it better to just run the script in another shell sending it a lot of parameters?</div><div><br></div><div><br></div><div><div>Kind regards</div><div><br></div><div>Johnny Rosenberg</div><div>ジョニー・ローゼンバーグ</div></div><div><br></div></div>