mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-12-04 15:15:34 +00:00
fix(env): Avoid automatic expansion of %% in env (#5395)
Co-authored-by: Rashil Gandhi <46838874+rashil2000@users.noreply.github.com>
This commit is contained in:
@@ -11,7 +11,8 @@
|
|||||||
- **autoupdate:** Fix file hash extraction ([#5295](https://github.com/ScoopInstaller/Scoop/issues/5295))
|
- **autoupdate:** Fix file hash extraction ([#5295](https://github.com/ScoopInstaller/Scoop/issues/5295))
|
||||||
- **shortcuts:** Output correctly formatted path ([#5333](https://github.com/ScoopInstaller/Scoop/issues/5333))
|
- **shortcuts:** Output correctly formatted path ([#5333](https://github.com/ScoopInstaller/Scoop/issues/5333))
|
||||||
- **core:** Fix `is_in_dir` under Unix ([#5391](https://github.com/ScoopInstaller/Scoop/issues/5391))
|
- **core:** Fix `is_in_dir` under Unix ([#5391](https://github.com/ScoopInstaller/Scoop/issues/5391))
|
||||||
- **install:** Fix download from private GitHub repositories ([#5357](https://github.com/ScoopInstaller/Scoop/issues/5357))
|
- **env:** Avoid automatic expansion of `%%` in env ([#5395](https://github.com/ScoopInstaller/Scoop/issues/5395))
|
||||||
|
- **install:** Fix download from private GitHub repositories ([#5361](https://github.com/ScoopInstaller/Scoop/issues/5361))
|
||||||
|
|
||||||
### Code Refactoring
|
### Code Refactoring
|
||||||
|
|
||||||
|
|||||||
27
lib/core.ps1
27
lib/core.ps1
@@ -662,10 +662,29 @@ function Invoke-ExternalCommand {
|
|||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
function env($name,$global,$val='__get') {
|
function env($name, $global, $val = '__get') {
|
||||||
$target = 'User'; if($global) {$target = 'Machine'}
|
$RegisterKey = if ($global) {
|
||||||
if($val -eq '__get') { [environment]::getEnvironmentVariable($name,$target) }
|
Get-Item -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager'
|
||||||
else { [environment]::setEnvironmentVariable($name,$val,$target) }
|
} else {
|
||||||
|
Get-Item -Path 'HKCU:'
|
||||||
|
}
|
||||||
|
$EnvRegisterKey = $RegisterKey.OpenSubKey('Environment', $val -ne '__get')
|
||||||
|
|
||||||
|
if ($val -eq '__get') {
|
||||||
|
$RegistryValueOption = [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames
|
||||||
|
$EnvRegisterKey.GetValue($name, $null, $RegistryValueOption)
|
||||||
|
} elseif ($val -eq $null) {
|
||||||
|
$EnvRegisterKey.DeleteValue($name)
|
||||||
|
} else {
|
||||||
|
$RegistryValueKind = if ($val.Contains('%')) {
|
||||||
|
[Microsoft.Win32.RegistryValueKind]::ExpandString
|
||||||
|
} elseif ($EnvRegisterKey.GetValue($name)) {
|
||||||
|
$EnvRegisterKey.GetValueKind($name)
|
||||||
|
} else {
|
||||||
|
[Microsoft.Win32.RegistryValueKind]::String
|
||||||
|
}
|
||||||
|
$EnvRegisterKey.SetValue($name, $val, $RegistryValueKind)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFileLocked([string]$path) {
|
function isFileLocked([string]$path) {
|
||||||
|
|||||||
Reference in New Issue
Block a user