Skip to content

Commit bd3f132

Browse files
authored
Merge branch 'origin-development-dax' into cmder4win
2 parents ffa37d4 + 6cf4a42 commit bd3f132

File tree

11 files changed

+154
-104
lines changed

11 files changed

+154
-104
lines changed

launcher/src/CmderLauncher.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
299299
// Set path to Cmder user ConEmu config file
300300
PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml");
301301
}
302-
303-
if ( PathFileExists(cpuCfgPath) || use_user_cfg == false ) // config/[cpu specific terminal emulator config] file exists or /m was specified on command line, use machine specific config.
302+
303+
if (wcscmp(cpuCfgPath, L"") != 0 && (PathFileExists(cpuCfgPath) || use_user_cfg == false)) // config/[host specific terminal emulator config] file exists or /m was specified on command line, use machine specific config.
304304
{
305305
if (cfgRoot.length() == 0) // '/c [path]' was NOT specified
306306
{
@@ -325,7 +325,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
325325
}
326326
}
327327
}
328-
else // [terminal emulator config] file does not exist, copy config/[cpu specific terminal emulator config] file to [terminal emulator config] file
328+
else // [terminal emulator config] file does not exist, copy config/[host specific terminal emulator config] file to [terminal emulator config] file
329329
{
330330
if (!CopyFile(cpuCfgPath, cfgPath, FALSE))
331331
{
@@ -348,7 +348,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
348348
}
349349
}
350350
}
351-
else if (PathFileExists(userCfgPath)) // config/user[terminal emulator config] file exists, use it.
351+
else if (wcscmp(userCfgPath, L"") != 0 && PathFileExists(userCfgPath)) // config/user[terminal emulator config] file exists, use it.
352352
{
353353
if (cfgRoot.length() == 0) // '/c [path]' was NOT specified
354354
{
@@ -451,12 +451,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
451451
{
452452
MessageBox(NULL,
453453
(GetLastError() == ERROR_ACCESS_DENIED)
454-
? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
454+
? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
455455
: L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP);
456456
exit(1);
457457
}
458458
}
459-
else if (PathFileExists(cfgPath)) // This is a first time Cmder.exe run and [terminal emulator config] file exists, copy [terminal emulator config] file to config/user_[terminal emulator config] file.
459+
else if (wcscmp(cfgPath, L"") != 0 && PathFileExists(cfgPath)) // This is a first time Cmder.exe run and [terminal emulator config] file exists, copy [terminal emulator config] file to config/user_[terminal emulator config] file.
460460
{
461461
if (!CopyFile(cfgPath, userCfgPath, FALSE))
462462
{
@@ -480,9 +480,9 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
480480

481481
PathCombine(userConEmuCfgPath, userConfigDirPath, L"user-ConEmu.xml");
482482
}
483-
else if (wcscmp(defaultCfgPath, L"") == 0) // '/c [path]' was specified and 'vendor/[terminal emulator config].default' config exists, copy Cmder 'vendor/[terminal emulator config].default' file to '[user specified path]/config/user_[terminal emulator config]'.
483+
else if (wcscmp(defaultCfgPath, L"") != 0) // '/c [path]' was specified and 'vendor/[terminal emulator config].default' config exists, copy Cmder 'vendor/[terminal emulator config].default' file to '[user specified path]/config/user_[terminal emulator config]'.
484484
{
485-
if (!CopyFile(defaultCfgPath, userCfgPath, FALSE))
485+
if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE))
486486
{
487487
if (PathFileExists(windowsTerminalDir))
488488
{

launcher/src/version.rc2.sample

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11

22
/**
3-
* WARNING: do NOT modify this file! the content of this file should be
4-
* automatically generated before AppVeyor builds using the
5-
* respective .ps1 Powershell scripts.
6-
*
3+
* WARNING: This file should NOT be manually modified!
4+
* The contents will be automatically generated using the `.ps1` PowerShell scripts,
5+
* during builds by the CI.
76
*/
87

98
/////////////////////////////////////////////////////////////////////////////

vendor/bin/create-cmdercfg.cmd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@echo off
2+
3+
powershell -executionpolicy bypass -f "%cmder_root%\vendor\bin\create-cmdercfg.ps1" -shell cmd -outfile "%CMDER_CONFIG_DIR%\user_init.cmd"

vendor/bin/excd.cmd

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
@if "%~1"=="/?" (@cd %*)
2-
@set excd=%*
3-
@set excd=%excd:"=%
4-
@if "%excd:~0,1%"=="~" (@set excd=%userprofile%\%excd:~1%)
5-
@if not "%~1"=="/d" (@set excd_param="/d") else (@set excd_param=)
6-
@cd %excd_param% "%excd%"
1+
@echo off
2+
set excd=%*
3+
set excd=%excd:"=%
4+
set excd_param=/d
5+
if /i "%excd:~0,2%"=="/d" set "excd=%excd:~2%"
6+
if "%excd:~0,1%"=="~" (set excd=%userprofile%\%excd:~1%)
7+
if "%excd:~0,1%"=="/" (set excd_param=)
8+
cd %excd_param% %excd%

vendor/init.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ if "%CMDER_ALIASES%" == "1" (
478478
)
479479

480480
:: Add aliases to the environment
481-
type "%user_aliases%" | findstr /b /l /i "history=cat " >nul
481+
type "%user_aliases%" | %WINDIR%\System32\findstr /b /l /i "history=cat " >nul
482482
if "%ERRORLEVEL%" == "0" (
483483
echo Migrating alias 'history' to new Clink 1.x.x...
484484
call "%CMDER_ROOT%\vendor\bin\alias.cmd" /d history

vendor/lib/lib_base.cmd

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,24 @@ if "%~1" == "/h" (
1010

1111
exit /b
1212

13-
:help
1413
:::===============================================================================
15-
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
14+
:::help - shows all sub routines in a .bat/.cmd file with documentation
1615
:::.
1716
:::include:
1817
:::.
1918
::: call "lib_base.cmd"
2019
:::.
2120
:::usage:
2221
:::.
23-
::: %lib_base% show_subs "file"
22+
::: %lib_base% help "file"
2423
:::.
2524
:::options:
2625
:::.
2726
::: file <in> full path to file containing lib_routines to display
28-
:::.
2927
:::-------------------------------------------------------------------------------
30-
for /f "tokens=* delims=:" %%a in ('type "%~1" ^| %WINDIR%\System32\findstr /i /r "^:::"') do (
31-
rem echo a="%%a"
3228

29+
:help
30+
for /f "tokens=* delims=:" %%a in ('%WINDIR%\System32\findstr /i /r "^:::" "%~1"') do (
3331
if "%%a"=="." (
3432
echo.
3533
) else if /i "%%a" == "usage" (
@@ -44,9 +42,13 @@ exit /b
4442
pause
4543
exit /b
4644

47-
:cmder_shell
4845
:::===============================================================================
49-
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
46+
:::cmder_shell - Initializes the Cmder shell environment variables
47+
:::.
48+
:::description:
49+
:::.
50+
::: This routine sets up the Cmder shell environment by detecting the
51+
::: command shell and initializing related variables.
5052
:::.
5153
:::include:
5254
:::.
@@ -55,14 +57,29 @@ exit /b
5557
:::usage:
5658
:::.
5759
::: %lib_base% cmder_shell
60+
:::-------------------------------------------------------------------------------
61+
62+
:cmder_shell
63+
call :detect_comspec %ComSpec%
64+
exit /b
65+
66+
:::===============================================================================
67+
:::detect_comspec - Detects the command shell being used:::
5868
:::.
59-
:::options:
69+
:::description:
6070
:::.
61-
::: file <in> full path to file containing lib_routines to display
71+
::: This function sets the CMDER_SHELL variable to the name of the
72+
::: detected command shell. It also initializes the CMDER_CLINK and
73+
::: CMDER_ALIASES variables if they are not already defined.
74+
:::.
75+
:::include:
6276
:::.
77+
::: call "lib_base.cmd"
78+
:::.
79+
:::usage:
80+
:::.
81+
::: %lib_base% detect_comspec %ComSpec%
6382
:::-------------------------------------------------------------------------------
64-
call :detect_comspec %ComSpec%
65-
exit /b
6683

6784
:detect_comspec
6885
set CMDER_SHELL=%~n1
@@ -74,6 +91,27 @@ exit /b
7491
)
7592
exit /b
7693

94+
:::===============================================================================
95+
:::update_legacy_aliases - Updates the legacy alias definitions in the user_aliases file
96+
:::.
97+
:::description:
98+
:::.
99+
::: This function checks if the user_aliases file contains the marker
100+
::: ";= Add aliases below here". If the marker is not found, it creates
101+
::: an initial user_aliases store by copying the default user_aliases file
102+
::: from the CMDER_ROOT directory. If the CMDER_USER_CONFIG environment
103+
::: variable is defined, it creates a backup of the existing user_aliases
104+
::: file before copying the default file.
105+
:::.
106+
:::include:
107+
:::.
108+
::: call "lib_base.cmd"
109+
:::.
110+
:::usage:
111+
:::.
112+
::: %lib_base% update_legacy_aliases
113+
:::-------------------------------------------------------------------------------
114+
77115
:update_legacy_aliases
78116
type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul
79117
if "%errorlevel%" == "1" (

vendor/lib/lib_git.cmd

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ if "%~1" == "/h" (
1212

1313
exit /b
1414

15-
:read_version
1615
:::===============================================================================
1716
:::read_version - Get the git.exe version
1817
:::.
@@ -34,6 +33,7 @@ exit /b
3433
::: GIT_VERSION_[GIT SCOPE] <out> Env variable containing Git semantic version string
3534
:::-------------------------------------------------------------------------------
3635

36+
:read_version
3737
:: clear the variables
3838
set GIT_VERSION_%~1=
3939

@@ -64,7 +64,6 @@ exit /b
6464

6565
exit /b
6666

67-
:parse_version
6867
:::===============================================================================
6968
:::parse_version - Parse semantic version string 'x.x.x.x' and return the pieces
7069
:::.
@@ -89,6 +88,7 @@ exit /b
8988
::: [SCOPE]_BUILD <out> Scoped Build version.
9089
:::-------------------------------------------------------------------------------
9190

91+
:parse_version
9292
:: process a `x.x.x.xxxx.x` formatted string
9393
%print_debug% :parse_version "ARGV[1]=%~1, ARGV[2]=%~2"
9494

@@ -111,9 +111,8 @@ exit /b
111111

112112
:endlocal_set_git_version
113113

114-
:validate_version
115114
:::===============================================================================
116-
:::validate_version - Validate semantic version string 'x.x.x.x'.
115+
:::validate_version - Validate semantic version string 'x.x.x.x'
117116
:::.
118117
:::include:
119118
:::.
@@ -129,6 +128,7 @@ exit /b
129128
::: [VERSION] <in> Semantic version String. Ex: 1.2.3.4
130129
:::-------------------------------------------------------------------------------
131130

131+
:validate_version
132132
:: now parse the version information into the corresponding variables
133133
%print_debug% :validate_version "ARGV[1]=%~1, ARGV[2]=%~2"
134134

@@ -143,9 +143,8 @@ exit /b
143143
)
144144
exit /b
145145

146-
:compare_versions
147146
:::===============================================================================
148-
:::compare_version - Compare semantic versions return latest version.
147+
:::compare_version - Compare semantic versions and return latest version
149148
:::.
150149
:::include:
151150
:::.
@@ -161,6 +160,7 @@ exit /b
161160
::: [SCOPE2] <in> Example: VENDOR
162161
:::-------------------------------------------------------------------------------
163162

163+
:compare_versions
164164
:: checks all major, minor, patch and build variables for the given arguments.
165165
:: whichever binary that has the most recent version will be used based on the return code.
166166

@@ -185,7 +185,12 @@ exit /b
185185
endlocal & exit /b 0
186186

187187
:::===============================================================================
188-
:::is_git_shim
188+
:::is_git_shim - Check if the directory has a git.shim file
189+
:::.
190+
:::description:
191+
:::.
192+
::: Shim is a small helper program for Scoop that calls the executable configured in git.shim file
193+
::: See: github.com/ScoopInstaller/Shim and github.com/cmderdev/cmder/pull/1905
189194
:::.
190195
:::include:
191196
:::.
@@ -202,7 +207,7 @@ exit /b
202207

203208
:is_git_shim
204209
pushd "%~1"
205-
:: check if there's shim - and if yes follow the path
210+
:: check if there is a shim file - if yes, read the actual executable path
206211
setlocal enabledelayedexpansion
207212
if exist git.shim (
208213
for /F "tokens=2 delims== " %%I in (git.shim) do (
@@ -219,7 +224,7 @@ exit /b
219224
exit /b
220225

221226
:::===============================================================================
222-
:::compare_git_versions
227+
:::compare_git_versions - Compare the user git version against the vendored version
223228
:::.
224229
:::include:
225230
:::.
@@ -253,7 +258,7 @@ exit /b
253258
:: if the user provided git executable is not found
254259
IF ERRORLEVEL -255 IF NOT ERRORLEVEL -254 (
255260
:: if not exist "%git_executable%" (
256-
%print_debug% ":compare_git_versions" "No git at "%git_executable%" found."
261+
%print_debug% ":compare_git_versions" "No git at '%git_executable%' found."
257262
set test_dir=
258263
)
259264
)
@@ -262,7 +267,7 @@ exit /b
262267
exit /b
263268

264269
:::===============================================================================
265-
:::get_user_git_version - get the version information for the user provided git binary
270+
:::get_user_git_version - Get the version information for the user provided git binary
266271
:::.
267272
:::include:
268273
:::.
@@ -278,5 +283,4 @@ exit /b
278283
%lib_git% read_version USER "%test_dir%" 2>nul
279284
%print_debug% ":get_user_git_version" "get_user_git_version GIT_VERSION_USER: %GIT_VERSION_USER%"
280285
%lib_git% validate_version USER %GIT_VERSION_USER%
281-
exit /b
282-
286+
exit /b

0 commit comments

Comments
 (0)