Refactoring: Use read -p MSG instead of doing echo -n MSG separately
I've seen strange readline editing behavior when the editing doesn't start at the first column: I can actually backspace into the prepended message (with Del, Ctrl-W or Ctrl-U), and then the whole edit becomes messed up. read can output a prompt on its own (hopefully in all versions of Bash that we aim to support - the tests will tell), and that doesn't have this problem, and it's also a bit cleaner and shorter. The prompt is only displayed if input is coming from a terminal. For the tests (currently only deletion and move confirmations are covered), this means that the prompt itself cannot be covered, and an empty line instead has to be expected. (On the positive side, this removes the ugly trick with $SPACE.)
This commit is contained in:
@@ -4,8 +4,6 @@ test_description='basic del functionality
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
SPACE=' '
|
||||
|
||||
test_todo_session 'del usage' <<EOF
|
||||
>>> todo.sh del B
|
||||
usage: todo.sh del ITEM# [TERM]
|
||||
@@ -60,7 +58,7 @@ test_todo_session 'del with confirmation' <<EOF
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> printf n | todo.sh del 1
|
||||
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
|
||||
\\
|
||||
TODO: No tasks were deleted.
|
||||
|
||||
>>> todo.sh -p list
|
||||
@@ -71,15 +69,15 @@ TODO: No tasks were deleted.
|
||||
TODO: 3 of 3 tasks shown
|
||||
|
||||
>>> printf x | todo.sh del 1
|
||||
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
|
||||
\\
|
||||
TODO: No tasks were deleted.
|
||||
|
||||
>>> echo | todo.sh del 1
|
||||
Delete '(B) smell the uppercase Roses +flowers @outside'? (y/n)$SPACE
|
||||
\\
|
||||
TODO: No tasks were deleted.
|
||||
|
||||
>>> 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
|
||||
TODO: 1 deleted.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user