Skip to content

Commit 1c22193

Browse files
committed
[shellenv] Fix infinite loop
1 parent e1a4e77 commit 1c22193

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

internal/wrapnix/wrapper.sh.tmpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ fi
1414
{{- end }}
1515

1616
{{/*
17-
We use ShellEnvHashKey to avoid re-sourcing shellenv. Since wrappers
18-
call other wrappers and potentially modify the environment, we don't want the
19-
environment to get re-written.
17+
We use ShellEnvHashKey to prevent doing shellenv if the correct envrioment is
18+
already set. (perf optimization)
19+
20+
We use the guard to prevent infinite loop if something in shellenv causes
21+
another wrapped binary to be called. The guard is specific to this project so shellenv
22+
could stil cause another project's shellenv to be called.
2023

2124
DO_NOT_TRACK=1 can be removed once we optimize segment to queue events.
2225
*/ -}}
2326

24-
if [[ "${{ .ShellEnvHashKey }}" != "{{ .ShellEnvHash }}" ]]; then
27+
if [[ "${{ .ShellEnvHashKey }}" != "{{ .ShellEnvHash }}" ]] && [[ -z "${{ .ShellEnvHashKey }}_GUARD" ]]; then
28+
export {{ .ShellEnvHashKey }}_GUARD=true
2529
eval "$(DO_NOT_TRACK=1 devbox shellenv -c {{ .ProjectDir }})"
2630
fi
2731

0 commit comments

Comments
 (0)