* Tests: Add coverage for del / move without -f, but with prompting
Supplying the user confirmation via "yes".
* Cosmetics: Align inconsistent spacing for before (y/n) prompt
* Refactoring: Extract confirm() function
The user confirmation query had been duplicated (once) in the code.
* Refactoring: confirm(): Leave early if forced
* Return from user prompt without requiring Enter
By just reading a single character (y for yes, anything else: no).
* Tests: Ensure that only a single "y" concludes the confirmation
By switching from "yes" (that endlessly prints newline-separated "y"s) to "printf y".
* t1800-del: Add coverage for negative confirmation
Negative means "anything but y", so "n", "x", and Enter all apply.
* Cosmetics: Add trailing space after (y/n) prompt
So that the user's typed answer is not recorded directly after it, but with separation: "Foo? (y/n) y" instead of "Foo? (y/n)y".
*Compatibility: "read -N 1" is only available in Bash 4.1+
Mac OS still ships with Bash 3.2 :-( Fall back to the original prompting that requires conclusion via Enter then.
Note: Even though the tests use "printf y", this still gets accepted, as there'll be EOF after that. In real use (when stdin from the terminal stays open), a concluding Enter is mandatory, though.
Closes#152
* Handle missing EOL in todo.txt
This can happen easily with certain editors (such as Mousepad) that do not automatically add a newline character at the end of a file.
In _addto(), ensure a trailing newline via sed (taken from https://unix.stackexchange.com/a/31955/18876).
Fixes#294
* Tests: Add basic coverage of move
* Handle missing EOL in todo.txt for move, too
This can happen easily with certain editors (such as Mousepad) that do not automatically add a newline character at the end of a file.
* Refactoring: Extract fixMissingEndOfLine()
* FIX: Compatibility: sed \+ multi not supported on MacOS
Use the POSIX \{1,\} instead.
Co-authored-by: Ali Karbassi <ali@karbassi.com>