Skip to content

Instantly share code, notes, and snippets.

@yschu7
Created May 3, 2013 07:46
Show Gist options
  • Select an option

  • Save yschu7/5507787 to your computer and use it in GitHub Desktop.

Select an option

Save yschu7/5507787 to your computer and use it in GitHub Desktop.
bash: display error message if empty or unset
#!/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