Sams Teach Yourself Shell Programming in 24 Hours
(Publisher: Macmillan Computer Publishing)
Author(s): Sriranga Veeraraghavan
ISBN: 0672314819
Publication Date: 01/01/99

Previous Table of Contents Next


Conclusion

In this chapter you looked at creating and calling functions. Some of the major topics that you covered are

  Creating a function
  Using functions to replace built-in commands
  Using IFS to simplify parsing
  Using arguments with functions
  Sharing data between functions
  Calling a function from within another function

Part III introduces the concept of function libraries and presents a set of functions that you can use in your scripts.

Questions

1.  Write a function to make a directory (and all its parents) change to that directory and then print the full path of that directory. Please include error checking at all levels. Make sure that all error messages are generated by your script, not the commands that you execute.
2.  Chapter 13, “Input/Output,” introduced the concept of prompting the user from a shell script. Write a function that can be used to prompt the user for a response. This function should take a single argument that is the prompt, and it should place the user’s response in the variable RESPONSE. Please include error checking at all levels.


Previous Table of Contents Next