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

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 787242 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 5/20/2013 4:30:01 AM
Access Restriction Public


If the folder contains another folder whose name is one or more spaces, then Get-ChildItem falls into infinite loop.
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 Dan [MSFT] 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 "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.