display: added dsleep, added -n switch to prnt, use it in conf_ntp

This commit is contained in:
levasseur
2021-10-12 17:51:40 +02:00
parent 983c8b5b70
commit f667db8787
2 changed files with 28 additions and 4 deletions

View File

@@ -88,10 +88,17 @@ export On_IWhite='\e[0;107m'
# ------------------------------------------------------------------------------
# Display status with color and timestamp
# (-n on first parameter to stay on the same line)
# ($1 accepted values: I=info, W=warning, E=error, m=des espaces (allignement)
# no header if anything else)
prnt()
{
if [[ $1 == "-n" ]]; then
local echoopt=$1
shift
else
local echoopt=""
fi
case $1 in
"I")
local heads="[ ${IGreen}info${DEFAULTFG} ]"
@@ -110,13 +117,30 @@ prnt()
shift
;;
esac
echo -e "${IWhite}$(date $DATEFORMAT)${DEFAULTFG} ${heads} $@"
echo $echoopt -e "${IWhite}$(date $DATEFORMAT)${DEFAULTFG} ${heads} $@"
unset heads
unset heads echoopt
}
export -f prnt
# ------------------------------------------------------------------------------
# Sleep and display a counter (or "the second parameter" every second)
dsleep()
{
i=$1
while test $i -gt 0
do
if [[ -n $2 ]]; then
echo -n "$2"
else
echo -n "${i} "
(( i=i-1 ))
sleep 1
done
echo
}
# ------------------------------------------------------------------------------
# Dump the keyboard's buffer
dump_key_buffer()