Dan Kendalls' Fluff

Why I hate Powershell

At an old job I was inadvertently placed into waxing lyrical about Powershell but that is because CLIs are awesome and we were using Microsoft Windows of which Powershell Core is the best and tightly coupled choice.

However that doesn't excuse its slow command execution, massive 339.84 MB binary or its needlessly recursive functions.

For example say I have mpv installed and I want it to run through CLI only using GPU and running all videos at 4x.

In sh I could simply do: alias mpv='mpv --hwdec --speed=4

However in powershell aliases can only be linked to functions BUT:

function mpv {
mpv --hwdec --speed=4
}

Would evaluate to:

mpv mpv --hwdec --speed=4 mpv --hwdec --speed=4 mpv --hwdec --speed=4 mpv --hwdec --speed=4 mpv --hwdec --speed=4 for ∞

As each instance of the text mpv is replaced with the same string infinitely.

Fans spin up but luckily a recursion limit of 2000 stops my computer from crapping out.

The far less clean solution:

function mpv {
cd "C:\Users\dkendall\scoop\apps\mpv\current\"
.\mpv.exe --hwdec --speed=4 $args
}

Go to the location of the actual executable then pass in arguments.

Maybe add a Set-Location $env:USERPROFILE to go back to home folder.

Compare that to the simplicity of: alias mpv='mpv --hwdec --speed=4