GithubHelp home page GithubHelp logo

Comments (6)

nightroman avatar nightroman commented on September 22, 2024 1

Why $pwd? Well, why not? Using Get-Location may have some advantages (and disadvantages). Just like using $pwd, some advantages and disadvantages.

from invoke-build.

nightroman avatar nightroman commented on September 22, 2024

exec -echo {...} prints $pwd as cd $pwd, see

Write-Build 8 "cd $pwd"

Is it possible that your $pwd contains such a value? If yes then it all works as expected.

If such "echo" is not welcome then do not use this switch with exec.

from invoke-build.

nightroman avatar nightroman commented on September 22, 2024

Hmm, an idea. Do you by any chance use the PowerShell automatic variable $pwd (current location) as a some sort of password?

https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.3#pwd

from invoke-build.

nightroman avatar nightroman commented on September 22, 2024

If yes, I'd say it is not a good idea to mess with PS automatic variables, who knows when and how this bites.
But this is up to the author / script, indeed, no problem.

In the meantime I'll think of printing cd $global:pwd to minimize chances of such issues.

from invoke-build.

codepic avatar codepic commented on September 22, 2024

Yes, you're right. There was another function within the same module assigning $script:pwd which within a module means module-wide scope.

The $global:pwd sounds good 👍

Question: Why not Get-Location? Because it's isn't available in PowerShell 2.0?

Benefit from Get-Location would be that it's supported by Pester Mock. Not that I can think off the shelf a scenario where one would want to use it...

Describe "Get-Location" {
	Context "Mocking works..." {
		BeforeEach{
			Mock Get-location { return @{ Path = 'D:\' } }
			$script:result = Get-Location
		}
		
		It "should work" {
			$script:result.Path | Should -Be 'D:\'
		}
	}
}

from invoke-build.

nightroman avatar nightroman commented on September 22, 2024

Done, v5.10.2

from invoke-build.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.