Windows Vista Forums

Bugs when paths contain apostrophe
  1. #1


    Stefan Delmarco Guest

    Bugs when paths contain apostrophe

    The MyDocuments folder on my workstation is set to "C:\Stefan's Documents".
    My Powershell command prompt shortcut is configured to start in this folder
    (i.e. the "Start In" property of the shortcut). Whenever I start a
    Powershell command prompt I get the following error:

    <Snip>
    Copyright (C) 2006 Microsoft Corporation. All rights reserved.

    Incomplete string token.
    At line:1 char:27
    + set-location 'C:\Stefan's D <<<< ocuments'
    PS C:\Stefan's Documents>
    </Snip>



    This is pretty annoying. I've tracked the bug down to the following line in
    the Microsoft.Powershell.ConsoleHost.InitializeRunspace:

    string command = StringUtil.Format("set-location '{0}'",
    Environment.CurrentDirectory);

    The resultant command is "set-location 'C:\Stefan's Documents'". The
    apostrophe in the directory name has not been escaped properly. This issue
    gets worse if you create a profile in this directory (i.e. $profile =
    C:\Stefan's Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1).

    <Snip>
    Windows PowerShell
    Copyright (C) 2006 Microsoft Corporation. All rights reserved.

    Incomplete string token.
    At line:1 char:27
    + set-location 'C:\Stefan's D <<<< ocuments'
    Incomplete string token.
    At line:1 char:17
    + . 'C:\Stefan`'s D <<<<
    ocuments\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'
    PS C:\Stefan's Documents>
    </Snip>

    In this case the code that runs profile includes a call to the
    EscapeTickCharacters function (see
    Microsoft.Powershell.ConsoleHost.RunProfile). This function prefixes an
    apostrophe (') with a backwards apostrophe (`). According to "get-help
    about_escape_character' (`') should escape the apostrophe. This second error
    message must therefore be a bug in the parser / tokenizer (probably
    StringTokenReader).

    I've logged this as a bug in Connect,
    https://connect.microsoft.com/feedba...8008&SiteID=99

    --
    Cheers,
    Stefan Delmarco | SQL Server MVP | http://www.fotia.co.uk/


      My System SpecsSystem Spec

  2. #2


    Neil Pike Guest

    Re: Bugs when paths contain apostrophe

    Stefan,

    I've just hit the same thing, so will vote/verify your connect report.

    Neil Pike. Protech Computing Ltd




      My System SpecsSystem Spec

Bugs when paths contain apostrophe

Similar Threads
Thread Thread Starter Forum Replies Last Post
Apostrophe A.N. Live Mail 1 08 Feb 2010
Looking for function to resolve VirtualStore paths to physical paths Scott Vista file management 9 08 Jul 2007
Looking for function to resolve VirtualStore paths to physical paths Scott Vista General 9 08 Jul 2007
egrave for apostrophe Shoshinsha Vista mail 0 25 Jun 2007
Vista pro - bugs... bugs... bugs... Kamil Dursun Vista performance & maintenance 3 22 May 2007