Skip to Content
Learn Linux Shell Scripting - Fundamentals of Bash 4.4
book

Learn Linux Shell Scripting - Fundamentals of Bash 4.4

by Sebastiaan Tammer
December 2018
Beginner
452 pages
12h 17m
English
Packt Publishing
Content preview from Learn Linux Shell Scripting - Fundamentals of Bash 4.4

Error checking

In the previous chapter, we spent some time explaining how we could capture and use user input in our scripts. While this makes our scripts much more dynamic and, by extension, much more practical, we also introduce a new concept: human error. Let's say you're writing a script where you want to present the user with a yes/no question. You might expect a reasonable user to use any of the following as an answer:

  • y
  • n
  • Y
  • N
  • Yes
  • No
  • yes
  • no
  • YES
  • NO

While Bash allows us to check for all values we can think of, sometimes a user will still be able to break the script by supplying input you do not expect. An example of this would be the user answering the yes/no question in their native language: ja, si, nei, or any of the countless other ...

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

Bash Scripting Fundamentals

Bash Scripting Fundamentals

Sander van Vugt

Publisher Resources

ISBN: 9781788995597Supplemental Content