Skip to content

Commit 0ec1144

Browse files
Add pathname to command_args
1 parent bf66db5 commit 0ec1144

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/crystal/system/unix/process.cr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ struct Crystal::System::Process
307307
pid
308308
end
309309

310-
def self.prepare_args(command : String, args : Enumerable(String)?, shell : Bool) : Array(String)
310+
def self.prepare_args(command : String, args : Enumerable(String)?, shell : Bool) : {String, Array(String)}
311311
if shell
312312
command = %(#{command} "${@}") unless command.includes?(' ')
313313
shell_args = ["/bin/sh", "-c", command, "sh"]
@@ -320,11 +320,11 @@ struct Crystal::System::Process
320320
shell_args.concat(args)
321321
end
322322

323-
shell_args
323+
{"/bin/sh", shell_args}
324324
else
325325
command_args = [command]
326326
command_args.concat(args) if args
327-
command_args
327+
{command, command_args}
328328
end
329329
end
330330

@@ -344,11 +344,11 @@ struct Crystal::System::Process
344344

345345
::Dir.cd(chdir) if chdir
346346

347-
command = command_args[0]
347+
pathname, argv = command_args
348348
argv = command_args.map &.check_no_null_byte.to_unsafe
349349
argv << Pointer(UInt8).null
350350

351-
lock_write { LibC.execvp(command, argv) }
351+
lock_write { LibC.execvp(pathname, argv) }
352352
end
353353

354354
def self.replace(command, command_args, env, clear_env, input, output, error, chdir)

src/process.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class Process
221221
output = exec_stdio_to_fd(output, for: STDOUT)
222222
error = exec_stdio_to_fd(error, for: STDERR)
223223

224-
Crystal::System::Process.replace(command_args, env, clear_env, input, output, error, chdir)
224+
Crystal::System::Process.replace(command, command_args, env, clear_env, input, output, error, chdir)
225225
end
226226

227227
private def self.exec_stdio_to_fd(stdio : ExecStdio, for dst_io : IO::FileDescriptor) : IO::FileDescriptor

0 commit comments

Comments
 (0)