Skip to content

Commit 68760de

Browse files
authored
fix(shortcuts): Output correctly formatted path (#5333)
1 parent 257304b commit 68760de

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
- **decompress:** Exclude '*.nsis' that may cause error ([#5294](https://github.com/ScoopInstaller/Scoop/issues/5294))
1010
- **autoupdate:** Fix file hash extraction ([#5295](https://github.com/ScoopInstaller/Scoop/issues/5295))
11+
- **shortcuts:** Output correctly formatted path ([#5333](https://github.com/ScoopInstaller/Scoop/issues/5333))
1112

1213
### Code Refactoring
1314

lib/shortcuts.ps1

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ function create_startmenu_shortcuts($manifest, $dir, $global, $arch) {
55
$target = [System.IO.Path]::Combine($dir, $_.item(0))
66
$target = New-Object System.IO.FileInfo($target)
77
$name = $_.item(1)
8-
$arguments = ""
8+
$arguments = ''
99
$icon = $null
10-
if($_.length -ge 3) {
10+
if ($_.length -ge 3) {
1111
$arguments = $_.item(2)
1212
}
13-
if($_.length -ge 4) {
13+
if ($_.length -ge 4) {
1414
$icon = [System.IO.Path]::Combine($dir, $_.item(3))
1515
$icon = New-Object System.IO.FileInfo($icon)
1616
}
17-
$arguments = (substitute $arguments @{ '$dir' = $dir; '$original_dir' = $original_dir; '$persist_dir' = $persist_dir})
17+
$arguments = (substitute $arguments @{ '$dir' = $dir; '$original_dir' = $original_dir; '$persist_dir' = $persist_dir })
1818
startmenu_shortcut $target $name $arguments $icon $global
1919
}
2020
}
@@ -29,11 +29,11 @@ function shortcut_folder($global) {
2929
}
3030

3131
function startmenu_shortcut([System.IO.FileInfo] $target, $shortcutName, $arguments, [System.IO.FileInfo]$icon, $global) {
32-
if(!$target.Exists) {
32+
if (!$target.Exists) {
3333
Write-Host -f DarkRed "Creating shortcut for $shortcutName ($(fname $target)) failed: Couldn't find $target"
3434
return
3535
}
36-
if($icon -and !$icon.Exists) {
36+
if ($icon -and !$icon.Exists) {
3737
Write-Host -f DarkRed "Creating shortcut for $shortcutName ($(fname $target)) failed: Couldn't find icon $icon"
3838
return
3939
}
@@ -51,22 +51,22 @@ function startmenu_shortcut([System.IO.FileInfo] $target, $shortcutName, $argume
5151
if ($arguments) {
5252
$wsShell.Arguments = $arguments
5353
}
54-
if($icon -and $icon.Exists) {
54+
if ($icon -and $icon.Exists) {
5555
$wsShell.IconLocation = $icon.FullName
5656
}
5757
$wsShell.Save()
58-
write-host "Creating shortcut for $shortcutName ($(fname $target))"
58+
Write-Host "Creating shortcut for $shortcutName ($(fname $target))"
5959
}
6060

6161
# Removes the Startmenu shortcut if it exists
6262
function rm_startmenu_shortcuts($manifest, $global, $arch) {
6363
$shortcuts = @(arch_specific 'shortcuts' $manifest $arch)
6464
$shortcuts | Where-Object { $_ -ne $null } | ForEach-Object {
6565
$name = $_.item(1)
66-
$shortcut = "$(shortcut_folder $global)\$name.lnk"
67-
write-host "Removing shortcut $(friendly_path $shortcut)"
68-
if(Test-Path -Path $shortcut) {
69-
Remove-Item $shortcut
66+
$shortcut = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$(shortcut_folder $global)\$name.lnk")
67+
Write-Host "Removing shortcut $(friendly_path $shortcut)"
68+
if (Test-Path -Path $shortcut) {
69+
Remove-Item $shortcut
7070
}
7171
}
7272
}

0 commit comments

Comments
 (0)