summaryrefslogtreecommitdiff
path: root/plugins/wd/wd.sh
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/wd/wd.sh')
-rwxr-xr-xplugins/wd/wd.sh25
1 files changed, 16 insertions, 9 deletions
diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
index f7a22ff7d..56c029252 100755
--- a/plugins/wd/wd.sh
+++ b/plugins/wd/wd.sh
@@ -8,7 +8,7 @@
# @github.com/mfaerevaag/wd
# version
-readonly WD_VERSION=0.10.0
+readonly WD_VERSION=0.10.1
# colors
readonly WD_BLUE="\033[96m"
@@ -174,6 +174,11 @@ wd_add()
point=$(basename "$PWD")
fi
+ if [ ! -w "$wd_config_file" ]; then
+ wd_exit_fail "\'$wd_config_file\' is not writeable."
+ return
+ fi
+
if [[ $point =~ "^[\.]+$" ]]
then
wd_exit_fail "Warp point cannot be just dots"
@@ -239,6 +244,11 @@ wd_remove()
point_list=$(basename "$PWD")
fi
+ if [ ! -w "$wd_config_file" ]; then
+ wd_exit_fail "\'$wd_config_file\' is not writeable."
+ return
+ fi
+
for point_name in $point_list ; do
if [[ ${points[$point_name]} != "" ]]
then
@@ -440,6 +450,11 @@ wd_clean() {
local count=0
local wd_tmp=""
+ if [ ! -w "$wd_config_file" ]; then
+ wd_exit_fail "\'$wd_config_file\' is not writeable."
+ return
+ fi
+
while read -r line
do
if [[ $line != "" ]]
@@ -543,14 +558,6 @@ args=$(getopt -o a:r:c:lhs -l add:,rm:,clean,list,ls:,open:,path:,help,show -- $
if [[ ($? -ne 0 || $#* -eq 0) && -z $wd_print_version ]]
then
wd_print_usage
-
-# check if config file is writeable
-elif [ ! -w "$wd_config_file" ]
-then
- # do nothing
- # can't run `exit`, as this would exit the executing shell
- wd_exit_fail "\'$wd_config_file\' is not writeable."
-
else
# parse rest of options
local wd_o