Shell scripts are better when having a shebang like so:
#!/bin/bash
echo "The shebang above this line works like a typical a comment but with a purpose"
PowerShell scripts are also shell scripts. So it should be okay to do like so:
#!/usr/local/bin/pwsh
echo "The shebang above this line works like a typical a comment but with a purpose"
It seems to does not make sense if the script was intended for Windows machines but for Linux and Mac machines they seem to make sense.
Do you think it would be best for PowerShell scripts to also have a shebang?
pwsh
prior to version 6.0 did not support the concept of shebang. – fpmurphy Mar 25 '21 at 16:38pwsh
is 6.0. It's also the first version to run on non-Windows platforms. Older version arepowershell
and runs on Windows only which has no idea of shebang – phuclv May 22 '22 at 15:45