Skip to content

Conversation

ipince
Copy link
Contributor

@ipince ipince commented Feb 16, 2023

Summary

I guess it actually was ready right on time on 2/16 :). (but not for a 2/16 release)

How was it tested?

testscript tests and using it while developing

@ipince ipince requested a review from savil February 16, 2023 23:11
@savil
Copy link
Collaborator

savil commented Feb 17, 2023

tests need updating

@ipince
Copy link
Contributor Author

ipince commented Feb 21, 2023

tests need updating

Yeah, working on it on a separate PR

@ipince
Copy link
Contributor Author

ipince commented Feb 21, 2023

Done in #660

@ipince ipince force-pushed the rodrigo/enable-unified-env branch from fc56f0f to ce44e68 Compare February 21, 2023 17:18
@ipince ipince merged commit 0fdee09 into main Feb 22, 2023
@ipince ipince deleted the rodrigo/enable-unified-env branch February 22, 2023 17:32
@ipince ipince mentioned this pull request Feb 22, 2023
ipince added a commit that referenced this pull request Feb 23, 2023
## Summary
Adds support for `fish` shell.

When running `devbox shell`:
We write the post-initialization steps into a "shellrc" file (see
`shellrc_fish.tmpl`). I attempted to reuse the existing `shellrc.tmpl`,
but the differences in syntax between fish and other shells were large
enough that I had to separate them. Next, we invoke `fish -C <shellrc>`.
This will make `fish` use the user's existing config first, and _then_
run whatever is in `<shellrc>`, which is similar to what we do for
non-fish shells.

When running `devbox run`:
- If unified env is ON, then we invoke `sh -c <script>` just like we do
for every other shell.
- If unified env is OFF, then we'll invoke `fish -C <shellrc> -c
<script>`. However, note that #650 already enables unified env by
default, so this branch is mainly here just in case something goes wrong
with unified env and we need to revert.

Caveats:
- We don't check any of the syntax in devbox.json's init hook or
scripts. If an init hook uses fish-specific syntax, then it will work
for users using `fish`, but it won't for users using a different shell.
Similarly for scripts. Conversely, if an init hook uses POSIX syntax
that fish doesn't support (e.g. `FOO=bar`), then the init hook will fail
for fish users.
- Any plugins that use init hooks should write them in such a way that
they work for both fish and non-fish. So far, it seems only `pip` and
`ruby` use init hooks, and they're written in a compatible way (AFAIK).

## How was it tested?
I tested that both `devbox shell` and `devbox run` worked with and
without unified env. I verified that `PATH` was being set, user's config
is being run (for shell only), init hooks are being run, history file is
set (shell only), prompt is set (shell only), and scripts are written
and run.
To test with fish, it's as easy as invoking devbox as such:
```
SHELL=fish devbox shell
```
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.

2 participants