Merge branches 'read-p' and 'testfix/cygwin-customaction'
This commit is contained in:
@@ -30,3 +30,19 @@ make_action_in_folder()
|
|||||||
mkdir ".todo.actions.d/$1"
|
mkdir ".todo.actions.d/$1"
|
||||||
[ -z "$1" ] || make_dummy_action ".todo.actions.d/$1/$1" "in folder $1"
|
[ -z "$1" ] || make_dummy_action ".todo.actions.d/$1/$1" "in folder $1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
invalidate_action()
|
||||||
|
{
|
||||||
|
local customActionFilespec="${1:?}"; shift
|
||||||
|
local testName="${1:?}"; shift
|
||||||
|
|
||||||
|
chmod -x "$customActionFilespec"
|
||||||
|
# On Cygwin, clearing the executable flag may have no effect, as the Windows
|
||||||
|
# ACL may still grant execution rights. In this case, we skip the test, and
|
||||||
|
# remove the (still valid) custom action so that it doesn't break following
|
||||||
|
# tests.
|
||||||
|
if [ -x "$customActionFilespec" ]; then
|
||||||
|
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }${testName}"
|
||||||
|
rm -- "$customActionFilespec"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ test_description='basic del functionality
|
|||||||
'
|
'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
SPACE=' '
|
|
||||||
|
|
||||||
test_todo_session 'del usage' <<EOF
|
test_todo_session 'del usage' <<EOF
|
||||||
>>> todo.sh del B
|
>>> todo.sh del B
|
||||||
usage: todo.sh del ITEM# [TERM]
|
usage: todo.sh del ITEM# [TERM]
|
||||||
@@ -60,7 +58,7 @@ test_todo_session 'del with confirmation' <<EOF
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> printf n | todo.sh del 1
|
>>> printf n | todo.sh del 1
|
||||||
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
|
\\
|
||||||
TODO: No tasks were deleted.
|
TODO: No tasks were deleted.
|
||||||
|
|
||||||
>>> todo.sh -p list
|
>>> todo.sh -p list
|
||||||
@@ -71,15 +69,15 @@ TODO: No tasks were deleted.
|
|||||||
TODO: 3 of 3 tasks shown
|
TODO: 3 of 3 tasks shown
|
||||||
|
|
||||||
>>> printf x | todo.sh del 1
|
>>> printf x | todo.sh del 1
|
||||||
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
|
\\
|
||||||
TODO: No tasks were deleted.
|
TODO: No tasks were deleted.
|
||||||
|
|
||||||
>>> echo | todo.sh del 1
|
>>> echo | todo.sh del 1
|
||||||
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
|
\\
|
||||||
TODO: No tasks were deleted.
|
TODO: No tasks were deleted.
|
||||||
|
|
||||||
>>> printf y | todo.sh del 1
|
>>> printf y | todo.sh del 1
|
||||||
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
|
\\
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
TODO: 1 deleted.
|
TODO: 1 deleted.
|
||||||
|
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ test_description='basic move functionality
|
|||||||
'
|
'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
SPACE=' '
|
|
||||||
|
|
||||||
cat > todo.txt <<EOF
|
cat > todo.txt <<EOF
|
||||||
(B) smell the uppercase Roses +flowers @outside
|
(B) smell the uppercase Roses +flowers @outside
|
||||||
(A) notice the sunflowers
|
(A) notice the sunflowers
|
||||||
@@ -42,7 +40,7 @@ x 2009-02-13 smell the coffee +wakeup
|
|||||||
EOF
|
EOF
|
||||||
test_todo_session 'basic move with confirmation' <<EOF
|
test_todo_session 'basic move with confirmation' <<EOF
|
||||||
>>> printf y | todo.sh move 1 done.txt 2>&1 | sed -e "s#'[^']\{1,\}/\([^/']\{1,\}\)'#'\1'#g" -e 's#from .\{1,\}/\([^/]\{1,\}\) to .\{1,\}/\([^/]\{1,\}\)?#from \1 to \2?#g'
|
>>> printf y | todo.sh move 1 done.txt 2>&1 | sed -e "s#'[^']\{1,\}/\([^/']\{1,\}\)'#'\1'#g" -e 's#from .\{1,\}/\([^/]\{1,\}\) to .\{1,\}/\([^/]\{1,\}\)?#from \1 to \2?#g'
|
||||||
Move '(B) smell the uppercase Roses +flowers @outside' from todo.txt to done.txt? (y/n)$SPACE
|
\\
|
||||||
1 (B) smell the uppercase Roses +flowers @outside
|
1 (B) smell the uppercase Roses +flowers @outside
|
||||||
TODO: 1 moved from 'todo.txt' to 'done.txt'.
|
TODO: 1 moved from 'todo.txt' to 'done.txt'.
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,7 @@ ls
|
|||||||
quux
|
quux
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
chmod -x .todo.actions.d/foo
|
invalidate_action .todo.actions.d/foo t8010.4
|
||||||
# On Cygwin, clearing the executable flag may have no effect, as the Windows ACL
|
|
||||||
# may still grant execution rights. In this case, we skip the test.
|
|
||||||
if [ -x .todo.actions.d/foo ]; then
|
|
||||||
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }t8010.4"
|
|
||||||
fi
|
|
||||||
test_todo_session 'nonexecutable action' <<EOF
|
test_todo_session 'nonexecutable action' <<EOF
|
||||||
>>> todo.sh listaddons
|
>>> todo.sh listaddons
|
||||||
bar
|
bar
|
||||||
@@ -66,13 +61,7 @@ norris
|
|||||||
quux
|
quux
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# nthorne: shamelessly stolen from above..
|
invalidate_action .todo.actions.d/norris/norris t8010.8
|
||||||
chmod -x .todo.actions.d/norris/norris
|
|
||||||
# On Cygwin, clearing the executable flag may have no effect, as the Windows ACL
|
|
||||||
# may still grant execution rights. In this case, we skip the test.
|
|
||||||
if [ -x .todo.actions.d/norris/norris ]; then
|
|
||||||
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }t8010.8"
|
|
||||||
fi
|
|
||||||
test_todo_session 'nonexecutable action in subfolder' <<EOF
|
test_todo_session 'nonexecutable action in subfolder' <<EOF
|
||||||
>>> todo.sh listaddons
|
>>> todo.sh listaddons
|
||||||
bar
|
bar
|
||||||
|
|||||||
15
todo.sh
15
todo.sh
@@ -364,12 +364,11 @@ confirm()
|
|||||||
{
|
{
|
||||||
[ $TODOTXT_FORCE = 0 ] || return 0
|
[ $TODOTXT_FORCE = 0 ] || return 0
|
||||||
|
|
||||||
printf %s "${1:?}? (y/n) "
|
|
||||||
local readArgs=(-e -r)
|
local readArgs=(-e -r)
|
||||||
[ -n "${BASH_VERSINFO:-}" ] && [ \( ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 \) -o ${BASH_VERSINFO[0]} -gt 4 ] &&
|
[ -n "${BASH_VERSINFO:-}" ] && [ \( ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 \) -o ${BASH_VERSINFO[0]} -gt 4 ] &&
|
||||||
readArgs+=(-N 1) # Bash 4.1+ supports -N nchars
|
readArgs+=(-N 1) # Bash 4.1+ supports -N nchars
|
||||||
local answer
|
local answer
|
||||||
read "${readArgs[@]}" answer
|
read -p "${1:?}? (y/n) " "${readArgs[@]}" answer
|
||||||
echo
|
echo
|
||||||
[ "$answer" = "y" ]
|
[ "$answer" = "y" ]
|
||||||
}
|
}
|
||||||
@@ -451,8 +450,7 @@ replaceOrPrepend()
|
|||||||
getTodo "$item"
|
getTodo "$item"
|
||||||
|
|
||||||
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
echo -n "$querytext"
|
read -p "$querytext" -r -i "$todo" -e input
|
||||||
read -r -i "$todo" -e input
|
|
||||||
else
|
else
|
||||||
input=$*
|
input=$*
|
||||||
fi
|
fi
|
||||||
@@ -1082,8 +1080,7 @@ fi
|
|||||||
case $action in
|
case $action in
|
||||||
"add" | "a")
|
"add" | "a")
|
||||||
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
echo -n "Add: "
|
read -p "Add: " -e -r input
|
||||||
read -e -r input
|
|
||||||
else
|
else
|
||||||
[ -z "$2" ] && die "usage: $TODO_SH add \"TODO ITEM\""
|
[ -z "$2" ] && die "usage: $TODO_SH add \"TODO ITEM\""
|
||||||
shift
|
shift
|
||||||
@@ -1094,8 +1091,7 @@ case $action in
|
|||||||
|
|
||||||
"addm")
|
"addm")
|
||||||
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
echo -n "Add: "
|
read -p "Add: " -e -r input
|
||||||
read -e -r input
|
|
||||||
else
|
else
|
||||||
[ -z "$2" ] && die "usage: $TODO_SH addm \"TODO ITEM\""
|
[ -z "$2" ] && die "usage: $TODO_SH addm \"TODO ITEM\""
|
||||||
shift
|
shift
|
||||||
@@ -1135,8 +1131,7 @@ case $action in
|
|||||||
getTodo "$item"
|
getTodo "$item"
|
||||||
|
|
||||||
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
|
||||||
echo -n "Append: "
|
read -p "Append: " -e -r input
|
||||||
read -e -r input
|
|
||||||
else
|
else
|
||||||
input=$*
|
input=$*
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user