Skip to content
Snippets Groups Projects
Commit b8bacd7e authored by Simona Vetter's avatar Simona Vetter Committed by Jani Nikula
Browse files

dim: echoerr helper for printing to stderr

parent 8d225bba
No related branches found
No related tags found
No related merge requests found
...@@ -102,12 +102,17 @@ DRY= ...@@ -102,12 +102,17 @@ DRY=
FORCE= FORCE=
HELP= HELP=
function echoerr
{
echo "$@" >&2
}
function warn_or_fail function warn_or_fail
{ {
if [[ $FORCE ]] ; then if [[ $FORCE ]] ; then
echo WARNING: $1, but continuing echoerr WARNING: $1, but continuing
else else
echo ERROR: $1, aborting echoerr ERROR: $1, aborting
exit 1 exit 1
fi fi
} }
...@@ -128,7 +133,7 @@ while getopts hdfi opt; do ...@@ -128,7 +133,7 @@ while getopts hdfi opt; do
HELP=1 HELP=1
;; ;;
*) *)
echo "See '$dim help' for more information." >&2 echoerr "See '$dim help' for more information."
exit exit
esac esac
done done
...@@ -167,18 +172,18 @@ function dim_uptodate ...@@ -167,18 +172,18 @@ function dim_uptodate
local using="${BASH_SOURCE[0]}" local using="${BASH_SOURCE[0]}"
if [[ ! -e "$using" ]]; then if [[ ! -e "$using" ]]; then
echo "$dim: could not figure out the version being used ($using)." >&2 echoerr "$dim: could not figure out the version being used ($using)."
exit 1 exit 1
fi fi
if [[ ! -e "$DIM_PREFIX/maintainer-tools/.git" ]]; then if [[ ! -e "$DIM_PREFIX/maintainer-tools/.git" ]]; then
echo "$dim: could not find the upstream repo for $dim." >&2 echoerr "$dim: could not find the upstream repo for $dim."
exit 1 exit 1
fi fi
if ! git --git-dir=$DIM_PREFIX/maintainer-tools/.git show @{upstream}:dim |\ if ! git --git-dir=$DIM_PREFIX/maintainer-tools/.git show @{upstream}:dim |\
diff "$using" - >& /dev/null; then diff "$using" - >& /dev/null; then
echo "$dim: not running upstream version of the script." >&2 echoerr "$dim: not running upstream version of the script."
exit 1 exit 1
fi fi
} }
...@@ -1280,6 +1285,6 @@ subcmd_func=dim_${subcmd//-/_} ...@@ -1280,6 +1285,6 @@ subcmd_func=dim_${subcmd//-/_}
if declare -f $subcmd_func >/dev/null; then if declare -f $subcmd_func >/dev/null; then
$subcmd_func "$@" $subcmd_func "$@"
else else
echo "$dim: '$subcommand' is not a dim command." >&2 echoerr "$dim: '$subcommand' is not a dim command."
dim_usage dim_usage
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment