Set-PSBreakpoint -Command Write-Error -Action { break; }
cmd.exe /c "exit 1"
echo "if this->($LASTEXITCODE) is 1 I shouldn't be here"
Your stack trace code is wrong. What your code is doing is essentially saying throw an exception when you encounter an error. All I am asking is when exception hits the top, dump the stack trace. $script:ErrorActionPreference = 'Stop'
function bar() {
throw "oops"
}
function foo() {
$a = 123
bar
}
foo
PS C:\tmp> .\a.ps1
Exception: C:\tmp\a.ps1:6:5
Line |
6 | throw "oops"
| ~~~~~~~~~~~~
| oops
I use `trap{$_.ScriptStackTrace; break}` but unfortunately I cannot hide this code into a helper script that I can dot source... because of scoping rules! Even though I am dot sourcing a file which I would think would load it into my current scope according to dot sourcing link you sent. yes you can wrap stuff in arrays, but that is making the callsite look ugly for a function definition problem. The solution "return ,$array" is just weird
Honestly I prefer the bash way of $yaml | yaml2json(.exe) | convert-fromjson. Easier to find cross platform converters which your example is not. Takes me like 5 seconds to write, however then I have to teach others to do it as well, I want it in the platform. Also why they are at it, add toml support as well. # .SYNOPSIS
# Why do I need to type .SYNOPSIS above here, and yes that extra line is too many
function foo(
# but here its just obviously a comment for a parameter
[string] $param=""
) {
$param
}
Also didn't mention this before I wish there was a version of powershell that was static checked like typescript for javascript.
If someone is going to just close these questions, then I will drop them as it’s not open source I want to be a part of.
I am okay with paying for software. not okay with paying to find out my feature request will get denied