1#!/bin/bash 2# Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5 6# Color output encodings. 7COL_RED='\E[31;1m' 8COL_GREEN='\E[32;1m' 9COL_YELLOW='\E[33;1m' 10COL_BLUE='\E[34;1m' 11COL_STOP='\E[0;m' 12 13# args: [message] 14green() { 15 echo -e "${COL_GREEN}$*${COL_STOP}" 16} 17 18# args: [message] 19yellow() { 20 echo -e "${COL_YELLOW}WARNING: $*${COL_STOP}" 21} 22 23# args: [message] 24red() { 25 echo -e "${COL_RED}$*${COL_STOP}" 26} 27 28# args: [nested level] [message] 29error() { 30 local lev=${1:-} 31 case "${1:-}" in 32 [0-9]*) 33 lev=$1 34 shift 35 ;; 36 *) lev=0 37 ;; 38 esac 39 local x=$(caller $lev) 40 local cline="${x%% *}" 41 local cfile="${x#* }" 42 cfile="${cfile##*/}" 43 local args="$*" 44 local spacer="${args:+: }" 45 red "at ${cfile}, line ${cline}${spacer}${args}" 1>&2 46 exit 1 47} 48