Skip to content

Commit 49f0c13

Browse files
dschoisaacs
authored andcommitted
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 yarnpkg/yarn#5349 among other issues. Signed-off-by: Johannes Schindelin <[email protected]> PR-URL: #30 Credit: @dscho Close: #30 Reviewed-by: @isaacs
1 parent adaf20b commit 49f0c13

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function writeShim_ (from, to, prog, args, variables, cb) {
132132
// basedir=`dirname "$0"`
133133
//
134134
// case `uname` in
135-
// *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
135+
// *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
136136
// esac
137137
//
138138
// if [ -x "$basedir/node.exe" ]; then
@@ -150,7 +150,7 @@ function writeShim_ (from, to, prog, args, variables, cb) {
150150
+ "basedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")\n"
151151
+ "\n"
152152
+ "case `uname` in\n"
153-
+ " *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;\n"
153+
+ " *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;\n"
154154
+ "esac\n"
155155
+ "\n"
156156

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
"rimraf": "~2.2.8",
1919
"tap": "^1.2.0"
2020
}
21-
}
21+
}

test/basic.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ test('no shebang', function (t) {
1717
"\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")"+
1818
"\n"+
1919
"\ncase `uname` in"+
20-
"\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;"+
20+
"\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;"+
2121
"\nesac"+
2222
"\n"+
2323
"\n\"$basedir/from.exe\" \"$@\"\nexit $?\n")
@@ -39,7 +39,7 @@ test('env shebang', function (t) {
3939
"\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")" +
4040
"\n" +
4141
"\ncase `uname` in" +
42-
"\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;" +
42+
"\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;" +
4343
"\nesac" +
4444
"\n" +
4545
"\nif [ -x \"$basedir/node\" ]; then" +
@@ -80,7 +80,7 @@ test('env shebang with args', function (t) {
8080
"\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")"+
8181
"\n"+
8282
"\ncase `uname` in"+
83-
"\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;"+
83+
"\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;"+
8484
"\nesac"+
8585
"\n"+
8686
"\nif [ -x \"$basedir/node\" ]; then"+
@@ -121,7 +121,7 @@ test('env shebang with variables', function (t) {
121121
"\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")" +
122122
"\n"+
123123
"\ncase `uname` in"+
124-
"\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;"+
124+
"\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;"+
125125
"\nesac"+
126126
"\n"+
127127
"\nif [ -x \"$basedir/node\" ]; then"+
@@ -162,7 +162,7 @@ test('explicit shebang', function (t) {
162162
"\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")" +
163163
"\n" +
164164
"\ncase `uname` in" +
165-
"\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;" +
165+
"\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;" +
166166
"\nesac" +
167167
"\n" +
168168
"\nif [ -x \"$basedir//usr/bin/sh\" ]; then" +
@@ -204,7 +204,7 @@ test('explicit shebang with args', function (t) {
204204
"\nbasedir=$(dirname \"$(echo \"$0\" | sed -e 's,\\\\,/,g')\")" +
205205
"\n" +
206206
"\ncase `uname` in" +
207-
"\n *CYGWIN*) basedir=`cygpath -w \"$basedir\"`;;" +
207+
"\n *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w \"$basedir\"`;;" +
208208
"\nesac" +
209209
"\n" +
210210
"\nif [ -x \"$basedir//usr/bin/sh\" ]; then" +

0 commit comments

Comments
 (0)