Commit 65c3c1c
authored
[envvars] Fix error when env contains Bash function (#2612)
## Summary
Fixes #995 - Error running `devbox shell` in environment with exported
Bash function
## How was it tested?
Tested that when running the below commands:
- no errors are printed
- the `foo` function runs successfully and prints `foo`
Case 1 (simple):
```
foo() { echo foo; }
export -f foo
devbox shell
foo
```
Case 2 (function that contains special characters `"` and `$`):
```
foo() { echo "${bar}"; }
export -f foo
export bar=foo
devbox shell
foo
```
Case 3 (`shellenv`):
```
foo() { echo foo; }
export -f foo
devbox shellenv > shellrc
# open a new shell
source shellrc
foo
```
Also added a Bash function to the test data used by
`TestWriteDevboxShellrc`.
## Community Contribution License
All community contributions in this pull request are licensed to the
project
maintainers under the terms of the
[Apache 2 License](https://www.apache.org/licenses/LICENSE-2.0).
By creating this pull request, I represent that I have the right to
license the
contributions to the project maintainers under the Apache 2 License as
stated in
the
[Community Contribution
License](https://github.com/jetify-com/opensource/blob/main/CONTRIBUTING.md#community-contribution-license).1 parent 70964d8 commit 65c3c1c
File tree
3 files changed
+28
-12
lines changed- internal/devbox
- testdata/shellrc/basic
3 files changed
+28
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
42 | 56 | | |
43 | | - | |
| 57 | + | |
44 | 58 | | |
45 | | - | |
46 | 59 | | |
47 | 60 | | |
48 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
0 commit comments