View Single Post
Old 01-21-2007   #2 (permalink)
RichS


 
 

RE: Inconsistent behaviour when using set-location with different prov

Andrew
I've tried them and got the same results. I think it should be consistent.
As more providers are added to PowerShell inconsistencies like this will
become more of an irritant and will put people off.
--
Richard Siddaway

Please note that all scripts are supplied "as is" and with no warranty


"Andrew Watt [MVP]" wrote:

> Try the following commands. I would be interesed if you can confirm
> the same inconsistencies in behaviour that I show below.
>
> There are three issues that I see:
>
> 1. Why does providing the provider name (or not) in the command affect
> what is displayed in the prompt?
>
> 2. Why is the behaviour of the FileSystem provider and Registry
> provider different? Is the inconsistency a bug?
>
> 3. Why does set-location C: and set-location FileSystem::C: take you
> to different folders? Bug?
>
> PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
> PS HKLM:\> set-location C:
>
> So far so good. But when you provide the name of the provider it
> appears in the prompt.
>
> PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
>
> If you omit the colon with the FileSystem provider you can an error.
>
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C
> Set-Location : Cannot find path 'C' because it does not exist.
> At line:1 char:13
> + set-location <<<< FileSystem::C
>
> But it works with the colon in place.
>
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C:
>
> Providing the colon with the Registry provider produces an error (the
> FileSystem equivalent worked).
>
> PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
> Registry::HKLM:
> Set-Location : Cannot find path 'HKLM:' because it does not exist.
> At line:1 char:13
> + set-location <<<< Registry::HKLM:
>
> For convenience here are the commands with no interpolated comment:
>
> PS C:\Documents and Settings\Andrew Watt> set-location HKLM:
> PS HKLM:\> set-location C:
> PS C:\Documents and Settings\Andrew Watt> set-location Registry::HKLM
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C
> Set-Location : Cannot find path 'C' because it does not exist.
> At line:1 char:13
> + set-location <<<< FileSystem::C
> PS Microsoft.PowerShell.Core\Registry::HKLM> set-location
> FileSystem::C:
> PS Microsoft.PowerShell.Core\FileSystem::C:\> set-location
> Registry::HKLM:
> Set-Location : Cannot find path 'HKLM:' because it does not exist.
> At line:1 char:13
> + set-location <<<< Registry::HKLM:
> PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
> functionrompt).definition
> 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
> '> '
> PS Microsoft.PowerShell.Core\FileSystem::C:\>
>
> For information here also is my prompt() function. It's the default.
>
> PS Microsoft.PowerShell.Core\FileSystem::C:\> (get-childitem
> functionrompt).definition
> 'PS ' + $(Get-Location) + $(if ($nestedpromptlevel -ge 1) { '>>' }) +
> '> '
> PS Microsoft.PowerShell.Core\FileSystem::C:\>
>
> Can others confirm the behaviour? Do you see the differences as
> desirable?
>
> Andrew Watt MVP
>

My System SpecsSystem Spec