Return to Snippet

Revision: 25072
at March 19, 2010 04:56 by evertwh


Initial Code
deftwitlogrc="~/.twitlog.rc"

#
# Parse command line
#

me=`basename $0 .sh`
usage="Usage: $me [-c config-file] <message>  \n\nNOTE: config-file defaults to $deftwitlogrc"

while getopts ":c:" options; do
  case $options in
    c ) twitlogrc=$OPTARG;;
    h ) echo -e $usage
        exit 0;;
    \? ) echo -e $usage
         exit 1;;
    * ) echo -e $usage
          exit 1;;
  esac
done  

shift $((OPTIND - 1))

#
# Try and read config file
#
if [ -z "$twitlogrc" ]
then
        source ${HOME}/.twitlog.rc
else
        source $twitlogrc
fi

if [ $? -ne 0 ]
then
        echo "Cannot open config file"
        echo
        echo -e $usage

        exit 1
fi

Initial URL

                                

Initial Description

                                

Initial Title
reading default config file in a bash script

Initial Tags
Bash

Initial Language
Bash