Following-up on the last suggestion of a previous answer, I am trying to find a way to disable interpretation of the parameters I want to feed to an executable
Since
D:\program.exe this is a #full sentence
will discard #full sentence
as a comment (and I specifically do not want to use quotes), I was hoping that an intermediate function would fix the problem:
function global:note {
D:\program.exe --% @Args
}
The rationale was that I do not want to interpret anything after --%
in the course of the execution of program.exe
, but still want to replace @Args
when running the function note
(as part of the execution of the function). Unfortunately, the result is a verbatim
D:\program.exe @Args
(the argument of program.exe
is the string @Args
)
My question: why isn't @Args
expanded in the presence of --%
, and the expansion happens without? Isn't --%
supposed to stop the interpretation of the command line (i.e. do not interpret the command line for D:\program.exe this is a #full sentence
when the arguments of the function are this is a #full sentence
)
Following Matthias' comment on splatting, here is what I get in different scenarios:
Case 1
function global:note {
D:\program.exe @Args
}
Output when typing note this is a #complete sentence
at the PS prompt:
this is a
Case 2
function global:note {
D:\program.exe --% @Args
}
Output when typing note this is a #complete sentence
at the PS prompt:
@Args