Ticket #629: msys.bat

File msys.bat, 7.0 KB (added by cnielsen, 15 years ago)

updated to convert filepaths to space-less style

Line 
1@echo off
2rem Copyright (C): 2001, 2002, 2003, 2004, 2005 Earnie Boyd
3rem mailto:earnie@users.sf.net
4rem This file is part of Minimal SYStem
5rem http://www.mingw.org/msys.shtml
6rem
7rem File: msys.bat
8rem Revision: 2.4
9rem Revision Date: December 8th, 2005
10
11rem ember to set the "Start in:" field of the shortcut.
12rem A value similar to C:\msys\1.0\bin is what the "Start in:" field needs
13rem to represent.
14
15rem ember value of GOTO: is used to know recursion has happened.
16if "%1" == "GOTO:" goto %2
17
18if NOT "x%WD%" == "x" set WD=
19
20rem ember command.com only uses the first eight characters of the label.
21goto _WindowsNT
22
23rem ember that we only execute here if we are in command.com.
24:_Windows
25
26if "x%COMSPEC%" == "x" set COMSPEC=command.com
27start /min %COMSPEC% /e:4096 /c %0 GOTO: _Resume %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
28goto EOF
29
30rem ember that we execute here if we recursed.
31:_Resume
32for %%F in (1 2 3) do shift
33if NOT EXIST "%WD%msys-1.0.dll" set WD=.\bin\
34
35rem ember that we get here even in command.com.
36:_WindowsNT
37
38rem Hopefully a temporary workaround for getting MSYS shell to run on x64
39rem (WoW64 cmd prompt sets PROCESSOR_ARCHITECTURE to x86)
40if not "x%PROCESSOR_ARCHITECTURE%" == "xAMD64" goto _NotX64
41set COMSPEC=%WINDIR%\SysWOW64\cmd.exe
42%COMSPEC% /c %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
43goto EOF
44:_NotX64
45
46if NOT EXIST "%WD%msys-1.0.dll" set WD=%~dps0bin\
47echo %WD%
48
49rem if installed in a directory containing spaces prepare for a world of pain
50for /F %%i IN ('echo %WD%') DO @set PART1=%%i
51if NOT "%PART1%" == "%WD%" (
52 echo Path names containing spaces are not supported -- aborting.
53 pause
54 exit 1
55)
56
57rem ember Set up option to use rxvt based on value of %1
58if "x%MSYSCON%" == "x" set MSYSCON=rxvt.exe
59if "x%1" == "x-norxvt" set MSYSCON=sh.exe
60if "x%1" == "x--norxvt" set MSYSCON=sh.exe
61if "x%MSYSCON%" == "xsh.exe" shift
62
63if "x%MSYSTEM%" == "x" set MSYSTEM=MINGW32
64if "%1" == "MINGW32" set MSYSTEM=MINGW32
65if "%1" == "MSYS" set MSYSTEM=MSYS
66
67if NOT "x%DISPLAY%" == "x" set DISPLAY=
68
69if "x%MSYSCON%" == "xrxvt.exe" goto startrxvt
70if "x%MSYSCON%" == "xsh.exe" goto startsh
71
72:unknowncon
73echo %MSYSCON% is an unknown option for msys.bat.
74pause
75exit 1
76
77:notfound
78echo Cannot find the rxvt.exe or sh.exe binary -- aborting.
79pause
80exit 1
81
82rem If you don't want to use rxvt then rename the file rxvt.exe to something
83rem else. Then sh.exe will be used instead.
84:startrxvt
85if NOT EXIST "%WD%rxvt.exe" goto startsh
86
87rem Setup the default colors for rxvt.
88if "x%MSYSBGCOLOR%" == "x" set MSYSBGCOLOR=White
89if "x%MSYSFGCOLOR%" == "x" set MSYSFGCOLOR=Black
90if "x%MINGW32BGCOLOR%" == "x" set MINGW32BGCOLOR=LightYellow
91if "x%MINGW32FGCOLOR%" == "x" set MINGW32FGCOLOR=Navy
92if "%MSYSTEM%" == "MSYS" set BGCOLOR=%MSYSBGCOLOR%
93if "%MSYSTEM%" == "MSYS" set FGCOLOR=%MSYSFGCOLOR%
94if "%MSYSTEM%" == "MINGW32" set BGCOLOR=%MINGW32BGCOLOR%
95if "%MSYSTEM%" == "MINGW32" set FGCOLOR=%MINGW32FGCOLOR%
96
97if "x%*" == "x" start "MSYS 1.0" "%WD%rxvt" -backspacekey -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Courier-12 -tn msys -geometry 80x25 -e /bin/sh --login -i
98if NOT "x%*" == "x" start "MSYS 1.0" "%WD%rxvt" -backspacekey -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Courier-12 -tn msys -geometry 80x25 -e /bin/sh --login -c "%*"
99exit
100
101:startsh
102if NOT EXIST "%WD%sh.exe" goto notfound
103start "MSYS 1.0" "%WD%sh" --login -i
104exit
105
106:EOF
107
108rem ChangeLog:
109rem 2002.03.07 Earnie Boyd mailto:earnie@users.sf.net
110rem * Move the @echo off to the top.
111rem * Change the binmode setting to nobinmode.
112rem * Remove the angle brackets around email address to workaround MS
113rem buggy command processor.
114rem
115rem 2002.03.12 Earnie Boyd mailto:earnie@users.sf.net
116rem * Add filter logic to find rxvt.exe
117rem
118rem 2002.03.13 Earnie Boyd mailto:earnie@users.sf.net
119rem * Revert the nobinmode change.
120rem
121rem 2002.03.20 Earnie Boyd mailto:earnie@users.sf.net
122rem * Add logic for stating bash.
123rem
124rem 2002.04.11 Earnie Boyd mailto;earnie@users.sf.net
125rem * Add logic for setting MSYSTEM value based on parameter.
126rem
127rem 2002.04.15 Olivier Gautherot mailto:olivier_gautherot@mentorg.com
128rem * Reduce number test conditions for finding an executable.
129rem
130rem 2002.04.15 Earnie Boyd mailto:earnie@users.sf.net
131rem * Unset DISPLAY if set before starting shell.
132rem
133rem 2002.04.16 Earnie Boyd mailto:earnie@users.sf.net
134rem * Remove use of DEFINED in conditional statments for variables for
135rem command.com support.
136rem * Add check for nonexistance of USERNAME variable for Win9x support.
137rem
138rem 2002.04.17 Earnie Boyd mailto:earnie@users.sf.net
139rem * Add foreground and background color defaults based on MSYSTEM value.
140rem
141rem 2002.04.22 Earnie Boyd mailto:earnie@users.sf.net
142rem * More Win 9x changes.
143rem
144rem 2002.05.04 Earnie Boyd mailto:earnie@users.sf.net
145rem * Remove the SET of USERNAME and HOME.
146rem
147rem 2002.11.18 Earnie Boyd mailto:earnie@users.sf.net
148rem * Add command.com detection and restart with a larger environment to
149rem avoid errors on w9x.
150rem Many thanks to Randy W. Sims mailto:RandyS@ThePierianSpring.org.
151rem See Randy's response to "RE: [Mingw-msys] Installation on WindowsME"
152rem from 11/06/2002 in the archives of mingw-msys@lists.sf.net.
153rem
154rem 2002.11.19 Paul Garceau mailto:pgarceau@attbi.com
155rem * Fix a typo: Change COMPSPEC to COMSPEC.
156rem
157rem 2002.11.25 Earnie Boyd mailto:earnie@users.sf.net
158rem * Remove the SET CYGWIN since it doesn't matter any longer.
159rem
160rem 2003.02.03 Earnie Boyd mailto:earnie@users.sf.net
161rem * Win9x doesn't like ``EXISTS dir'' so change it to ``EXISTS dir\nul''.
162rem Thanks to Nicolas Weber mailto:nicolasweber@gmx.de.
163rem
164rem 2003.03.06 Earnie Boyd mailto:earnie@users.sf.net
165rem * Add -backspacekey switch to rxvt startup.
166rem * Move RXVT color setup to startrxvt label
167rem
168rem 2004.01.30 Earnie Boyd mailto:earnie@users.sf.net
169rem * Add -geometry parameter to work around an off by one issue with
170rem the default values.
171rem Thanks to Dave Schuyler mailto:parameter@users.sf.net
172rem
173rem 2004.03.28 Earnie Boyd mailto:earnie@users.sf.net
174rem * Add -norxvt or --norxvt switch argument.
175rem Thanks to Keith Marshall mailto:Keith.Marshall@total.com.
176rem * Add method to determine absolute path of msys.bat so that we no
177rem longer need to change to the bin directory. This allows msys.bat to be
178rem called from any working directory.
179rem Thanks to Kevin Mack mailto:kevin.mack@us.cd-adapco.com
180rem
181rem 2005.07.06 Max TE Woodbury mailto:mtew@users.sf.net
182rem * Fixed WD check for command.com systems.
183rem * Minimized intermediate CMD window to reduce startup flashyness.
184rem * If rxvt.exe cannot be found, try sh.exe.
185rem
186rem 2005.12.06 Tuomo Latto mailto:nonperson@users.sf.net
187rem * Added a temporary workaround for getting MSYS shell to run on x64.
188rem
189rem 2005.12.07 Keith Marshall mailto:keithmarshall@users.sf.net
190rem * ``EXISTS %WD%\sh.exe'' should be ``EXISTS %WD%sh.exe''; corrected.
191rem * Modified Tuomo's patch, to avoid trashing Window settings in Win32.
192rem
193rem 2005.12.08 Tuomo Latto mailto:nonperson@users.sf.net
194rem * Keith's modified patch fails on x64; start did funny things.
195rem Reworked, for correct behaviour on both platforms.
196rem