Data handling errors occur when a user enters incorrect or unexpected input.
These are notreally errors because your program will still work if your user enters the expected input. Data handling errors do not show up until the program is run later using the bad input. This might include a user typing a space where it does not belong or typing a word when your program is expecting a number. When writing your shell script, decide how much input checking to include in your code.
You can decide to:
- Allow the program to fail if a user enters bad input. This saves you time programming, but aggravates the user.
- Check for some of the possible bad inputs, but not all.
- Handle every possible bad input. This saves the user aggravation, but uses a lot of programming time.
This lesson listed your choices for handling the situation. We will look at specific examples of handling bad user input later in this module.
The next lesson examines two common problems with user input, and how write your code to work around these problems.