-
Notifications
You must be signed in to change notification settings - Fork 715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Housekeeping: Combined PR of all of my outstanding PRs. #405
Conversation
The action script creation in both test helper functions is pretty similar; extract a function for that so that the invocation is a single command.
Instead of potentially falling back to the built-in action that a custom action was intended to override, but (e.g. due to file system reorganizations) now results in a broken link. The extension functionality that is then skipped may result in undesired results, but this may not be immedately obvious to the user (if the extension is not particularly verbose), so some data corruption could occur if this remains undetected. To avoid duplicating (or somehow extracting) all the built-in actions, simply detect _any_ broken symlink; i.e. offer a superset of the required functionality. So this would also complain about a broken symlink to a non-executable custom (auxiliary) file (rarely used) if that is mistakenly passed as a custom action (unlikely). Fixes todotxt#359
There's no command-line option to reduce verbosity (just -v to increase it), so users who would like to remove the additional messages (cp. todotxt#364) have to configure this, but the variable is hard to find. Include the default value in commented-out form and some documentation of the possible values.
And only coincidentally picked up as the global configuration (if CONFIG_DIR=/etc). Fixes todotxt#377
…tion to copy the template
I didn't know about printf's capability when I introduced quoting 10 years ago. The %q format will do the quoting, and "-v VAR" can be used to reassign to the variable. Note: The shellquote() function has been exported for reuse by add-ons. I don't think anyone has ever used that (it was mostly intended for my own, extensive extensions, and I never used it), and is trivial to move away from, anyway.
This doesn't matter if (as currently recommended) the script is placed into a eagerly loaded location (like /etc/bash_completion.d/) - any name will do. However, there's now lazy loading of completion scripts (in /usr/share/bash-completion/completions/), and that only works when the completion script is named exactly like the command the completion is for. As our command is todo.sh (ignoring aliases, which become more complex with lazy loading), the corresponding completion needs to be todo.sh (with the .sh extension) as well. Renaming does not do any harm for our recommended location, but makes it easier for users (and packagers who prepare a todo.sh package) that want to use lazy loading. See todotxt#383 for the complete discussion.
So that any combination of priority / date entered in the replacement will replace the corresponding original ones, but if they are left out, the original ones will be kept. In essence, omitted stuff will be kept, added stuff will override, only deletion of existing stuff is not possible (but this is replace, after all). Fixes todotxt#386
If a custom action cannot be made non-executable, it needs to be removed as well (and the test skipped); otherwise its existence will break following tests that assume it's inactive.
We don't "shamelessly steal" code, we refactoring it ;-)
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.)
By convention, error output should be printed to standard error, not standard out. Same for the usage help that may accompany the error message.
To indicate that something went wrong (e.g. the task already was unprioritized). Note: For actions that handle multiple ITEMs in a loop, we cannot use die() as that would abort processing of any following ITEM(s). Instead, use a status variable and set it to 1 on error, then exit at the end.
I'm all for a new release when this is merged! |
@inkarkat Thank you so much for this. Much easier to review. Do you know why the |
@karbassi The Mac tests have been failing for a very long time. I'm not sure I remember this correctly, but there was an update to a newer MacOS version, and since then that newline handling (that's what add to file without EOL is about) was broken. Ah, it was discovered here: #369 (comment) |
@inkarkat Trying to fix the tests. I'm unsure wether I'm on the right track though, could this be related?
|
@chrysle Yes, this is related to the CR vs. LF problem. The test failure (e.g. here) shows that the missing newline isn't added:
Instead, the second task is appended to the first one:
In the code, the |
Thank you for the reply!
It looks like the MacOS FreeBSD
Since I'm too frustrated with BSD We'd also need to tweak the |
Have you tried
I meant documenting (in the Readme) that the script requires GNU sed, and that / how it can be installed via Homebrew. Ideally only users who care about the missing newline would need to install GNU sed, and the rest could just use the script as-is. That doesn't help with the failing GitHub action, though. But if we go with an optional dependency, I would rather keep the MacOS 11 image with its BSD sed, and just skip that failing test there.
Or alternatively define a wrapper function:
|
I have, also with a similar command. But there is a problem. |
It can be useful to filter for non-consecutive priority ranges. By enforcing uppercase in that added syntax, overlap with general TERM(s) (e.g. "foo-bar") can be mostly avoided (and in the rare case of having to filter by all-uppercase TERM(s) one can always pass the default A-Z filter, anyway).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏽
Great to see this merged! ❤️ |
This is a combined merge of the PRs that I've submitted over the last couple of months; I've been using it all the time myself. @karbassi if you take this, you'll save us the hassle of figuring out any merge conflicts, and it's less work than going over each of my PRs individually.
Closes #360 Robustness: Check for broken symlinks to custom actions and complain
Closes #365 Add TODOTXT_VERBOSE to the configuration
Closes #379 Readme: Clarify CONFIG_DIR and recommend copy of config template
Closes #380 Refactoring: Replace shellquote() with printf %q
Closes #384 Renaming: Add .sh extension to completion script
Closes #387 replace: Completely merge given priority / date with existing
Closes #388 TESTSFIX: t8010-listaddons breaks on Cygwin
Closes #389 Refactoring: Use read -p MSG instead of doing echo -n MSG separately
Closes #404 FIX: Use standard error for die(), dieWithHelp(), and error messages
Before submitting a pull request, please make sure the following is done:
master
.fixes #XX
reference to the issue that this pull request fixes.