Skip to content
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

adding command to the history #559

Closed
Edo78 opened this issue May 5, 2023 · 6 comments
Closed

adding command to the history #559

Edo78 opened this issue May 5, 2023 · 6 comments

Comments

@Edo78
Copy link

Edo78 commented May 5, 2023

I'm wondering if it's possibile to have the executed command added to the history.
Is there an option that I can't find or it's a feature that doesn't exists (yet)?

@ehmicky
Copy link
Collaborator

ehmicky commented May 5, 2023

Hi @Edo78,

By history, do you mean the shell history, e.g. the Bash REPL history?

@Edo78
Copy link
Author

Edo78 commented May 6, 2023

Hi @Edo78,

By history, do you mean the shell history, e.g. the Bash REPL history?

Yes, sorry for being too vague. I'd like the command to be added to the interactive shell history if it's possible

@ehmicky
Copy link
Collaborator

ehmicky commented May 6, 2023

Thanks for explaining.

There would be a few issues with this:

  • Execa does not use a shell by default. To put non-shell commands in a shell history file would require escaping them appropriately, which is not simple nor shell-agnostic.
  • Multiple shells can be used. By default, it is sh on Unix and cmd.exe on Windows. Others can be specified. To remain shell-agnostic, Execa would need to support multiple shells.
  • Execa would need to detect the shell type, since sh is usually a symlink towards different possible shells (dash, Bash, etc.). I believe some older shells don't even have histories. Others use different files.
  • Since programmatic process execution can easily spawn thousands of processes in a short amount of time, and we don't want to flood the history file, we might consider adding rate limiting.

That being said, I can see how this feature could be useful. However, it seems like it might be a significant effort to implement properly and while respecting Execa current design (shell-agnostic with no shell by default). Based on this, I would favor not implementing this, although I am curious to hear what @sindresorhus thinks. 🤔

Also, this can probably be implemented with a module built on top of Execa, if you're open to experiment creating one. This would help keeping Execa small and modular.

@Edo78
Copy link
Author

Edo78 commented May 6, 2023

I fully understand every and each point you made.

Can you elaborate on building execa module? I'll be willing to give it a try (while learning something new)

@ehmicky
Copy link
Collaborator

ehmicky commented May 6, 2023

I am thinking of a module which would wrap Execa. I.e. the arguments and return value would be forwarded to Execa, but the module would also add the history feature.

I am going to close this issue preemptively, but we can re-open it if @sindresorhus thinks the history feature is a good idea to implement in Execa itself.

@ehmicky ehmicky closed this as completed May 6, 2023
@sindresorhus
Copy link
Owner

Shell history is outside the scope of what we intend to do with Execa.

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

No branches or pull requests

3 participants