Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
PowerShell Scripts require .ps1 extension #1103
Scripts (on linux) don't function unless they have the extension
Steps to reproduce
#!/usr/bin/powershell echo hi
chmod a+x ./myscript # hangs! ./myscript mv ./myscript ./myscript.ps1 # works ./myscript.ps1 hi
On linux, this should work even if the extension isn't
This is really important. Without this we also can't use scripts as executables, as adding a shebang to the start of a file without a
I don't think that's necessarily a bad thing - sure, functions and modules should make considerations for cross platform compatibility, but some of these, and some scripts that leverage them, will inherently target specific platforms.
IMHO, you might find the folks writing PowerShell scripts on *nix, or at least a decent proportion of them, recognize the importance of cross-platform support, where it makes sense.
That said, assuming I'm wrong, wouldn't it be better to have a few folks end up writing non-cross-platform scripts (assumption), rather than walking away from the language given this limitation (assumption, perhaps just as likely)?
@RamblingCookieMonster I'm personally where you landed on this which is to lower the barrier to entry on Linux to get adoption and where cross platform is needed, scriptanalyzer can help with that and those users will learn very quickly it won't work on Windows.
@PowerShell/powershell-committee discussed this. There may be impact to get-command as now it would have to read the shebang to determine if it's a PowerShell script so we can run it within current runspace. It may be worth experimenting to compare perf impact.
We should fix the hang so that scripts without extensions works as "executables" (new instance of powershell will execute it) as long as shebang is there.