-
Notifications
You must be signed in to change notification settings - Fork 702
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
fix: use builtin sed #4991
fix: use builtin sed #4991
Conversation
This commit fixes alias conflicts by explicitly using `\sed`. This ensures compatibility in environments where sed is aliased to a non-compatible tool, such as `alias sed=sd` (chmln/sd).
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.
I'll give this a deeper look shortly, but I also want to be cognizant of diverging from the upstream project.
Seems as if we already diverge from upstream a bit. Perhaps we should upstream this change and then use
|
If it's actively maintained (looks like it), I think we should upstream these changes and try to remain mainlined. |
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.
A few thoughts:
- Is it common to alias
sed
tosd
? That seems risky given thatsd
doesn't provide ased
-compatible command line interface (in a "you're knowingly voiding the warranty" kind of way). - This proposed change seems fine to me, although it does flip the assumption that someone who intentionally aliased
sed
to a sed-compatible tool won't get that benefit here. I doubt that matters in practice though. - I'd ultimately prefer to drop the dependency on
sed
entirely, which we should be able to do with bash's shell parameter expansion syntax, although I'd need to look more closely to see if what's needed would be supported by the full range of bash versions thatbash-preexec
targets.
For example, we previously used something like this in our own shell integration script to avoid calling sed
for this use case:
cmd=$(builtin history 1)
cmd="${cmd#*[[:digit:]]*[[:space:]]}" # remove leading history number
cmd="${cmd#"${cmd%%[![:space:]]*}"}" # remove remaining leading whitespace
I think that would make for a more attractive upstream change (assuming it's version-compatible).
But for the purposes of this change, I'm good with integrating it in the short term if we agree this is an issue that needs addressing while we look at the long-term options.
I think in general for scripts like this, we want to use the tool we expect and DON'T want user aliases coming through. As long as we can get to a point where we're mostly doing POSIX-standard things then I think that's especially true as we expect POSIX behavior. |
I think that would work if we make the |
Yes, I agree with that (for the same reason we want to use My point was more about people who were expecting it to work that way before (in a compatible way), but I can't think of why that would be important in practice. |
Here's an upstream change that aims to remove one instance of |
I have two pending upstream changes that should also address this issue:
Let's wait a few on this PR. If those get merged, we can pull them down instead. |
While those upstream pull requests are under consideration (which might take some time), I've moved forward with our own copies of those changes: |
Was going to ask this. Agree |
This commit fixes alias conflicts by explicitly using
\sed
. This ensures compatibility in environments where sed is aliased to a non-compatible tool, such asalias sed=sd
(chmln/sd).Fixes #4990