aboutsummaryrefslogtreecommitdiff
path: root/standalone/windows/ssh-keygen.cmd
blob: c4ec3cdb43ee19136bbb249272207a1121f63270 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@rem Do not use "echo off" to not affect any child calls.

@rem Enable extensions, the `verify other 2>nul` is a trick from the setlocal help
@verify other 2>nul
@setlocal enableDelayedExpansion
@if errorlevel 1 (
    @echo Unable to enable delayed expansion. Immediate expansion will be used.
    @goto fallback
)

@rem Get the absolute path to the parent directory, which is assumed to be the
@rem Git installation root.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=!git_install_root!\bin;!git_install_root!\mingw\bin;!PATH!

ssh-keygen %*
@goto end

:fallback
@rem The above script again with immediate expansion, in case delayed expansion
@rem is unavailable.
@for /F "delims=" %%I in ("%~dp0..") do @set git_install_root=%%~fI
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%PATH%

@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%

ssh-keygen %*

:end
@rem End of script