-
Notifications
You must be signed in to change notification settings - Fork 716
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
Improve GNU sed fallback while allowing use of -i.bak #447
Open
inkarkat
wants to merge
7
commits into
todotxt:master
Choose a base branch
from
inkarkat:fix-inplace-sed
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dcd470a
fix: Improve fallback when using sed
hyperupcall d162645
Removed: Superfluous error handling
inkarkat 8783186
ENH: Allow overriding sed command via TODOTXT_SED_COMMAND
inkarkat 96818cf
ENH: Allow opt-in to sed emulation for add-ons via TODOTXT_SED_EXPORT…
inkarkat 2268f21
Minor: Prefer $TMPDIR if set; use /tmp as fallback
inkarkat e84a78e
Refactoring: Minor: Use if...then, single quotes, other separator, en…
inkarkat 3232901
ENH: Auto-detect sed in-place editing capability during "make install"
inkarkat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What if instead of
TODOTXT_SED_COMMAND
, we introduce some sort ofTODOTXT_ENABLE_SED_SHIM
, which is disabled by default?Then, we can do:
That way, we can have better performance by default. If we go this route, then the variable
TODOTXT_SED_EXPORT_FOR_ADDONS
could be renamed to a more consistentTODOTXT_SED_EXPORT_SHIM_FOR_ADDONS
. (and we would also have to check for this new variable before theexport -f sed
below)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.
Thinking about it, and maybe
SHIM
isn't the best word, because that could imply that it's some special file atbin/sed
, which imply an worse performance impact than it actually is. But even with a better name, the idea is the sameThere 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.
The ability to inject a custom
sed
command covers scenarios where people have a capablesed
installed, but not accessible throughPATH
, or with a non-standard name. (Additionally, it enables nifty dev use cases, like injecting averboseSed
command that logs the sed arguments for troubleshooting.) To me, that's more flexibility for zero cost (versus an alternative yes/no flag).If we go back to disabling the workaround by default, BSD and Busybox users are faced with a strange error message, and somehow have to find the workaround, like before. It's just a bit more convenient because the function is now packaged inside
todo.sh
, not a snippet they have to copy-and-paste into their configuration. But I'm afraid many won't easily find the flag in the config (who reads documentation and comments?), maybe google it, and then either find the GitHub issues (or just the older discussion mentioning the snippet).I found a (somewhat clever 😊) way to auto-detect the in-place capability in the
Makefile
and manipulate the default config (which is already done for theTODO_DIR
, anyway). It's still quite a bit of code for a very minor optimization, but now that CI/CD performsmake [un]install
for every change, it feels acceptable to me. I have no idea how many users use which installation method, and how many are actually using BSD / Busybox withtodo.sh
; if someone else argues with simplicity and to scrap the whole workaround in this PR, I'd be fine with that, too.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.
The ability to inject a custom sed command covers scenarios where people have a capable sed installed, but not accessible through PATH, or with a non-standard name. (Additionally, it enables nifty dev use cases, like injecting a verboseSed command that logs the sed arguments for troubleshooting.) To me, that's more flexibility for zero cost (versus an alternative yes/no flag).
👍
I really wouldn't want to force somebody to look up some random GitHub issue to get things to work if say they're on Busybox and get some sort of error. So yeah, better to enable the workaround by default
With the code already written, I see no reason to remove it! I think the auto-detection optimization is a good improvement