开发者

Pattern for writing a wrapper script which calls several other scripts?

开发者 https://www.devze.com 2023-04-07 12:08 出处:网络
I have several (bash) scripts that are run both individually and in sequence.Let\'s cal开发者_Go百科l them one, two, and three.They take awhile to run, so since we frequently run them in order, I\'m w

I have several (bash) scripts that are run both individually and in sequence. Let's cal开发者_Go百科l them one, two, and three. They take awhile to run, so since we frequently run them in order, I'm writing a wrapper script to simply call them in order.

I'm not running into any problems, per se, but I'm realizing how brittle this is. For example:

script two has a -e argument for the user to specify an email address to send errors to. script three has a -t argument for the same thing. script one's -e argument means something else

My wrapper script basically parses the union of all the arguments of the three subscripts, and "does the right thing." (i.e. it has its own args - say -e for email, and it passes its value to the -e arg to the second script but to the -t arg for the third).

My problem is that these scripts are now so tightly coupled - for example, someone comes along, looks at scripts two and three, and says "oh, we should use the same argument for email address", and changes the -t to a -e in script three. Script three works fine on its own but now the wrapper script is broken.

What would you do in this situation? I have some big warnings in the comments in each script, but this bothers me. The only other thing I can think of is to have one huge monolithic script, which I'm obviously not crazy about either.


The problem seems to be that people are thoughtlessly changing the API of the underlying scripts. You can’t go around arbitrarily changing an API that you know others are depending on. After all, it might not just be this wrapper script that expects script #3 to take a -t argument. So the answer seems to be: stop changing the underlying scripts.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号