#!/bin/sh #---------------------------------------------------------------------------- # /var/install/include/mecho - multi echo # # Creation: 2004-07-22 fm # Last Update: $Id$ # # Copyright (c) 2004-2007 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) # -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) _mecho_opt='STD'; shift;; -info) _mecho_opt='INFO'; shift;; -warn) _mecho_opt='WARN'; shift;; -error) _mecho_opt='ERROR'; shift;; -tty) _mecho_mode='tty'; shift;; -html) _mecho_mode='html'; shift;; -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 #============================================================================