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

Add script aliases (experimental) #510

Closed
wants to merge 4 commits into from
Closed

Conversation

ipince
Copy link
Contributor

@ipince ipince commented Jan 25, 2023

Summary

This is just a quick and dirty experiment. It adds alias <script>=<path-to-script> for every script. This can unlock two potentially useful things:

  1. A script can call another script. I tested this and it works just fine.
  2. When a user is in devbox shell, they could potentially just type <script> instead of devbox run <script> and execute the script they want. That said, if you run it directly, the script would be executing within the devbox shell environment, so it may not behave exactly the same as if it were run with devbox run, which is a bit more strict/pure. Of course, the user could still run with devbox run if they wanted the other behavior.

This is just a proof-of-concept. I don't know if alias will work with different shells--need to test. I'd also need to add a guard to .hook.sh, to prevent the hooks from being run multiple times, which isn't a problem today.

How was it tested?

Tested a script can call another script, and that I can call a script inside a shell if I manually source .hooks.sh. The sourcing would have to be automatic. Haven't tested that or cross-shell support.

@ipince
Copy link
Contributor Author

ipince commented Jan 25, 2023

Oh and, of course, if a script has the same name as some other command, then the script would shadow/take precedence.

@mikeland73
Copy link
Contributor

If you add a feature flag we can go ahead and merge it

Copy link
Contributor

@mikeland73 mikeland73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RC because this is old.

Thoughts on putting this behind a devbox.json setting? (so opt-in ?)

@loreto loreto closed this Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants