Last active
August 29, 2015 14:17
-
-
Save TheMightyLlama/261b296d66b3a042b743 to your computer and use it in GitHub Desktop.
print a string and status with correct number of periods
This file contains 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
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