Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Generic command to add shell prelude #3350

Open
eraserhd opened this issue Feb 7, 2020 · 1 comment
Open

Generic command to add shell prelude #3350

eraserhd opened this issue Feb 7, 2020 · 1 comment

Comments

@eraserhd
Copy link
Contributor

eraserhd commented Feb 7, 2020

The idea: a command like so:

define-shell-prelude kakquote %{
  kakquote() {
    : # implementation
  }
}

When the word specified in the first arg (kakquote) is encountered in a shell expansion, the text of the second arg is prepended to the shell expansion. The text could be source /path/to/file.sh.

It could be adding an element to $PATH, allowing binaries to be shipped with plugins without needing an option to compute their full path. (Although it might be better to have a facility just to set $PATH.)

This could be provided in a module which is required by other modules.

Transitive dependencies (other prelude blobs and variables used by them) can be precomputed and updated when a define-shell-prelude command is read to improve processing time, if needed.

The main idea here is to avoid including unused prelude (for example, prepending kakquote to every shell invocation, even when it isn't used), while still allowing the reuse of shell functions, including those provided by plugins.

@lenormf
Copy link
Contributor

lenormf commented Feb 7, 2020

This mechanism looks very brittle, and could potentially backstab users who are not aware some code is being injected into their scripts.

Making users explicitly source a file shipped with Kakoune seems like a safer solution, especially if the hypothetical implementation of the commands being injected is going to be just a call to source.

Or ship full scripts and let the user fix their $PATH, c.f. #1430.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants