1

I operate in an environment that uses both git-bash and cygwin bash. There are probably other flavors as well. What is the easiest way to robustly identify which bash flavor is running?

IMPLEMENTATION NOTE: There are a lot of non-trivial ways to do this; there are a lot of ways to make potential solutions fail.

Here's how one developer does this: Update the .bashrc by adding an environment variable. In scripts, check the value of the environment variable. Pro: easy. Con: This requires the modification of 2 .bashrc files.

Richard Jessop
  • 897
  • 1
  • 12
  • 19
  • 1
    We're here to help you fix code that isn't working. We'll need to see samples and error messages. Please update your Q with your best attempt to solve your problem. Good lulck.\ – shellter May 01 '20 at 14:27
  • Why does it matter? What will you do differently in one bash versus the other? – glenn jackman May 01 '20 at 15:07

1 Answers1

1

uname -s should be enough:

  • Git for Windows bash:

    MINGW64_NT-10.0-18363
    
  • Cygwin bash (as illustrated here)

    CYGWIN_NT-5.1
    
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250