Skip to content
This repository has been archived by the owner on Feb 4, 2019. It is now read-only.

ParseException regarding parameter type declaration. #394

Open
phrohdoh opened this issue Oct 4, 2015 · 0 comments
Open

ParseException regarding parameter type declaration. #394

phrohdoh opened this issue Oct 4, 2015 · 0 comments

Comments

@phrohdoh
Copy link

phrohdoh commented Oct 4, 2015

OS X 10.10.4
Mono 4.0.4 (d481017)
Pash d6c0bdb

Having a $profile of:

$global:shortenPathLength = 3

function prompt {
    $chost = [ConsoleColor]::Green
    $cdelim = [ConsoleColor]::DarkCyan
    $cloc = [ConsoleColor]::Cyan

    Write-Host ' '

    Write-Host ($env:MachineName) -NoNewline -Foregroundcolor $chost
    Write-Host ' {' -NoNewline -Foregroundcolor $cdelim
    Write-Host (Shorten-Path (pwd).Path) -NoNewline -Foregroundcolor $cloc
    Write-Host '} ' -NoNewline -Foregroundcolor $cdelim

    Write-Host "»" -NoNewline -Foregroundcolor $cloc
    ' '

    $Host.UI.RawUI.ForegroundColor = [ConsoleColor]::White
}

function Shorten-Path([String]$path = $pwd) {
   $loc = $path.Replace($HOME, '~')
   # remove prefix for UNC paths
   $loc = $loc -replace '^[^:]+::', ''
   # Make path shorter like tabs in Vim, handle paths starting with \\
   #  and . correctly
   return ($loc -replace "\\(\.?)([^\\]{$shortenPathLength})[^\\]*(?=\\)",'\$1$2')
}

Results in:

Parse error at (20:22): Syntax error, expected: variable, )
> function Shorten-Path([String]$path = $pwd) {
                        ^
  +CategoryInfo: ParserError, Reason: ParseException
  +FullyQualifiedErrorId: Parse

Though this works fine under PS and I see no obvious errors.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant