Skip to content

Commit 6b4312b

Browse files
authored
Use null character ending with env (#1996)
Line splitting was less safe as some scripts inject `BASH_FUNC_...` env variables which have newlines in them
1 parent 96b5db4 commit 6b4312b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cookbook/foreign_shell_scripts.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ def capture-foreign-env [
101101
echo '<ENV_CAPTURE_EVAL_FENCE>'
102102
eval "$SCRIPT_TO_SOURCE"
103103
echo '<ENV_CAPTURE_EVAL_FENCE>'
104-
env -u _ -u _AST_FEATURES -u SHLVL` # Filter out known changing variables
104+
env -0 -u _ -u _AST_FEATURES -u SHLVL` # Filter out known changing variables
105105
}
106106
| split row '<ENV_CAPTURE_EVAL_FENCE>'
107107
| {
108108
before: ($in | first | str trim | lines)
109-
after: ($in | last | str trim | lines)
109+
after: ($in | last | str trim | split row (char --integer 0))
110110
}
111111
112112
# Unfortunate Assumption:

0 commit comments

Comments
 (0)