Skip to content

Instantly share code, notes, and snippets.

@ruanbekker
Created May 25, 2018 06:51
Show Gist options
  • Save ruanbekker/c21e5495726a85fbbfe892cf1c570c2d to your computer and use it in GitHub Desktop.
Save ruanbekker/c21e5495726a85fbbfe892cf1c570c2d to your computer and use it in GitHub Desktop.
Bash: If Variable Empty Return Default Value
#!/bin/bash
set -ex
K=$1
K=${K:=BLANK_VARS}
if [ "$K" == "BLANK_VARS" ] ;
then echo "blanks" && exit 1 ;
else echo $K ;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment