UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 10.8 Fix Quoting in csh Aliases with makealias and quote Chapter 10
Aliases
Next: 10.10 Simulated Bourne Shell Functions and Aliases
 

10.9 Shell Functions

sh_init
The C shell has aliases (10.2). But until System V Release 2, the Bourne Shell had almost (10.10) no way for users to set up their own built-in commands. Functions are like aliases, but better. For instance, functions can return a status (44.7) and have much more reasonable syntax (10.7). bash and the Korn Shell have shell functions, too. To find out all about functions, check a shell programming book. There are examples in the sh_init file on the CD-ROM. Here are the examples from articles 10.2 and 10.3 changed into Bourne shell aliases:

That example shows how to write a function with more than one line. In that style, with the ending curly brace on its own line, you don't need a semicolon after the last command.

- JP


Previous: 10.8 Fix Quoting in csh Aliases with makealias and quote UNIX Power ToolsNext: 10.10 Simulated Bourne Shell Functions and Aliases
10.8 Fix Quoting in csh Aliases with makealias and quote Book Index10.10 Simulated Bourne Shell Functions and Aliases

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System