Skip to content

Commit 7b3055f

Browse files
committed
.bat-files: move duplicated code to separate file
1 parent a7b0cf6 commit 7b3055f

File tree

5 files changed

+79
-86
lines changed

5 files changed

+79
-86
lines changed

filesystem/PKGBUILD

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Maintainer: Alexey Pavlov <alexpux@gmail.com>
22

33
pkgname=filesystem
4-
pkgver=2016.03
5-
pkgrel=2
4+
pkgver=2016.04
5+
pkgrel=1
66
pkgdesc='Base filesystem'
77
arch=('i686' 'x86_64')
88
license=('BSD')
@@ -23,6 +23,7 @@ source=('bash.bash_logout'
2323
'dot.inputrc'
2424
'dot.profile'
2525
'fstab'
26+
'start_shell.cmd'
2627
'mingw32_shell.bat'
2728
'mingw64_shell.bat'
2829
'msys2_shell.bat'
@@ -51,9 +52,10 @@ sha256sums=('6d651f6b0b2d173961a3fa21acd9d44c783ed9cd73a031687698c8b9ed1f6dee'
5152
'b896abbbd7187184045e42e2646d4cb25f5484a27558f780137c7ec9ca9bdc47'
5253
'50c3746d621e682e3560e1b37cc1ac5d988460064a20ed15f107c203ac5ad622'
5354
'9620bdf1c82ea3f14c3553c44a2006ea61ff3f5a775a2a053130a59cc186daf5'
54-
'91e1dc387c06af1f222df8fa067a335c15723a6af1eaefae303060083d193b98'
55-
'41368f93b01436eb9a0ff978d751612adde1245e3eb1e69321dbf109463fd7a3'
56-
'6afb20f651f340b3b45875177212979636eaae92f7fa9f85c5fdaec1ba76806a'
55+
'5137f56e2bbdf51cca60f1f8033aeda7f383e3dc86b2ad0fa1c6b732b91866bc'
56+
'147773db7cb87fe09f735b5f47ff0dc3e1ffb8bf3149a51636341f7f61feec11'
57+
'fd6d475058e122823aa8665d8c8bf6bde251524fbba954c1f1c941c10ea46f7f'
58+
'eae2795591117fd3d7665d94a7b1827e13176580bc5a16d65350c584df5aaa7e'
5759
'7d6994d7caf52a459b562cfb0da1d758a4b7bca478d1df00de3a96686e59008e'
5860
'91f1f918cf13deab0124082086e990786113b0e710dbda4678d8fc14905ad94d'
5961
'c2f0bd7714f4909c8be30217e6f68929ab5ea2856ebb04663e9e709cc35416d5'
@@ -108,6 +110,7 @@ package() {
108110
install -m644 ${srcdir}/profile.lang.sh etc/profile.d/lang.sh
109111

110112
install -m644 ${srcdir}/msys2.ico msys2.ico
113+
install -m755 ${srcdir}/start_shell.cmd start_shell.cmd
111114
install -m755 ${srcdir}/msys2_shell.bat msys2_shell.bat
112115
install -m755 ${srcdir}/mingw32_shell.bat mingw32_shell.bat
113116
install -m755 ${srcdir}/mingw64_shell.bat mingw64_shell.bat

filesystem/mingw32_shell.bat

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
:
22
@echo off
33

4-
set "WD=%__CD__%"
5-
6-
if NOT EXIST "%WD%msys-2.0.dll" set "WD=%~dp0usr\bin\"
7-
8-
set MSYSTEM=MINGW32
9-
104
rem To activate windows native symlinks uncomment next line
115
rem set MSYS=winsymlinks:nativestrict
126

@@ -16,25 +10,5 @@ rem set MSYS=error_start:%WD%../../mingw32/bin/qtcreator.exe^|-debug^|^<process-
1610
rem To export full current PATH from environment into MSYS2 uncomment next line
1711
rem set SET_FULL_PATH=1
1812

19-
if "x%~1" == "x-consolez" shift& set MSYSCON=console.exe
20-
if "x%~1" == "x-mintty" shift& set MSYSCON=mintty.exe
21-
22-
if "x%MSYSCON%" == "xmintty.exe" goto startmintty
23-
if "x%MSYSCON%" == "xconsole.exe" goto startconsolez
24-
25-
if NOT EXIST "%WD%mintty.exe" goto startsh
26-
set MSYSCON=mintty.exe
27-
:startmintty
28-
start "%MSYSTEM%" "%WD%mintty" -i /msys2.ico /usr/bin/bash --login %1 %2 %3 %4 %5 %6 %7 %8 %9
29-
exit /b %ERRORLEVEL%
30-
31-
:startconsolez
32-
cd %WD%..\lib\ConsoleZ
33-
start console -t "MinGW" -r %1 %2 %3 %4 %5 %6 %7 %8 %9
34-
exit /b %ERRORLEVEL%
35-
36-
:startsh
37-
start "%MSYSTEM%" "%WD%sh" --login -i %1 %2 %3 %4 %5 %6 %7 %8 %9
38-
exit /b %ERRORLEVEL%
39-
13+
call "%~dp0start_shell.cmd" -mingw32 %*
4014
:EOF

filesystem/mingw64_shell.bat

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
:
22
@echo off
33

4-
set "WD=%__CD__%"
5-
6-
if NOT EXIST "%WD%msys-2.0.dll" set "WD=%~dp0usr\bin\"
7-
8-
set MSYSTEM=MINGW64
9-
104
rem To activate windows native symlinks uncomment next line
115
rem set MSYS=winsymlinks:nativestrict
126

@@ -16,25 +10,5 @@ rem set MSYS=error_start:%WD%../../mingw64/bin/qtcreator.exe^|-debug^|^<process-
1610
rem To export full current PATH from environment into MSYS2 uncomment next line
1711
rem set SET_FULL_PATH=1
1812

19-
if "x%~1" == "x-consolez" shift& set MSYSCON=console.exe
20-
if "x%~1" == "x-mintty" shift& set MSYSCON=mintty.exe
21-
22-
if "x%MSYSCON%" == "xmintty.exe" goto startmintty
23-
if "x%MSYSCON%" == "xconsole.exe" goto startconsolez
24-
25-
if NOT EXIST "%WD%mintty.exe" goto startsh
26-
set MSYSCON=mintty.exe
27-
:startmintty
28-
start "%MSYSTEM%" "%WD%mintty" -i /msys2.ico /usr/bin/bash --login %1 %2 %3 %4 %5 %6 %7 %8 %9
29-
exit /b %ERRORLEVEL%
30-
31-
:startconsolez
32-
cd %WD%..\lib\ConsoleZ
33-
start console -t "MinGW" -r %1 %2 %3 %4 %5 %6 %7 %8 %9
34-
exit /b %ERRORLEVEL%
35-
36-
:startsh
37-
start "%MSYSTEM%" "%WD%sh" --login -i %1 %2 %3 %4 %5 %6 %7 %8 %9
38-
exit /b %ERRORLEVEL%
39-
13+
call "%~dp0start_shell.cmd" -mingw64 %*
4014
:EOF

filesystem/msys2_shell.bat

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
:
22
@echo off
33

4-
set "WD=%__CD__%"
5-
6-
if NOT EXIST "%WD%msys-2.0.dll" set "WD=%~dp0usr\bin\"
7-
8-
set MSYSTEM=MSYS
9-
104
rem To activate windows native symlinks uncomment next line
115
rem set MSYS=winsymlinks:nativestrict
126

@@ -16,25 +10,5 @@ rem set MSYS=error_start:%WD%../../mingw32/bin/qtcreator.exe^|-debug^|^<process-
1610
rem To export full current PATH from environment into MSYS2 uncomment next line
1711
rem set SET_FULL_PATH=1
1812

19-
if "x%~1" == "x-consolez" shift& set MSYSCON=console.exe
20-
if "x%~1" == "x-mintty" shift& set MSYSCON=mintty.exe
21-
22-
if "x%MSYSCON%" == "xmintty.exe" goto startmintty
23-
if "x%MSYSCON%" == "xconsole.exe" goto startconsolez
24-
25-
if NOT EXIST "%WD%mintty.exe" goto startsh
26-
set MSYSCON=mintty.exe
27-
:startmintty
28-
start "%MSYSTEM%" "%WD%mintty" -i /msys2.ico /usr/bin/bash --login %1 %2 %3 %4 %5 %6 %7 %8 %9
29-
exit /b %ERRORLEVEL%
30-
31-
:startconsolez
32-
cd %WD%..\lib\ConsoleZ
33-
start console -t "MSys2" -r %1 %2 %3 %4 %5 %6 %7 %8 %9
34-
exit /b %ERRORLEVEL%
35-
36-
:startsh
37-
start "%MSYSTEM%" "%WD%sh" --login -i %1 %2 %3 %4 %5 %6 %7 %8 %9
38-
exit /b %ERRORLEVEL%
39-
13+
call "%~dp0start_shell.cmd" -msys %*
4014
:EOF

filesystem/start_shell.cmd

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
@echo off
2+
3+
set "WD=%__CD__%"
4+
if NOT EXIST "%WD%msys-2.0.dll" set "WD=%~dp0usr\bin\"
5+
6+
rem To activate windows native symlinks uncomment next line
7+
rem set MSYS=winsymlinks:nativestrict
8+
9+
rem Set debugging program for errors
10+
rem set MSYS=error_start:%WD%../../mingw64/bin/qtcreator.exe^|-debug^|^<process-id^>
11+
12+
rem To export full current PATH from environment into MSYS2 uncomment next line
13+
rem set SET_FULL_PATH=1
14+
15+
:checkparams
16+
rem Shell types
17+
if "x%~1" == "x-msys" shift& set MSYSTEM=MSYS& goto :checkparams
18+
if "x%~1" == "x-msys2" shift& set MSYSTEM=MSYS& goto :checkparams
19+
if "x%~1" == "x-mingw32" shift& set MSYSTEM=MINGW32& goto :checkparams
20+
if "x%~1" == "x-mingw64" shift& set MSYSTEM=MINGW64& goto :checkparams
21+
if "x%~1" == "x-mingw" shift& (
22+
if exist "%WD%..\..\mingw64" (set MSYSTEM=MINGW64) else (set MSYSTEM=MINGW32)
23+
)& goto :checkparams
24+
rem Console types
25+
if "x%~1" == "x-consolez" shift& set MSYSCON=console.exe& goto :checkparams
26+
if "x%~1" == "x-mintty" shift& set MSYSCON=mintty.exe& goto :checkparams
27+
if "x%~1" == "x-defterm" shift& set MSYSCON=defterm& goto :checkparams
28+
29+
30+
rem Autodetect shell type if not specified
31+
if not defined MSYSTEM (
32+
if exist "%WD%..\..\mingw64" (
33+
set MSYSTEM=MINGW64
34+
) else if exist "%WD%..\..\mingw32" (
35+
set MSYSTEM=MINGW32
36+
) else (set MSYSTEM=MSYS)
37+
)
38+
39+
rem Setup proper title
40+
if "%MSYSTEM%" == "MSYS" (
41+
set CONTITLE=MSys2
42+
) else if "%MSYSTEM%" == "MINGW32" (
43+
set "CONTITLE=MinGW x32"
44+
) else if "%MSYSTEM%" == "MINGW64" (
45+
set "CONTITLE=MinGW x64"
46+
)
47+
48+
if "x%MSYSCON%" == "xmintty.exe" goto startmintty
49+
if "x%MSYSCON%" == "xconsole.exe" goto startconsolez
50+
if "x%MSYSCON%" == "xdefterm" goto startsh
51+
52+
if NOT EXIST "%WD%mintty.exe" goto startsh
53+
set MSYSCON=mintty.exe
54+
:startmintty
55+
start "%CONTITLE%" "%WD%mintty" -i /msys2.ico /usr/bin/bash --login %1 %2 %3 %4 %5 %6 %7 %8 %9
56+
exit /b %ERRORLEVEL%
57+
58+
:startconsolez
59+
cd %WD%..\lib\ConsoleZ
60+
start console -t "%CONTITLE%" -r %1 %2 %3 %4 %5 %6 %7 %8 %9
61+
exit /b %ERRORLEVEL%
62+
63+
:startsh
64+
set MSYSCON=
65+
start "%CONTITLE%" "%WD%bash" --login %1 %2 %3 %4 %5 %6 %7 %8 %9
66+
exit /b %ERRORLEVEL%
67+
68+
:EOF

0 commit comments

Comments
 (0)