Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create sh shim #1951

Merged
merged 7 commits into from
Feb 19, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@ function shim($path, $global, $name, $arg) {
# shim .bat, .cmd so they can be used by programs with no awareness of PSH
$shim_cmd = "$(strip_ext($shim)).cmd"
"@`"$(resolve-path $path)`" $arg %*" | out-file $shim_cmd -encoding ascii

$shim_sh = "$(strip_ext($shim))"
"#!/bin/sh`ncmd `"$(resolve-path $path)`" `"$@`"" | out-file $shim_sh -encoding ascii
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't $arg be in here too?
"#!/bin/sh`ncmd `"$(resolve-path $path)`" $arg `"$@`""

} elseif($path -match '\.ps1$') {
# make ps1 accessible from cmd.exe
$shim_cmd = "$(strip_ext($shim)).cmd"
Expand All @@ -248,11 +251,10 @@ set args=%args:)=``)%
set invalid=`"='
if !args! == !invalid! ( set args= )
powershell -noprofile -ex unrestricted `"& '$(resolve-path $path)' %args%;exit `$lastexitcode`"" | out-file $shim_cmd -encoding ascii
}

# make command accessible from sh terminals
$shim_cmd = $(strip_ext($shim))
"#!/bin/sh`npowershell -ex unrestricted `"$(resolve-path $path)`" `"$@`"" | out-file $shim_cmd -encoding ascii
$shim_sh = "$(strip_ext($shim))"
"#!/bin/sh`npowershell -ex unrestricted `"$(resolve-path $path)`" `"$@`"" | out-file $shim_sh -encoding ascii
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too
"#!/bin/sh`npowershell -ex unrestricted `"$(resolve-path $path)`" $arg `"$@`""

}
}

function ensure_in_path($dir, $global) {
Expand Down