Skip to content

Commit

Permalink
Merge branch 'origin-development-dax' into cmder4win
Browse files Browse the repository at this point in the history
  • Loading branch information
daxgames authored Jan 5, 2025
2 parents ffa37d4 + 6cf4a42 commit bd3f132
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 104 deletions.
16 changes: 8 additions & 8 deletions launcher/src/CmderLauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,8 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
// Set path to Cmder user ConEmu config file
PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml");
}

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.
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.
{
if (cfgRoot.length() == 0) // '/c [path]' was NOT specified
{
Expand All @@ -325,7 +325,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
}
}
}
else // [terminal emulator config] file does not exist, copy config/[cpu specific terminal emulator config] file to [terminal emulator config] file
else // [terminal emulator config] file does not exist, copy config/[host specific terminal emulator config] file to [terminal emulator config] file
{
if (!CopyFile(cpuCfgPath, cfgPath, FALSE))
{
Expand All @@ -348,7 +348,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
}
}
}
else if (PathFileExists(userCfgPath)) // config/user[terminal emulator config] file exists, use it.
else if (wcscmp(userCfgPath, L"") != 0 && PathFileExists(userCfgPath)) // config/user[terminal emulator config] file exists, use it.
{
if (cfgRoot.length() == 0) // '/c [path]' was NOT specified
{
Expand Down Expand Up @@ -451,12 +451,12 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
{
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
? L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml! Access Denied."
: L"Failed to copy vendor/ConEmu.xml.default file to vendor/conemu-maximus5/ConEmu.xml!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
}
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.
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.
{
if (!CopyFile(cfgPath, userCfgPath, FALSE))
{
Expand All @@ -480,9 +480,9 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr

PathCombine(userConEmuCfgPath, userConfigDirPath, L"user-ConEmu.xml");
}
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]'.
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]'.
{
if (!CopyFile(defaultCfgPath, userCfgPath, FALSE))
if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE))
{
if (PathFileExists(windowsTerminalDir))
{
Expand Down
7 changes: 3 additions & 4 deletions launcher/src/version.rc2.sample
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

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

/////////////////////////////////////////////////////////////////////////////
Expand Down
3 changes: 3 additions & 0 deletions vendor/bin/create-cmdercfg.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

powershell -executionpolicy bypass -f "%cmder_root%\vendor\bin\create-cmdercfg.ps1" -shell cmd -outfile "%CMDER_CONFIG_DIR%\user_init.cmd"
14 changes: 8 additions & 6 deletions vendor/bin/excd.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@if "%~1"=="/?" (@cd %*)
@set excd=%*
@set excd=%excd:"=%
@if "%excd:~0,1%"=="~" (@set excd=%userprofile%\%excd:~1%)
@if not "%~1"=="/d" (@set excd_param="/d") else (@set excd_param=)
@cd %excd_param% "%excd%"
@echo off
set excd=%*
set excd=%excd:"=%
set excd_param=/d
if /i "%excd:~0,2%"=="/d" set "excd=%excd:~2%"
if "%excd:~0,1%"=="~" (set excd=%userprofile%\%excd:~1%)
if "%excd:~0,1%"=="/" (set excd_param=)
cd %excd_param% %excd%
2 changes: 1 addition & 1 deletion vendor/init.bat
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ if "%CMDER_ALIASES%" == "1" (
)

:: Add aliases to the environment
type "%user_aliases%" | findstr /b /l /i "history=cat " >nul
type "%user_aliases%" | %WINDIR%\System32\findstr /b /l /i "history=cat " >nul
if "%ERRORLEVEL%" == "0" (
echo Migrating alias 'history' to new Clink 1.x.x...
call "%CMDER_ROOT%\vendor\bin\alias.cmd" /d history
Expand Down
62 changes: 50 additions & 12 deletions vendor/lib/lib_base.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,24 @@ if "%~1" == "/h" (

exit /b

:help
:::===============================================================================
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
:::help - shows all sub routines in a .bat/.cmd file with documentation
:::.
:::include:
:::.
::: call "lib_base.cmd"
:::.
:::usage:
:::.
::: %lib_base% show_subs "file"
::: %lib_base% help "file"
:::.
:::options:
:::.
::: file <in> full path to file containing lib_routines to display
:::.
:::-------------------------------------------------------------------------------
for /f "tokens=* delims=:" %%a in ('type "%~1" ^| %WINDIR%\System32\findstr /i /r "^:::"') do (
rem echo a="%%a"

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

:cmder_shell
:::===============================================================================
:::show_subs - shows all sub routines in a .bat/.cmd file with documentation
:::cmder_shell - Initializes the Cmder shell environment variables
:::.
:::description:
:::.
::: This routine sets up the Cmder shell environment by detecting the
::: command shell and initializing related variables.
:::.
:::include:
:::.
Expand All @@ -55,14 +57,29 @@ exit /b
:::usage:
:::.
::: %lib_base% cmder_shell
:::-------------------------------------------------------------------------------

:cmder_shell
call :detect_comspec %ComSpec%
exit /b

:::===============================================================================
:::detect_comspec - Detects the command shell being used:::
:::.
:::options:
:::description:
:::.
::: file <in> full path to file containing lib_routines to display
::: This function sets the CMDER_SHELL variable to the name of the
::: detected command shell. It also initializes the CMDER_CLINK and
::: CMDER_ALIASES variables if they are not already defined.
:::.
:::include:
:::.
::: call "lib_base.cmd"
:::.
:::usage:
:::.
::: %lib_base% detect_comspec %ComSpec%
:::-------------------------------------------------------------------------------
call :detect_comspec %ComSpec%
exit /b

:detect_comspec
set CMDER_SHELL=%~n1
Expand All @@ -74,6 +91,27 @@ exit /b
)
exit /b

:::===============================================================================
:::update_legacy_aliases - Updates the legacy alias definitions in the user_aliases file
:::.
:::description:
:::.
::: This function checks if the user_aliases file contains the marker
::: ";= Add aliases below here". If the marker is not found, it creates
::: an initial user_aliases store by copying the default user_aliases file
::: from the CMDER_ROOT directory. If the CMDER_USER_CONFIG environment
::: variable is defined, it creates a backup of the existing user_aliases
::: file before copying the default file.
:::.
:::include:
:::.
::: call "lib_base.cmd"
:::.
:::usage:
:::.
::: %lib_base% update_legacy_aliases
:::-------------------------------------------------------------------------------

:update_legacy_aliases
type "%user_aliases%" | %WINDIR%\System32\findstr /i ";= Add aliases below here" >nul
if "%errorlevel%" == "1" (
Expand Down
30 changes: 17 additions & 13 deletions vendor/lib/lib_git.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ if "%~1" == "/h" (

exit /b

:read_version
:::===============================================================================
:::read_version - Get the git.exe version
:::.
Expand All @@ -34,6 +33,7 @@ exit /b
::: GIT_VERSION_[GIT SCOPE] <out> Env variable containing Git semantic version string
:::-------------------------------------------------------------------------------

:read_version
:: clear the variables
set GIT_VERSION_%~1=

Expand Down Expand Up @@ -64,7 +64,6 @@ exit /b

exit /b

:parse_version
:::===============================================================================
:::parse_version - Parse semantic version string 'x.x.x.x' and return the pieces
:::.
Expand All @@ -89,6 +88,7 @@ exit /b
::: [SCOPE]_BUILD <out> Scoped Build version.
:::-------------------------------------------------------------------------------

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

Expand All @@ -111,9 +111,8 @@ exit /b

:endlocal_set_git_version

:validate_version
:::===============================================================================
:::validate_version - Validate semantic version string 'x.x.x.x'.
:::validate_version - Validate semantic version string 'x.x.x.x'
:::.
:::include:
:::.
Expand All @@ -129,6 +128,7 @@ exit /b
::: [VERSION] <in> Semantic version String. Ex: 1.2.3.4
:::-------------------------------------------------------------------------------

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

Expand All @@ -143,9 +143,8 @@ exit /b
)
exit /b

:compare_versions
:::===============================================================================
:::compare_version - Compare semantic versions return latest version.
:::compare_version - Compare semantic versions and return latest version
:::.
:::include:
:::.
Expand All @@ -161,6 +160,7 @@ exit /b
::: [SCOPE2] <in> Example: VENDOR
:::-------------------------------------------------------------------------------

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

Expand All @@ -185,7 +185,12 @@ exit /b
endlocal & exit /b 0

:::===============================================================================
:::is_git_shim
:::is_git_shim - Check if the directory has a git.shim file
:::.
:::description:
:::.
::: Shim is a small helper program for Scoop that calls the executable configured in git.shim file
::: See: github.com/ScoopInstaller/Shim and github.com/cmderdev/cmder/pull/1905
:::.
:::include:
:::.
Expand All @@ -202,7 +207,7 @@ exit /b

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

:::===============================================================================
:::compare_git_versions
:::compare_git_versions - Compare the user git version against the vendored version
:::.
:::include:
:::.
Expand Down Expand Up @@ -253,7 +258,7 @@ exit /b
:: if the user provided git executable is not found
IF ERRORLEVEL -255 IF NOT ERRORLEVEL -254 (
:: if not exist "%git_executable%" (
%print_debug% ":compare_git_versions" "No git at "%git_executable%" found."
%print_debug% ":compare_git_versions" "No git at '%git_executable%' found."
set test_dir=
)
)
Expand All @@ -262,7 +267,7 @@ exit /b
exit /b

:::===============================================================================
:::get_user_git_version - get the version information for the user provided git binary
:::get_user_git_version - Get the version information for the user provided git binary
:::.
:::include:
:::.
Expand All @@ -278,5 +283,4 @@ exit /b
%lib_git% read_version USER "%test_dir%" 2>nul
%print_debug% ":get_user_git_version" "get_user_git_version GIT_VERSION_USER: %GIT_VERSION_USER%"
%lib_git% validate_version USER %GIT_VERSION_USER%
exit /b

exit /b
Loading

0 comments on commit bd3f132

Please sign in to comment.