Skip to content

Commit 6d151b8

Browse files
Pass envp to execvpe (#16340)
1 parent e43bb14 commit 6d151b8

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

spec/std/process_spec.cr

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -388,19 +388,8 @@ describe Process do
388388
end
389389
{% end %}
390390

391-
if {{ flag?(:win32) }}
392-
it "finds binary in parent `$PATH`, not `env`" do
393-
Process.run(*print_env_command, env: {"PATH" => ""})
394-
end
395-
else
396-
# FIXME: This behaviour is incorrect. It should lookup the command in
397-
# the parent process' `$PATH`, without any changes from `env`.
398-
# https://github.com/crystal-lang/crystal/issues/6464#issuecomment-3391000914
399-
it "finds binary in `env`" do
400-
expect_raises(File::NotFoundError) do
401-
Process.run(*print_env_command, env: {"PATH" => ""})
402-
end
403-
end
391+
it "finds binary in parent `$PATH`, not `env`" do
392+
Process.run(*print_env_command, env: {"PATH" => ""})
404393
end
405394

406395
it "errors on invalid key" do

src/crystal/system/unix/process.cr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ struct Crystal::System::Process
342342
reopen_io(output, ORIGINAL_STDOUT)
343343
reopen_io(error, ORIGINAL_STDERR)
344344

345-
LibC.environ = Env.make_envp(env, clear_env)
345+
envp = Env.make_envp(env, clear_env)
346346
::Dir.cd(chdir) if chdir
347347

348-
execvpe(*prepared_args, LibC.environ)
348+
execvpe(*prepared_args, envp)
349349
end
350350

351351
private def self.execvpe(file, argv, envp)

0 commit comments

Comments
 (0)