Skip to Content
Pro Bash Programming: Scripting the GNU/Linux Shell
book

Pro Bash Programming: Scripting the GNU/Linux Shell

by Chris F.A. Johnson
October 2009
Beginner to intermediate
242 pages
5h 4m
English
Apress
Content preview from Pro Bash Programming: Scripting the GNU/Linux Shell

CHAPTER 6Shell Functions

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 in its own right 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 has to be created. All the variables of the script are available to it without having to be exported, and when a function changes those variables, the changes will be seen by the calling script. That said, you can make variables local to the function so that they ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pro Bash Programming : Scripting the GNU/Linux Shell, Second Edition

Pro Bash Programming : Scripting the GNU/Linux Shell, Second Edition

Chris F. A. Johnson, Jayant Varma
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781430219972Purchase book