Skip to content

Conversation

@m5x
Copy link

@m5x m5x commented Apr 25, 2020

PR Summary

Allow System.Management.Automation.Runspaces.Command operating in IsScript = true mode to remember and pass on path to the script file and make use of this feature when executing script file passed as -File command line argument.

PR Context

Fixes #4217

@m5x m5x requested review from anmenaga and daxian-dbw as code owners April 25, 2020 23:16
@ghost ghost assigned iSazonov Apr 25, 2020
@msftclas
Copy link

msftclas commented Apr 25, 2020

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@vexx32 vexx32 left a comment

Choose a reason for hiding this comment

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

Code seems sound, nice work!

Can we add a test to verify this works and guard against regressions?

Copy link
Collaborator

@iSazonov iSazonov left a comment

Choose a reason for hiding this comment

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

Please add tests.

@iSazonov iSazonov added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Apr 26, 2020
@iSazonov iSazonov added this to the 7.1.0-preview.3 milestone Apr 26, 2020
m5x added 2 commits April 27, 2020 02:59
…tion.InvocationName contain proper values when running script by means of -File argument
@m5x
Copy link
Author

m5x commented Apr 27, 2020

Tests have been added. I also added one small change to use ExternalScriptInfo for scripts with known path (i.e. scripts started with -File argument) and thus provide proper values in $MyInvocation special variable even for scripts without .ps1 extension.

@m5x
Copy link
Author

m5x commented Apr 27, 2020

Sorry for the spacing around parentheses. I like to put spaces inside for better readability and I've been doing it so long that I type it automatically this way and sometimes forget to check and fix it when committing to other projects. I will fix it in next commit - should I add [Feature] prefix to the commit message again to comply with testing guidelines in case it is the last one of this PR?

@m5x
Copy link
Author

m5x commented Apr 27, 2020

Added the requested formatting and property docs changes. CodeFactor reports no more issues.

@ghost ghost added the Review - Needed The PR is being reviewed label May 27, 2020
@ghost
Copy link

ghost commented May 27, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Mainainer, Please provide feedback and/or mark it as Waiting on Author

@iSazonov
Copy link
Collaborator

@m5x Please rebase to pass CIs.

@ghost ghost removed the Review - Needed The PR is being reviewed label Jul 23, 2020
@ghost ghost added the Review - Needed The PR is being reviewed label Jul 30, 2020
@ghost
Copy link

ghost commented Jul 30, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@m5x
Copy link
Author

m5x commented Jul 30, 2020

Is rebasing all that's blocking merge of this pull request? I have currently some other things I have to finish first but if I am the only one blocking this I'll try to find a time to rebase this weekend.

@iSazonov
Copy link
Collaborator

iSazonov commented Aug 1, 2020

It is a question for MSFT team - @daxian-dbw @anmenaga have you time to review the PR?

@ghost ghost removed the Review - Needed The PR is being reviewed label Aug 1, 2020
@daxian-dbw
Copy link
Member

Add @SteveL-MSFT and @rjmholt to review.
@SteveL-MSFT You marked the issue "by design" in #4217 (comment), can you please review this PR and the subsequent comments in that issue to see if we want to accept this PR? Also would the change of design cause any breaking change?

@ghost ghost added the Review - Needed The PR is being reviewed label Aug 11, 2020
@ghost
Copy link

ghost commented Aug 11, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@SteveL-MSFT SteveL-MSFT added this to the 7.2-Consider milestone Dec 9, 2020
@ghost ghost removed this from the 7.2-Consider milestone Dec 9, 2020
@ghost
Copy link

ghost commented Dec 9, 2020

Open PRs should not be assigned to milestone, so they are not assigned to the wrong milestone after they are merged. For backport consideration, use a backport label.

@rjmholt
Copy link
Collaborator

rjmholt commented Dec 10, 2020

Blocked on #12494 (comment); @SteveL-MSFT or the @PowerShell/powershell-committee need to advise on whether we want to make this change

@ghost ghost removed the Review - Needed The PR is being reviewed label Dec 10, 2020
commandProcessorBase = new CommandProcessor(functionInfo, executionContext,
_useLocalScope ?? false, fromScriptFile: false, sessionState: executionContext.EngineSessionState);
}
else if (ScriptPath != null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
else if (ScriptPath != null)
else if (ScriptPath is not null)

@ghost ghost added the Review - Needed The PR is being reviewed label Dec 18, 2020
@ghost
Copy link

ghost commented Dec 18, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@ghost ghost removed the Review - Needed The PR is being reviewed label Sep 15, 2021
@ghost ghost added the Review - Needed The PR is being reviewed label Sep 23, 2021
@ghost
Copy link

ghost commented Sep 23, 2021

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

Copy link
Contributor

@jazzdelightsme jazzdelightsme left a comment

Choose a reason for hiding this comment

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

:shipit:

param($Filename)
$testFilePath = Join-Path $testdrive $Filename
Set-Content -Path $testFilePath -Value '$MyInvocation.MyCommand.Name'
$observed = & $powershell -File $testFilePath -NoProfile -NoLogo
Copy link
Member

Choose a reason for hiding this comment

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

There was an intentional breaking change in PowerShell 7.2 related to powershell -File: when running on Windows, a file without .ps1 extension is not allowed to run using pwsh -File. So, the test won't work on Windows.

}
else if (ScriptPath != null)
{
var scriptName = Path.GetFileName(ScriptPath);
Copy link
Member

Choose a reason for hiding this comment

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

The script (content of the file) could be using cmdlet binding (scriptBlock.UsesCmdletBinding being true), by having a param block defined. In that case, the code execution would fall into the if (scriptBlock.UsesCmdletBinding) block, right?

@ghost ghost added Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept and removed Review - Needed The PR is being reviewed labels Jan 18, 2022
@ghost ghost added the Stale label Feb 3, 2022
@ghost
Copy link

ghost commented Feb 3, 2022

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 10 days of this comment.

@ghost ghost closed this Feb 13, 2022
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log Stale Waiting on Author The PR was reviewed and requires changes or comments from the author before being accept

Projects

None yet

10 participants