I actually had use for a polyglot script at work, since in .csproj files, <PreBuildEvent> is run as a "batch" cmd script on Windows, but with bash on Linux. The simplest trick I could find was this:
rem () { ./bash-version.bash; exit $?; }
rem skip rest of script if executed by bash
rem batch script follows:
IF %blah% EQU 0 etc.