Skip to content

Don't require extensions for script.ps1 etc. on Linux - #1048

Merged
Andy Jordan (andyleejordan) merged 2 commits into
masterfrom
andschwa/skip-extensions
Jun 3, 2016
Merged

Andy Jordan (andyleejordan) merged 2 commits into
masterfrom
andschwa/skip-extensions

Conversation

@andyleejordan

@andyleejordan Andy Jordan (andyleejordan) commented May 27, 2016 •

Copy link
Copy Markdown
Member

Resolves #1044.

I thought about it, and to answer your question, no, we should probably just Do What I Mean here.


This change is Reviewable

@andyleejordan Andy Jordan (andyleejordan) added the Usability (LEGACY) Helps filter issues that might be higher priority because they directly affect usability label May 27, 2016
@andyleejordan Andy Jordan (andyleejordan) changed the title Andschwa/skip extensions Don't require extensions for script.ps1 etc. on Linux May 27, 2016
// 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 };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:
... = new [] { commandName + ".ps1", commandName };
In other words, we don't need wildcards, we just look for foo.ps1 before foo.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@andyleejordan

Copy link
Copy Markdown
Member Author

Jason Shirk (@lzybkr) James Truher (@JamesWTruher) Updated, good to go?

@lzybkr

Copy link
Copy Markdown
Contributor

:shipit:

@andyleejordan
Andy Jordan (andyleejordan) merged commit d833371 into master Jun 3, 2016
@andyleejordan
Andy Jordan (andyleejordan) deleted the andschwa/skip-extensions branch June 3, 2016 21:44
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj-contribs/PowerShell that referenced this pull request Aug 6, 2026
…nsions

Don't require extensions for script.ps1 etc. on Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Usability (LEGACY) Helps filter issues that might be higher priority because they directly affect usability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants