Skip to content

Commit

Permalink
Add confirmation promt to rmtree to solve Issue #22 (#24)
Browse files Browse the repository at this point in the history
* Add confirmation promt to rmtree to solve Issue #22
* Change question if user fails to respond yes/no
  • Loading branch information
vjacynycz authored and ml0renz0 committed Nov 19, 2019
1 parent 5822569 commit 6ae1e06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,9 @@ Now it has become a useful tool here at [Stratio](http://www.stratio.com)
# Known bugs
* If you type really fast enough you may incur a race condition on the loop that manages the keyboard input.
* Home/End keys do not work when ran within a screen shell
# Contributors
* Marcos Lorenzo (Creator) ([mlorenzo-stratio](https://github.com/mlorenzo-stratio))
* Ángel Prada ([aprada-stratio](https://github.com/aprada-stratio))
* Viktor Jacynycz ([vjacynycz-stratio](https://github.com/vjacynycz-stratio))
15 changes: 12 additions & 3 deletions vcli
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# vcli internal variables
declare SCRIPTNAME
SCRIPTNAME="$(basename "$0")"
declare VERSION="0.5.16"
declare VERSION="0.5.17"
declare VERBOSE=${VERBOSE:-"no"}
declare DEBUG=${DEBUG:-"no"}
declare DEBUG_HEXDUMP="no"
Expand Down Expand Up @@ -1069,7 +1069,7 @@ function _cptree(){

# removes recursively a vault path
function _rmtree(){
local funcname
local funcname question
funcname="${FUNCNAME[0]}"
local url
if [[ ! $1 =~ ^/ ]]; then
Expand All @@ -1090,7 +1090,15 @@ function _rmtree(){
if [[ ! $depth ]]; then
depth=0
first="yes"
# TODO: Ask user before removing tree
question="Do you want to remove $url? (yes/no): "
while read -p "$question" ANSWER </dev/tty; do
if [[ "$ANSWER" == "no" ]]; then
return
elif [[ "$ANSWER" == "yes" ]]; then
break
fi
question="Please type 'yes' or 'no': "
done
echo -n "Removing recursively '$url'"
# other wise we increment a depth as we go deeper in the structure
else
Expand Down Expand Up @@ -2289,3 +2297,4 @@ function main(){
}

main "$@"

0 comments on commit 6ae1e06

Please sign in to comment.