4 ms·
You can write cmdlets in C# and VB, not just call Powershell cmdlets/scripts. You should be able to write cmdlets in Ruby, or Node.js or Brainfuck.
by Touche 12y ago
You can write cmdlets in C# and VB, not just call Powershell cmdlets/scripts. You should be able to write cmdlets in Ruby, or Node.js or Brainfuck.
- brudgers 12y agoOK, I get what you want. My understanding is that the reason you can write a cmdlet in C# is because C# provides a facility to return .NET objects [more or less] and that's only in so far as it interops with the .NET API. Ruby implementations will tend to return a byte stream rather than a value a value against the .NET API. Even if Microsoft provided another API on top of the .NET API, the same situation would exist because Ruby implementations usually don't write to that API by default. It's turtles all the way down on the .NET side. Programming .NET in Ruby requires writing to the .NET interface from the Ruby program. If one wants to program to the .NET interface through Powershell from Ruby, a Ruby program can always output text that can be interpreted as a Powershell script. One way or another, the responsibility is on the program to write to an API. What would be the output of a Brainfuck program that should operate as a PowerShell cmdlet? Would it ever be more than text which can be interpreted as a PowerShell command or script?
- Touche 12y agoYou're entirely missing my point. Powershell shouldn't have been written to require .NET. Full-stop. That's a deal-breaker and highlights the quote I original referenced. Stop building high-level stuff on top of other high-level stuff where it's uses are restricted to only a small subset of potential developers.
- apalmer 12y agoi think you can write cmdlets in anything that compiles down to IL. So i am guessing you could write them in IronRuby or IronPython. Might be mistaken about that though. also you can use the '&' operator to call anything executable, so you could take an exe and call it from powershell without issue
- ygra 12y agoIt's still a shell. No need to use & 'externalProgram.exe' when you can just use externalProgram.exe just as well. I see a lot of weird things on Stack Overflow with & or even Invoke-Expression, especially when it involves passing parameters to programs and the lack of understanding how parameter passing works. The results usually aren't pretty, then.
- MichaelGG 12y agoPretty sure you need & to call a variable, like & $git if you've a var pointing to git instead of having in the path.