Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 3
    @mikeserv - Perhaps you should write a blog post about those facts and variations. But it would be in an advanced bash scripting category, not this answer's basic guidelines category. Commented Nov 10, 2015 at 21:44
  • 1
    @mikeserv My "categories" are made up to describe the difference between this answer (which covers 80% of use cases), and your comment (which alludes to the other 20% not covered). (: Even those percentages are made up. :) Commented Nov 12, 2015 at 6:19
  • 8
    Worth noting: if two (or more) scripts need to share some code, it's probably best to put that code into a function which is itself located in a third file that both of those scripts import/source. Commented Sep 21, 2016 at 19:40
  • 4
    Another item to add to that list of questions: Do you ever need to change functionality in the command on the fly? changes to a script will be reflected in all sessions, whereas functions and aliases must be reloaded or redefined on a per session basis. Commented Apr 14, 2017 at 21:02
  • 1
    Another dimension to the discussion: External commands (scripts) can be more easily tested, reloaded, etc. There are entire development cultures and environments for building and testing external commands and their components but nothing for aliases and functions. Ksh93 has FPATH to try to make functions more like commands. Commented Oct 3, 2019 at 14:25