© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
J. VarmaPro Bash https://doi.org/10.1007/978-1-4842-9588-5_6

6. Shell Functions

Jayant Varma1  
(1)
Berwick, VIC, Australia
 

A shell function is a compound command that has been given a name. It stores a series of commands for later execution. The name becomes a command and can be used in the same way as any other command. Its arguments are available in the positional parameters, just as in any other script. Like other commands, it sets a return code.

A function is executed in the same process as the script that calls it. This makes it fast because no new process must be created. All the variables of the script are available to it without having to be exported, ...

Get Pro Bash: Learn to Script and Program the GNU/Linux Shell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.