Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Bug in escape character / variable expansion?

Reply
 
Old 07-20-2006   #1 (permalink)
=?Utf-8?B?Um9tYW4gS3V6bWlu?=


 
 

Bug in escape character / variable expansion?

I’d like to output a variable value enclosed by ` (backwards apostrophes).
For example for variable $pshome:

PS> ...
`C:\Program Files\Windows PowerShell\v1.0`

I type (escaping backwards apostrophes with one more):
PS> "``$pshome``"

The result is pretty unexpected:
$pshome`

Is it a bug?

--
Thanks,
Roman

My System SpecsSystem Spec
Old 07-20-2006   #2 (permalink)
=?Utf-8?B?ZHJlZXNjaGtpbmQ=?=


 
 

RE: Bug in escape character / variable expansion?

This should work:

>"``" + $pshome + "``"

`C:\Programme\Windows PowerShell\v1.0`


I'm not sure why the following does not work. The first Backtick should only
escape the second one. I think somehow the $ gets escaped, too.

>"``$pshome``"

$pshome`


--
greetings
dreeschkind

"Roman Kuzmin" wrote:

> I’d like to output a variable value enclosed by ` (backwards apostrophes).
> For example for variable $pshome:
>
> PS> ...
> `C:\Program Files\Windows PowerShell\v1.0`
>
> I type (escaping backwards apostrophes with one more):
> PS> "``$pshome``"
>
> The result is pretty unexpected:
> $pshome`
>
> Is it a bug?
>
> --
> Thanks,
> Roman

My System SpecsSystem Spec
Old 07-21-2006   #3 (permalink)
Tom G.


 
 

Re: Bug in escape character / variable expansion?

You could also try:
"``{0}``" -f $pshome

"Roman Kuzmin" <RomanKuzmin@discussions.microsoft.com> wrote in message
news:7B2E30AE-75E1-4058-92B4-D48B3AE79AA9@microsoft.com...
> I'd like to output a variable value enclosed by ` (backwards apostrophes).
> For example for variable $pshome:
>
> PS> ...
> `C:\Program Files\Windows PowerShell\v1.0`
>
> I type (escaping backwards apostrophes with one more):
> PS> "``$pshome``"
>
> The result is pretty unexpected:
> $pshome`
>
> Is it a bug?
>
> --
> Thanks,
> Roman



My System SpecsSystem Spec
Old 07-21-2006   #4 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: Bug in escape character / variable expansion?

This works as well:
"``"+"$pshome``"
In any case, that does look like a bug to me.

"dreeschkind" <dreeschkind@discussions.microsoft.com> wrote in message
news:65902051-601F-4B51-BE4E-579DD92358D0@microsoft.com...
> This should work:
>
>>"``" + $pshome + "``"

> `C:\Programme\Windows PowerShell\v1.0`
>
>
> I'm not sure why the following does not work. The first Backtick should
> only
> escape the second one. I think somehow the $ gets escaped, too.
>
>>"``$pshome``"

> $pshome`
>
>
> --
> greetings
> dreeschkind
>
> "Roman Kuzmin" wrote:
>
>> I'd like to output a variable value enclosed by ` (backwards
>> apostrophes).
>> For example for variable $pshome:
>>
>> PS> ...
>> `C:\Program Files\Windows PowerShell\v1.0`
>>
>> I type (escaping backwards apostrophes with one more):
>> PS> "``$pshome``"
>>
>> The result is pretty unexpected:
>> $pshome`
>>
>> Is it a bug?
>>
>> --
>> Thanks,
>> Roman



My System SpecsSystem Spec
Old 07-24-2006   #5 (permalink)
James Truher [MSFT]


 
 

Re: Bug in escape character / variable expansion?

it's a bug

--
James W. Truher [MSFT]
Windows PowerShell Program Management
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

"Roman Kuzmin" <RomanKuzmin@discussions.microsoft.com> wrote in message
news:7B2E30AE-75E1-4058-92B4-D48B3AE79AA9@microsoft.com...
> I'd like to output a variable value enclosed by ` (backwards apostrophes).
> For example for variable $pshome:
>
> PS> ...
> `C:\Program Files\Windows PowerShell\v1.0`
>
> I type (escaping backwards apostrophes with one more):
> PS> "``$pshome``"
>
> The result is pretty unexpected:
> $pshome`
>
> Is it a bug?
>
> --
> Thanks,
> Roman



My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: exchange shell escape character PowerShell
Escape character question PowerShell
How can I escape a slash character in item name? PowerShell
How do I escape the wildcard character in a path string? PowerShell
howto? escape the comment character PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46