i'm writing a shell script to make echoing in color easier. but i keep getting an error. there is a help message for explaining how the command works; and no matter what i do, the help keeps showing up instead of the rest of the script running.
please help.
the script is:
Code:#!/bin/bash # # cecho # By: James Brumond # Created: 19 January 2009 # helpmsg () { echo echo "USE: cecho [-h | -f:COLOR | -b:COLOR] 'TEXT'" echo echo "OPTIONS:" echo " -f COLOR Sets the foreground color." echo " -b COLOR Sets the background color." echo " -h Display this message." echo echo "FOREGROUND COLORS:" echo -e '\E[;mdefault \E[;1mldefault \E[;30mblack \E[;1;30mdgrey \E[;31mred \E[1;31mlred' echo -e '\E[;32mgreen \E[1;32mlgreen \E[;33myellow \E[;1;33mlyellow \E[;34mblue \E[1;34mlblue' echo -e '\E[;35mmagenta \E[1;35mlmagenta \E[;36mcyan \E[;1;36mlcyan \E[;37mwhite \E[1;37mlwhite' echo echo "BACKGROUND COLORS:" echo -en '\E[;1mdefault\E[;m ' echo -en '\E[40;1mblack\E[;m ' echo -en '\E[41;1mred\E[;m ' echo -e '\E[42;1mgreen\E[;m ' echo -en '\E[43;1myellow\E[;m ' echo -en '\E[44;1mblue\E[;m ' echo -en '\E[45;1mmagenta\E[;m ' echo -e '\E[46;1mcyan\E[;m ' echo -e '\E[47;1mwhite\E[;m ' echo tput sgr0 } setup () { # foreground codes foregroundCode[0]=m foregroundCode[1]=1m foregroundCode[2]=30m foregroundCode[3]="1;30m" foregroundCode[4]=31m foregroundCode[5]="1;31m" foregroundCode[6]=32m foregroundCode[7]="1;32m" foregroundCode[8]=33m foregroundCode[9]="1;33m" foregroundCode[10]=34m foregroundCode[11]="1;34m" foregroundCode[12]=35m foregroundCode[13]="1;35m" foregroundCode[14]=36m foregroundCode[15]="1;36m" foregroundCode[16]=37m foregroundCode[17]="1;37m" # foreground text foregroundText[0]=default foregroundText[1]=ldefault foregroundText[2]=black foregroundText[3]=dgrey foregroundText[4]=red foregroundText[5]=lred foregroundText[6]=green foregroundText[7]=lgreen foregroundText[8]=yellow foregroundText[9]=lyellow foregroundText[10]=blue foregroundText[11]=lblue foregroundText[12]=magenta foregroundText[13]=lmagenta foregroundText[14]=cyan foregroundText[15]=lcyan foregroundText[16]=white foregroundText[17]=lwhite # background codes backgroundCode[0]= backgroundCode[1]=40 backgroundCode[2]=41 backgroundCode[3]=42 backgroundCode[4]=43 backgroundCode[5]=44 backgroundCode[6]=45 backgroundCode[7]=46 backgroundCode[8]=47 # background text backgroundText[0]=default backgroundText[1]=black backgroundText[2]=red backgroundText[3]=green backgroundText[4]=yellow backgroundText[5]=blue backgroundText[6]=magenta backgroundText[7]=cyan backgroundText[8]=white } startup () { setup if [ $# -eq 0 ] then helpmsg exit 0 elif [ $# -eq 1 ] then if [ $1 = "-h" ] then helpmsg exit 0 elif [ $1 = "-f:*" ] then echo exit 0 elif [ $1 = "-b:*" ] then echo exit 0 else echo "$1" fi elif [ $# -eq 2 ] then echo 2 elif [ $# -eq 3 ] then echo 3 else echo "Improper Use!" helpmsg exit 1 fi } startup


LinkBack URL
About LinkBacks

Reply With Quote
