How to run a script which can determine whether cmd.exe or gnu mingw shell is running

后端 未结 1 745
盖世英雄少女心
盖世英雄少女心 2021-01-14 08:07

I want to write a script which runs some git commands on Windows 7 platform.

The users have git tools installed or at least MINGW - the minimalist GNU for Windows

相关标签:
1条回答
  • 2021-01-14 08:40

    One trick I used is to name your sh script git-xxx.
    (Replace xxx by a sensible name). Start your script with #!/bin/sh.

    That way, you can launch 'git xxx' (gitspacexxx) from a git-bash or a CMD session: it will use the MINGW shell every time.

    Make sure that git-xxx (no extension) is in your %PATH%.
    And you PATH should also include <path/to/git/bin> and <path/to/git/usr/bin>. For instance:

    C:\prgs\git\PortableGit-2.7.0-64-bit\bin;C:\prgs\git\PortableGit-2.7.0-64-bit\usr\bin;
    

    That last path has more than 200 unix commands compiled for Windows.

    0 讨论(0)
提交回复
热议问题