Skip to content

Should non-windows system users be required to include the extension when executing scripts? #1044

Closed

Description

Assume that I have written a script which is a paragon of portability. It runs on all the platforms without modification, and is in my PATH. On Windows, I type:
PS> Hello
and it executes!

should I be able to do the same on non-windows platforms? Note that I have not typed the actual name of the file on Windows (which is hello.ps1), just hello.

#!powershell does not address this issue, because it doesn't change the name of the script. Are we going to suggest that our users create 2 copies of the same file:
hello and hello.ps1
one for Windows, another for not?
are we going to require our users to type hello.ps1 on non-Windows platforms?

I suggest that we support our current behavior on non-Windows platforms, we supply the .ps1, and use the same disambiguation logic that we do for .cmd, .exe, etc, which an additional which is no extension. This way if files (on non-windows)

hello
hello.ps1

we would execute hello. similar to what we would do if we found hello.exe on windows
If we find only hello.ps1, and the user types hello, we run it and not require the user to type the actual filename

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Usability

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions