Skip to content

Commit 4cd6822

Browse files
committed
Merge branches 'read-p' and 'testfix/cygwin-customaction'
3 parents b25c791 + 4662651 + bab2af9 commit 4cd6822

File tree

5 files changed

+28
-32
lines changed

5 files changed

+28
-32
lines changed

tests/actions-test-lib.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,19 @@ make_action_in_folder()
3030
mkdir ".todo.actions.d/$1"
3131
[ -z "$1" ] || make_dummy_action ".todo.actions.d/$1/$1" "in folder $1"
3232
}
33+
34+
invalidate_action()
35+
{
36+
local customActionFilespec="${1:?}"; shift
37+
local testName="${1:?}"; shift
38+
39+
chmod -x "$customActionFilespec"
40+
# On Cygwin, clearing the executable flag may have no effect, as the Windows
41+
# ACL may still grant execution rights. In this case, we skip the test, and
42+
# remove the (still valid) custom action so that it doesn't break following
43+
# tests.
44+
if [ -x "$customActionFilespec" ]; then
45+
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }${testName}"
46+
rm -- "$customActionFilespec"
47+
fi
48+
}

tests/t1800-del.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ test_description='basic del functionality
44
'
55
. ./test-lib.sh
66

7-
SPACE=' '
8-
97
test_todo_session 'del usage' <<EOF
108
>>> todo.sh del B
119
usage: todo.sh del ITEM# [TERM]
@@ -60,7 +58,7 @@ test_todo_session 'del with confirmation' <<EOF
6058
TODO: 3 of 3 tasks shown
6159
6260
>>> printf n | todo.sh del 1
63-
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
61+
\\
6462
TODO: No tasks were deleted.
6563
6664
>>> todo.sh -p list
@@ -71,15 +69,15 @@ TODO: No tasks were deleted.
7169
TODO: 3 of 3 tasks shown
7270
7371
>>> printf x | todo.sh del 1
74-
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
72+
\\
7573
TODO: No tasks were deleted.
7674
7775
>>> echo | todo.sh del 1
78-
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
76+
\\
7977
TODO: No tasks were deleted.
8078
8179
>>> printf y | todo.sh del 1
82-
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
80+
\\
8381
1 (B) smell the uppercase Roses +flowers @outside
8482
TODO: 1 deleted.
8583

tests/t1850-move.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ test_description='basic move functionality
44
'
55
. ./test-lib.sh
66

7-
SPACE=' '
8-
97
cat > todo.txt <<EOF
108
(B) smell the uppercase Roses +flowers @outside
119
(A) notice the sunflowers
@@ -42,7 +40,7 @@ x 2009-02-13 smell the coffee +wakeup
4240
EOF
4341
test_todo_session 'basic move with confirmation' <<EOF
4442
>>> 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'
45-
Move '(B) smell the uppercase Roses +flowers @outside' from todo.txt to done.txt? (y/n)$SPACE
43+
\\
4644
1 (B) smell the uppercase Roses +flowers @outside
4745
TODO: 1 moved from 'todo.txt' to 'done.txt'.
4846

tests/t8010-listaddons.sh

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,7 @@ ls
2828
quux
2929
EOF
3030

31-
chmod -x .todo.actions.d/foo
32-
# On Cygwin, clearing the executable flag may have no effect, as the Windows ACL
33-
# may still grant execution rights. In this case, we skip the test.
34-
if [ -x .todo.actions.d/foo ]; then
35-
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }t8010.4"
36-
fi
31+
invalidate_action .todo.actions.d/foo t8010.4
3732
test_todo_session 'nonexecutable action' <<EOF
3833
>>> todo.sh listaddons
3934
bar
@@ -66,13 +61,7 @@ norris
6661
quux
6762
EOF
6863

69-
# nthorne: shamelessly stolen from above..
70-
chmod -x .todo.actions.d/norris/norris
71-
# On Cygwin, clearing the executable flag may have no effect, as the Windows ACL
72-
# may still grant execution rights. In this case, we skip the test.
73-
if [ -x .todo.actions.d/norris/norris ]; then
74-
SKIP_TESTS="${SKIP_TESTS}${SKIP_TESTS+ }t8010.8"
75-
fi
64+
invalidate_action .todo.actions.d/norris/norris t8010.8
7665
test_todo_session 'nonexecutable action in subfolder' <<EOF
7766
>>> todo.sh listaddons
7867
bar

todo.sh

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -364,12 +364,11 @@ confirm()
364364
{
365365
[ $TODOTXT_FORCE = 0 ] || return 0
366366

367-
printf %s "${1:?}? (y/n) "
368367
local readArgs=(-e -r)
369368
[ -n "${BASH_VERSINFO:-}" ] && [ \( ${BASH_VERSINFO[0]} -eq 4 -a ${BASH_VERSINFO[1]} -ge 1 \) -o ${BASH_VERSINFO[0]} -gt 4 ] &&
370369
readArgs+=(-N 1) # Bash 4.1+ supports -N nchars
371370
local answer
372-
read "${readArgs[@]}" answer
371+
read -p "${1:?}? (y/n) " "${readArgs[@]}" answer
373372
echo
374373
[ "$answer" = "y" ]
375374
}
@@ -451,8 +450,7 @@ replaceOrPrepend()
451450
getTodo "$item"
452451

453452
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
454-
echo -n "$querytext"
455-
read -r -i "$todo" -e input
453+
read -p "$querytext" -r -i "$todo" -e input
456454
else
457455
input=$*
458456
fi
@@ -1082,8 +1080,7 @@ fi
10821080
case $action in
10831081
"add" | "a")
10841082
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
1085-
echo -n "Add: "
1086-
read -e -r input
1083+
read -p "Add: " -e -r input
10871084
else
10881085
[ -z "$2" ] && die "usage: $TODO_SH add \"TODO ITEM\""
10891086
shift
@@ -1094,8 +1091,7 @@ case $action in
10941091

10951092
"addm")
10961093
if [[ -z "$2" && $TODOTXT_FORCE = 0 ]]; then
1097-
echo -n "Add: "
1098-
read -e -r input
1094+
read -p "Add: " -e -r input
10991095
else
11001096
[ -z "$2" ] && die "usage: $TODO_SH addm \"TODO ITEM\""
11011097
shift
@@ -1135,8 +1131,7 @@ case $action in
11351131
getTodo "$item"
11361132

11371133
if [[ -z "$1" && $TODOTXT_FORCE = 0 ]]; then
1138-
echo -n "Append: "
1139-
read -e -r input
1134+
read -p "Append: " -e -r input
11401135
else
11411136
input=$*
11421137
fi

0 commit comments

Comments
 (0)