Joined September 2012
·

Richard Howard

DevOps Engineer at iovation
·
Portland, Oregon
·
·
·

I think MOST scripts have pieces of reusable functionality. think about all those shell scripts that use paths, permissions, etc. all of those are bits of code we re-use over and over again. I agree with "no abstraction until abstraction is needed" but for me and the things I use shell scripts for, I have many overlapping use cases. And I hate having to do it over and over again.

This tip is for those times other languages aren't available, or you cannot code what you need in the language that IS available (I do not code 'haskell' or 'Coffeescript' at this time for example, I am learning though!), not that what I do in those other languages is really MENT for systems management / basic systems tasks.

I do not think you are trashing anything, you bring up interesting points that are well worth discussing :)

Going to have to disagree with you on that.

here is why:

Most scripts encompass multiple actions. Organizing actions into a primary function makes code easier to read, understand and organize. Not to mention to allow for locally scoped variables by function . This thereby increases the maintainability of the script as requirements change.

edit:
I hate throwing away functionality I will need going forward. A well written script can be incorporated into other scripts if solid coding practices are adhered to.

I am all about GSD, but not at the longer term cost of avoidable technical debt

when passing elements that have to be "ran" by the script into a function you should use the 'eval' as it will ensure your code is treated as a unique shell call, thereby creating consistency in your scripts and predicability :)

Achievements
89 Karma
2,739 Total ProTip Views