From df23827b1e2861ee174f6b6751d9369d7cce11ba Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Thu, 21 Jun 2018 09:52:50 +0200 Subject: [PATCH] Fix generated shell scripts for MSYS2/MINGW It has been reported tons and tons of times that the generated shell scripts simply fail in Git Bash of the Git for Windows project. The reason is that the Cygwin-specific basedir workaround is also required for MSYS2 (which is used internally by the Git Bash). Let's be nice to everybody and include support for MSYS2. As MSYS2 distinguishes between MSYS/MINGW modes, triggered by setting the environment variable MSYSTEM to the values MSYS, MINGW32 and MINGW64, and as those modes are reflected in the output of `uname -s`, we need to look not only for MSYS but also for MINGW in the output of `uname`. This addresses https://github.com/yarnpkg/yarn/issues/5349 among other issues. Signed-off-by: Johannes Schindelin --- index.js | 4 ++-- package.json | 2 +- test/basic.js | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 9f22e10..78f53f9 100644 --- a/index.js +++ b/index.js @@ -116,7 +116,7 @@ function writeShim_ (from, to, prog, args, cb) { // basedir=`dirname "$0"` // // case `uname` in - // *CYGWIN*) basedir=`cygpath -w "$basedir"`;; + // *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;; // esac // // if [ -x "$basedir/node.exe" ]; then @@ -135,7 +135,7 @@ function writeShim_ (from, to, prog, args, cb) { + "basedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")\n" + "\n" + "case `uname` in\n" - + " *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;\n" + + " *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;\n" + "esac\n" + "\n" diff --git a/package.json b/package.json index 95520a9..64ff4f1 100644 --- a/package.json +++ b/package.json @@ -18,4 +18,4 @@ "tap": "~0.4.11", "rimraf": "~2.2.8" } -} \ No newline at end of file +} diff --git a/test/basic.js b/test/basic.js index 0982315..acb7140 100755 --- a/test/basic.js +++ b/test/basic.js @@ -34,7 +34,7 @@ test('env shebang', function (t) { "\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")"+ "\n"+ "\ncase `uname` in"+ - "\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;"+ + "\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;"+ "\nesac"+ "\n"+ "\nif [ -x \"$basedir/node\" ]; then"+ @@ -72,7 +72,7 @@ test('env shebang with args', function (t) { "\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")"+ "\n"+ "\ncase `uname` in"+ - "\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;"+ + "\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;"+ "\nesac"+ "\n"+ "\nif [ -x \"$basedir/node\" ]; then"+ @@ -110,7 +110,7 @@ test('explicit shebang', function (t) { "\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")" + "\n" + "\ncase `uname` in" + - "\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;" + + "\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;" + "\nesac" + "\n" + "\nif [ -x \"$basedir//usr/bin/sh\" ]; then" + @@ -149,7 +149,7 @@ test('explicit shebang with args', function (t) { "\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")" + "\n" + "\ncase `uname` in" + - "\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;" + + "\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;" + "\nesac" + "\n" + "\nif [ -x \"$basedir//usr/bin/sh\" ]; then" +