Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If psdrive was created in a previous raw, it won't be found. #27

Open
abuyanov opened this issue Feb 21, 2013 · 8 comments
Open

If psdrive was created in a previous raw, it won't be found. #27

abuyanov opened this issue Feb 21, 2013 · 8 comments

Comments

@abuyanov
Copy link

I created such test page:
!|script|
|eval|mkdir c:\test|
|eval|1..5 > c:\test\file1.txt|

!|script|
|eval|New-PSDrive -PSProvider FileSystem -name test -root c:\test;$res1 = gc test:file1.txt -last 1|
|check|eval|$res1|5|

!|script|
|eval|New-PSDrive -PSProvider FileSystem -name test -root c:\test|
|eval|$res2=gc test:file1.txt -last 1|
|check|eval|$res2|5|

the first check is successful, but second one is not. Output Captured returns an error:
gc : Cannot find drive. A drive with the name 'test' does not exist.

@EKibort
Copy link

EKibort commented Feb 21, 2013

Do you think it is an issue of PowerSlim? I don't think so.... It is bug tracker but not discussion board.
Konstantin, could you create Google group for such discussions?

@mikeplavsky
Copy link
Collaborator

IMHO we can discuss it here. It is a triage. Nothing bad with it.

@abuyanov
Copy link
Author

IMHO it is PowerSlim issue.
I would be very grateful if you could explain why the psdrive that I have created is not available at next raw. I hope it will help me to better understand PowerSlim.

@mikeplavsky
Copy link
Collaborator

Alexander, I agree with you, seems like a PowerSlim issue! Looking into it right now!

@mikeplavsky
Copy link
Collaborator

I have changed the last table:

!|script|
|check|eval|$d = New-PSDrive -PSProvider FileSystem -name test1 -root c:\test;$res2=gc test1:file1.txt -last 1||
|check|eval|$res2|5|
|check|eval|$res2=gc test1:file1.txt -last 1||
|check|eval|$res2|5|

The second raw is green.
My guess is by some reason "test1" drive is not visible in the global namespace.

@mikeplavsky
Copy link
Collaborator

I see such code in PowerSlim and imho that's the reason why.

if($s.StartsWith('function',$true,$null)){Set-Variable -Name Script__ -Value ($s -replace 'function\s+(.+)(?=\()','function global:$1') -Scope Global}
else{Set-Variable -Name Script__ -Value ($s -replace '\$(\w+)(?=\s*=)','$global:$1') -Scope Global}

It looks like w/o such code variables are local to the script.

@mikeplavsky
Copy link
Collaborator

Alexander, here is the temporary fix for you:

!|script|
|check|eval|New-PSDrive -PSProvider FileSystem -name test1 -root c:\test -Scope Global||
|check|eval|$res2=gc test1:file1.txt -last 1||
|check|eval|$res2|5|

See this parameter -Scope Global
Is it ok for now?

@abuyanov
Copy link
Author

Mike, thanks a lot for explanation.

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

No branches or pull requests

3 participants