Skip to content

Commit

Permalink
fix(shim): Remove character replacement in .cmd -> .ps1 shims
Browse files Browse the repository at this point in the history
  • Loading branch information
L. Yeung committed May 17, 2022
1 parent 5d58703 commit c814712
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- **depends:** Avoid digits in archive file extension (except for .7z and .001) ([#4915](https://github.com/ScoopInstaller/Scoop/issues/4915))
- **bucket:** Don't check remote URL of non-git buckets ([#4923](https://github.com/ScoopInstaller/Scoop/issues/4923))
- **bucket:** Don't write message OK before bucket is cloned ([#4925](https://github.com/ScoopInstaller/Scoop/issues/4925))
- **shim:** Remove character replacement in .cmd -> .ps1 shims ([#4910](https://github.com/ScoopInstaller/Scoop/issues/4910))

### Documentation

Expand Down
12 changes: 2 additions & 10 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -679,19 +679,11 @@ function shim($path, $global, $name, $arg) {
@(
"@rem $resolved_path",
"@echo off",
"setlocal enabledelayedexpansion",
"set args=%*",
":: replace problem characters in arguments",
"set args=%args:`"='%",
"set args=%args:(=``(%",
"set args=%args:)=``)%",
"set invalid=`"='",
"if !args! == !invalid! ( set args= )",
"where /q pwsh.exe",
"if %errorlevel% equ 0 (",
" pwsh -noprofile -ex unrestricted -file `"$resolved_path`" $arg %args%",
" pwsh -noprofile -ex unrestricted -file `"$resolved_path`" $arg %*",
") else (",
" powershell -noprofile -ex unrestricted -file `"$resolved_path`" $arg %args%",
" powershell -noprofile -ex unrestricted -file `"$resolved_path`" $arg %*",
")"
) -join "`r`n" | Out-UTF8File "$shim.cmd"

Expand Down

0 comments on commit c814712

Please sign in to comment.