From 90d86a7e5e471311675354088518820a24e6b5c3 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Mon, 6 Nov 2023 09:55:49 -0500 Subject: [PATCH 01/18] add vendor/bin/create-cmdercfg.cmd --- vendor/bin/create-cmdercfg.cmd | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 vendor/bin/create-cmdercfg.cmd diff --git a/vendor/bin/create-cmdercfg.cmd b/vendor/bin/create-cmdercfg.cmd new file mode 100644 index 0000000..cc8c711 --- /dev/null +++ b/vendor/bin/create-cmdercfg.cmd @@ -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" From d2f7136ef8ceec529758efb20f9b7ba4154a9a9e Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 6 Jun 2024 13:34:55 +0330 Subject: [PATCH 02/18] modify the header to remove outdated mention --- launcher/src/version.rc2.sample | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/launcher/src/version.rc2.sample b/launcher/src/version.rc2.sample index b809c36..e8d509b 100644 --- a/launcher/src/version.rc2.sample +++ b/launcher/src/version.rc2.sample @@ -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. */ ///////////////////////////////////////////////////////////////////////////// From b56a6d43cb7387e5cc25fad93b51cbfe13f06660 Mon Sep 17 00:00:00 2001 From: Stan West <38358698+stanwest@users.noreply.github.com> Date: Fri, 26 Jul 2024 20:24:12 -0400 Subject: [PATCH 03/18] Use single quotes inside double quotes --- vendor/lib/lib_git.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/lib/lib_git.cmd b/vendor/lib/lib_git.cmd index de963ce..f20f7e8 100644 --- a/vendor/lib/lib_git.cmd +++ b/vendor/lib/lib_git.cmd @@ -253,7 +253,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= ) ) From 540532f126f4f3a3e5e3cc463d58cdf1e171b8bd Mon Sep 17 00:00:00 2001 From: David Refoua Date: Mon, 14 Oct 2024 14:40:21 +0330 Subject: [PATCH 04/18] make library comments consistent and clean up code --- vendor/lib/lib_base.cmd | 64 ++++++++++++++++++++++++++++++-------- vendor/lib/lib_git.cmd | 21 ++++++------- vendor/lib/lib_profile.cmd | 19 ++++++----- 3 files changed, 70 insertions(+), 34 deletions(-) diff --git a/vendor/lib/lib_base.cmd b/vendor/lib/lib_base.cmd index d86a7fc..f7420ef 100644 --- a/vendor/lib/lib_base.cmd +++ b/vendor/lib/lib_base.cmd @@ -10,9 +10,8 @@ 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: :::. @@ -20,16 +19,15 @@ exit /b :::. :::usage: :::. -::: %lib_base% show_subs "file" +::: %lib_base% help "file" :::. :::options: :::. ::: file 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" ( @@ -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: :::. @@ -55,15 +57,30 @@ exit /b :::usage: :::. ::: %lib_base% cmder_shell -:::. -:::options: -:::. -::: file full path to file containing lib_routines to display -:::. :::------------------------------------------------------------------------------- + +:cmder_shell call :detect_comspec %ComSpec% exit /b +:::=============================================================================== +:::detect_comspec - Detects the command shell being used::: +:::. +:::description: +:::. +::: 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% +:::------------------------------------------------------------------------------- + :detect_comspec set CMDER_SHELL=%~n1 if not defined CMDER_CLINK ( @@ -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" ( diff --git a/vendor/lib/lib_git.cmd b/vendor/lib/lib_git.cmd index f20f7e8..58d2f19 100644 --- a/vendor/lib/lib_git.cmd +++ b/vendor/lib/lib_git.cmd @@ -12,7 +12,6 @@ if "%~1" == "/h" ( exit /b -:read_version :::=============================================================================== :::read_version - Get the git.exe version :::. @@ -34,6 +33,7 @@ exit /b ::: GIT_VERSION_[GIT SCOPE] Env variable containing Git semantic version string :::------------------------------------------------------------------------------- +:read_version :: clear the variables set GIT_VERSION_%~1= @@ -64,7 +64,6 @@ exit /b exit /b -:parse_version :::=============================================================================== :::parse_version - Parse semantic version string 'x.x.x.x' and return the pieces :::. @@ -89,6 +88,7 @@ exit /b ::: [SCOPE]_BUILD Scoped Build version. :::------------------------------------------------------------------------------- +:parse_version :: process a `x.x.x.xxxx.x` formatted string %print_debug% :parse_version "ARGV[1]=%~1, ARGV[2]=%~2" @@ -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: :::. @@ -129,6 +128,7 @@ exit /b ::: [VERSION] 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" @@ -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: :::. @@ -161,6 +160,7 @@ exit /b ::: [SCOPE2] 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. @@ -185,7 +185,7 @@ exit /b endlocal & exit /b 0 :::=============================================================================== -:::is_git_shim +:::is_git_shim - Check if the directory has a git.shim file :::. :::include: :::. @@ -219,7 +219,7 @@ exit /b exit /b :::=============================================================================== -:::compare_git_versions +:::compare_git_versions - Compare the user git version against the vendored version :::. :::include: :::. @@ -262,7 +262,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: :::. @@ -278,5 +278,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 diff --git a/vendor/lib/lib_profile.cmd b/vendor/lib/lib_profile.cmd index 850db14..050beac 100644 --- a/vendor/lib/lib_profile.cmd +++ b/vendor/lib/lib_profile.cmd @@ -12,26 +12,26 @@ if "%~1" == "/h" ( exit /b -:run_profile_d :::=============================================================================== -:::run_profile_d - Run all scripts in the passed dir path -::: +:::run_profile_d - Run all scripts in the passed directory path +:::. :::include: -::: +:::. ::: call "lib_profile.cmd" -::: +:::. :::usage: -::: +:::. ::: %lib_profile% "[dir_path]" -::: +:::. :::required: -::: +:::. ::: [dir_path] Fully qualified directory path containing init *.cmd|*.bat. ::: Example: "c:\bin" -::: +:::. ::: path Sets the path env variable if required. :::------------------------------------------------------------------------------- +:run_profile_d if not exist "%~1" ( mkdir "%~1" ) @@ -43,4 +43,3 @@ exit /b ) popd exit /b - From 4204faa063620ee92505bdb78c5e99797c736f28 Mon Sep 17 00:00:00 2001 From: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com> Date: Wed, 16 Oct 2024 13:42:04 +0000 Subject: [PATCH 05/18] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Update=20dependencie?= =?UTF-8?q?s=20(git-for-windows=20v2.47.0.windows.1,=20clink=20v1.7.3,=20c?= =?UTF-8?q?link-completions=20v0.6.0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vendor/sources.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vendor/sources.json b/vendor/sources.json index 97c82e7..1926359 100644 --- a/vendor/sources.json +++ b/vendor/sources.json @@ -1,13 +1,13 @@ [ { "name": "git-for-windows", - "version": "2.45.1.windows.1", - "url": "https://github.com/git-for-windows/git/releases/download/v2.45.1.windows.1/PortableGit-2.45.1-64-bit.7z.exe" + "version": "2.47.0.windows.1", + "url": "https://github.com/git-for-windows/git/releases/download/v2.47.0.windows.1/PortableGit-2.47.0-64-bit.7z.exe" }, { "name": "clink", - "version": "1.6.14", - "url": "https://github.com/chrisant996/clink/releases/download/v1.6.14/clink.1.6.14.93b83f.zip" + "version": "1.7.3", + "url": "https://github.com/chrisant996/clink/releases/download/v1.7.3/clink.1.7.3.f8fb96.zip" }, { "name": "conemu-maximus5", @@ -16,7 +16,7 @@ }, { "name": "clink-completions", - "version": "0.5.2", - "url": "https://github.com/vladimir-kotikov/clink-completions/archive/v0.5.2.zip" + "version": "0.6.0", + "url": "https://github.com/vladimir-kotikov/clink-completions/archive/v0.6.0.zip" } ] From e220d114b2226e05a3be228fff7d3436ca3f619d Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 17 Oct 2024 19:43:14 +0330 Subject: [PATCH 06/18] add notes on what shim actually is --- vendor/lib/lib_git.cmd | 7 +- vendor/psmodules/Cmder.ps1 | 357 +++++++++++++++++++------------------ 2 files changed, 185 insertions(+), 179 deletions(-) diff --git a/vendor/lib/lib_git.cmd b/vendor/lib/lib_git.cmd index 58d2f19..7b3bc47 100644 --- a/vendor/lib/lib_git.cmd +++ b/vendor/lib/lib_git.cmd @@ -187,6 +187,11 @@ exit /b :::=============================================================================== :::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: :::. ::: call "$0" @@ -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 ( diff --git a/vendor/psmodules/Cmder.ps1 b/vendor/psmodules/Cmder.ps1 index a42e40c..ec9cc2c 100644 --- a/vendor/psmodules/Cmder.ps1 +++ b/vendor/psmodules/Cmder.ps1 @@ -1,178 +1,179 @@ -function readVersion($gitPath) { - $gitExecutable = "${gitPath}\git.exe" - - if (-not (Test-Path "$gitExecutable")) { - return $null - } - - $gitVersion = (cmd /c "${gitExecutable}" --version) - - if ($gitVersion -match 'git version') { - ($trash1, $trash2, $gitVersion) = $gitVersion.split(' ', 3) - } else { - pause - return $null - } - - return $gitVersion.toString() -} - -function isGitShim($gitPath) { - # check if there's shim - and if yes follow the path - - if (Test-Path "${gitPath}\git.shim") { - $shim = (get-content "${gitPath}\git.shim") - ($trash, $gitPath) = $shim.replace(' ', '').split('=') - - $gitPath = $gitPath.replace('\git.exe', '') - } - - return $gitPath.toString() -} - -function compareVersions($userVersion, $vendorVersion) { - if ($null -ne $userVersion) { - ($userMajor, $userMinor, $userPatch, $userBuild) = $userVersion.split('.', 4) - } else { - return -1 - } - - if ($null -ne $vendorVersion) { - ($vendorMajor, $vendorMinor, $vendorPatch, $vendorBuild) = $vendorVersion.split('.', 4) - } else { - return 1 - } - - if (($userMajor -eq $vendorMajor) -and ($userMinor -eq $vendorMinor) -and ($userPatch -eq $vendorPatch) -and ($userBuild -eq $vendorBuild)) { - return 1 - } - - if ($userMajor -gt $vendorMajor) { return 1 } - if ($userMajor -lt $vendorMajor) { return -1 } - - if ($userMinor -gt $vendorMinor) { return 1 } - if ($userMinor -lt $vendorMinor) { return -1 } - - if ($userPatch -gt $vendorPatch) { return 1 } - if ($userPatch -lt $vendorPatch) { return -1 } - - if ($userBuild -gt $vendorBuild) { return 1 } - if ($userBuild -lt $vendorBuild) { return -1 } - - return 0 -} - -function compare_git_versions($userVersion, $vendorVersion) { - $result = compareVersions -userVersion $userVersion -vendorVersion $vendorVersion - - Write-Debug "Compare Versions Result: ${result}" - if ($result -ge 0) { - return $userVersion - } - else { - return $vendorVersion - } -} - -function Configure-Git($gitRoot, $gitType, $gitPathUser) { - # Proposed Behavior - - # Modify the path if we are using VENDORED Git, do nothing if using USER Git. - # If User Git is installed but is older, match its path config adding paths - # in the same path positions allowing a user to configure Cmder Git path - # using locally installed Git Path Config. - if ($gitType -eq 'VENDOR') { - # If User Git is installed replace its path config with Newer Vendored Git Path - if (($null -ne $gitPathUser) -and ($gitPathUser -ne '')) { - Write-Verbose "Cmder 'profile.ps1': Replacing older user Git path '$gitPathUser' with newer vendored Git path '$gitRoot' in the system path..." - - $newPath = ($env:path -ireplace [regex]::Escape($gitPathUser), $gitRoot) - } - else { - if (-not ($env:Path -match [regex]::Escape("$gitRoot\cmd"))) { - Write-Debug "Adding $gitRoot\cmd to the path" - $newPath = $($gitRoot + "\cmd" + ";" + $env:Path) - } - - # Add "$gitRoot\mingw[32|64]\bin" to the path if exists and not done already - if ((Test-Path "$gitRoot\mingw32\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw32\bin"))) { - Write-Debug "Adding $gitRoot\mingw32\bin to the path" - $newPath = "$newPath;$gitRoot\mingw32\bin" - } - elseif ((Test-Path "$gitRoot\mingw64\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw64\bin"))) { - Write-Debug "Adding $gitRoot\mingw64\bin to the path" - $newPath = "$newPath;$gitRoot\mingw64\bin" - } - - # Add "$gitRoot\usr\bin" to the path if exists and not done already - if ((Test-Path "$gitRoot\usr\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\usr\bin"))) { - Write-Debug "Adding $gitRoot\usr\bin to the path" - $newPath = "$newPath;$gitRoot\usr\bin" - } - } - - return $newPath - } - - return $env:path -} - -function Import-Git() { - $GitModule = Get-Module -Name Posh-Git -ListAvailable - if ($GitModule | Select-Object version | Where-Object version -le ([version]"0.6.1.20160330")) { - Import-Module Posh-Git > $null - } - if ($GitModule | Select-Object version | Where-Object version -ge ([version]"1.0.0")) { - Import-Module Posh-Git > $null - $GitPromptSettings.AnsiConsole = $false - } - if (-not $GitModule) { - Write-Host -NoNewline "`r`n" - Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart Cmder." - Write-Host -NoNewline "`r$([char]0x1B)[A" - return $false - } - # Make sure we only run once by always returning true - return $true -} - -function checkGit($Path) { - if (-not (Get-Command git -ErrorAction SilentlyContinue)) { - return - } - if (-not (Test-Path -Path (Join-Path $Path '.git'))) { - $SplitPath = Split-Path $path - if ($SplitPath) { checkGit($SplitPath) } - return - } - if (getGitStatusSetting -eq $true) { - if ($null -eq $env:gitLoaded) { - $env:gitLoaded = Import-Git - } - if ($env:gitLoaded -eq $true) { - Write-VcsStatus - } - } - else { - $headContent = Get-Content (Join-Path $Path '.git/HEAD') - if ($headContent -like "ref: refs/heads/*") { - $branchName = $headContent.Substring(16) - } - else { - $branchName = "HEAD detached at $($headContent.Substring(0, 7))" - } - Write-Host " [$branchName]" -NoNewline -ForegroundColor White - } -} - -function getGitStatusSetting() { - $gitStatus = (git --no-pager config -l) | Out-String - - foreach ($line in $($gitStatus -split "`r`n")) { - if (($line -match 'cmder.status=false') -or ($line -match 'cmder.psstatus=false')) { - return $false - } - } - - return $true -} +function readVersion($gitPath) { + $gitExecutable = "${gitPath}\git.exe" + + if (-not (Test-Path "$gitExecutable")) { + return $null + } + + $gitVersion = (cmd /c "${gitExecutable}" --version) + + if ($gitVersion -match 'git version') { + ($trash1, $trash2, $gitVersion) = $gitVersion.split(' ', 3) + } else { + pause + return $null + } + + return $gitVersion.toString() +} + +function isGitShim($gitPath) { + # check if there is a shim file - if yes, read the actual executable path + # See: github.com/ScoopInstaller/Shim + + if (Test-Path "${gitPath}\git.shim") { + $shim = (get-content "${gitPath}\git.shim") + ($trash, $gitPath) = $shim.replace(' ', '').split('=') + + $gitPath = $gitPath.replace('\git.exe', '') + } + + return $gitPath.toString() +} + +function compareVersions($userVersion, $vendorVersion) { + if ($null -ne $userVersion) { + ($userMajor, $userMinor, $userPatch, $userBuild) = $userVersion.split('.', 4) + } else { + return -1 + } + + if ($null -ne $vendorVersion) { + ($vendorMajor, $vendorMinor, $vendorPatch, $vendorBuild) = $vendorVersion.split('.', 4) + } else { + return 1 + } + + if (($userMajor -eq $vendorMajor) -and ($userMinor -eq $vendorMinor) -and ($userPatch -eq $vendorPatch) -and ($userBuild -eq $vendorBuild)) { + return 1 + } + + if ($userMajor -gt $vendorMajor) { return 1 } + if ($userMajor -lt $vendorMajor) { return -1 } + + if ($userMinor -gt $vendorMinor) { return 1 } + if ($userMinor -lt $vendorMinor) { return -1 } + + if ($userPatch -gt $vendorPatch) { return 1 } + if ($userPatch -lt $vendorPatch) { return -1 } + + if ($userBuild -gt $vendorBuild) { return 1 } + if ($userBuild -lt $vendorBuild) { return -1 } + + return 0 +} + +function compare_git_versions($userVersion, $vendorVersion) { + $result = compareVersions -userVersion $userVersion -vendorVersion $vendorVersion + + Write-Debug "Compare Versions Result: ${result}" + if ($result -ge 0) { + return $userVersion + } + else { + return $vendorVersion + } +} + +function Configure-Git($gitRoot, $gitType, $gitPathUser) { + # Proposed Behavior + + # Modify the path if we are using VENDORED Git, do nothing if using USER Git. + # If User Git is installed but is older, match its path config adding paths + # in the same path positions allowing a user to configure Cmder Git path + # using locally installed Git Path Config. + if ($gitType -eq 'VENDOR') { + # If User Git is installed replace its path config with Newer Vendored Git Path + if (($null -ne $gitPathUser) -and ($gitPathUser -ne '')) { + Write-Verbose "Cmder 'profile.ps1': Replacing older user Git path '$gitPathUser' with newer vendored Git path '$gitRoot' in the system path..." + + $newPath = ($env:path -ireplace [regex]::Escape($gitPathUser), $gitRoot) + } + else { + if (-not ($env:Path -match [regex]::Escape("$gitRoot\cmd"))) { + Write-Debug "Adding $gitRoot\cmd to the path" + $newPath = $($gitRoot + "\cmd" + ";" + $env:Path) + } + + # Add "$gitRoot\mingw[32|64]\bin" to the path if exists and not done already + if ((Test-Path "$gitRoot\mingw32\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw32\bin"))) { + Write-Debug "Adding $gitRoot\mingw32\bin to the path" + $newPath = "$newPath;$gitRoot\mingw32\bin" + } + elseif ((Test-Path "$gitRoot\mingw64\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw64\bin"))) { + Write-Debug "Adding $gitRoot\mingw64\bin to the path" + $newPath = "$newPath;$gitRoot\mingw64\bin" + } + + # Add "$gitRoot\usr\bin" to the path if exists and not done already + if ((Test-Path "$gitRoot\usr\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\usr\bin"))) { + Write-Debug "Adding $gitRoot\usr\bin to the path" + $newPath = "$newPath;$gitRoot\usr\bin" + } + } + + return $newPath + } + + return $env:path +} + +function Import-Git() { + $GitModule = Get-Module -Name Posh-Git -ListAvailable + if ($GitModule | Select-Object version | Where-Object version -le ([version]"0.6.1.20160330")) { + Import-Module Posh-Git > $null + } + if ($GitModule | Select-Object version | Where-Object version -ge ([version]"1.0.0")) { + Import-Module Posh-Git > $null + $GitPromptSettings.AnsiConsole = $false + } + if (-not $GitModule) { + Write-Host -NoNewline "`r`n" + Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart Cmder." + Write-Host -NoNewline "`r$([char]0x1B)[A" + return $false + } + # Make sure we only run once by always returning true + return $true +} + +function checkGit($Path) { + if (-not (Get-Command git -ErrorAction SilentlyContinue)) { + return + } + if (-not (Test-Path -Path (Join-Path $Path '.git'))) { + $SplitPath = Split-Path $path + if ($SplitPath) { checkGit($SplitPath) } + return + } + if (getGitStatusSetting -eq $true) { + if ($null -eq $env:gitLoaded) { + $env:gitLoaded = Import-Git + } + if ($env:gitLoaded -eq $true) { + Write-VcsStatus + } + } + else { + $headContent = Get-Content (Join-Path $Path '.git/HEAD') + if ($headContent -like "ref: refs/heads/*") { + $branchName = $headContent.Substring(16) + } + else { + $branchName = "HEAD detached at $($headContent.Substring(0, 7))" + } + Write-Host " [$branchName]" -NoNewline -ForegroundColor White + } +} + +function getGitStatusSetting() { + $gitStatus = (git --no-pager config -l) | Out-String + + foreach ($line in $($gitStatus -split "`r`n")) { + if (($line -match 'cmder.status=false') -or ($line -match 'cmder.psstatus=false')) { + return $false + } + } + + return $true +} From 1cfba25beb46c74bb1debca2bcfe7ac470e96172 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 17 Oct 2024 20:00:21 +0330 Subject: [PATCH 07/18] fix conflict --- vendor/psmodules/Cmder.ps1 | 358 ++++++++++++++++++------------------- 1 file changed, 179 insertions(+), 179 deletions(-) diff --git a/vendor/psmodules/Cmder.ps1 b/vendor/psmodules/Cmder.ps1 index ec9cc2c..e3c48d4 100644 --- a/vendor/psmodules/Cmder.ps1 +++ b/vendor/psmodules/Cmder.ps1 @@ -1,179 +1,179 @@ -function readVersion($gitPath) { - $gitExecutable = "${gitPath}\git.exe" - - if (-not (Test-Path "$gitExecutable")) { - return $null - } - - $gitVersion = (cmd /c "${gitExecutable}" --version) - - if ($gitVersion -match 'git version') { - ($trash1, $trash2, $gitVersion) = $gitVersion.split(' ', 3) - } else { - pause - return $null - } - - return $gitVersion.toString() -} - -function isGitShim($gitPath) { - # check if there is a shim file - if yes, read the actual executable path - # See: github.com/ScoopInstaller/Shim - - if (Test-Path "${gitPath}\git.shim") { - $shim = (get-content "${gitPath}\git.shim") - ($trash, $gitPath) = $shim.replace(' ', '').split('=') - - $gitPath = $gitPath.replace('\git.exe', '') - } - - return $gitPath.toString() -} - -function compareVersions($userVersion, $vendorVersion) { - if ($null -ne $userVersion) { - ($userMajor, $userMinor, $userPatch, $userBuild) = $userVersion.split('.', 4) - } else { - return -1 - } - - if ($null -ne $vendorVersion) { - ($vendorMajor, $vendorMinor, $vendorPatch, $vendorBuild) = $vendorVersion.split('.', 4) - } else { - return 1 - } - - if (($userMajor -eq $vendorMajor) -and ($userMinor -eq $vendorMinor) -and ($userPatch -eq $vendorPatch) -and ($userBuild -eq $vendorBuild)) { - return 1 - } - - if ($userMajor -gt $vendorMajor) { return 1 } - if ($userMajor -lt $vendorMajor) { return -1 } - - if ($userMinor -gt $vendorMinor) { return 1 } - if ($userMinor -lt $vendorMinor) { return -1 } - - if ($userPatch -gt $vendorPatch) { return 1 } - if ($userPatch -lt $vendorPatch) { return -1 } - - if ($userBuild -gt $vendorBuild) { return 1 } - if ($userBuild -lt $vendorBuild) { return -1 } - - return 0 -} - -function compare_git_versions($userVersion, $vendorVersion) { - $result = compareVersions -userVersion $userVersion -vendorVersion $vendorVersion - - Write-Debug "Compare Versions Result: ${result}" - if ($result -ge 0) { - return $userVersion - } - else { - return $vendorVersion - } -} - -function Configure-Git($gitRoot, $gitType, $gitPathUser) { - # Proposed Behavior - - # Modify the path if we are using VENDORED Git, do nothing if using USER Git. - # If User Git is installed but is older, match its path config adding paths - # in the same path positions allowing a user to configure Cmder Git path - # using locally installed Git Path Config. - if ($gitType -eq 'VENDOR') { - # If User Git is installed replace its path config with Newer Vendored Git Path - if (($null -ne $gitPathUser) -and ($gitPathUser -ne '')) { - Write-Verbose "Cmder 'profile.ps1': Replacing older user Git path '$gitPathUser' with newer vendored Git path '$gitRoot' in the system path..." - - $newPath = ($env:path -ireplace [regex]::Escape($gitPathUser), $gitRoot) - } - else { - if (-not ($env:Path -match [regex]::Escape("$gitRoot\cmd"))) { - Write-Debug "Adding $gitRoot\cmd to the path" - $newPath = $($gitRoot + "\cmd" + ";" + $env:Path) - } - - # Add "$gitRoot\mingw[32|64]\bin" to the path if exists and not done already - if ((Test-Path "$gitRoot\mingw32\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw32\bin"))) { - Write-Debug "Adding $gitRoot\mingw32\bin to the path" - $newPath = "$newPath;$gitRoot\mingw32\bin" - } - elseif ((Test-Path "$gitRoot\mingw64\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw64\bin"))) { - Write-Debug "Adding $gitRoot\mingw64\bin to the path" - $newPath = "$newPath;$gitRoot\mingw64\bin" - } - - # Add "$gitRoot\usr\bin" to the path if exists and not done already - if ((Test-Path "$gitRoot\usr\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\usr\bin"))) { - Write-Debug "Adding $gitRoot\usr\bin to the path" - $newPath = "$newPath;$gitRoot\usr\bin" - } - } - - return $newPath - } - - return $env:path -} - -function Import-Git() { - $GitModule = Get-Module -Name Posh-Git -ListAvailable - if ($GitModule | Select-Object version | Where-Object version -le ([version]"0.6.1.20160330")) { - Import-Module Posh-Git > $null - } - if ($GitModule | Select-Object version | Where-Object version -ge ([version]"1.0.0")) { - Import-Module Posh-Git > $null - $GitPromptSettings.AnsiConsole = $false - } - if (-not $GitModule) { - Write-Host -NoNewline "`r`n" - Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart Cmder." - Write-Host -NoNewline "`r$([char]0x1B)[A" - return $false - } - # Make sure we only run once by always returning true - return $true -} - -function checkGit($Path) { - if (-not (Get-Command git -ErrorAction SilentlyContinue)) { - return - } - if (-not (Test-Path -Path (Join-Path $Path '.git'))) { - $SplitPath = Split-Path $path - if ($SplitPath) { checkGit($SplitPath) } - return - } - if (getGitStatusSetting -eq $true) { - if ($null -eq $env:gitLoaded) { - $env:gitLoaded = Import-Git - } - if ($env:gitLoaded -eq $true) { - Write-VcsStatus - } - } - else { - $headContent = Get-Content (Join-Path $Path '.git/HEAD') - if ($headContent -like "ref: refs/heads/*") { - $branchName = $headContent.Substring(16) - } - else { - $branchName = "HEAD detached at $($headContent.Substring(0, 7))" - } - Write-Host " [$branchName]" -NoNewline -ForegroundColor White - } -} - -function getGitStatusSetting() { - $gitStatus = (git --no-pager config -l) | Out-String - - foreach ($line in $($gitStatus -split "`r`n")) { - if (($line -match 'cmder.status=false') -or ($line -match 'cmder.psstatus=false')) { - return $false - } - } - - return $true -} +function readVersion($gitPath) { + $gitExecutable = "${gitPath}\git.exe" + + if (-not (Test-Path "$gitExecutable")) { + return $null + } + + $gitVersion = (cmd /c "${gitExecutable}" --version) + + if ($gitVersion -match 'git version') { + ($trash1, $trash2, $gitVersion) = $gitVersion.split(' ', 3) + } else { + pause + return $null + } + + return $gitVersion.toString() +} + +function isGitShim($gitPath) { + # check if there is a shim file - if yes, read the actual executable path + # See: github.com/ScoopInstaller/Shim + + if (Test-Path "${gitPath}\git.shim") { + $shim = (get-content "${gitPath}\git.shim") + ($trash, $gitPath) = $shim.replace(' ', '').split('=') + + $gitPath = $gitPath.replace('\git.exe', '') + } + + return $gitPath.toString() +} + +function compareVersions($userVersion, $vendorVersion) { + if ($null -ne $userVersion) { + ($userMajor, $userMinor, $userPatch, $userBuild) = $userVersion.split('.', 4) + } else { + return -1 + } + + if ($null -ne $vendorVersion) { + ($vendorMajor, $vendorMinor, $vendorPatch, $vendorBuild) = $vendorVersion.split('.', 4) + } else { + return 1 + } + + if (($userMajor -eq $vendorMajor) -and ($userMinor -eq $vendorMinor) -and ($userPatch -eq $vendorPatch) -and ($userBuild -eq $vendorBuild)) { + return 1 + } + + if ($userMajor -gt $vendorMajor) { return 1 } + if ($userMajor -lt $vendorMajor) { return -1 } + + if ($userMinor -gt $vendorMinor) { return 1 } + if ($userMinor -lt $vendorMinor) { return -1 } + + if ($userPatch -gt $vendorPatch) { return 1 } + if ($userPatch -lt $vendorPatch) { return -1 } + + if ($userBuild -gt $vendorBuild) { return 1 } + if ($userBuild -lt $vendorBuild) { return -1 } + + return 0 +} + +function compare_git_versions($userVersion, $vendorVersion) { + $result = compareVersions -userVersion $userVersion -vendorVersion $vendorVersion + + Write-Debug "Compare Versions Result: ${result}" + if ($result -ge 0) { + return $userVersion + } + else { + return $vendorVersion + } +} + +function Configure-Git($gitRoot, $gitType, $gitPathUser) { + # Proposed Behavior + + # Modify the path if we are using VENDORED Git, do nothing if using USER Git. + # If User Git is installed but is older, match its path config adding paths + # in the same path positions allowing a user to configure Cmder Git path + # using locally installed Git Path Config. + if ($gitType -eq 'VENDOR') { + # If User Git is installed replace its path config with Newer Vendored Git Path + if (($null -ne $gitPathUser) -and ($gitPathUser -ne '')) { + Write-Verbose "Cmder 'profile.ps1': Replacing older user Git path '$gitPathUser' with newer vendored Git path '$gitRoot' in the system path..." + + $newPath = ($env:path -ireplace [regex]::Escape($gitPathUser), $gitRoot) + } + else { + if (-not ($env:Path -match [regex]::Escape("$gitRoot\cmd"))) { + Write-Debug "Adding $gitRoot\cmd to the path" + $newPath = $($gitRoot + "\cmd" + ";" + $env:Path) + } + + # Add "$gitRoot\mingw[32|64]\bin" to the path if exists and not done already + if ((Test-Path "$gitRoot\mingw32\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw32\bin"))) { + Write-Debug "Adding $gitRoot\mingw32\bin to the path" + $newPath = "$newPath;$gitRoot\mingw32\bin" + } + elseif ((Test-Path "$gitRoot\mingw64\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\mingw64\bin"))) { + Write-Debug "Adding $gitRoot\mingw64\bin to the path" + $newPath = "$newPath;$gitRoot\mingw64\bin" + } + + # Add "$gitRoot\usr\bin" to the path if exists and not done already + if ((Test-Path "$gitRoot\usr\bin") -and -not ($env:path -match [regex]::Escape("$gitRoot\usr\bin"))) { + Write-Debug "Adding $gitRoot\usr\bin to the path" + $newPath = "$newPath;$gitRoot\usr\bin" + } + } + + return $newPath + } + + return $env:path +} + +function Import-Git() { + $GitModule = Get-Module -Name Posh-Git -ListAvailable + if ($GitModule | Select-Object version | Where-Object version -le ([version]"0.6.1.20160330")) { + Import-Module Posh-Git > $null + } + if ($GitModule | Select-Object version | Where-Object version -ge ([version]"1.0.0")) { + Import-Module Posh-Git > $null + $GitPromptSettings.AnsiConsole = $false + } + if (-not $GitModule) { + Write-Host -NoNewline "`r`n" + Write-Warning "Missing git support, install posh-git with 'Install-Module posh-git' and restart Cmder." + Write-Host -NoNewline "`r$([char]0x1B)[A" + return $false + } + # Make sure we only run once by always returning true + return $true +} + +function checkGit($Path) { + if (-not (Get-Command git -ErrorAction SilentlyContinue)) { + return + } + if (-not (Test-Path -Path (Join-Path $Path '.git'))) { + $SplitPath = Split-Path $path + if ($SplitPath) { checkGit($SplitPath) } + return + } + if (getGitStatusSetting -eq $true) { + if ($null -eq $env:gitLoaded) { + $env:gitLoaded = Import-Git + } + if ($env:gitLoaded -eq $true) { + Write-VcsStatus + } + } + else { + $headContent = Get-Content (Join-Path $Path '.git/HEAD') + if ($headContent -like "ref: refs/heads/*") { + $branchName = $headContent.Substring(16) + } + else { + $branchName = "HEAD detached at $($headContent.Substring(0, 7))" + } + Write-Host " [$branchName]" -NoNewline -ForegroundColor White + } +} + +function getGitStatusSetting() { + $gitStatus = (git --no-pager config -l) | Out-String + + foreach ($line in $($gitStatus -split "`r`n")) { + if (($line -match 'cmder.status=false') -or ($line -match 'cmder.psstatus=false')) { + return $false + } + } + + return $true +} From 42315d8cecab61757530d709f63d1c135f8a6a5b Mon Sep 17 00:00:00 2001 From: David Refoua Date: Fri, 18 Oct 2024 03:18:17 +0330 Subject: [PATCH 08/18] enable `/d` flag in `excd` by default --- vendor/bin/excd.cmd | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vendor/bin/excd.cmd b/vendor/bin/excd.cmd index c957740..a4ac4bd 100644 --- a/vendor/bin/excd.cmd +++ b/vendor/bin/excd.cmd @@ -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% From 25ccfeed772ab3060096d966c78a68aa370ba50a Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 13 Nov 2024 23:08:13 +0330 Subject: [PATCH 09/18] prevent warnings if the dir does not exist https://github.com/cmderdev/cmder/issues/121#issuecomment-654171568 --- vendor/lib/lib_path.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index d9f229b..33386f7 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -52,7 +52,7 @@ exit /b set "position=" ) - dir "%add_path%" | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL + dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL if "%ERRORLEVEL%" == "0" ( set "add_to_path=%add_path%" ) else ( From 4d15730d05698fbb691ce80e264d44a3ea5a99a4 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 13 Nov 2024 23:12:59 +0330 Subject: [PATCH 10/18] cleanup --- vendor/lib/lib_path.cmd | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index 33386f7..36f4fb1 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -1,6 +1,5 @@ @echo off - call "%~dp0lib_base.cmd" call "%%~dp0lib_console" set lib_path=call "%~dp0lib_path.cmd" @@ -32,13 +31,12 @@ exit /b :::options: ::: ::: append Append to the path env variable rather than pre-pend. -::B +::: ::: :::output: ::: ::: path Sets the path env variable if required. :::------------------------------------------------------------------------------- - if "%~1" neq "" ( set "add_path=%~1" ) else ( @@ -53,6 +51,7 @@ exit /b ) dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL + if "%ERRORLEVEL%" == "0" ( set "add_to_path=%add_path%" ) else ( @@ -135,7 +134,6 @@ exit /b exit /b - :set_found if "%ERRORLEVEL%" == "0" ( set found=1 @@ -223,7 +221,7 @@ exit /b exit /b -: set_depth +:set_depth set /a "depth=%depth%+1" exit /b @@ -239,4 +237,3 @@ exit /b %print_debug% :enhance_path_recursive "Env Var AFTER- depth=%depth%" ) exit /b - From 510178852d074c8f3d4c01c06585b6bb81cfa064 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Wed, 13 Nov 2024 23:58:11 +0330 Subject: [PATCH 11/18] add missing qualified dir https://github.com/cmderdev/cmder/pull/1961 --- vendor/init.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/init.bat b/vendor/init.bat index 1799ae4..583e0e9 100644 --- a/vendor/init.bat +++ b/vendor/init.bat @@ -426,7 +426,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 From 7ceacb63ddaa08f41fc92020a99f659f561df3e3 Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 14 Nov 2024 00:00:53 +0330 Subject: [PATCH 12/18] respect PATHEXT instead of hardcoding our own value * support other path extensions as well (e.g. `.py` commonly used) --- vendor/lib/lib_path.cmd | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index 36f4fb1..e91efab 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -10,6 +10,13 @@ if "%~1" == "/h" ( call :%* ) +setlocal enabledelayedexpansion +if not defined find_pathext ( + set "find_pathext=!PATHEXT:;= !" + set "find_pathext=!find_pathext:.=\.!" +) +endlocal & set "find_pathext=%find_pathext%" + exit /b :enhance_path @@ -50,7 +57,7 @@ exit /b set "position=" ) - dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL + dir "%add_path%" 2>NUL | findstr -i -e "%find_pathext%" >NUL if "%ERRORLEVEL%" == "0" ( set "add_to_path=%add_path%" @@ -184,7 +191,7 @@ exit /b set "position=" ) - dir "%add_path%" 2>NUL | findstr -i "\.COM \.EXE \.BAT \.CMD \.PS1 \.VBS" >NUL + dir "%add_path%" 2>NUL | findstr -i -e "%find_pathext%" >NUL if "%ERRORLEVEL%" == "0" ( set "add_to_path=%add_path%" From 126347025f9cade241beff182738b2527da7535e Mon Sep 17 00:00:00 2001 From: David Refoua Date: Thu, 14 Nov 2024 00:01:29 +0330 Subject: [PATCH 13/18] cleanup --- vendor/lib/lib_path.cmd | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/vendor/lib/lib_path.cmd b/vendor/lib/lib_path.cmd index e91efab..04f1cf3 100644 --- a/vendor/lib/lib_path.cmd +++ b/vendor/lib/lib_path.cmd @@ -87,20 +87,20 @@ exit /b echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!;" call :set_found ) - %print_debug% :enhance_path "Env Var INSIDE PATH !find_query! - found=!found!" + %print_debug% :enhance_path "Env Var INSIDE PATH !find_query! - found=!found!" if /i "!position!" == "append" ( if "!found!" == "0" ( echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:";!find_query!\"$" call :set_found ) - %print_debug% :enhance_path "Env Var END PATH !find_query! - found=!found!" + %print_debug% :enhance_path "Env Var END PATH !find_query! - found=!found!" ) else ( if "!found!" == "0" ( echo "!path!"|!WINDIR!\System32\findstr >nul /I /R /C:"^\"!find_query!;" call :set_found ) - %print_debug% :enhance_path "Env Var BEGIN PATH !find_query! - found=!found!" + %print_debug% :enhance_path "Env Var BEGIN PATH !find_query! - found=!found!" ) endlocal & set found=%found% @@ -135,8 +135,8 @@ exit /b exit /b :changed - %print_debug% :enhance_path "END Env Var - PATH=%path%" - %print_debug% :enhance_path "Env Var %find_query% - found=%found%" + %print_debug% :enhance_path "END Env Var - PATH=%path%" + %print_debug% :enhance_path "Env Var %find_query% - found=%found%" exit /b exit /b @@ -210,10 +210,10 @@ exit /b exit /b ) - %print_debug% :enhance_path_recursive "Env Var - add_path=%add_to_path%" - %print_debug% :enhance_path_recursive "Env Var - position=%position%" - %print_debug% :enhance_path_recursive "Env Var - depth=%depth%" - %print_debug% :enhance_path_recursive "Env Var - max_depth=%max_depth%" + %print_debug% :enhance_path_recursive "Env Var - add_path=%add_to_path%" + %print_debug% :enhance_path_recursive "Env Var - position=%position%" + %print_debug% :enhance_path_recursive "Env Var - depth=%depth%" + %print_debug% :enhance_path_recursive "Env Var - max_depth=%max_depth%" if %max_depth% gtr %depth% ( if "%add_to_path%" neq "" ( @@ -238,9 +238,9 @@ exit /b ) for /d %%i in ("%add_path%\*") do ( - %print_debug% :enhance_path_recursive "Env Var BEFORE - depth=%depth%" + %print_debug% :enhance_path_recursive "Env Var BEFORE - depth=%depth%" %print_debug% :enhance_path_recursive "Found Subdirectory - '%%~fi'" call :enhance_path_recursive "%%~fi" %depth% %max_depth% %position% - %print_debug% :enhance_path_recursive "Env Var AFTER- depth=%depth%" + %print_debug% :enhance_path_recursive "Env Var AFTER- depth=%depth%" ) exit /b From ebce8479ef7736b591d81b1c53517f1063706953 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Sun, 29 Dec 2024 16:23:59 -0500 Subject: [PATCH 14/18] origin/fix_launcher_overwrite --- launcher/src/CmderLauncher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 1a70b4a..94a719f 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -290,7 +290,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr 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 ( 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 { @@ -315,7 +315,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)) { From 8ea276d9bd3ebf1b57c3de1854cb6626d134aeda Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Wed, 1 Jan 2025 22:15:34 -0500 Subject: [PATCH 15/18] not set --- launcher/src/CmderLauncher.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index b0e8c91..cc1c3ea 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -289,8 +289,12 @@ 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"); } + + // Check if the user has specified a config file to use + // If cpuCfgPath is set and exists, use it. + // If userCfgPath is set and exists, use it. - if (wcscmp(cpuCfgPath, L"") == 0 && (PathFileExists(cpuCfgPath) || use_user_cfg == false)) // config/ConEmu-%COMPUTERNAME%.xml 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/ConEmu-%COMPUTERNAME%.xml file exists or /m was specified on command line, use machine specific config. { if (cfgRoot.length() == 0) // '/c [path]' was NOT specified { @@ -335,7 +339,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr } } } - else if (wcscmp(userCfgPath, L"") == 0 && PathFileExists(userCfgPath)) // config/user_conemu.xml exists, use it. + else if (wcscmp(userCfgPath, L"") != 0 && PathFileExists(userCfgPath)) // config/user_conemu.xml exists, use it. { if (cfgRoot.length() == 0) // '/c [path]' was NOT specified { @@ -439,7 +443,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr exit(1); } } - else if (wcscmp(cfgPath, L"") == 0 && PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml + else if (wcscmp(cfgPath, L"") != 0 && PathFileExists(cfgPath)) // vendor/conemu-maximus5/ConEmu.xml exists, copy vendor/conemu-maximus5/ConEmu.xml to config/user_conemu.xml { if (!CopyFile(cfgPath, userCfgPath, FALSE)) { @@ -462,7 +466,7 @@ 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/ConEmu.xml.default' config exists, copy Cmder 'vendor/ConEmu.xml.default' file to '[user specified path]/config/user_ConEmu.xml'. + else if (wcscmp(defaultCfgPath, L"") != 0) // '/c [path]' was specified and 'vendor/ConEmu.xml.default' config exists, copy Cmder 'vendor/ConEmu.xml.default' file to '[user specified path]/config/user_ConEmu.xml'. { if ( ! CopyFile(defaultCfgPath, userCfgPath, FALSE)) { From 9b5be7bd53c09c9b4af384a080cb54f0e3784ce9 Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Wed, 1 Jan 2025 22:29:41 -0500 Subject: [PATCH 16/18] cleanup --- launcher/src/CmderLauncher.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 1e15e29..2b18ad2 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -290,10 +290,6 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr PathCombine(userCfgPath, userConfigDirPath, L"user-ConEmu.xml"); } - // Check if the user has specified a config file to use - // If cpuCfgPath is set and exists, use it. - // If userCfgPath is set and exists, use it. - 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 From 05f616fd769fb5874159c9937e83912c478399df Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Wed, 1 Jan 2025 22:32:37 -0500 Subject: [PATCH 17/18] cleanup --- launcher/src/CmderLauncher.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index 2b18ad2..f565f47 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -436,9 +436,9 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr else if (!CopyFile(defaultCfgPath, cfgPath, FALSE) && PathFileExists(conEmuDir)) { 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!", MB_TITLE, MB_ICONSTOP); + (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!", MB_TITLE, MB_ICONSTOP); exit(1); } } From 74d7dd211f2c204cd00b2d0c4ebdd1e7ca4d0c5a Mon Sep 17 00:00:00 2001 From: "Dax T. Games" Date: Wed, 1 Jan 2025 22:49:02 -0500 Subject: [PATCH 18/18] cleanup --- launcher/src/CmderLauncher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/launcher/src/CmderLauncher.cpp b/launcher/src/CmderLauncher.cpp index f565f47..8d7864f 100644 --- a/launcher/src/CmderLauncher.cpp +++ b/launcher/src/CmderLauncher.cpp @@ -437,7 +437,7 @@ 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); }