Skip to content

Commit

Permalink
Fix portable shell command arguments in Process#prepare_args (cryst…
Browse files Browse the repository at this point in the history
…al-lang#13942)

Co-authored-by: psykose <[email protected]>
  • Loading branch information
GeopJr and nekopsykose authored Nov 6, 2023
1 parent 0daa835 commit 67c85e3
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/crystal/system/unix/process.cr
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,13 @@ struct Crystal::System::Process
def self.prepare_args(command : String, args : Enumerable(String)?, shell : Bool) : Array(String)
if shell
command = %(#{command} "${@}") unless command.includes?(' ')
shell_args = ["/bin/sh", "-c", command, "--"]
shell_args = ["/bin/sh", "-c", command, "sh"]

if args
unless command.includes?(%("${@}"))
raise ArgumentError.new(%(Can't specify arguments in both command and args without including "${@}" into your command))
end

{% if flag?(:freebsd) || flag?(:dragonfly) %}
shell_args << ""
{% end %}

shell_args.concat(args)
end

Expand Down

0 comments on commit 67c85e3

Please sign in to comment.