Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I'm writing a little batch script to create a C header containing the current git commit hash.
- the bottom `echo CommitID_U >>Header` line is not working.
- I'm trying to capitalize the hash, and then append the hash to a previously echo'd line without an interveneing newline, and despite trying to disable delayed expansion and reenable it and do every trick I can think of, nothing is working.
- code:
- @ECHO OFF
- SETLOCAL EnableExtensions
- SETLOCAL EnableDelayedExpansion
- SET Header=%~dp0..\Library\include\Private\CommitID.h
- echo !Header!
- echo|set /p="#define Version_CommitID " >!Header!
- FOR /F %%A IN ('git branch --show-current') DO SET GitBranch=%%A
- FOR /F %%A IN ('git rev-parse !GitBranch!') DO SET CommitID=%%A
- SET CommitID_U=!CommitID!
- CALL :HexUpper CommitID_U
- echo !CommitID_U!
- GOTO:EOF
- :HexUpper
- FOR %%i IN ("0=0" "1=1" "2=2" "3=3" "4=4" "5=5" "6=6" "7=7" "8=8" "9=9" "a=A" "b=B" "c=C" "d=D" "e=E" "f=F") DO CALL SET "%1=%%%1:%%~i%%"
- GOTO:EOF
- echo !CommitID_U! >>!Header!
- ENDLOCAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement