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*

4
  • 11
    "a function returns a single value, and does not output anything" -- well, yeah, in the mathematical sense maybe. But in imperative programming languages, it's really common for "function" to mean just a subroutine, one that could do anything. And shell functions in particular may very well have output or other side effects, since the return value of functions is so limited. Commented Sep 13, 2018 at 11:51
  • @ilkkachu. Thank you. I have updated the answer. Please feel free to revise ;-) Commented Sep 13, 2018 at 11:56
  • 3
    I think these definitions are from a programming-language context, not a shell context. Yes, I know the shell language is a programming language, but its idea of a "function" is quite different to the mathematical or computer-science definition - in shell, all commands (whether builtins, functions, aliases, programs or scripts) act alike, and are simply different kinds of implementation. Commented Sep 13, 2018 at 16:51
  • 1
    ...*mostly* alike; builtins can change the state of the shell itself, whereas external programs can't call chdir() or setenv() in the shell that is, to them, a distinct parent process. Commented Sep 13, 2018 at 17:51