Improve Cygwin path-stripping code (fixes issue #67)
[msysgit.git] / msys.bat
blob1868e27ad54649b42881b2e49ff6898b47819769
1 @echo off\r
2 rem Copyright (C):  2001, 2002  Earnie Boyd\r
3 rem   mailto:earnie@users.sf.net\r
4 rem This file is part of Minimal SYStem\r
5 rem   http://www.mingw.org/msys.shtml\r
6 rem\r
7 rem File:           msys.bat\r
8 rem Revision:       2.0\r
9 rem Revision Date:  April 17th, 2002\r
11 rem ember to set the "Start in:" field of the shortcut.\r
12 rem A value similar to C:\msys\1.0\bin is what the "Start in:" field needs\r
13 rem to represent.\r
15 rem this should let run MSYS shell on x64\r
16 if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (\r
17   SET COMSPEC=%WINDIR%\SysWOW64\cmd.exe\r
18 )\r
20 rem ember value of GOTO: is used to know recursion has happened.\r
21 if "%1" == "GOTO:" goto %2\r
23 rem ember command.com only uses the first eight characters of the label.\r
24 set OS_VERSION="NT"\r
25 goto _WindowsNT\r
27 rem ember that we only execute here if we are in command.com.\r
28 :_Windows\r
29 set OS_VERSION="9x"\r
31 if "x%COMSPEC%" == "x" set COMSPEC=command.com\r
32 start %COMSPEC% /e:4096 /c %0 GOTO: _Resume %0 %1 %2 %3 %4 %5 %6 %7 %8 %9\r
33 goto EOF\r
35 rem ember that we execute here if we recursed.\r
36 :_Resume\r
37 for %%F in (1 2 3) do shift\r
39 rem ember that we get here even in command.com.\r
40 :_WindowsNT\r
42 if "x%MSYSTEM%" == "x" set MSYSTEM=MINGW32\r
43 if "%1" == "MSYS" set MSYSTEM=MSYS\r
45 if NOT "x%DISPLAY%" == "x" set DISPLAY=\r
47 rem We here assume old behavior, to make sure that older platforms can still use\r
48 rem this batch file to start their MSys environment.\r
49 set BIN=""\r
50 if EXIST bin\nul set BIN=bin\\r
51 if EXIST %BIN%bash.exe goto startbash\r
52 if EXIST %BIN%rxvt.exe goto startrxvt\r
54 rem If we're not on win9x type OSs, lets try a little better at finding bash/rxvt\r
55 if "win%OS_VERSION%"=="win9x" goto failed\r
56 set BIN="%~dp0bin\"\r
57 if EXIST %BIN%bash.exe goto startbash\r
58 if EXIST %BIN%rxvt.exe goto startrxvt\r
60 :failed\r
61 echo Cannot find the rxvt.exe or bash.exe binary -- aborting.\r
62 pause\r
63 rem exit 1\r
64 rem we skip using exit 1 here, since it will close the console you were working on\r
65 rem which probably isn't what you wanted. If the bat file was run from a shortcut\r
66 rem the window will still close, like you would expect it to. Sorry, you cant test\r
67 rem for exit values anymore, but hey, you can just un-rem the line above then! :-)\r
68 goto EOF\r
70 rem If you don't want to use rxvt then rename the file rxvt.exe to something\r
71 rem else.  Then bash.exe will be used instead.\r
72 :startrxvt\r
74 rem Setup the default colors for rxvt.\r
75 if "x%MSYSBGCOLOR%" == "x" set MSYSBGCOLOR=White\r
76 if "x%MSYSFGCOLOR%" == "x" set MSYSFGCOLOR=Black\r
77 if "x%MINGW32BGCOLOR%" == "x" set MINGW32BGCOLOR=LightYellow\r
78 if "x%MINGW32FGCOLOR%" == "x" set MINGW32FGCOLOR=Navy\r
79 if "%MSYSTEM%" == "MSYS" set BGCOLOR=%MSYSBGCOLOR%\r
80 if "%MSYSTEM%" == "MSYS" set FGCOLOR=%MSYSFGCOLOR%\r
81 if "%MSYSTEM%" == "MINGW32" set BGCOLOR=%MINGW32BGCOLOR%\r
82 if "%MSYSTEM%" == "MINGW32" set FGCOLOR=%MINGW32FGCOLOR%\r
84 start %COMSPEC% /c %BIN%rxvt -backspacekey \b -sl 2500 -fg %FGCOLOR% -bg %BGCOLOR% -sr -fn Courier-12 -tn msys -geometry 80x25 -e /bin/bash --login -i\r
85 exit\r
87 :startbash\r
88 call %COMSPEC% /c %BIN%bash --login -i\r
90 :EOF\r
92 rem ChangeLog:\r
93 rem 2002.03.07  Earnie Boyd  mailto:earnie@users.sf.net\r
94 rem     * Move the @echo off to the top.\r
95 rem     * Change the binmode setting to nobinmode.\r
96 rem     * Remove the angle brackets around email address to workaround MS\r
97 rem     buggy command processor.\r
98 rem\r
99 rem 2002.03.12  Earnie Boyd  mailto:earnie@users.sf.net\r
100 rem     * Add filter logic to find rxvt.exe\r
101 rem\r
102 rem 2002.03.13  Earnie Boyd  mailto:earnie@users.sf.net\r
103 rem     * Revert the nobinmode change.\r
104 rem\r
105 rem 2002.03.20  Earnie Boyd  mailto:earnie@users.sf.net\r
106 rem     * Add logic for stating bash.\r
107 rem\r
108 rem 2002.04.11  Earnie Boyd  mailto;earnie@users.sf.net\r
109 rem     * Add logic for setting MSYSTEM value based on parameter.\r
110 rem\r
111 rem 2002.04.15  Olivier Gautherot  mailto:olivier_gautherot@mentorg.com\r
112 rem     * Reduce number test conditions for finding an executable.\r
113 rem\r
114 rem 2002.04.15  Earnie Boyd  mailto:earnie@users.sf.net\r
115 rem     * Unset DISPLAY if set before starting shell.\r
116 rem\r
117 rem 2002.04.16  Earnie Boyd  mailto:earnie@users.sf.net\r
118 rem     * Remove use of DEFINED in conditional statments for variables for\r
119 rem     command.com support.\r
120 rem     * Add check for nonexistance of USERNAME variable for Win9x support.\r
121 rem\r
122 rem 2002.04.17  Earnie Boyd  mailto:earnie@users.sf.net\r
123 rem     * Add foreground and background color defaults based on MSYSTEM value.\r
124 rem\r
125 rem 2002.04.22  Earnie Boyd  mailto:earnie@users.sf.net\r
126 rem     * More Win 9x changes.\r
127 rem\r
128 rem 2002.05.04  Earnie Boyd  mailto:earnie@users.sf.net\r
129 rem     * Remove the SET of USERNAME and HOME.\r
130 rem\r
131 rem 2002.11.18  Earnie Boyd  mailto:earnie@users.sf.net\r
132 rem     * Add command.com detection and restart with a larger environment to\r
133 rem     avoid errors on w9x.\r
134 rem     Many thanks to Randy W. Sims mailto:RandyS@ThePierianSpring.org.\r
135 rem     See Randy's response to "RE: [Mingw-msys] Installation on WindowsME"\r
136 rem     from 11/06/2002 in the archives of mingw-msys@lists.sf.net.\r
137 rem\r
138 rem 2002.11.19  Paul Garceau  mailto:pgarceau@attbi.com\r
139 rem     * Fix a typo: Change COMPSPEC to COMSPEC.\r
140 rem\r
141 rem 2002.11.25  Earnie Boyd  mailto:earnie@users.sf.net\r
142 rem     * Remove the SET CYGWIN since it doesn't matter any longer.\r
143 rem\r
144 rem 2003.02.03  Earnie Boyd  mailto:earnie@users.sf.net\r
145 rem     * Win9x doesn't like ``EXISTS dir'' so change it to ``EXISTS dir\nul''.\r
146 rem     Thanks to Nicolas Weber mailto:nicolasweber@gmx.de.\r
147 rem\r
148 rem 2003.03.06  Earnie Boyd  mailto:earnie@users.sf.net\r
149 rem     * Add -backspacekey switch to rxvt startup.\r
150 rem     * Move RXVT color setup to startrxvt label\r
151 rem\r
152 rem 2004.01.30  Earnie Boyd  mailto:earnie@users.sf.net\r
153 rem     * Add -geometry parameter to work around an off by one issue with\r
154 rem       the default values.\r
155 rem     Thanks to Dave Schuyler mailto:parameter@users.sf.net\r