Created
May 3, 2013 07:46
-
-
Save yschu7/5507787 to your computer and use it in GitHub Desktop.
bash: display error message if empty or unset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| ## Check for unset arguments | |
| : ${1?An argument is required} \ | |
| ${2?Two arguments are required} | |
| ## Check for empty arguments | |
| : ${1:?An non-empty argument is required} \ | |
| ${2:?Two non-empty arguments are required} | |
| echo "Thank you." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment