Giter VIP home page Giter VIP logo

native's Issues

Unix-like systems should respect PATH for sh and bash rather than defaulting to /bin

Similar to using #!/usr/bin/env bash or #!/usr/bin/env sh, maybe something like

# Note: By default, due to its ubiquity, we use bash, unless -UseSh was passed or bash doesn't exist (unlikely).
if ($UseSh) {
	(Get-Command -CommandType 'Application' -Name 'sh').Path
} else {
	@(Get-Command -CommandType 'Application' -Name 'bash', 'sh' -ErrorAction SilentlyContinue)[0].Path
}

`ie` can't call executables installed by Scoop

I use Scoop to install command line programs on Windows. For each executable, Scoop creates two shims in ~/scoop/shims/: a .ps1 and an .exe. For example:

PS C:\> Get-Command -All git

CommandType     Name             Version    Source
-----------     ----             -------    ------
ExternalScript  git.ps1                     C:\Users\imgx64\scoop\shims\git.ps1
Application     git.exe          0.0.0.0    C:\Users\imgx64\scoop\shims\git.exe

If you try to run such shim with ie, it fails because the .ps1 has higher priority.

PS C:\> ie git --version
This command supports external executables (applications) only; "git" ("git.ps1") is a command of type ExternalScript
At C:\Users\imgx64\Documents\WindowsPowerShell\Modules\Native\1.0.3\Native.psm1:540 char:5
+     Throw (
+     ~~~~~~~
    + CategoryInfo          : InvalidArgument: (git:String) [], ArgumentException
    + FullyQualifiedErrorId : InvalidCommandType

Is it possible to detect this and run the .exe instead, without the user having to type .exe explicitly?

PS C:\> ie git.exe --version
git version 2.28.0.windows.1

Try cmd /s /c instead of the temporary batch file

cmd.exe does have a simpler mode for passing in command-line stuff: use /s and put a pair of double quotes over whatever is in /c as the end of the cmdline. The quote would be simply stripped and the contents used.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.