Skip to content

Commit

Permalink
refactor(shim): Use -file instead of -command in ps1 script shims (
Browse files Browse the repository at this point in the history
…ScoopInstaller#4721)

* refactor(shim): Use `-file` instead of `-command` in ps1 script shims

* update changelog

* Update CHANGELOG.md

Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
  • Loading branch information
2 people authored and se35710 committed Mar 8, 2022
1 parent ced841e commit 81e2095
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- **diagnostic** Skip check for 'exclusionPath' if defender realtime protect is disabled ([#4699](https://github.com/ScoopInstaller/Scoop/pull/4699))
- **scoop-checkup** Skip 'check_windows_defender' when have not admin privileges ([#4699](https://github.com/ScoopInstaller/Scoop/pull/4699))
- **scoop-checkup** Separate defender issues, mark as performance problem instead potential problem ([#4699](https://github.com/ScoopInstaller/Scoop/pull/4699))
- **shim:** Use `-file` instead of `-command` in ps1 script shims ([#4721](https://github.com/ScoopInstaller/Scoop/pull/4721))

### Builds

Expand Down
8 changes: 4 additions & 4 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,9 @@ function shim($path, $global, $name, $arg) {
"if !args! == !invalid! ( set args= )",
"where /q pwsh.exe",
"if %errorlevel% equ 0 (",
" pwsh -noprofile -ex unrestricted -command `"& '$resolved_path' $arg %args%;exit `$lastexitcode`"",
" pwsh -noprofile -ex unrestricted -file `"$resolved_path`" $arg %args%",
") else (",
" powershell -noprofile -ex unrestricted -command `"& '$resolved_path' $arg %args%;exit `$lastexitcode`"",
" powershell -noprofile -ex unrestricted -file `"$resolved_path`" $arg %args%",
")"
) -join "`r`n" | Out-File "$shim.cmd" -Encoding ASCII

Expand All @@ -653,9 +653,9 @@ function shim($path, $global, $name, $arg) {
"#!/bin/sh",
"# $resolved_path",
"if command -v pwsh.exe > /dev/null 2>&1; then",
" pwsh.exe -noprofile -ex unrestricted -command `"& '$resolved_path' $arg $@;exit \`$lastexitcode`"",
" pwsh.exe -noprofile -ex unrestricted -file `"$resolved_path`" $arg $@",
"else",
" powershell.exe -noprofile -ex unrestricted -command `"& '$resolved_path' $arg $@;exit \`$lastexitcode`"",
" powershell.exe -noprofile -ex unrestricted -file `"$resolved_path`" $arg $@",
"fi"
) -join "`n" | Out-File $shim -Encoding ASCII -NoNewline
} elseif ($path -match '\.jar$') {
Expand Down

0 comments on commit 81e2095

Please sign in to comment.