Search

foreach doesn't work with 'Set-PSDebug -trace 1' in PS3 by sba

Active

13
0
Sign in
to vote
Type: Bug
ID: 779439
Opened: 2/18/2013 7:11:48 AM
Access Restriction: Public
0
Workaround(s)
6
User(s) can reproduce this bug
If 'Set-PSDebug -trace 1' is in action, 'foreach' doesn't work (does nothing) in PS3.

IMVHO that's definitely a bug.

Can we expect a fix or at least a workaround?
Details (expand)
How often does this happen?
Always Happens

Have you seen this problem before in this product?

No, this is new to the most recent version
Reproduction Steps
- Take the following script:

foreach ($basename in ('a','b','c'))
{
    write-host $basename
}

- Run a PS3 host
- issue "Set-PSDebug -trace 1"
- run the script

You'll get:

PS 3.0 E:\private_sba>E:\tmp\foreach.ps1
DEBUG:    1+ >>>> E:\tmp\foreach.ps1
DEBUG:    1+ foreach ($basename in >>>> ('a','b','cl'))
DEBUG:     ! SET $foreach = 'a b cl'.
DEBUG:    1+ foreach ( >>>> $basename in ('a','b','c'))
DEBUG:     ! SET $foreach = ''.
Expected Results
If you run the script under the same conditions in a PS2 host (powershell -version 2.0) you'll get:

PS 2.0 E:\private_sba>Set-PSDebug -trace 1
DEBUG:    2+         $foundSuggestion = <<<< $false
DEBUG:    4+         if <<<< ($lastError -and
DEBUG: 15+         $foundSuggestion <<<<
PS 2.0 E:\private_sba>E:\tmp\foreach.ps1
DEBUG:    1+ <<<< E:\tmp\foreach.ps1
DEBUG:    1+ foreach <<<< ($basename in ('a','b','c'))
DEBUG:    3+     <<<< write-host $basename
a
DEBUG:    3+     <<<< write-host $basename
b
DEBUG:    3+     <<<< write-host $basename
c
DEBUG:    2+         $foundSuggestion = <<<< $false
DEBUG:    4+         if <<<< ($lastError -and
DEBUG: 15+         $foundSuggestion <<<<
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.