Home Dashboard Directory Help
Search

Get-ChildItem -Recurse in PowerShell 3.0 falls into infinite loop by Pavel G


Status: 

Closed
 as Won't Fix Help for as Won't Fix


2
0
Sign in
to vote
Type: Bug
ID: 787242
Opened: 5/20/2013 4:30:01 AM
Access Restriction: Public
0
Workaround(s)
view
1
User(s) can reproduce this bug

Description

If the folder contains another folder whose name is one or more spaces, then Get-ChildItem falls into infinite loop.
Details
Sign in to post a comment.
Posted by iluytsu6rtyxuygliu on 8/7/2013 at 11:16 AM
I understand that this is an invalid file path, but wouldn't it be better to at least throw an error. Right now the default behavior seems to be to trim the blank space from any string prior to processing it. I know it is generally best practice to trim strings when taking input, but if there is a space in this string it is either because it is actually in the path or because I intentionally put it inside the quotes. If get-childitem would just throw an invalid path error instead of trimming and working itself in a loop it would be much nicer to use.

As it stands right now, I have to script my own recursion loop any time I'm running this command against a large data set just in case some joker decided to throw a space in there somewhere. An error, I can catch - an infinite loop I can't.
Posted by Microsoft on 5/24/2013 at 2:29 PM
It doesn't seem that a file or folder name whose only characters are spaces is allowed. See http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx. "Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not." If you are able to somehow create a file or folder whose name contains only spaces, you will likely get unpredicable results in many scenarios other than Get-ChildItem -Recurse.
Sign in to post a workaround.