Repository navigation
Don't require extensions for script.ps1 etc. on Linux - #1048
Conversation
| // Porting note: on non-Windows platforms, we want to always allow just 'commandName' | ||
| // as an acceptable command name. However, we also want to allow commands to be | ||
| // called with their extensions, so that 'script.ps1' can be called by 'script'. | ||
| commandPatterns = new [] { commandName, commandNamePattern }; |
There was a problem hiding this comment.
Shouldn't this be:
... = new [] { commandName + ".ps1", commandName };
In other words, we don't need wildcards, we just look for foo.ps1 before foo.
There was a problem hiding this comment.
I think you're right. We probably want to be explicit about this working for only .ps1 scripts, not anything with an extension.
James Truher (@JamesWTruher) thoughts?
There was a problem hiding this comment.
my only concern is that I don't know how to execute
ls if ls.ps1 exists (on windows this isn't likely, but *nix more so
my question is only about precedence - should it be
new[] { commandName, commandName + ".ps1" } or
new[] { commandName + ".ps1", commandName }
There was a problem hiding this comment.
Jim has a good point – I thought of this when I first commented, but missed it just now.
From: James Truher [MSFT] [mailto:notifications@github.com]
Sent: Friday, June 3, 2016 2:41 PM
To: PowerShell/PowerShell PowerShell@noreply.github.com
Cc: Jason Shirk (POWERSHELL) jasonsh@microsoft.com; Mention mention@noreply.github.com
Subject: Re: [PowerShell/PowerShell] Don't require extensions for script.ps1 etc. on Linux (#1048)
In src/System.Management.Automation/engine/CommandPathSearch.cshttps://github.com//pull/1048#discussion_r65779950:
if (Platform.IsWindows) {
commandName = commandName + ".*";commandPatterns = new [] { commandNamePattern };}else{// Porting note: on non-Windows platforms, we want to always allow just 'commandName'// as an acceptable command name. However, we also want to allow commands to be// called with their extensions, so that 'script.ps1' can be called by 'script'.commandPatterns = new [] { commandName, commandNamePattern };
my only concern is that I don't know how to execute
ls if ls.ps1 exists (on windows this isn't likely, but *nix more so
my question is only about precedence - should it be
new[] { commandName, commandName + ".ps1" } or
new[] { commandName + ".ps1", commandName }
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//pull/1048/files/f747fc9650cdf33d60cda814bb01800698715380#r65779950, or mute the threadhttps://github.com/notifications/unsubscribe/ACDHmNfWerq3_ZEqPONaWYDTocNxP4jGks5qIJ9XgaJpZM4IoxI2.
For instance, `script.ps1` can be called with just `script`.
f747fc9 to
c6960f0
Compare
|
Jason Shirk (@lzybkr) James Truher (@JamesWTruher) Updated, good to go? |
|
|
…nsions Don't require extensions for script.ps1 etc. on Linux
Resolves #1044.
I thought about it, and to answer your question, no, we should probably just Do What I Mean here.
This change is