Timeline for In Bash, when to alias, when to script and when to write a function?
Current License: CC BY-SA 3.0
24 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 3, 2019 at 14:25 | comment | added | jrw32982 | 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. | |
| Aug 13, 2019 at 20:19 | comment | added | Yoav Aharoni | I also found this to fix alias autocompletion in bash. | |
| Apr 14, 2017 at 21:02 | comment | added | Stratus3D | 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. | |
| Sep 21, 2016 at 19:40 | comment | added | kbolino | 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. | |
| Nov 12, 2015 at 6:19 | comment | added | Jesse Chisholm | @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. :) | |
| Nov 10, 2015 at 22:22 | comment | added | mikeserv | @JesseChisholm - well the comment was fundamentally incorrect in the terminology used for one thing, but where do you get these categories? | |
| Nov 10, 2015 at 21:44 | comment | added | Jesse Chisholm |
@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.
|
|
| Apr 30, 2014 at 17:06 | comment | added | mikeserv |
This answer is not necessarily correct, if only because there can be as many nested layers of the two different concepts as your system will allow or can handle. There is also the <<heredocument for which POSIX specifies an iohere system call which makes it an inline file and so it can blur the lines between the two if it contains a script. Because a function can define a file and because a function can exec a script there are many possible variations on your facts.
|
|
| Mar 16, 2014 at 18:13 | comment | added | Ciro Santilli OurBigBook.com | What about function vs alias only? Is function strictly more powerful than alias? | |
| S Sep 8, 2012 at 0:52 | history | suggested | Robbie | CC BY-SA 3.0 |
removed redundant word
|
| Sep 8, 2012 at 0:23 | review | Suggested edits | |||
| S Sep 8, 2012 at 0:52 | |||||
| Sep 6, 2012 at 13:46 | history | edited | jw013 | CC BY-SA 3.0 |
added 61 characters in body
|
| Aug 27, 2012 at 16:41 | history | wiki removed | Michael Mrozek | ||
| Jul 25, 2012 at 17:12 | history | edited | jw013 | CC BY-SA 3.0 |
edited body; deleted 21 characters in body
|
| May 9, 2012 at 11:59 | history | edited | jw013 | CC BY-SA 3.0 |
edited body
|
| May 9, 2012 at 0:47 | history | edited | jw013 | CC BY-SA 3.0 |
added 53 characters in body
|
| May 8, 2012 at 17:56 | history | edited | jw013 | CC BY-SA 3.0 |
added 11 characters in body
|
| May 8, 2012 at 13:03 | history | edited | jw013 | CC BY-SA 3.0 |
added 12 characters in body
|
| May 8, 2012 at 12:42 | history | edited | jw013 | CC BY-SA 3.0 |
added 1290 characters in body
|
| May 8, 2012 at 12:36 | history | edited | jw013 | CC BY-SA 3.0 |
added 1290 characters in body
|
| Feb 7, 2012 at 1:01 | history | edited | jw013 | CC BY-SA 3.0 |
added 451 characters in body
|
| Feb 6, 2012 at 19:59 | history | edited | jw013 | CC BY-SA 3.0 |
added 39 characters in body
|
| Feb 5, 2012 at 22:28 | history | edited | jw013 | CC BY-SA 3.0 |
added 25 characters in body
|
| Feb 5, 2012 at 21:49 | history | answered | jw013 | CC BY-SA 3.0 |