Skip to content

Commit

Permalink
skip cmd quote handling
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Nov 20, 2023
1 parent 39ac68d commit 9fe8bd6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/crystal/system/win32/process.cr
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,9 @@ struct Crystal::System::Process
process_info = LibC::PROCESS_INFORMATION.new

if command_args.is_a?(String)
raise ArgumentError.new("Command line contains newline") if command_args.includes?('\n')
result = LibC.CreateProcessW(
CMD_EXE, System.to_wstr(%(/c "#{command_args}")), nil, nil, true, LibC::CREATE_UNICODE_ENVIRONMENT,
CMD_EXE, System.to_wstr(%(/s /c "#{command_args}")), nil, nil, true, LibC::CREATE_UNICODE_ENVIRONMENT,
make_env_block(env, clear_env), chdir.try { |str| System.to_wstr(str) } || Pointer(UInt16).null,
pointerof(startup_info), pointerof(process_info)
)
Expand Down
2 changes: 1 addition & 1 deletion src/process.cr
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class Process
# * On Windows this is implemented by passing the string as-is to `%COMSPEC%`,
# and passing *args* is not supported. The user is responsible for correctly
# quoting the command string, as `Process.quote_windows` does not handle
# this.
# this. Additionally, *command* cannot contain the newline character (`\n`).
#
# Raises `IO::Error` if executing the command fails (for example if the executable doesn't exist).
def initialize(command : String, args = nil, env : Env = nil, clear_env : Bool = false, shell : Bool = false,
Expand Down

0 comments on commit 9fe8bd6

Please sign in to comment.