fix output for mac

master
Marc Wäckerlin 7 years ago
parent 186a7dde78
commit ef69ea0655
  1. 164
      scripts/bootstrap.sh
  2. 130
      scripts/template.sh

@ -302,7 +302,91 @@ EOF
shift;
done
echo -en "\e[1m-> checking:\e[0m for version control system ..."
# check if stdout is a terminal...
if test -t 1; then
# see if it supports colors...
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
fi
notice() {
echo "${yellow}→ notice: ${bold}$*${normal}"
}
running() {
echo -n "${bold}${blue}→ running: ${bold}${white}$*${normal}"
}
checking() {
echo -n "${bold}${blue}→ checking: ${bold}${white}$*${normal}"
}
generating() {
echo -n "${bold}${blue}→ generating: ${bold}${white}$*${normal}"
}
configuring() {
echo -n "${bold}${blue}→ configuring ${bold}${white}$1${normal}:"
shift
echo -n "${white}$*${normal}"
}
ignored() {
echo "${bold}${yellow}ignored $*${normal}"
}
success() {
echo "${bold}${green}success $*${normal}"
}
error() {
echo "${bold}${red}→ error: $1${normal}"
shift
if test -n "$*"; then
echo "${bold}$*${normal}"
fi
exit 1
}
run() {
check=1
while test $# -gt 0; do
case "$1" in
(--no-check) check=0;;
(*) break;;
esac
shift;
done
running $*
result=$($* 2>&1)
res=$?
if test $res -ne 0; then
if test $check -eq 1; then
error "Failed with return code: $res" "$result"
else
ignored
fi
else
success
fi
}
checking for version control system
VCS=""
VCSDEPENDS=""
for path in . .. ../.. ../../..; do
@ -310,18 +394,18 @@ for path in . .. ../.. ../../..; do
VCS="svn"
VCSDEPENDS_DEB="svn2cl, subversion, subversion-tools,"
VCSDEPENDS_RPM="subversion, "
echo -e " \e[32msuccess\e[0m detected ${VCS}"
success detected ${VCS}
break
elif test -d ${path}/.git; then
VCS="git"
VCSDEPENDS_DEB="git2cl, git,"
VCSDEPENDS_RPM="git, "
echo -e " \e[32msuccess\e[0m detected ${VCS}"
success detected ${VCS}
break
fi
done
if test -z "$VCS"; then
echo -e " \e[33mignored\e[0m"
ignored
fi
HEADER='## @id '"\$Id\$"'
@ -349,43 +433,6 @@ CHEADER='/** @id '"\$Id\$"'
'
notice() {
echo -e "\e[1;33m$*\e[0m"
}
error() {
echo -e " \e[31merror\e[0m $*"
exit 1
}
run() {
check=1
while test $# -gt 0; do
case "$1" in
(--no-check) check=0;;
(*) break;;
esac
shift;
done
echo -en "\e[1m-> running:\e[0m $* ..."
result=$($* 2>&1)
res=$?
if test $res -ne 0; then
if test $check -eq 1; then
echo -e " \e[31merror\e[0m"
echo -e "\e[1m*** Failed with return code: $res\e[0m"
if test -n "$result"; then
echo "$result"
fi
exit 1
else
echo -e " \e[33mignored\e[0m"
fi
else
echo -e " \e[32msuccess\e[0m"
fi
}
testtag() {
local IFS="|"
egrep -q '^ *'"($*)"' *(\(.*)? *$' configure.ac
@ -438,18 +485,13 @@ to() {
return 1
fi
checkdir "$(dirname ${1})"
echo -en "\e[1m-> generating:\e[0m $1 ..."
generating $1
result=$(cat > "$1" 2>&1)
res=$?
if test $res -ne 0; then
echo -e " \e[31merror\e[0m"
echo -e "\e[1m*** Failed with return code: $res\e[0m"
if test -n "$result"; then
echo "$result"
fi
exit 1
error "Failed with return code: $res" "$result"
else
echo -e " \e[32msuccess\e[0m"
success
fi
run chmod $mode $1
if test $exists -eq 0; then
@ -491,24 +533,20 @@ copy() {
}
doxyreplace() {
echo -en "\e[1m-> doxyfile:\e[0m configure $1 ..."
configuring doxyfile $1
if sed -i 's|\(^'"$1"' *=\) *.*|\1'" $2"'|g' doc/doxyfile.in; then
echo -e " \e[32msuccess\e[0m"
success
else
echo -e " \e[31merror\e[0m"
echo -e "\e[1m**** command: $0 $*\e[0m"
exit 1
error $0 $*
fi
}
doxyadd() {
echo -en "\e[1m-> doxyfile:\e[0m configure $1 ..."
configuring doxyfile $1
if sed -i '/^'"$1"' *=/a'"$1"' += '"$2" doc/doxyfile.in; then
echo -e " \e[32msuccess\e[0m"
success
else
echo -e " \e[31merror\e[0m"
echo -e "\e[1m**** command: $0 $*\e[0m"
exit 1
error $0 $*
fi
}
@ -1801,9 +1839,9 @@ fi
aclocal
$(if testtag AX_USE_LIBTOOL; then
cat <<EOF1
if which -s libtoolize; then
if which libtoolize > /dev/null; then
run libtoolize --force;
elif which -s glibtoolize; then
elif which glibtoolize > /dev/null; then
run glibtoolize --force;
else
echo "error: libtoolize not found" 1>&2
@ -1879,9 +1917,9 @@ else
run --no-check vcs2cl
run aclocal
if testtag AX_USE_LIBTOOL; then
if which -s libtoolize; then
if which libtoolize > /dev/null; then
run libtoolize --force;
elif which -s glibtoolize; then
elif which glibtoolize > /dev/null; then
run glibtoolize --force;
else
error libtoolize not found

@ -1,81 +1,89 @@
#!/bin/bash -e
# template for bash scripts
##########################################################################################
#### template for bash scripts #### START BELOW ##########################################
##########################################################################################
############################################################################ begin logging
# check if stdout is a terminal...
if test -t 1; then
# see if it supports colors...
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
bold="$(tput bold)"
underline="$(tput smul)"
standout="$(tput smso)"
normal="$(tput sgr0)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
fi
fi
# internal use only
append_msg() {
if test $# -ne 0; then
echo -en ":\e[0m \e[1m$*"
echo -n ": ${bold}$*"
fi
echo -e "\e[0m"
echo "${normal}"
}
# write a notice
notice() {
# write a message
message() {
if test $# -eq 0; then
return
fi
echo -e "\e[1m$*\e[0m" 1>&2
echo "${bold}${while}$*${normal}" 1>&2
}
# write error message
error() {
echo -en "\e[1;31merror" 1>&2
# write a success message
success() {
echo -n "${bold}${green}success" 1>&2
append_msg $* 1>&2
}
# write a notice
notice() {
echo -n "${bold}${yellow}notice" 1>&2
append_msg $* 1>&2
}
# write a warning message
warning() {
echo -en "\e[1;33mwarning" 1>&2
echo -en "${bold}${red}warning" 1>&2
append_msg $* 1>&2
}
# write a success message
success() {
echo -en "\e[1;32msuccess" 1>&2
# write error message
error() {
echo -en "${bold}${red}error" 1>&2
append_msg $* 1>&2
}
# commandline parameter evaluation
while test $# -gt 0; do
case "$1" in
(--help|-h) less <<EOF
SYNOPSIS
$0 [OPTIONS]
OPTIONS
--help, -h show this help
DESCRIPTION
EOF
exit;;
(*) error "unknow option $1, try $0 --help"; exit 1;;
esac
if test $# -eq 0; then
error "missing parameter, try $0 --help"; exit 1
fi
shift;
done
# run a command, print the result and abort in case of error
# option: --no-check: ignore the result, continue in case of error
# option: --ignore: ignore the result, continue in case of error
run() {
check=1
ignore=1
while test $# -gt 0; do
case "$1" in
(--no-check) check=0;;
(--ignore) ignore=0;;
(*) break;;
esac
shift;
done
echo -en "\e[1m-> running:\e[0m $* ..."
echo -n "${bold}${yellow}running:${white} $*${normal}"
set +e
result=$($* 2>&1)
res=$?
set -e
if test $res -ne 0; then
if test $check -eq 1; then
if test $ignore -eq 1; then
error "failed with return code: $res"
if test -n "$result"; then
echo "$result"
@ -89,7 +97,7 @@ run() {
fi
}
# error handler
############################################################################ error handler
function traperror() {
set +x
local err=($1) # error status
@ -101,9 +109,9 @@ function traperror() {
if test -n "$e" -a "$e" != "0"; then
error "line $line - command '$command' exited with status: $e (${err[@]})"
if [ "${funcstack}" != "main" -o "$linecallfunc" != "0" ]; then
echo -n " ... error at ${funcstack} "
echo -n " ... error at ${funcstack} " 1>&2
if [ "$linecallfunc" != "" ]; then
echo -n "called at line $linecallfunc"
echo -n "called at line $linecallfunc" 1>&2
fi
echo
fi
@ -117,5 +125,35 @@ function traperror() {
# catch errors
trap 'traperror "$? ${PIPESTATUS[@]}" $LINENO $BASH_LINENO "$BASH_COMMAND" "${FUNCNAME[@]}" "${FUNCTION}"' ERR SIGINT INT TERM EXIT
##########################################################################################
#### START HERE ##########################################################################
##########################################################################################
######################################################### commandline parameter evaluation
while test $# -gt 0; do
case "$1" in
(--help|-h) less <<EOF
SYNOPSIS
$0 [OPTIONS]
OPTIONS
--help, -h show this help
DESCRIPTION
EOF
exit;;
(*) error "unknow option $1, try $0 --help"; exit 1;;
esac
if test $# -eq 0; then
error "missing parameter, try $0 --help"; exit 1
fi
shift;
done
##################################################################################### Main

Loading…
Cancel
Save