From 0b300ccb866d5451aa34d82dc8933ab193564ed4 Mon Sep 17 00:00:00 2001 From: Ivan Povalyukhin Date: Wed, 25 Mar 2015 16:29:46 -0700 Subject: [PATCH] add argument presence check for functions in dirs plugin to bad usage --- plugins/available/dirs.plugin.bash | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/plugins/available/dirs.plugin.bash b/plugins/available/dirs.plugin.bash index 4b82291c..283b51b0 100644 --- a/plugins/available/dirs.plugin.bash +++ b/plugins/available/dirs.plugin.bash @@ -67,7 +67,8 @@ fi alias L='cat ~/.dirs' -G () { # goes to distination dir otherwise , stay in the dir +# goes to distination dir otherwise, stay in the dir +G () { about 'goes to destination dir' param '1: directory' example '$ G ..' @@ -76,20 +77,28 @@ G () { # goes to distination dir otherwise , stay in the dir cd "${1:-$(pwd)}" ; } -S () { # SAVE a BOOKMARK +S () { about 'save a bookmark' + param '1: bookmark name' + example '$ S mybkmrk' group 'dirs' + [[ $# -eq 1 ]] || { echo "${FUNCNAME[0]} function requires 1 argument"; return 1; } + sed "/$@/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ; } -R () { # remove a BOOKMARK +R () { about 'remove a bookmark' + param '1: bookmark name' + example '$ R mybkmrk' group 'dirs' + [[ $# -eq 1 ]] || { echo "${FUNCNAME[0]} function requires 1 argument"; return 1; } + sed "/$@/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; }