bash-preexec icon indicating copy to clipboard operation
bash-preexec copied to clipboard

Use `command` to execute `sed`

Open jparise opened this issue 1 year ago • 5 comments

We want our execution environment to be a predictable as possible. Similar to how we use builtin to ensure we're running the shell's builtin function (and not a redefinition), use command to ensure we're running sed and not a shell function or alias.

jparise avatar Jan 13 '25 14:01 jparise

Some other notes:

  • We could also use the \sed syntax if that's preferred.
  • It would be nice to remove this sed call entirely, but it looks like it might be difficult to re-implement this in "native" bash.

The motivation for this change is to avoid conflicts with (incompatible) sed aliases: https://github.com/ghostty-org/ghostty/pull/4991

jparise avatar Jan 13 '25 14:01 jparise

  • It would be nice to remove this sed call entirely, but it looks like it might be difficult to re-implement this in "native" bash.

Actually. you could simply do

eval "local trap_argv=(${__bp_trap_string:-})"
prior_trap=${trap_argv[2]}

That is much nicer! Will you create a new pull request using that approach?

jparise avatar Jan 13 '25 14:01 jparise

You can modify this PR. I don't care about the credit about it.

akinomyoga avatar Jan 13 '25 14:01 akinomyoga

You can modify this PR. I don't care about the credit about it.

I created #170 so the maintainers can compare the two approaches.

jparise avatar Jan 13 '25 16:01 jparise

I created #170 so the maintainers can compare the two approaches.

Thanks!

akinomyoga avatar Jan 14 '25 01:01 akinomyoga

@rcaloras Thanks for checking and merging PRs! Now that #170 is merged, this PR (which implements an alternative approach to #170) can be closed.

akinomyoga avatar Aug 03 '25 03:08 akinomyoga