Skip to content

Commit

Permalink
Add checks: if config file exists and is writeable
Browse files Browse the repository at this point in the history
  • Loading branch information
malthejorgensen committed Nov 19, 2013
1 parent fc8ec58 commit 7b03a3b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions wd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ RED="\033[91m"
NOC="\033[m"


# check if config file exists
if [[ ! -a $CONFIG ]]
then
# if not: create config file
touch $CONFIG
fi

## load warp points
typeset -A points
while read line
Expand Down Expand Up @@ -132,6 +139,13 @@ wd_print_usage()

## run

# check if config file is writeable
if [[ ! -w $CONFIG ]]
then
wd_print_msg $RED "\'$CONFIG\' is not writeable. Exiting."
exit 1
fi

# get opts
args=`getopt -o a:r:lhs -l add:,remove:,list,help,show -- $*`

Expand Down

0 comments on commit 7b03a3b

Please sign in to comment.