use consistent indentation in init.bat

This commit is contained in:
David Refoua 2022-10-18 15:20:35 +03:30
parent 6d77c988db
commit 971483b2b7
2 changed files with 126 additions and 126 deletions

View File

@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Testing Clink Shell - name: Testing Clink Shell
run: | run: |
cmd /c vendor\init.bat cmd /c vendor\init.bat /v /d /t
- name: Testing PowerShell - name: Testing PowerShell
run: | run: |
PowerShell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "Invoke-Expression '. ''vendor\profile.ps1'''" PowerShell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -Command "Invoke-Expression '. ''vendor\profile.ps1'''"

38
vendor/init.bat vendored
View File

@ -2,7 +2,7 @@
set CMDER_INIT_START=%time% set CMDER_INIT_START=%time%
:: Init Script for cmd.exe :: Init Script for cmd.exe shell
:: Created as part of cmder project :: Created as part of cmder project
:: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED :: !!! THIS FILE IS OVERWRITTEN WHEN CMDER IS UPDATED
@ -44,6 +44,7 @@ if not defined CMDER_ROOT (
:: Remove trailing '\' from %CMDER_ROOT% :: Remove trailing '\' from %CMDER_ROOT%
if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%" if "%CMDER_ROOT:~-1%" == "\" SET "CMDER_ROOT=%CMDER_ROOT:~0,-1%"
:: Include Cmder libraries
call "%cmder_root%\vendor\bin\cexec.cmd" /setpath call "%cmder_root%\vendor\bin\cexec.cmd" /setpath
call "%cmder_root%\vendor\lib\lib_base" call "%cmder_root%\vendor\lib\lib_base"
call "%cmder_root%\vendor\lib\lib_path" call "%cmder_root%\vendor\lib\lib_path"
@ -58,9 +59,9 @@ call "%cmder_root%\vendor\lib\lib_profile"
set fast_init=1 set fast_init=1
) else if /i "%1" == "/t" ( ) else if /i "%1" == "/t" (
set time_init=1 set time_init=1
) else if /i "%1"=="/v" ( ) else if /i "%1" == "/v" (
set verbose_output=1 set verbose_output=1
) else if /i "%1"=="/d" ( ) else if /i "%1" == "/d" (
set debug_output=1 set debug_output=1
) else if /i "%1" == "/max_depth" ( ) else if /i "%1" == "/max_depth" (
if "%~2" geq "1" if "%~2" leq "5" ( if "%~2" geq "1" if "%~2" leq "5" (
@ -91,7 +92,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
%print_error% "The Git install root folder "%~2", you specified does not exist!" %print_error% "The Git install root folder "%~2", you specified does not exist!"
exit /b exit /b
) )
) else if /i "%1"=="/nix_tools" ( ) else if /i "%1" == "/nix_tools" (
if "%2" equ "0" ( if "%2" equ "0" (
REM Do not add *nix tools to path REM Do not add *nix tools to path
set nix_tools=0 set nix_tools=0
@ -123,7 +124,7 @@ call "%cmder_root%\vendor\lib\lib_profile"
goto var_loop goto var_loop
:start :start
:: Sets CMDER_SHELL, CMDER_CLINK, CMDER_ALIASES :: Sets CMDER_SHELL, CMDER_CLINK, CMDER_ALIASES variables
%lib_base% cmder_shell %lib_base% cmder_shell
%print_debug% init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%" %print_debug% init.bat "Env Var - CMDER_ROOT=%CMDER_ROOT%"
%print_debug% init.bat "Env Var - debug_output=%debug_output%" %print_debug% init.bat "Env Var - debug_output=%debug_output%"
@ -134,7 +135,7 @@ if defined CMDER_USER_CONFIG (
if not exist "%CMDER_USER_CONFIG%\..\opt" md "%CMDER_USER_CONFIG%\..\opt" if not exist "%CMDER_USER_CONFIG%\..\opt" md "%CMDER_USER_CONFIG%\..\opt"
) )
:: Pick right version of clink :: Pick right version of Clink
if "%PROCESSOR_ARCHITECTURE%"=="x86" ( if "%PROCESSOR_ARCHITECTURE%"=="x86" (
set clink_architecture=x86 set clink_architecture=x86
set architecture_bits=32 set architecture_bits=32
@ -164,14 +165,14 @@ if "%CMDER_CLINK%" == "1" (
del "%CMDER_USER_CONFIG%\settings" del "%CMDER_USER_CONFIG%\settings"
) )
REM Cleanup legacy CLink history file REM Cleanup legacy Clink history file
if exist "%CMDER_USER_CONFIG%\.history" if exist "%CMDER_USER_CONFIG%\clink_history" ( if exist "%CMDER_USER_CONFIG%\.history" if exist "%CMDER_USER_CONFIG%\clink_history" (
del "%CMDER_USER_CONFIG%\.history" del "%CMDER_USER_CONFIG%\.history"
) )
"%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_USER_CONFIG%" --scripts "%CMDER_ROOT%\vendor" "%CMDER_ROOT%\vendor\clink\clink_%clink_architecture%.exe" inject --quiet --profile "%CMDER_USER_CONFIG%" --scripts "%CMDER_ROOT%\vendor"
) else ( ) else (
if not exist "%CMDER_ROOT%\config\settings" if not exist "%CMDER_ROOT%\config\clink_settings" ( if not exist "%CMDER_ROOT%\config\settings" if not exist "%CMDER_ROOT%\config\clink_settings" (
echo Generating clink initial settings in "%CMDER_ROOT%\config\clink_settings" echo Generating Clink initial settings in "%CMDER_ROOT%\config\clink_settings"
copy "%CMDER_ROOT%\vendor\clink_settings.default" "%CMDER_ROOT%\config\clink_settings" copy "%CMDER_ROOT%\vendor\clink_settings.default" "%CMDER_ROOT%\config\clink_settings"
echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup. echo Additional *.lua files in "%CMDER_ROOT%\config" are loaded on startup.
) )
@ -209,10 +210,7 @@ if "%CMDER_CONFIGURED%" GTR "1" (
:: Prepare for git-for-windows :: Prepare for git-for-windows
:: I do not even know, copypasted from their .bat :: Detect which git.exe version to use
set PLINK_PROTOCOL=ssh
:: The idea:
:: * if the users points as to a specific git, use that :: * if the users points as to a specific git, use that
:: * test if a git is in path and if yes, use that :: * test if a git is in path and if yes, use that
:: * last, use our vendored git :: * last, use our vendored git
@ -228,13 +226,13 @@ if defined GIT_INSTALL_ROOT (
%print_debug% init.bat "Looking for Git install root..." %print_debug% init.bat "Looking for Git install root..."
:: get the version information for vendored git binary :: Get the version information for vendored git binary
%lib_git% read_version VENDORED "%CMDER_ROOT%\vendor\git-for-windows\cmd" 2>nul %lib_git% read_version VENDORED "%CMDER_ROOT%\vendor\git-for-windows\cmd" 2>nul
%lib_git% validate_version VENDORED %GIT_VERSION_VENDORED% %lib_git% validate_version VENDORED %GIT_VERSION_VENDORED%
:: check if git is in path... :: Check if git is in path
for /F "delims=" %%F in ('where git.exe 2^>nul ^| find "\cmd\git.exe"') do ( for /F "delims=" %%F in ('where git.exe 2^>nul ^| find "\cmd\git.exe"') do (
:: get the absolute path to the user provided git binary :: Get the absolute path to the user provided git binary
%lib_git% is_git_shim "%%~dpF" %lib_git% is_git_shim "%%~dpF"
%lib_git% get_user_git_version %lib_git% get_user_git_version
%lib_git% compare_git_versions %lib_git% compare_git_versions
@ -244,7 +242,7 @@ for /F "delims=" %%F in ('where git.exe 2^>nul ^| find "\cmd\git.exe"') do (
) )
) )
:: our last hope: our own git... :: Our last hope: use vendored git
:VENDORED_GIT :VENDORED_GIT
if exist "%CMDER_ROOT%\vendor\git-for-windows" ( if exist "%CMDER_ROOT%\vendor\git-for-windows" (
set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows" set "GIT_INSTALL_ROOT=%CMDER_ROOT%\vendor\git-for-windows"
@ -267,7 +265,7 @@ goto :CONFIGURE_GIT
:: Add git to the path :: Add git to the path
if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" %lib_path% enhance_path "%GIT_INSTALL_ROOT%\cmd" "" if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" %lib_path% enhance_path "%GIT_INSTALL_ROOT%\cmd" ""
:: Add the unix commands at the end to not shadow windows commands like more :: Add the unix commands at the end to not shadow windows commands like more and find
if %nix_tools% equ 1 ( if %nix_tools% equ 1 (
%print_verbose% "Preferring Windows commands" %print_verbose% "Preferring Windows commands"
set "path_position=append" set "path_position=append"
@ -287,7 +285,10 @@ if %nix_tools% geq 1 (
) )
) )
:: define SVN_SSH so we can use git svn with ssh svn repositories :: Plink (PuTTY Link) is a command-line connection tool similar to ssh, setting its protocol to ssh
set PLINK_PROTOCOL=ssh
:: Define SVN_SSH so we can use git svn with ssh svn repositories
if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe" if not defined SVN_SSH set "SVN_SSH=%GIT_INSTALL_ROOT:\=\\%\\bin\\ssh.exe"
:: Find locale.exe: From the git install root, from the path, using the git installed env, or fallback using the env from the path. :: Find locale.exe: From the git install root, from the path, using the git installed env, or fallback using the env from the path.
@ -298,7 +299,6 @@ if not defined git_locale for /F "tokens=* delims=" %%F in ('where env.exe 2^>nu
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
if defined git_locale ( if defined git_locale (
REM %print_debug% init.bat "Env Var - git_locale=!git_locale!" REM %print_debug% init.bat "Env Var - git_locale=!git_locale!"
if not defined LANG ( if not defined LANG (
for /F "delims=" %%F in ('!git_locale! -uU 2') do ( for /F "delims=" %%F in ('!git_locale! -uU 2') do (