sdcard-write: Colorize error message if possible
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
This commit is contained in:
@@ -7,16 +7,46 @@
|
||||
# This script contains some helper functions and can be sourced by other
|
||||
# scripts
|
||||
|
||||
# set terminal styles
|
||||
# are we on terrminal?
|
||||
if [ -t 1 ] ; then
|
||||
# tput available?
|
||||
if [ ! "x`which tput 2>/dev/null`" = "x" ] ; then
|
||||
# supports colors ?
|
||||
ncolors=`tput colors`
|
||||
if [ -n "$ncolors" -a $ncolors -ge 8 ] ; then
|
||||
style_bold="`tput bold`"
|
||||
style_underline="`tput smul`"
|
||||
style_standout="`tput smso`"
|
||||
style_normal="`tput sgr0`"
|
||||
style_black="`tput setaf 0`"
|
||||
style_red="`tput setaf 1`"
|
||||
style_green="`tput setaf 2`"
|
||||
style_yellow="`tput setaf 3`"
|
||||
style_blue="`tput setaf 4`"
|
||||
style_magenta="`tput setaf 5`"
|
||||
style_cyan="`tput setaf 6`"
|
||||
style_white="`tput setaf 7`"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
ErrorOut() {
|
||||
echo
|
||||
echo "${style_red}${style_bold}${1}!${style_normal}"
|
||||
echo
|
||||
exit -1
|
||||
}
|
||||
|
||||
# CheckPrerequisite checks if required hosttool is found on host. In case not
|
||||
# it outputs a message and exits script.
|
||||
CheckPrerequisite() {
|
||||
if [ "x`which $1`" = "x" ] ; then
|
||||
echo
|
||||
echo "You need to install $1 first!"
|
||||
echo
|
||||
exit -1
|
||||
if [ "x`which $1 2>/dev/null`" = "x" ] ; then
|
||||
ErrorOut "You need to install $1 first!"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# SelectCardDevice() creates a dialog to select one of all available removable
|
||||
# devices. The path to the selected device is stored in the variale DevicePath.
|
||||
SelectCardDevice() {
|
||||
@@ -59,8 +89,7 @@ SelectCardDevice() {
|
||||
done
|
||||
|
||||
if [ $iCount -eq 0 ]; then
|
||||
echo 'No removable devices found!'
|
||||
exit 1
|
||||
ErrorOut 'No removable devices found!'
|
||||
fi
|
||||
|
||||
dialog --title 'Select card device'\
|
||||
|
||||
Reference in New Issue
Block a user