I made a simple hybrid bat-bash file which works fine for me on Windows 10 Build 14316:
Code: Select all
@goto :batch_part
# Bash part
echo Hello from bash!
echo Normal syntax for variable expansion doesnt work here: %a%
echo However, using syntax \"\$name\" we can expand even CMD.EXE variables: "\$A"=$A
echo Note: variables are case-sensivite, CMD.EXE variables are uppercase
echo Other features from bash should also work
exit
:batch_part
@echo off
set a=b
bash "%~f0"
echo.
echo End of bash part
exit /b
Output:
Code: Select all
D:\CMD\my\bash_hybrid.bat: line 1: @goto: command not found
Hello from bash!
Normal syntax for variable expansion doesnt work here: %a%
However, using syntax "$name" we can expand even CMD.EXE variables: $A=b
Note: variables are case-sensivite, CMD.EXE variables are uppercase
Other features from bash should also work
End of bash part
If someone finds a better way to make hybrid batch-bash files, please post it here.
EDIT: Corrected windows version.