Skip to content

Commit 86d3fef

Browse files
committed
fix(core): Add 'PSObject.Copy()' to 'substitute()' (#5962)
1 parent e324fa4 commit 86d3fef

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Bug Fixes
44

5-
- **autoupdate:** Copy `PSCustomObject`-type properties within `autoupdate` to prevent reference changes ([#5934](https://github.com/ScoopInstaller/Scoop/issues/5934))
5+
- **autoupdate:** Copy `PSCustomObject`-type properties within `substitute()` to prevent reference changes ([#5934](https://github.com/ScoopInstaller/Scoop/issues/5934), [#5962](https://github.com/ScoopInstaller/Scoop/issues/5962))
66
- **system:** Fix argument passing to `Split-PathLikeEnvVar()` in deprecated `strip_path()` ([#5937](https://github.com/ScoopInstaller/Scoop/issues/5937))
77
- **core:** Fix "Invoke-ExternalCommand" quoting rules ([#5945](https://github.com/ScoopInstaller/Scoop/issues/5945))
88

lib/autoupdate.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ function Update-ManifestProperty {
365365
}
366366
} elseif ($Manifest.$currentProperty -and $Manifest.autoupdate.$currentProperty) {
367367
# Update other property (global)
368-
$autoupdateProperty = $Manifest.autoupdate.$currentProperty.PSObject.Copy()
368+
$autoupdateProperty = $Manifest.autoupdate.$currentProperty
369369
$newValue = substitute $autoupdateProperty $Substitutions
370370
if (($autoupdateProperty.GetType().Name -eq 'Object[]') -and ($autoupdateProperty.Length -eq 1)) {
371371
# Make sure it's an array

lib/core.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,8 +1225,8 @@ function Test-ScoopCoreOnHold() {
12251225
}
12261226

12271227
function substitute($entity, [Hashtable] $params, [Bool]$regexEscape = $false) {
1228-
$newentity = $entity
1229-
if ($null -ne $newentity) {
1228+
if ($null -ne $entity) {
1229+
$newentity = $entity.PSObject.Copy()
12301230
switch ($entity.GetType().Name) {
12311231
'String' {
12321232
$params.GetEnumerator() | ForEach-Object {
@@ -1238,7 +1238,7 @@ function substitute($entity, [Hashtable] $params, [Bool]$regexEscape = $false) {
12381238
}
12391239
}
12401240
'Object[]' {
1241-
$newentity = $entity | ForEach-Object { ,(substitute $_ $params $regexEscape) }
1241+
$newentity = $entity | ForEach-Object { , (substitute $_ $params $regexEscape) }
12421242
}
12431243
'PSCustomObject' {
12441244
$newentity.PSObject.Properties | ForEach-Object { $_.Value = substitute $_.Value $params $regexEscape }

0 commit comments

Comments
 (0)