#!/bin/sh #---------------------------------------------------------------------------- # /var/install/include/mecho - multi echo # # Creation: 2004-07-22 fm # Last Update: $Id$ # # Copyright (c) 2004-2011 the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # --------------------------------------------------------------------------- # usage # --------------------------------------------------------------------------- # # mecho [-n] [--std|--info|--warn|--error] [--tty|--html|--file] message ... # # options: # -n do not append newline # # --std print standard message (default) # --stdbr print standard message (default)(bright) # --info print info message (green) # --warn print warning message (yellow)(bright) # --error print error message (red)(brightinvers) # --link print message '>' (cyan) # --ok print message [ OK ] (green) # --fail print message [ Fail ] (red)(bright) # # --tty use console colors # --html use html tags for colors # --file don't use any color tags # # DEPRECATED is the old syntax # -std print standard message (default) # -info print info message # -warn print warning message # -error print error message # # -tty use console colors # -html use html tags for colors # -file don't use any color tags # # --------------------------------------------------------------------------- # =========================================================================== # main # =========================================================================== mecho () { _mecho_opt='STD' _mecho_mode="$_EISLIB_PRINTMODE" _mecho_flags='' _mecho_colors='' _mecho_append='' while [ 1 ] do case "$1" in -n) _mecho_flags='-n'; shift;; --std|-std) _mecho_opt='STD'; shift;; --stdbr) _mecho_opt='STDBR'; shift;; --info|-info) _mecho_opt='INFO'; shift;; --warn|-warn) _mecho_opt='WARN'; shift;; --error|-error) _mecho_opt='ERROR'; shift;; --link) _mecho_opt='LINK'; shift;; --ok) _mecho_opt='MSG_OK'; shift;; --fail) _mecho_opt='MSG_FAIL'; shift;; --tty|-tty) _mecho_mode='tty'; shift;; --html|-html) _mecho_mode='html'; shift;; --file|-file) _mecho_mode='file'; shift;; *) break;; esac done _mecho_mode2=`echo $_mecho_mode | tr 'a-z' 'A-Z'` eval _mecho_pre='$'_EISLIB_COLOR_${_mecho_mode2}_PRE eval _mecho_post='$'_EISLIB_COLOR_${_mecho_mode2}_POST eval _mecho_reset='$'_EISLIB_COLOR_${_mecho_mode2}_RESET eval _mecho_colors='$'_EISLIB_COLOR_${_mecho_mode2}_${_mecho_opt} if [ "$_mecho_mode" = "html" ] then [ "$_mecho_flags" != "-n" ] && _mecho_append='
' _mecho_flags='' fi echo -e $_mecho_flags "${_mecho_pre}${_mecho_colors}${_mecho_post}${*}${_mecho_reset}${_mecho_append}" } # =========================================================================== # end # ===========================================================================