SuzanneSoy / os-test-framework

Test framework to run an OS in multiple emulators, as a guest graphical / text shell on linux, and so on.
Creative Commons Zero v1.0 Universal
0 stars 0 forks source link

.sh and .bat should self-extract an executable stub for the supported platforms #15

Open SuzanneSoy opened 6 years ago

SuzanneSoy commented 6 years ago

printf (which is I think part of the POSIX standard) should make it relatively easy to produce a binary stub.

For MS-DOS, things are not that easy since not all characters can be printed to a file. The following post lists some possibilities (using debug, which is not present on all systems, producing a VBScript, using echo (can't handle all characters), set /p (/p option not present on older systems) or other built-in commands). I think the best solution would be to use echo to create a very small binary stub (a .COM and/or .EXE) which is capable of sending to STDOUT or to a file the rest of the binary data, based on a (e.g.) base64 output. The extraction would then proceed in three stages:

https://www.experts-exchange.com/questions/26372121/DOS-Batch-file-to-write-Binary.html

There might be a solution using a fixed header that can be printed by MS-DOS echo, followed by binary data that matches the entire os.bat file. The extraction would then consist in printing a tiny header, and using copy header.txt+os.bat result.exe to concatenate them.