1

Just a theoretical question. Would it be possible to have a file that simultaneously acts as a batch file for windows and a bash file for *nix?

The way I think it would work is to have a line that is ignored by bash but in Windows jumps to some batch code.

coresdev
  • 72
  • 8
  • 3
    https://stackoverflow.com/questions/17510688/single-script-to-run-in-both-windows-batch-and-linux-bash – larsks Jun 01 '20 at 14:05
  • Thanks for that. Exactly what I was looking for. – coresdev Jun 01 '20 at 14:07
  • guess the line ending will make trouble (CRLF vs LF) and it's pain in the ass to code like this! imagine a simple comment will change return code `REM 2> /dev/null # comment` – alecxs Jun 01 '20 at 14:17
  • Yeah it does but with some complex regex you can fix the line ending problem. Microsoft why do you have to be different? – coresdev Jun 01 '20 at 14:21
  • got the idea to write complete shell script as comments at the end of .bat and just run a tail / sed into completely new file without REM and CRLF – alecxs Jun 01 '20 at 15:36

0 Answers0