Skip to content

Instantly share code, notes, and snippets.

@TheMightyLlama
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TheMightyLlama/261b296d66b3a042b743 to your computer and use it in GitHub Desktop.
Save TheMightyLlama/261b296d66b3a042b743 to your computer and use it in GitHub Desktop.
print a string and status with correct number of periods
function printStatus () {
string=$1;
status=$2;
lineLength=`tput cols`;
stringLength=${#string};
statusLength=${#status};
periodLength=$((lineLength - stringLength - statusLength));
printf "${string}";
printf '%0.s.' $(seq 1 $periodLength);
if [[ ${status} = "OK" ]] ; then
printf "${green}${status}${reset}";
fi
if [[ ${status} = "NOK" ]] ; then
printf "${red}${status}${reset}";
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment