Re: [MSH] Problems with directory names containing square brackets
- From: "Jeff Jones [MSFT]" <jeffjon@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 11 Apr 2006 12:26:57 -0700
This is a known issue that we have been spending time thinking about. You
won't see any changes for this in the next drop but probably the one after.
The current thinking has three changes. First, the parser will not remove
backticks for invalid escape sequences but will instead throw a parsing
error. Second, the parser will not process escape sequences inside single
quotes ('`[foo`]'). Third, all the provider cmdlets with be supplied with
a -noglob parameter which tells the path resolution APIs to ignore wildcard
characters and treat them just like any other character.
--
Jeff Jones [MSFT]
Monad Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
"dreeschkind" <dreeschkind@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B7F460E7-576F-4406-A6DD-4796E147A335@xxxxxxxxxxxxxxxx
I encountered a bunch of problems working with directories that contain
square brackets and backticks in their name, due to msh using these
characters as wildcard etc.
Here is the first problem, which breakes my skripts:
***********************************************************************
# 1. create a directory with square brackets in the name
MSH C:\>md "[foo]"
Directory: Microsoft.Management.Automation.Core\FileSystem::C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 11.04.2006 15:42 [foo]
***********************************************************************
# 2. get the item and assign it to a variable
MSH C:\>gi "``[foo``]"
Directory: Microsoft.Management.Automation.Core\FileSystem::C:\
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 11.04.2006 15:42 [foo]
MSH C:\>$bar = gi "``[foo``]"
***********************************************************************
# 3. provider path and mshpath don't get 'backticked'
MSH C:\>$bar.fullname
C:\[foo]
MSH C:\>$bar.mshpath
Microsoft.Management.Automation.Core\FileSystem::C:\[foo]
***********************************************************************
# 4. thus, other cmdlets can't work with that item
MSH C:\>cd $bar
set-location : Cannot find path 'C:\[foo]' because it does not exist.
At line:1 char:3
+ cd <<<< $bar
MSH C:\>cd $bar.mshpath
set-location : Cannot find path
'Microsoft.Management.Automation.Core\FileSystem::C:\[foo]' because it
does
not exist.
At line:1 char:3
+ cd <<<< $bar.mshpath
<creating some files and subdirectories using windows explorer>
MSH C:\>gci $bar
MSH C:\>gci $bar.mshpath
***********************************************************************
# 5. you have to 'backtick' the path yourself - what about scripts?
MSH C:\>cd "``[foo``]"
MSH C:\`[foo`]>cd ..
MSH C:\>gci "``[foo``]"
Directory: Microsoft.Management.Automation.Core\FileSystem::C:\[foo]
Mode LastWriteTime Length Name
---- ------------- ------ ----
...
Is there a (built-in) solution/cmdlet/.NET-Method to 'backtick' path names
like that automatically so that msh scripts can handle all possible valid
directory names?
BTW: As I mentioned at the beginning there are some more problems with
this
wildcard/backtick 'feature' in connection with the filesystem which I will
demonstrate as soon as I have some more time for that.
.
- Follow-Ups:
- References:
- [MSH] Problems with directory names containing square brackets
- From: dreeschkind
- [MSH] Problems with directory names containing square brackets
- Prev by Date: Re: Howto determine if a .dll is registered
- Next by Date: Re: [MSH]
- Previous by thread: [MSH] Problems with directory names containing square brackets
- Next by thread: Re: Problems with directory names containing square brackets
- Index(es):
Relevant Pages
|