You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Process.new (and .run) has two parameters, command for the command to be executed, and args for the arguments.
I'm not quite sure what's the reasoning behind this separation. It's been established since the early days of Crystal (0b35fa5) and is probably inherited from Ruby's Kernel#exec.
In many (most?) other APIs, the equivalent method receives a single list of arguments, where the first one represents the command to execute. This is similar to the way process execution is modeled in Unix.
Process even uses this representation internally: The command and args parameters are merged into a single array in Process.prepare_args. Even on Windows.
This internal representation as Array(String) is additional allocation which is actually just an intermediary: On Unix, the array is mapped to an array of pointers to those strings. On Windows it's mapped to an array of wide strings (Array(Slice(UInt16))).
This intermediate representation should be avoidable.
However, we might also want to consider whether the public API could use the single array model where the command is just the first element. I'm not sure if this has any clear benefit expect being more similar to other APIs.
This was breviously mentioned in #9030 before. And I suppose this might have some relevancy the shell: true conundrum.
The text was updated successfully, but these errors were encountered:
Process.new
(and.run
) has two parameters,command
for the command to be executed, andargs
for the arguments.I'm not quite sure what's the reasoning behind this separation. It's been established since the early days of Crystal (0b35fa5) and is probably inherited from Ruby's
Kernel#exec
.In many (most?) other APIs, the equivalent method receives a single list of arguments, where the first one represents the command to execute. This is similar to the way process execution is modeled in Unix.
Process
even uses this representation internally: Thecommand
andargs
parameters are merged into a single array inProcess.prepare_args
. Even on Windows.This internal representation as
Array(String)
is additional allocation which is actually just an intermediary: On Unix, the array is mapped to an array of pointers to those strings. On Windows it's mapped to an array of wide strings (Array(Slice(UInt16))
).This intermediate representation should be avoidable.
However, we might also want to consider whether the public API could use the single array model where the command is just the first element. I'm not sure if this has any clear benefit expect being more similar to other APIs.
This was breviously mentioned in #9030 before. And I suppose this might have some relevancy the
shell: true
conundrum.The text was updated successfully, but these errors were encountered: