From 6396fef55eebdafa82356e10d44fc5c16860e280 Mon Sep 17 00:00:00 2001 From: Marty Gentillon Date: Thu, 20 Apr 2017 15:12:03 -0700 Subject: [PATCH 1/2] Fixed bug where $home doesn't support .endswith In Windows 10, at least after the Creators update, $h is of type PathInfo, which does not support String operations. By toStringing it, we turn it into a String and enable the expected String operations. see https://github.com/lukesampson/scoop/issues/1440 --- lib/core.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index 58d86e573..67a89b8b7 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -87,7 +87,8 @@ function fullpath($path) { # should be ~ rooted } function relpath($path) { "$($myinvocation.psscriptroot)\$path" } # relative to calling script function friendly_path($path) { - $h = $home; if(!$h.endswith('\')) { $h += '\' } + $h = $home.ToString() + if(!$h.endswith('\')) { $h += '\' } if($h -eq '\') { return $path } return "$path" -replace ([regex]::escape($h)), "~\" } From adf0e2cdafb6d16dbbbc1905d379879a96dc5176 Mon Sep 17 00:00:00 2001 From: Luke Sampson Date: Fri, 21 Apr 2017 08:41:43 +1000 Subject: [PATCH 2/2] Adjust style, use $env:userprofile for consistency --- lib/core.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/core.ps1 b/lib/core.ps1 index 67a89b8b7..72a8898e4 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -87,8 +87,7 @@ function fullpath($path) { # should be ~ rooted } function relpath($path) { "$($myinvocation.psscriptroot)\$path" } # relative to calling script function friendly_path($path) { - $h = $home.ToString() - if(!$h.endswith('\')) { $h += '\' } + $h = "$env:userprofile"; if(!$h.endswith('\')) { $h += '\' } if($h -eq '\') { return $path } return "$path" -replace ([regex]::escape($h)), "~\" }