Closed mbl-35 closed 3 years ago
Issue from ps2exe: https://github.com/MScholtes/PS2EXE/issues/54#issuecomment-897698775 If I want to keep UN*x behavior, I need to change my parsing parameter method (but no powershell names...)
v1.0.1
Still have error with .exe
--force : toot many arguments
--no-user: invalid parameter
--v1 invalid parameter
Simple test.ps1
$args.count
$args | ConvertTo-Json
ps1 tests:
PS > .\test.ps1 arg1 arg2 arg3
3
[
"arg1",
"arg2",
"arg3"
PS > .\test.ps1 arg1 arg2 arg3 --toto
4
[
"arg1",
"arg2",
"arg3",
"--toto"
]
Create binary with Invoke-ps2exe -inputFile test.ps1 -outputFile test.exe -x64
and do same tests:
PS > .\test.exe arg1 arg2 arg3 --toto
5
[
"arg1",
"arg2",
"arg3",
"-toto",
true
]
PS > .\test.exe arg1 arg2 arg3 ---toto
5
[
"arg1",
"arg2",
"arg3",
"--toto",
true
]
PS > .\test.exe arg1 arg2 arg3 -toto
5
[
"arg1",
"arg2",
"arg3",
"-toto",
true
]
PS > .\test.exe arg1 arg2 arg3 -toto --toto
7
[
"arg1",
"arg2",
"arg3",
"-toto",
true,
"-toto",
true
]
Seems that ps2exe add boolean when parameter starts with '-'.
Solution: Filter args New test.ps1
$args = $args | Where {$_ -is [String]} # Filter
$args.count
$args | ConvertTo-Json
Produce same result calling the ps1 file.
Results exe recompiled with filter
PS > .\test.exe arg1 arg2 arg3 --toto
4
[
"arg1",
"arg2",
"arg3",
"-toto"
]
PS > .\test.exe arg1 arg2 arg3 -toto
4
[
"arg1",
"arg2",
"arg3",
"-toto"
]
PS > .\test.exe arg1 arg2 arg3 ---toto
4
[
"arg1",
"arg2",
"arg3",
"--toto"
]
PS > .\test.exe arg1 arg2 arg3 -toto --toto
5
[
"arg1",
"arg2",
"arg3",
"-toto",
"-toto"
]
Resolved by release 1.0.2.
wslctl: v1.0.0 wins10
When using with powershell inerpreter, no pb:
But with the generated executable, the command line does not pass '--' but '-' :
Same from MSDos console: