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).
jparise
left a comment
There was a problem hiding this comment.
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.
A few thoughts:
- Is it common to alias
sedtosd? That seems risky given thatsddoesn'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
sedto 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
sedentirely, 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-preexectargets.
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 whitespaceI 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